示例#1
0
文件: site.php 项目: jonlb/JxCMS
 public function before()
 {
     $this->auth = Auth::instance();
     $user = $this->auth->get_user();
     //Jx_Debug::dump($this->auth,'auth object');
     //Jx_Debug::dump($user, 'User object');
     $capabilities = FALSE;
     //first check $this->security_all
     if ($this->security_all !== FALSE) {
         if (is_array($this->security_all)) {
             $capabilities = $this->security_all;
         } else {
             $capabilities = array($this->security_all);
         }
     }
     if ($this->security_action !== FALSE && array_key_exists($this->request->action, $this->security_action)) {
         $c = $this->security_action[$this->request->action];
         if (is_array($c)) {
             $capabilities = array_merge($capabilities, $c);
         } else {
             $capabilities[] = $c;
         }
     }
     //Jx_Debug::dump($capabilities, 'checking for capabilities');
     if (FALSE !== $capabilities) {
         if (in_array(Jx_Acl::get_login_cap(), $capabilities) && !$this->auth->logged_in()) {
             //Jx_Debug::dump(null,'not logged in');
             Session::instance()->set('redirect', array('fromUrl' => $this->request->uri));
             $this->request->redirect(Route::get('users')->uri(array('action' => 'login')));
         } else {
             if (!Jx_Acl::check_for_cap($capabilities, $user)) {
                 //Jx_Debug::dump(null, 'no capability');
                 Session::instance()->set('redirect', array('fromUrl' => $this->request->uri));
                 //$this->request->redirect(Route::get('users')->uri(array('action'=>'denied')));
             }
         }
     }
     //Jx_Debug::dump(null, 'checks passed');
     if ($this->auto_render) {
         $this->template = Jx_View::factory($this);
     }
     return parent::before();
 }
示例#2
0
文件: form.php 项目: jonlb/JxCMS
 public function render()
 {
     $this->load_defaults();
     $view = Jx_View::factory($this->model['view']);
     $view->model = $this->model;
     //Jx_Debug::dump($view->model);
     if (isset($this->erros)) {
         $view->errors = $this->errors;
     }
     $ret = $view->render();
     //Jx_Debug::dump($view);
     return $ret;
 }