Extract HTML from display user overview page
Server\Privileges::getHtmlForUserOverview Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
0ad9427edc
commit
c534e85a05
@ -3551,10 +3551,7 @@ class Privileges
|
||||
*/
|
||||
public function getHtmlForUserOverview($pmaThemeImage, $text_dir)
|
||||
{
|
||||
$html_output = '<div class="row"><h2>' . "\n"
|
||||
. Util::getIcon('b_usrlist')
|
||||
. __('User accounts overview') . "\n"
|
||||
. '</h2></div>' . "\n";
|
||||
global $is_createuser;
|
||||
|
||||
$password_column = 'Password';
|
||||
$server_type = Util::getServerType();
|
||||
@ -3589,6 +3586,7 @@ class Privileges
|
||||
DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
$errorMessages = '';
|
||||
if (! $res) {
|
||||
// the query failed! This may have two reasons:
|
||||
// - the user does not have enough privileges
|
||||
@ -3605,8 +3603,8 @@ class Privileges
|
||||
);
|
||||
|
||||
if (! $res) {
|
||||
$html_output .= $this->getHtmlForViewUsersError();
|
||||
$html_output .= $this->getAddUserHtmlFieldset();
|
||||
$errorMessages .= $this->getHtmlForViewUsersError();
|
||||
$errorMessages .= $this->getAddUserHtmlFieldset();
|
||||
} else {
|
||||
// This message is hardcoded because I will replace it by
|
||||
// a automatic repair feature soon.
|
||||
@ -3615,7 +3613,7 @@ class Privileges
|
||||
. 'Please run the <code>mysql_upgrade</code> command'
|
||||
. ' that should be included in your MySQL server distribution'
|
||||
. ' to solve this problem!';
|
||||
$html_output .= Message::rawError($raw)->getDisplay();
|
||||
$errorMessages .= Message::rawError($raw)->getDisplay();
|
||||
}
|
||||
$this->dbi->freeResult($res);
|
||||
} else {
|
||||
@ -3626,7 +3624,7 @@ class Privileges
|
||||
foreach ($db_rights as $right) {
|
||||
foreach ($right as $account) {
|
||||
if (empty($account['User']) && $account['Host'] == 'localhost') {
|
||||
$html_output .= Message::notice(
|
||||
$emptyUserNotice = Message::notice(
|
||||
__(
|
||||
'A user account allowing any user from localhost to '
|
||||
. 'connect is present. This will prevent other users '
|
||||
@ -3645,7 +3643,7 @@ class Privileges
|
||||
* Also not necessary if there is less than 20 privileges
|
||||
*/
|
||||
if ($this->dbi->numRows($res_all) > 20) {
|
||||
$html_output .= $this->getHtmlForInitials($array_initials);
|
||||
$initials = $this->getHtmlForInitials($array_initials);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3656,15 +3654,13 @@ class Privileges
|
||||
|| isset($_GET['showall'])
|
||||
|| $this->dbi->numRows($res) < 50
|
||||
) {
|
||||
$html_output .= $this->getUsersOverview(
|
||||
$usersOverview = $this->getUsersOverview(
|
||||
$res,
|
||||
$db_rights,
|
||||
$pmaThemeImage,
|
||||
$text_dir
|
||||
);
|
||||
} else {
|
||||
$html_output .= $this->getAddUserHtmlFieldset();
|
||||
} // end if (display overview)
|
||||
}
|
||||
|
||||
$response = Response::getInstance();
|
||||
if (! $response->isAjax()
|
||||
@ -3706,11 +3702,18 @@ class Privileges
|
||||
Message::NOTICE
|
||||
);
|
||||
}
|
||||
$html_output .= $flushnote->getDisplay();
|
||||
$flushNotice = $flushnote->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
return $html_output;
|
||||
return $this->template->render('server/privileges/user_overview', [
|
||||
'error_messages' => $errorMessages,
|
||||
'empty_user_notice' => $emptyUserNotice ?? '',
|
||||
'initials' => $initials ?? '',
|
||||
'users_overview' => $usersOverview ?? '',
|
||||
'is_createuser' => $is_createuser,
|
||||
'flush_notice' => $flushNotice ?? '',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
29
templates/server/privileges/user_overview.twig
Normal file
29
templates/server/privileges/user_overview.twig
Normal file
@ -0,0 +1,29 @@
|
||||
<div class="row">
|
||||
<h2>
|
||||
{{ get_icon('b_usrlist') }}
|
||||
{% trans 'User accounts overview' %}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
{{ error_messages|raw }}
|
||||
|
||||
{{ empty_user_notice|raw }}
|
||||
|
||||
{{ initials|raw }}
|
||||
|
||||
{% if users_overview is not empty %}
|
||||
{{ users_overview|raw }}
|
||||
{% elseif is_createuser %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<fieldset id="fieldset_add_user">
|
||||
<legend>{% trans %}New{% context %}Create new user{% endtrans %}</legend>
|
||||
<a id="add_user_anchor" href="{{ url('/server/privileges', {'adduser': true}) }}">
|
||||
{{ get_icon('b_usradd', 'Add user account'|trans) }}
|
||||
</a>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ flush_notice|raw }}
|
||||
Loading…
Reference in New Issue
Block a user