diff --git a/libraries/classes/Server/UserGroups.php b/libraries/classes/Server/UserGroups.php
index 834bfb949b..1df70dcd8c 100644
--- a/libraries/classes/Server/UserGroups.php
+++ b/libraries/classes/Server/UserGroups.php
@@ -10,6 +10,7 @@ namespace PhpMyAdmin\Server;
use PhpMyAdmin\Html\Generator;
use PhpMyAdmin\Relation;
+use PhpMyAdmin\Template;
use PhpMyAdmin\Url;
use PhpMyAdmin\Util;
@@ -29,11 +30,11 @@ class UserGroups
*/
public static function getHtmlForListingUsersofAGroup($userGroup)
{
+ $users = [];
+ $numRows = 0;
$relation = new Relation($GLOBALS['dbi']);
- $html_output = '
'
- . sprintf(__('Users of \'%s\' user group'), htmlspecialchars($userGroup))
- . '
';
+ $userGroupSpecialChars = htmlspecialchars($userGroup);
$cfgRelation = $relation->getRelationsParam();
$usersTable = Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['users']);
@@ -42,28 +43,25 @@ class UserGroups
. "'";
$result = $relation->queryAsControlUser($sql_query, false);
if ($result) {
- if ($GLOBALS['dbi']->numRows($result) == 0) {
- $html_output .= ''
- . __('No users were found belonging to this user group.')
- . '
';
- } else {
- $html_output .= ''
- . '| # | ' . __('User') . ' |
'
- . '';
+ $numRows = $GLOBALS['dbi']->numRows($result);
+ if ($numRows != 0) {
$i = 0;
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
$i++;
- $html_output .= ''
- . '| ' . $i . ' | '
- . '' . htmlspecialchars($row[0]) . ' | '
- . '
';
+ $user = [];
+ $user['count'] = $i;
+ $user['user'] = $row[0];
+ $users[] = $user;
}
- $html_output .= ''
- . '
';
}
}
$GLOBALS['dbi']->freeResult($result);
- return $html_output;
+ $template = new Template();
+ return $template->render('/server/user_groups/user_listings', [
+ 'user_group_special_chars' => $userGroupSpecialChars,
+ 'num_rows' => $numRows,
+ 'users' => $users,
+ ]);
}
/**
@@ -74,29 +72,18 @@ class UserGroups
public static function getHtmlForUserGroupsTable()
{
$relation = new Relation($GLOBALS['dbi']);
- $html_output = '' . __('User groups') . '
';
$cfgRelation = $relation->getRelationsParam();
$groupTable = Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['usergroups']);
$sql_query = 'SELECT * FROM ' . $groupTable . ' ORDER BY `usergroup` ASC';
$result = $relation->queryAsControlUser($sql_query, false);
-
- if ($result && $GLOBALS['dbi']->numRows($result)) {
- $html_output .= '';
}
+ $addUserUrl = Url::getFromRoute('/server/user-groups', ['addUserGroup' => 1]);
+ $addUserIcon = Generator::getIcon('b_usradd');
$GLOBALS['dbi']->freeResult($result);
-
- $html_output .= '';
-
- return $html_output;
+ $template = new Template();
+ return $template->render('server/user_groups/user_groups', [
+ 'action' => $action,
+ 'hidden_inputs' => isset($hidden_inputs) ? $hidden_inputs : '',
+ 'result' => $result,
+ 'has_rows' => $numRows,
+ 'user_groups_values' => $userGroupsValues,
+ 'add_user_url' => $addUserUrl,
+ 'add_user_icon' => $addUserIcon,
+ ]);
}
/**
@@ -224,44 +201,22 @@ class UserGroups
public static function getHtmlToEditUserGroup($userGroup = null)
{
$relation = new Relation($GLOBALS['dbi']);
- $html_output = '';
- if ($userGroup == null) {
- $html_output .= '' . __('Add user group') . '
';
- } else {
- $html_output .= ''
- . sprintf(__('Edit user group: \'%s\''), htmlspecialchars($userGroup))
- . '
';
- }
-
- $html_output .= '
diff --git a/templates/server/user_groups/tab_list.twig b/templates/server/user_groups/tab_list.twig
new file mode 100644
index 0000000000..5b8a140278
--- /dev/null
+++ b/templates/server/user_groups/tab_list.twig
@@ -0,0 +1,13 @@
+
diff --git a/templates/server/user_groups/user_groups.twig b/templates/server/user_groups/user_groups.twig
new file mode 100644
index 0000000000..4f8b9466c8
--- /dev/null
+++ b/templates/server/user_groups/user_groups.twig
@@ -0,0 +1,49 @@
+{% trans 'User groups' %}
+{% if has_rows > 0 %}
+
+{% endif %}
+
diff --git a/templates/server/user_groups/user_listings.twig b/templates/server/user_groups/user_listings.twig
new file mode 100644
index 0000000000..54fcef6d2d
--- /dev/null
+++ b/templates/server/user_groups/user_listings.twig
@@ -0,0 +1,22 @@
+{{ 'Users of \'%s\' user group'|trans|format(user_group_special_chars) }}
+{% if num_rows == 0 %}
+ {% trans 'No users were found belonging to this user group.' %}
+{% else %}
+
+
+
+ | # |
+ {% trans 'User' %} |
+
+
+
+ {% for obj in users %}
+
+ | {{ obj.count }} |
+ {{ obj.user }} |
+
+ {% endfor %}
+
+
+
+{% endif %}