Bug #9431: Pass value into prefs_init hook
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 8 Dec 2010 00:07:28 +0000 (17:07 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 8 Dec 2010 00:07:28 +0000 (17:07 -0700)
Note, the function signature for prefs_init has changed.  You will need
to update your hooks.php file if currently using the prefs_init hook.

framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php
horde/config/hooks.php.dist
imp/config/hooks.php.dist

index 8364159..d275b85 100644 (file)
@@ -27,10 +27,7 @@ class Horde_Core_Prefs_Storage_Hooks extends Horde_Prefs_Storage_Base
 
         foreach ($conf_ob->hooks[$scope_ob->scope] as $name) {
             try {
-                $value = Horde::callHook('prefs_init', array($name, $this->_params['user']), $scope_ob->scope);
-                if (!is_null($value)) {
-                    $scope_ob->set($name, $value);
-                }
+                $scope_ob->set($name, Horde::callHook('prefs_init', array($name, $scope_ob->get($name), $this->_params['user']), $scope_ob->scope));
             } catch (Horde_Exception_HookNotSet $e) {}
         }
 
index bbb7f6e..0c757d1 100644 (file)
@@ -24,9 +24,9 @@
  * ----------------------
  * 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. If null
- * is returned, the original preference value is used.
+ * This hook receives the preference name, preference value, and the username
+ * as parameters and uses the return value from the hook as the new preference
+ * value.
  *
  * This hook is ONLY executed on login and preferences are cached during a
  * users' session.
 class Horde_Hooks
 {
 //    // PREFERENCES INIT: See above for documentation.
-//    public function prefs_init($pref, $username = null)
+//    public function prefs_init($pref, $value, $username = null)
 //    {
 //        switch ($pref) {
 //        case 'from_addr':
index c2d5cf2..0a82af7 100644 (file)
@@ -49,12 +49,8 @@ class IMP_Hooks
      * PREFERENCE INIT: Set preference values on login.
      *
      * See horde/config/hooks.php.dist for more information.
-     *
-     * @param string $username  The username.
-     *
-     * @return string  The prefrence value.
      */
-//    public function prefs_init($pref, $username = null)
+//    public function prefs_init($pref, $value, $username = null)
 //    {
 //        if (!$username) {
 //            return;
@@ -80,7 +76,7 @@ class IMP_Hooks
 //                return json_encode(array_keys($sources));
 //            }
 //
-//            return $GLOBALS['prefs']->getValue($pref);
+//            return $value;
 //        }
 //    }