From bc085442a407dfae685c4acf73bc08f6dd08b028 Mon Sep 17 00:00:00 2001 From: divyachaudhari <58217051+divyachaudhari@users.noreply.github.com> Date: Fri, 27 Aug 2021 11:37:12 +0530 Subject: [PATCH 01/16] Task #173952 Fix: Joomla 4 compatibility (#55) * Task #173952 Fix: Hierarchy compatibility * Task #173952 Fix: Hierarchy compatibility * Task #173952 Fix: com_hierarchy compatibility * Task #173952 Fix: com_hierarchy compatibility * Task #173544 Chore: Resolving comment * Task #173544 Chore: Resolving comment * Task #173544 Chore: Resolving comment --- .../assets/elements/integrations.php | 31 +++--- administrator/controller.php | 8 +- administrator/controllers/hierarchy.php | 42 ++++---- administrator/controllers/hierarchys.php | 43 ++++---- administrator/helpers/hierarchy.php | 16 +-- administrator/hierarchy.php | 17 +-- administrator/models/fields/contextlist.php | 12 ++- administrator/models/fields/users.php | 10 +- administrator/models/hierarchy.php | 100 +++++++++--------- administrator/models/hierarchys.php | 16 +-- administrator/tables/hierarchy.php | 3 +- administrator/views/hierarchy/tmpl/edit.php | 30 +++--- administrator/views/hierarchy/view.html.php | 17 +-- .../views/hierarchys/tmpl/default.php | 62 ++++++----- administrator/views/hierarchys/view.csv.php | 16 ++- administrator/views/hierarchys/view.html.php | 37 ++++--- media/js/hierarchy.js | 4 +- plugins/privacy/hierarchy/hierarchy.php | 13 +-- script.hierarchy.php | 26 ++--- site/controller.php | 8 +- site/controllers/hierarchys.php | 5 +- site/helpers/hierarchy.php | 16 +-- site/hierarchy.php | 17 +-- site/models/hierarchys.php | 16 +-- site/views/hierarchys/tmpl/chart.php | 28 ++--- site/views/hierarchys/tmpl/default.php | 17 +-- site/views/hierarchys/tmpl/list.php | 33 +++--- site/views/hierarchys/view.html.php | 31 ++++-- 28 files changed, 380 insertions(+), 294 deletions(-) diff --git a/administrator/assets/elements/integrations.php b/administrator/assets/elements/integrations.php index 0fd9831..b9e2e71 100644 --- a/administrator/assets/elements/integrations.php +++ b/administrator/assets/elements/integrations.php @@ -8,7 +8,10 @@ */ defined('_JEXEC') or die('Restricted access'); -jimport('joomla.form.formfield'); +use Joomla\CMS\Form\FormField; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Filesystem\File; /** * JFormFieldIntegrations class @@ -17,7 +20,7 @@ * @subpackage component * @since 1.0 */ -class JFormFieldIntegrations extends JFormField +class FormFieldIntegrations extends FormField { /** *Function to construct a hierarchy view @@ -63,37 +66,37 @@ public function fetchElement ($name, $value, $controlName) if ($name == 'jform[integration]') { $options = array(); - $options[] = JHtml::_('select.option', '2', JText::_('COM_HIERARCHY_NATIVE')); + $options[] = HTMLHelper::_('select.option', '2', Text::_('COM_HIERARCHY_NATIVE')); - if (JFile::exists($this->communityMainFile)) + if (File::exists($this->communityMainFile)) { - $options[] = JHtml::_('select.option', '1', JText::_('COM_HIERARCHY_JOMSOCIAL')); + $options[] = HTMLHelper::_('select.option', '1', Text::_('COM_HIERARCHY_JOMSOCIAL')); } - if (JFile::exists($this->jeventsMainFile)) + if (File::exists($this->jeventsMainFile)) { - $options[] = JHtml::_('select.option', '3', JText::_('COM_HIERARCHY_JEVENT')); + $options[] = HTMLHelper::_('select.option', '3', Text::_('COM_HIERARCHY_JEVENT')); } - if (JFile::exists($this->esMainFile)) + if (File::exists($this->esMainFile)) { - $options[] = JHtml::_('select.option', '4', JText::_('COM_HIERARCHY_EASYSOCIAL')); + $options[] = HTMLHelper::_('select.option', '4', Text::_('COM_HIERARCHY_EASYSOCIAL')); } - if (JFile::exists($this->easyProMainFile)) + if (File::exists($this->easyProMainFile)) { - $options[] = JHtml::_('select.option', '5', JText::_('COM_HIERARCHY_EASYPROFILE')); + $options[] = HTMLHelper::_('select.option', '5', Text::_('COM_HIERARCHY_EASYPROFILE')); } - if (JFile::exists($this->cbMainFile)) + if (File::exists($this->cbMainFile)) { - $options[] = JHtml::_('select.option', '6', JText::_('COM_HIERARCHY_COMMUNITY_BUILDER')); + $options[] = HTMLHelper::_('select.option', '6', Text::_('COM_HIERARCHY_COMMUNITY_BUILDER')); } $fieldName = $name; } - $html = JHtml::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $controlName . $name); + $html = HTMLHelper::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $controlName . $name); return $html; } diff --git a/administrator/controller.php b/administrator/controller.php index 331b1d7..546e44d 100755 --- a/administrator/controller.php +++ b/administrator/controller.php @@ -9,13 +9,15 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\Factory; /** * Hierarchy view class for the hierarchy package. * * @since 1.6 */ -class HierarchyController extends JControllerLegacy +class HierarchyController extends BaseController { /** * Method to display a view. @@ -31,8 +33,8 @@ public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/hierarchy.php'; - $view = JFactory::getApplication()->input->getCmd('view', 'hierarchys'); - JFactory::getApplication()->input->set('view', $view); + $view = Factory::getApplication()->input->getCmd('view', 'hierarchys'); + Factory::getApplication()->input->set('view', $view); parent::display($cachable, $urlparams); diff --git a/administrator/controllers/hierarchy.php b/administrator/controllers/hierarchy.php index 8681709..af5c69d 100755 --- a/administrator/controllers/hierarchy.php +++ b/administrator/controllers/hierarchy.php @@ -9,15 +9,19 @@ // No direct access defined('_JEXEC') or die; - -jimport('joomla.application.component.controllerform'); +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\CMS\Factory; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Router\Route; /** * The Hierarchy Controller * * @since 1.6 */ -class HierarchyControllerHierarchy extends JControllerForm +class HierarchyControllerHierarchy extends FormController { /** * Constructor. @@ -30,11 +34,11 @@ public function __construct() { $this->view_list = 'hierarchys'; - $this->db = JFactory::getDbo(); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); - $this->hierarchyTableObj = JTable::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $this->db)); + $this->db = Factory::getDbo(); + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); + $this->hierarchyTableObj = Table::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $this->db)); - $this->msg = JText::_('COM_HIERARCHY_REPORTEES_SAVE_MSG'); + $this->msg = Text::_('COM_HIERARCHY_REPORTEES_SAVE_MSG'); parent::__construct(); } @@ -51,21 +55,21 @@ public function __construct() public function save($key = null, $urlVar = null) { // Check for request forgeries. - JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); // Initialise variables. - $app = JFactory::getApplication(); + $app = Factory::getApplication(); $model = $this->getModel('hierarchy', 'HierarchyModel'); // Get the user data. - $data = JFactory::getApplication()->input->get('jform', array(), 'array'); + $data = Factory::getApplication()->input->get('jform', array(), 'array'); // Validate the posted data. $form = $model->getForm(); if (!$form) { - JError::raiseError(500, $model->getError()); + $app->enqueueMessage($model->getError(), 'error'); return false; } @@ -76,7 +80,7 @@ public function save($key = null, $urlVar = null) $data = $model->validate($form, $data); } - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; $data['user_id'] = $jinput->get('user_id', '', 'int'); $data['created_by'] = $jinput->get('created_by', '', 'int'); $data['modified_by'] = $jinput->get('modified_by', '', 'int'); @@ -112,7 +116,7 @@ public function save($key = null, $urlVar = null) $return = $model->save($data); } - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; $id = $input->get('id'); if (empty($id)) @@ -124,8 +128,9 @@ public function save($key = null, $urlVar = null) if ($task == 'apply') { - $redirect = JRoute::_('index.php?option=com_hierarchy&view=hierarchy&layout=edit&id=' . $id, false); - $app->redirect($redirect, $this->msg); + $redirect = Route::_('index.php?option=com_hierarchy&view=hierarchy&layout=edit&id=' . $id, false); + $app->enqueueMessage($this->msg); + $app->redirect($redirect); } // Clear the profile id from the session. @@ -138,8 +143,9 @@ public function save($key = null, $urlVar = null) } // Redirect to the list screen. - $redirect = JRoute::_('index.php?option=com_hierarchy&view=hierarchys', false); - $app->redirect($redirect, $this->msg); + $redirect = Route::_('index.php?option=com_hierarchy&view=hierarchys', false); + $app->enqueueMessage($this->msg); + $app->redirect($redirect); // Flush the data from the session. $app->setUserState('com_hierarchy.edit.hierarchy.data', null); @@ -154,7 +160,7 @@ public function save($key = null, $urlVar = null) */ public function getAutoSuggestUsers() { - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; $userId = $jinput->get('user_id', '', 'int'); // Get the model. diff --git a/administrator/controllers/hierarchys.php b/administrator/controllers/hierarchys.php index 364d59f..81f3061 100755 --- a/administrator/controllers/hierarchys.php +++ b/administrator/controllers/hierarchys.php @@ -9,16 +9,18 @@ // No direct access. defined('_JEXEC') or die; - -jimport('joomla.application.component.controlleradmin'); -jimport('joomla.filesystem.file'); +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\CMS\Factory; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; /** * The Hierarchys List Controller * * @since 1.6 */ -class HierarchyControllerHierarchys extends JControllerAdmin +class HierarchyControllerHierarchys extends AdminController { /** * Proxy for getModel @@ -47,23 +49,22 @@ public function getModel($name = 'hierarchy', $prefix = 'HierarchyModel', $confi */ public function csvImport() { - jimport('joomla.filesystem.file'); - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Start file heandling functionality $fname = $_FILES['csvfile']['name']; $rowNum = 0; - $uploadsDir = JFactory::getApplication()->getCfg('tmp_path') . '/' . $fname; - JFile::upload($_FILES['csvfile']['tmp_name'], $uploadsDir); + $uploadsDir = Factory::getApplication()->get('tmp_path') . '/' . $fname; + File::upload($_FILES['csvfile']['tmp_name'], $uploadsDir); if ($file = fopen($uploadsDir, "r")) { - $ext = JFile::getExt($uploadsDir); + $ext = File::getExt($uploadsDir); if ($ext != 'csv') { - $app->enqueueMessage(JText::_('COM_HIERARCHY_CSV_FORMAT_ERROR'), 'Message'); - $app->redirect(JRoute::_('index.php?option=com_hierarchy&view=hierarchys', false)); + $app->enqueueMessage(Text::_('COM_HIERARCHY_CSV_FORMAT_ERROR'), 'Message'); + $app->redirect(Route::_('index.php?option=com_hierarchy&view=hierarchys', false)); return; } @@ -100,14 +101,14 @@ public function csvImport() } else { - $app->enqueueMessage(JText::_('COM_HIERARCHY_IMPORT_CSV_ERROR'), 'error'); - $app->redirect(JRoute::_('index.php?option=com_hierarchy&view=hierarchys', false)); + $app->enqueueMessage(Text::_('COM_HIERARCHY_IMPORT_CSV_ERROR'), 'error'); + $app->redirect(Route::_('index.php?option=com_hierarchy&view=hierarchys', false)); return; } $model = $this->getModel(); - $userID = JFactory::getUser()->id; + $userID = Factory::getUser()->id; $data = array(); @@ -123,8 +124,10 @@ public function csvImport() $result = $model->save($data); } - $msg = JText::_('COM_HIERARCHY_IMPORT_CSV_SUCCESS_MSG'); - $app->redirect(JRoute::_('index.php?option=com_hierarchy&view=hierarchys', false), $msg); + $msg = Text::_('COM_HIERARCHY_IMPORT_CSV_SUCCESS_MSG'); + + $app->enqueueMessage($msg, 'success'); + $app->redirect(Route::_('index.php?option=com_hierarchy&view=hierarchys', false)); return; } @@ -140,7 +143,7 @@ public function csvImport() */ public function getUserId($email) { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__users')) @@ -160,7 +163,7 @@ public function getUserId($email) public function remove() { $model = $this->getModel(); - $input = JFactory::getApplication()->input; + $input = Factory::getApplication()->input; $post = $input->post; $userIds = $post->get('cid', '', 'ARRAY'); @@ -181,11 +184,11 @@ public function remove() if ($model->delete($hierarchyIds)) { - $msg = JText::_('COM_HIERARCHY_HIERARCHY_DELETED_SCUSS'); + $msg = Text::_('COM_HIERARCHY_HIERARCHY_DELETED_SCUSS'); } else { - $msg = JText::_('COM_HIERARCHY_HIERARCHY_DELETED_ERROR'); + $msg = Text::_('COM_HIERARCHY_HIERARCHY_DELETED_ERROR'); } $this->setRedirect("index.php?option=com_hierarchy&view=hierarchys", $msg); diff --git a/administrator/helpers/hierarchy.php b/administrator/helpers/hierarchy.php index ced585a..1297e53 100755 --- a/administrator/helpers/hierarchy.php +++ b/administrator/helpers/hierarchy.php @@ -9,6 +9,10 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Factory; +use Joomla\CMS\Object\CMSObject; /** * Hierarchys helper. @@ -28,7 +32,7 @@ class HierarchyHelper */ public static function addSubmenu($vName = '') { - JHtmlSidebar::addEntry(JText::_('COM_HIERARCHY_TITLE_HIERARCHYS'), 'index.php?option=com_hierarchy&view=hierarchys', $vName == 'hierarchys'); + JHtmlSidebar::addEntry(Text::_('COM_HIERARCHY_TITLE_HIERARCHYS'), 'index.php?option=com_hierarchy&view=hierarchys', $vName == 'hierarchys'); } /** @@ -41,8 +45,8 @@ public static function addSubmenu($vName = '') */ public static function getActions() { - $user = JFactory::getUser(); - $result = new JObject; + $user = Factory::getUser(); + $result = new CMSObject; $assetName = 'com_hierarchy'; @@ -65,8 +69,8 @@ public static function getActions() */ public static function getLanguageConstant() { - JText::script('JGLOBAL_VALIDATION_FORM_FAILED'); - JText::script('COM_HIERARCHY_HIERARCHY_DELETE_CONF'); - JText::script('COM_HIERARCHY_USERNAMES_DESC'); + Text::script('JGLOBAL_VALIDATION_FORM_FAILED'); + Text::script('COM_HIERARCHY_HIERARCHY_DELETE_CONF'); + Text::script('COM_HIERARCHY_USERNAMES_DESC'); } } diff --git a/administrator/hierarchy.php b/administrator/hierarchy.php index 1c0e4cf..c10d076 100755 --- a/administrator/hierarchy.php +++ b/administrator/hierarchy.php @@ -9,20 +9,25 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\MVC\Controller\BaseController; // Access check. -if (!JFactory::getUser()->authorise('core.manage', 'com_hierarchy')) +if (!Factory::getUser()->authorise('core.manage', 'com_hierarchy')) { - throw new Exception(JText::_('JERROR_ALERTNOAUTHOR')); + throw new Exception(Text::_('JERROR_ALERTNOAUTHOR')); } // Include dependancies jimport('joomla.application.component.controller'); // Initialize hierarchy js -$document = JFactory::getDocument(); -$document->addScript(JUri::root(true) . '/media/com_hierarchy/js/hierarchy.js'); +$document = Factory::getDocument(); +HTMLHelper::_('script', '/media/com_hierarchy/js/hierarchy.js'); -$controller = JControllerLegacy::getInstance('Hierarchy'); -$controller->execute(JFactory::getApplication()->input->get('task')); +$controller = BaseController::getInstance('Hierarchy'); +$controller->execute(Factory::getApplication()->input->get('task')); $controller->redirect(); diff --git a/administrator/models/fields/contextlist.php b/administrator/models/fields/contextlist.php index 3de1105..ff111b7 100644 --- a/administrator/models/fields/contextlist.php +++ b/administrator/models/fields/contextlist.php @@ -9,6 +9,10 @@ // No direct access. defined('_JEXEC') or die(); +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper; JFormHelper::loadFieldClass('list'); @@ -17,7 +21,7 @@ * * @since 1.0.0 */ -class JFormFieldContextList extends JFormFieldList +class JFormFieldContextList extends FormFieldList { /** * The form field type. @@ -44,7 +48,7 @@ class JFormFieldContextList extends JFormFieldList */ protected function getOptions() { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. @@ -57,14 +61,14 @@ protected function getOptions() $contextList = $db->loadObjectList(); $options = array(); - $options[] = JHtml::_('select.option', '0', JText::_('COM_HIERARCHY_SELECT_CONTEXT')); + $options[] = HTMLHelper::_('select.option', '0', Text::_('COM_HIERARCHY_SELECT_CONTEXT')); if (!empty($contextList)) { foreach ($contextList as $context) { $context = $context->context; - $options[] = JHtml::_('select.option', $context, $context); + $options[] = HTMLHelper::_('select.option', $context, $context); } } diff --git a/administrator/models/fields/users.php b/administrator/models/fields/users.php index 4deb8b2..cf4d148 100644 --- a/administrator/models/fields/users.php +++ b/administrator/models/fields/users.php @@ -9,6 +9,10 @@ // No direct access. defined('_JEXEC') or die(); +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Form\Field\UserField; +use Joomla\CMS\Factory; +use Joomla\CMS\HTML\HTMLHelper; JFormHelper::loadFieldClass('list'); @@ -17,7 +21,7 @@ * * @since 1.0.0 */ -class JFormFieldUsers extends JFormFieldList +class JFormFieldUsers extends FormFieldList { /** * The form field type. @@ -44,7 +48,7 @@ class JFormFieldUsers extends JFormFieldList */ protected function getOptions() { - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. @@ -61,7 +65,7 @@ protected function getOptions() foreach ($allUsers as $u) { - $options[] = JHtml::_('select.option', $u->id, $u->name); + $options[] = HTMLHelper::_('select.option', $u->id, $u->name); } if (!$this->loadExternally) diff --git a/administrator/models/hierarchy.php b/administrator/models/hierarchy.php index e478383..ae0f328 100755 --- a/administrator/models/hierarchy.php +++ b/administrator/models/hierarchy.php @@ -9,16 +9,18 @@ // No direct access. defined('_JEXEC') or die; - -jimport('joomla.application.component.modeladmin'); -jimport('joomla.database.table'); +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Plugin\PluginHelper; /** * Methods supporting a list of Hierarchy records. * * @since 1.6 */ -class HierarchyModelHierarchy extends JModelAdmin +class HierarchyModelHierarchy extends AdminModel { /** * @var string The prefix to use with controller messages. @@ -38,9 +40,9 @@ class HierarchyModelHierarchy extends JModelAdmin */ public function getTable($type = 'hierarchy', $prefix = 'HierarchyTable', $config = array()) { - JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/tables'); + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/tables'); - return JTable::getInstance($type, $prefix, $config); + return Table::getInstance($type, $prefix, $config); } /** @@ -56,7 +58,7 @@ public function getTable($type = 'hierarchy', $prefix = 'HierarchyTable', $confi public function getForm($data = array(), $loadData = true) { // Initialise variables. - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Get the form. $form = $this->loadForm('com_hierarchy.hierarchy', 'hierarchy', array('control' => 'jform', 'load_data' => $loadData)); @@ -79,7 +81,7 @@ public function getForm($data = array(), $loadData = true) protected function loadFormData() { // Check the session for previously entered form data. - $data = JFactory::getApplication()->getUserState('com_hierarchy.edit.hierarchy.data', array()); + $data = Factory::getApplication()->getUserState('com_hierarchy.edit.hierarchy.data', array()); if (empty($data)) { @@ -101,7 +103,7 @@ public function getItem($pk = null) $item = parent::getItem($pk); // Get client and client_id from URL - $jinput = JFactory::getApplication()->input; + $jinput = Factory::getApplication()->input; if (empty($item->context) && $jinput->get('client')) { @@ -142,7 +144,7 @@ public function save($data) // Validate if user_id is not specified if (!$data['user_id'] || !$data['reports_to']) { - $this->setError(JText::_('COM_HIERARCHY_INVALID_USER')); + $this->setError(Text::_('COM_HIERARCHY_INVALID_USER')); return false; } @@ -155,7 +157,7 @@ public function save($data) // Check hierarchy is already exist or not. $hierarchyId = $this->checkIfHierarchyExist($data); - $date = JFactory::getDate(); + $date = Factory::getDate(); if ($hierarchyId) { @@ -172,25 +174,23 @@ public function save($data) $isNew = empty($data['id']) ? true : false; // On before assigning manager - $dispatcher = JDispatcher::getInstance(); - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher->trigger("hierarchyOnBeforeSaveHierarchy", array($data, $isNew)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnBeforeSaveHierarchy", array($data, $isNew)); if (parent::save($data)) { $id = (int) $this->getState($this->getName() . '.id'); // On after assigning manager - $dispatcher = JDispatcher::getInstance(); - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher->trigger("hierarchyOnAfterSaveHierarchy", array($data, $isNew)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnAfterSaveHierarchy", array($data, $isNew)); return $id; } - $this->setError(JText::_('COM_HIERARCHY_SAVE_FAIL')); + $this->setError(Text::_('COM_HIERARCHY_SAVE_FAIL')); return false; } @@ -233,16 +233,16 @@ public function checkIfHierarchyExist($data) */ public function getSubUsers($id, $onlyIds = false) { - $user = JFactory::getuser($id); + $user = Factory::getuser($id); if (!$user->id) { - $this->setError(JText::_("COM_HIERARCHY_INVALID_USER")); + $this->setError(Text::_("COM_HIERARCHY_INVALID_USER")); return false; } - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); if ($onlyIds) @@ -284,16 +284,16 @@ public function getSubUsers($id, $onlyIds = false) */ public function getManagers($id) { - $user = JFactory::getuser($id); + $user = Factory::getuser($id); if (!$user->id) { - $this->setError(JText::_("COM_HIERARCHY_INVALID_USER")); + $this->setError(Text::_("COM_HIERARCHY_INVALID_USER")); return false; } - $db = JFactory::getDBO(); + $db = Factory::getDBO(); $query = $db->getQuery(true); $query->select('*'); $query->from($db->quoteName('#__hierarchy_users')); @@ -318,16 +318,16 @@ public function getManagers($id) */ public function getReportsTo($reportsTo) { - $user = JFactory::getuser($reportsTo); + $user = Factory::getuser($reportsTo); if (!$user->id) { - $this->setError(JText::_("COM_HIERARCHY_INVALID_USER")); + $this->setError(Text::_("COM_HIERARCHY_INVALID_USER")); return false; } - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); $query->select($db->quoteName(array('hu.id', 'user_id','reports_to','name','username','email'))); $query->from($db->quoteName('#__hierarchy_users', 'hu')); @@ -350,12 +350,12 @@ public function getReportsTo($reportsTo) */ public function getAutoSuggestUsers($userId) { - $app = JFactory::getApplication(); + $app = Factory::getApplication(); // Get search term $searchTerm = $app->input->get('search', '', 'STRING'); - $db = JFactory::getDbo(); + $db = Factory::getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. @@ -387,33 +387,31 @@ public function getAutoSuggestUsers($userId) */ public function delete(&$pks) { - $user = JFactory::getUser(); - $db = JFactory::getDbo(); + $user = Factory::getUser(); + $db = Factory::getDbo(); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); + Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); if (is_array($pks)) { foreach ($pks as $id) { - $hierarchyTable = JTable::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $db)); + $hierarchyTable = Table::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $db)); $hierarchyTable->load(array('id' => $id)); $data = $hierarchyTable->getProperties(); // On before removing manager - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger("hierarchyOnBeforeDeleteHierarchy", array($data)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnBeforeDeleteHierarchy", array($data)); if ($hierarchyTable->delete($data['id'])) { // On after removing manager - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger("hierarchyOnAfterDeleteHierarchy", array($data)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnAfterDeleteHierarchy", array($data)); } else { @@ -423,24 +421,22 @@ public function delete(&$pks) } else { - $hierarchyTable = JTable::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $db)); + $hierarchyTable = Table::getInstance('Hierarchy', 'HierarchyTable', array('dbo', $db)); $hierarchyTable->load(array('id' => $pks)); $data = $hierarchyTable->getProperties(); // On before removing manager - $dispatcher = JDispatcher::getInstance(); - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher->trigger("hierarchyOnBeforeDeleteHierarchy", array($data)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnBeforeDeleteHierarchy", array($data)); if ($hierarchyTable->delete($data['id'])) { // On after removing manager - $dispatcher = JDispatcher::getInstance(); - JPluginHelper::importPlugin("system"); - JPluginHelper::importPlugin("actionlog"); - $dispatcher->trigger("hierarchyOnAfterDeleteHierarchy", array($data)); + PluginHelper::importPlugin("system"); + PluginHelper::importPlugin("actionlog"); + Factory::getApplication()->triggerEvent("hierarchyOnAfterDeleteHierarchy", array($data)); } else { diff --git a/administrator/models/hierarchys.php b/administrator/models/hierarchys.php index e3e38fb..29181d9 100644 --- a/administrator/models/hierarchys.php +++ b/administrator/models/hierarchys.php @@ -8,15 +8,17 @@ */ defined('_JEXEC') or die; - -jimport('joomla.application.component.modellist'); +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; /** * Methods supporting a list of Hierarchy records. * * @since 1.6 */ -class HierarchyModelHierarchys extends JModelList +class HierarchyModelHierarchys extends ListModel { /** * Constructor. @@ -37,8 +39,8 @@ public function __construct($config = array()) ); } - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models'); - $this->hierarchyModel = JModelLegacy::getInstance('Hierarchy', 'HierarchyModel'); + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models'); + $this->hierarchyModel = BaseDatabaseModel::getInstance('Hierarchy', 'HierarchyModel'); parent::__construct($config); } @@ -58,7 +60,7 @@ public function __construct($config = array()) protected function populateState($ordering = null, $direction = null) { // Initialise variables. - $app = JFactory::getApplication('administrator'); + $app = Factory::getApplication('administrator'); // Load the filter state. $search = $app->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); @@ -71,7 +73,7 @@ protected function populateState($ordering = null, $direction = null) $this->setState('filter.context', $contextName); // Load the parameters. - $params = JComponentHelper::getParams('com_hierarchy'); + $params = ComponentHelper::getParams('com_hierarchy'); $this->setState('params', $params); // List state information. diff --git a/administrator/tables/hierarchy.php b/administrator/tables/hierarchy.php index e866302..0c2aae9 100644 --- a/administrator/tables/hierarchy.php +++ b/administrator/tables/hierarchy.php @@ -9,13 +9,14 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Table\Table; /** * hierarchy Table class * * @since 1.0.4 */ -class HierarchyTableHierarchy extends JTable +class HierarchyTableHierarchy extends Table { /** * Constructor diff --git a/administrator/views/hierarchy/tmpl/edit.php b/administrator/views/hierarchy/tmpl/edit.php index 2223e7d..0e356c1 100755 --- a/administrator/views/hierarchy/tmpl/edit.php +++ b/administrator/views/hierarchy/tmpl/edit.php @@ -9,24 +9,28 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Router\Route; -JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); -JHtml::_('behavior.tooltip'); -JHtml::_('behavior.formvalidation'); -JHtml::_('behavior.keepalive'); -$input = JFactory::getApplication()->input; +HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html'); +HTMLHelper::_('behavior.tooltip'); +HTMLHelper::_('behavior.formvalidation'); +HTMLHelper::_('behavior.keepalive'); +$input = Factory::getApplication()->input; $userId = $input->get('user_id', 0); -$JUriRoot = JUri::root(true) . '/administrator/'; +$UriRoot = Uri::root(true) . '/administrator/'; // Tokenize -$document = JFactory::getDocument(); -$document->addScript(JUri::root(true) . '/media/com_hierarchy/vendors/tokenize/jquery.tokenize.js'); -$document->addStylesheet(JUri::root(true) . '/media/com_hierarchy/vendors/tokenize/jquery.tokenize.css'); +$document = Factory::getDocument(); +HTMLHelper::_('script', '/media/com_hierarchy/vendors/tokenize/jquery.tokenize.js'); +HTMLHelper::_('stylesheet','/media/com_hierarchy/vendors/tokenize/jquery.tokenize.css'); // Call helper function HierarchyHelper::getLanguageConstant(); ?> -
+
@@ -40,16 +44,16 @@
- + - +
diff --git a/site/views/hierarchys/view.html.php b/site/views/hierarchys/view.html.php index ebd18a4..7de9c23 100755 --- a/site/views/hierarchys/view.html.php +++ b/site/views/hierarchys/view.html.php @@ -7,8 +7,15 @@ * @license GNU General Public License version 2 or later. */ defined('_JEXEC') or die; +use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Router\Route; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Component\ComponentHelper; -jimport('joomla.application.component.view'); JLoader::import('components.com_hierarchy.models.hierarchys', JPATH_SITE); /** @@ -16,7 +23,7 @@ * * @since 1.6 */ -class HierarchyViewHierarchys extends JViewLegacy +class HierarchyViewHierarchys extends HtmlView { protected $items; @@ -37,18 +44,20 @@ class HierarchyViewHierarchys extends JViewLegacy */ public function display($tpl = null) { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); + $app = Factory::getApplication(); + $user = Factory::getUser(); // Validate user login. if (empty($user->id)) { - $msg = JText::_('COM_HIERARCHY_MESSAGE_LOGIN_FIRST'); + $msg = Text::_('COM_HIERARCHY_MESSAGE_LOGIN_FIRST'); // Get current url. - $current = JUri::getInstance()->toString(); + $current = Uri::getInstance()->toString(); $url = base64_encode($current); - $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . $url, false), $msg); + + $app->enqueueMessage($msg, 'notice'); + $app->redirect(Route::_('index.php?option=com_users&view=login&return=' . $url, false)); } $this->state = $this->get('State'); @@ -59,14 +68,14 @@ public function display($tpl = null) $contextName = $this->state->get('filter_context'); $contextList = array(); - $contextList[] = JHtml::_('select.option', '0', JText::_('COM_HIERARCHY_SELECT_CONTEXT')); + $contextList[] = HTMLHelper::_('select.option', '0', Text::_('COM_HIERARCHY_SELECT_CONTEXT')); if (!empty($this->items)) { foreach ($this->items as $item) { // Get list of people who is managers of logged in user. - $this->hierarchysModel = JModelLegacy::getInstance('Hierarchys', 'HierarchyModel'); + $this->hierarchysModel = BaseDatabaseModel::getInstance('Hierarchys', 'HierarchyModel'); $this->reportingsTo = $this->hierarchysModel->getReportingTo($item->reports_to); // Get avatar @@ -75,7 +84,7 @@ public function display($tpl = null) // Context filter $context = $item->context; - $contextList[] = JHtml::_('select.option', $context, $context); + $contextList[] = HTMLHelper::_('select.option', $context, $context); } } @@ -90,7 +99,7 @@ public function display($tpl = null) $this->HierarchyFrontendHelper = new HierarchyFrontendHelper; // Get component params - $this->params = JComponentHelper::getParams('com_hierarchy'); + $this->params = ComponentHelper::getParams('com_hierarchy'); // Get permissions $this->canCreate = $user->authorise('core.create', 'com_hierarchy'); From e8eebecf6de0533dd03884062e228c7ec660d823 Mon Sep 17 00:00:00 2001 From: divyachaudhari <58217051+divyachaudhari@users.noreply.github.com> Date: Thu, 7 Oct 2021 13:54:43 +0530 Subject: [PATCH 02/16] Task #173952 Chore: Script changes (#56) --- script.hierarchy.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script.hierarchy.php b/script.hierarchy.php index 840880f..5a02719 100755 --- a/script.hierarchy.php +++ b/script.hierarchy.php @@ -16,6 +16,7 @@ use Joomla\CMS\Installer\InstallerHelper; use Joomla\CMS\Language\Text; use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Installer\Installer; /** * Hierarchy Installer @@ -110,7 +111,7 @@ public function installSqlFiles($parent) if ($buffer !== false) { - $queries = \JDatabaseDriver::splitSql($buffer) + $queries = \JDatabaseDriver::splitSql($buffer); if (count($queries) != 0) { @@ -122,7 +123,7 @@ public function installSqlFiles($parent) { $db->setQuery($query); - if (!$db->query()) + if (!$db->execute()) { $this->setMessage(Text::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), 'error'); From 68789025b3087abefe593a42c2fdd3d43bb36a31 Mon Sep 17 00:00:00 2001 From: divyachaudhari <58217051+divyachaudhari@users.noreply.github.com> Date: Thu, 7 Oct 2021 17:35:43 +0530 Subject: [PATCH 03/16] Task #173952 Chore: Table changes - changing default values for changes (#57) --- administrator/sql/install.mysql.utf8.sql | 20 ++++++++++---------- administrator/sql/updates/mysql/1.1.4.sql | 10 ++++++++++ changelog.md | 5 +++++ 3 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 administrator/sql/updates/mysql/1.1.4.sql diff --git a/administrator/sql/install.mysql.utf8.sql b/administrator/sql/install.mysql.utf8.sql index 5cb47c9..d7b2909 100755 --- a/administrator/sql/install.mysql.utf8.sql +++ b/administrator/sql/install.mysql.utf8.sql @@ -4,15 +4,15 @@ -- CREATE TABLE IF NOT EXISTS `#__hierarchy_users` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, -`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user', -`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to', -`context` VARCHAR(255) NOT NULL , -`context_id` INT(11) NOT NULL, -`created_by` INT(11) NOT NULL, -`modified_by` INT(11) NOT NULL, -`created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`state` INT(11) NOT NULL, -`note` TEXT NOT NULL, +`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user' DEFAULT 0, +`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to' DEFAULT 0, +`context` VARCHAR(255) NOT NULL DEFAULT '', +`context_id` INT(11) NOT NULL DEFAULT 0, +`created_by` INT(11) NOT NULL DEFAULT 0, +`modified_by` INT(11) NOT NULL DEFAULT 0, +`created_date` datetime NULL DEFAULT NULL, +`modified_date` datetime NULL DEFAULT NULL, +`state` INT(11) NOT NULL DEFAULT 0, +`note` TEXT NOT NULL DEFAULT '', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/administrator/sql/updates/mysql/1.1.4.sql b/administrator/sql/updates/mysql/1.1.4.sql new file mode 100644 index 0000000..ef1269b --- /dev/null +++ b/administrator/sql/updates/mysql/1.1.4.sql @@ -0,0 +1,10 @@ +-- Adding default value for all the columns + +ALTER TABLE `#__hierarchy_users` CHANGE `context` `context` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `#__hierarchy_users` CHANGE `context_id` `context_id` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `created_by` `created_by` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `modified_by` `modified_by` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime NULL DEFAULT NULL, +ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime NULL DEFAULT NULL, +ALTER TABLE `#__hierarchy_users` CHANGE `state` `state` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT NOT NULL DEFAULT ''; diff --git a/changelog.md b/changelog.md index a09ac8c..30a0bbc 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ - Feature Addition (+) - Improvement (^) +## com_hierarchy v1.1.4 + +##### ^ Improvements: +- #173952 Adding default values to the Tables for Joomla 4 Compatibility + ## com_hierarchy v1.1.3 ##### - Bug Fixes: From 8616a5a5e5504bec0c0bb249478cd7bedb6b1ccb Mon Sep 17 00:00:00 2001 From: kokbira Date: Thu, 7 Oct 2021 09:08:33 -0300 Subject: [PATCH 04/16] Little corrections on text (#50) --- README.md | 7 ++++--- script.hierarchy.php | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d96bc6a..55acbab 100644 --- a/README.md +++ b/README.md @@ -6,16 +6,17 @@ Here is a live example of how general and context specific hierarchy can be: Mark, Swapnil, Mary & Vaishali normally report to Vijay. However Mary and Vaishali have been asked to additionally report to Parth in the special context of a 'Project A' ## How to Install -Donwload the code. Package it as a Zip and install it using the Joomla extension manager. +Download the code. Package it as a Zip and install it using the Joomla extension manager. ## Configurtion -Integration Options : Core Joomla, EasySocial, JomSocial, EasyProfile, Community Builder +Integration Options: Core Joomla, EasySocial, JomSocial, EasyProfile, Community Builder ## Frontend Menus The Hierarchy management system supports the following menus on the frontend. ### My Team -Shows a list view of people directly reporting to the logged in user. List can be filtered by Context. Default (context ?) is None. +Shows a list view of people directly reporting to the logged in user. List can be filtered by Context. Default (context ?) is None. + From this view they can drill down to the user and see a short User information page and also the team that reports to that user. An Icon will let you switch to a visual representation that will show a chart view. The default layout to use can be set in menu parameters. diff --git a/script.hierarchy.php b/script.hierarchy.php index 5a02719..9e293e7 100755 --- a/script.hierarchy.php +++ b/script.hierarchy.php @@ -1,10 +1,10 @@ - * @package Com_Tjlms - * @copyright Copyright (C) 2005 - 2014. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt - * Shika is free software. This version may have been modified pursuant + * @package Com_Hierarchy + * @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see http://www.gnu.org/licenses/gpl-2.0.html + * Hierarchy Management Extension is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or * is derivative of works licensed under the GNU General Public License or * other free or open source software licenses. From ff6b65cc9438519b4118bc5962b247e38c83b736 Mon Sep 17 00:00:00 2001 From: divyachaudhari <58217051+divyachaudhari@users.noreply.github.com> Date: Wed, 8 Dec 2021 10:21:22 +0530 Subject: [PATCH 05/16] Task #173952 Chore: Changes in DB file (#58) * Task #173952 Chore: Changes in DB file * Task #173952 Chore: Changes in DB file * Task #173952 Chore: Changes in DB file * Task #173952 Chore: Changes in DB file * Task #173952 Chore: Changes in DB file --- administrator/sql/install.mysql.utf8.sql | 6 +++--- administrator/sql/updates/mysql/1.1.4.sql | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/administrator/sql/install.mysql.utf8.sql b/administrator/sql/install.mysql.utf8.sql index d7b2909..1c65d11 100755 --- a/administrator/sql/install.mysql.utf8.sql +++ b/administrator/sql/install.mysql.utf8.sql @@ -10,9 +10,9 @@ CREATE TABLE IF NOT EXISTS `#__hierarchy_users` ( `context_id` INT(11) NOT NULL DEFAULT 0, `created_by` INT(11) NOT NULL DEFAULT 0, `modified_by` INT(11) NOT NULL DEFAULT 0, -`created_date` datetime NULL DEFAULT NULL, -`modified_date` datetime NULL DEFAULT NULL, +`created_date` datetime DEFAULT NULL, +`modified_date` datetime DEFAULT NULL, `state` INT(11) NOT NULL DEFAULT 0, -`note` TEXT NOT NULL DEFAULT '', +`note` TEXT DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/administrator/sql/updates/mysql/1.1.4.sql b/administrator/sql/updates/mysql/1.1.4.sql index ef1269b..8db59f1 100644 --- a/administrator/sql/updates/mysql/1.1.4.sql +++ b/administrator/sql/updates/mysql/1.1.4.sql @@ -4,7 +4,7 @@ ALTER TABLE `#__hierarchy_users` CHANGE `context` `context` VARCHAR(255) NOT NU ALTER TABLE `#__hierarchy_users` CHANGE `context_id` `context_id` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `created_by` `created_by` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `modified_by` `modified_by` INT(11) NOT NULL DEFAULT 0; -ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime NULL DEFAULT NULL, -ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime NULL DEFAULT NULL, +ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime DEFAULT NULL, +ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime DEFAULT NULL, ALTER TABLE `#__hierarchy_users` CHANGE `state` `state` INT(11) NOT NULL DEFAULT 0; -ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT NOT NULL DEFAULT ''; +ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT DEFAULT NULL; From 0e68344662654b92a8901538e90976d111611a63 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Thu, 28 Apr 2022 17:01:37 +0530 Subject: [PATCH 06/16] Task #166370 feat: use namespace in overall product --- administrator/sql/updates/mysql/1.1.4.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/sql/updates/mysql/1.1.4.sql b/administrator/sql/updates/mysql/1.1.4.sql index 8db59f1..9ccd5b0 100644 --- a/administrator/sql/updates/mysql/1.1.4.sql +++ b/administrator/sql/updates/mysql/1.1.4.sql @@ -4,7 +4,7 @@ ALTER TABLE `#__hierarchy_users` CHANGE `context` `context` VARCHAR(255) NOT NU ALTER TABLE `#__hierarchy_users` CHANGE `context_id` `context_id` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `created_by` `created_by` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `modified_by` `modified_by` INT(11) NOT NULL DEFAULT 0; -ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime DEFAULT NULL, -ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime DEFAULT NULL, +ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime DEFAULT NULL; +ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime DEFAULT NULL; ALTER TABLE `#__hierarchy_users` CHANGE `state` `state` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT DEFAULT NULL; From 7e5a06d2c5c31daba43b0734c04093f4480c7306 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 29 Apr 2022 12:59:30 +0530 Subject: [PATCH 07/16] Task #166370 feat: use namespace in overall product --- administrator/sql/install.mysql.utf8.sql | 14 ++++---- administrator/sql/updates/mysql/1.1.2.sql | 6 ++-- administrator/sql/updates/mysql/1.1.4.sql | 2 +- administrator/sql/updates/mysql/1.1.sql | 39 +++++++++++------------ 4 files changed, 29 insertions(+), 32 deletions(-) diff --git a/administrator/sql/install.mysql.utf8.sql b/administrator/sql/install.mysql.utf8.sql index 1c65d11..e8ba576 100755 --- a/administrator/sql/install.mysql.utf8.sql +++ b/administrator/sql/install.mysql.utf8.sql @@ -4,15 +4,15 @@ -- CREATE TABLE IF NOT EXISTS `#__hierarchy_users` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, -`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user' DEFAULT 0, -`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to' DEFAULT 0, -`context` VARCHAR(255) NOT NULL DEFAULT '', -`context_id` INT(11) NOT NULL DEFAULT 0, -`created_by` INT(11) NOT NULL DEFAULT 0, -`modified_by` INT(11) NOT NULL DEFAULT 0, +`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user' DEFAULT 0, +`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to' DEFAULT 0, +`context` VARCHAR(255) NOT NULL DEFAULT '', +`context_id` INT(11) NOT NULL DEFAULT 0, +`created_by` INT(11) NOT NULL DEFAULT 0, +`modified_by` INT(11) NOT NULL DEFAULT 0, `created_date` datetime DEFAULT NULL, `modified_date` datetime DEFAULT NULL, -`state` INT(11) NOT NULL DEFAULT 0, +`state` INT(11) NOT NULL DEFAULT 0, `note` TEXT DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; diff --git a/administrator/sql/updates/mysql/1.1.2.sql b/administrator/sql/updates/mysql/1.1.2.sql index 3f23ae8..150f82b 100755 --- a/administrator/sql/updates/mysql/1.1.2.sql +++ b/administrator/sql/updates/mysql/1.1.2.sql @@ -2,7 +2,5 @@ ALTER TABLE `#__hierarchy_users` ENGINE = InnoDB; -- Change charset, collation -ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL; -ALTER TABLE `#__hierarchy_users` CHANGE `context` `context` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL; - - +ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL; +ALTER TABLE `#__hierarchy_users` CHANGE `context` `context` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''; diff --git a/administrator/sql/updates/mysql/1.1.4.sql b/administrator/sql/updates/mysql/1.1.4.sql index 9ccd5b0..5402d57 100644 --- a/administrator/sql/updates/mysql/1.1.4.sql +++ b/administrator/sql/updates/mysql/1.1.4.sql @@ -6,5 +6,5 @@ ALTER TABLE `#__hierarchy_users` CHANGE `created_by` `created_by` INT(11) NOT N ALTER TABLE `#__hierarchy_users` CHANGE `modified_by` `modified_by` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `created_date` `created_date` datetime DEFAULT NULL; ALTER TABLE `#__hierarchy_users` CHANGE `modified_date` `modified_date` datetime DEFAULT NULL; -ALTER TABLE `#__hierarchy_users` CHANGE `state` `state` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `state` `state` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `#__hierarchy_users` CHANGE `note` `note` TEXT DEFAULT NULL; diff --git a/administrator/sql/updates/mysql/1.1.sql b/administrator/sql/updates/mysql/1.1.sql index af95455..14622b4 100755 --- a/administrator/sql/updates/mysql/1.1.sql +++ b/administrator/sql/updates/mysql/1.1.sql @@ -4,25 +4,24 @@ -- CREATE TABLE IF NOT EXISTS `#__hierarchy_users` ( `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, -`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user', -`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to', -`context` VARCHAR(255) NOT NULL , -`context_id` INT(11) NOT NULL, -`created_by` INT(11) NOT NULL, -`modified_by` INT(11) NOT NULL, -`created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', -`state` INT(11) NOT NULL, -`note` TEXT NOT NULL, +`user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user' DEFAULT 0, +`reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to' DEFAULT 0, +`context` VARCHAR(255) NOT NULL DEFAULT '', +`context_id` INT(11) NOT NULL DEFAULT 0, +`created_by` INT(11) NOT NULL DEFAULT 0, +`modified_by` INT(11) NOT NULL DEFAULT 0, +`created_date` datetime DEFAULT NULL, +`modified_date` datetime DEFAULT NULL, +`state` INT(11) NOT NULL DEFAULT 0, +`note` TEXT DEFAULT NULL, PRIMARY KEY (`id`) -) DEFAULT COLLATE=utf8_general_ci; - -ALTER TABLE `#__hierarchy_users` CHANGE `user_id` `reports_to` INT(11); -ALTER TABLE `#__hierarchy_users` CHANGE `subuser_id` `user_id` INT(11); -ALTER TABLE `#__hierarchy_users` CHANGE `client` `context` varchar(255); -ALTER TABLE `#__hierarchy_users` CHANGE `client_id` `context_id` varchar(255); -ALTER TABLE `#__hierarchy_users` add column `created_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; -ALTER TABLE `#__hierarchy_users` add column `created_by` int(11) NULL DEFAULT '0' AFTER `created_date`; -ALTER TABLE `#__hierarchy_users` add column `modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `created_by`; -ALTER TABLE `#__hierarchy_users` add column `modified_by` int(11) NULL DEFAULT '0' AFTER `modified_date`; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; +ALTER TABLE `#__hierarchy_users` CHANGE `user_id` `reports_to` INT(11) NOT NULL COMMENT 'This field is to select to whom all current user reports to' DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `subuser_id` `user_id` INT(11) NOT NULL COMMENT 'This field is to store user id of user' DEFAULT 0; +ALTER TABLE `#__hierarchy_users` CHANGE `client` `context` VARCHAR(255) NOT NULL DEFAULT ''; +ALTER TABLE `#__hierarchy_users` CHANGE `client_id` `context_id` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` add column `created_date` datetime DEFAULT NULL; +ALTER TABLE `#__hierarchy_users` add column `created_by` INT(11) NOT NULL DEFAULT 0; +ALTER TABLE `#__hierarchy_users` add column `modified_date` datetime DEFAULT NULL; +ALTER TABLE `#__hierarchy_users` add column `modified_by` INT(11) NOT NULL DEFAULT 0; From afdb2c1e314b1c2ec8d2db8d658b9f397c437adb Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 29 Apr 2022 13:22:29 +0530 Subject: [PATCH 08/16] Task #166370 feat: use namespace in overall product --- administrator/models/hierarchy.php | 12 ++++++------ hierarchy.xml | 6 +++--- plugins/actionlog/hierarchy/hierarchy.php | 4 ++-- plugins/actionlog/hierarchy/hierarchy.xml | 6 +++--- plugins/privacy/hierarchy/hierarchy.xml | 6 +++--- script.hierarchy.php | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/administrator/models/hierarchy.php b/administrator/models/hierarchy.php index ae0f328..e04fe16 100755 --- a/administrator/models/hierarchy.php +++ b/administrator/models/hierarchy.php @@ -176,7 +176,7 @@ public function save($data) // On before assigning manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnBeforeSaveHierarchy", array($data, $isNew)); + Factory::getApplication()->triggerEvent("onBeforeHierarchySaveHierarchy", array($data, $isNew)); if (parent::save($data)) { @@ -185,7 +185,7 @@ public function save($data) // On after assigning manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnAfterSaveHierarchy", array($data, $isNew)); + Factory::getApplication()->triggerEvent("onAfterHierarchySaveHierarchy", array($data, $isNew)); return $id; } @@ -404,14 +404,14 @@ public function delete(&$pks) // On before removing manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnBeforeDeleteHierarchy", array($data)); + Factory::getApplication()->triggerEvent("onBeforeHierarchyDeleteHierarchy", array($data)); if ($hierarchyTable->delete($data['id'])) { // On after removing manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnAfterDeleteHierarchy", array($data)); + Factory::getApplication()->triggerEvent("onAfterHierarchyDeleteHierarchy", array($data)); } else { @@ -429,14 +429,14 @@ public function delete(&$pks) // On before removing manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnBeforeDeleteHierarchy", array($data)); + Factory::getApplication()->triggerEvent("onBeforeHierarchyDeleteHierarchy", array($data)); if ($hierarchyTable->delete($data['id'])) { // On after removing manager PluginHelper::importPlugin("system"); PluginHelper::importPlugin("actionlog"); - Factory::getApplication()->triggerEvent("hierarchyOnAfterDeleteHierarchy", array($data)); + Factory::getApplication()->triggerEvent("onAfterHierarchyDeleteHierarchy", array($data)); } else { diff --git a/hierarchy.xml b/hierarchy.xml index f3e680b..dae8a8a 100644 --- a/hierarchy.xml +++ b/hierarchy.xml @@ -1,13 +1,13 @@ com_hierarchy - 22nd Jul 2021 - Copyright (C) 2016 - 2021 Techjoomla. All rights reserved. + 29th Apr 2022 + Copyright (C) 2016 - 2022 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL Techjoomla extensions@techjoomla.com https://techjoomla.com - 1.1.3 + 2.0.0 This tool will let the admin set a ‘Reports to’ field for each user in the system. This will be updated en masse using a CSV diff --git a/plugins/actionlog/hierarchy/hierarchy.php b/plugins/actionlog/hierarchy/hierarchy.php index 354fed5..660bc9c 100644 --- a/plugins/actionlog/hierarchy/hierarchy.php +++ b/plugins/actionlog/hierarchy/hierarchy.php @@ -81,7 +81,7 @@ protected function addLog($messages, $messageLanguageKey, $context, $userId = nu * * @since 1.1.1 */ - public function hierarchyOnAfterSaveHierarchy($data, $isNew) + public function onAfterHierarchySaveHierarchy($data, $isNew) { if (!$this->params->get('logActionForAssigningManager', 1) || !$isNew) { @@ -120,7 +120,7 @@ public function hierarchyOnAfterSaveHierarchy($data, $isNew) * * @since 1.1.1 */ - public function hierarchyOnAfterDeleteHierarchy($data) + public function onAfterHierarchyDeleteHierarchy($data) { if (!$this->params->get('logActionForRemoveManager', 1) || empty($data['id'])) { diff --git a/plugins/actionlog/hierarchy/hierarchy.xml b/plugins/actionlog/hierarchy/hierarchy.xml index 0250c68..55346c6 100644 --- a/plugins/actionlog/hierarchy/hierarchy.xml +++ b/plugins/actionlog/hierarchy/hierarchy.xml @@ -1,12 +1,12 @@ plg_actionlog_hierarchy - 1.1.3 - 22nd Jul 2021 + 2.0.0 + 29th Apr 2022 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2021 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2022 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_ACTIONLOG_HIERARCHY_XML_DESCRIPTION diff --git a/plugins/privacy/hierarchy/hierarchy.xml b/plugins/privacy/hierarchy/hierarchy.xml index 7eadb46..430c127 100644 --- a/plugins/privacy/hierarchy/hierarchy.xml +++ b/plugins/privacy/hierarchy/hierarchy.xml @@ -1,12 +1,12 @@ plg_privacy_hierarchy - 1.1.3 - 22nd Jul 2021 + 2.0.0 + 29th Apr 2022 Techjoomla extensions@techjoomla.com https://techjoomla.com - Copyright (C) 2016 - 2021 Techjoomla. All rights reserved. + Copyright (C) 2016 - 2022 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL PLG_PRIVACY_HIERARCHY_XML_DESCRIPTION diff --git a/script.hierarchy.php b/script.hierarchy.php index 9e293e7..85e2525 100755 --- a/script.hierarchy.php +++ b/script.hierarchy.php @@ -2,7 +2,7 @@ /** * @version SVN: * @package Com_Hierarchy - * @copyright Copyright (C) 2016 - 2021 Techjoomla. All rights reserved. + * @copyright Copyright (C) 2016 - 2022 Techjoomla. All rights reserved. * @license GNU General Public License version 2 or later; see http://www.gnu.org/licenses/gpl-2.0.html * Hierarchy Management Extension is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includes or From 338c04583883fec907261752bfe338f78ea5fbb0 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 29 Apr 2022 13:27:36 +0530 Subject: [PATCH 09/16] Task #166370 feat: use namespace in overall product --- administrator/sql/updates/mysql/{1.1.4.sql => 2.0.0.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename administrator/sql/updates/mysql/{1.1.4.sql => 2.0.0.sql} (100%) diff --git a/administrator/sql/updates/mysql/1.1.4.sql b/administrator/sql/updates/mysql/2.0.0.sql similarity index 100% rename from administrator/sql/updates/mysql/1.1.4.sql rename to administrator/sql/updates/mysql/2.0.0.sql From 857ed7e8740d69b3001527c8058318a1fce54d8d Mon Sep 17 00:00:00 2001 From: ankush_m Date: Wed, 16 Nov 2022 15:27:34 +0530 Subject: [PATCH 10/16] Task #190386 feat: Joomla 4 related changes --- administrator/models/fields/contextlist.php | 2 +- administrator/models/fields/users.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/administrator/models/fields/contextlist.php b/administrator/models/fields/contextlist.php index ff111b7..6c04a2b 100644 --- a/administrator/models/fields/contextlist.php +++ b/administrator/models/fields/contextlist.php @@ -21,7 +21,7 @@ * * @since 1.0.0 */ -class JFormFieldContextList extends FormFieldList +class JFormFieldContextList extends JFormFieldList { /** * The form field type. diff --git a/administrator/models/fields/users.php b/administrator/models/fields/users.php index cf4d148..e408943 100644 --- a/administrator/models/fields/users.php +++ b/administrator/models/fields/users.php @@ -21,7 +21,7 @@ * * @since 1.0.0 */ -class JFormFieldUsers extends FormFieldList +class JFormFieldUsers extends JFormFieldList { /** * The form field type. From 55fd13ba6e314ef7f5c2d23bdbe282524f96437d Mon Sep 17 00:00:00 2001 From: Megha Biranje Date: Tue, 27 Jun 2023 18:40:06 +0530 Subject: [PATCH 11/16] Joomla 4 hierarchy compatibility issues --- administrator/helpers/hierarchy.php | 7 +++++-- administrator/views/hierarchys/tmpl/default.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/administrator/helpers/hierarchy.php b/administrator/helpers/hierarchy.php index 1297e53..05fdaad 100755 --- a/administrator/helpers/hierarchy.php +++ b/administrator/helpers/hierarchy.php @@ -32,9 +32,12 @@ class HierarchyHelper */ public static function addSubmenu($vName = '') { - JHtmlSidebar::addEntry(Text::_('COM_HIERARCHY_TITLE_HIERARCHYS'), 'index.php?option=com_hierarchy&view=hierarchys', $vName == 'hierarchys'); + if (JVERSION < '4.0.0') + { + JHtmlSidebar::addEntry(Text::_('COM_HIERARCHY_TITLE_HIERARCHYS'), 'index.php?option=com_hierarchy&view=hierarchys', $vName == 'hierarchys'); + } } - + /** * Gets a list of the actions that can be performed. * diff --git a/administrator/views/hierarchys/tmpl/default.php b/administrator/views/hierarchys/tmpl/default.php index 5f2807f..d6c11b3 100755 --- a/administrator/views/hierarchys/tmpl/default.php +++ b/administrator/views/hierarchys/tmpl/default.php @@ -19,7 +19,7 @@ HTMLHelper::addIncludePath(JPATH_COMPONENT.'/helpers/html'); HTMLHelper::_('bootstrap.tooltip'); HTMLHelper::_('behavior.multiselect'); -HTMLHelper::_('behavior.modal', 'a.modal'); +HTMLHelper::_('bootstrap.renderModal', 'a.modal'); HTMLHelper::_('behavior.keepalive'); // Import CSS From d4f0132f6265d0cfb55108623470ee6866a7ea65 Mon Sep 17 00:00:00 2001 From: Megha Biranje Date: Wed, 28 Jun 2023 12:32:15 +0530 Subject: [PATCH 12/16] Resolve comments --- administrator/views/hierarchys/tmpl/default.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/administrator/views/hierarchys/tmpl/default.php b/administrator/views/hierarchys/tmpl/default.php index d6c11b3..4c588e3 100755 --- a/administrator/views/hierarchys/tmpl/default.php +++ b/administrator/views/hierarchys/tmpl/default.php @@ -19,9 +19,17 @@ HTMLHelper::addIncludePath(JPATH_COMPONENT.'/helpers/html'); HTMLHelper::_('bootstrap.tooltip'); HTMLHelper::_('behavior.multiselect'); -HTMLHelper::_('bootstrap.renderModal', 'a.modal'); HTMLHelper::_('behavior.keepalive'); +if (JVERSION < '4.0.0') +{ + HTMLHelper::_('behavior.modal', 'a.modal'); +} +else +{ + HTMLHelper::_('bootstrap.renderModal', 'a.modal'); +} + // Import CSS HTMLHelper::_('script', 'jui/fielduser.min.js', array('version' => 'auto', 'relative' => true)); From 2eef721dbdf8ddb07d4fd9abcb35eed60a8640db Mon Sep 17 00:00:00 2001 From: "manasi.badave@vowellms.com" Date: Wed, 9 Aug 2023 15:28:18 +0530 Subject: [PATCH 13/16] Bug #202982 fix: User create hierarchey menu in FE it shows error. --- site/router.php | 120 +++++++++++++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 52 deletions(-) diff --git a/site/router.php b/site/router.php index 0e5edb1..4c19ce0 100755 --- a/site/router.php +++ b/site/router.php @@ -10,72 +10,88 @@ // No direct access defined('_JEXEC') or die; +use Joomla\CMS\Component\Router\RouterBase; +use Joomla\CMS\Table\Table; + +// Add Table Path +JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); + /** - * Build the route for the com_hierarchy component + * Routing class from com_tjlms * - * @param array &$query An array of URL arguments + * @subpackage com_tjlms * - * @return array The URL arguments to use to assemble the subsequent URL. - * - * @since 1.5 + * @since 1.0.0 */ -function hierarchyBuildRoute(&$query) +class HierarchyRouter extends RouterBase { - $segments = array(); - - if (isset($query['task'])) - { - $segments[] = implode('/', explode('.', $query['task'])); - - unset($query['task']); - } - - if (isset($query['view'])) - { - $segments[] = $query['view']; - - unset($query['view']); - } - - if (isset($query['id'])) - { - $segments[] = $query['id']; - - unset($query['id']); - } - - return $segments; -} - /** - * Parse the segments of a URL. + * Build the route for the com_hierarchy component * - * @param array $segments The segments of the URL to parse. + * @param array &$query An array of URL arguments * - * @return array The URL attributes to be used by the application. + * @return array The URL arguments to use to assemble the subsequent URL. * * @since 1.5 */ -function hierarchyParseRoute($segments) -{ - $vars = array(); - - // View is always the first element of the array - $vars['view'] = array_shift($segments); - - while (!empty($segments)) + public function build(&$query) { - $segment = array_pop($segments); - - if (is_numeric($segment)) + $segments = array(); + + if (isset($query['task'])) + { + $segments[] = implode('/', explode('.', $query['task'])); + + unset($query['task']); + } + + if (isset($query['view'])) { - $vars['id'] = $segment; + $segments[] = $query['view']; + + unset($query['view']); } - else + + if (isset($query['id'])) { - $vars['task'] = $vars['view'] . '.' . $segment; + $segments[] = $query['id']; + + unset($query['id']); } + + return $segments; } - - return $vars; -} + + /** + * Parse the segments of a URL. + * + * @param array $segments The segments of the URL to parse. + * + * @return array The URL attributes to be used by the application. + * + * @since 1.5 + */ + public function parse(&$segments) + { + $vars = array(); + + // View is always the first element of the array + $vars['view'] = array_shift($segments); + + while (!empty($segments)) + { + $segment = array_pop($segments); + + if (is_numeric($segment)) + { + $vars['id'] = $segment; + } + else + { + $vars['task'] = $vars['view'] . '.' . $segment; + } + } + + return $vars; + } +} \ No newline at end of file From 6641afa38bd66e01439f6115a184094bebdbc05f Mon Sep 17 00:00:00 2001 From: "manasi.badave@vowellms.com" Date: Wed, 9 Aug 2023 16:04:59 +0530 Subject: [PATCH 14/16] Bug #202982 fix: User create hierarchey menu in FE it shows error. --- site/router.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/site/router.php b/site/router.php index 4c19ce0..46939e7 100755 --- a/site/router.php +++ b/site/router.php @@ -14,12 +14,12 @@ use Joomla\CMS\Table\Table; // Add Table Path -JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); +Table::addIncludePath(JPATH_ROOT . '/administrator/components/com_hierarchy/tables'); /** - * Routing class from com_tjlms + * Routing class from com_hierarchy * - * @subpackage com_tjlms + * @subpackage com_hierarchy * * @since 1.0.0 */ @@ -37,31 +37,31 @@ class HierarchyRouter extends RouterBase public function build(&$query) { $segments = array(); - + if (isset($query['task'])) { $segments[] = implode('/', explode('.', $query['task'])); - + unset($query['task']); } - + if (isset($query['view'])) { $segments[] = $query['view']; - + unset($query['view']); } - + if (isset($query['id'])) { $segments[] = $query['id']; - + unset($query['id']); } - + return $segments; } - + /** * Parse the segments of a URL. * @@ -74,14 +74,14 @@ public function build(&$query) public function parse(&$segments) { $vars = array(); - + // View is always the first element of the array $vars['view'] = array_shift($segments); - + while (!empty($segments)) { $segment = array_pop($segments); - + if (is_numeric($segment)) { $vars['id'] = $segment; @@ -91,7 +91,7 @@ public function parse(&$segments) $vars['task'] = $vars['view'] . '.' . $segment; } } - + return $vars; } } \ No newline at end of file From 6d3c8393f57689e05c5d68ccc98a8057b3fb8bcc Mon Sep 17 00:00:00 2001 From: Vineet Jadhav Date: Mon, 23 Dec 2024 12:18:00 +0530 Subject: [PATCH 15/16] change lang const --- administrator/language/en-GB/en-GB.com_hierarchy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_hierarchy.ini b/administrator/language/en-GB/en-GB.com_hierarchy.ini index b12b03b..bbd1aaf 100755 --- a/administrator/language/en-GB/en-GB.com_hierarchy.ini +++ b/administrator/language/en-GB/en-GB.com_hierarchy.ini @@ -123,7 +123,7 @@ COM_HIERARCHY_GRAVATAR_INT_CONF="Fetch user profile pic from http://en.gravatar. COM_HIERARCHY_GRAVATAR_INT_CONF_DESC="If you enable this option then user profile pic will be taken from http://en.gravatar.com/, where most of the users profile pics available. This configuration is useful only while integration with the only Joomla." COM_HIERARCHY_INVALID_USER="Enter a valid user id" COM_HIERARCHY_INVALID_REPORTS_TO="Enter a valid reports to." -COM_HIERARCHY_SAVE_MSG="Hierarchy save successfully." +COM_HIERARCHY_SAVE_MSG="Hierarchy saved successfully." COM_HIERARCHY_FAIL_MSG="Failed to save hierarchy." COM_HIERARCHY_IMPORT_CSV_SUCCESS_MSG="Hierarchy imported successfully" COM_HIERARCHY_SET_MANAGER="Set" From 1ba8ec5125916b25d59b1bdea746a9d00c33477f Mon Sep 17 00:00:00 2001 From: Vineet Jadhav Date: Mon, 23 Dec 2024 15:50:54 +0530 Subject: [PATCH 16/16] change done --- administrator/language/en-GB/en-GB.com_hierarchy.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/administrator/language/en-GB/en-GB.com_hierarchy.ini b/administrator/language/en-GB/en-GB.com_hierarchy.ini index bbd1aaf..ab7e0a6 100755 --- a/administrator/language/en-GB/en-GB.com_hierarchy.ini +++ b/administrator/language/en-GB/en-GB.com_hierarchy.ini @@ -62,7 +62,7 @@ COM_HIERARCHY_IMPORT_CATEGORY_SUCCESSFULY="Successfully import categoryies." COM_HIERARCHY_IMPORT_SUBUSERS_CSV_DATA_WRONG="Please check CSV file, Data format is wrong." COM_HIERARCHY_HIERARCHYS_REPORT_TO="Reports to" CSV_EXPORT="Export CSV" -COM_HIERARCHY_USERS_CSV_SELECT_FILE="Select CSV File" +COM_HIERARCHY_USERS_CSV_SELECT_FILE="Select the CSV File" COM_HIERARCHY_USERS_BROWSE="Browse" COM_HIERARCHY_CSVHELP="Note: To import users from a CSV file, make sure you enter your data in the given CSV %s" COM_HIERARCHY_CSV_SAMPLE="Format"