diff options
| -rw-r--r-- | application/modules/user/controllers/RoleController.php | 34 | ||||
| -rw-r--r-- | application/modules/user/forms/RoleAdd.php | 23 | ||||
| -rw-r--r-- | application/modules/user/views/scripts/role/show.phtml | 8 | ||||
| -rw-r--r-- | public/media/css/user.css | 36 |
4 files changed, 91 insertions, 10 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; } } diff --git a/application/modules/user/forms/RoleAdd.php b/application/modules/user/forms/RoleAdd.php index e8e99a5..9a9570c 100644 --- a/application/modules/user/forms/RoleAdd.php +++ b/application/modules/user/forms/RoleAdd.php @@ -22,15 +22,32 @@ class user_Form_RoleAdd extends Zend_Form 'label' => 'Title:', )); - $this->addElement('text', 'description', array( + $this->addElement('text', 'title', array( 'filters' => array('StringTrim'), 'validators' => array( - array('StringLength', false, array(0, 140)), + array('StringLength', false, array(0, 50)), ), 'required' => false, - 'label' => 'Description:', + 'label' => 'Title:', )); + $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); + if(count($this->rightlist) > 0) { + foreach($this->rightlist as $rightcategory => $rights) { + foreach($rights as $rightID => $rightTitle) { + $element = $this->createElement('checkbox', "$rightID", array( + 'label' => $rightTitle . ':', + 'belongsTo' => 'rights', + )); + $elements[] = $rightID; + $sform->addElement($element); + } + $sform->addDisplayGroup($elements, "$rightcategory", array("legend" => $rightcategory . ":")); + unset($elements); + } + } + $this->addSubForm($sform, 'rights'); + $this->addElement('checkbox', 'inheritance', array( 'label' => 'Inheritance:', )); diff --git a/application/modules/user/views/scripts/role/show.phtml b/application/modules/user/views/scripts/role/show.phtml index 408dcc4..6c6f8f5 100644 --- a/application/modules/user/views/scripts/role/show.phtml +++ b/application/modules/user/views/scripts/role/show.phtml @@ -44,7 +44,8 @@ if($this->roleID) { if(isset($this->rightcategorieslist)) { foreach($this->rightcategorieslist as $k => $v) { $rights = $this->rightsList[$k]; - ?> + if(count($rights) > 0) { + ?> <h3><?php echo $v; ?></h3> <table> <tr> @@ -76,6 +77,7 @@ if($this->roleID) { ?> </table> <?php + } } } } else { @@ -84,6 +86,6 @@ if($this->roleID) { <center> <h3>No Rights have been added!</h3> </center> -<?php -} + <?php + } }
\ No newline at end of file diff --git a/public/media/css/user.css b/public/media/css/user.css index 00d144a..faf2fa4 100644 --- a/public/media/css/user.css +++ b/public/media/css/user.css @@ -27,4 +27,40 @@ tr.selectedEntry { tr.selectedEntry td { padding-left: 3px; +} + +#rights-element dl fieldset dt { + width: 325px; +} + +#rights-element dl fieldset { + margin-bottom: 10px; + width: 350px; +} + +#fieldset-rights { + margin-top: 10px; + border: 0px; + margin-left: 0; + padding: 0; +} + +#fieldset-rights legend { + padding-left: 0; +} + +#fieldset-rights dl legend { + padding-left: 2px; +} + +#rights-element dd { + margin-left: 0px; +} + +#rights-element { + margin-left: 0px; +} + +#rights-label { + width: 0px; }
\ No newline at end of file |
