public function getAuth($format = null)
{
global $session;
if (is_null($format) && !is_null($this->_cache['auth'])) {
return $this->_cache['auth'];
}
if (!isset($session)) {
return false;
}
if ($format == 'original') {
return $session->exists('horde', 'auth/authId') ? $session->get('horde', 'auth/authId') : false;
}
$user = $session->get('horde', 'auth/userId');
if (is_null($user)) {
return false;
}
switch ($format) {
case 'bare':
return ($pos = strpos($user, '@')) === false ? $user : substr($user, 0, $pos);
case 'domain':
return ($pos = strpos($user, '@')) === false ? false : substr($user, $pos + 1);
default:
/* Specifically cache this result, since it generally is called
* many times in a page. */
$this->_cache['auth'] = $user;
return $user;
}
}