Beispiel #1
0
 public function before()
 {
     parent::before();
     if (empty(\Session::get(self::SESSION_KEY_USER_ID))) {
         return Response::redirect('index.php/auth');
     }
 }
Beispiel #2
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Forum');
     // Generic page actions
     $this->page_actions['new-posts'] = array('link' => Route::url('forum'), 'text' => '<i class="icon-comment icon-white"></i> ' . __('New posts'));
     // Forum areas dropdown
     $groups = Model_Forum_Group::factory()->find_all();
     $areas = array();
     foreach ($groups as $group) {
         $divider = false;
         foreach ($group->areas() as $area) {
             if (Permission::has($area, Model_Forum_Area::PERMISSION_READ, self::$user)) {
                 $divider = true;
                 $areas[] = array('link' => Route::model($area), 'text' => HTML::entities($area->name));
             }
         }
         if ($divider) {
             $areas[] = array('divider' => true);
         }
     }
     array_pop($areas);
     $this->page_actions['areas'] = array('link' => Route::url('forum_group'), 'text' => '<i class="icon-folder-open icon-white"></i> ' . __('Areas'));
     $this->page_actions['area'] = array('link' => Route::url('forum_group'), 'text' => '', 'dropdown' => $areas);
     if (self::$user) {
         $this->page_actions['private-messages'] = array('link' => Forum::private_messages_url(), 'text' => '<i class="icon-envelope icon-white"></i> ' . __('Private messages'));
     }
 }
Beispiel #3
0
 /**
  * The before() method is called before your controller action.
  * In our template controller we override this method so that we can
  * set up default values. These variables are then available to our
  * controllers if they need to be modified.
  *
  * @return  void
  */
 public function before()
 {
     // This codeblock is very useful in development sites:
     // What it does is get rid of invalid sessions which cause exceptions, which may happen
     // 1) when you make errors in your code.
     // 2) when the session expires!
     try {
         $this->session = Session::instance();
     } catch (ErrorException $e) {
         session_destroy();
     }
     // Execute parent::before first
     parent::before();
     // Open session
     $this->session = Session::instance();
     //if we're not logged in, but auth type is orm. gives us chance to auto login
     $supports_auto_login = new ReflectionClass(get_class(Auth::instance()));
     $supports_auto_login = $supports_auto_login->hasMethod('auto_login');
     if (!Auth::instance()->logged_in() && $supports_auto_login) {
         Auth::instance()->auto_login();
     }
     // Check user auth and role
     $action_name = Request::current()->action();
     if ($this->auth_required !== FALSE && Auth::instance()->logged_in($this->auth_required) === FALSE || is_array($this->secure_actions) && array_key_exists($action_name, $this->secure_actions) && Auth::instance()->logged_in($this->secure_actions[$action_name]) === FALSE) {
         if (Auth::instance()->logged_in()) {
             // user is logged in but not on the secure_actions list
             $this->access_required();
         } else {
             $this->login_required();
         }
     }
 }
Beispiel #4
0
 public function before()
 {
     if (!$this->me()->id) {
         Request::current()->redirect('');
     }
     parent::before();
 }
Beispiel #5
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->history = false;
     // Always render page
     $this->view = new View_ErrorPage(__('Something wonky just happened'));
     // Show always 404 for now
     return $this->request->action(404);
     /*
     if ($this->_request_type !== Controller::REQUEST_AJAX) {
     
     	// External requests show always 404
     	return $this->request->action(404);
     
     } else {
     
     	// Internal requests only
     	if ($message = rawurldecode($this->request->param('message'))) {
     		$this->view->add(View_Page::COLUMN_TOP, $message);
     	}
     
     }
     
     $this->response->status((int)$this->request->action());
     */
 }
Beispiel #6
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->date = new DateTime();
     if ($this->_request_type !== Controller::REQUEST_AJAX) {
         $this->view->search = View_Page::SEARCH_EVENTS;
     }
 }
Beispiel #7
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     if (!Visitor::instance()->logged_in('admin')) {
         throw new Permission_Exception(new Model_Tag());
     }
     $this->view = View_Page::factory(__('Tags'));
 }
Beispiel #8
0
 public function before()
 {
     parent::before();
     // Authentication required
     if (!Visitor::$user) {
         $this->request->redirect(URL::site());
     }
 }
Beispiel #9
0
 public function before()
 {
     parent::before();
     if (empty(\Session::get(self::SESSION_KEY_USER_ID))) {
         return Response::redirect('index.php/auth/index/true');
     }
     if (empty(\Session::get(self::SESSION_KEY_CART))) {
         return Response::redirect('index.php/message/cartempty');
     }
 }
Beispiel #10
0
 public function before()
 {
     @header('P3P: CP="ALL OTP DEV COM NAV OUR IND"');
     if (!empty($_GET['u'])) {
         // save the URL for JS
         setcookie('bmu', $_GET['u']);
         $_COOKIE['bmu'] = $_GET['u'];
     } else {
         if (!empty($_COOKIE['bmu'])) {
             $_GET['u'] = $_COOKIE['bmu'];
         }
     }
     return parent::before();
 }
Beispiel #11
0
 /**
  * Construct controller.
  *
  * @throws  OAuth2_Exception_UnsupportedGrantType
  */
 public function before()
 {
     parent::before();
     $this->history = false;
     // See if we already have a token
     $provider = $this->request->param('provider');
     if ($provider) {
         if (Visitor::$user && ($this->external = Model_User_External::factory()->find_by_user_id(Visitor::$user->id, $provider))) {
             // Access token should be available
             $this->consumer = new OAuth2_Consumer($provider, $this->external->loaded() ? $this->external->access_token() : false);
         } else {
             // No access token available
             $this->consumer = new OAuth2_Consumer($provider, false);
         }
     }
 }
Beispiel #12
0
 /**
  * Construct controller.
  */
 public function before()
 {
     parent::before();
     Permission::required(new Model_Role(), Model_Role::PERMISSION_UPDATE, self::$user);
 }
Beispiel #13
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Venues');
 }
Beispiel #14
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Galleries');
 }
Beispiel #15
0
 public function before()
 {
     parent::before();
     // この行がないと、テンプレートが動作しません!
 }
Beispiel #16
0
 /**
  * Construct controller.
  */
 public function before()
 {
     parent::before();
     $this->page_title = 'Developers';
 }
Beispiel #17
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->history = false;
 }
Beispiel #18
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->date = new DateTime();
 }