This should work alittle bit better, just incase a user uses his full email address to login it won't fail.

 if (!function_exists('_imp_hook_vinfo')) {
     function _imp_hook_vinfo($type = 'username')
     {
         $vdomain = getenv('HTTP_HOST');
         $vdomain = preg_replace('|^(web)?mail\.|i', '', $vdomain);
         $vdomain = String::lower($vdomain);

         if ($type == 'username') {
             if(strpos($_SESSION['imp']['user'],'@')===false)
               return $_SESSION['imp']['user'] . '@' . $vdomain;
             else return $_SESSION['imp']['user'];
         } elseif ($type == 'vdomain') {
             return $vdomain;
         } else {
             return PEAR::raiseError('invalid type: ' . $type);
         }
     }
 }


Quoting Wayne Catterton <[email protected]>:

I got this piece to work, here's what I did:

horde/imp/config/conf.php

     $conf['hooks']['vinfo'] = true;

horde/imp/config/hooks.php


if (!function_exists('_imp_hook_vinfo')) {
     function _imp_hook_vinfo($type = 'username')
     {
         $vdomain = getenv('HTTP_HOST');
         $parts = explode(".",$vdomain);
         $rparts = array_reverse($parts);
         $vdomain = $rparts[1] . '.' . $rparts[0];
         $vdomain = String::lower($vdomain);
         $imp_user = Util::getFormData('imapuser');
         if ($type == 'username') {
        //      return preg_replace('|\.|', '', $_SESSION['imp']['user'] .
'@') . $vdomain;
                return $imp_user . '@' . $vdomain;
         } elseif ($type == 'vdomain') {
                return $vdomain;
         } else {
                return PEAR::raiseError('invalid type: ' . $type);
         }
     }
}

Then in horde/imp/config/servers.php

$servers['Imap'] = array(
        'name' => 'Imap Server',
        'server' => 'localhost',
        'hordeauth' => 'full',
        'protocol' => 'imap/notls',
        'port' => 143,
        'realm' => '',
        'preferred' => true,
        'smtphost' => 'domain.com',
        'smtpport' => 25,
);

This seems to work pretty well, I've tested it with the 2 domains I have
running, and all seems to work ok.

Ok,

Now that I got my slowness problem resolved, I have yet another.  I'm
using IMP for authentication, and it's authenticating via IMAP.  If I
login with [email protected] it works fine, but I want to be able to
just login with username.   Squirrelmail had a plugin to do this where it
grabs the domain from the URL and appends it to the username
automatically.  I can do the code for this without a problem, however I'm
confused on how to implement it, I've been reading up on hooks and stuff,
but it's still sorta cryptic, I don't know what to use for what and where,
if you know what I mean.

I turned on the vinfo hook in imp and modified it to suit my needs, so it
displays properly the @domain.com after the username box, but I think
that's all it does, it doesn't actually append that on to the username
that you enter, so that it can sucessfully login via IMAP.  I looked at
and fiddled around with the username_hook_tobackend and frombackend hooks,
but couldn't get anything to do anything for me.

What's the best way to accomplish this?

Thanks,


--
Wayne Catterton CCNA
Network Engineer
Scappoose, OR

--
IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]



--
Wayne Catterton CCNA
Network Engineer
Scappoose, OR

--
IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]




--
IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [email protected]

Reply via email to