diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php
index 7608c1165caa..5eba7c6e3a0c 100644
--- a/libraries/classes/Server/Privileges.php
+++ b/libraries/classes/Server/Privileges.php
@@ -1647,22 +1647,6 @@ public function getUserLink(
return $html;
}
- /**
- * Returns user group edit link
- *
- * @param string $username User name
- *
- * @return string HTML code with link
- */
- public function getUserGroupEditLink($username)
- {
- return ''
- . Util::getIcon('b_usrlist', __('Edit user group'))
- . ' ';
- }
-
/**
* Returns number of defined user groups
*
@@ -1737,6 +1721,8 @@ public function getExtraDataForAjaxBehavior(
$hostname,
$username
) {
+ global $is_grantuser;
+
if (isset($GLOBALS['dbname'])) {
//if (preg_match('/\\\\(?:_|%)/i', $dbname)) {
if (preg_match('/(?' . "\n"
- . '
'
- . ' ' . "\n"
- . ''
- . (empty($_POST['username'])
- ? '' . __('Any') . ' '
- : htmlspecialchars($username) ) . ' ' . "\n"
- . '' . htmlspecialchars($hostname) . ' ' . "\n";
-
- $new_user_string .= '';
-
- if (! empty($password) || isset($_POST['pma_pw'])) {
- $new_user_string .= __('Yes');
- } else {
- $new_user_string .= ''
- . __('No')
- . ' ';
- }
-
- $new_user_string .= ' ' . "\n";
- $new_user_string .= ''
- . '' . implode(', ', $this->extractPrivInfo(null, true)) . '
'
- . ' '; //Fill in privileges here
-
- // if $cfg['Servers'][$i]['users'] and $cfg['Servers'][$i]['usergroups'] are
- // enabled
$cfgRelation = $this->relation->getRelationsParam();
- if (! empty($cfgRelation['users']) && ! empty($cfgRelation['usergroups'])) {
- $new_user_string .= ' ';
- }
-
- $new_user_string .= '';
- if (isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y') {
- $new_user_string .= __('Yes');
- } else {
- $new_user_string .= __('No');
- }
- $new_user_string .= ' ';
-
- if ($GLOBALS['is_grantuser']) {
- $new_user_string .= ''
- . $this->getUserLink('edit', $username, $hostname)
- . ' ' . "\n";
- }
-
- if ($cfgRelation['menuswork'] && $user_group_count > 0) {
- $new_user_string .= ''
- . $this->getUserGroupEditLink($username)
- . ' ' . "\n";
- }
-
- $new_user_string .= ''
- . $this->getUserLink(
- 'export',
- $username,
- $hostname,
- '',
- '',
- '',
- isset($_GET['initial']) ? $_GET['initial'] : ''
- )
- . ' ' . "\n";
-
- $new_user_string .= '';
-
- $extra_data['new_user_string'] = $new_user_string;
+ $user = [
+ 'name' => $username,
+ 'host' => $hostname,
+ 'has_password' => ! empty($password) || isset($_POST['pma_pw']),
+ 'privileges' => implode(', ', $this->extractPrivInfo(null, true)),
+ 'has_group' => ! empty($cfgRelation['users']) && ! empty($cfgRelation['usergroups']),
+ 'has_group_edit' => $cfgRelation['menuswork'] && $user_group_count > 0,
+ 'has_grant' => isset($_POST['Grant_priv']) && $_POST['Grant_priv'] == 'Y',
+ ];
+ $extra_data['new_user_string'] = $this->template->render('server/privileges/new_user_ajax', [
+ 'user' => $user,
+ 'is_grantuser' => $is_grantuser,
+ 'initial' => $_GET['initial'] ?? '',
+ ]);
/**
* Generate the string for this alphabet's initial, to update the user
diff --git a/templates/server/privileges/new_user_ajax.twig b/templates/server/privileges/new_user_ajax.twig
new file mode 100644
index 000000000000..b5fdd11b469d
--- /dev/null
+++ b/templates/server/privileges/new_user_ajax.twig
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+ {% if user.name is empty %}
+ {% trans 'Any' %}
+ {% else %}
+ {{ user.name }}
+ {% endif %}
+
+
+
+ {{ user.host }}
+
+
+ {% if user.has_password %}
+ {% trans 'Yes' %}
+ {% else %}
+ {% trans 'No' %}
+ {% endif %}
+
+
+
+ {{ user.privileges|raw }}
+
+
+ {% if user.has_group %}
+
+ {% endif %}
+
+ {{ user.has_grant ? 'Yes'|trans : 'No'|trans }}
+
+ {% if is_grantuser %}
+
+
+ {{ get_icon('b_usredit', 'Edit privileges'|trans) }}
+
+
+ {% endif %}
+ {% if user.has_group_edit %}
+
+
+ {{ get_icon('b_usrlist', 'Edit user group'|trans) }}
+
+
+ {% endif %}
+
+
+ {{ get_icon('b_tblexport', 'Export'|trans) }}
+
+
+