diff options
Diffstat (limited to 'application/modules/user/controllers/RoleController.php')
| -rw-r--r-- | application/modules/user/controllers/RoleController.php | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index d8ed9e6..6246c9d 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -35,23 +35,49 @@ class User_RoleController extends Zend_Controller_Action public function addAction() { if(isset($this->userIDsNamespace['groupID'])) { + $roleID = $this->userIDsNamespace['roleID']; + $rights = $this->rightMapper->fetchAll(); + if(count($rights) > 0) { + $rightCategoryMapper = new Application_Model_RightCategoryMapper(); + foreach($rights as $right) { + $rightCategory = $rightCategoryMapper->find($right->getRightcategoryID()); + $rightlist[$rightCategory->getTitle()][$right->getID()] = $right->getTitle(); + } + } if (!isset($_POST["add"])){ - $addForm = new user_Form_RoleAdd(array('rightlist' => $rightList)); + $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist)); } else { - $addForm = new user_Form_RoleAdd(array('rightlist' => $rightList),$_POST); + $addForm = new user_Form_RoleAdd(array('rightlist' => $rightlist),$_POST); if ($addForm->isValid($_POST)) { $_POST['groupID'] = $this->userIDsNamespace['groupID']; $role = new Application_Model_Role($_POST); try { $this->roleMapper->save($role); + $db = Zend_Db_Table::getDefaultAdapter(); + $insertedRoleID = $db->lastInsertId(); } catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_helper->redirector('', 'role'); - return; + foreach($_POST['rights'] as $rightID => $bool) { + if($bool == 1) { + $rightrole = new Application_Model_RightRoles(); + $rightrole->setRightID($rightID); + $rightrole->setRoleID($insertedRoleID); + try { + $this->rightRolesMapper->save($rightrole); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + return; + } + } + } + //$this->_helper->redirector('', 'role'); + //return; } } |
