Changeset 42 for trunk/lib/Prefs.inc.php
- Timestamp:
- Dec 18, 2005 12:16:03 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Prefs.inc.php
r41 r42 30 30 */ 31 31 var $params = array(); 32 33 32 33 34 34 /** 35 35 * Prefs constructor. … … 43 43 /** 44 44 * Sets the default value of a preference. The pref will be set only if 45 * is not set already. 45 * is not set already. 46 46 * 47 47 * @param string $pref The name of the preference to modify. … … 56 56 $scope =& $this->scope; 57 57 } 58 58 59 59 // No empty values allowed. 60 60 if ('' == $pref || '' == $val || '' == $scope) { 61 61 return false; 62 62 } 63 63 64 64 // Initialized the prefs array. 65 65 if (!isset($_SESSION['_prefs'])) { 66 66 $_SESSION['_prefs'] = array(); 67 67 } 68 68 69 69 // In case boolean or null values are passed as a string. 70 70 if ($val == 'true') { … … 84 84 85 85 /** 86 * Sets the given preferences to the specific value, 86 * Sets the given preferences to the specific value, 87 87 * 88 88 * @param string $pref The name of the preference to modify. … … 97 97 $scope =& $this->scope; 98 98 } 99 99 100 100 // No empty values allowed. 101 101 if ('' == $pref || '' == $val || '' == $scope) { 102 102 return false; 103 103 } 104 104 105 105 // Initialized the prefs array. 106 106 if (!isset($_SESSION['_prefs'])) { 107 107 $_SESSION['_prefs'] = array(); 108 108 } 109 109 110 110 // In case boolean or null values are passed as a string. 111 111 if ($val == 'true') { … … 120 120 return true; 121 121 } 122 122 123 123 /** 124 124 * Returns the value of the requested preference. … … 134 134 $scope =& $this->scope; 135 135 } 136 136 137 137 return (isset($_SESSION['_prefs'][$scope][$pref])) ? $_SESSION['_prefs'][$scope][$pref] : null; 138 138 } 139 139 140 140 /** 141 141 * To see if a preference has been set. … … 152 152 $scope =& $this->scope; 153 153 } 154 154 155 155 return isset($_SESSION['_prefs'][$scope][$pref]); 156 156 } 157 157 158 158 /** 159 159 * Clear a set preference value. … … 167 167 $scope =& $this->scope; 168 168 } 169 169 170 170 if (isset($_SESSION['_prefs'][$scope][$pref])) { 171 171 unset($_SESSION['_prefs'][$scope][$pref]); … … 181 181 * preferences listed in the $prefs hash. 182 182 * 183 * @return mixed True on success or a PEAR_Error object on failure. 183 * @return mixed True on success or a PEAR_Error object on failure. 184 184 */ 185 185 function retrieve() … … 192 192 // FIXME: Database query goes here.... 193 193 return false; 194 194 195 195 $_SESSION['_prefs']['loaded'] = true; 196 196 } … … 211 211 return true; 212 212 } 213 213 214 214 /* 215 215 * If a list of preferences to store hasn't been provided in … … 221 221 $prefs = array_merge($_SESSION['_prefs'], $prefs); 222 222 } 223 223 224 224 if (!is_array($prefs) || empty($prefs)) { 225 225 App::raiseMsg(_("No preferences are available."), MSG_ERR, __FILE__, __LINE__); 226 226 App::dieBoomerangURL(); 227 227 } 228 228 229 229 // FIXME: Database query goes here.... 230 230 return false;
Note: See TracChangeset
for help on using the changeset viewer.