コード例 #1
0
ファイル: Auth.php プロジェクト: ariol/adminshop
 public function before()
 {
     parent::before();
     if (!ACL::is_action_allowed($this->request->directory(), $this->request->controller(), $this->request->action())) {
         $this->on_auth_error();
     }
     $this->_user = Auth::instance()->get_user();
 }
コード例 #2
0
ファイル: Crud.php プロジェクト: ariol/adminshop
 public function action_index()
 {
     foreach ($this->_group_actions as $action => $cfg) {
         if (!ACL::is_action_allowed($this->request->directory(), $this->request->controller(), $action)) {
             unset($this->_group_actions[$action]);
         }
     }
     if (isset($_POST['group_actions'])) {
         $action = NULL;
         foreach (arr::get($_POST, 'action', array()) as $name => $value) {
             $action = $name;
         }
         $handler = arr::path($this->_group_actions, $action . '.handler');
         if ($action && $handler && method_exists($this, $handler)) {
             if (arr::path($this->_group_actions, $action . '.one_item')) {
                 foreach ($_POST['ids'] as $id) {
                     $item = ORM::factory($this->_model, $id);
                     if ($item->loaded()) {
                         $this->{$handler}($item);
                     }
                 }
             } else {
                 $ids = array();
                 foreach ($_POST['ids'] as $id) {
                     if ($id) {
                         $ids[] = $id;
                     }
                 }
                 if (count($ids)) {
                     $this->{$handler}($ids);
                 }
             }
         }
         $this->back($this->get_index_route());
     }
     $this->set_view('crud/index');
     Navigation::instance()->actions()->add($this->get_create_route(), 'Добавить');
     $model = ORM::factory($this->_model);
     $this->template->filter_form = $this->get_filter_form($model);
     if ($this->template->filter_form) {
         $this->template->filter_form->set_method('GET');
         if (isset($_GET['filter_cancel'])) {
             $this->redirect('/' . Extasy_Url::url_to_route($this->get_index_route()));
         }
         if (isset($_GET['filter'])) {
             $this->template->filter_form->submit();
         }
     }
     $this->template->unSortableFields = $model->getUnSortableSortableFields();
     $grid = $this->before_fetch($model)->grid()->set_group_actions($this->_group_actions);
     $this->template->grid = $this->prepare_grid($grid);
 }
コード例 #3
0
ファイル: Config.php プロジェクト: ariol/adminshop
 public function action_index()
 {
     $write_allowed = ACL::is_action_allowed('admin', 'config', 'write');
     $this->template->write_allowed = $write_allowed;
     if (isset($_POST['cancel'])) {
         $this->redirect('/' . Extasy_Url::url_to_route('admin-config'));
     }
     $form = new Form_Config();
     if (!$write_allowed) {
         $form->set_read_only();
     }
     if ($write_allowed and isset($_POST['submit']) and $form->submit()) {
         $this->redirect('/' . Extasy_Url::url_to_route('admin-config'));
     }
     $this->template->form = $form;
 }