Example #1
0
 protected function init()
 {
     $module_config = Helper_Module::load_config('blog');
     $helper_acl = new Helper_ACL($this->acl);
     $helper_acl->inject(Arr::get($module_config, 'a2'));
     $this->blog_group = Arr::get($this->params, 'group');
 }
Example #2
0
 public function before()
 {
     parent::before();
     // в конфиг a2 нельзя, т.к. используются константы SITE_ID и SITE_ID_MASTER,
     // которые определяются после подключения всех конфигов
     $inject_config = array('rules' => array('allow' => array('pages_can_hide' => array('role' => 'base', 'resource' => 'page', 'privilege' => 'can_hide', 'assertion' => array('Acl_Assert_Page', array('site_id' => SITE_ID, 'site_id_master' => SITE_ID_MASTER))))));
     $helper_acl = new Helper_ACL($this->acl);
     $helper_acl->inject($inject_config);
 }
Example #3
0
 protected function init()
 {
     $request = $this->request->current();
     $this->config = Kohana::$config->load($this->config)->as_array();
     $this->acl_init();
     $this->site_init();
     $helper_acl = new Helper_ACL($this->acl);
     $a2_config = Kohana::$config->load('admin/a2/base')->as_array();
     $helper_acl->inject($a2_config);
     if (Route::name($request->route()) == 'modules') {
         $this->module_page_id = (int) $request->query('page');
         $this->module_config = empty($this->module_config) ? Helper_Module::code_by_controller($request->controller()) : $this->module_config;
         $_pages = $this->get_module_pages($this->module_config);
         if ($_pages->count() > 0) {
             if ($this->module_page_id == 0) {
                 $this->module_page_id = $_pages->rewind()->current()->id;
             }
             foreach ($_pages as $_item) {
                 $_link = URL::base() . Page_Route::dynamic_base_uri($_item->id);
                 $this->module_pages[$_item->id] = $_item->title . " [ {$_link} ]";
             }
         }
         $this->module_config = Helper_Module::load_config($this->module_config);
         if (!Kohana::$is_cli) {
             $config = Arr::get($this->module_config, 'a2');
             $helper_acl->inject($config);
         }
         if (!$this->acl->is_allowed($this->user, $request->controller() . '_controller', 'access')) {
             throw new HTTP_Exception_404();
         }
     }
     $injectors = array();
     foreach ($this->injectors as $_key => $_array) {
         $params = Arr::get($_array, 1);
         if (class_exists($_array[0])) {
             $object = new $_array[0]($request, $this->user, $this->acl, $params);
             $injectors[$_key] = $object;
         }
     }
     $this->injectors = $injectors;
     unset($injectors);
     $this->is_cancel = $request->post('cancel') == 'cancel';
     $this->back_url = $request->query('back_url');
     $this->post_check_empty_files();
     $this->post_check_deleted_fields();
 }
Example #4
0
 public function action_index()
 {
     $modules = array();
     $_modules = Kohana::$config->load('_modules');
     foreach ($_modules as $code => $config) {
         if (empty($config['alias']) or !Helper_Module::check_module($config['alias'])) {
             continue;
         }
         $module_config = Kohana::$config->load('admin/modules/' . $code);
         $helper_acl = new Helper_ACL($this->acl);
         $helper_acl->inject($module_config->get('a2'));
         $_controller = empty($config['controller']) ? $code : $config['controller'];
         if ($this->acl->is_allowed($this->user, $_controller . '_controller', 'access')) {
             $modules[$code] = array('code' => $code, 'name' => __($config['name']), 'url' => Route::url('modules', array('controller' => $_controller)));
         }
     }
     $this->template->set_filename('modules/list')->set('modules', $modules);
     $this->title = __('Modules');
 }