Esempio n. 1
0
 public function startup()
 {
     parent::startup();
     if ($this->getName() != 'Admin:Sign' && !$this->user->isLoggedIn()) {
         $this->redirect('Sign:default');
     }
     //nastavim prava
     foreach ($this->roles->getAll() as $role) {
         $this->acl->addRole($role['system_name']);
     }
     foreach ($this->resources->getAll() as $resource) {
         $this->acl->addResource($resource['system_name']);
     }
     foreach ($this->permissions->getAll() as $permission) {
         $this->acl->allow($permission->role->system_name, $permission->resource->system_name, $permission->privilege->system_name);
     }
     $this->acl->addRole('super_admin');
     $this->acl->allow('super_admin');
     //homepage a sign maji pristup vsichni
     $this->acl->addResource('homepage');
     $this->acl->allow(\App\AdminModule\Components\Authorizator::ALL, 'homepage');
     $this->acl->addResource('sign');
     $this->acl->allow(\App\AdminModule\Components\Authorizator::ALL, 'sign');
     //vychozi role
     $this->acl->addRole('guest');
     //kontrola prav
     if ($this->getName() != 'Admin:Image' && $this->getAction() != 'ordering' && $this->getAction() != 'orderingCategory' && $this->getAction() != 'deleteImage' && $this->getAction() != 'changePassword' && $this->getAction() != 'getCity' && $this->getAction() != 'download') {
         if (!$this->getUser()->isAllowed($this->getNameSimple(), $this->getAction())) {
             $this->flashMessage($this->translator->translate('admin.login.noAccess'), 'error');
             $this->redirect('Homepage:default');
         }
     }
     //projedu vsek moduly a pokusim se najit presentery
     $presenters = array();
     $vsekDir = dirname(__FILE__) . '/../../../';
     $ch = opendir($vsekDir);
     while (($file = readdir($ch)) !== false) {
         if (!in_array($file, array('.', '..'))) {
             if (file_exists($vsekDir . $file . '/src/setting.xml')) {
                 $xml = simplexml_load_file($vsekDir . $file . '/src/setting.xml');
                 if (isset($xml->presenter)) {
                     $this->menuModules[] = array('name' => (string) $xml->presenter->name, 'resource' => (string) $xml->presenter->resource);
                 }
             }
         }
     }
     closedir($ch);
 }