/** * (non-PHPdoc) * @see Zend_Controller_Plugin_Abstract::preDispatch() */ public function preDispatch(Zend_Controller_Request_Abstract $request) { try { #Zend_Debug::dump($request->getParams()); #die(); $mdlRole = new Acl_Model_Role(); $auth = Zend_Auth::getInstance(); $acl = Zend_Registry::get('ZendACL'); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $this->role = $mdlRole->find($identity->role_id)->current(); } else { $this->role = $mdlRole->find(3)->current(); } $mdlMenuItem = new menu_Model_Item(); $mdlMenu = new menu_Model_Menu(); $navLinks = array(); $nav = new Zend_Navigation($navLinks); $menuList = $mdlMenu->getByStatus(1); foreach ($menuList as $menu) { $options = array('id' => 'menu-' . $menu->id, 'label' => $menu->name, 'uri' => ''); $page = Zend_Navigation_Page::factory($options); $nav->addPage($page); $menuitemList = $mdlMenuItem->getItemsForNavigationByMenu($menu); foreach ($menuitemList as $menuItem) { if ($menuItem->parent_id == 0) { if ($menuItem->external == 1) { $this->addExternalPage($page, $menuItem); } else { $this->addInternalPage($page, $menuItem); } } else { $parent = $nav->findBy('id', 'mii-' . $menuItem->parent_id); if ($menuItem->external == 1) { $this->addExternalPage($parent, $menuItem); } else { $this->addInternalPage($parent, $menuItem); } } } } $this->addCurrentPageUnregistered($nav, $request); $page = $nav->findBy("id", "mii-" . $request->getParam("mid")); if ($page) { $page->setActive(true); } Zend_Registry::set('Zend_Navigation', $nav); #Zend_Debug::dump($nav->toArray()); #die(); } catch (Exception $e) { try { $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log'); $logger = new Zend_Log($writer); $logger->log($e->getMessage(), Zend_Log::ERR); } catch (Exception $e) { } } }
/** * Prepare the ACL for a given admin * * @params $admin Admin_Model_Admin * @return Acl_Model_Acl */ public function prepare($admin) { if (!is_null($admin->getRoleId())) { $role = new Acl_Model_Role(); $this->__role_obj = $role->getRoleById($admin->getRoleId()); $this->__role = $this->__role_obj->getCode(); $this->__build(); } return $this; }
/** * (non-PHPdoc) * @see Zend_Controller_Plugin_Abstract::preDispatch() */ public function preDispatch(Zend_Controller_Request_Abstract $request) { try { $viewHelperAction = new Zend_View_Helper_Action(); $navigation = Zend_Registry::get('Zend_Navigation'); $navItem = $navigation->findBy('active', true); $auth = Zend_Auth::getInstance(); $acl = Zend_Registry::get('ZendACL'); $mdlRole = new Acl_Model_Role(); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $role = $mdlRole->find($identity->role_id)->current(); } else { $role = $mdlRole->find(3)->current(); } // Zend_Debug::dump($acl); //Zend_Debug::dump($role->id); $mdlWidget = new System_Model_Widget(); $hookXml = APPLICATION_PATH . '/configs/hooks.xml'; $sxeHook = new SimpleXMLElement($hookXml, null, true); $mdlResource = new Acl_Model_Resource(); $mdlWidgetDetail = new System_Model_Widgetdetail(); foreach ($sxeHook as $hook) { #/* #Zend_Debug::dump($hook); $widgets = $mdlWidgetDetail->getWidgetsByHookAndItemId($navItem->id, $hook); $hookContent = ''; foreach ($widgets as $widget) { #Zend_Debug::dump($widget->title); $params = array(); $widgetParams = Zend_Json::decode($widget->params); foreach ($widgetParams as $strParam => $valParam) { $params[$strParam] = $valParam; } $rsACL = strtolower($widget->module . ':' . $widget->controller); $prvACL = strtolower($widget->actioncontroller); if ($acl->isAllowed($role->id, $rsACL, $prvACL)) { #if ( $widget->position == "menu_registrado" ) #var_dump($widget->params, $widget->actioncontroller, $widget->id); $hookContent .= $widget->showtitle == 1 ? "<h3>" . $widget->title . "</h3>" : ""; $hookContent .= $viewHelperAction->action($widget->actioncontroller, $widget->controller, $widget->module, $params); } } #*/ Zend_Layout::getMvcInstance()->assign(strval($hook), $hookContent); } } catch (Exception $e) { try { $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log'); $logger = new Zend_Log($writer); $logger->log($e->getMessage(), Zend_Log::ERR); } catch (Exception $e) { } } }
/** * (non-PHPdoc) * @see Zend_Form::init() */ public function init() { #$this->_addClassNames('well'); $this->setMethod(Zend_Form::METHOD_POST); $this->setTranslator(); $txtName = $this->createElement('text', 'name'); $txtName->setLabel('ACL_ROLE')->setRequired(TRUE)->setAttrib('size', '40')->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($txtName); $mdlRole = new Acl_Model_Role(); $roles = $mdlRole->getRoles(); $cbRole = $this->createElement("select", "parent_id"); $cbRole->setLabel("ACL_ROLE_PARENT")->setRequired(FALSE); if ($roles->count() > 0) { foreach ($roles as $role) { $cbRole->addMultiOption($role->id, $role->name); } } $this->addElement($cbRole); $mdlSkin = new System_Model_Skin(); $skin = $mdlSkin->getSkinSelected(); $skinName = is_null($skin) ? 'default' : strtolower($skin->name); $layouts = new Zend_Config_Xml(APPLICATION_PATH . '/layouts/scripts/' . $skinName . '/layouts.xml'); $layouts = $layouts->files->layout->toArray(); $cbDesktopLayout = $this->createElement("select", "desktop_layout"); $cbDesktopLayout->setLabel('LBL_DESKTOP_LAYOUT'); $cbDesktopLayout->setRequired(true); $cbMobileLayout = $this->createElement("select", "mobile_layout"); $cbMobileLayout->setLabel('LBL_MOBILE_LAYOUT'); $cbMobileLayout->setRequired(true); foreach ($layouts as $layout) { $cbDesktopLayout->addMultiOption($layout, $layout); $cbMobileLayout->addMultiOption($layout, $layout); } $this->addElement($cbDesktopLayout); $this->addElement($cbMobileLayout); $txtPriority = $this->createElement('text', 'priority'); $txtPriority->setLabel('ACL_PRIORITY')->setRequired(TRUE)->setAttrib('size', 10)->setAttrib('maxlength', 2)->addValidator(new Zend_Validate_NotEmpty()); $this->addElement($txtPriority); $id = $this->createElement('hidden', 'id'); $id->setDecorators(array('ViewHelper')); $this->addElement($id); $token = new Zend_Form_Element_Hash('token'); $token->setSalt(md5(uniqid(rand(), TRUE))); $token->setTimeout(60); $token->setDecorators(array('ViewHelper')); $this->addElement($token); $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default'); $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions); $btnSubmit->setLabel('LBL_SAVE'); $btnSubmit->removeDecorator('Label'); $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper'))); $btnSubmit->removeDecorator('Label'); $this->addElement($btnSubmit); }
/** * Sync action for resource controller */ public function syncAction() { $translate = Zend_Registry::get('Zend_Translate'); try { $mdlResource = new Acl_Model_Resource(); $registeredList = $mdlResource->getRegisteredList(); #print_r($registeredList); #die(); $resourcesAvailable = array(); $sxe = new SimpleXMLElement(APPLICATION_PATH . '/../.zfproject.xml', null, true); foreach ($sxe->projectDirectory->applicationDirectory->modulesDirectory->moduleDirectory as $module) { #echo "<h1>Modulo:".$module['moduleName']."</h1>"; foreach ($module->controllersDirectory->controllerFile as $controller) { #echo "<h2>controlador: ".$controller['controllerName']."<h2>"; foreach ($controller->actionMethod as $action) { #echo "<h3>action: ".$action['actionName']."<h3>"; $resourcesAvailable[] = $module['moduleName'] . '-' . $controller['controllerName'] . '-' . $action['actionName']; } } } foreach ($resourcesAvailable as $rsa) { $isRegistered = false; foreach ($registeredList as $rsRegistered) { $rsTemp = $rsRegistered->module . '-' . $rsRegistered->controller . '-' . $rsRegistered->actioncontroller; if (strcasecmp($rsa, $rsTemp) == 0) { $isRegistered = true; } } if (!$isRegistered) { $arrResource = explode('-', $rsa); $resource = $mdlResource->createRow(); $resource->module = $arrResource[0]; $resource->controller = $arrResource[1]; $resource->actioncontroller = $arrResource[2]; $resource->save(); } } /* @var $cache Zend_Cache_Backend_File */ $cache = Zend_Registry::get('cacheACL'); $mdlRole = new Acl_Model_Role(); $roles = $mdlRole->getRoles(); foreach ($roles as $role) { if ($cache->test('cacheACL_' . $role->id)) { $cache->remove('cacheACL_' . $role->id); } } $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("ACL_RESOURCES_SYNCD"))); return $this->_helper->redirector("list", "resource", "acl"); } catch (Exception $e) { $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage())); return $this->_helper->redirector("list", "resource", "acl"); } return; }
public function deleteAction() { if ($this->getRequest()->getParam("role_id")) { $role = new Acl_Model_Role(); $role->find($this->getRequest()->getParam("role_id")); $role->delete(); $data = array("success" => true, "message" => $this->_("Your role has been successfully deleted")); } else { $data = array("error" => true, "message" => $this->_("An error occurred while deleting your role. please try again later")); } $this->_sendHtml($data); }
/** * Returns permissions assigned to a specific role * @param Zend_Db_Table_Row_Abstract $resource * @param Zend_Db_Table_Row_Abstract $role * @return Ambigous <Zend_Db_Table_Row_Abstract, NULL, unknown> */ function getByResource(Zend_Db_Table_Row_Abstract $resource, Zend_Db_Table_Row_Abstract $role) { #var_dump($role); $select = $this->select()->setIntegrityCheck(false)->from(array('perm' => $this->_name), array('privilege', 'role_id'))->joinInner(array('rop' => Zend_Registry::get('tablePrefix') . 'acl_role'), 'perm.role_id = rop.id', 'rop.name')->where("role_id = ?", $role->id, Zend_Db::INT_TYPE)->where("resource_id = ?", $resource->id, Zend_Db::INT_TYPE)->limit(1); #echo $select->__toString().'<br>' $mdlRole = new Acl_Model_Role(); $select2 = $mdlRole->select()->order('priority DESC')->limit(1); if (is_null($this->fetchRow($select))) { $childRole = $role->findDependentRowset('Acl_Model_Role', null, $select2)->current(); if (!is_null($childRole)) { return $this->getByResource($resource, $childRole); } } /*else { return $this->fetchRow($select); }*/ return $this->fetchRow($select); }
/** * (non-PHPdoc) * * @see Zend_Form::init() */ public function init() { $this->setTranslator(); // this->_addClassNames('well'); $this->setMethod(Zend_Form::METHOD_POST); $txtFullname = $this->createElement('text', 'fullname')->setLabel("LBL_FULLNAME")->setRequired(true)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim(), new Zend_Filter_Alpha(true)))->addValidators(array(new Zend_Validate_Alpha(true), new Zend_Validate_StringLength(array('min' => 5, 'max' => 200)))); $this->addElement($txtFullname); $txtEmail = $this->createElement('text', 'email')->setLabel("ACL_EMAIL")->setRequired(TRUE)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress()); $txtEmail->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'os_acl_account', 'field' => 'email'))); $this->addElement($txtEmail); $txtEmailAlternative = $this->createElement('text', 'email_alternative')->setLabel("ACL_EMAIL_ALTERNATIVE")->setRequired(TRUE)->setAttrib('size', 40)->addFilters(array(new Zend_Filter_StringToLower(), new Zend_Filter_StringTrim()))->addValidator(new Zend_Validate_EmailAddress()); $txtEmailAlternative->addValidator(new Zend_Validate_Db_NoRecordExists(array('table' => 'os_acl_account', 'field' => 'email_alternative'))); $this->addElement($txtEmailAlternative); $txtPassword = $this->createElement('password', 'password')->setLabel('ACL_PASSWORD')->setRequired(TRUE)->setAttrib('size', 40)->addValidator(new Zend_Validate_StringLength(array('min' => '6'))); $this->addElement($txtPassword); $txtPassword2 = $this->createElement('password', 'password2')->setLabel('ACL_REPEAT_PASSWORD')->setRequired(TRUE)->setAttrib('size', 40)->addValidator('Identical', false, array('password'))->addValidator(new Zend_Validate_StringLength(array('min' => '6'))); $this->addElement($txtPassword2); $mdlRole = new Acl_Model_Role(); $roles = $mdlRole->getRoles(); $cbRole = $this->createElement("select", "role_id")->setLabel("ACL_ROLE")->setRequired(TRUE); // >addMultiOption ( 0, "LABEL_SELECT_ROLE" ); if ($roles->count() > 0) { foreach ($roles as $role) { $cbRole->addMultiOption($role->id, $role->name); } } $this->addElement($cbRole); $id = $this->createElement('hidden', 'id'); $id->setDecorators(array('ViewHelper')); $this->addElement($id); $token = new Zend_Form_Element_Hash('token'); $token->setSalt(md5(uniqid(rand(), TRUE))); $token->setTimeout(60); $token->setDecorators(array('ViewHelper')); $this->addElement($token); $submitOptions = array('buttonType' => Twitter_Bootstrap_Form_Element_Button::BUTTON_LINK, 'type' => 'submit', 'buttonType' => 'default'); $btnSubmit = new Twitter_Bootstrap_Form_Element_Button('submit', $submitOptions); $btnSubmit->setLabel('LBL_SAVE'); $btnSubmit->removeDecorator('Label'); $btnSubmit->setDecorators(array(array('FieldSize'), array('ViewHelper'), array('Addon'), array('ElementErrors'), array('Description', array('tag' => 'p', 'class' => 'help-block')), array('HtmlTag', array('tag' => 'div', 'class' => 'controls')), array('Wrapper'))); $btnSubmit->removeDecorator('Label'); $this->addElement($btnSubmit); }
/** * (non-PHPdoc) * @see Zend_Controller_Plugin_Abstract::preDispatch() */ public function preDispatch(Zend_Controller_Request_Abstract $request) { try { $boostrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'); $userAgent = $boostrap->getResource('useragent'); $device = $userAgent->getDevice(); $module = strtolower($this->getRequest()->getModuleName()); $controller = strtolower($this->_request->getControllerName()); $action = strtolower($this->_request->getActionName()); $role = null; $auth = Zend_Auth::getInstance(); #Zend_Debug::dump( $auth->hasIdentity() ); $mdlRole = new Acl_Model_Role(); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $role = $mdlRole->find(intval($identity->role_id)); } else { $role = $mdlRole->find(3); } if ((int) $device->getFeature('is_desktop') == 1) { $layout = $role->desktop_layout; } else { $layout = $role->mobile_layout; } $mdlSkin = new System_Model_Skin(); $skin = $mdlSkin->getSkinSelected(); $skinName = is_null($skin) ? 'default' : strtolower($skin->name); $layoutPath = Zend_Layout::getMvcInstance()->getLayoutPath(); Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/' . $skinName); Zend_Layout::getMvcInstance()->setLayout($layout); } catch (Exception $e) { $layout = "frontend"; Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . '/layouts/scripts/default'); Zend_Layout::getMvcInstance()->setLayout($layout); try { $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log'); $logger = new Zend_Log($writer); $logger->log($e->getMessage(), Zend_Log::ERR); } catch (Exception $e) { } } }
public function findAction() { $admin = new Admin_Model_Admin(); $admin->find($this->getRequest()->getParam("admin_id")); $data = array(); if ($admin->getId()) { $data["admin"] = $admin->getData(); $data["section_title"] = $this->_("Edit the user %s", $admin->getFirstname() . " " . $admin->getLastname()); } else { $data["section_title"] = $this->_("Create a new user"); } $data["applications_section_title"] = $this->_("Manage access"); $countries = Zend_Registry::get('Zend_Locale')->getTranslationList('Territory', null, 2); asort($countries, SORT_LOCALE_STRING); $data["country_codes"] = $countries; $roles = $admin->getAvailableRole(); $data["roles"] = $roles; $role = new Acl_Model_Role(); $default_role_id = $role->findDefaultRoleId(); $data["default_role_id"] = $default_role_id; $this->_sendHtml($data); }
public function findallAction() { $role = new Acl_Model_Role(); $roles = $role->findAll(); $default_role = $role->findDefaultRoleId(); $data = array(); foreach ($roles as $role) { $is_default_role = false; if ($role->getId() == $default_role) { $is_default_role = true; } $data[] = array("id" => $role->getId(), "code" => $role->getCode(), "label" => $role->getLabel(), "default" => $is_default_role); } $this->_sendHtml($data); }
/** * PreDispatch method for ACL Plugin. It checks if current user has privileges for resources requested * @see Zend_Controller_Plugin_Abstract::preDispatch() * @param Zend_Controller_Request_Abstract $request */ public function preDispatch(Zend_Controller_Request_Abstract $request) { try { $frontendOptions = array('lifetime' => 43200, 'automatic_serialization' => true); $backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); // fetch the current user $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $identity = $auth->getIdentity(); $objRole->id = $identity->role_id; // get an instance of Zend_Session_Namespace used by Zend_Auth #$authns = new Zend_Session_Namespace($auth->getStorage()->getNamespace()); // set an expiration on the Zend_Auth namespace where identity is held #$authns->setExpirationSeconds(60 * 30); // expire auth storage after 30 min } else { $objRole->id = 3; # guess } $cacheACL = false; if ($cache->load('cacheACL_' . $objRole->id) && $cache->test('cacheACL_' . $objRole->id)) { $cacheACL = $cache->load('cacheACL_' . $objRole->id); } if ($cacheACL == false) { // set up acl $acl = new Zend_Acl(); $mdlRole = new Acl_Model_Role(); $mdlResource = new Acl_Model_Resource(); $mdlPermission = new Acl_Model_Permission(); #$role = $mdlRole->createRow(); $acl->addRole(new Zend_Acl_Role($objRole->id)); $role = $mdlRole->find($objRole->id)->current(); #var_dump($role, $objRole->id); #die(); if ($role == null) { throw new Zend_Exception('Role not found'); } $select = $mdlRole->select()->order('priority DESC')->limit(1); $childRole = $role->findDependentRowset('Acl_Model_Role', null, $select)->current(); $resources = $mdlResource->getRegisteredList(); #if ( !$resources ) throw new Zend_Exception('Resources not available'); if ($resources->count() > 0) { foreach ($resources as $resource) { $resourceTemp = strtolower($resource->module . ':' . $resource->controller); if (!$acl->has(new Zend_Acl_Resource($resourceTemp))) { $acl->addResource(new Zend_Acl_Resource($resourceTemp)); } } } else { throw new Zend_Exception('Resources not available'); } if ($resources->count() > 0) { foreach ($resources as $resource) { $resourceTemp = strtolower($resource->module . ':' . $resource->controller); $childPrivilege = $childRole ? $mdlPermission->getByResource($resource, $childRole) : null; $rolePrivilege = $mdlPermission->getByResource($resource, $role); if ($objRole->id < 2) { $acl->allow($objRole->id, $resourceTemp, $resource->actioncontroller); } elseif (!$childRole && !$rolePrivilege || strcasecmp($rolePrivilege->privilege, 'deny') == 0 || $childPrivilege && strcasecmp($childPrivilege->privilege, 'deny') == 0 && !$rolePrivilege) { $acl->deny($objRole->id, $resourceTemp, $resource->actioncontroller); } elseif (strcasecmp($rolePrivilege->privilege, 'allow') == 0 || $childPrivilege && strcasecmp($childPrivilege->privilege, 'allow') == 0 && !$rolePrivilege) { $acl->allow($objRole->id, $resourceTemp, $resource->actioncontroller); } } # foreach ( $resources as $resource ) } # if ( $resources->count() > 0 ) $cache->save($acl, 'cacheACL_' . $objRole->id); Zend_Registry::set('ZendACL', $acl); } else { Zend_Registry::set('ZendACL', $cacheACL); } Zend_Registry::set('cacheACL', $cache); } catch (Exception $e) { try { $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log'); $logger = new Zend_Log($writer); $logger->log($e->getMessage(), Zend_Log::ERR); } catch (Exception $e) { } } }
/** * Delete action for role controller * @throws Zend_Exception */ public function deleteAction() { $translate = Zend_Registry::get('Zend_Translate'); try { $id = $this->getRequest()->getParam('id'); if ($id < 4) { throw new Zend_Exception($translate->translate("ACL_DEFAULT_ROLE_COULD_NOT_BE_DROPPED")); } $mdlRole = new Acl_Model_Role(); $role = $mdlRole->find($id)->current(); if (!$role) { throw new Zend_Exception($translate->translate("LBL_ROW_NOT_FOUND")); } $role->delete(); $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("LBL_CHANGES_SAVED"))); return $this->_helper->redirector("list", "role", "acl"); } catch (Exception $e) { $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage())); return $this->_helper->redirector("list", "role", "acl"); } return; }
public function signuppostAction() { if ($data = $this->getRequest()->getPost()) { try { // Check l'email et le mot de passe if (empty($data['email']) or !Zend_Validate::is($data['email'], 'emailAddress')) { throw new Exception($this->_('Please enter a valid email address.')); } if (empty($data['password']) or strlen($data['password']) < 6) { throw new Exception($this->_('The password must be at least 6 characters.')); } if (empty($data['confirm_password']) or $data['password'] != $data['confirm_password']) { throw new Exception($this->_('The password and the confirmation does not match.')); } $admin = new Admin_Model_Admin(); $admin->findByEmail($data['email']); if ($admin->getId()) { throw new Exception($this->_('We are sorry but this email address is already used.')); } $role = new Acl_Model_Role(); if ($default_role = $role->findDefaultRoleId()) { $admin->setRoleId($default_role); } // Créé le user $admin->setEmail($data['email'])->setPassword($data['password'])->save(); // Met le user en session $this->getSession()->setAdmin($admin); $admin->sendAccountCreationEmail($data["password"]); $redirect_to = 'admin/application/list'; } catch (Exception $e) { if ($this->getSession()->isLoggedIn()) { $redirect_to = 'admin/application/list'; } else { $this->getSession()->addError($e->getMessage()); $redirect_to = "/"; } } $this->redirect($redirect_to); } }
/** * Update action for permission controller * @throws Zend_Exception * @return NULL */ public function updateAction() { // action body try { $translate = Zend_Registry::get('Zend_Translate'); $roleId = $this->getRequest()->getParam('id', 0); $mdlRole = new Acl_Model_Role(); $role = $mdlRole->find($roleId)->current(); if (!$role) { throw new Exception($translate->translate("LBL_ROW_NOT_FOUND")); } #Zend_Debug::dump( $this->getRequest()->getParams() ); $mdlPermission = new Acl_Model_Permission(); #$resources = $this->getRequest()->getParam( 'hrs'); $hrs = new Zend_Session_Namespace('resourceDataIds'); $resources = $hrs->hrs; zend_session::namespaceUnset('resourceDataIds'); $arrResources = explode(',', $resources); #$mdlPermission->deleteByRole($role); $permissions = $role->findDependentRowset('Acl_Model_Permission', 'Role'); foreach ($permissions as $perm) { #$perm = $mdlPermission->find()->current(); $perm->delete(); } foreach ($arrResources as $resourceId) { #echo $this->getRequest()->getParam('cb_res_'.$resourceId, 'deny')."<br>"; $permission = $mdlPermission->createRow(); $permission->role_id = $role->id; $permission->resource_id = $resourceId; $permission->privilege = $this->getRequest()->getParam('cb_res_' . $resourceId, 'deny'); $permission->save(); } /* @var $cache Zend_Cache_Backend_File */ $cache = Zend_Registry::get('cacheACL'); $mdlRole = new Acl_Model_Role(); $roles = $mdlRole->getList(); foreach ($roles as $role) { if ($cache->test('cacheACL_' . $role->id)) { $cache->remove('cacheACL_' . $role->id); } } $this->_helper->flashMessenger->addMessage(array('type' => 'info', 'header' => '', 'message' => $translate->translate("LBL_CHANGES_SAVED"))); //$this->_helper->redirector( "manage", "permission", "acl", array('role'=>$role->id) ); $this->_helper->redirector("list", "role", "acl"); } catch (Exception $e) { $this->_helper->flashMessenger->addMessage(array('type' => 'error', 'header' => '', 'message' => $e->getMessage())); $this->_helper->redirector("list", "role", "acl"); } return null; }