public function getAcl() { if ($this->acl) { return $this->acl; } $cache = $this->getCache(); if ($cache && ($data = $cache->get('acl'))) { return $this->acl = $data; } $acl = new MemoryAcl(); $acl->setDefaultAction(Acl::DENY); $roles = Entities\Roles::find(); foreach ($roles as $role) { $roleName = $role->name ? $role->name : $role->roleKey; $acl->addRole($role->roleKey, $role->roleKey); } $resources = Entities\Resources::find(); foreach ($resources as $resource) { $acl->addResource($resource->resourceKey); } $operations = Entities\Operations::find(); foreach ($operations as $operation) { $acl->addResourceAccess($operation->resourceKey, $operation->operationKey); if ($operation->roles) { foreach ($operation->roles as $role) { $acl->allow($role->roleKey, $operation->resourceKey, $operation->operationKey); } } } if ($cache) { $cache->save('acl', $acl); } return $this->acl = $acl; }
/** * @operationName("Operation List") * @operationDescription("Get operation list") */ public function indexAction() { $query = array('q' => $this->request->getQuery('q', 'string'), 'rid' => $this->request->getQuery('rid', 'int'), 'roleid' => $this->request->getQuery('roleid', 'int'), 'group' => $this->request->getQuery('group', 'string'), 'limit' => 1000, 'page' => $this->request->getQuery('page', 'int', 1)); $form = new Forms\OperationFilterForm(); $form->setValues($this->request->getQuery()); $this->view->setVar('form', $form); $operation = new Models\Operation(); $operations = $operation->findOperations($query); $paginator = new \Eva\EvaEngine\Paginator(array("builder" => $operations, "limit" => $query['limit'], "page" => $query['page'])); $paginator->setQuery($query); $pager = $paginator->getPaginate(); $this->view->setVar('pager', $pager); $this->view->setVar('roles', Entities\Roles::find()); }
public function addRole() { if ($this->roleid) { return $this->roleid; } $roles = Entities\Roles::find(); $options = array('All Roles'); if ($roles) { foreach ($roles as $role) { $options[$role->id] = $role->roleKey . ' | ' . $role->name; } } $element = new Select('roleid', $options); $this->add($element); return $this->roleid = $element; }