/** * Override the before method * check if ajax and select correct template */ public function before() { $this->auth_filter(); if (Auth::instance()->logged_in()) { $this->acl_filter(); } // create a new Config reader and attach to the Config instance $config = Config::instance(); $config->attach(new Config_Database()); $this->breadcrumbs(); //check if controller is of innerpage of course and courseid is there in session // TODO - fix for modular extensibility if ($this->request->is_initial()) { // check if this is initial request $course_pages = array('document', 'flashcard', 'link', 'video', 'lesson', 'quiz', 'assignment', 'question', 'quiz', 'exercise'); $controller = $this->request->controller(); $course_id = Session::instance()->get('course_id'); if (in_array($controller, $course_pages) && !$course_id) { $this->request->redirect('course'); } elseif (!in_array($controller, $course_pages)) { Session::instance()->delete('course_id'); } } return parent::before(); }
public function before() { parent::before(); $this->template->title = 'Swiftriver'; $this->template->theme = Theming::get_theme(); $this->template->header = new View('defaults/header'); $this->template->content = ''; $this->template->rightbar = new View('defaults/rightbar'); $this->template->footer = new View('defaults/footer'); $loggedinstatus = RiverId::is_logged_in(); if (!$loggedinstatus["IsLoggedIn"]) { $this->template->admin = new View("adminbar/user"); } else { if ($loggedinstatus["Role"] == "sweeper") { $this->template->admin = new View("adminbar/sweeper"); } else { if ($loggedinstatus["Role"] == "editor") { $this->template->admin = new View("adminbar/editor"); } else { if ($loggedinstatus["Role"] == "admin") { $this->template->admin = new View("adminbar/admin"); } } } } }
/** * Before - Check for login */ public function before() { if ($this->request->action != 'login' and !Auth::check()) { Reponse::redirect('admin/login'); } return parent::before(); }
public function after() { if (!isset($this->template->heading)) { $this->template->heading = ucfirst($this->request->controller()); } if (!isset($this->template->subheading)) { $this->template->subheading = ucfirst($this->request->action()); } $session_messages = $this->session->get_once('messages'); if ($session_messages) { $this->template->messages = array_merge($session_messages, $this->template->messages); } $session_errors = $this->session->get_once('errors'); if ($session_errors) { $this->template->errors = array_merge($session_errors, $this->template->errors); } /* Are you logged in? */ $this->template->set_global('isLoggedIn', $this->auth->is_logged_in()); $this->template->set_global('isVerifiedAccount', isset($this->isVerifiedAccount) ? $this->isVerifiedAccount : FALSE); /* store the user */ $this->template->set_global('account', $this->auth->getAccount()); if ($this->template->isLoggedIn) { $this->addMenuItem(array('url' => 'convention/checkout', 'title' => 'Purchase Tickets')); $this->addMenuItem(array('title' => 'My Account', 'url' => 'user')); if ($this->auth->hasPermission('admin')) { $this->addMenuItem(array('title' => 'Administration', 'url' => 'admin')); } $this->addMenuItem(array('url' => 'user/logout', 'title' => 'Logout')); } return parent::after(); }
public function before() { parent::before(); !Auth::check() and Response::redirect('/auth/login'); $this->current_user = Model_User::find_by_username(Auth::get_screen_name()); $this->template->set_global('current_user', $this->current_user); }
public function before() { parent::before(); //許可するアクション $action = array('login', 'index'); //アクティブなアクション $active = Request::active()->action; //ログインしていなくて、許可アクション以外は if (!Auth::check() and !in_array($active, $action)) { //ログインページへ移動 Response::redirect('pt/login'); } // public function before(){ // parent::before(); // var_dump(Auth::check()); // if(!Auth::check()){ // Response::redirect('pt/login'); // } // // if(!Auth::check()){ // Response::redirect('pt/index'); // } // $action = array('pt','login','pt/index/HTML5','pt/index/PHP','pt/index'); // // $active = Request::active()->action; // var_dump($action); exit; // var_dump($active); exit; // if(!Auth::check() and !in_array($active,$action)){ // Response::redirect('pt/index'); // exit; // }else{ // Response::redirect('pt'); // }; }
public function after($response) { if (empty($response) or !$response instanceof Response) { $response = \Response::forge(\Theme::instance()->render()); } return parent::after($response); }
/** * After action */ public function after() { $this->template->breadcrumbs = $this->breadcrumbs; $v_go_previous = View::factory('frontend/v_go_previous'); $this->template->set_global('v_go_previous', $v_go_previous); parent::after(); }
public function before() { if (!Auth::instance()->logged_in() && $this->request->action() != 'get_login' && $this->request->action() != 'post_login') { $this->redirect('login'); } parent::before(); }
public function before() { // Выполняем функцию родительского класса parent::before(); $this->template->styles = array(Kohana::$base_url . 'css/admin.css'); $this->template->title = 'Панель управления'; }
public function before() { parent::before(); // Load the configuration settings $config = $this->_config = Kohana::config('docs')->as_array(); // The language is part of the route if ($lang = $this->request->param('lang')) { // Set the language and locale I18n::lang($lang); setlocale(LC_ALL, $config['language']['supported'][$lang]['locale']); // Remember the preferred language Cookie::set('lang', $this->lang = $lang); } else { // We need a language, try the cookie or use the default $lang = Cookie::get('lang', $config['language']['default']); // Redirect with a chosen language $this->request->redirect($this->request->uri(array('lang' => $lang))); } }
public function before() { parent::before(); // if user not connected and not on the login, 404 or session_up pages then redirect to login page if (Request::active()->action != 'login' && !Sentry::check() && Request::active()->action != '404' && Request::active()->action != 'session_up') { Session::set(array('redirect' => Request::active()->route->translation)); Response::redirect('login'); } $this->current_user = self::current_user(); View::set_global('current_user', self::current_user()); if (Sentry::check()) { // logout if banned if (Sentry::attempts($this->current_user->username)->get() == Sentry::attempts()->get_limit()) { Session::set_flash('Your account has been blocked'); Sentry::logout(); Response::redirect('login'); } } View::set_global('site_title', 'IKON Backend'); View::set_global('separator', '/'); foreach (Model_Forms::find('all') as $k => $form) { $this->tables[$k]['cleanName'] = $form->cleanName; $this->tables[$k]['url'] = $form->url; $this->tables[$k]['table'] = $form->table; } View::set_global('tables', $this->tables); }
public function before() { parent::before(); if (Auth::Check() === false) { Response::Redirect(Uri::Base()); } }
public function before() { parent::before(); if (\Settings::Get('signup_and_approve') === true && Auth::Check() === false) { Response::Redirect(Uri::Create('signup')); } }
public function before() { parent::before(); I18n::lang('ru'); Cookie::$salt = 'eqw67dakbs'; Session::$default = 'cookie'; //$this->cache = Cache::instance('file'); $this->session = Session::instance(); $this->auth = Auth::instance(); $this->user = $this->auth->get_user(); // $captcha = Captcha::instance(); // Подключаем стили и скрипты $this->template->styles = array(); $this->template->scripts = array(); //Вывод в шаблон $this->template->title = null; $this->template->site_name = null; $this->template->description = null; $this->template->page_title = null; //Подключаем главный шаблон $this->template->main = null; $this->template->userarea = null; $this->template->top_menu = View::factory('v_top_menu'); $this->template->manufactures = null; $this->template->left_categories = null; $this->template->slider_banner = null; $this->template->block_left = array(); $this->template->block_center = array(); $this->template->block_right = array(); $this->template->block_footer = null; }
public function before() { parent::before(); if (empty(Session::get(self::LOGIN))) { return Response::redirect('client/auth'); } }
public function before() { parent::before(); if (!Auth::check()) { Response::redirect('login'); } }
/** * Loads test suite */ public function before() { parent::before(); if( ! Kohana_Tests::enabled()) { // Pretend this is a normal 404 error... $this->status = 404; throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri', array(':uri' => $this->request->uri)); } // Prevent the whitelist from being autoloaded, but allow the blacklist // to be laoded Kohana_Tests::configure_enviroment(FALSE); $this->config = Kohana::$config->load('phpunit'); // This just stops some very very long lines $route = Route::get('unittest'); $this->report_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'report')); $this->run_uri = $route->uri(array('controller' => 'phpunit', 'action' => 'run')); // Switch used to disable cc settings $this->xdebug_loaded = extension_loaded('xdebug'); $this->template->set_global('xdebug_enabled', $this->xdebug_loaded); }
/** * before create */ public function before() { parent::before(); $this->template->content = ''; $this->template->styles = array('main'); $this->template->scripts = ''; }
/** * Construct controller */ public function before() { parent::before(); if (!Visitor::instance()->logged_in('admin')) { throw new Permission_Exception(new Model_Role()); } }
public function before() { if ($this->tt == 0) { return 0; } return parent::before(); }
/** * Unset current navigation item */ public function after() { $key = array_search($this->_current_nav, $this->_config['menu']); if ($key) { $this->_config['menu'][$key] = NULL; } // If a submenu is defined if (isset($this->_config['submenu'][$this->_current_nav])) { // Unset current action sublink $key = array_search($this->request->action, $this->_config['submenu'][$this->_current_nav]); if ($key === FALSE) { // Match controler and action $key = array_search($this->request->controller . "/" . $this->request->action, $this->_config['submenu'][$this->_current_nav]); if ($key === FALSE) { // Match controler only (if a submenu belong to many actions) $key = array_search($this->request->controller, $this->_config['submenu'][$this->_current_nav]); } } if ($key) { $this->_config['submenu'][$this->_current_nav][$key] = NULL; } // Prepend current navigation path to all menu's actions foreach ($this->_config['submenu'][$this->_current_nav] as $key => $action) { if (!empty($action)) { $this->_config['submenu'][$this->_current_nav][$key] = $this->_current_nav . '/' . $action; } } } parent::after(); }
public function before() { parent::before(); if (Request::current()->is_initial()) { $this->request->action(404); } }
public function before() { // if(!CMS_User::instance()->is_authenticated()){ // $this->request->redirect(CMS_Infrastructure_Routes_Manager::login()); // } parent::before(); $this->template->cms_url_prefix = URL_PREFIX; $this->template->topmenu = View::factory('cms/navigation/top'); $this->template->leftmenu = View::factory('cms/navigation/left'); $this->set_caption('Модуль управления сайтом'); $this->set_content('', 'main_content'); $this->template->styles = array(); $this->add_style('cms/css/bootstrap.min.css'); $this->add_style('cms/font-awesome/css/font-awesome.css'); $this->add_style('cms/css/sb-admin-2.css'); $this->add_style('cms/css/style.css'); $this->template->scripts = array(); $this->add_script('cms/js/jquery-1.10.2.js'); $this->add_script('cms/js/bootstrap.min.js'); $this->add_script('cms/js/plugins/metisMenu/jquery.metisMenu.js'); $this->add_script('cms/js/plugins/cms/jquery.inputeditor.js'); $this->add_script('cms/js/plugins/cms/jquery.inputeditor2.js'); $this->add_script('cms/js/plugins/cms/jquery.controlselect.js'); $this->add_script('cms/js/plugins/cms/jquery.colorselect.js'); $this->add_script('cms/js/sb-admin.js'); $this->add_script('cms/js/script.js'); }
public function before() { parent::before(); $this->session = Session::instance(); # Check user authentication $auth_result = true; $action_name = Request::instance()->action; if (array_key_exists($action_name, $this->auth)) { $auth_result = $this->_check_auth($action_name); } else { if (array_key_exists('*', $this->auth)) { $auth_result = $this->_check_auth('*'); } } if (!$auth_result) { if (Auth::instance()->logged_in()) { //! \todo Flash message. Request::instance()->redirect('user'); } else { Request::instance()->redirect('login'); } } // Try to pre-fetch the template. Doesn't have to succeed. try { $this->template->content = View::factory(Request::instance()->controller . '/' . Request::instance()->action); } catch (Kohana_View_Exception $e) { } $this->template->title = ucwords(Request::instance()->action); $this->template->left = null; $this->template->right = null; $this->template->footer = null; $this->template->no_back_button = true; $this->template->menu = array(); }
public function before() { parent::before(); if (Request::current()->is_initial()) { $this->auto_render = FALSE; } }
public function after() { if ($this->template->body && is_string($this->template->body)) { $this->template->body = View::factory($this->template->body, $this->data, false); } parent::after(); }
public function before() { parent::before(); $this->session = Session::instance(); $this->config = Kohana::$config->load('app'); View::bind_global('app_config', $this->config); }
function after() { if (class_exists('DebugToolbar')) { echo DebugToolbar::render(); } return parent::after(); }
public function before() { parent::before(); /* * Set up views */ if (Kohana::find_file('views', $this->request->action())) { $this->view = View::factory($this->request->action()); $this->template->content = $this->view; } $this->template->set_global('databases', array()); $this->template->set_global('database', FALSE); $this->template->set_global('tables', array()); $this->template->set_global('table', FALSE); $this->template->messages = array(); $this->template->controller = $this->request->controller(); $this->template->action = $this->request->action(); $this->template->actions = array('index' => 'Browse & Search', 'edit' => 'New', 'import' => 'Import', 'export' => 'Export'); /* * Add flash messages to the template, then clear them from the session. */ foreach (Session::instance()->get('flash_messages', array()) as $msg) { $this->add_template_message($msg['message'], $msg['status']); } Session::instance()->set('flash_messages', array()); $this->_query_string_session(); }