FuelPHP Bin
Sign in
Public
PHP
Save
<?php class Controller_Private extends \Controller { public $layout = 'admin'; public $template = 'layouts/default'; public $data = array(); public function before() { if (\Input::is_ajax()) { return parent::before(); } // Initial configuration #\Package::load('nvutility'); $this->theme = \Theme::instance(); $this->theme->active($this->layout); $this->theme->set_template($this->template); #\Theme::instance()->active('private-theme'); #\Theme::instance()->set_template($this->template); #\Theme::instance()->asset->add_path('upload/'); // Set empty values to avoid errors // To Check: Benötigt??? $this->data['template_values'] = array(); $this->data['site_values'] = array(); $this->data['page_values'] = array(); // Setting authorization => TODO!!! #$permission = array($this->request->controller, $this->request->action); #$roles = \Config::get('simpleauth.roles', array()); $auth_id = \Auth::instance()->get_user_id(); $this->global_user = Model_User::find($auth_id[1]); // User isn't logged in if(!\Auth::check()) { \Session::set_flash('error', 'User isn\'t logged in!'); \Debug::dump(\Auth::check()); #die; \Response::redirect('admin/login'); } // Check if user can access this section => TODO!!! // if(!\NVUtility\NVPermission::is_allowed($permission)) // { // // Check if user can access admin section // if(\NVUtility\NVPermission::is_allowed(array('main', $roles['main']['dashboard']))) // { // \Session::set_flash('error', 'You can\' access this section.'); // \Response::redirect('admin/dashboard'); // } // else // { // \Session::set_flash('error', 'You can\' access this section.'); // \Response::redirect('admin/login'); // } // } // Set variables $this->data['template_values']['title'] = 'Site Admin Title'; $this->data['template_values']['subtitle'] = 'Default Admin subtitle'; $this->data['template_values']['author'] = 'Default Admin Author'; $this->data['template_values']['description'] = 'Default Admin description'; $this->data['template_values']['keywords'] = 'Default Admin keywords'; $this->data['site_values']['global_user'] = $this->global_user; // Set template #\Theme::instance()->set_partial('header', 'private/_global/header'); $this->theme->set_partial('navigation', 'partials/navigation'); $this->theme->set_partial('messages', 'partials/messages'); } public function after($response) { if (!\Input::is_ajax()) { \Theme::instance()->set_info('data', $this->data); if (empty($response)) { $response = \Response::forge(\Theme::instance()); } } return parent::after($response); } }