add $cfg['UserprefsDisallow'] and allow setting it in setup script
correct IE opacity issue for "restore default value" button fix regressions introduced in previous commit
This commit is contained in:
@@ -2176,6 +2176,11 @@ setfacl -d -m "g:www-data:rwx" tmp
|
|||||||
closed state. A value of <tt>'open'</tt> does the reverse. To completely
|
closed state. A value of <tt>'open'</tt> does the reverse. To completely
|
||||||
disable all visual sliders, use <tt>'disabled'</tt>.</dd>
|
disable all visual sliders, use <tt>'disabled'</tt>.</dd>
|
||||||
|
|
||||||
|
<dt id="cfg_UserprefsDisallow">$cfg['UserprefsDisallow'] array</dt>
|
||||||
|
<dd>Contains names of configuration options (keys in <tt>$cfg</tt> array)
|
||||||
|
that users can't set through user preferences. For possible values, refer
|
||||||
|
to <tt>libraries/config/user_preferences.forms.php</tt>.</dd>
|
||||||
|
|
||||||
<dt id="cfg_TitleTable">$cfg['TitleTable'] string</dt>
|
<dt id="cfg_TitleTable">$cfg['TitleTable'] string</dt>
|
||||||
<dt id="cfg_TitleDatabase">$cfg['TitleDatabase'] string</dt>
|
<dt id="cfg_TitleDatabase">$cfg['TitleDatabase'] string</dt>
|
||||||
<dt id="cfg_TitleServer">$cfg['TitleServer'] string</dt>
|
<dt id="cfg_TitleServer">$cfg['TitleServer'] string</dt>
|
||||||
|
@@ -571,7 +571,8 @@ function restoreField(field_id) {
|
|||||||
$(function() {
|
$(function() {
|
||||||
$('.restore-default, .set-value').each(function() {
|
$('.restore-default, .set-value').each(function() {
|
||||||
var link = $(this);
|
var link = $(this);
|
||||||
link.css('opacity', 0.25);
|
// inline-block for IE so opacity inheritance works
|
||||||
|
link.css('display', 'inline-block').css('opacity', 0.25);
|
||||||
if (!link.hasClass('restore-default')) {
|
if (!link.hasClass('restore-default')) {
|
||||||
// restore-default is handled by markField
|
// restore-default is handled by markField
|
||||||
link.css('display', '');
|
link.css('display', '');
|
||||||
|
@@ -2282,7 +2282,13 @@ $cfg['NaturalOrder'] = true;
|
|||||||
*/
|
*/
|
||||||
$cfg['InitialSlidersState'] = 'closed';
|
$cfg['InitialSlidersState'] = 'closed';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User preferences: disallow these settings
|
||||||
|
* For possible setting names look in libraries/config/user_preferences.forms.php
|
||||||
|
*
|
||||||
|
* @global array $cfg['UserprefsDisallow']
|
||||||
|
*/
|
||||||
|
$cfg['UserprefsDisallow'] = array();
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// custom-setup by mkkeck: 2004-05-04
|
// custom-setup by mkkeck: 2004-05-04
|
||||||
|
@@ -499,8 +499,9 @@ class ConfigFile
|
|||||||
} else {
|
} else {
|
||||||
// more than 4 values - value per line
|
// more than 4 values - value per line
|
||||||
$ret = "\$cfg['$var_name'] = array(";
|
$ret = "\$cfg['$var_name'] = array(";
|
||||||
for ($i = 0, $imax = count($ret)-1; $i <= $imax; $i++) {
|
$imax = count($retv)-1;
|
||||||
$ret .= ($i < $imax ? $crlf : '') . ' ' . $v;
|
for ($i = 0; $i <= $imax; $i++) {
|
||||||
|
$ret .= ($i < $imax ? ($i > 0 ? ',' : '') : '') . $crlf . ' ' . $retv[$i];
|
||||||
}
|
}
|
||||||
$ret .= ');' . $crlf;
|
$ret .= ');' . $crlf;
|
||||||
}
|
}
|
||||||
|
@@ -8,9 +8,8 @@
|
|||||||
* o translated_path - work_path modified for HTML field name, a path with
|
* o translated_path - work_path modified for HTML field name, a path with
|
||||||
* slashes changed to hyphens, eg. Servers-4-verbose
|
* slashes changed to hyphens, eg. Servers-4-verbose
|
||||||
*
|
*
|
||||||
* @package phpMyAdmin-setup
|
* @package phpMyAdmin
|
||||||
* @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
|
* @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,7 +63,19 @@ class FormDisplay
|
|||||||
* Tells whether forms have been validated
|
* Tells whether forms have been validated
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $is_valdiated = true;
|
private $is_validated = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dictionary with user preferences keys
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $userprefs_keys;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dictionary with disallowed user preferences keys
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $userprefs_disallow;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@@ -86,7 +97,7 @@ class FormDisplay
|
|||||||
public function registerForm($form_name, array $form, $server_id = null)
|
public function registerForm($form_name, array $form, $server_id = null)
|
||||||
{
|
{
|
||||||
$this->forms[$form_name] = new Form($form_name, $form, $server_id);
|
$this->forms[$form_name] = new Form($form_name, $form, $server_id);
|
||||||
$this->is_valdiated = false;
|
$this->is_validated = false;
|
||||||
foreach ($this->forms[$form_name]->fields as $path) {
|
foreach ($this->forms[$form_name]->fields as $path) {
|
||||||
$work_path = $server_id === null
|
$work_path = $server_id === null
|
||||||
? $path
|
? $path
|
||||||
@@ -121,7 +132,7 @@ class FormDisplay
|
|||||||
*/
|
*/
|
||||||
private function _validate()
|
private function _validate()
|
||||||
{
|
{
|
||||||
if ($this->is_valdiated) {
|
if ($this->is_validated) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +166,7 @@ class FormDisplay
|
|||||||
$this->errors[$work_path] = $error_list;
|
$this->errors[$work_path] = $error_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->is_valdiated = true;
|
$this->is_validated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,6 +208,16 @@ class FormDisplay
|
|||||||
$this->_validate();
|
$this->_validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// user preferences
|
||||||
|
if ($this->userprefs_keys === null) {
|
||||||
|
$this->userprefs_keys = array_flip(PMA_read_userprefs_fieldnames());
|
||||||
|
// read real config for user preferences display
|
||||||
|
$userprefs_disallow = defined('PMA_SETUP') && PMA_SETUP
|
||||||
|
? ConfigFile::getInstance()->get('UserprefsDisallow', array())
|
||||||
|
: $GLOBALS['cfg']['UserprefsDisallow'];
|
||||||
|
$this->userprefs_disallow = array_flip($userprefs_disallow);
|
||||||
|
}
|
||||||
|
|
||||||
// display forms
|
// display forms
|
||||||
foreach ($this->forms as $form) {
|
foreach ($this->forms as $form) {
|
||||||
/* @var $form Form */
|
/* @var $form Form */
|
||||||
@@ -211,9 +232,13 @@ class FormDisplay
|
|||||||
foreach ($form->fields as $field => $path) {
|
foreach ($form->fields as $field => $path) {
|
||||||
$work_path = array_search($path, $this->system_paths);
|
$work_path = array_search($path, $this->system_paths);
|
||||||
$translated_path = $this->translated_paths[$work_path];
|
$translated_path = $this->translated_paths[$work_path];
|
||||||
|
// always true/false for user preferences display
|
||||||
|
$userprefs_allow = isset($this->userprefs_keys[$path])
|
||||||
|
? !isset($this->userprefs_disallow[$path])
|
||||||
|
: null;
|
||||||
// display input
|
// display input
|
||||||
$this->_displayFieldInput($form, $field, $path, $work_path,
|
$this->_displayFieldInput($form, $field, $path, $work_path,
|
||||||
$translated_path, $show_restore_default, $js_default);
|
$translated_path, $show_restore_default, $userprefs_allow, $js_default);
|
||||||
// register JS validators for this field
|
// register JS validators for this field
|
||||||
if (isset($validators[$path])) {
|
if (isset($validators[$path])) {
|
||||||
js_validate($translated_path, $validators[$path], $js);
|
js_validate($translated_path, $validators[$path], $js);
|
||||||
@@ -250,10 +275,11 @@ class FormDisplay
|
|||||||
* @param string $work_path work path, eg. Servers/4/verbose
|
* @param string $work_path work path, eg. Servers/4/verbose
|
||||||
* @param string $translated_path work path changed so that it can be used as XHTML id
|
* @param string $translated_path work path changed so that it can be used as XHTML id
|
||||||
* @param bool $show_restore_default whether show "restore default" button besides the input field
|
* @param bool $show_restore_default whether show "restore default" button besides the input field
|
||||||
|
* @param mixed $userprefs_allow whether user preferences are enabled for this field (null - no support, true/false - enabled/disabled)
|
||||||
* @param array &$js_default array which stores JavaScript code to be displayed
|
* @param array &$js_default array which stores JavaScript code to be displayed
|
||||||
*/
|
*/
|
||||||
private function _displayFieldInput(Form $form, $field, $system_path, $work_path,
|
private function _displayFieldInput(Form $form, $field, $system_path, $work_path,
|
||||||
$translated_path, $show_restore_default, array &$js_default)
|
$translated_path, $show_restore_default, $userprefs_allow, array &$js_default)
|
||||||
{
|
{
|
||||||
$name = PMA_lang_name($system_path);
|
$name = PMA_lang_name($system_path);
|
||||||
$description = PMA_lang_desc($system_path);
|
$description = PMA_lang_desc($system_path);
|
||||||
@@ -270,7 +296,8 @@ class FormDisplay
|
|||||||
$opts = array(
|
$opts = array(
|
||||||
'doc' => $this->getDocLink($system_path),
|
'doc' => $this->getDocLink($system_path),
|
||||||
'wiki' => $this->getWikiLink($system_path),
|
'wiki' => $this->getWikiLink($system_path),
|
||||||
'show_restore_default' => $show_restore_default);
|
'show_restore_default' => $show_restore_default,
|
||||||
|
'userprefs_allow' => $userprefs_allow);
|
||||||
if (isset($form->default[$system_path])) {
|
if (isset($form->default[$system_path])) {
|
||||||
$opts['setvalue'] = $form->default[$system_path];
|
$opts['setvalue'] = $form->default[$system_path];
|
||||||
}
|
}
|
||||||
@@ -417,6 +444,16 @@ class FormDisplay
|
|||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
$to_save = array();
|
$to_save = array();
|
||||||
|
$is_setup_script = defined('PMA_SETUP') && PMA_SETUP;
|
||||||
|
if ($is_setup_script && $this->userprefs_keys === null) {
|
||||||
|
$this->userprefs_keys = array_flip(PMA_read_userprefs_fieldnames());
|
||||||
|
// read real config for user preferences display
|
||||||
|
$userprefs_disallow = $is_setup_script
|
||||||
|
? ConfigFile::getInstance()->get('UserprefsDisallow', array())
|
||||||
|
: $GLOBALS['cfg']['UserprefsDisallow'];
|
||||||
|
$this->userprefs_disallow = array_flip($userprefs_disallow);
|
||||||
|
}
|
||||||
|
|
||||||
$this->errors = array();
|
$this->errors = array();
|
||||||
foreach ($forms as $form) {
|
foreach ($forms as $form) {
|
||||||
/* @var $form Form */
|
/* @var $form Form */
|
||||||
@@ -448,6 +485,16 @@ class FormDisplay
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// user preferences allow/disallow
|
||||||
|
if ($is_setup_script && isset($this->userprefs_keys[$system_path])) {
|
||||||
|
if (isset($this->userprefs_disallow[$system_path])
|
||||||
|
&& isset($_POST[$key . '-userprefs-allow'])) {
|
||||||
|
unset($this->userprefs_disallow[$system_path]);
|
||||||
|
} else if (!isset($_POST[$key . '-userprefs-allow'])) {
|
||||||
|
$this->userprefs_disallow[$system_path] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// cast variables to correct type
|
// cast variables to correct type
|
||||||
$type = $form->getOptionType($field);
|
$type = $form->getOptionType($field);
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@@ -516,6 +563,9 @@ class FormDisplay
|
|||||||
}
|
}
|
||||||
$cf->set($work_path, $values[$path], $path);
|
$cf->set($work_path, $values[$path], $path);
|
||||||
}
|
}
|
||||||
|
if ($is_setup_script) {
|
||||||
|
$cf->set('UserprefsDisallow', array_keys($this->userprefs_disallow));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't look for non-critical errors
|
// don't look for non-critical errors
|
||||||
|
@@ -2,9 +2,8 @@
|
|||||||
/**
|
/**
|
||||||
* Form templates
|
* Form templates
|
||||||
*
|
*
|
||||||
* @package phpMyAdmin-setup
|
* @package phpMyAdmin
|
||||||
* @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
|
* @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
|
||||||
* @version $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -98,7 +97,7 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
|
|||||||
* o errors - error array
|
* o errors - error array
|
||||||
* o setvalue - (string) shows button allowing to set poredefined value
|
* o setvalue - (string) shows button allowing to set poredefined value
|
||||||
* o show_restore_default - (boolean) whether show "restore default" button
|
* o show_restore_default - (boolean) whether show "restore default" button
|
||||||
* o userprefs_allow - whether show user preferences allow/deny checkbox (null - no, true/false - yes)
|
* o userprefs_allow - whether user preferences are enabled for this field (null - no support, true/false - enabled/disabled)
|
||||||
* o values - key - value paris for <select> fields
|
* o values - key - value paris for <select> fields
|
||||||
* o values_escaped - (boolean) tells whether values array is already escaped (defaults to false)
|
* o values_escaped - (boolean) tells whether values array is already escaped (defaults to false)
|
||||||
* o values_disabled - (array)list of disabled values (keys from values)
|
* o values_disabled - (array)list of disabled values (keys from values)
|
||||||
@@ -116,21 +115,20 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
|||||||
{
|
{
|
||||||
static $base_dir, $img_path;
|
static $base_dir, $img_path;
|
||||||
|
|
||||||
if ($base_dir === null) {
|
|
||||||
$is_setup_script = defined('PMA_SETUP') && PMA_SETUP;
|
$is_setup_script = defined('PMA_SETUP') && PMA_SETUP;
|
||||||
|
if ($base_dir === null) {
|
||||||
$base_dir = $is_setup_script ? '../' : '';
|
$base_dir = $is_setup_script ? '../' : '';
|
||||||
$img_path = $is_setup_script
|
$img_path = $is_setup_script
|
||||||
? '../' . ltrim($GLOBALS['cfg']['ThemePath'], './') . '/original/img/'
|
? '../' . ltrim($GLOBALS['cfg']['ThemePath'], './') . '/original/img/'
|
||||||
: $_SESSION['PMA_Theme']->img_path;
|
: $_SESSION['PMA_Theme']->img_path;
|
||||||
}
|
}
|
||||||
$has_errors = isset($opts['errors']) && !empty($opts['errors']);
|
$has_errors = isset($opts['errors']) && !empty($opts['errors']);
|
||||||
$field_class = $type == 'checkbox' ? '' : 'checkbox';
|
$field_class = $type == 'checkbox' ? 'checkbox' : '';
|
||||||
if (!$value_is_default) {
|
if (!$value_is_default) {
|
||||||
$field_class .= ($field_class == '' ? '' : ' ') . ($has_errors ? 'custom field-error' : 'custom');
|
$field_class .= ($field_class == '' ? '' : ' ') . ($has_errors ? 'custom field-error' : 'custom');
|
||||||
}
|
}
|
||||||
$field_class = 'class="' . $field_class . '"';
|
$field_class = $field_class ? ' class="' . $field_class . '"' : '';
|
||||||
$name_id = 'name="' . $path . '" id="' . $path . '"';
|
$name_id = 'name="' . $path . '" id="' . $path . '"';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
@@ -152,8 +150,7 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
|||||||
. ' value="' . htmlspecialchars($value) . '" />';
|
. ' value="' . htmlspecialchars($value) . '" />';
|
||||||
break;
|
break;
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
echo '<span ' . $field_class
|
echo '<span' . $field_class . '><input type="checkbox" ' . $name_id
|
||||||
. '"><input type="checkbox" ' . $name_id
|
|
||||||
. ($value ? ' checked="checked"' : '') . ' /></span>';
|
. ($value ? ' checked="checked"' : '') . ' /></span>';
|
||||||
break;
|
break;
|
||||||
case 'select':
|
case 'select':
|
||||||
@@ -212,8 +209,18 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
|||||||
echo '</dl>';
|
echo '</dl>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
<?php
|
||||||
|
if ($is_setup_script && isset($opts['userprefs_allow'])) {
|
||||||
|
?>
|
||||||
|
<td class="userprefs-allow" title="<?php echo __('Allow users to customize this value') ?>">
|
||||||
|
<input type="checkbox" name="<?php echo $path ?>-userprefs-allow" <?php if ($opts['userprefs_allow']) echo 'checked="checked"' ?> />
|
||||||
|
</td>
|
||||||
|
<?php
|
||||||
|
} else if ($is_setup_script) {
|
||||||
|
echo '<td> </td>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
@@ -225,9 +232,13 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
|||||||
*/
|
*/
|
||||||
function display_fieldset_bottom()
|
function display_fieldset_bottom()
|
||||||
{
|
{
|
||||||
|
$colspan = 2;
|
||||||
|
if (defined('PMA_SETUP') && PMA_SETUP) {
|
||||||
|
$colspan++;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="lastrow">
|
<td colspan="<?php echo $colspan ?>" class="lastrow">
|
||||||
<input type="submit" name="submit_save" value="<?php echo __('Save') ?>" class="green" />
|
<input type="submit" name="submit_save" value="<?php echo __('Save') ?>" class="green" />
|
||||||
<input type="button" name="submit_reset" value="<?php echo __('Reset') ?>" />
|
<input type="button" name="submit_reset" value="<?php echo __('Reset') ?>" />
|
||||||
</td>
|
</td>
|
||||||
|
@@ -168,3 +168,25 @@ function ajaxValidate(parent, id, values) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// END: Form validation and field operations
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// User preferences allow/disallow UI
|
||||||
|
//
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$('.userprefs-allow').click(function(e) {
|
||||||
|
if (this != e.target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var el = $(this).find('input');
|
||||||
|
el.attr('checked', !el.attr('checked'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// END: User preferences allow/disallow UI
|
||||||
|
// ------------------------------------------------------------------
|
@@ -262,6 +262,18 @@ fieldset td {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset td.userprefs-allow {
|
||||||
|
padding: 0;
|
||||||
|
vertical-align: middle;
|
||||||
|
text-align: center;
|
||||||
|
width: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset td.userprefs-allow:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: #EEE;
|
||||||
|
}
|
||||||
|
|
||||||
fieldset th small {
|
fieldset th small {
|
||||||
display: block;
|
display: block;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
Reference in New Issue
Block a user