Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a1bfcdff8e
@ -1382,27 +1382,21 @@ class Privileges
|
||||
/**
|
||||
* Get HTML snippet for global privileges table with check boxes
|
||||
*
|
||||
* @param array $privTable privileges table array
|
||||
* @param array $privTable_names names of the privilege tables
|
||||
* (Data, Structure, Administration)
|
||||
* @param array $row first row from result or boolean false
|
||||
* @param array $privTable privileges table array
|
||||
* @param array $privTableNames names of the privilege tables
|
||||
* (Data, Structure, Administration)
|
||||
* @param array $row first row from result or boolean false
|
||||
*
|
||||
* @return string $html_output
|
||||
*/
|
||||
public static function getHtmlForGlobalPrivTableWithCheckboxes(
|
||||
$privTable, $privTable_names, $row
|
||||
$privTable, $privTableNames, $row
|
||||
) {
|
||||
$html_output = '';
|
||||
$html_output = Template::get('privileges/global_priv_table')
|
||||
->render(
|
||||
array(
|
||||
'privTable' => $privTable,
|
||||
'privTable_names' => $privTable_names,
|
||||
'row' => $row
|
||||
)
|
||||
);
|
||||
|
||||
return $html_output;
|
||||
return Template::get('privileges/global_priv_table')->render(array(
|
||||
'priv_table' => $privTable,
|
||||
'priv_table_names' => $privTableNames,
|
||||
'row' => $row,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3325,22 +3319,22 @@ class Privileges
|
||||
) {
|
||||
$uiData = array(
|
||||
'database' => array(
|
||||
'formId' => 'database_specific_priv',
|
||||
'subMenuLabel' => __('Database'),
|
||||
'legend' => __('Database-specific privileges'),
|
||||
'typeLabel' => __('Database'),
|
||||
'form_id' => 'database_specific_priv',
|
||||
'sub_menu_label' => __('Database'),
|
||||
'legend' => __('Database-specific privileges'),
|
||||
'type_label' => __('Database'),
|
||||
),
|
||||
'table' => array(
|
||||
'formId' => 'table_specific_priv',
|
||||
'subMenuLabel' => __('Table'),
|
||||
'legend' => __('Table-specific privileges'),
|
||||
'typeLabel' => __('Table'),
|
||||
'form_id' => 'table_specific_priv',
|
||||
'sub_menu_label' => __('Table'),
|
||||
'legend' => __('Table-specific privileges'),
|
||||
'type_label' => __('Table'),
|
||||
),
|
||||
'routine' => array(
|
||||
'formId' => 'routine_specific_priv',
|
||||
'subMenuLabel' => __('Routine'),
|
||||
'legend' => __('Routine-specific privileges'),
|
||||
'typeLabel' => __('Routine'),
|
||||
'form_id' => 'routine_specific_priv',
|
||||
'sub_menu_label' => __('Routine'),
|
||||
'legend' => __('Routine-specific privileges'),
|
||||
'type_label' => __('Routine'),
|
||||
),
|
||||
);
|
||||
|
||||
@ -3429,8 +3423,8 @@ class Privileges
|
||||
|
||||
$data = $uiData[$type];
|
||||
$data['privileges'] = $privileges;
|
||||
$data['userName'] = $username;
|
||||
$data['hostName'] = $hostname;
|
||||
$data['username'] = $username;
|
||||
$data['hostname'] = $hostname;
|
||||
$data['database'] = $dbname;
|
||||
$data['type'] = $type;
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ use PhpMyAdmin\Twig\CharsetsExtension;
|
||||
use PhpMyAdmin\Twig\I18nExtension;
|
||||
use PhpMyAdmin\Twig\MessageExtension;
|
||||
use PhpMyAdmin\Twig\SanitizeExtension;
|
||||
use PhpMyAdmin\Twig\ServerPrivilegesExtension;
|
||||
use PhpMyAdmin\Twig\UrlExtension;
|
||||
use PhpMyAdmin\Twig\UtilExtension;
|
||||
use Twig_Environment;
|
||||
@ -75,6 +76,7 @@ class Template
|
||||
$this->twig->addExtension(new I18nExtension());
|
||||
$this->twig->addExtension(new MessageExtension());
|
||||
$this->twig->addExtension(new SanitizeExtension());
|
||||
$this->twig->addExtension(new ServerPrivilegesExtension());
|
||||
$this->twig->addExtension(new UrlExtension());
|
||||
$this->twig->addExtension(new UtilExtension());
|
||||
}
|
||||
|
||||
35
libraries/classes/Twig/ServerPrivilegesExtension.php
Normal file
35
libraries/classes/Twig/ServerPrivilegesExtension.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* hold PhpMyAdmin\Twig\ServerPrivilegesExtension class
|
||||
*
|
||||
* @package PhpMyAdmin\Twig
|
||||
*/
|
||||
namespace PhpMyAdmin\Twig;
|
||||
|
||||
use Twig_Extension;
|
||||
use Twig_SimpleFunction;
|
||||
|
||||
/**
|
||||
* Class ServerPrivilegesExtension
|
||||
*
|
||||
* @package PhpMyAdmin\Twig
|
||||
*/
|
||||
class ServerPrivilegesExtension extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Returns a list of functions to add to the existing list.
|
||||
*
|
||||
* @return Twig_SimpleFunction[]
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return array(
|
||||
new Twig_SimpleFunction(
|
||||
'ServerPrivileges_formatPrivilege',
|
||||
'PhpMyAdmin\Server\Privileges::formatPrivilege',
|
||||
array('is_safe' => array('html'))
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,7 @@ use PhpMyAdmin\Twig\CharsetsExtension;
|
||||
use PhpMyAdmin\Twig\I18nExtension;
|
||||
use PhpMyAdmin\Twig\MessageExtension;
|
||||
use PhpMyAdmin\Twig\SanitizeExtension;
|
||||
use PhpMyAdmin\Twig\ServerPrivilegesExtension;
|
||||
use PhpMyAdmin\Twig\UrlExtension;
|
||||
use PhpMyAdmin\Twig\UtilExtension;
|
||||
|
||||
@ -24,6 +25,7 @@ $twig->addExtension(new CharsetsExtension());
|
||||
$twig->addExtension(new I18nExtension());
|
||||
$twig->addExtension(new MessageExtension());
|
||||
$twig->addExtension(new SanitizeExtension());
|
||||
$twig->addExtension(new ServerPrivilegesExtension());
|
||||
$twig->addExtension(new UrlExtension());
|
||||
$twig->addExtension(new UtilExtension());
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
<?php foreach ($privTable as $i => $table) : ?>
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" class="sub_checkall_box" id="checkall_<?= $privTable_names[$i] ?>_priv"
|
||||
title="<?= __('Check all') ?>" />
|
||||
<label for="checkall_<?= $privTable_names[$i] ?>_priv"><?= $privTable_names[$i] ?></label>
|
||||
</legend>
|
||||
<?php foreach ($table as $priv) : ?>
|
||||
<?php $checked = ((isset($row[$priv[0] . '_priv']) && $row[$priv[0] . '_priv'] == 'Y')
|
||||
? 'checked="checked"' : ''); ?>
|
||||
<?php $formatted_priv = \PhpMyAdmin\Server\Privileges::formatPrivilege($priv, true);?>
|
||||
<?=
|
||||
PhpMyAdmin\Template::get('privileges/global_priv_tbl_item')->render(
|
||||
array(
|
||||
'checked' => $checked,
|
||||
'formatted_priv' => $formatted_priv,
|
||||
'priv' => $priv
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
<?php endforeach; ?>
|
||||
18
templates/privileges/global_priv_table.twig
Normal file
18
templates/privileges/global_priv_table.twig
Normal file
@ -0,0 +1,18 @@
|
||||
{% for key, table in priv_table %}
|
||||
<fieldset>
|
||||
<legend>
|
||||
<input type="checkbox" class="sub_checkall_box" id="checkall_{{ priv_table_names[key] }}_priv"
|
||||
title="{% trans 'Check all' %}" />
|
||||
<label for="checkall_{{ priv_table_names[key] }}_priv">{{ priv_table_names[key] }}</label>
|
||||
</legend>
|
||||
{% for priv in table %}
|
||||
{% set checked = row[priv[0] ~ '_priv'] is defined and row[priv[0] ~ '_priv'] == 'Y' ? ' checked="checked"' %}
|
||||
{% set formatted_priv = ServerPrivileges_formatPrivilege(priv, true) %}
|
||||
{% include 'privileges/global_priv_tbl_item.twig' with {
|
||||
'checked': checked,
|
||||
'formatted_priv': formatted_priv,
|
||||
'priv': priv
|
||||
} only %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
@ -1,65 +0,0 @@
|
||||
<?php use PhpMyAdmin\Template; ?>
|
||||
<form class="submenu-item" action="server_privileges.php" id="<?= $formId; ?>" method="post">
|
||||
<?= PhpMyAdmin\Url::getHiddenInputs(); ?>
|
||||
<input type="hidden" name="username" value="<?= htmlspecialchars($userName); ?>" />
|
||||
<input type="hidden" name="hostname" value="<?= htmlspecialchars($hostName); ?>" />
|
||||
|
||||
<fieldset>
|
||||
<legend data-submenu-label="<?= $subMenuLabel; ?>">
|
||||
<?= $legend; ?>
|
||||
</legend>
|
||||
|
||||
<table class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= $typeLabel; ?></th>
|
||||
<th><?= __('Privileges'); ?></th>
|
||||
<th><?= __('Grant'); ?></th>
|
||||
<?php if ($type == 'database') : ?>
|
||||
<th><?= __('Table-specific privileges'); ?></th>
|
||||
<?php elseif ($type == 'table') : ?>
|
||||
<th><?= __('Column-specific privileges'); ?></th>
|
||||
<?php endif; ?>
|
||||
<th colspan="2"><?= __('Action'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<?php if (count($privileges) == 0) : ?>
|
||||
<?php $colspan = ($type == 'database' ? 7 : ($type == 'table' ? 6 : 5)); ?>
|
||||
<tr>
|
||||
<td colspan="<?= $colspan; ?>"><center><i><?= __('None') ?></i></center></td>
|
||||
</tr>
|
||||
<?php else : ?>
|
||||
<?php foreach ($privileges as $privilege) : ?>
|
||||
<?= Template::get('privileges/privileges_summary_row')
|
||||
->render(
|
||||
array_merge(
|
||||
$privilege,
|
||||
array(
|
||||
'type' => $type,
|
||||
)
|
||||
)
|
||||
); ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if ($type == 'database') : ?>
|
||||
<?= Template::get('privileges/add_privileges_database')
|
||||
->render(array('databases' => $databases)); ?>
|
||||
<?php elseif ($type == 'table') : ?>
|
||||
<?= Template::get('privileges/add_privileges_table')
|
||||
->render(array('database' => $database, 'tables' => $tables)); ?>
|
||||
<?php else: // routine ?>
|
||||
<?= Template::get('privileges/add_privileges_routine')
|
||||
->render(array('database' => $database, 'routines' => $routines)); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="tblFooters">
|
||||
<input type="submit" value="<?= __('Go'); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
62
templates/privileges/privileges_summary.twig
Normal file
62
templates/privileges/privileges_summary.twig
Normal file
@ -0,0 +1,62 @@
|
||||
<form class="submenu-item" action="server_privileges.php" id="{{ form_id }}" method="post">
|
||||
{{ Url_getHiddenInputs() }}
|
||||
<input type="hidden" name="username" value="{{ username }}" />
|
||||
<input type="hidden" name="hostname" value="{{ hostname }}" />
|
||||
|
||||
<fieldset>
|
||||
<legend data-submenu-label="{{ sub_menu_label }}">
|
||||
{{ legend }}
|
||||
</legend>
|
||||
|
||||
<table class="data">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ type_label }}</th>
|
||||
<th>{% trans 'Privileges' %}</th>
|
||||
<th>{% trans 'Grant' %}</th>
|
||||
{% if type == 'database' %}
|
||||
<th>{% trans 'Table-specific privileges' %}</th>
|
||||
{% elseif type == 'table' %}
|
||||
<th>{% trans 'Column-specific privileges' %}</th>
|
||||
{% endif %}
|
||||
<th colspan="2">{% trans 'Action' %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% if privileges|length == 0 %}
|
||||
{% set colspan = type == 'database' ? 7 : (type == 'table' ? 6 : 5) %}
|
||||
<tr>
|
||||
<td colspan="{{ colspan }}"><center><em>{% trans 'None' %}</em></center></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
{% for privilege in privileges %}
|
||||
{% include 'privileges/privileges_summary_row.twig' with [
|
||||
privilege|merge({'type': type})
|
||||
] only %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% if type == 'database' %}
|
||||
{% include 'privileges/add_privileges_database.twig' with {
|
||||
'databases': databases
|
||||
} only %}
|
||||
{% elseif type == 'table' %}
|
||||
{% include 'privileges/add_privileges_table.twig' with {
|
||||
'database': database,
|
||||
'tables': tables
|
||||
} only %}
|
||||
{% else %}
|
||||
{% include 'privileges/add_privileges_routine.twig' with {
|
||||
'database': database,
|
||||
'routines': routines
|
||||
} only %}
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="tblFooters">
|
||||
<input type="submit" value="{% trans 'Go' %}" />
|
||||
</fieldset>
|
||||
</form>
|
||||
@ -1,16 +0,0 @@
|
||||
<fieldset>
|
||||
<legend>SSL</legend>
|
||||
<div id="require_ssl_div">
|
||||
<?php foreach ($require_options as $require_option) : ?>
|
||||
<?php if ($require_option['name'] === 'ssl_cipher') : ?>
|
||||
<div id="specified_div" style="padding-left:20px;">
|
||||
<?php endif; ?>
|
||||
<?=
|
||||
PhpMyAdmin\Template::get('privileges/require_options_item')->render(
|
||||
array('require_option' => $require_option)
|
||||
);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</div> <!-- END specified_div -->
|
||||
</div> <!-- END require_ssl_div -->
|
||||
</fieldset>
|
||||
14
templates/privileges/require_options.twig
Normal file
14
templates/privileges/require_options.twig
Normal file
@ -0,0 +1,14 @@
|
||||
<fieldset>
|
||||
<legend>SSL</legend>
|
||||
<div id="require_ssl_div">
|
||||
{% for require_option in require_options %}
|
||||
{% if require_option['name'] is same as('ssl_cipher') %}
|
||||
<div id="specified_div" style="padding-left:20px;">
|
||||
{% endif %}
|
||||
{% include 'privileges/require_options_item.twig' with {
|
||||
'require_option': require_option
|
||||
} only %}
|
||||
{% endfor %}
|
||||
</div>{# END specified_div #}
|
||||
</div>{# END require_ssl_div #}
|
||||
</fieldset>
|
||||
@ -1,16 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><?= __('Resource limits') ?></legend>
|
||||
<p>
|
||||
<small>
|
||||
<i><?= __('Note: Setting these options to 0 (zero) removes the limit.') ?></i>
|
||||
</small>
|
||||
</p>
|
||||
<?php foreach ($limits as $limit) : ?>
|
||||
<?=
|
||||
PhpMyAdmin\Template::get('privileges/resource_limit_item')->render(
|
||||
array('limit' => $limit)
|
||||
);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
</fieldset>
|
||||
|
||||
13
templates/privileges/resource_limits.twig
Normal file
13
templates/privileges/resource_limits.twig
Normal file
@ -0,0 +1,13 @@
|
||||
<fieldset>
|
||||
<legend>{% trans 'Resource limits' %}</legend>
|
||||
<p>
|
||||
<small>
|
||||
<em><{% trans 'Note: Setting these options to 0 (zero) removes the limit.' %}</em>
|
||||
</small>
|
||||
</p>
|
||||
{% for limit in limits %}
|
||||
{% include 'privileges/resource_limit_item.twig' with {
|
||||
'limit': limit
|
||||
} only %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
@ -1,30 +0,0 @@
|
||||
<tr class="var-row <?= $rowClass; ?>">
|
||||
<td class="var-action">
|
||||
<?php if ($editable): ?>
|
||||
<a href="#" data-variable="<?= htmlspecialchars($name) ?>" class="editLink"><?= \PhpMyAdmin\Util::getIcon('b_edit.png', __('Edit')) ?></a>
|
||||
<?php else: ?>
|
||||
<span title="<?= __('This is a read-only variable and can not be edited') ?>" class="read_only_var">
|
||||
<?= \PhpMyAdmin\Util::getIcon('bd_edit.png', __('Edit')) ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="var-name">
|
||||
<?php if ($docLink != null): ?>
|
||||
<span title="<?= htmlspecialchars(str_replace('_', ' ', $name)); ?>">
|
||||
<?= \PhpMyAdmin\Util::showMySQLDocu($docLink[1], false, $docLink[2] . '_' . $docLink[0], true)
|
||||
, str_replace('_', ' ', htmlspecialchars($name))
|
||||
, '</a>'
|
||||
?>
|
||||
</span>
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars(str_replace('_', ' ', $name)); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="var-value value <?= ($isSuperuser ? ' editable' : '') ?>">
|
||||
<?php if ($isHtmlFormatted == false): ?>
|
||||
<?= str_replace(',', ',​', htmlspecialchars($value)); ?>
|
||||
<?php else: ?>
|
||||
<?= $value; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
29
templates/server/variables/variable_row.twig
Normal file
29
templates/server/variables/variable_row.twig
Normal file
@ -0,0 +1,29 @@
|
||||
<tr class="var-row {{ row_class }}">
|
||||
<td class="var-action">
|
||||
{% if editable %}
|
||||
<a href="#" data-variable="{{ name }}" class="editLink">{{ Util_getIcon('b_edit.png', 'Edit'|trans) }}</a>
|
||||
{% else %}
|
||||
<span title="{% trans 'This is a read-only variable and can not be edited' %}" class="read_only_var">
|
||||
{{ Util_getIcon('bd_edit.png', 'Edit'|trans) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="var-name">
|
||||
{% if doc_link != null %}
|
||||
<span title="{{ name|replace({'_': ' '}) }}">
|
||||
{{ Util_showMySQLDocu(doc_link[1], false, doc_link[2] ~ '_' ~ doc_link[0], true) }}
|
||||
{{ name|e|replace({'_': ' '})|raw }}
|
||||
</a>
|
||||
</span>
|
||||
{% else %}
|
||||
{{ name|replace({'_': ' '}) }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="var-value value{{ is_superuser ? ' editable' }}">
|
||||
{% if is_html_formatted == false %}
|
||||
{{ value|e|replace({',': ',​'})|raw }}
|
||||
{% else %}
|
||||
{{ value }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
Loading…
Reference in New Issue
Block a user