Пример #1
0
 /**
  * Shows a table with all groups.
  */
 public function indexAction()
 {
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuAccess'), array('action' => 'index'));
     $postData = $this->getRequest()->getPost();
     $groupMapper = new GroupMapper();
     $groups = $groupMapper->getGroupList();
     $this->getView()->set('activeGroupId', 0);
     $this->getView()->set('activeGroup', null);
     foreach ($groups as $key => $group) {
         if ($group->getId() == 1) {
             unset($groups[$key]);
         }
     }
     $this->getView()->set('groups', $groups);
     if (isset($postData['groupId'])) {
         $groupId = (int) $postData['groupId'];
         $_SESSION['user']['accessGroup'] = $groupId;
     } elseif (isset($_SESSION['user']['accessGroup'])) {
         $groupId = (int) $_SESSION['user']['accessGroup'];
     } else {
         $groupId = 0;
     }
     if ($groupId) {
         $groupAccessList = $groupMapper->getGroupAccessList($groupId);
         $activeGroup = $groupMapper->getGroupById($groupId);
         $this->getView()->set('groupAccessList', $groupAccessList);
         $this->getView()->set('activeGroupId', $groupId);
         $this->getView()->set('activeGroup', $activeGroup);
     }
     $moduleMapper = new ModuleMapper();
     $modules = $moduleMapper->getModules();
     $pageMapper = new PageMapper();
     $pages = $pageMapper->getPageList();
     $articleMapper = new ArticleMapper();
     $articles = $articleMapper->getArticles();
     $boxMapper = new BoxMapper();
     $boxes = $boxMapper->getBoxList($this->getTranslator()->getLocale());
     $accessTypes = array('module' => $modules, 'page' => $pages, 'article' => $articles, 'box' => $boxes);
     $this->getView()->set('accessTypes', $accessTypes);
 }
Пример #2
0
 public function treatAction()
 {
     if ($this->getRequest()->getParam('id') !== null) {
         $user = \Ilch\Registry::get('user');
         if (!$user->hasAccess('box_' . $this->getRequest()->getParam('id'))) {
             $this->redirect(array('action' => 'index'));
         }
     }
     $this->getView()->set('contentLanguage', $this->getConfig()->get('content_language'));
     $boxMapper = new BoxMapper();
     if ($this->getRequest()->getParam('id')) {
         if ($this->getRequest()->getParam('locale') == '') {
             $locale = '';
         } else {
             $locale = $this->getRequest()->getParam('locale');
         }
         $this->getView()->set('box', $boxMapper->getBoxByIdLocale($this->getRequest()->getParam('id'), $locale));
     }
     $this->getView()->set('languages', $this->getTranslator()->getLocaleList());
     $this->getView()->set('multilingual', (bool) $this->getConfig()->get('multilingual_acp'));
     if ($this->getRequest()->isPost()) {
         $model = new BoxModel();
         if ($this->getRequest()->getParam('id')) {
             $model->setId($this->getRequest()->getParam('id'));
         }
         $model->setTitle($this->getRequest()->getPost('boxTitle'));
         $model->setContent($this->getRequest()->getPost('boxContent'));
         if ($this->getRequest()->getPost('boxLanguage') != '') {
             $model->setLocale($this->getRequest()->getPost('boxLanguage'));
         } else {
             $model->setLocale('');
         }
         $boxMapper->save($model);
         $this->redirect(array('action' => 'index'));
     }
 }