T'Krin's Realm

My yammerings…

Tuesday, August 25, 2009

Add domain automatically to Default Identity in Horde when using standard passwd files

I did a lot of searching for this and finally came up with this solution based on a couple of different ones that I found. These changes will automatically fill in the domain portion of the e-mail address in the Default Identity and lock it down so users can not change their e-mail address on the server.

1 – Edit config/hooks.php and add the following hook:

if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($user = null)
{
if (is_null($user)) {
$user = Auth::getAuth();
}
if (!empty($user)) {
$user = Auth::getAuth();
$mail = "$user" . "@example.com";
return (empty($mail) ? '' : $mail);
}
return '';
}
}

2 – Edit config/prefs.php and change

$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'shared' => true,
'type' => 'text',
'desc' => _("Your From: address:")

to

$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'hook' => true,
'shared' => true,
'type' => 'text',
'desc' => _("Your From: address:")
);

posted by tkrin at 7:39 AM  

2 Comments »

  1. Hello,
    I have follow your script to hook.
    But user login email address always show only “from_addr@default….”
    Is have other setup?
    Or other setup need to check?
    Thanks a lot.

    Comment by akong — 2010-09-17 @ 7:16 PM

  2. akong, did you add the

    ‘hook’ => true,

    line to the prefs.php file as well or just edit the hooks.php?

    Comment by tkrin — 2010-09-19 @ 3:06 PM

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress