From 198221618856ef22ab8f69874b8d4e101db3746d Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 5 Apr 2011 15:35:32 +0200 Subject: Rechte in Controller eingepflanzt --- .../modules/user/controllers/PrebootController.php | 41 ++++++++++------------ 1 file changed, 18 insertions(+), 23 deletions(-) (limited to 'application/modules/user/controllers/PrebootController.php') diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 6944e27..0572c32 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -58,8 +58,8 @@ class User_PrebootController extends Zend_Controller_Action $groupID = $this->membership->getGroupID(); - //TODO ACL Darf er PrebootMenu sehen? - if(false) + //ACL Darf er PrebootMenu sehen? + if(!Pbs_Acl::checkRight('pro')) $this->_redirect('/user/index'); $this->view->prebootlist = $this->prebootMapper->findBy(array("groupID" => $groupID)); @@ -76,8 +76,7 @@ class User_PrebootController extends Zend_Controller_Action $this->view->page = $pagination->getRequestPage(); $this->view->prebootlist= $this->view->prebootlist; - - + $this->view->update = array(); $update = $this->_request->getParam('checkupdate'); @@ -92,8 +91,8 @@ class User_PrebootController extends Zend_Controller_Action public function createprebootAction() { - //TODO ACL Is he allowed to create Preboots? - if(false) + //ACL Is he allowed to create Preboots? + if(!Pbs_Acl::checkRight('prc')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/forbidden'); if (!isset($_POST["createpreboot"])){ @@ -109,8 +108,7 @@ class User_PrebootController extends Zend_Controller_Action if ($prebootForm->isValid($_POST)) { $preboot = new Application_Model_PreBoot($_POST); - $preboot->setMembershipID($this->membership->getID()); - $preboot->setGroupID($this->membership->getGroupID()); + $preboot->setGroupID($this->membership->getGroupID()); try { @@ -153,8 +151,8 @@ class User_PrebootController extends Zend_Controller_Action public function checkupdateAction($preboot) { - //TODO ACL Is he allowed to update Preboots? - if(false) + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('pru')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); $prebootID = $preboot->getID(); @@ -184,8 +182,8 @@ class User_PrebootController extends Zend_Controller_Action public function updateprebootAction() { - //TODO ACL Is he allowed to update Preboots? - if(false) + //ACL Is he allowed to update Preboots? + if(!Pbs_Acl::checkRight('pru')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/updateresult/forbidden'); $prebootID = $this->_request->getParam('prebootID'); @@ -243,8 +241,8 @@ class User_PrebootController extends Zend_Controller_Action public function editprebootAction() { - //TODO ACL Is he allowed to edit Preboots? - if(false) + //ACL Is he allowed to edit Preboots? + if(!Pbs_Acl::checkRight('pre')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); $prebootID = $this->_request->getParam('prebootID'); @@ -262,16 +260,14 @@ class User_PrebootController extends Zend_Controller_Action if (!isset($_POST["editpreboot"])){ $prebootForm = new user_Form_Preboot(array( - 'action' => 'editpreboot', - 'rights' => 'meta', + 'action' => 'editpreboot', 'page' => $this->page)); $prebootForm->populate($preboot->toArray()); }else{ $prebootForm = new user_Form_Preboot(array( - 'action' => 'editpreboot', - 'rights' => 'meta', + 'action' => 'editpreboot', 'page' => $this->page),$_POST); if ($prebootForm->isValid($_POST)) { @@ -279,7 +275,6 @@ class User_PrebootController extends Zend_Controller_Action $prebootold = $preboot; $preboot = new Application_Model_PreBoot($_POST); - $preboot->setMembershipID($this->membership->getID()); $preboot->setGroupID($this->membership->getGroupID()); $preboot->setID($prebootID); @@ -287,8 +282,8 @@ class User_PrebootController extends Zend_Controller_Action if($preboot->getPath_preboot() != $prebootold->getPath_preboot()){ - //TODO ACL Is he allowed to edit the Preboot Path? - if(false) + //ACL Is he allowed to edit the Preboot Path? + if(Pbs_Acl::checkRight('prem')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); exec("wget -O '".$path_preboot."preboot.zip' ".escapeshellcmd($preboot->getPath_preboot()) ." 2>&1 | grep 'saved'" , $status); @@ -350,8 +345,8 @@ class User_PrebootController extends Zend_Controller_Action public function deleteprebootAction() { - //TODO ACL Is he allowed to delete Preboots? - if(false) + //ACL Is he allowed to delete Preboots? + if(!Pbs_Acl::checkRight('prd')) $this->_redirect('/user/preboot/index/page/'.$this->page.'/deleteresult/forbidden'); try{ -- cgit v1.2.3-55-g7522 From 92c66441276e03c6fd53496ac8d57ff52b4a3eb4 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 5 Apr 2011 15:54:00 +0200 Subject: Session-Controller erstellt --- .zfproject.xml | 7 ++ application/models/BootMenuEntriesMapper.php | 20 ++++- .../modules/user/controllers/PrebootController.php | 2 +- .../modules/user/controllers/SessionController.php | 89 ++++++++++++++++++++++ application/modules/user/layouts/user.phtml | 1 + .../modules/user/views/scripts/session/index.phtml | 31 ++++++++ library/Pbs/Search.php | 10 ++- 7 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 application/modules/user/controllers/SessionController.php create mode 100644 application/modules/user/views/scripts/session/index.phtml (limited to 'application/modules/user/controllers/PrebootController.php') diff --git a/.zfproject.xml b/.zfproject.xml index 21e4994..3a64fde 100644 --- a/.zfproject.xml +++ b/.zfproject.xml @@ -184,6 +184,9 @@ + + + @@ -342,6 +345,9 @@ + + + @@ -827,6 +833,7 @@ + diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index 02c5e07..466b80b 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -129,11 +129,25 @@ class Application_Model_BootMenuEntriesMapper $row = $result->current(); if($botmenuentries == null){ - $botmenuentries = new Application_Model_BootMenuEntriesMapper(); - $botmenuentries->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setKclappend($row->kclappend)->setOrder($row->order); + $botmenuentries = new Application_Model_BootMenuEntries(); + $botmenuentries->setID($row->bootmenuentriesID) + ->setBootosID($row->bootosID) + ->setBootmenuID($row->bootmenuID) + ->setTitle($row->title) + ->setConfigID($row->configID) + ->setKcl($row->kcl) + ->setKclappend($row->kclappend) + ->setOrder($row->order); return $botmenuentries; }else{ - $botmenuentries->setID($row->bootmenuentriesID)->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setKclappend($row->kclappend)->setOrder($row->order); + $botmenuentries->setID($row->bootmenuentriesID) + ->setBootosID($row->bootosID) + ->setBootmenuID($row->bootmenuID) + ->setTitle($row->title) + ->setConfigID($row->configID) + ->setKcl($row->kcl) + ->setKclappend($row->kclappend) + ->setOrder($row->order); } } diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 94759f6..f283969 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -69,11 +69,11 @@ class User_PrebootController extends Zend_Controller_Action $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); } + $this->view->searchform = $mySearch->searchForm(); // Pagination $pagination = new Pbs_Pagination(); diff --git a/application/modules/user/controllers/SessionController.php b/application/modules/user/controllers/SessionController.php new file mode 100644 index 0000000..3c3c192 --- /dev/null +++ b/application/modules/user/controllers/SessionController.php @@ -0,0 +1,89 @@ +hasIdentity()) { + $userIDsNamespace = Zend_Session::namespaceGet('userIDs'); + if($userIDsNamespace['membershipID'] ==''){ + $pbsNotifier = new Pbs_Notifier(); + echo $pbsNotifier->notify('No membershipID set','forbidden'); + } + + $membershipMapper = new Application_Model_MembershipMapper(); + $this->membership = new Application_Model_Membership(); + $membershipMapper->find($userIDsNamespace['membershipID'],$this->membership); + } else { + $this->_helper->redirector('login', 'auth'); + } + $this->page = $this->_request->getParam('page'); + } + + public function indexAction() + { + $sessionMapper = new Application_Model_SessionMapper(); + $bootisoMapper = new Application_Model_BootIsoMapper(); + $bootosMapper = new Application_Model_BootOsMapper(); + $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); + $membershipMapper = new Application_Model_MembershipMapper(); + $personMapper = new Application_Model_PersonMapper(); + + $bootisos = $bootisoMapper->findBy(array('groupID',$this->membership->getGroupID())); + foreach($bootisos as $bootiso){ + $sessions = $sessionMapper->findBy(array('bootisoID',$bootiso->getID())); + foreach($sessions as $session){ + #echo $session->getBootosID(); + if($session->getBootosID() != '') + $session->setBootosID("[".$session->getBootosID()."] ".$bootosMapper->find($session->getBootosID())->getTitle()); + + if($session->getBootmenuentryID() != '') + $session->setBootmenuentryID("[".$session->getBootmenuentryID()."] ".$bootmenuentriesMapper->find($session->getBootmenuentryID())->getTitle()); + + if($session->getBootisoID() != '') + $session->setBootisoID("[".$session->getBootisoID()."] ".$bootisoMapper->find($session->getBootisoID())->getTitle()); + + if($session->getMembershipID() != ''){ + $personID = $membershipMapper->find($session->getMembershipID())->getPersonID(); + $p = new Application_Model_Person(); + $personMapper->find($personID,$p); + $session->setMembershipID("[".$session->getMembershipID()."] ".$p->getFirstname()." ".$p->getName()); + + } + $mySessions[] =$session; + } + } + + // Search + $search = $this->_request->getParam('search'); + $mySearch = new Pbs_Search(); + $mySearch->setSearchTerm($search); + $mySearch->setModule('session'); + $this->view->searchform = $mySearch->searchForm(); + if($search != ''){ + $this->view->search = $mySearch->getSearchTerm(); + $mySessions = $mySearch->search($mySessions); + } + + // Pagination + $pagination = new Pbs_Pagination(); + $pagination->setPerPage(3); + $pagination->setElement($mySessions); + $pagination->setRequestPage($this->_request->getParam('page')); + $pagination->setPageUrl('/user/session/index'.((isset($this->view->search))?'/search/'.$this->view->search:'')); + $mySessions = $pagination->getElements(); + + $this->view->pagination = $pagination->pagination($pageurl); + $this->view->page = $pagination->getRequestPage(); + $this->view->sessions = $mySessions; + + } + + public function searchAction(){ + $this->_redirect('/user/session/index/search/'.($_GET['search'])); + } + + +} + diff --git a/application/modules/user/layouts/user.phtml b/application/modules/user/layouts/user.phtml index 84873ef..14ce235 100644 --- a/application/modules/user/layouts/user.phtml +++ b/application/modules/user/layouts/user.phtml @@ -40,6 +40,7 @@ echo $this->headScript()."\n"; + diff --git a/application/modules/user/views/scripts/session/index.phtml b/application/modules/user/views/scripts/session/index.phtml new file mode 100644 index 0000000..bb9f1e2 --- /dev/null +++ b/application/modules/user/views/scripts/session/index.phtml @@ -0,0 +1,31 @@ +

