Exemple #1
0
 /**
  * This function generates a new session.
  *
  * @access protected
  * @override
  * @return string                           the new session id
  */
 protected function _regenerate()
 {
     do {
         // Create a new session id
         $id = str_replace('.', '-', uniqid(NULL, TRUE));
         $count = DB_ORM::select($this->_table, array($this->_columns['session_id']))->where($this->_columns['session_id'], DB_SQL_Operator::_EQUAL_TO_, $id)->query()->count();
     } while ($count > 0);
     return $this->_session_id = $id;
 }
Exemple #2
0
 /**
  * This function returns a result set containing all nodes in the specified tree's scope.
  *
  * @access public
  * @static
  * @param integer $scope                            the scope of the desired tree
  * @param string $ordering                          the ordering token that signals whether the
  *                                                  left column will sorted either in ascending or
  *                                                  descending order
  * @param integer $limit                            the "limit" constraint
  * @return DB_ResultSet                             a result set containing all nodes in the
  *                                                  specified tree's scope
  */
 public static function full_tree($scope, $ordering = 'ASC', $limit = 0)
 {
     $model = get_called_class();
     $results = DB_ORM::select($model)->where('scope', DB_SQL_Operator::_EQUAL_TO_, $scope)->order_by('lft', $ordering)->limit($limit)->query();
     return $results;
 }
Exemple #3
0
 /**
  * This function logs the current user out.
  *
  * @access public
  * @param boolean $destroy                  whether the session is to be to completely
  *                                          destroyed
  * @param boolean $logout_all               whether all tokens for user are to be removed
  * @param boolean                           whether the logout was successful
  */
 public function logout($destroy = FALSE, $logout_all = FALSE)
 {
     // Set by force_login()
     $this->_session->delete('auth_forced');
     if ($token = Cookie::get('authautologin')) {
         // Delete the autologin cookie to prevent re-login
         Cookie::delete('authautologin');
         // Clear the autologin token from the database
         $token = DB_ORM::select($this->models['token'])->where($this->columns['token'], DB_SQL_Operator::_EQUAL_TO_, $token)->limit(1)->query()->fetch(0);
         $token_model = DB_ORM_Model::model_name($this->models['token']);
         if ($logout_all) {
             DB_ORM::delete($this->models['token'])->where($this->columns['user_id'], DB_SQL_Operator::_EQUAL_TO_, $token->user)->execute();
         } else {
             if ($token instanceof $token_model and $token->is_loaded()) {
                 $token->delete();
             }
         }
     }
     return parent::logout($destroy);
 }