[dev] New prefs_init hook

Michael M Slusarz slusarz at horde.org
Thu Feb 10 18:40:21 UTC 2011


Quoting Jan Schneider <jan at horde.org>:

> IIUC the new prefs_init hook is called *always* after logging in.  
> This is a change from the old behavior where the preference hooks  
> were only called if a value hasn't been set yet.
>
> 1) is this the intended behavior?
> 2) if yes, why?
> 3) who is one supposed to determine if the value passed to the hook  
> is the user's value or the pref's default value?

1) Yes.

2) Because there was no way to reliably do things like altering a  
currently existing preference, or removing an already set preference.   
You could do this in a hook elsewhere, a login task, etc.  But it  
would not be guaranteed that the original preference value might be  
used somewhere in the meantime.

e.g. A theme called 'foo' exists.  Some users switch to 'foo'.  'foo'  
is removed as a theme.  An admin doesn't want to mess with the backend  
to change this value, so he uses a prefs_init hook to change the value  
of 'foo' to something else.

The use-case you describe above is only one thing an admin would want  
to do when initializing a preference value.  The current prefs_init  
method is a more general solution for allowing other tasks, while  
guaranteeing that the pref value will never be used unless it is  
exactly what the admin wants it to be.

3) $injector->getInstance('Horde_Prefs')->isDefault($pref_name)

michael

-- 
___________________________________
Michael Slusarz [slusarz at horde.org]




More information about the dev mailing list