[dev] selecting IMAP server based on username

Aleksandar Milivojevic alex at milivojevic.org
Fri Aug 26 12:04:25 PDT 2005


I've read http://wiki.horde.org/ImapSelect?referrer=HowTo, and decided to
implement something similar.

I've patched horde/config/conf.xml and horde/imp/lib/IMP.php files.  In
conf.xml, I've added configuration option $conf[hooks][imapserver] to support
custom _hook_imp_imapserver function.  Then, I placed call to it at the start
of IMP::getAutoLoginServer() (see attached diff).

Seems that IMP::getAutoLoginServer() is called whenever user clicks on anything.
 Not sure why.  The only way for its return value to change is if administrator
changed servers.php file in the middle of user's session.  Which wouldn't be a
good thing from user's perspective if he gets unexpectedly bounced from one
mail server to another.  It could probably be called only once, but anyhow.

The question I have is, given the above behaviour, if I want to call hook only
once per session, should I simply place whatever hook returns into the
$_SESSION['__auth']['autologinserver'] (or wherever), and use it instead of
calling the hook, or should I use some other mechanism for caching this data? 
No point in bombarding database backend (wich in my case holds username ->
mail_server mapping) with queries that always return same result.

Another question is, is IMP::getAutoLoginServer() the right place to call hook
from?  It looked as best candidate to me.

BTW, is there a chance for something like this to go into IMP distribution?  It
would be an usefull feature for sites where users are distributed across
multiple IMAP servers, and there's no clashes in usernames.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the dev mailing list