[horde] loading pref in preauth hook

Jan Schneider jan at horde.org
Fri Mar 30 14:50:30 UTC 2007


Zitat von Kevin Conley <kevinconley at northwestern.edu>:

> I created a mail protocol pref so a user can dynamically choose their mail
> server protocol instead of having it statically set in servers.php or as a
> dropdown list on the login page.
>
> Currently in the preauth hook I am just doing a raw SELECT mysql call to get
> this preference as the global pref variable is not set before a user logs in.
>
> However, I think I can save a db connection by instead of just doing  
> the raw sql
> call I can initialize the $pref global singleton. Therefore, after  
> auth the sql
> call will not be needed when HORDE goes to load create the pref  
> singleton as normal.
>
> I have tried to do this in the preauth hook but can't seem to get it  
> to work -
> any ideas of the syntax of this call?

I wouldn't worry too much about the db connection. DB::connect() is a  
singleton, so as long as you use it by reference and use the same  
connection credentials like horde, there is no additional connection.  
Only an additional (but fast) query.
Tinkering with prefs and authentication in a pre-auth hook sounds like  
potential side-effect problems.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the horde mailing list