Пример #1
0
 /**
  * Gets auth and perm container objects back from session and tries
  * to give them an active database/whatever connection again.
  *
  * @return boolean true on success or false on failure
  *
  * @access private
  */
 function _unfreeze()
 {
     if (!$this->_options['session']['force_start']) {
         if (!isset($_REQUEST[$this->_options['session']['name']])) {
             return false;
         }
         $this->_startSession();
     }
     if (isset($_SESSION[$this->_options['session']['varname']]['auth']) && is_array($_SESSION[$this->_options['session']['varname']]['auth']) && isset($_SESSION[$this->_options['session']['varname']]['auth_name']) && strlen($_SESSION[$this->_options['session']['varname']]['auth_name']) > 0) {
         $containerName = $_SESSION[$this->_options['session']['varname']]['auth_name'];
         $auth =& LiveUser::authFactory($this->_authContainers[$containerName], $containerName);
         if ($auth === false) {
             return false;
         }
         if ($auth->unfreeze($_SESSION[$this->_options['session']['varname']]['auth'])) {
             $auth->backendArrayIndex = $_SESSION[$this->_options['session']['varname']]['auth_name'];
             $this->_auth =& $auth;
             if (isset($_SESSION[$this->_options['session']['varname']]['perm']) && $_SESSION[$this->_options['session']['varname']]['perm']) {
                 $perm =& LiveUser::permFactory($this->_permContainer);
                 if ($perm === false) {
                     return $perm;
                 }
                 if ($this->_options['cache_perm']) {
                     $result = $perm->unfreeze($this->_options['session']['varname']);
                 } else {
                     $result = $perm->mapUser($auth->getProperty('auth_user_id'), $auth->backendArrayIndex);
                 }
                 if ($result) {
                     $this->_perm =& $perm;
                 }
             }
             $this->_status = LIVEUSER_STATUS_UNFROZEN;
             $this->dispatcher->post($this, 'onUnfreeze');
             return true;
         }
     }
     return false;
 }
Пример #2
0
 /**
  * Gets auth and perm container objects back from session and tries
  * to give them an active database/whatever connection again.
  *
  * @return bool true on success or false on failure
  *
  * @access private
  */
 function _unfreeze()
 {
     if (!$this->_options['session']['force_start']) {
         if (!array_key_exists($this->_options['session']['name'], $_REQUEST)) {
             return false;
         }
         $this->_startSession();
     }
     if (isset($_SESSION[$this->_options['session']['varname']]) && array_key_exists('auth', $_SESSION[$this->_options['session']['varname']]) && is_array($_SESSION[$this->_options['session']['varname']]['auth']) && array_key_exists('auth_name', $_SESSION[$this->_options['session']['varname']]) && strlen($_SESSION[$this->_options['session']['varname']]['auth_name']) > 0) {
         $containerName = $_SESSION[$this->_options['session']['varname']]['auth_name'];
         $auth =& LiveUser::authFactory($this->_authContainers[$containerName], $containerName);
         if ($auth === false) {
             $this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate auth container: ' . $containerName));
             return false;
         }
         if ($auth->unfreeze($_SESSION[$this->_options['session']['varname']]['auth'])) {
             $auth->containerName = $_SESSION[$this->_options['session']['varname']]['auth_name'];
             $this->_auth =& $auth;
             if (array_key_exists('perm', $_SESSION[$this->_options['session']['varname']]) && $_SESSION[$this->_options['session']['varname']]['perm']) {
                 $perm =& LiveUser::permFactory($this->_permContainer);
                 if ($perm === false) {
                     $this->stack->push(LIVEUSER_ERROR, 'exception', array('msg' => 'Could not instanciate perm container of type: ' . $this->_permContainer));
                     return $perm;
                 }
                 if ($this->_options['cache_perm']) {
                     $result = $perm->unfreeze($this->_options['session']['varname']);
                 } else {
                     $result = $perm->mapUser($auth->getProperty('auth_user_id'), $auth->containerName);
                 }
                 if ($result) {
                     $this->_perm =& $perm;
                 }
             }
             $this->_status = LIVEUSER_STATUS_UNFROZEN;
             $this->dispatcher->post($this, 'onUnfreeze');
             return true;
         }
     }
     return false;
 }
Пример #3
0
 /**
  * Setup backend container.
  *
  * Upon success it will return true. You can then
  * access the backend container by using the auth
  * and perm properties of this class.
  *
  * e.g.: $admin->perm->getUsers();
  *
  * @param int user auth id
  * @param  string auth container name
  * @return bool true upon success, false otherwise
  *
  * @access public
  */
 function init($authUserId = null, $authName = null)
 {
     if (!is_array($this->_conf)) {
         $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Missing configuration array'));
         return false;
     }
     if (is_null($authName)) {
         if (is_null($authUserId)) {
             reset($this->_conf['authContainers']);
             $authName = key($this->_conf['authContainers']);
         } else {
             foreach ($this->_conf['authContainers'] as $key => $value) {
                 if (!isset($this->_authContainers[$key]) || !is_object($this->_authContainers[$key])) {
                     $auth =& LiveUser::authFactory($value, $key, 'LiveUser_Admin_');
                     if ($auth === false) {
                         $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Could not instanciate auth container: ' . $key));
                         return $auth;
                     }
                     $this->_authContainers[$key] =& $auth;
                 }
                 if (!is_null($authUserId)) {
                     $match = $this->_authContainers[$key]->getUsers(array('filters' => array('auth_user_id' => $authUserId)));
                     if (is_array($match) && count($match) > 0) {
                         $authName = $key;
                         break;
                     }
                 }
             }
         }
         if (!isset($authName)) {
             $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Could not determine what auth container to use'));
             return false;
         }
     }
     if (!$this->setAdminAuthContainer($authName)) {
         return false;
     }
     if (!isset($this->perm) || !is_object($this->perm)) {
         if (!$this->setAdminPermContainer()) {
             return false;
         }
     }
     return true;
 }