示例#1
0
 protected function checkAllowed()
 {
     error_log("Action is [" . Pfw_Request::getParam('action') . "] and access is [" . $this->access_allowed . "]");
     if (empty($this->access_allowed)) {
         $this->access_allowed = false;
     }
     if ($this->access_allowed) {
         return true;
     }
     if (self::is_logged_in()) {
         $post_vars = Pfw_Session::get('saved_post_vars');
         foreach ($post_vars as $key => $value) {
             $this->params[$key] = $value;
         }
         error_log("Session is already initialized, you are logged in");
         return true;
     }
     // if session is valid (not sexpired)
     // check to see saved_form isset and if so setup params with it
     // marshall post variables
     Pfw_Session::set('saved_post_vars', $_POST);
     Pfw_Session::set('saved_qs_vars', $_GET);
     // return true
     // if not send to login page
     // create session
     $action = Pfw_Request::getParam('action');
     $controller = Pfw_Request::getParam('controller');
     // marshall form post (in case we are in the middle of a post)
     // Not sure how to do this without stuffing the whole request in a session
     $this->redirect('/user/login?redir=/' . $controller . '/' . $action);
 }
示例#2
0
 /**
  * Internal error/notice add method.
  * 
  * @param string $message the alert message
  * @param string|null $field the file to add notice on, or null if alert is not on a field 
  * @param bool $follows_redir true if alert must follow redirect, false if immediate page render 
  * @param string $type on of the TYPE_* constants
  */
 protected static function add($message, $field, $follows_redir, $type)
 {
     self::assertInitialized();
     $follows_redir = $follows_redir ? true : false;
     $alert = array('message' => $message, 'redir' => $follows_redir, 'field' => $field);
     array_push(self::$alerts[$type], $alert);
     if (true === $follows_redir) {
         if (!Pfw_Session::isStarted()) {
             throw new Pfw_Exception_System("Session alerts are not available, session has not been initialized");
         }
         $alerts = Pfw_Session::get(self::SESSION_KEY);
         if (empty($alerts)) {
             $alerts = array();
             $alerts[self::TYPE_ERROR] = array();
             $alerts[self::TYPE_NOTICE] = array();
         }
         array_push($alerts[$type], $alert);
         Pfw_Session::set(self::SESSION_KEY, $alerts);
     }
 }
示例#3
0
 /**
  * Logout
  */
 function logoutAction()
 {
     Pfw_Session::set('is_logged_in', false);
     Pfw_Session::clear('login_id');
     $this->redirect('/user/login');
 }