//100Username
{
$OUT =<<'HERE';
class Horde_Hooks
\{
      public function preauthenticate($userId, $credentials)
      \{
         return array( 
                'userId' => Horde_String::lower($userId),
                'credentials' => $credentials
      );
      
      \}

      public function authusername($userId, $toHorde)
      \{
          // Example #1: Append the virtual domain to the username.
          // ex. $HTTP_HOST = 'mail.mydomain.com', $userId = 'myname' returns:
          // 'myname@mydomain.com'
          $vdomain = getenv('HTTP_HOST');
          preg_match('/[^.]+\.[^.]+$/', $vdomain, $matches);
          $vdomain = $matches[0];   
          if ($userId == 'adminremoveuser') \{
               return $userId;
          \} else \{
             if ($toHorde) \{
                 return $userId . '@' . $vdomain;
             \} else \{
                  return (substr($userId, -strlen($vdomain)) == $vdomain)
                  ? substr($userId, 0, -strlen($vdomain)-1)
                  : $userId;
             \}
          \}
      \}
\}

HERE
}
