From bd5988e7b8c3377a3768efc1dedabd199a90c342 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 5 Apr 2011 15:34:21 +0200 Subject: find Methode angepasst --- application/models/BootMenuEntriesMapper.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'application/models') diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index 4d82c96..02c5e07 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -119,7 +119,7 @@ class Application_Model_BootMenuEntriesMapper } } - public function find($id, Application_Model_BootMenuEntries $botmenuentries) + public function find($id, Application_Model_BootMenuEntries $botmenuentries = null) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { @@ -128,8 +128,13 @@ class Application_Model_BootMenuEntriesMapper $row = $result->current(); - $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); - + 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); + 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); + } } public function fetchAll() -- 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/models') 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 From 6e476cbdc86f66a154b6794967adaba1a2d0f004 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Tue, 5 Apr 2011 16:21:08 +0200 Subject: Rechte in Alle Controller --- application/models/BootMenuMapper.php | 13 ++++-- .../user/controllers/BootmenuController.php | 49 ++++++++++------------ 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'application/models') diff --git a/application/models/BootMenuMapper.php b/application/models/BootMenuMapper.php index 60c506d..1043897 100644 --- a/application/models/BootMenuMapper.php +++ b/application/models/BootMenuMapper.php @@ -93,16 +93,23 @@ class Application_Model_BootMenuMapper } } - public function find($id, Application_Model_BootMenu $botmenu) + public function find($id, Application_Model_BootMenu $botmenu = null) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { return; } - $row = $result->current(); - $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + if($botmenu == null){ + $botmenu = new Application_Model_BootMenu(); + $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + return $botmenu; + }else{ + $botmenu->setID($row->bootmenuID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setTitle($row->title)->setCreated($row->created); + } + + } public function fetchAll() diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index 84c31ff..78fdde7 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -135,8 +135,7 @@ class user_BootmenuController extends Zend_Controller_Action $bootmenu = new Application_Model_BootMenu($_POST); $bootmenu->setCreated(time()); - - $bootmenu->setMembershipID($this->membership->getID()); + $bootmenu->setGroupID($this->membership->getGroupID()); try{ @@ -156,8 +155,8 @@ class user_BootmenuController extends Zend_Controller_Action public function editbootmenuAction() { - //TODO ACL Is he allowed to edit BootMenus? - if(false) + //ACL Is he allowed to edit BootMenus? + if(!Pbs_Acl::checkRight('booe')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); $bootmenuID = $this->_request->getParam('bootmenuID'); @@ -172,26 +171,21 @@ class user_BootmenuController extends Zend_Controller_Action if (!isset($_POST["editbootmenu"])){ - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all','page' => $this->page)); + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu','page' => $this->page)); $bootmenuForm->populate($bootmenu->toArray()); }else{ - $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all','page' => $this->page),$_POST); + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu','page' => $this->page),$_POST); if ($bootmenuForm->isValid($_POST)) { $bootmenuold = $bootmenu; $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setMembershipID($this->membership->getID()); $bootmenu->setGroupID($this->membership->getGroupID()); $bootmenu->setCreated(time()); $bootmenu->setID($bootmenuID); - //TODO ACL Is he allowed to edit this? - if(false) - $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); - try { $this->bootmenuMapper->save($bootmenu); }catch(Zend_Exception $e) @@ -212,8 +206,8 @@ class user_BootmenuController extends Zend_Controller_Action public function deletebootmenuAction() { - //TODO ACL Is he allowed to delete Bootmenu? - if(false) + //ACL Is he allowed to delete Bootmenu? + if(!Pbs_Acl::checkRight('bood')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); try{ @@ -240,8 +234,8 @@ class user_BootmenuController extends Zend_Controller_Action public function addbootmenuentryAction() { - //TODO ACL Darf er BootMenuEntries erstellen? - if(false) + //ACL Darf er BootMenuEntries erstellen? + if(!Pbs_Acl::checkRight('booae')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/forbidden'); $bootmenuID = $this->_request->getParam('bootmenuID'); @@ -255,6 +249,9 @@ class user_BootmenuController extends Zend_Controller_Action $bootoslist = $bootosMapper->fetchAll(); $configlist = $configMapper->fetchAll(); + if($this->membership->getGroupID() != $this->bootmenuMapper->find($bootmenuID)->getGroupID()) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); + if (!isset($_POST["addbootmenuentry"])){ $bootmenuentryForm = new user_Form_BootmenuEntries(array( @@ -262,8 +259,7 @@ class user_BootmenuController extends Zend_Controller_Action 'maxorder'=> $maxorder, 'configlist'=> $configlist, 'page' => $this->page, - 'action' => 'addbootmenuentry', - 'rights' => 'meta' + 'action' => 'addbootmenuentry' )); $bootmenuentryForm->populate(array('order' => $maxorder)); @@ -278,8 +274,7 @@ class user_BootmenuController extends Zend_Controller_Action 'maxorder'=> $maxorder, 'configlist'=>$configlist, 'page' => $this->page, - 'action' => 'addbootmenuentry', - 'rights' => 'meta'),$_POST); + 'action' => 'addbootmenuentry'),$_POST); if ($bootmenuentryForm->isValid($_POST)) { @@ -312,8 +307,8 @@ class user_BootmenuController extends Zend_Controller_Action public function editbootmenuentryAction() { - //TODO ACL Is he allowed to edit BootMenus? - if(false) + //ACL Is he allowed to edit BootMenus? + if(!Pbs_Acl::checkRight('booee')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); @@ -344,7 +339,6 @@ class user_BootmenuController extends Zend_Controller_Action 'kcl' => $bootmenuentry->getKcl(), 'page' => $this->page, 'action' => 'editbootmenuentry', - 'rights' => 'all' )); if(!isset($_POST['configID'])){ @@ -363,8 +357,7 @@ class user_BootmenuController extends Zend_Controller_Action 'configlist'=> $configlist, 'kcl' => $bootmenuentry->getKcl(), 'page' => $this->page, - 'action' => 'editbootmenuentry', - 'rights' => 'all'),$_POST); + 'action' => 'editbootmenuentry'),$_POST); if ($bootmenuentryForm->isValid($_POST)) { @@ -378,8 +371,8 @@ class user_BootmenuController extends Zend_Controller_Action $bootmenuentryold->getConfigID() != $bootmenuentry->getConfigID() || $bootmenuentryold->getKcl() != $bootmenuentry->getKcl() || $bootmenuentryold->getKclappend() != $bootmenuentry->getKclappend()){ - //TODO ACL Is he allowed to edit this? - if(false) + //ACL Is he allowed to edit this? + if(Pbs_Acl::checkRight('booeem')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); } @@ -410,8 +403,8 @@ class user_BootmenuController extends Zend_Controller_Action public function removebootmenuentryAction() { - //TODO ACL Is he allowed to delete Bootos? - if(false) + //ACL Is he allowed to delete Bootos? + if(!Pbs_Acl::checkRight('boode')) $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); try{ -- cgit v1.2.3-55-g7522