From 2e55d85ab5adff22e6c766b2c857fd60a62416cd Mon Sep 17 00:00:00 2001 From: Crack Date: Thu, 22 Jul 2010 20:04:16 +0200 Subject: [PATCH] Developers tab no longer depends on UserprefsDisallow, introduced UserprefsDeveloperTab setting --- libraries/config.default.php | 14 +++++++------- libraries/config/ConfigFile.class.php | 7 +------ libraries/config/FormDisplay.class.php | 6 ++---- libraries/config/FormDisplay.tpl.php | 9 ++------- libraries/config/messages.inc.php | 2 ++ libraries/config/setup.forms.php | 1 + libraries/config/user_preferences.forms.php | 1 + libraries/user_preferences.lib.php | 7 +++++++ prefs_forms.php | 13 ++----------- 9 files changed, 25 insertions(+), 35 deletions(-) diff --git a/libraries/config.default.php b/libraries/config.default.php index df641a899..97c513d9b 100644 --- a/libraries/config.default.php +++ b/libraries/config.default.php @@ -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 - * - * $cfg['UserprefsDisallow'] = array_merge($this->settings['UserprefsDisallow'], array()); - * - * 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 diff --git a/libraries/config/ConfigFile.class.php b/libraries/config/ConfigFile.class.php index 869f9a72e..a6acb94f3 100644 --- a/libraries/config/ConfigFile.class.php +++ b/libraries/config/ConfigFile.class.php @@ -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) { diff --git a/libraries/config/FormDisplay.class.php b/libraries/config/FormDisplay.class.php index 1fbd33998..c2d3e581c 100644 --- a/libraries/config/FormDisplay.class.php +++ b/libraries/config/FormDisplay.class.php @@ -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, diff --git a/libraries/config/FormDisplay.tpl.php b/libraries/config/FormDisplay.tpl.php index 5e443bdfa..fa49518d8 100644 --- a/libraries/config/FormDisplay.tpl.php +++ b/libraries/config/FormDisplay.tpl.php @@ -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 name="-userprefs-allow" /> + /> $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); }