From d91d02f44ce63b59103122e5365d3ffa0bbc98a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 16 Sep 2022 09:31:02 +0200 Subject: [PATCH] add badges in user admin --- htdocs/core/class/extrafields.class.php | 3 +++ htdocs/core/lib/usergroups.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a3925c9160a..8a1ea7222ce 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -851,6 +851,7 @@ class ExtraFields $resql = $this->db->query($sql); if ($resql) { + $count = 0; if ($this->db->num_rows($resql)) { while ($tab = $this->db->fetch_object($resql)) { if ($tab->entity != 0 && $tab->entity != $conf->entity) { @@ -890,10 +891,12 @@ class ExtraFields $this->attributes[$tab->elementtype]['csslist'][$tab->name] = $tab->csslist; $this->attributes[$tab->elementtype]['loaded'] = 1; + $count++; } } if ($elementtype) { $this->attributes[$elementtype]['loaded'] = 1; // If nothing found, we also save tag 'loaded' + $this->attributes[$elementtype]['count'] = $count; } } else { $this->error = $this->db->lasterror(); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index d252606571b..79648eddd87 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -272,7 +272,7 @@ function user_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/user/admin/user_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Users").")"; - $nbExtrafields = is_countable($extrafields->attributes['user']['label']) ? count($extrafields->attributes['user']['label']) : 0; + $nbExtrafields = $extrafields->attributes['user']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; } @@ -281,7 +281,7 @@ function user_admin_prepare_head() $head[$h][0] = DOL_URL_ROOT.'/user/admin/group_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields")." (".$langs->trans("Groups").")"; - $nbExtrafields = is_countable($extrafields->attributes['usergroup']['label']) ? count($extrafields->attributes['usergroup']['label']) : 0; + $nbExtrafields = $extrafields->attributes['usergroup']['count']; if ($nbExtrafields > 0) { $head[$h][1] .= ' '.$nbExtrafields.''; }