Example #1
0
 /**
  * Returns a new SessionQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     SessionQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return SessionQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof SessionQuery) {
         return $criteria;
     }
     $query = new SessionQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 /**
  *   @see parent::sessionRead
  */
 public function sessionRead($id)
 {
     $result = parent::sessionRead($id);
     $this->setSessionKey($id);
     // Find session persistent object
     $session = SessionQuery::create()->filterBySessionKey($id)->findOne();
     // Associate an IP address with the session & user
     if (!is_null($session) && $session instanceof Session) {
         $context = sfContext::getInstance();
         if ($session->getClientIpAddress() == null) {
             $session->setClientIpAddress($context->getRequest()->getRemoteAddress());
         }
         // Associate User with session
         $user = $context->getUser();
         if ($session->getUserId() == null && !is_null($user) && $user->isAuthenticated()) {
             $session->setUser($user->getProfile());
         }
         $session->save();
     }
     return $result;
 }
Example #3
0
    $_SESSION["postVars"] = $_POST;
    $_SESSION["pageErrors"] = $pageErrors;
    header("Location: ../shared/loginform.php");
    exit;
}
#****************************************************************************
#*  Redirect to suspended message if suspended
#****************************************************************************
if ($staff->isSuspended()) {
    header("Location: ../shared/suspended.php");
    exit;
}
#**************************************************************************
#*  Insert new session row with random token
#**************************************************************************
$sessionQ = new SessionQuery();
$sessionQ->connect();
if ($sessionQ->errorOccurred()) {
    $sessionQ->close();
    displayErrorPage($sessionQ);
}
$token = $sessionQ->getToken($staff->getUserid());
if ($token == false) {
    $sessionQ->close();
    displayErrorPage($sessionQ);
}
$sessionQ->close();
#**************************************************************************
#*  Destroy form values and errors and reset signon variables
#**************************************************************************
unset($_SESSION["postVars"]);
Example #4
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return     void
  * @throws     PropelException
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(SessionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = SessionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #5
0
 $_SESSION["returnPage"] = $returnPage;
 #****************************************************************************
 #*  Checking to see if session variables exist
 #****************************************************************************
 if (!isset($_SESSION["userid"]) or $_SESSION["userid"] == "") {
     header("Location: ../shared/loginform.php");
     exit;
 }
 if (!isset($_SESSION["token"]) or $_SESSION["token"] == "") {
     header("Location: ../shared/loginform.php");
     exit;
 }
 #****************************************************************************
 #*  Checking session table to see if session_id has timed out
 #****************************************************************************
 $sessQ = new SessionQuery();
 $sessQ->connect();
 if ($sessQ->errorOccurred()) {
     displayErrorPage($sessQ);
 }
 if (!$sessQ->validToken($_SESSION["userid"], $_SESSION["token"])) {
     if ($sessQ->errorOccurred()) {
         displayErrorPage($sessQ);
     }
     $sessQ->close();
     header("Location: ../shared/loginform.php?RET=" . U($returnPage));
     exit;
 }
 $sessQ->close();
 #****************************************************************************
 #*  Checking authorization for this tab
Example #6
0
 /**
  * Retrieves a single Session by the provided session key
  *
  * @param string $session_key
  * @return Session
  */
 public static function retrieveBySessionKey($session_key)
 {
     return SessionQuery::create()->filterBySessionKey($session_key)->findOne();
 }
 /**
  * Get the associated Session object
  *
  * @param      PropelPDO $con Optional Connection object.
  * @return                 Session The associated Session object.
  * @throws PropelException
  */
 public function getSession(PropelPDO $con = null)
 {
     if ($this->aSession === null && $this->session_id !== null) {
         $this->aSession = SessionQuery::create()->findPk($this->session_id, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aSession->addSingleSignOnKeys($this);
            */
     }
     return $this->aSession;
 }
Example #8
0
 /**
  * Removes this object from datastore and sets delete attribute.
  *
  * @param      PropelPDO $con
  * @return void
  * @throws PropelException
  * @throws Exception
  * @see        BaseObject::setDeleted()
  * @see        BaseObject::isDeleted()
  */
 public function delete(PropelPDO $con = null)
 {
     if ($this->isDeleted()) {
         throw new PropelException("This object has already been deleted.");
     }
     if ($con === null) {
         $con = Propel::getConnection(SessionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = SessionQuery::create()->filterByPrimaryKey($this->getPrimaryKey());
         $ret = $this->preDelete($con);
         // symfony_behaviors behavior
         foreach (sfMixer::getCallables('BaseSession:delete:pre') as $callable) {
             if (call_user_func($callable, $this, $con)) {
                 $con->commit();
                 return;
             }
         }
         if ($ret) {
             $deleteQuery->delete($con);
             $this->postDelete($con);
             // symfony_behaviors behavior
             foreach (sfMixer::getCallables('BaseSession:delete:post') as $callable) {
                 call_user_func($callable, $this, $con);
             }
             $con->commit();
             $this->setDeleted(true);
         } else {
             $con->commit();
         }
     } catch (Exception $e) {
         $con->rollBack();
         throw $e;
     }
 }
Example #9
0
 /**
  * Returns the number of related Session objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return int             Count of related Session objects.
  * @throws PropelException
  */
 public function countSessions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if (null === $this->collSessions || null !== $criteria) {
         if ($this->isNew() && null === $this->collSessions) {
             return 0;
         } else {
             $query = SessionQuery::create(null, $criteria);
             if ($distinct) {
                 $query->distinct();
             }
             return $query->filterByUser($this)->count($con);
         }
     } else {
         return count($this->collSessions);
     }
 }