diff options
| author | Björn Geiger | 2011-03-31 19:40:08 +0200 |
|---|---|---|
| committer | Björn Geiger | 2011-03-31 19:40:08 +0200 |
| commit | 9a9129f1b59c0ead5cc530cfa367f9d121867b7f (patch) | |
| tree | 8ae55c11d5ca665ea664a0baf2270704a09dcb63 /application/modules/user/controllers/RoleController.php | |
| parent | alphaID in KCL implementiert (diff) | |
| download | pbs2-9a9129f1b59c0ead5cc530cfa367f9d121867b7f.tar.gz pbs2-9a9129f1b59c0ead5cc530cfa367f9d121867b7f.tar.xz pbs2-9a9129f1b59c0ead5cc530cfa367f9d121867b7f.zip | |
Checkboxen für Rechte beim erstellen einer Rolle
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; } } |
