Add the 'container' type to the prefs.php config file
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 25 Jan 2011 22:55:51 +0000 (15:55 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 26 Jan 2011 00:28:47 +0000 (17:28 -0700)
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
horde/config/prefs.php.dist

index 246742f..70fd856 100644 (file)
@@ -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;
     }
 
     /**
index 9b83d3b..0745a86 100644 (file)
  * 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.
  *   '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$
  */