[horde] Need help with _username_hook_frombackend

tetra@cisco.or.id tetra at cisco.or.id
Mon May 8 03:59:25 PDT 2006


Quoting Demi <gruessle at gmail.com>:

> Hi
>
> What I am trying to do is let people login with their username without
> @example.com. Then I like to get the rest of the info from HTTP_HOST.
>
> Following is what I did but what it does this:
> It appends the $vdomain after login. So if someone logs in as username
> it fails, if someone logs in as username at example.com he/she gets in
> with
> userID=username at example.com@example.com
>
>
> // MY VERSION :
> if (!function_exists('_username_hook_frombackend')) {
>     function _username_hook_frombackend($userID)
>     {
>        $vdomain = preg_split('/\./', getenv('HTTP_HOST'), -1);
>        $vdomain = array_reverse($vdomain);
>        $vdomain = $vdomain[1] . "." . $vdomain[0];
>        return $userID . '@' . $vdomain;
>     }
> }
> if (!function_exists('_username_hook_tobackend')) {
>     function _username_hook_tobackend($userID)
>     {
>        $vdomain = preg_split('/\./', getenv('HTTP_HOST'), -1);
>        $vdomain = array_reverse($vdomain);
>        $vdomain = $vdomain[1] . "." . $vdomain[0];
>        if (substr($userID, -strlen($vdomain)) == $vdomain) {
>            $userID = substr($userID, 0, -strlen($vdomain));
>        }
>        return $userID;
>     }
> }
>
> Demi
Hi, Demi..
If I don't get you wrong (i am not a native English speaker :D), this is the
solution..
You should edit the "imp_hook_vinfo" part at /horde/config/hooks.php to 
be like
this:
=========================================================
if (!function_exists('_imp_hook_vinfo')) {
     function _imp_hook_vinfo($type = 'username')
     {
         $vdomain = getenv('HTTP_HOST');
         $vdomain = preg_replace('|^mail\.|i', '', $vdomain);
         $vdomain = String::lower($vdomain);

         if ($type == 'username') {
=========================================================
             return preg_replace('|\.|', '.', $_SESSION['imp']['user'] . '@' .
$vdomain);
//Note: Remember to replace the default "_" with "@"
=========================================================
         } elseif ($type == 'vdomain') {
             return $vdomain;
         } else {
             return PEAR::raiseError('invalid type: ' . $type);
         }
     }
}
=========================================================
Hope this could help :p.



---------------------------------------------------------------- 
Fakultas Teknologi Industri Jl. Kaliurang KM 14.5 Yogyakarta -Indonesia 
55584
Universitas Islam Indonesia



More information about the horde mailing list