*/
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;
}
/**
* 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$
*/