diff options
| author | michael pereira | 2011-04-05 15:35:35 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-05 15:35:35 +0200 |
| commit | 324b653c50e328019127c0aad29939fb933e4bcf (patch) | |
| tree | 10f6eaa134ab8a8bb804b8699293ad8fa2ef5b65 /application/modules/user/controllers | |
| parent | Rechte in Controller eingepflanzt (diff) | |
| parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
| download | pbs2-324b653c50e328019127c0aad29939fb933e4bcf.tar.gz pbs2-324b653c50e328019127c0aad29939fb933e4bcf.tar.xz pbs2-324b653c50e328019127c0aad29939fb933e4bcf.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
Diffstat (limited to 'application/modules/user/controllers')
12 files changed, 265 insertions, 61 deletions
diff --git a/application/modules/user/controllers/AuthController.php b/application/modules/user/controllers/AuthController.php index 7eccc98..8160104 100644 --- a/application/modules/user/controllers/AuthController.php +++ b/application/modules/user/controllers/AuthController.php @@ -2,9 +2,7 @@ class User_AuthController extends Zend_Controller_Action { - protected $personmapper = null; - private $db = null; public function init() @@ -120,11 +118,19 @@ class User_AuthController extends Zend_Controller_Action public function deleteAction() { + if($this->_request->getParam('personID')) { + if(!Pbs_Acl::checkRight('peoa')) { + $this->_redirect('/user'); + } + $personID = $this->_request->getParam('personID'); + } else { + if(!Pbs_Acl::checkRight('pdo')) { + $this->_redirect('/user'); + } + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + $personID = $userIDsNamespace['personID']; + } if($_POST['confirmdelete']) { - $auth = Zend_Auth::getInstance(); - $result = $this->personmapper->findBy(array('email' => $auth->getIdentity()),true); - $person = $result[0]; - $personID = $person["personID"]; if (isset($personID)){ $this->personmapper = new Application_Model_PersonMapper(); $person = $this->personmapper->find($personID); diff --git a/application/modules/user/controllers/BootisoController.php b/application/modules/user/controllers/BootisoController.php index 84d51ab..5c3acaa 100644 --- a/application/modules/user/controllers/BootisoController.php +++ b/application/modules/user/controllers/BootisoController.php @@ -79,6 +79,16 @@ class user_BootisoController extends Zend_Controller_Action $this->view->bootisolist = array_reverse($this->view->bootisolist); + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('bootiso'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->bootisolist = $mySearch->search($this->view->bootisolist); + } // Pagination $pagination = new Pbs_Pagination(); @@ -104,6 +114,10 @@ class user_BootisoController extends Zend_Controller_Action } + public function searchAction(){ + $this->_redirect('/user/bootiso/index/search/'.($_GET['search'])); + } + public function downloadbootisoAction() { $this->_helper->layout->disableLayout(); diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index b18adbe..84c31ff 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -87,6 +87,17 @@ class user_BootmenuController extends Zend_Controller_Action } } + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('bootmenu'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $bootmenu = $mySearch->search($bootmenu); + } + // Pagination $pagination = new Pbs_Pagination(); $pagination->setPerPage(2); @@ -102,6 +113,10 @@ class user_BootmenuController extends Zend_Controller_Action $this->view->bootmenuentrylist = $bootmenuentries; } + + public function searchAction(){ + $this->_redirect('/user/bootmenu/index/search/'.($_GET['search'])); + } public function createbootmenuAction() diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index 34fddd0..eeb60a7 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -66,6 +66,17 @@ class user_BootosController extends Zend_Controller_Action $this->view->bootoslist = $this->bootosMapper->findBy(array("groupID" => $groupID)); $this->view->update = array(); + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('bootos'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->bootoslist = $mySearch->search($this->view->bootoslist); + } + // Pagination $pagination = new Pbs_Pagination(); $pagination->setPerPage(5); @@ -92,6 +103,9 @@ class user_BootosController extends Zend_Controller_Action } } + public function searchAction(){ + $this->_redirect('/user/bootos/index/search/'.($_GET['search'])); + } public function createbootosAction() { diff --git a/application/modules/user/controllers/ClientController.php b/application/modules/user/controllers/ClientController.php index 87e764d..9fe4b03 100644 --- a/application/modules/user/controllers/ClientController.php +++ b/application/modules/user/controllers/ClientController.php @@ -53,15 +53,16 @@ class User_ClientController extends Zend_Controller_Action $search = $this->_request->getParam('search'); $mySearch = new Pbs_Search(); $mySearch->setSearchTerm($search); + $mySearch->setModule('client'); $this->view->searchform = $mySearch->searchForm(); if($search != ''){ - $this->view->search = $search; + $this->view->search = $mySearch->getSearchTerm(); $clientsInGroup = $mySearch->search($clientsInGroup); } // Pagination $pagination = new Pbs_Pagination(); - $pagination->setPerPage(10); + $pagination->setPerPage(10); $pagination->setElement($clientsInGroup); $pagination->setRequestPage($this->_request->getParam('page')); $pagination->setPageUrl('/user/client/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); @@ -73,7 +74,7 @@ class User_ClientController extends Zend_Controller_Action } public function searchAction(){ - $this->_redirect('/user/client/index/search/'.$_GET['search']); + $this->_redirect('/user/client/index/search/'.($_GET['search'])); } public function addclientAction() diff --git a/application/modules/user/controllers/ConfigController.php b/application/modules/user/controllers/ConfigController.php index 000a5e9..ecc3c65 100644 --- a/application/modules/user/controllers/ConfigController.php +++ b/application/modules/user/controllers/ConfigController.php @@ -65,6 +65,17 @@ class user_ConfigController extends Zend_Controller_Action $config->setGroupID("[".$config->getGroupID()."] ".$groupMapper->find($config->getGroupID())->getTitle()); } + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('config'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->configlist = $mySearch->search($this->view->configlist); + } + // Pagination $pagination = new Pbs_Pagination(); $pagination->setPerPage(2); @@ -78,6 +89,10 @@ class user_ConfigController extends Zend_Controller_Action $this->view->configlist = $this->view->configlist; } + + public function searchAction(){ + $this->_redirect('/user/config/index/search/'.($_GET['search'])); + } public function createconfigAction() { diff --git a/application/modules/user/controllers/FilterController.php b/application/modules/user/controllers/FilterController.php index 4ab3ad6..f84f501 100644 --- a/application/modules/user/controllers/FilterController.php +++ b/application/modules/user/controllers/FilterController.php @@ -55,6 +55,17 @@ class User_FilterController extends Zend_Controller_Action $ff->setID($filter['filterID']); $allFilter[] = $ff; } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('filter'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $allFilter = $mySearch->search($allFilter); + } // Pagination $pagination = new Pbs_Pagination(); @@ -69,6 +80,10 @@ class User_FilterController extends Zend_Controller_Action $this->view->filters = $allFilter; } + + public function searchAction(){ + $this->_redirect('/user/filter/index/search/'.($_GET['search'])); + } public function addfilterAction() { diff --git a/application/modules/user/controllers/GroupController.php b/application/modules/user/controllers/GroupController.php index 76639bd..83358c4 100644 --- a/application/modules/user/controllers/GroupController.php +++ b/application/modules/user/controllers/GroupController.php @@ -2,21 +2,13 @@ class User_GroupController extends Zend_Controller_Action { - protected $groupMapper = null; - protected $groupGroupsMapper = null; - protected $membershipMapper = null; - protected $groupRequestMapper = null; - protected $personmapper = null; - protected $rolemapper = null; - protected $groupList = null; - protected $userIDsNamespace = null; public function init() @@ -112,7 +104,15 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_redirect($_SERVER['HTTP_REFERER']); + 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'); + } + } return; } } @@ -217,12 +217,8 @@ class User_GroupController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show')) { - if(strpos($_SERVER['HTTP_REFERER'], '/groupID/')) { - $this->_redirect('/user/group/showall'); - } else { - $this->_helper->redirector('changemembership', 'person'); - } + if(strpos($_SERVER['HTTP_REFERER'], '/user/group/show') !== false && strpos($_SERVER['HTTP_REFERER'], '/groupID/') === false) { + $this->_helper->redirector('changemembership', 'person'); } else { $this->_helper->redirector('showall', 'group'); } diff --git a/application/modules/user/controllers/PersonController.php b/application/modules/user/controllers/PersonController.php index e614b98..08add21 100644 --- a/application/modules/user/controllers/PersonController.php +++ b/application/modules/user/controllers/PersonController.php @@ -2,7 +2,6 @@ class user_PersonController extends Zend_Controller_Action { - protected $person = null; protected $personmapper = null; protected $membershipMapper = null; @@ -10,14 +9,20 @@ class user_PersonController extends Zend_Controller_Action protected $groupMapper = null; protected $groups = null; protected $groupRequestMapper = null; + protected $userIDsNamespace = null; public function init() { if (Zend_Auth::getInstance()->hasIdentity()) { $this->personmapper = new Application_Model_PersonMapper(); - $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); - $this->person = new Application_Model_Person($result[0]); - $this->person->setID($result[0]['personID']); + $this->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($this->userIDsNamespace['personID']) { + $this->person = $this->personmapper->find($this->userIDsNamespace['personID']); + } else { + $result = $this->personmapper->findBy(array('email' => Zend_Auth::getInstance()->getIdentity()),true); + $this->person = new Application_Model_Person($result[0]); + $this->person->setID($result[0]['personID']); + } $this->groupMapper = new Application_Model_GroupMapper(); $this->groupRequestMapper = new Application_Model_GroupRequestMapper(); $this->membershipMapper = new Application_Model_MembershipMapper(); @@ -26,10 +31,10 @@ class user_PersonController extends Zend_Controller_Action foreach($this->memberships as $membership) { $group = $this->groupMapper->find($membership['groupID']); $this->groups[] = array ( - 'groupID' => $group->getID(), - 'title' => $group->getTitle(), - 'description' => $group->getDescription(), - 'membershipID' => $membership['membershipID'] + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'] ); } } @@ -41,12 +46,15 @@ class user_PersonController extends Zend_Controller_Action public function indexAction() { - if(!Pbs_Acl::checkRight('psod')) { $this->_redirect('/user'); } $this->view->person = $this->person; $this->view->groups = $this->groups; + $this->view->groupRequestRight = Pbs_Acl::checkRight('grm'); + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->leaveRight = Pbs_Acl::checkRight('gl'); + $this->view->overviewRight = Pbs_Acl::checkRight('pso'); $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); } @@ -55,27 +63,54 @@ class user_PersonController extends Zend_Controller_Action if(!Pbs_Acl::checkRight('peod')) { $this->_redirect('/user'); } - $this->view->person = $this->person; + if($personID = $this->_request->getParam('personID')) { + if(!Pbs_Acl::checkRight('peoa')) { + $this->_redirect('/user'); + } + $person = $this->personmapper->find($personID); + $this->view->person = $person; + } else { + $this->view->person = $this->person; + } if (!isset($_POST["save"])){ $editForm = new user_Form_PersonEdit(); } else { $editForm = new user_Form_PersonEdit($_POST); if ($editForm->isValid($_POST)) { - if(isset($_POST['newpassword'])) { - $date = new DateTime(); - $this->person->setPassword($_POST['newpassword']); - $this->person->setPasswordSalt(MD5($date->getTimestamp())); - $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); - } - $this->person->setOptions($_POST); - try { - $this->personmapper->save($this->person); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - echo "Email Address already existing."; - return; + if($personID = $this->_request->getParam('personID')) { + if(isset($_POST['newpassword'])) { + $date = new DateTime(); + $person->setPassword($_POST['newpassword']); + $person->setPasswordSalt(MD5($date->getTimestamp())); + $person->setPassword(MD5($person->getPassword() . $this->person->getPasswordSalt())); + } + $person->setOptions($_POST); + try { + $this->personmapper->save($person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } + } else { + if(isset($_POST['newpassword'])) { + $date = new DateTime(); + $this->person->setPassword($_POST['newpassword']); + $this->person->setPasswordSalt(MD5($date->getTimestamp())); + $this->person->setPassword(MD5($this->person->getPassword() . $this->person->getPasswordSalt())); + } + $this->person->setOptions($_POST); + try { + $this->personmapper->save($this->person); + } catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + echo "Email Address already existing."; + return; + } } $this->_helper->redirector('', 'person'); return; @@ -151,10 +186,9 @@ class user_PersonController extends Zend_Controller_Action public function leaveAction() { - // Nicht klar welches Recht geprüft werden soll - /*if(!Pbs_Acl::checkRight('peod')) { - $this->_redirect('/user'); - }*/ + if(!Pbs_Acl::checkRight('gl')) { + $this->_redirect('/user'); + } $this->_helper-> viewRenderer-> setNoRender(); $this->view->person = $this->person; $membershipID = $this->_request->getParam('membershipID'); @@ -197,9 +231,9 @@ class user_PersonController extends Zend_Controller_Action $group = $groupMapper->find($membership['groupID']); $role = $roleMapper->find($membership['roleID']); $membershipList[] = array( - 'membershipID' => $membership['membershipID'], - 'group' => $group->getTitle(), - 'role' => $role->getTitle() + 'membershipID' => $membership['membershipID'], + 'group' => $group->getTitle(), + 'role' => $role->getTitle() ); } } @@ -220,6 +254,54 @@ 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(); + } + + public function showAction() + { + if(!Pbs_Acl::checkRight('psood')) { + $this->_redirect('/user'); + } + $personID = $this->_request->getParam('personID'); + if($personID) { + $person = $this->personmapper->find($personID); + $memberships = $this->membershipMapper->findBy(array("personID" => $person->getID()),true); + if(isset($memberships)) { + foreach($memberships as $membership) { + $group = $this->groupMapper->find($membership['groupID']); + $groups[] = array ( + 'groupID' => $group->getID(), + 'title' => $group->getTitle(), + 'description' => $group->getDescription(), + 'membershipID' => $membership['membershipID'] + ); + } + } + $this->view->person = $person; + $this->view->groups = $groups; + $this->view->personID = $personID; + $this->view->editRight = Pbs_Acl::checkRight('peoa'); + $this->view->deleteRight = Pbs_Acl::checkRight('pd'); + $this->view->overviewRight = Pbs_Acl::checkRight('pso'); + $this->view->userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + } else { + $this->_helper->redirector('', 'person'); + return; + } + } + } @@ -237,3 +319,7 @@ class user_PersonController extends Zend_Controller_Action + + + + diff --git a/application/modules/user/controllers/PoolController.php b/application/modules/user/controllers/PoolController.php index e5fea8c..7800c7a 100644 --- a/application/modules/user/controllers/PoolController.php +++ b/application/modules/user/controllers/PoolController.php @@ -64,6 +64,17 @@ class User_PoolController extends Zend_Controller_Action $ff->setID($pool['poolID']); $yourpools[] = $ff; } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('pool'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $yourpools = $mySearch->search($yourpools); + } // Pagination $pagination = new Pbs_Pagination(); @@ -95,6 +106,10 @@ class User_PoolController extends Zend_Controller_Action if(Pbs_Acl::checkRight('posuc')) $this->view->freeclients = $freeclients; } + + public function searchAction(){ + $this->_redirect('/user/pool/index/search/'.($_GET['search'])); + } public function createpoolAction() { diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 0572c32..94759f6 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -64,6 +64,17 @@ class User_PrebootController extends Zend_Controller_Action $this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID)); + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('preboot'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $this->view->prebootlist = $mySearch->search($this->view->prebootlist); + } + // Pagination $pagination = new Pbs_Pagination(); $pagination->setPerPage(2); @@ -88,6 +99,10 @@ class User_PrebootController extends Zend_Controller_Action } } + public function searchAction(){ + $this->_redirect('/user/preboot/index/search/'.($_GET['search'])); + } + public function createprebootAction() { diff --git a/application/modules/user/controllers/RoleController.php b/application/modules/user/controllers/RoleController.php index 059d9c4..38c12b0 100644 --- a/application/modules/user/controllers/RoleController.php +++ b/application/modules/user/controllers/RoleController.php @@ -2,7 +2,7 @@ class User_RoleController extends Zend_Controller_Action { - protected $userIDsNamespace; + protected $userIDsNamespace = null; public function init() { @@ -76,8 +76,8 @@ class User_RoleController extends Zend_Controller_Action } } } - //$this->_helper->redirector('', 'role'); - //return; + $this->_helper->redirector('', 'role'); + return; } } @@ -127,7 +127,15 @@ class User_RoleController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_redirect($_SERVER['HTTP_REFERER']); + 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'); + } + } return; } } @@ -215,7 +223,11 @@ class User_RoleController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; return; } - $this->_helper->redirector('', 'role'); + 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'); + } return; } else { $pbsNotifier = new Pbs_Notifier(); |
