Show group memberships in a tooltip

This commit is contained in:
Manfred Hoffmann 2020-04-05 20:20:12 +02:00 committed by GitHub
parent 1ee17e995a
commit b442c52acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 114 additions and 10 deletions

View File

@ -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
);
}
/**

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1416,5 +1416,7 @@ return array(
'Change to global tag' => 'Ændre til globalt mærke',
'Do you really want to make the tag "%s" global?' => 'Skal mærket "%s" gøres globalt?',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'Group membership(s):' => ':',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1416,5 +1416,7 @@ return array(
'Change to global tag' => 'Zu globalem Schlagwort machen',
'Do you really want to make the tag "%s" global?' => 'Das Schlagwort "%s" wirklich global machen?',
'Enable global tags for this project' => 'Globale Schlagworte für dieses Projekt aktivieren',
// 'Group membership(s):' => '',
'Group membership(s):' => 'Gruppen-Mitgliedschaft(en):',
'hover mouse over group-icon, to show all group-memberships' => 'Mauszeiger über das Gruppensymbol halten, um alle Gruppenmitgliedschaften anzuzeigen',
'%s is a member of the following group(s):' => '%s ist Mitglied in der/den folgenden Gruppe(n):',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -838,7 +838,6 @@ return array(
'Remove group' => 'Supprimer le groupe',
'Group removed successfully.' => 'Groupe supprimé avec succès.',
'Unable to remove this group.' => 'Impossible de supprimer ce groupe.',
// 'Group membership(s):' => '',
'Project Permissions' => 'Permissions du projet',
'Manager' => 'Gestionnaire',
'Project Manager' => 'Chef de projet',
@ -1418,4 +1417,6 @@ return array(
'Do you really want to make the tag "%s" global?' => 'Voulez-vous vraiment rendre le libellé « %s » global ?',
'Enable global tags for this project' => 'Activer les libellés globaux pour ce projet',
'Group membership(s):' => 'Membre des groupes :',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
'Do you really want to make the tag "%s" global?' => 'Valóban globálissá szeretné tenni a(z) „%s” címkét?',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
'Do you really want to make the tag "%s" global?' => 'Você realmente deseja transformar a etiqueta "%s" em etiqueta global?',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
'Do you really want to make the tag "%s" global?' => 'Tem a certeza que pretende por a etiqueta "%s" como global?',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
'Do you really want to make the tag "%s" global?' => 'Вы действительно хотите сделать метку "%s" глобальной?',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -1417,4 +1417,6 @@ return array(
// 'Do you really want to make the tag "%s" global?' => '',
// 'Enable global tags for this project' => '',
// 'Group membership(s):' => '',
// 'hover mouse over group-icon, to show all group-memberships' => '',
// '%s is a member of the following group(s):' => '',
);

View File

@ -11,7 +11,11 @@
<span><a href="mailto:<?= $this->text->e($user['email']) ?>"><?= $this->text->e($user['email']) ?></a></span>
<?php endif ?>
<?php if (! empty($this->user->getGroupNames($user['id'])) ): ?>
<span><i class="fa fa-fw fa-group aria-hidden="true"></i> <?= $this->user->getGroupNames($user['id']) ?></span>
<?php if ( SHOW_GROUP_MEMBERSHIPS_IN_USERLIST ): ?>
<?php $users_group_names = $this->user->getUsersGroupNames($user['id']); ?>
<?php $groups_list_tooltip = t('%s is a member of the following group(s):', $user['name']) . '&#10;' . $users_group_names['full_list']; ?>
<?php if ($users_group_names['has_groups']): ?>
<span><i class="fa fa-fw fa-group aria-hidden="true" title="<?= $groups_list_tooltip ?>"></i> <?= $users_group_names['limited_list'] ?></span>
<?php endif ?>
<?php endif ?>
</div>

View File

@ -14,7 +14,7 @@
</div>
<ul class="panel">
<li><?= t('Role:') ?> <strong><?= $this->user->getRoleName($user['role']) ?></strong></li>
<li><?= t('Group membership(s):') ?> <strong><?= $this->user->getGroupNames($user['id']) ?></strong></li>
<li><?= t('Group membership(s):') ?> <strong><?= $this->user->getUsersGroupNames($user['id'])['full_list'] ?></strong></li>
<li><?= t('Account type:') ?> <strong><?= $user['is_ldap_user'] ? t('Remote') : t('Local') ?></strong></li>
<li><?= $user['twofactor_activated'] == 1 ? t('Two factor authentication enabled') : t('Two factor authentication disabled') ?></li>
<li><?= t('Number of failed login:') ?> <strong><?= $user['nb_failed_login'] ?></strong></li>

View File

@ -156,5 +156,13 @@ defined('TOTP_ISSUER') or define('TOTP_ISSUER', getenv('TOTP_ISSUER') ?: 'Kanboa
// Comma separated list of fields to not synchronize when using external authentication providers
defined('EXTERNAL_AUTH_EXCLUDE_FIELDS') or define('EXTERNAL_AUTH_EXCLUDE_FIELDS', getenv('EXTERNAL_AUTH_EXCLUDE_FIELDS') ?: 'username');
// Enable or disable displaying group-memberships in userlist (true by default)
defined('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST') or define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST', getenv('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST') ?: true);
// Limit number of groups to display in userlist (The full list of group-memberships is always shown, ...
// ... when hovering the mouse over the group-icon of a given user!)
// If set to 0 ALL group-memberships will be listed (7 by default)
defined('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT') or define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT', intval(getenv('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT')) ?: 7);
// Documentation URL
defined('DOCUMENTATION_URL_PATTERN') or define('DOCUMENTATION_URL_PATTERN', getenv('DOCUMENTATION_URL_PATTERN') ?: 'https://docs.kanboard.org/en/%s/user_guide/%s.html');

View File

@ -251,3 +251,11 @@ define('TOTP_ISSUER', 'Kanboard');
// Comma separated list of fields to not synchronize when using external authentication providers
define('EXTERNAL_AUTH_EXCLUDE_FIELDS', 'username');
// Enable or disable displaying group-memberships in userlist (true by default)
define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST', true);
// Limit number of groups to display in userlist (The full list of group-memberships is always shown, ...
// ... when hovering the mouse over the group-icon of a given user!)
// If set to 0 ALL group-memberships will be listed (7 by default)
define('SHOW_GROUP_MEMBERSHIPS_IN_USERLIST_WITH_LIMIT', 7);