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); }
protected function createComponentGrid($name) { $grid = new \App\Grid\Grid($this, $name); $grid->setModel($this->model->getAll()); $grid->addColumn(new Column('name', $this->translator->translate('admin.form.name'))); $grid->addColumn(new Column('system_name', $this->translator->translate('admin.form.systemName'))); $grid->addColumn(new Column('id', $this->translator->translate('admin.grid.id'))); $grid->addMenu(new \App\Grid\Menu\Update('edit', $this->translator->translate('admin.form.edit'))); $grid->addMenu(new \App\Grid\Menu\Menu('permission', $this->translator->translate('admin.role.setPermission'))); $grid->addMenu(new \App\Grid\Menu\Delete('delete', $this->translator->translate('admin.grid.delete'))); $grid->setOrder('name'); return $grid; }
/** * Index action method * * @return void */ public function index() { $role = new Model\Role(); if ($role->hasPages($this->application->config()['pagination'])) { $limit = $this->application->config()['pagination']; $pages = new Paginator($role->getCount(), $limit); $pages->useInput(true); } else { $limit = null; $pages = null; } $this->prepareView('roles/index.phtml'); $this->view->title = 'Roles'; $this->view->pages = $pages; $this->view->queryString = $this->getQueryString('sort'); $this->view->roles = $role->getAll($limit, $this->request->getQuery('page'), $this->request->getQuery('sort')); $this->send(); }
/** * Edit action method * * @return void */ public function edit($id) { $user = new Model\User(); $user->getById($id); if (!isset($user->id)) { $this->redirect('/users'); } if ($this->services['acl']->isAllowed($this->sess->user->role, 'users-of-role-' . $user->role_id, 'edit')) { $this->prepareView('users/edit.phtml'); $this->view->title = 'Edit User'; $this->view->username = $user->username; $role = new Model\Role(); $roles = $role->getAll(); $roleValues = []; foreach ($roles as $r) { $roleValues[$r->id] = $r->name; } $fields = $this->application->config()['forms']['App\\Form\\User']; $fields[1]['username']['attributes']['onkeyup'] = 'pop.changeTitle(this.value);'; $fields[1]['password1']['required'] = false; $fields[1]['password2']['required'] = false; $fields[0]['clear_logins']['value'][1] = $user->total_logins . ' Login' . ($user->total_logins == 1 ? '' : 's'); $fields[0]['role_id']['type'] = 'select'; $fields[0]['role_id']['label'] = 'Role'; $fields[0]['role_id']['value'] = $roleValues; $fields[0]['role_id']['marked'] = $user->role_id; $this->view->form = new Form\User($fields); $this->view->form->addFilter('strip_tags', null, 'textarea')->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($user->toArray()); if ($this->request->isPost()) { $this->view->form->addFilter('strip_tags', null, 'textarea')->setFieldValues($this->request->getPost()); if ($this->view->form->isValid()) { $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter(); $user = new Model\User(); $user->update($this->view->form->getFields(), $this->application->config()['application_title'], $this->sess); $this->view->id = $user->id; $this->sess->setRequestValue('saved', true); $this->redirect('/users/edit/' . $user->id); } } $this->send(); } else { $this->redirect('/users'); } }