[horde] only first initialization of preferences via hooks

Steffen skhorde at smail.inf.fh-bonn-rhein-sieg.de
Tue Mar 4 15:04:09 UTC 2014


Hi,

how do I initialize preferences of users via hooks, but then keep my hands 
off them for later logins? I use: horde 5.1.5 stable

E.g. I want to pre-select [taken from imp]:

         case 'search_sources':
                 $sources = $GLOBALS['registry']->call('contacts/sources');
                 $me = json_encode(array_keys($sources));
                 return $me;
         case 'display_cals':
                  $me = serialize(array('shared_cal'));
                  return $me;


But if the user changes the list, it is overwritten the next time the user 
logs in. Also, some prefs query LDAP a.s.o. which is not necessary, once 
the user prefs have been initialized once.

Ideally, I want to return $value, if the user does login for the 2nd or 
more time, e.g.:

     public function prefs_init($pref, $value, $username, $scope_ob)
     {
             if (is_null($username)) {   // not logged in
                 return $value;
             }

 	   if (!is_first_time_login($username)) {
 		return $value;
 	   }

 	   // heave-weight fist time initialization of user prefs
     }

Should I configure an invalid default value like so:

$_prefs['search_sources']['hook'] = true;
$_prefs['search_sources']['value'] = false;

and trigger on the fact that $value passed into prefs_init() is "false", 
what is an invalid value for search_sources?

-- 
Steffen


More information about the horde mailing list