예제 #1
0
 /**
  * Edit an existing role in the ACL
  *
  */
 public function editAction()
 {
     $roleId = $this->_getParam('roleId', null);
     if (is_null($roleId)) {
         throw new Ot_Exception_Input('msg-error-roleIdNotSet');
     }
     $role = new Ot_Model_DbTable_Role();
     $thisRole = $role->find($roleId);
     if (is_null($thisRole)) {
         throw new Ot_Exception_Data('msg-error-noRole');
     }
     if ($thisRole->editable != 1) {
         throw new Ot_Exception_Access('msg-error-unallowedRoleEdit');
     }
     $form = new Ot_Form_Role();
     $form->populate($thisRole->toArray());
     if ($this->_request->isPost()) {
         if ($form->isValid($_POST)) {
             $data = array('roleId' => $roleId, 'name' => $form->getValue('name'), 'inheritRoleId' => $form->getValue('inheritRoleId'));
             $role->update($data, null);
             $logOptions = array('attributeName' => 'accessRole', 'attributeId' => $data['roleId']);
             $this->_helper->log(Zend_Log::INFO, 'Role ' . $data['name'] . ' was modified', $logOptions);
             $this->_helper->messenger->addSuccess('Role was saved successfully');
             $this->_helper->redirector->gotoRoute(array('controller' => 'acl', 'action' => 'details', 'roleId' => $roleId), 'ot', true);
         } else {
             $this->_helper->messenger->addError('msg-error-invalidForm');
         }
     }
     $this->_helper->pageTitle("ot-acl-edit:title");
     $this->view->assign(array('role' => $thisRole, 'form' => $form));
 }