Exemple #1
0
 public function before()
 {
     parent::before();
     if (empty(\Session::get(self::SESSION_KEY_USER_ID))) {
         return Response::redirect('index.php/auth');
     }
 }
Exemple #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'));
     }
 }
Exemple #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();
         }
     }
 }
Exemple #4
0
 public function before()
 {
     if (!$this->me()->id) {
         Request::current()->redirect('');
     }
     parent::before();
 }
Exemple #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());
     */
 }
Exemple #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;
     }
 }
Exemple #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'));
 }
Exemple #8
0
 public function before()
 {
     parent::before();
     // Authentication required
     if (!Visitor::$user) {
         $this->request->redirect(URL::site());
     }
 }
Exemple #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');
     }
 }
Exemple #10
0
 public function after($response)
 {
     global $data;
     $this->template->content = View::forge('content/message', $data);
     $response = parent::after($response);
     // あなた自身のレスポンスオブジェクトを作成する場合は必要ありません。
     // do stuff
     return $response;
     // after() は確実に Response オブジェクトを返すように
 }
Exemple #11
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();
 }
Exemple #12
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);
         }
     }
 }
Exemple #13
0
 /**
  * Construct controller
  */
 public function after()
 {
     if ($user = self::_get_user(false)) {
         Anqh::page_meta('type', 'profile');
         Anqh::page_meta('title', HTML::chars($user->username));
         Anqh::page_meta('profile:username', HTML::chars($user->username));
         switch ($user->gender) {
             case 'f':
                 Anqh::page_meta('profile:gender', 'female');
                 break;
             case 'm':
                 Anqh::page_meta('profile:gender', 'male');
                 break;
         }
         if ($image = $user->get_image_url()) {
             Anqh::page_meta('image', $image);
         }
         Anqh::share(true);
     }
     parent::after();
 }
Exemple #14
0
 /**
  * Construct controller.
  */
 public function before()
 {
     parent::before();
     Permission::required(new Model_Role(), Model_Role::PERMISSION_UPDATE, self::$user);
 }
Exemple #15
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Venues');
 }
Exemple #16
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->page_title = __('Galleries');
 }
Exemple #17
0
 /**
  * Construct controller.
  */
 public function before()
 {
     parent::before();
     $this->page_title = 'Developers';
 }
Exemple #18
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->history = false;
 }
Exemple #19
0
        $_SESSION['check'] = md5($_POST['login'] . "petrubank");
        Flight::redirect('/user');
    } else {
        $page->zaloguj(array("error" => "Bledny login lub haslo"));
    }
});
Flight::route('/zaloguj', function () {
    $page = new Controller_Page();
    $page->zaloguj();
});
Flight::route('POST /contact', function () {
    $page = new Controller_Page();
    $page->contact(array($_POST['name'], $_POST['email']));
});
Flight::route('/contact', function () {
    $page = new Controller_Page();
    $page->contact();
});
Flight::route('/user', function () {
    $auth = new Controller_Authorization();
    if (!$auth->isLogged($_SESSION['login'], $_SESSION['check'])) {
        Flight::redirect('/');
    }
    $user = new Controller_User();
    $model = new Model_Dao();
    if ($auth->isAdmin($_SESSION['login'])) {
        $user->indexAdmin($model->getUser($_SESSION['login']));
    } else {
        $user->index($model->getUser($_SESSION['login']));
    }
});
Exemple #20
0
 /**
  * Construct controller
  */
 public function before()
 {
     parent::before();
     $this->date = new DateTime();
 }