From: Michael M Slusarz Date: Tue, 7 Dec 2010 23:59:26 +0000 (-0700) Subject: Ticket #9431: prefs_init hook given way to indicate original value should be used X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b13e53dbc2274b268da52900b14850183c7304aa;p=horde.git Ticket #9431: prefs_init hook given way to indicate original value should be used --- diff --git a/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php b/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php index fd905b78b..8364159c0 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php +++ b/framework/Core/lib/Horde/Core/Prefs/Storage/Hooks.php @@ -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) {} } diff --git a/horde/config/hooks.php.dist b/horde/config/hooks.php.dist index 09f29a7bf..bbb7f6ef3 100644 --- a/horde/config/hooks.php.dist +++ b/horde/config/hooks.php.dist @@ -20,22 +20,23 @@ * ================= * 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 ''; // } // }