diff --git a/libraries/classes/Server/Privileges.php b/libraries/classes/Server/Privileges.php index bd9a87ede5..c5301127d9 100644 --- a/libraries/classes/Server/Privileges.php +++ b/libraries/classes/Server/Privileges.php @@ -1613,233 +1613,60 @@ class Privileges * Displays the fields used by the "new user" form as well as the * "change login information / copy user" form. * - * @param string $mode are we creating a new user or are we just - * changing one? (allowed values: 'new', 'change') - * @param string $username User name - * @param string $hostname Host name - * - * @global array $cfg the phpMyAdmin configuration - * @global resource $user_link the database connection + * @param string $mode are we creating a new user or are we just + * changing one? (allowed values: 'new', 'change') + * @param string $user User name + * @param string $host Host name * * @return string a HTML snippet */ public function getHtmlForLoginInformationFields( $mode = 'new', - $username = null, - $hostname = null + $user = null, + $host = null ) { - list($username_length, $hostname_length) = $this->getUsernameAndHostnameLength(); + global $pred_username, $pred_hostname, $username, $hostname, $new_username; - if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) { - $GLOBALS['pred_username'] = 'any'; + list($usernameLength, $hostnameLength) = $this->getUsernameAndHostnameLength(); + + if (isset($username) && strlen($username) === 0) { + $pred_username = 'any'; } - $html_output = '
' . "\n" - . '' . __('Login Information') . '' . "\n" - . '
' . "\n" - . '' . "\n" - . '' . "\n"; - $html_output .= '' . "\n" - . '' . "\n"; - - $html_output .= '' . "\n"; - - $html_output .= '
' - . Message::notice( - __( - 'An account already exists with the same username ' - . 'but possibly a different hostname.' - ) - )->getDisplay() - . '
'; - $html_output .= '
'; - - $html_output .= '
' . "\n" - . '' . "\n"; - - $html_output .= '' . "\n" - . ' ' . "\n" - . '' . "\n"; - - $html_output .= '' . "\n" - . Util::showHint( - __( - 'When Host table is used, this field is ignored ' - . 'and values stored in Host table are used instead.' - ) - ) - . '
' . "\n"; - - $html_output .= '
' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" - . 'Strength: ' - . ' ' - . '' . "\n" - . '
' . "\n"; - - $html_output .= '
' . "\n" - . '' . "\n" - . ' ' . "\n" - . '' . "\n" - . '
' . "\n" - . '
' - . ' ' . "\n"; - - $auth_plugin_dropdown = $this->getHtmlForAuthPluginsDropdown( - $orig_auth_plugin, + $isNew = true; + $authPluginDropdown = $this->getHtmlForAuthPluginsDropdown( + $authPlugin, $mode, 'new' ); } else { - $html_output .= __('Password Hashing Method') - . ' ' . "\n"; - $auth_plugin_dropdown = $this->getHtmlForAuthPluginsDropdown( - $orig_auth_plugin, + $isNew = false; + $authPluginDropdown = $this->getHtmlForAuthPluginsDropdown( + $authPlugin, $mode, 'old' ); } - $html_output .= $auth_plugin_dropdown; - $html_output .= '' - . Message::notice( - __( - 'This method requires using an \'SSL connection\' ' - . 'or an \'unencrypted connection that encrypts the password ' - . 'using RSA\'; while connecting to the server.' - ) - . Util::showMySQLDocu('sha256-authentication-plugin') - ) - ->getDisplay() - . '
'; - - $html_output .= '' . "\n" - // Generate password added here via jQuery - . '
' . "\n"; - - return $html_output; + return $this->template->render('server/privileges/login_information_fields', [ + 'pred_username' => $pred_username ?? null, + 'pred_hostname' => $pred_hostname ?? null, + 'username_length' => $usernameLength, + 'hostname_length' => $hostnameLength, + 'username' => $username ?? null, + 'new_username' => $new_username ?? null, + 'hostname' => $hostname ?? null, + 'this_host' => $thisHost, + 'is_change' => $mode === 'change', + 'auth_plugin' => $authPlugin, + 'auth_plugin_dropdown' => $authPluginDropdown, + 'is_new' => $isNew, + ]); } /** diff --git a/templates/server/privileges/login_information_fields.twig b/templates/server/privileges/login_information_fields.twig new file mode 100644 index 0000000000..d2af70eaa0 --- /dev/null +++ b/templates/server/privileges/login_information_fields.twig @@ -0,0 +1,87 @@ +
+ {% trans 'Login Information' %} +
+ + + + + + +
+ {{ 'An account already exists with the same username but possibly a different hostname.'|trans|notice }} +
+
+ +
+ + + + + + + {{ show_hint('When Host table is used, this field is ignored and values stored in Host table are used instead.'|trans) }} +
+ +
+ + + + + + {% trans %}Strength:{% context %}Password strength{% endtrans %} + + +
+ +
+ +   + +
+ +
+ +   + + {{ auth_plugin_dropdown|raw }} + +
+ {% filter notice %} + {% trans %} + This method requires using an 'SSL connection' or an 'unencrypted connection that encrypts the password using RSA'; while connecting to the server. + {% endtrans %} + {{ show_mysql_docu('sha256-authentication-plugin') }} + {% endfilter %} +
+
+ {# Generate password added here via jQuery #} +