From 30149a9e62b96cd9112a5849234ca60dc60eda7d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 7 Dec 2010 17:07:28 -0700 Subject: [PATCH] Bug #9431: Pass value into prefs_init hook 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 | 5 +---- horde/config/hooks.php.dist | 8 ++++---- imp/config/hooks.php.dist | 8 ++------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php b/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php index 8364159c0..d275b85f0 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php +++ b/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php @@ -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) {} } diff --git a/horde/config/hooks.php.dist b/horde/config/hooks.php.dist index bbb7f6ef3..0c757d171 100644 --- a/horde/config/hooks.php.dist +++ b/horde/config/hooks.php.dist @@ -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. @@ -149,7 +149,7 @@ 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': diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index c2d5cf20d..0a82af70c 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -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; // } // } -- 2.11.0