Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions administrator/models/hierarchys.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 31 additions & 0 deletions site/helpers/hierarchy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will retrun array and not boolean

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, i have used this to retrieve users under the manager so can use in drop down filters. And if he has users under him then the user is the manager.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then change the function name.. getSubUsers

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to check if the previous function name is used anywhere? If yes,you will need to change it to this new one

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this helper ? Why are we adding more things to helpers instead of removing ? Cant you simply use the models for this ?

}

return false;
}
}