Session

+searchform; ?> + + + + + + + + + + + + + +sessions as $session): ?> + + + + + + + + + + + + + +
ID sessionIDalphasessionID alphasessionIDClientID clientIDBootmenuentryID bootmenyentryIDBootOsID bootosIDBootIsoID bootisoIDMembershipID membershipIDTime timeIP ipIPv6 ip6
escape($session->getID()) ?>escape($session->getAlphasessionID()) ?>escape($session->getClientID()) ?>escape($session->getBootmenuentryID()) ?>escape($session->getBootosID()) ?>escape($session->getBootisoID()) ?>escape($session->getMembershipID()) ?>escape($session->getTime())) ?>escape($session->getIp()) ?>escape($session->getIp6()) ?>
+pagination; ?> diff --git a/library/Pbs/Search.php b/library/Pbs/Search.php index 971bdab..eb9d198 100644 --- a/library/Pbs/Search.php +++ b/library/Pbs/Search.php @@ -6,6 +6,8 @@ class Pbs_Search{ private $searcha; private $searchb; private $module; + private $countall; + private $countresult; public function searchForm(){ $str = "
@@ -13,8 +15,9 @@ class Pbs_Search{ "; $highlight = array(); if($this->searchTerm != ''){ - $str .= "Delete Client - "; + $str .= "Delete Client"; + $str .= "
$this->countresult results found in $this->countall
"; + $str .=""; foreach($this->getSearchTerms() as $term){ $highlight[] = "$('table').highlight('".$term."');"; } @@ -80,7 +83,7 @@ class Pbs_Search{ return $beta; } public function search($array){ - + $this->countall = count($array); foreach($array as $counter => $cig){ if(is_object($cig)){ $cig = $cig->toArray(); @@ -111,6 +114,7 @@ class Pbs_Search{ } foreach( $data as $c) $ges[] = $array[$c]; + $this->countresult = count($ges); return $ges; } } -- cgit v1.2.3-55-g7522