Developers tab no longer depends on UserprefsDisallow, introduced UserprefsDeveloperTab setting
This commit is contained in:
@@ -2310,16 +2310,16 @@ $cfg['InitialSlidersState'] = 'closed';
|
||||
|
||||
/**
|
||||
* User preferences: disallow these settings
|
||||
* 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.
|
||||
* For possible setting names look in libraries/config/user_preferences.forms.php
|
||||
*
|
||||
* @global array $cfg['UserprefsDisallow']
|
||||
*/
|
||||
$cfg['UserprefsDisallow'] = array(
|
||||
'Error_Handler/display', 'Error_Handler/gather', 'DBG/sql', 'DBG/php');
|
||||
$cfg['UserprefsDisallow'] = array();
|
||||
|
||||
/**
|
||||
* User preferences: enable the Developer tab
|
||||
*/
|
||||
$cfg['UserprefsDeveloperTab'] = false;
|
||||
|
||||
/**
|
||||
* User preferences: disabling options by users
|
||||
|
@@ -521,11 +521,6 @@ class ConfigFile
|
||||
$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 .= implode(', ', $retv);
|
||||
@@ -536,7 +531,7 @@ class ConfigFile
|
||||
$ret .= ($i < $imax ? ($i > 0 ? ',' : '') : '') . $crlf . ' ' . $retv[$i];
|
||||
}
|
||||
}
|
||||
$ret .= $ret_end;
|
||||
$ret .= ');' . $crlf;
|
||||
} else {
|
||||
// string keys: $cfg[key][subkey] = value
|
||||
foreach ($var_value as $k => $v) {
|
||||
|
@@ -228,8 +228,6 @@ class FormDisplay
|
||||
|
||||
// user preferences
|
||||
$this->_loadUserprefsInfo();
|
||||
$default_disallow = array_flip(
|
||||
ConfigFile::getInstance()->getDefault('UserprefsDisallow', array()));
|
||||
|
||||
// display forms
|
||||
foreach ($this->forms as $form) {
|
||||
@@ -245,10 +243,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/'disable' for user preferences display
|
||||
// always true/false for user preferences display
|
||||
// otherwise null
|
||||
$userprefs_allow = isset($this->userprefs_keys[$path])
|
||||
? (isset($default_disallow[$path]) ? 'disable' : !isset($this->userprefs_disallow[$path]))
|
||||
? !isset($this->userprefs_disallow[$path])
|
||||
: null;
|
||||
// display input
|
||||
$this->_displayFieldInput($form, $field, $path, $work_path,
|
||||
|
@@ -105,7 +105,7 @@ function display_fieldset_top($title = '', $description = '', $errors = null, $a
|
||||
* 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, 'disable' - false and field is disabled)
|
||||
* true/false - enabled/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)
|
||||
@@ -258,14 +258,9 @@ 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"<?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>
|
||||
<?php
|
||||
} else if ($is_setup_script) {
|
||||
|
@@ -491,6 +491,8 @@ $strConfigUploadDir_desc = __('Directory on server where you can upload files fo
|
||||
$strConfigUploadDir_name = __('Upload directory');
|
||||
$strConfigUseDbSearch_desc = __('Allow for searching inside the entire database');
|
||||
$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_name = __('Verbose multiple statements');
|
||||
$strConfigVersionCheckLink = __('Check for latest version');
|
||||
|
@@ -107,6 +107,7 @@ $forms['Features']['Warnings'] = array(
|
||||
'SuhosinDisableWarning',
|
||||
'McryptDisableWarning');
|
||||
$forms['Features']['Developer'] = array(
|
||||
'UserprefsDeveloperTab',
|
||||
'Error_Handler/display',
|
||||
'Error_Handler/gather',
|
||||
'DBG/sql',
|
||||
|
@@ -40,6 +40,7 @@ $forms['Features']['Warnings'] = array(
|
||||
'PmaNoRelation_DisableWarning',
|
||||
'SuhosinDisableWarning',
|
||||
'McryptDisableWarning');
|
||||
// settings from this form are treated specially, see prefs_forms.php and user_preferences.lib.php
|
||||
$forms['Features']['Developer'] = array(
|
||||
'Error_Handler/display',
|
||||
'Error_Handler/gather',
|
||||
|
@@ -134,6 +134,13 @@ function PMA_apply_userprefs(array $config_data)
|
||||
{
|
||||
$cfg = array();
|
||||
$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 some additional fields which are custom handled
|
||||
$whitelist['ThemeDefault'] = true;
|
||||
|
@@ -27,17 +27,8 @@ 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;
|
||||
}
|
||||
if ($form_name == 'Developer' && !$GLOBALS['cfg']['UserprefsDeveloperTab']) {
|
||||
continue;
|
||||
}
|
||||
$form_display->registerForm($form_name, $form);
|
||||
}
|
||||
|
Reference in New Issue
Block a user