Ticket #9431: prefs_init hook given way to indicate original value should be used
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Dec 2010 23:59:26 +0000 (16:59 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 7 Dec 2010 23:59:38 +0000 (16:59 -0700)
framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php
horde/config/hooks.php.dist

index fd905b7..8364159 100644 (file)
@@ -27,7 +27,10 @@ class Horde_Core_Prefs_Storage_Hooks extends Horde_Prefs_Storage_Base
 
         foreach ($conf_ob->hooks[$scope_ob->scope] as $name) {
             try {
-                $scope_ob->set($name, Horde::callHook('prefs_init', array($name, $this->_params['user']), $scope_ob->scope));
+                $value = Horde::callHook('prefs_init', array($name, $this->_params['user']), $scope_ob->scope);
+                if (!is_null($value)) {
+                    $scope_ob->set($name, $value);
+                }
             } catch (Horde_Exception_HookNotSet $e) {}
         }
 
index 09f29a7..bbb7f6e 100644 (file)
  * =================
  * Two types of preferences hooks are available.
  *
- * On change
- * ---------
- * A hook named prefs_change will be called after a preference is altered.
- * It is passed the preference name that has changed and does not expect a
- * return value.
- *
- * Setting value
- * -------------
+ * Setting value at login
+ * ----------------------
  * If the 'hook' parameter is non-empty for a preference (config/prefs.php),
  * the prefs_init hook will be run on login to allow alteration of the value.
  * This hook receives the preference name and the username as parameters and
- * uses the return value from the hook as the new preference value.
+ * uses the return value from the hook as the new preference value. If null
+ * is returned, the original preference value is used.
  *
  * This hook is ONLY executed on login and preferences are cached during a
  * users' session.
  *
+ * On change
+ * ---------
+ * A hook named prefs_change will be called after a preference is altered.
+ * It is passed the preference name that has changed and does not expect a
+ * return value.
+ *
  * Authentication/Login Hooks
  * ==========================
  * There are three special hooks called during the initial authentication
@@ -289,11 +290,9 @@ class Horde_Hooks
 //
 //            case 'turba':
 //                return 'orange';
-//
-//            default:
-//                return '';
 //            }
-//            break;
+//
+//            return '';
 //        }
 //    }