[horde] How to program Horde, and Imp, hooks?

Jan Schneider jan at horde.org
Wed Aug 9 09:08:09 PDT 2006


Zitat von Otto Stolz <Otto.Stolz at uni-konstanz.de>:

> Hello,
>
> for historic reasons, the names of the mailboxes in our IMAP server
> have no algorithmic relation to the e-mail addresses. E. g., the
> mailbox (= IMAP account) for my test account is "pop15959", whilst
> the e-mail address is "hugine.habicht at uni-konstanz.de". I can look
> up the relation (in both directions), in our LDAP server.
>
> Now,
>
> 1. I want the user to login, directly to Imp H3 4.1.2, with the
>    local part of their respective e-mail address,
>    e. g. "hugine.habicht"; then Imp will have to determine the proper
>    IMAP account, via an LDAP request.
>
> 2. I also want the proper e-mail address, and the cn from the LDAP
>    entry, to be used for the SMTP "MAIL FROM" command, and for the
>    RFC 822 "From:" header.
>
> Ad 1.
>
> I guess that an _imp_hook_vinfo function in horde/config/hooks.php
> could be used to find the proper IMAP account, but I cannot figure
> out the exact interface for that function.

This is not exactly what the vinfo hook for but it might still work.  
If not, you should be using the username_from/to_backend hooks instead.

> - imp/config/conf.xml says: "The hook will be used to set $imp['user']
>   at login time." -- but then, what is the exact purpose of that
>   variable? Will it be used as the IMAP account, or as the From address?

The IMAP account.

>   Is it supposed to contain a complete e-mail address, or only the local
>   part?

The IMAP user name.

> - The example in horde/config/hooks.php.dist mentions:
>   · a global variable named $_SESSION['imp']['user'],
>   · an argument called $type, that may have the value 'username',
>     or 'vdomain', or possibly something else.
>   But I cannot find any information on
>   · the possible keys and values of the $_SESSION array,
>     and their respective use and meaning,

You probably don't need them, but they are documented in imp/lib/Session.php

>   · the possible values of that $type argument,
>     and their respective meaning,

You already mentioned the possible values. If 'vdomain', the hook is  
expected to return a string that will be appended to the user name  
field of the login screen, usually a domain name. If 'username', the  
hook is expected to return the IMAP user name.

>   · the meaning, and syntax, of the result this function
>     is supposed to yield.

See above.

> Where can I find the missing documentation?
> Or, if a kind soul would be willing to tell me, how
> (with which arguments) will this function be invoked,
> and what is it supposed to yield, in the "Hugine.Habicht"
> example outlined above?
>
> Ad 2.
>
> I guess that the _imp_hook_vinfo function is also somehow involved
> in determining the correct From address -- but how? I hope, this
> will become evident from the answer on item 1, above.

Only as a fallback, if the From address can't be determined by other means.

> I also guess, that I will have to provide another hook to find
> the full name for the RFC 822 From header, probably

Correct.

> _prefs_hook_fullname. But again, I cannot derive from the
> examples provided in horde/config/hooks.php.dist how this
> function will be invoked, and what it is supposed to yield.

Why not? The examples are pretty self explanatory.

> - It will be invoked with one argument, named $user.  I guess,
>   this is the user name supplied in the login screen -- or
>   can it be some other string, possibly derived from
>   _imp_hook_vinfo's result? And why do the examples provided
>   check for an empty argument? And what string will be delivered
>   by Auth::get_Auth() -- in the example outlined above, will it
>   be "pop15959", or "hugine.habicht at uni-konstanz.de", or
>   "hugine.habicht"?

It's the internal Horde user name. Which this is exactly is being  
determined by the several hooks.

> - And what is the difference between Auth::get_Auth() and
>   $_SESSION['imp']['user']?

Auth::getAuth() returns the Horde user name, the session value is the  
IMAP user name, which can be different.

> - Is _prefs_hook_fullname supposed to yield the user's common name
>   in UTF-8, or as an encoded-word, according to RFC 2047?

Good question, I guess it has to be in the interface charset that can  
be determined with NLS::getCharset().

Jan.

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



More information about the horde mailing list