[horde] Fetching Horde 'from_addr' for mysql in hooks.php

Otto Stolz Otto.Stolz at uni-konstanz.de
Thu Sep 28 03:19:54 PDT 2006


Hello Jacques Beaudoin,

you wrote:
> I would like to fetch the 'from_addr' field in the horde
> 'hooks.php' file.

I do not really understand what you mean by "fetch".

It just so happens that I yesterday have finished the
_prefs_hook_from_addr for my forthcoming Horde 3.1.2
+ IMP 4.1.2 installation -- and it works.

_prefs_hook_from_addr should yield the address
to be used in the From filed (and in the SMTP
envelope) of messages composed by Imp.  This may be
what you are looking for.

To activate _prefs_hook_from_addr, you have to
amend the pertinent entry in horde/config/prefs.php
to read:
   $_prefs['from_addr'] = array(
       'value' => '',
       'locked' => true,
       'hook'   => true,
       'shared' => true,
       'type' => 'text',
       'desc' =>  _("Your From: address:")
   );

If you thus have set $_prefs['from_addr']['hook'],
_prefs_hook_fullname will be called 2 times during login,
and 3 times during logoff. Only the second one of these
5 invocations is meant to be taken seriously: this one has
an actual argument.

So your _prefs_hook_fullname would be look like:
   if (!function_exists('_prefs_hook_from_addr')) :
     function _prefs_hook_from_addr($name=NULL)
     {return (empty($name) ? '' : cspi_user_data('from_address', $name));}
   endif;
where cspi_user_data does the real information retrieving.
(Note that, in 80% of the invocations, $name will be NULL,
hence the result will be ''.)

Horde will cashe the result of that second (serious) invocation
with the session data, and Imp will use it whenever a message
is composed during that session. (Note that, during message
composition, _prefs_hook_fullname will not again be asked for
an address.)

In my case, my own knu_user_data function will retrieve the
user information from the pertinent LDAP server, and will
cashe it in the session data, so the LDAP server is bothered
only once per session. In my implementation, Horde will
keep the session data in a MySQL data base, but the technical
realization of Horde's storage does not really matter for your
current question.

Good luck,
   Otto Stolz




More information about the horde mailing list