Developers tab no longer depends on UserprefsDisallow, introduced UserprefsDeveloperTab setting

This commit is contained in:
Crack
2010-07-22 20:04:16 +02:00
parent c8b6acdf59
commit 2e55d85ab5
9 changed files with 25 additions and 35 deletions

View File

@@ -2310,16 +2310,16 @@ $cfg['InitialSlidersState'] = 'closed';
/** /**
* User preferences: disallow these settings * User preferences: disallow these settings
* For possible setting names look in libraries/config/user_preferences.forms.php. Use * For possible setting names look in libraries/config/user_preferences.forms.php
* <code>
* $cfg['UserprefsDisallow'] = array_merge($this->settings['UserprefsDisallow'], array());
* </code>
* to append new keys.
* *
* @global array $cfg['UserprefsDisallow'] * @global array $cfg['UserprefsDisallow']
*/ */
$cfg['UserprefsDisallow'] = array( $cfg['UserprefsDisallow'] = array();
'Error_Handler/display', 'Error_Handler/gather', 'DBG/sql', 'DBG/php');
/**
* User preferences: enable the Developer tab
*/
$cfg['UserprefsDeveloperTab'] = false;
/** /**
* User preferences: disabling options by users * User preferences: disabling options by users

View File

@@ -521,11 +521,6 @@ class ConfigFile
$retv[] = var_export($v, true); $retv[] = var_export($v, true);
} }
$ret = "\$cfg['$var_name'] = array("; $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) { if (count($retv) <= 4) {
// up to 4 values - one line // up to 4 values - one line
$ret .= implode(', ', $retv); $ret .= implode(', ', $retv);
@@ -536,7 +531,7 @@ class ConfigFile
$ret .= ($i < $imax ? ($i > 0 ? ',' : '') : '') . $crlf . ' ' . $retv[$i]; $ret .= ($i < $imax ? ($i > 0 ? ',' : '') : '') . $crlf . ' ' . $retv[$i];
} }
} }
$ret .= $ret_end; $ret .= ');' . $crlf;
} else { } else {
// string keys: $cfg[key][subkey] = value // string keys: $cfg[key][subkey] = value
foreach ($var_value as $k => $v) { foreach ($var_value as $k => $v) {

View File

@@ -228,8 +228,6 @@ class FormDisplay
// user preferences // user preferences
$this->_loadUserprefsInfo(); $this->_loadUserprefsInfo();
$default_disallow = array_flip(
ConfigFile::getInstance()->getDefault('UserprefsDisallow', array()));
// display forms // display forms
foreach ($this->forms as $form) { foreach ($this->forms as $form) {
@@ -245,10 +243,10 @@ 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/'disable' for user preferences display // always true/false for user preferences display
// otherwise null // otherwise null
$userprefs_allow = isset($this->userprefs_keys[$path]) $userprefs_allow = isset($this->userprefs_keys[$path])
? (isset($default_disallow[$path]) ? 'disable' : !isset($this->userprefs_disallow[$path])) ? !isset($this->userprefs_disallow[$path])
: null; : null;
// display input // display input
$this->_displayFieldInput($form, $field, $path, $work_path, $this->_displayFieldInput($form, $field, $path, $work_path,

View File

@@ -105,7 +105,7 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
* 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 user preferences are enabled for this field (null - no support, * o userprefs_allow - whether user preferences are enabled for this field (null - no support,
* true/false - enabled/disabled, 'disable' - false and field is disabled) * true/false - enabled/disabled)
* o userprefs_comment - (string) field comment * o userprefs_comment - (string) field comment
* 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)
@@ -258,14 +258,9 @@ function display_input($path, $name, $description = '', $type, $value, $value_is
</td> </td>
<?php <?php
if ($is_setup_script && isset($opts['userprefs_allow'])) { 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') ?>"> <td class="userprefs-allow" title="<?php echo __('Allow users to customize this value') ?>">
<input type="checkbox"<?php echo $disabled ?> name="<?php echo $path ?>-userprefs-allow" <?php if ($opts['userprefs_allow']) echo 'checked="checked"' ?> /> <input type="checkbox" name="<?php echo $path ?>-userprefs-allow" <?php if ($opts['userprefs_allow']) echo 'checked="checked"' ?> />
</td> </td>
<?php <?php
} else if ($is_setup_script) { } else if ($is_setup_script) {

View File

@@ -491,6 +491,8 @@ $strConfigUploadDir_desc = __('Directory on server where you can upload files fo
$strConfigUploadDir_name = __('Upload directory'); $strConfigUploadDir_name = __('Upload directory');
$strConfigUseDbSearch_desc = __('Allow for searching inside the entire database'); $strConfigUseDbSearch_desc = __('Allow for searching inside the entire database');
$strConfigUseDbSearch_name = __('Use database search'); $strConfigUseDbSearch_name = __('Use database search');
$strConfigUserprefsDeveloperTab_name = __('Enable the Developer tab in settings');
$strConfigUserprefsDeveloperTab_desc = __('When disabled, users cannot set any of the options below, regardless of the checkbox on the right');
$strConfigVerboseMultiSubmit_desc = __('Show affected rows of each statement on multiple-statement queries. See libraries/import.lib.php for defaults on how many queries a statement may contain.'); $strConfigVerboseMultiSubmit_desc = __('Show affected rows of each statement on multiple-statement queries. See libraries/import.lib.php for defaults on how many queries a statement may contain.');
$strConfigVerboseMultiSubmit_name = __('Verbose multiple statements'); $strConfigVerboseMultiSubmit_name = __('Verbose multiple statements');
$strConfigVersionCheckLink = __('Check for latest version'); $strConfigVersionCheckLink = __('Check for latest version');

View File

@@ -107,6 +107,7 @@ $forms['Features']['Warnings'] = array(
'SuhosinDisableWarning', 'SuhosinDisableWarning',
'McryptDisableWarning'); 'McryptDisableWarning');
$forms['Features']['Developer'] = array( $forms['Features']['Developer'] = array(
'UserprefsDeveloperTab',
'Error_Handler/display', 'Error_Handler/display',
'Error_Handler/gather', 'Error_Handler/gather',
'DBG/sql', 'DBG/sql',

View File

@@ -40,6 +40,7 @@ $forms['Features']['Warnings'] = array(
'PmaNoRelation_DisableWarning', 'PmaNoRelation_DisableWarning',
'SuhosinDisableWarning', 'SuhosinDisableWarning',
'McryptDisableWarning'); 'McryptDisableWarning');
// settings from this form are treated specially, see prefs_forms.php and user_preferences.lib.php
$forms['Features']['Developer'] = array( $forms['Features']['Developer'] = array(
'Error_Handler/display', 'Error_Handler/display',
'Error_Handler/gather', 'Error_Handler/gather',

View File

@@ -134,6 +134,13 @@ function PMA_apply_userprefs(array $config_data)
{ {
$cfg = array(); $cfg = array();
$blacklist = array_flip($GLOBALS['cfg']['UserprefsDisallow']); $blacklist = array_flip($GLOBALS['cfg']['UserprefsDisallow']);
if (!$GLOBALS['cfg']['UserprefsDeveloperTab']) {
// disallow everything in the Developers tab
$blacklist['Error_Handler/display'] = true;
$blacklist['Error_Handler/gather'] = true;
$blacklist['DBG/sql'] = true;
$blacklist['DBG/php'] = true;
}
$whitelist = array_flip(PMA_read_userprefs_fieldnames()); $whitelist = array_flip(PMA_read_userprefs_fieldnames());
// whitelist some additional fields which are custom handled // whitelist some additional fields which are custom handled
$whitelist['ThemeDefault'] = true; $whitelist['ThemeDefault'] = true;

View File

@@ -27,17 +27,8 @@ require_once './libraries/user_preferences.inc.php';
$form_display = new FormDisplay(); $form_display = new FormDisplay();
foreach ($forms[$form_param] as $form_name => $form) { foreach ($forms[$form_param] as $form_name => $form) {
// skip Developer form if no setting is available // skip Developer form if no setting is available
if ($form_name == 'Developer') { if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
$show = false; continue;
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); $form_display->registerForm($form_name, $form);
} }