From 14beea6cde7131be49eda19ac93b006aa5dcc7cd Mon Sep 17 00:00:00 2001 From: Amit Udale Date: Wed, 24 May 2017 19:45:09 +0530 Subject: [PATCH 1/3] Com_hierarchy changes to check if user have sub users --- administrator/models/hierarchys.php | 5 +++++ site/helpers/hierarchy.php | 31 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/administrator/models/hierarchys.php b/administrator/models/hierarchys.php index 4f0ac94..fd9fd01 100755 --- a/administrator/models/hierarchys.php +++ b/administrator/models/hierarchys.php @@ -65,6 +65,11 @@ protected function populateState($ordering = null, $direction = null) // Filtering user_id $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . '.filter.user_id', 'filter_user_id', '', 'string')); + if (!empty($user_id)) + { + $this->setState('filter.user_id', $app->getUserStateFromRequest($this->context . '.filter.user_id', 'filter_user_id', '', 'string')); + } + // Load the parameters. $params = JComponentHelper::getParams('com_hierarchy'); $this->setState('params', $params); diff --git a/site/helpers/hierarchy.php b/site/helpers/hierarchy.php index fd1eec5..3939f5d 100644 --- a/site/helpers/hierarchy.php +++ b/site/helpers/hierarchy.php @@ -260,4 +260,35 @@ public static function getTrainingAdminExit($uid = null) return $managerId = $db->loadResult(); } } + + /** + * Check the user is manager or not + * + * @param user_Id $user_Id Id of user + * + * @return boolean + * + * @since 1.0 + */ + public function checkManager($user_Id = null) + { + if (empty($user_Id)) + { + $user_Id = JFactory::getUser()->id; + } + + if ($user_Id) + { + // Checking if the user is having subuser in hierarchy + JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models', 'hierarchys'); + $HierarchyModelHierarchys = JModelLegacy::getInstance('Hierarchys', 'HierarchyModel'); + + $HierarchyModelHierarchys->setState('filter.user_id', $user_Id); + $isManager = $HierarchyModelHierarchys->getItems(); + + return $isManager; + } + + return false; + } } From 4fc9bffc0b3309a2679f01f91461c885271e82e5 Mon Sep 17 00:00:00 2001 From: Amit Udale Date: Fri, 2 Jun 2017 17:36:39 +0530 Subject: [PATCH 2/3] Com_hierarchy changes to check if user have sub users --- site/helpers/hierarchy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/helpers/hierarchy.php b/site/helpers/hierarchy.php index 3939f5d..8a399ce 100644 --- a/site/helpers/hierarchy.php +++ b/site/helpers/hierarchy.php @@ -270,7 +270,7 @@ public static function getTrainingAdminExit($uid = null) * * @since 1.0 */ - public function checkManager($user_Id = null) + public function getSubUsers($user_Id = null) { if (empty($user_Id)) { From 2231228d5a67ef49a1df17fa5fdd277b56972903 Mon Sep 17 00:00:00 2001 From: Amit Udale Date: Sat, 3 Jun 2017 17:39:22 +0530 Subject: [PATCH 3/3] Com_hierarchy changes to check if user have sub users --- site/helpers/hierarchy.php | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/site/helpers/hierarchy.php b/site/helpers/hierarchy.php index 8a399ce..fd1eec5 100644 --- a/site/helpers/hierarchy.php +++ b/site/helpers/hierarchy.php @@ -260,35 +260,4 @@ public static function getTrainingAdminExit($uid = null) return $managerId = $db->loadResult(); } } - - /** - * Check the user is manager or not - * - * @param user_Id $user_Id Id of user - * - * @return boolean - * - * @since 1.0 - */ - public function getSubUsers($user_Id = null) - { - if (empty($user_Id)) - { - $user_Id = JFactory::getUser()->id; - } - - if ($user_Id) - { - // Checking if the user is having subuser in hierarchy - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_hierarchy/models', 'hierarchys'); - $HierarchyModelHierarchys = JModelLegacy::getInstance('Hierarchys', 'HierarchyModel'); - - $HierarchyModelHierarchys->setState('filter.user_id', $user_Id); - $isManager = $HierarchyModelHierarchys->getItems(); - - return $isManager; - } - - return false; - } }