[imp] virtual users and their from addys...
Daniel Frazier
dfrazier at glengroup.com
Fri Jul 1 06:08:31 PDT 2005
FWIW, I finally got this working. hope this helps someone down the
road...
horde/config/hooks.conf:
if (!function_exists('_prefs_hook_from_addr')) {
function _prefs_hook_from_addr($user = null)
{
if (is_null($user)) {
$user = Auth::getAuth();
}
if (strstr($user, '%')) {
return preg_replace('|%|', '@', $user); } else {
return $user;
}
}
}
horde/config/prefs.php:
$_prefs['from_addr'] = array(
'value' => '',
'locked' => true,
'shared' => true,
'type' => 'text',
'hook' => 'true',
'desc' => _("Your From: address:")
);
Daniel Frazier wrote:
> Kevin Myer wrote:
>
>>Quoting Daniel Frazier <dfrazier at glengroup.com>:
>>
>>
>>
>>>anyone? I've been playing with various hooks for the last 3 days, but
>>>the specifics of what variables I need to be modifying are eluding me...
>>>I've gotten the from address to show as "virtuser%virtdomain@" by
>>>unsetting the maildomain in imp/config/servers.php, but that's no good.
>>>It needs to be "virtuser at virtdomain" so my users don't complain... I'll
>>>keep plugging away, but would really, really appreciate some guidance
>>
>>>from someone who knows what they're doing.
>>
>>
>>I don't pretend to know what I'm doing but if you've gotten it to the state of
>>virtuser%virtdomain, just do a preg_replace on it and replace @ with nothing
>>and the % with @.
>>
>>Kevin
>>
>
>
> Thanks for the input, Kevin. It's not so much the how to do it that's
> got me boggled, it's the "what" and "where". What variables need to be
> massaged and where the heck are they? I know perl well enough to hack
> at the php, and I've got some expert developers here who can help if
> needed. I've tried adding...
>
> $conf['hooks']['username'] = true;
>
> ...to horde/imp/config/conf.php, and added this entry to
> /horde/config/hooks.php:
>
> if (!function_exists('_imp_hook_username'))
> {
> function _imp_hook_username($userid)
> {
> if (strstr($userid, '%'))
> {
> $parts = explode('%', $userid);
> $userid = $parts[0] . '@' . $parts[1];
> return $userid;
> } else {
> return $userid;
> }
> }
> }
>
> But it's just not working! I added a hook for sam as well, in order
> to get the prefs added to mysql correctly, and that one works like a
> champ.
>
> if (!function_exists('_sam_hook_username')) {
> function _sam_hook_username($horde_uid)
> {
> if (strstr($horde_uid, '%')) {
> $parts = explode('%', $horde_uid);
> $horde_uid = $parts[0] . '@' . $parts[1];
> return $horde_uid;
> } else {
> return $horde_uid;
> }
> }
> }
>
> As you can see, it's basically the same code. I've tried it using
> both $userid and $horde_uid, but neither affects the login. I can't
> tell if this hook is being called at all, or if I just haven't tried the
> right username variable. If I log in using "virtuser at virtdomain"
> everything works as it should, but I want to enforce using a "%" 'cause
> that's what they have to use when using their normal email clients and I
> don't want to confuse my users any more than necessary.
>
> I've also played with the the vinfo hook, but that doesn't give me what
> I need. It seems to want to use the same vdomain for everyone who logs
> in, which is no good. I just want users to log in using their normal
> username, "vuser%vdomain", and have imp change that to "vuser at vdomain"
> immediately after logging in.
>
--
----------------------------------------------------------------------
Daniel Frazier <daniel at glengroup.com> Tel: 603-356-3030 Ext. 331
Systems Administrator
Glen Group WWW: http://www.glengroup.com/
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
- Benjamin Franklin, Historical Review of Pennsylvania, 1759.
More information about the imp
mailing list