[sam] Problem with saving preferences (patch)

Adam Yearout adam at cbnn.net
Wed Mar 12 20:50:22 PST 2003


Came across a small bug in regards to SAM's preference storing mechanism 
in sam/lib/Driver/sql.php.  Originally it was set to simply ignore any 
changes if the setting matched the default setting, but then in that 
case, it wouldn't get changed _at all_.  Modified the function so that 
it will DELETE the preference from the sql table instead, and thus 
simply load the default automatically for that user preference.

Hope that makes sense.  :)

--

Adam Yearout
adam at cbnn.net
-------------- next part --------------
--- sql.php.orig	Sat Feb 15 16:30:05 2003
+++ sql.php	Wed Mar 12 20:38:57 2003
@@ -199,11 +199,14 @@
         }
             
         foreach ($store as $preference => $value) {
-            /* Don't save a user pref if it is just set to the
-             * default. */
+            /* Delete the user pref if it is the same as the default */ 
             if ($type === SAM_PREFTYPE_USER &&
                 array_key_exists($preference, $this->defaults) &&
                 $this->defaults[$preference] == $value) {
+                $this->_db->query(sprintf('DELETE FROM %s WHERE horde_id = %s AND preference = %s;',
+                                          $this->_params['table'],
+                                          $this->_db->quote($uid),
+                                          $this->_db->quote($preference)));
                 continue;
             }
 


More information about the sam mailing list