[dev] Patch for prefs
Jason Rust
jrust at rustyparts.com
Thu Jan 8 08:39:30 PST 2004
Attached an updated version of the patch. It makes it a little clearer
that when the pref is locked it retrieves the default pref.
-Jason
-------------- next part --------------
Index: Prefs.php
===================================================================
RCS file: /repository/horde/lib/Prefs.php,v
retrieving revision 1.124
diff -u -r1.124 Prefs.php
--- Prefs.php 1 Jan 2004 15:15:53 -0000 1.124
+++ Prefs.php 7 Jan 2004 17:36:45 -0000
@@ -625,7 +625,13 @@
*/
function _setDefaults($app)
{
+ static $loaded;
global $registry;
+
+ if (!empty($loaded[$app])) {
+ return;
+ }
+
$filename = $registry->getParam('fileroot', $app) . '/config/prefs.php';
/* Ensure that the defaults from this file are only read once.
@@ -661,6 +667,7 @@
}
}
+ $loaded[$app] = true;
/* Update the preferences cache with the defaults. */
$this->cacheUpdate();
}
Index: Prefs/sql.php
===================================================================
RCS file: /repository/horde/lib/Prefs/sql.php,v
retrieving revision 1.81
diff -u -r1.81 sql.php
--- Prefs/sql.php 5 Jan 2004 16:42:06 -0000 1.81
+++ Prefs/sql.php 7 Jan 2004 17:36:45 -0000
@@ -133,7 +133,10 @@
/* Make sure we're connected. */
$this->_connect();
+ /* Load defaults to make sure we have all preferences. */
+ $this->_setDefaults('horde');
if ($scope != 'horde') {
+ $this->_setDefaults($scope);
$scope = 'pref_scope = ' . $this->_db->quote($scope) . " OR pref_scope = 'horde'";
} else {
$scope = "pref_scope = 'horde'";
@@ -153,10 +156,18 @@
$prefs = $this->_db->getAssoc($query);
foreach ($prefs as $pref => $value) {
- $prefs[$pref] = $this->_convertFromDriver($value);
+ if ($this->isLocked($pref)) {
+ $prefs[$pref] = $this->getDefault($pref);
+ } else {
+ $prefs[$pref] = $this->_convertFromDriver($value);
+ }
}
return $prefs;
} else {
+ if ($this->isLocked($retrieve)) {
+ return $this->getDefault($retrieve);
+ }
+
$query = 'SELECT pref_value FROM ' . $this->_params['table'] . ' WHERE pref_uid=' . $this->_db->quote($user) . ' AND pref_name=' . $this->_db->quote($retrieve) . ' AND (' . $scope . ')';
Horde::logMessage(sprintf('SQL Query by Prefs_sql::getPref(): %s', $query), __FILE__, __LINE__, PEAR_LOG_DEBUG);
More information about the dev
mailing list