Horde_Registry::getAuth PHP 메소드

getAuth() 공개 메소드

Returns the currently logged in user, if there is one.
public getAuth ( string $format = null ) : mixed
$format string The return format, defaults to the unique Horde ID. Alternative formats: - bare: (string) Horde ID without any domain information. EXAMPLE: [email protected] would be returned as 'foo'. - domain: (string) Domain of the Horde ID. EXAMPLE: [email protected] would be returned as 'example.com'. - original: (string) The username used to originally login to Horde.
리턴 mixed The user ID or false if no user is logged in.
    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;
        }
    }

Usage Example

예제 #1
0
파일: Locks.php 프로젝트: raz0rsdge/horde
 /**
  * Locks a uri
  *
  * @param string $uri
  * @param Locks\LockInfo $lockInfo
  * @return bool
  */
 public function lock($uri, Locks\LockInfo $lockInfo)
 {
     list($app) = explode('/', $uri);
     $type = $lockInfo->scope == Locks\LockInfo::EXCLUSIVE ? Horde_Lock::TYPE_EXCLUSIVE : Horde_Lock::TYPE_SHARED;
     try {
         $lockId = $this->_lock->setLock($this->_registry->getAuth(), $app, $uri, $lockInfo->timeout ?: Horde_Lock::PERMANENT, $type);
         $lockInfo->token = $lockId;
     } catch (Horde_Lock_Exception $e) {
         throw new DAV\Exception($e->getMessage(), $e->getCode(), $e);
     }
 }
All Usage Examples Of Horde_Registry::getAuth