From 6b1c9b8ae2e7ba546a47da66406292be95255480 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 25 Jan 2011 15:55:51 -0700 Subject: [PATCH] Add the 'container' type to the prefs.php config file Only way I can think of at the moment to indicate to admins that these prefs MUST be displayed on the same page (for UI reasons). --- framework/Core/lib/Horde/Core/Prefs/Ui.php | 55 ++++++++++++++++++++---------- horde/config/prefs.php.dist | 22 +++++++----- 2 files changed, 51 insertions(+), 26 deletions(-) diff --git a/framework/Core/lib/Horde/Core/Prefs/Ui.php b/framework/Core/lib/Horde/Core/Prefs/Ui.php index 246742f0f..70fd856c4 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Ui.php +++ b/framework/Core/lib/Horde/Core/Prefs/Ui.php @@ -151,35 +151,54 @@ class Horde_Core_Prefs_Ui */ public function getChangeablePrefs($group = null) { - $prefs = array(); - if (is_null($group)) { if (!$this->group) { - return $prefs; + return array(); } $group = $this->group; } - if (!empty($this->prefGroups[$group]['members'])) { - foreach ($this->prefGroups[$group]['members'] as $pref) { - /* Changeable pref if: - * 1. Not locked - * 2. Not in suppressed array ($this->suppress) - * 3. Not an advanced pref -or- in advanced view mode - * 4. Not an implicit pref */ - if (!$GLOBALS['prefs']->isLocked($pref) && - !in_array($pref, $this->suppress) && - (empty($this->prefs[$pref]['advanced']) || - $GLOBALS['session']->get('horde', 'prefs_advanced')) && - ((!empty($this->prefs[$pref]['type']) && - ($this->prefs[$pref]['type'] != 'implicit')))) { - $prefs[] = $pref; + return empty($this->prefGroups[$group]['members']) + ? array() + : $this->_getChangeablePrefs($this->prefGroups[$group]['members']); + } + + /** + * Returns the list of changeable prefs. + * + * @param array $preflist The list of preferences to check. + * + * @return array The list of changeable prefs. + */ + protected function _getChangeablePrefs($preflist) + { + $cprefs = array(); + + foreach ($preflist as $pref) { + /* Changeable pref if: + * 1. Not locked + * 2. Not in suppressed array ($this->suppress) + * 3. Not an advanced pref -or- in advanced view mode + * 4. Not an implicit pref */ + if (!$GLOBALS['prefs']->isLocked($pref) && + !in_array($pref, $this->suppress) && + (empty($this->prefs[$pref]['advanced']) || + $GLOBALS['session']->get('horde', 'prefs_advanced')) && + ((!empty($this->prefs[$pref]['type']) && + ($this->prefs[$pref]['type'] != 'implicit')))) { + if ($this->prefs[$pref]['type'] == 'container') { + if (isset($this->prefs[$pref]['value']) && + is_array($this->prefs[$pref]['value'])) { + $cprefs = array_merge($cprefs, $this->prefs[$pref]['value']); + } + } else { + $cprefs[] = $pref; } } } - return $prefs; + return $cprefs; } /** diff --git a/horde/config/prefs.php.dist b/horde/config/prefs.php.dist index 9b83d3b1b..0745a866f 100644 --- a/horde/config/prefs.php.dist +++ b/horde/config/prefs.php.dist @@ -177,14 +177,6 @@ * ADDITIONAL KEYS: * 'value' - (string) The raw (already escaped) HTML to output to the page. * - * 'special' - * --------- - * Used as placeholder to indicate that the application will provide both the - * UI display code and the subsequent preferences storage. - * - * This pref is a UI placeholder only and will not be stored in the preference - * backend. - * * 'text' * ------ * Provides a single-line textbox. @@ -202,6 +194,20 @@ * 'value' - (string) The preference value. Lines should be separated * with the "\n" character. * + * + * Placeholder types - these prefs are UI placeholders only and will not + * be stored in the preference backend. + * + * 'container' + * ----------- + * Used to indicate a list of preferences that MUST appear on the same page + * for UI purposes. + * + * 'special' + * --------- + * Used as placeholder to indicate that the application will provide both the + * UI display code and the subsequent preferences storage. + * * $Id$ */ -- 2.11.0