Exemple #1
0
 public function before()
 {
     $config = Kohana::$config->load('common');
     $this->template = $config->template_name;
     parent::before();
     if (Auth::instance()->logged_in()) {
         $user = new Model_User();
         $this->template->topbar = View::factory('profile/topbar')->set('users', $user->where('id', '=', Auth::instance()->get_user()->pk())->find())->set('users_levels', $user->get_level(Auth::instance()->get_user()->pk()));
     } else {
         $this->template->topbar = View::factory('login');
     }
     $this->template->stylesheets = $config->stylesheets;
     $this->template->site_name = $config->site_name;
     if (Auth::instance()->logged_in()) {
         $user_id = Auth::instance()->get_user()->pk();
         $roles = ORM::factory('Roles_User')->get_last_role_id($user_id);
         foreach ($roles as $role) {
             if ($role->role_id == 1) {
                 if ($this->request->directory() == 'dashboard') {
                     $this->request->redirect('');
                 }
                 if ($this->request->uri() == 'dashboard') {
                     $this->request->redirect('');
                 }
             }
         }
     } else {
         if ($this->request->directory() == 'dashboard') {
             $this->request->redirect('');
         }
         if ($this->request->uri() == 'dashboard') {
             $this->request->redirect('');
         }
     }
 }
Exemple #2
0
 public function before()
 {
     if (!(Auth::instance()->logged_in("admin") or Auth::instance()->logged_in("internal")) and $this->request->controller() !== 'user' and $this->request->action() !== 'log' and $this->request->param('id') !== 'in') {
         $back_url = "?back_url=" . URL::site($this->request->uri()) . (!empty($_GET) ? "?" . http_build_query($_GET, '&') : "");
         $this->redirect('admin/user/log/in' . $back_url);
     }
     parent::before();
 }
Exemple #3
0
 public function before()
 {
     parent::before();
     $config = Kohana::$config->load('common');
     $this->template->site_name = $config->site_name;
     $this->template->stylesheets = $config->stylesheets;
     $this->template->scripts = $config->scripts;
 }
Exemple #4
0
 /**
  * If the request is an AJAX request then the template is
  * stripped out from the response, and only the content is 
  * returned.
  */
 public function after()
 {
     if (Request::$is_ajax) {
         $this->request->response = $this->template->content;
     } else {
         parent::after();
     }
 }
Exemple #5
0
 public function after()
 {
     if ($this->auto_render === TRUE) {
         $this->view->set_filename($this->request->directory() . DIRECTORY_SEPARATOR . $this->request->controller() . DIRECTORY_SEPARATOR . $this->request->action());
         $this->template->content = $this->view;
     }
     parent::after();
 }
Exemple #6
0
 public function before()
 {
     if ($this->request->is_ajax()) {
         $this->profiler = NULL;
         $this->auto_render = FALSE;
         header('content-type: application/json');
     }
     parent::before();
 }
 public function before()
 {
     parent::before();
     $this->checkAuth();
     $this->modelStructure = new Structure();
     $this->modelStructureArticle = new Structure_Article();
     $this->modelStructureRole = new Structure_Role();
     $this->config = Kohana::$config->load("structure");
     $this->uploadPath = MODPATH . "/dynamic-structure/upload/";
 }
Exemple #8
0
 /**
  * Checks for a media file
  */
 public function before()
 {
     if ($this->request->action == 'media') {
         $this->auto_render = FALSE;
     } else {
         parent::before();
         $this->dir = $this->request->param('dir');
         $view_data = array('css' => array('console/media/css/reset.css' => 'screen', 'console/media/css/console.css' => 'screen'), 'js' => array('console/media/js/jquery-1.3.2.min.js', 'console/media/js/console.js'));
         $this->template->set($view_data);
     }
 }
 public function before()
 {
     // Before anything, checks module installation
     $this->migrations = new Flexiblemigrations(true);
     try {
         $this->model = ORM::factory('Migration');
     } catch (Database_Exception $a) {
         echo 'Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server';
         exit;
     }
     parent::before();
 }
Exemple #10
0
 public function __construct(\Request $request, \Response $response)
 {
     $this->project = Model::factory('Project')->where("share_hash", "=", $request->param('hash'))->find();
     if (!$this->project->loaded() or $this->project->visibility->name == "privat") {
         throw new HTTP_Exception_404(__('This page seems to not exists.'));
     }
     if ($this->project->visibility->name == "secure") {
         if (!$this->visitor_authorized($request->param('hash')) and $request->action() != 'authenticate') {
             $this->redirect('/share/' . $request->param('hash') . '/project/authenticate/');
         }
     }
     parent::__construct($request, $response);
 }
