Exemplo n.º 1
0
 protected function aclAccessFail($zone, $action)
 {
     if ($zone === 'not login') {
         return $this->_redirect('pages/restricted');
     }
     Session::error('You gotsta be logged for this shit right here');
     $this->_redirect('pages/login');
 }
Exemplo n.º 2
0
 public function logout()
 {
     if (parent::logout()) {
         Session::success('You are now logged out.');
     }
 }
Exemplo n.º 3
0
 public function index()
 {
     $postsPerPage = $this->_config('posts_on_index');
     // Way 1
     // Define which get method to use to fetch Posts by checking ACL
     // Use that function and the Model's logic to get those posts.
     $unpub = $this->user->hasAccess('blog read unpublished');
     $method = $unpub ? 'newest' : 'newestPublished';
     $posts = models\Post::$method($postsPerPage);
     // The quick 'n dirty //
     $page = Options::one($_GET, 'page', 1, false);
     $start = ($page - 1) * $postsPerPage;
     $conditions = $unpub ? '1' : 'is_published = 1';
     $posts = models\Post::all($conditions . ' ORDER BY created_on DESC LIMIT ' . $start . ', ' . $postsPerPage . '');
     // Don't do it! //
     // Way 2
     // Define the difference in conditions here (instead of in the Model)
     $conditions = $unpub ? '' : array('is_published' => true);
     $numAllPosts = models\Post::count($conditions);
     // Way 3
     // A third way would be a combination like this:
     /*
     			$access = $this->user->hasAccess('blog read unpublished');
     			$posts = model\Post::postsByAccess($access, $this->_config('posts_on_index'));
     */
     // That way you can check access in the Controller and have fetch logic in the Model
     $messages = Session::messages();
     $canCreatePosts = $this->user->hasAccess('blog create posts');
     return get_defined_vars();
     // view will be rendered by row\Controller->_post_action
     return $this->_display(__METHOD__, get_defined_vars(), !$this->AJAX);
     // view will be rendered by Output->display
     return $this->_display(get_defined_vars());
     // view will be rendered by Output->display
 }
Exemplo n.º 4
0
 public function login($uid = null)
 {
     if (null !== $uid) {
         $this->user->login(models\User::get($uid));
     }
     if ($this->user->isLoggedIn()) {
         $this->_redirect('/blog');
     }
     if ($this->POST) {
         $post = options($_POST);
         $get = options($_GET);
         try {
             // get user object
             $user = models\User::withCredentials(array('username' => (string) $post->username, 'password' => (string) $post->password));
             // log user in(to SessionUser)
             $this->user->login($user);
             // debug direct logged in status
             Session::message('<pre>' . var_export($this->user->isLoggedIn(), 1) . '</pre>');
             // message OK
             Session::success('Alright, alright, alright, you\'re logged in...');
             // back to blog
             return $this->_redirect($post->get('goto', $get->get('goto', 'blog')));
         } catch (\Exception $ex) {
         }
         // message FAIL
         Session::error('Sorry, buddy, that\'s not your username!');
     }
     $messages = Session::messages();
     return get_defined_vars();
 }
 public function set($key, $val)
 {
     echo '<pre>';
     var_dump(Session::variable($key, $val));
     print_r($_SESSION);
 }
Exemplo n.º 6
0
 public function login()
 {
     $messages = Session::messages();
     $google = OpenID::$providers['google'];
     return get_defined_vars();
 }
Exemplo n.º 7
0
 public function logoutAction()
 {
     $this->user->logout();
     Session::success(t('You logged out...'));
     $this->_redirect('user');
 }
Exemplo n.º 8
0
 public function display($tpl = true, $vars = null, $layout = true)
 {
     $this->assign('messages', Session::messages());
     return parent::display($tpl, $vars, $layout);
 }