public function injectGlobalMenu() { //TODO ACL if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, App_Module_Acl::ACL_RESOURCE_APPACCOUNT, App_Module_Acl::ACL_RESOURCE_APPACCOUNT_PRIVILEGE_VIEW)) { return array(array('label' => '{{i class=||icon-cog||}}{{/i}} {{translate}}Administration{{/translate}}', 'id' => 'menu-adm', 'uri' => '#', 'order' => 999), array('label' => '{{i class=||icon-user||}}{{/i}} {{translate}}Persons{{/translate}}', 'id' => 'menu-person', 'parent' => 'menu-adm', 'load-in' => 'content-container', 'action' => 'index', 'controller' => 'gm', 'module' => 'aganacore', 'params' => array('id' => 'persons'), 'order' => 999)); } }
public function injectGlobalMenu() { //TODO ACL $globalMenu = Zend_Registry::get('Navigation.GlobalMenu'); $menuAdm = $globalMenu->findOneBy('id', 'menu-adm'); if ($menuAdm === null) { $menuAdm = new Zend_Navigation_Page_Uri(array('label' => '{{i class=||icon-cog||}}{{/i}} {{translate}}Administration{{/translate}}', 'id' => 'menu-adm', 'uri' => '#', 'order' => 999)); } // $newPage = new Zend_Navigation_Page_Mvc( // array( // 'label' => '{{i class=||icon-user||}}{{/i}} {{translate}}Users{{/translate}}', // 'id' => 'menu-adm-users', // 'parent' => $menuAdm, // 'module' => 'user', // 'controller' => 'admin', // 'action' => 'index', // )); // if (Zend_Auth::getInstance()->hasIdentity()) { if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_LIST) || Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USERROLE, User_Module_Acl::ACL_RESOURCE_USERROLE_PRIVILEGE_LIST)) { $newPage = new Zend_Navigation_Page_Mvc(array('label' => '{{i class=||icon-user||}}{{/i}} {{translate}}Users{{/translate}}', 'id' => 'menu-adm-users', 'parent' => $menuAdm, 'load-in' => 'content-container', 'action' => 'index', 'controller' => 'gm', 'module' => 'aganacore', 'params' => array('id' => 'user_acl'), 'order' => 999)); } } $globalMenu->addPage($menuAdm); }
/** * Teste if cant edit. If can NOT return TRUE * to be used in disabled attrib * @return boolean */ private function cantEdit() { $cantEdit = false; if ($this->_action == self::ACTION_EDIT) { $cantEdit = !Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE); } return $cantEdit; }
protected function _isUserAllowed($resource, $privilege) { if (Zend_Auth::getInstance()->hasIdentity()) { return Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, $resource, $privilege); } else { $this->_redirectLogin(); return false; } }
public function initResources() { $acl = Agana_Acl_Service::getInstance(); $resources = $this->getResources(); foreach ($resources as $res) { if (!$acl->has($res['name'])) { $acl->addResource($res['name']); } } }
public function update() { if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_HEAD, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_HEAD_PRIVILEGE_UPDATE) || Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_BRANCH, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_BRANCH_PRIVILEGE_UPDATE)) { try { $dao = new Busunit_Persist_Dao_Busunit(); return $dao->save($this->_busunit); } catch (Exception $e) { throw $e; } } }
public function __construct() { $this->_name = 'Users'; if (Zend_Auth::getInstance()->hasIdentity()) { if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_LIST)) { $this->_navigation[] = array('icon' => 'icon-user', 'label' => 'Users', 'module' => 'user', 'controller' => 'admin', 'action' => 'index', 'route' => 'default', 'uri' => '', 'title' => ''); } if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USERROLE, User_Module_Acl::ACL_RESOURCE_USERROLE_PRIVILEGE_LIST)) { $this->_navigation[] = array('icon' => 'icon-group', 'label' => 'User roles', 'module' => 'user', 'controller' => 'role', 'action' => 'index', 'route' => 'default', 'uri' => '', 'title' => ''); } } }
/** * * @param integer $appaccount_id * @return Busunit_Model_Branch * @throws Exception * @throws Agana_Exception */ public function getByAppAccount($appaccount_id) { try { if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_BRANCH, Busunit_Module_Acl::ACL_RESOURCE_BUSUNIT_BRANCH_PRIVILEGE_LIST)) { $dao = new Busunit_Persist_Dao_Busunit(); return $dao->getByAppAccount($appaccount_id, 0, array('returnArray' => true)); } else { throw new Agana_Exception('You don not have permission to access this'); } } catch (Exception $e) { throw $e; } }
private function _isUserAllowed($resource, $privilege) { if (Zend_Auth::getInstance()->hasIdentity()) { if (!Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, $resource, $privilege)) { Agana_Acl_Service::addNoPermissionFlashMessage(); if (Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USERROLE, User_Module_Acl::ACL_RESOURCE_USERROLE_PRIVILEGE_LIST)) { $this->_helper->redirector('list'); } else { $this->_helper->redirector('index', 'index', 'aganacore'); } return false; } else { return true; } } else { $this->_redirectLogin(); return false; } }
public function listAction() { if ($this->_isUserAllowed(User_Module_Acl::ACL_RESOURCE_USERROLE, User_Module_Acl::ACL_RESOURCE_USERROLE_PRIVILEGE_CREATE)) { if ($this->_hasParam('id')) { $roleDomain = new User_Domain_Role(null); $role = $roleDomain->getById($this->_getParam('id')); if ($role) { $this->view->role = $role; $this->view->modulesResources = Agana_Acl_Service::getResources(); } else { $this->_helper->flashMessenger->addMessage(array('error' => 'Could not found any role with this id')); return; } //$this->view->roles = $roleDomain->getAll(Zend_Auth::getInstance()->getIdentity()->appaccount_id); } else { $this->_helper->flashMessenger->addMessage(array('error' => 'Param id missing')); return; } } }
public function updatePasswordAction() { if ($this->_hasParam("id")) { $id = $this->_getParam("id"); //$update = $this->_isUserAllowed(User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE); $update = Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE_PASSWORD); $isMe = $id == Zend_Auth::getInstance()->getIdentity()->id; if ($update || $isMe) { $request = $this->getRequest(); $userDomain = new User_Domain_User(null); $user = $userDomain->getById($id); $form = new User_Form_Password(User_Form_User::ACTION_EDIT, $user); if ($request->isPost()) { $data = $request->getPost(); if (isset($data['save'])) { if ($form->isValid($data)) { try { $this->_updatePassword($data); $msg = 'User updated'; $this->_helper->flashMessenger->addMessage(array('success' => $msg)); $param = null; if ($id) { $param = array('id' => $id); } $this->_helper->redirector('index', 'profile', 'user', $param); } catch (Exception $e) { $this->_addSavingExceptionMessage($e); } } else { $this->_addValidationMessage(); } } else { if (isset($data['cancel'])) { $param = null; if ($id) { $param = array('id' => $id); } $this->_helper->redirector('index', 'profile', 'user', $param); } } } $this->view->form = $form; $this->view->user = $user; } else { $this->_helper->flashMessenger->addMessage(array('error' => 'You do not have permission to access this')); $param = null; if ($id) { $param = array('id' => $id); } $this->_helper->redirector('index', 'profile', 'user', $param); return; } } else { $this->_helper->flashMessenger->addMessage(array('error' => 'Param id missing')); $this->_helper->redirector('index', 'profile', 'user'); return; } }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $acl = Agana_Acl_Service::loadAcl(); }