Show group memberships in a tooltip
This commit is contained in:
@@ -110,15 +110,32 @@ class UserHelper extends Base
|
||||
}
|
||||
|
||||
/**
|
||||
* Get group names(as a comma-separated list) for a given user
|
||||
* Get group names for a given user and return an associative array:
|
||||
* ['full_list'] = a comma-separated list of all group-memberships
|
||||
* ['limited_list'] = a comma-separated list limited to N groups depending on value of SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT
|
||||
* ['has_groups'] = boolean TRUE if user is member of at least one group ... else FALSE
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id User id
|
||||
* @return string
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupNames($user_id)
|
||||
public function getUsersGroupNames($user_id)
|
||||
{
|
||||
return implode(', ', array_column($this->groupMemberModel->getGroups($user_id), 'name'));
|
||||
$groups_list = array_column($this->groupMemberModel->getGroups($user_id), 'name');
|
||||
$full_list = implode(', ', $groups_list);
|
||||
|
||||
// let's reduce the array to the limit
|
||||
$limited_list = ( SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT == 0 ) ? $groups_list : array_slice($groups_list, 0 , SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT);
|
||||
// if limiting had any effect ... let's add a hint to the list, to inform the user there are more group-memberships for that user
|
||||
$limited_list = ( $groups_list == $limited_list ) ? implode(', ', $limited_list) : implode(', ', $limited_list) . ' ( >> ' . t('hover mouse over group-icon, to show all group-memberships') . ' )';
|
||||
|
||||
$has_groups = (count($groups_list)) ? true : false;
|
||||
|
||||
return array(
|
||||
'full_list' => $full_list,
|
||||
'limited_list' => $limited_list,
|
||||
'has_groups' => $has_groups
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user