Exemple #11
0
 public function before()
 {
     parent::before();
     $config = Kohana::$config->load('common');
     $this->template->name = $config->name;
     $this->template->stylesheets = $config->stylesheets;
     $categories = new Model_Category();
     $client = new Model_Client();
     $product = new Model_Product();
     $this->template->products = $product->get_random_product_with_discount();
     $this->template->valute = $client->get_user_valute(Session::instance()->get('email'));
     $this->template->categories = $categories->get_list_of_categories();
     $this->template->users = $client->get_user_data(Session::instance()->get('email'));
     $this->template->scripts = $config->scripts;
 }
 public function before()
 {
     parent::before();
     /* twitter sandbox for the kohanatwitlib, if you are going to do
      * extensive testing please create your own account
      * same password for both accounts
      */
     $username = '******';
     //$username = '******';
     $password = '******';
     $this->t = Twitter::instance($username, $password);
     $this->u = $username;
     print '<h1>' . $this->request->param('action') . '</h1>';
     print "<h2>user: {$username}</h2>";
 }
 public function before()
 {
     // Before anything, checks module installation
     $this->migrations = new Flexiblemigrations(TRUE);
     if (!Auth::instance()->logged_in()) {
         $this->redirect('/');
     }
     $user = Auth::instance()->get_user();
     if (!$user->has_access('a')) {
         $this->redirect('/');
     }
     try {
         $this->model = ORM::factory('Migration');
     } catch (Database_Exception $a) {
         echo 'Flexible Migrations is not installed. Please Run the migrations.sql script in your mysql server';
         exit;
     }
     parent::before();
 }
Exemple #14
0
 public function before()
 {
     //J'ai préféré utiliser la fonction Kohana::cache plutôt que le module Cache
     if (Kohana::cache('sidebar_categories') == NULL) {
         $sidebar_categories = ORM::factory('Category')->order_by('post_count', 'DESC')->find_all();
         Kohana::cache('sidebar_categories', $sidebar_categories->cached(), 60 * 60);
         // 60s * 60s = 1 heure
     }
     View::set_global('sidebar_categories', Kohana::cache('sidebar_categories'));
     if (Kohana::cache('sidebar_posts') == NULL) {
         $sidebar_posts = ORM::factory('Post')->order_by('created', 'DESC')->order_by('id', 'DESC')->limit(2)->find_all();
         Kohana::cache('sidebar_posts', $sidebar_posts->cached(), 60 * 60);
         // 60s * 60s = 1 heure
     }
     View::set_global('sidebar_posts', Kohana::cache('sidebar_posts'));
     if (strrpos($this->request->action(), 'post_') === FALSE) {
         parent::before();
     }
     //pas besoin de créer une vue pour ce cas
 }
 public function after()
 {
     if ($this->auto_render) {
         // Get the media route
         $media = Route::get('docs/media');
         // Add styles
         $this->template->styles = array($media->uri(array('file' => 'css/print.css')) => 'print', $media->uri(array('file' => 'css/screen.css')) => 'screen', $media->uri(array('file' => 'css/kodoc.css')) => 'screen', $media->uri(array('file' => 'css/shCore.css')) => 'screen', $media->uri(array('file' => 'css/shThemeKodoc.css')) => 'screen');
         // Add scripts
         $this->template->scripts = array($media->uri(array('file' => 'js/jquery.min.js')), $media->uri(array('file' => 'js/kodoc.js')), $media->uri(array('file' => 'js/shCore.js')), $media->uri(array('file' => 'js/shBrushPhp.js')));
         // Add languages
         $this->template->translations = Kohana::message('userguide', 'translations');
     }
     return parent::after();
 }
Exemple #16
0
 public function after()
 {
     $this->main_nav();
     parent::after();
 }
Exemple #17
0
 public function before()
 {
     parent::before();
     $config = Kohana::$config->load('common');
     $this->template->set('site_title', $config->site_title);
 }
 public function after()
 {
     $this->template->user = $this->_user;
     parent::after();
 }
Exemple #19
0
 public function before()
 {
     parent::before();
     $setting = Kohana::$config->load('common');
     $this->template->set('site_title', $setting['site_title'])->set('img_descr', $setting['img_descr'])->set('site_description', $setting['site_description'])->set('footer', View::factory('template/footer'));
 }
Exemple #20
0
 public function before()
 {
     parent::before();
 }