more styling for disabled options
new "Developer" tab (by default all options are disabled, users can't modify them) fixed UserprefsDisallow export in setup script
This commit is contained in:
@@ -2310,11 +2310,16 @@ $cfg['InitialSlidersState'] = 'closed';
|
||||
|
||||
/**
|
||||
* User preferences: disallow these settings
|
||||
* For possible setting names look in libraries/config/user_preferences.forms.php
|
||||
* For possible setting names look in libraries/config/user_preferences.forms.php. Use
|
||||
* <code>
|
||||
* $cfg['UserprefsDisallow'] = array_merge($this->settings['UserprefsDisallow'], array());
|
||||
* </code>
|
||||
* to append new keys.
|
||||
*
|
||||
* @global array $cfg['UserprefsDisallow']
|
||||
*/
|
||||
$cfg['UserprefsDisallow'] = array();
|
||||
$cfg['UserprefsDisallow'] = array(
|
||||
'Error_Handler/display', 'Error_Handler/gather', 'DBG/sql', 'DBG/php');
|
||||
|
||||
/**
|
||||
* User preferences: disabling options by users
|
||||
|
@@ -520,18 +520,23 @@ class ConfigFile
|
||||
foreach ($var_value as $v) {
|
||||
$retv[] = var_export($v, true);
|
||||
}
|
||||
$ret = "\$cfg['$var_name'] = array(";
|
||||
$ret_end = ');' . $crlf;
|
||||
if ($var_name == 'UserprefsDisallow') {
|
||||
$ret = "\$cfg['$var_name'] = array_merge(\$this->settings['UserprefsDisallow'],\n\tarray(";
|
||||
$ret_end = ')' . $ret_end;
|
||||
}
|
||||
if (count($retv) <= 4) {
|
||||
// up to 4 values - one line
|
||||
$ret = "\$cfg['$var_name'] = array(" . implode(', ', $retv) . ');' . $crlf;
|
||||
$ret .= implode(', ', $retv);
|
||||
} else {
|
||||
// more than 4 values - value per line
|
||||
$ret = "\$cfg['$var_name'] = array(";
|
||||
$imax = count($retv)-1;
|
||||
for ($i = 0; $i <= $imax; $i++) {
|
||||
$ret .= ($i < $imax ? ($i > 0 ? ',' : '') : '') . $crlf . ' ' . $retv[$i];
|
||||
}
|
||||
$ret .= ');' . $crlf;
|
||||
}
|
||||
$ret .= $ret_end;
|
||||
} else {
|
||||
// string keys: $cfg[key][subkey] = value
|
||||
foreach ($var_value as $k => $v) {
|
||||
|
@@ -175,7 +175,6 @@ class FormDisplay
|
||||
$this->is_validated = true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Outputs HTML for forms
|
||||
*
|
||||
@@ -192,7 +191,6 @@ class FormDisplay
|
||||
* @uses PMA_config_get_validators()
|
||||
* @uses PMA_jsFormat()
|
||||
* @uses PMA_lang()
|
||||
* @uses PMA_read_userprefs_fieldnames()
|
||||
* @param bool $tabbed_form
|
||||
* @param bool $show_restore_default whether show "restore default" button besides the input field
|
||||
*/
|
||||
@@ -229,14 +227,9 @@ class FormDisplay
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
$this->_loadUserprefsInfo();
|
||||
$default_disallow = array_flip(
|
||||
ConfigFile::getInstance()->getDefault('UserprefsDisallow', array()));
|
||||
|
||||
// display forms
|
||||
foreach ($this->forms as $form) {
|
||||
@@ -252,9 +245,10 @@ class FormDisplay
|
||||
foreach ($form->fields as $field => $path) {
|
||||
$work_path = array_search($path, $this->system_paths);
|
||||
$translated_path = $this->translated_paths[$work_path];
|
||||
// always true/false for user preferences display
|
||||
// always true/false/'disable' for user preferences display
|
||||
// otherwise null
|
||||
$userprefs_allow = isset($this->userprefs_keys[$path])
|
||||
? !isset($this->userprefs_disallow[$path])
|
||||
? (isset($default_disallow[$path]) ? 'disable' : !isset($this->userprefs_disallow[$path]))
|
||||
: null;
|
||||
// display input
|
||||
$this->_displayFieldInput($form, $field, $path, $work_path,
|
||||
@@ -306,7 +300,8 @@ class FormDisplay
|
||||
* @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 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 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
|
||||
*/
|
||||
private function _displayFieldInput(Form $form, $field, $system_path, $work_path,
|
||||
@@ -490,7 +485,6 @@ class FormDisplay
|
||||
* @uses Form::getOptionType()
|
||||
* @uses Form::getOptionValueList()
|
||||
* @uses PMA_lang_name()
|
||||
* @uses PMA_read_userprefs_fieldnames()
|
||||
* @param array|string $forms array of form names
|
||||
* @param bool $allow_partial_save allows for partial form saving on failed validation
|
||||
* @return boolean true on success (no errors and all saved)
|
||||
@@ -504,13 +498,8 @@ class FormDisplay
|
||||
$values = 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);
|
||||
if ($is_setup_script) {
|
||||
$this->_loadUserprefsInfo();
|
||||
}
|
||||
|
||||
$this->errors = array();
|
||||
@@ -664,7 +653,7 @@ class FormDisplay
|
||||
if ($test == 'Import' || $test == 'Export') {
|
||||
return '';
|
||||
}
|
||||
return 'Documentation.html#cfg_' . self::_getOptName($path);
|
||||
return 'Documentation.html#cfg_' . $this->_getOptName($path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -675,7 +664,7 @@ class FormDisplay
|
||||
*/
|
||||
public function getWikiLink($path)
|
||||
{
|
||||
$opt_name = self::_getOptName($path);
|
||||
$opt_name = $this->_getOptName($path);
|
||||
if (substr($opt_name, 0, 7) == 'Servers') {
|
||||
$opt_name = substr($opt_name, 8);
|
||||
if (strpos($opt_name, 'AllowDeny') === 0) {
|
||||
@@ -701,11 +690,28 @@ class FormDisplay
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
private static function _getOptName($path)
|
||||
private function _getOptName($path)
|
||||
{
|
||||
return str_replace(
|
||||
array('Servers/1/', 'disable/', '/'),
|
||||
array('Servers/', '', '_'), $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills out {@link userprefs_keys} and {@link userprefs_disallow}
|
||||
*
|
||||
* @uses PMA_read_userprefs_fieldnames()
|
||||
*/
|
||||
private function _loadUserprefsInfo()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@@ -104,7 +104,8 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
|
||||
* o errors - error array
|
||||
* o setvalue - (string) shows button allowing to set poredefined value
|
||||
* o show_restore_default - (boolean) whether show "restore default" button
|
||||
* o userprefs_allow - whether user preferences are enabled for this field (null - no support, true/false - enabled/disabled)
|
||||
* o userprefs_allow - whether user preferences are enabled for this field (null - no support,
|
||||
* true/false - enabled/disabled, 'disable' - false and field is disabled)
|
||||
* o userprefs_comment - (string) field comment
|
||||
* o values - key - value paris for <select> fields
|
||||
* o values_escaped - (boolean) tells whether values array is already escaped (defaults to false)
|
||||
@@ -136,21 +137,26 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
||||
: $_SESSION['PMA_Theme']->img_path;
|
||||
}
|
||||
$has_errors = isset($opts['errors']) && !empty($opts['errors']);
|
||||
$option_is_disabled = !$is_setup_script && isset($opts['userprefs_allow']) && !$opts['userprefs_allow'];
|
||||
$name_id = 'name="' . htmlspecialchars($path) . '" id="' . htmlspecialchars($path) . '"';
|
||||
$field_class = $type == 'checkbox' ? 'checkbox' : '';
|
||||
if (!$value_is_default) {
|
||||
$field_class .= ($field_class == '' ? '' : ' ') . ($has_errors ? 'custom field-error' : 'custom');
|
||||
}
|
||||
$field_class = $field_class ? ' class="' . $field_class . '"' : '';
|
||||
$name_id = 'name="' . htmlspecialchars($path) . '" id="' . htmlspecialchars($path) . '"';
|
||||
$tr_class = $_FormDisplayGroup ? ' class="group-field"' : '';
|
||||
$tr_class = $_FormDisplayGroup ? 'group-field' : '';
|
||||
if (isset($opts['setvalue']) && $opts['setvalue'] == ':group') {
|
||||
unset($opts['setvalue']);
|
||||
$tr_class = ' class="group-header-field"';
|
||||
$tr_class = 'group-header-field';
|
||||
if ($_FormDisplayGroup) {
|
||||
display_group_footer();
|
||||
}
|
||||
$_FormDisplayGroup = true;
|
||||
}
|
||||
if ($option_is_disabled) {
|
||||
$tr_class .= ($tr_class ? ' ' : '') . 'disabled-field';
|
||||
}
|
||||
$tr_class = $tr_class ? ' class="' . $tr_class . '"' : '';
|
||||
?>
|
||||
<tr<?php echo $tr_class ?>>
|
||||
<th>
|
||||
@@ -161,7 +167,7 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
||||
<?php if (!empty($opts['wiki'])){ ?><a href="<?php echo $opts['wiki'] ?>" target="wiki"><img class="icon" src="<?php echo $img_path ?>b_info.png" width="11" height="11" alt="Wiki" title="Wiki" /></a><?php } ?>
|
||||
</span>
|
||||
<?php } ?>
|
||||
<?php if (!$is_setup_script && isset($opts['userprefs_allow']) && !$opts['userprefs_allow']) { ?>
|
||||
<?php if ($option_is_disabled) { ?>
|
||||
<span class="disabled-notice" title="<?php echo __('This setting is disabled, it will not be applied to your configuration') ?>"><?php echo __('Disabled') ?></span>
|
||||
<?php } ?>
|
||||
<?php if (!empty($description)) { ?><small><?php echo $description ?></small><?php } ?>
|
||||
@@ -252,9 +258,14 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
|
||||
</td>
|
||||
<?php
|
||||
if ($is_setup_script && isset($opts['userprefs_allow'])) {
|
||||
$disabled = '';
|
||||
if ($opts['userprefs_allow'] === 'disable') {
|
||||
$opts['userprefs_allow'] = false;
|
||||
$disabled = ' disabled="$disabled"';
|
||||
}
|
||||
?>
|
||||
<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"' ?> />
|
||||
<input type="checkbox"<?php echo $disabled ?> name="<?php echo $path ?>-userprefs-allow" <?php if ($opts['userprefs_allow']) echo 'checked="checked"' ?> />
|
||||
</td>
|
||||
<?php
|
||||
} else if ($is_setup_script) {
|
||||
|
@@ -39,6 +39,8 @@ $strConfigConfigurationFile = __('Configuration file');
|
||||
$strConfigConfirm_desc = __('Whether a warning ("Are your really sure...") should be displayed when you\'re about to lose data');
|
||||
$strConfigConfirm_name = __('Confirm DROP queries');
|
||||
$strConfigCtrlArrowsMoving_name = __('Field navigation using Ctrl+Arrows');
|
||||
$strConfigDBG_php_name = __('Debug PHP');
|
||||
$strConfigDBG_sql_name = __('Debug SQL');
|
||||
$strConfigDefaultDisplay_name = __('Default display direction');
|
||||
$strConfigDefaultPropDisplay_desc = __('[kbd]horizontal[/kbd], [kbd]vertical[/kbd] or a number that indicates maximum number for which vertical model is used');
|
||||
$strConfigDefaultPropDisplay_name = __('Display direction for altering/creating columns');
|
||||
@@ -56,6 +58,8 @@ $strConfigDisplayServersList_desc = __('Show server listing as a list instead of
|
||||
$strConfigDisplayServersList_name = __('Display servers as a list');
|
||||
$strConfigEditInWindow_desc = __('Edit SQL queries in popup window');
|
||||
$strConfigEditInWindow_name = __('Edit in window');
|
||||
$strConfigError_Handler_display_name = __('Display errors');
|
||||
$strConfigError_Handler_gather_name = __('Gather errors');
|
||||
$strConfigErrorIconic_desc = __('Show icons for warning, error and information messages');
|
||||
$strConfigErrorIconic_name = __('Iconic errors');
|
||||
$strConfigExecTimeLimit_desc = __('Set the number of seconds a script is allowed to run ([kbd]0[/kbd] for no limit)');
|
||||
@@ -152,13 +156,15 @@ $strConfigForm_CodeGen = 'CodeGen';
|
||||
$strConfigForm_CodeGen_desc = __('Customize default options');
|
||||
$strConfigForm_Csv = __('CSV');
|
||||
$strConfigForm_Csv_desc = __('Customize default options');
|
||||
$strConfigForm_Developer = __('Developer');
|
||||
$strConfigForm_Developer_desc = __('Settings for phpMyAdmin developers');
|
||||
$strConfigForm_Edit = __('Edit mode');
|
||||
$strConfigForm_Edit_desc = __('Customize edit mode');
|
||||
$strConfigForm_Export = __('Export');
|
||||
$strConfigForm_Export_defaults = __('Export defaults');
|
||||
$strConfigForm_Export_defaults_desc = __('Customize default export options');
|
||||
$strConfigForm_Features = __('Features');
|
||||
$strConfigForm_General = __('General settings');
|
||||
$strConfigForm_General = __('General');
|
||||
$strConfigForm_General_desc = __('Set some commonly used options');
|
||||
$strConfigForm_Import = __('Import');
|
||||
$strConfigForm_Import_defaults = __('Import defaults');
|
||||
|
@@ -106,6 +106,11 @@ $forms['Features']['Warnings'] = array(
|
||||
'PmaNoRelation_DisableWarning',
|
||||
'SuhosinDisableWarning',
|
||||
'McryptDisableWarning');
|
||||
$forms['Features']['Developer'] = array(
|
||||
'Error_Handler/display',
|
||||
'Error_Handler/gather',
|
||||
'DBG/sql',
|
||||
'DBG/php');
|
||||
$forms['Features']['Other_core_settings'] = array(
|
||||
'NaturalOrder',
|
||||
'InitialSlidersState',
|
||||
|
@@ -31,6 +31,20 @@ $forms['Features']['Text_fields'] = array(
|
||||
'TextareaCols',
|
||||
'TextareaRows',
|
||||
'LongtextDoubleTextarea');
|
||||
$forms['Features']['Page_titles'] = array(
|
||||
'TitleDefault',
|
||||
'TitleTable',
|
||||
'TitleDatabase',
|
||||
'TitleServer');
|
||||
$forms['Features']['Warnings'] = array(
|
||||
'PmaNoRelation_DisableWarning',
|
||||
'SuhosinDisableWarning',
|
||||
'McryptDisableWarning');
|
||||
$forms['Features']['Developer'] = array(
|
||||
'Error_Handler/display',
|
||||
'Error_Handler/gather',
|
||||
'DBG/sql',
|
||||
'DBG/php');
|
||||
$forms['Sql_queries']['Sql_queries'] = array(
|
||||
'ShowSQL',
|
||||
'Confirm',
|
||||
@@ -52,15 +66,6 @@ $forms['Sql_queries']['Sql_validator'] = array(
|
||||
'SQLValidator/use',
|
||||
'SQLValidator/username',
|
||||
'SQLValidator/password');
|
||||
$forms['Features']['Page_titles'] = array(
|
||||
'TitleDefault',
|
||||
'TitleTable',
|
||||
'TitleDatabase',
|
||||
'TitleServer');
|
||||
$forms['Features']['Warnings'] = array(
|
||||
'PmaNoRelation_DisableWarning',
|
||||
'SuhosinDisableWarning',
|
||||
'McryptDisableWarning');
|
||||
$forms['Left_frame']['Left_frame'] = array(
|
||||
'LeftFrameLight',
|
||||
'LeftDisplayLogo',
|
||||
|
@@ -30,7 +30,7 @@ echo PMA_generate_html_tab(array(
|
||||
'link' => 'prefs_manage.php',
|
||||
'text' => __('Manage your settings'))) . "\n";
|
||||
echo '<li> </li>' . "\n";
|
||||
$script_name = basename(basename($GLOBALS['PMA_PHP_SELF']));
|
||||
$script_name = basename($GLOBALS['PMA_PHP_SELF']);
|
||||
foreach (array_keys($forms) as $formset) {
|
||||
$tab = array(
|
||||
'link' => 'prefs_forms.php',
|
||||
|
@@ -26,6 +26,19 @@ require_once './libraries/user_preferences.inc.php';
|
||||
|
||||
$form_display = new FormDisplay();
|
||||
foreach ($forms[$form_param] as $form_name => $form) {
|
||||
// skip Developer form if no setting is available
|
||||
if ($form_name == 'Developer') {
|
||||
$show = false;
|
||||
foreach ($form as $field_name) {
|
||||
if (array_search($field_name, $GLOBALS['cfg']['UserprefsDisallow']) === false) {
|
||||
$show = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$show) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$form_display->registerForm($form_name, $form);
|
||||
}
|
||||
|
||||
|
@@ -183,6 +183,9 @@ $(function() {
|
||||
return;
|
||||
}
|
||||
var el = $(this).find('input');
|
||||
if (el.attr('disabled')) {
|
||||
return;
|
||||
}
|
||||
el.attr('checked', !el.attr('checked'));
|
||||
});
|
||||
});
|
||||
|
@@ -1445,6 +1445,13 @@ fieldset .group-field th {
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
fieldset .disabled-field th,
|
||||
fieldset .disabled-field th small,
|
||||
fieldset .disabled-field td {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
.config-form .lastrow {
|
||||
border-top: 1px #000 solid;
|
||||
}
|
||||
|
@@ -1377,6 +1377,13 @@ fieldset .group-field th {
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
fieldset .disabled-field th,
|
||||
fieldset .disabled-field th small,
|
||||
fieldset .disabled-field td {
|
||||
color: #666;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.config-form .lastrow {
|
||||
border-top: 1px #000 solid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user