/** * EditAction for Roles * * @return void */ public function editAction() { $this->view->title = "Edit roles"; $form = new User_Form_Role(); $form->submit->setLabel('Save'); $this->view->form = $form; if ($this->getRequest()->isPost()) { if ($form->isValid($this->getRequest()->getPost())) { $model = new User_Model_Roles(); $id = $this->getRequest()->getPost('id'); $data = $form->getValues(); if ($data["name"] == "implementor") { echo "pantalla de error de no se puede crear implementor"; die; } $model->update($form->getValues(), 'id = ' . (int) $id); return $this->_helper->redirector('index'); } else { $form->populate($this->getRequest()->getPost()); } } else { $id = $this->_getParam('id', 0); if ($id > 0) { $model = new User_Model_Roles(); $form->populate($model->fetchEntry($id)); } } }
public function updateAction() { if ($this->_isUserAllowed()) { if ($this->_hasParam("id")) { $id = $this->_getParam("id"); $request = $this->getRequest(); $role = new User_Domain_Role(null); $role = $role->getById($id); $form = new User_Form_Role(User_Form_Role::ACTION_EDIT, $role); if ($request->isPost()) { $data = $request->getPost(); if (isset($data['save'])) { if ($form->isValid($request->getPost())) { try { $this->_update($form->getValues()); $msg = 'Role updated'; $this->_helper->flashMessenger->addMessage(array('success' => $msg)); $this->_helper->redirector(array('action' => 'list', 'controller' => 'role', 'module' => 'user')); } catch (Exception $e) { $this->_addSavingExceptionMessage($e); } } else { $this->_addValidationMessage(); } } else { if (isset($data['cancel'])) { $lru = new Agana_Controller_Action_Helper_LastRequestUri(); $lru->setNamespace('acl_role'); $lru->redirect('user/role/list'); //$this->_helper->redirector(array('action' => 'list', 'controller' => 'admin', 'module' => 'user')); } } } $this->view->form = $form; } else { $this->_helper->flashMessenger->addMessage(array('error' => 'Param id missing')); $this->_forward('list'); return; } } }