From e5fcbd73596db87bb5cd24e1ba91cf735549b3c3 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Tue, 12 Apr 2011 14:54:50 +0200 Subject: verschiedene Korrekturen --- .../modules/user/controllers/AuthController.php | 13 +- .../modules/user/controllers/GroupController.php | 93 ++++----- .../modules/user/controllers/PersonController.php | 126 +++++------- .../modules/user/controllers/RoleController.php | 22 +-- application/modules/user/forms/RoleAdd.php | 21 +- application/modules/user/layouts/user.phtml | 10 +- .../modules/user/views/scripts/auth/delete.phtml | 2 +- .../modules/user/views/scripts/group/index.phtml | 105 ++++++++++ .../modules/user/views/scripts/group/show.phtml | 17 +- .../modules/user/views/scripts/person/index.phtml | 216 +++++++++++---------- .../user/views/scripts/person/owndetails.phtml | 108 +++++++++++ 11 files changed, 479 insertions(+), 254 deletions(-) create mode 100644 application/modules/user/views/scripts/group/index.phtml create mode 100644 application/modules/user/views/scripts/person/owndetails.phtml (limited to 'application') diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index bb16e94..d1596ae 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -133,6 +133,7 @@ class User_AuthController extends Zend_Controller_Action if (isset($personID)){ $this->personmapper = new Application_Model_PersonMapper(); $person = $this->personmapper->find($personID); + print_r($person); try { $this->personmapper->delete($person); }catch(Zend_Exception $e) @@ -141,10 +142,14 @@ class User_AuthController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - $auth->clearIdentity(); - Zend_Session::namespaceUnset('userIDs'); - Zend_Session::forgetMe(); - $this->_helper->redirector('login', 'auth'); + if($this->_request->getParam('personID')) { + $this->_helper->redirector('', 'person'); + } else { + $auth->clearIdentity(); + Zend_Session::namespaceUnset('userIDs'); + Zend_Session::forgetMe(); + $this->_helper->redirector('login', 'auth'); + } return; } } else { diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index a853a75..0a4b25d 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -30,7 +30,34 @@ class User_GroupController extends Zend_Controller_Action public function indexAction() { - $this->_helper->redirector('show', 'group'); + $this->view->groupList = $this->groupList; + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('group'); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->groupList = $mySearch->search($this->view->groupList); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(5); + $pagination->setElement($this->view->groupList); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/group/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); + + $this->view->groupList = $pagination->getElements(); + $this->view->pagination = $pagination->pagination($pageurl); + $this->view->page = $pagination->getRequestPage(); + $this->view->userIDsNamespace = $this->userIDsNamespace; + } + + public function searchAction(){ + $this->_redirect('/user/group/index/search/'.($_GET['search'])); } public function addAction() @@ -94,7 +121,7 @@ class User_GroupController extends Zend_Controller_Action $editForm = new user_Form_GroupEdit(array('groupID' => $groupID), $_POST); if ($editForm->isValid($_POST)) { $group = new Application_Model_Group($_POST); - $group->setID($this->_request->getParam('groupID')); + $group->setID($groupID); try { $this->groupMapper->save($group); } catch(Zend_Exception $e) @@ -103,19 +130,10 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - if($_SERVER['HTTP_REFERER']) { - $this->_redirect($_SERVER['HTTP_REFERER']); - } else { - if(isset($groupID)) { - $this->_redirect('/user/group/show/groupID/' . $groupID); - } else { - $this->_helper->redirector('', 'group'); - } - } + $this->_helper->redirector('', 'group'); return; } } - $this->view->editForm = $editForm; } @@ -231,10 +249,14 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/groupID/') === false) { - $this->_helper->redirector('changemembership', 'person'); + if($_SERVER['HTTP_REFERER']) { + if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/groupID/') === false) { + $this->_helper->redirector('changemembership', 'person'); + } else { + $this->_helper->redirector('', 'group'); + } } else { - $this->_helper->redirector('showall', 'group'); + $this->_helper->redirector('', 'group'); } return; } else { @@ -262,9 +284,9 @@ class User_GroupController extends Zend_Controller_Action $membership->setRoleID($_POST['roleID']); try { $id = $this->membershipMapper->save($membership); - + $membership->setID($id); - + $newMember = new Pbs_NewMember(); $newMember->createDefaults($membership); } catch(Zend_Exception $e) @@ -292,41 +314,8 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - $this->_redirect("/user/group/edit/groupID/" . $membership->getGroupID()); + $this->_redirect("/user/group/show/groupID/" . $membership->getGroupID()); } } } - - public function showallAction() - { - $this->view->groupList = $this->groupList; - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('group'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->groupList = $mySearch->search($this->view->groupList); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(5); - $pagination->setElement($this->view->groupList); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/group/showall'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - - $this->view->groupList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination($pageurl); - $this->view->page = $pagination->getRequestPage(); - $this->view->userIDsNamespace = $this->userIDsNamespace; - } - - public function searchAction(){ - $this->_redirect('/user/group/showall/search/'.($_GET['search'])); - } -} - +} \ No newline at end of file diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index ad8f596..7511233 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -45,6 +45,44 @@ class user_PersonController extends Zend_Controller_Action } public function indexAction() + { + if(!Pbs_Acl::checkRight('pso')) { + $this->_redirect('/user'); + } + $this->view->showRight = Pbs_Acl::checkRight('psod'); + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); + $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo'); + $this->view->userIDsNamespace = $this->userIDsNamespace; + + $this->view->personList = $this->personmapper->fetchAll(); + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('person'); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->personList = $mySearch->search($this->view->personList); + } + $this->view->searchform = $mySearch->searchForm(); + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(5); + $pagination->setElement($this->view->personList); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/person/index/'.((isset($this->view->search))?'/search/'.$this->view->search:'')); + + $this->view->personList = $pagination->getElements(); + $this->view->pagination = $pagination->pagination($pageurl); + $this->view->page = $pagination->getRequestPage(); + } + + public function owndetailsAction() { #if(!Pbs_Acl::checkRight('psod')) { # $this->_redirect('/user'); @@ -62,7 +100,7 @@ class user_PersonController extends Zend_Controller_Action $this->view->page = $pagination->getRequestPage(); // This should be activated in case the person has no membership and no rights. $this->view->groupRequestRight = true; - $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->editRight = Pbs_Acl::checkRight('peod'); $this->view->leaveRight = Pbs_Acl::checkRight('gl'); $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); } @@ -98,11 +136,12 @@ class user_PersonController extends Zend_Controller_Action $this->personmapper->save($person); } catch(Zend_Exception $e) { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - echo "Email Address already existing."; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; return; } + $this->_helper->redirector('', 'person'); } else { if(isset($_POST['newpassword'])) { $date = new DateTime(); @@ -115,13 +154,13 @@ class user_PersonController extends Zend_Controller_Action $this->personmapper->save($this->person); } catch(Zend_Exception $e) { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - echo "Email Address already existing."; + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('Email already registered', 'error'); + $this->view->registerForm = $registerForm; return; } + $this->_helper->redirector('owndetails', 'person'); } - $this->_helper->redirector('', 'person'); return; } } @@ -165,7 +204,7 @@ class user_PersonController extends Zend_Controller_Action } if (!isset($_POST["request"])){ if(count($allgroups) <= 0) { - $this->_helper->redirector('', 'person'); + $this->_helper->redirector('owndetails', 'person'); return; } $requestForm = new user_Form_GroupRequest(array('grouplist' => $allgroups)); @@ -186,7 +225,7 @@ class user_PersonController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - $this->_helper->redirector('', 'person'); + $this->_helper->redirector('owndetails', 'person'); return; } } @@ -211,7 +250,7 @@ class user_PersonController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - $this->_helper->redirector('', 'person'); + $this->_helper->redirector('owndetails', 'person'); return; } } @@ -263,49 +302,11 @@ class user_PersonController extends Zend_Controller_Action return; } - public function showallAction() - { - if(!Pbs_Acl::checkRight('pso')) { - $this->_redirect('/user'); - } - $this->view->showRight = Pbs_Acl::checkRight('psod'); - $this->view->editRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteRight = Pbs_Acl::checkRight('pd'); - $this->view->showOtherRight = Pbs_Acl::checkRight('psood'); - $this->view->editOtherRight = Pbs_Acl::checkRight('peoa'); - $this->view->deleteOtherRight = Pbs_Acl::checkRight('pdo'); - $this->view->userIDsNamespace = $this->userIDsNamespace; - - $this->view->personList = $this->personmapper->fetchAll(); - - // Search - $search = $this->_request->getParam('search'); - $mySearch = new Pbs_Search(); - $mySearch->setSearchTerm($search); - $mySearch->setModule('person'); - if($search != ''){ - $this->view->search = $mySearch->getSearchTerm(); - $this->view->personList = $mySearch->search($this->view->personList); - } - $this->view->searchform = $mySearch->searchForm(); - - // Pagination - $pagination = new Pbs_Pagination(); - $pagination->setPerPage(5); - $pagination->setElement($this->view->personList); - $pagination->setRequestPage($this->_request->getParam('page')); - $pagination->setPageUrl('/user/person/showall'.((isset($this->view->search))?'/search/'.$this->view->search:'')); - - $this->view->personList = $pagination->getElements(); - $this->view->pagination = $pagination->pagination($pageurl); - $this->view->page = $pagination->getRequestPage(); - } - public function searchAction(){ - if(Pbs_Acl::checkRight('pso')) { + if(!Pbs_Acl::checkRight('pso')) { $this->_redirect('/user'); } - $this->_redirect('/user/person/showall/search/'.($_GET['search'])); + $this->_redirect('/user/person/index/search/'.($_GET['search'])); } public function showAction() @@ -349,25 +350,4 @@ class user_PersonController extends Zend_Controller_Action return; } } - - -} - - - - - - - - - - - - - - - - - - - +} \ No newline at end of file diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 74efd70..91357f0 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -61,7 +61,7 @@ class User_RoleController extends Zend_Controller_Action } public function searchAction(){ - if(Pbs_Acl::checkRight('ro')) { + if(!Pbs_Acl::checkRight('ro')) { $this->_redirect('/user'); } $this->_redirect('/user/role/index/search/'.($_GET['search'])); @@ -157,7 +157,7 @@ class User_RoleController extends Zend_Controller_Action if ($editForm->isValid($_POST)) { $role = new Application_Model_Role($_POST); - $role->setID($this->_request->getParam('roleID')); + $role->setID($roleID); try { $this->roleMapper->save($role); } catch(Zend_Exception $e) @@ -166,15 +166,7 @@ class User_RoleController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - if($_SERVER['HTTP_REFERER']) { - $this->_redirect($_SERVER['HTTP_REFERER']); - } else { - if(isset($roleID)) { - $this->_redirect('/user/role/show/roleID/' . $roleID); - } else { - $this->_helper->redirector('', 'role'); - } - } + $this->_helper->redirector('', 'role'); return; } } @@ -272,8 +264,12 @@ class User_RoleController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "
"; return; } - if(strpos($_SERVER['HTTP_REFERER'], '/user/role/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/roleID/') === false) { - $this->_helper->redirector('changemembership', 'person'); + if($_SERVER['HTTP_REFERER']) { + if(strpos($_SERVER['HTTP_REFERER'], '/user/role/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/roleID/') === false) { + $this->_helper->redirector('changemembership', 'person'); + } else { + $this->_helper->redirector('', 'role'); + } } else { $this->_helper->redirector('', 'role'); } diff --git a/application/modules/user/forms/RoleAdd.php b/application/modules/user/forms/RoleAdd.php index 89cd540..4b5f059 100644 --- a/application/modules/user/forms/RoleAdd.php +++ b/application/modules/user/forms/RoleAdd.php @@ -41,23 +41,33 @@ class user_Form_RoleAdd extends Zend_Form 'label' => 'Title:', )); - $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); + $this->addElement('text', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 140)), + ), + 'required' => false, + 'label' => 'Description:', + 'value' => $_POST['description'], + )); - $sform->addElement('button', 'checkAll', array( + if($this->addrighttoroleright) { + $sform = new Zend_Form_SubForm(array('legend' => 'Rights:')); + $sform->addElement('button', 'checkAll', array( 'required' => false, 'ignore' => true, 'label' => 'Check All', 'class' => 'leftbutton', 'onclick' => "checkAllCheckBoxes(new Array('inheritance'));", - )); - - if($this->addrighttoroleright) { + )); + $sform->addElement('button', 'uncheckAll', array( 'required' => false, 'ignore' => true, 'label' => 'Uncheck All', 'onclick' => "uncheckAllCheckBoxes(new Array('inheritance'));", )); + if(count($this->rightlist) > 0) { foreach($this->rightlist as $rightcategory => $rights) { foreach($rights as $rightID => $rightTitle) { @@ -72,6 +82,7 @@ class user_Form_RoleAdd extends Zend_Form unset($elements); } } + $this->addSubForm($sform, 'rights'); } diff --git a/application/modules/user/layouts/user.phtml b/application/modules/user/layouts/user.phtml index 32569c9..2886d7a 100644 --- a/application/modules/user/layouts/user.phtml +++ b/application/modules/user/layouts/user.phtml @@ -30,19 +30,19 @@ echo $this->headScript()."\n";