/**
  * init: check if user is logged in
  * 
  * if not: redirect to login
  */
 public function init()
 {
     // call parent before first
     parent::init();
     // only check if the controller is not auth
     if (Request::initial()->controller() != 'Auth') {
         // url to loginpage
         $url = URL::to('Auth@login');
         // init identity
         $identity = Identity::instance();
         //revert identity to original user (maybe assume was called somewhere else)
         $identity->revert();
         // check authentication
         if (!$identity->authenticated()) {
             // if user is not allready authenticated, redirect to login page
             $this->redirect($url);
         } else {
             $website = Website::instance();
             // else: initialise acl
             Acl::init($identity, new Model_Rights($website->websites()));
             // set current environment
             Acl::environment($website->id());
             // if user is not entitled to access backend
             if (!Acl::instance()->allowed('Backend', 'access')) {
                 $this->redirect($url);
             }
             // if user is not entitled to access controller
             if (!Acl::instance()->allowed(Request::initial()->controller(), 'access')) {
                 $this->redirect($url);
             }
         }
     }
 }
Esempio n. 2
0
 public function init()
 {
     parent::init();
     $this->_layout = new LayoutPlugin('layout.html');
     $this->dispatcher = Yaf_Registry::get("dispatcher");
     $this->dispatcher->registerPlugin($this->_layout);
 }
 public function init()
 {
     parent::init();
 }
Esempio n. 4
0
 public function init()
 {
     parent::init();
     //使用layout页面布局
     $this->_layout = new LayoutPlugin('layout.html', APP_PATH . '/views/layout/');
 }