From 00a1bcc61d4b5c1e28b14c018332a934100e227f Mon Sep 17 00:00:00 2001 From: michael pereira Date: Fri, 1 Apr 2011 16:46:47 +0200 Subject: Bootmenu & BootOs Controller --- .../user/controllers/BootmenuController.php | 235 ++++++++++++--------- 1 file changed, 141 insertions(+), 94 deletions(-) (limited to 'application/modules/user/controllers/BootmenuController.php') diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index 627d37c..7d829de 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -30,12 +30,34 @@ class user_BootmenuController extends Zend_Controller_Action public function indexAction() { + + $result = $this->_request->getParam('addresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('create',$result); + } + $result = $this->_request->getParam('deleteresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('delete',$result); + } + $result = $this->_request->getParam('modifyresult'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('modify',$result); + } + + //TODO ACL Darf er BootOsMenu sehen? + if(false) + $this->_redirect('/user/index'); + $this->bootMenumapper = new Application_Model_BootMenuMapper(); $this->bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper(); $bootosMapper = new Application_Model_BootOsMapper(); $configMapper = new Application_Model_ConfigMapper(); if(true){ + //TODO nur Bootmenus von Admins $bootmenu = $this->bootmenuMapper->findBy('groupID', $this->membership->getGroupID()); foreach ($bootmenu as $bm){ $bootmenuID = $bm->getID(); @@ -61,6 +83,123 @@ class user_BootmenuController extends Zend_Controller_Action } + + public function createbootmenuAction() + { + //TODO ACL Darf er BootMenus erstellen? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/addresult/forbidden'); + + if (!isset($_POST["createbootmenu"])){ + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'rights' => 'all')); + } else { + + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'createbootmenu', 'rights' => 'all'),$_POST); + + if ($bootmenuForm->isValid($_POST)) { + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID($this->membership->getID()); + $bootmenu->setGroupID($this->membership->getGroupID()); + $bootmenu->setCreated(time()); + + try{ + $this->bootmenuMapper->save($bootmenu); + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/bootmenu/index/page/'.$page.'/addresult/error'); + } + $this->_redirect('/user/bootmenu/index/page/'.$page.'/addresult/ok'); + } + } + + $this->view->bootmenuForm = $bootmenuForm; + } + + public function editbootmenuAction() + { + + //TODO ACL Is he allowed to edit BootMenus? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/forbidden'); + + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!is_numeric($bootmenuID)) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/forbidden'); + + $bootmenu = new Application_Model_BootMenu(); + $bootmenu = $this->bootmenuMapper->find($bootmenuID); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/forbidden'); + + if (!isset($_POST["editbootmenu"])){ + + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all')); + $bootmenuForm->populate($bootmenu->toArray()); + + }else{ + $bootmenuForm = new user_Form_Bootmenu(array('action' => 'editbootmenu', 'rights' => 'all'),$_POST); + + if ($bootmenuForm->isValid($_POST)) { + + $bootmenuold = $bootmenu; + + $bootmenu = new Application_Model_BootMenu($_POST); + $bootmenu->setMembershipID($this->membership->getID()); + $bootmenu->setCreated(time()); + $bootmenu->setID($bootmenuID); + + //TODO ACL Is he allowed to edit this? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/forbidden'); + + try { + $this->bootmenuMapper->save($bootmenu); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/error'); + } + + $this->_redirect('/user/bootmenu/index/page/'.$page.'/modifyresult/ok'); + } + + } + + $this->view->editbootmenuForm = $editbootmenuForm; + } + + public function deletebootmenuAction() + { + + //TODO ACL Is he allowed to delete Bootos? + if(false) + $this->_redirect('/user/bootos/index/page/'.$page.'/deleteresult/forbidden'); + + try{ + $bootmenuID = $this->_request->getParam('bootmenuID'); + if (!is_numeric($bootmenuID)) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/deleteresult/forbidden'); + + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuMapper->find($bootmenuID, $bootmenu); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + $this->_redirect('/user/bootmenu/index/page/'.$page.'/deleteresult/forbidden'); + + $this->bootmenuMapper->delete($bootmenu); + + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "
"; + echo "Message: " . $e->getMessage() . "
"; + $this->_redirect('/user/bootmenu/index/page/'.$page.'/deleteresult/error'); + } + $this->_redirect('/user/bootmenu/index/page/'.$page.'/deleteresult/ok'); + } + public function addbootmenuentryAction() { $bootmenuID = $this->_request->getParam('bootmenuID'); @@ -107,84 +246,6 @@ class user_BootmenuController extends Zend_Controller_Action } - public function createbootmenuAction() - { - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["createbootmenu"])){ - $createbootmenuForm = new user_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll())); - } else { - - $createbootmenuForm = new user_Form_BootmenuCreate(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($createbootmenuForm->isValid($_POST)) { - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setMembershipID('1'); - $bootmenu->setCreated(time()); - $bootmenumapper = new Application_Model_BootMenuMapper(); - - try { - $bootmenumapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - - } - $this->_redirect('/user/bootmenu'); - } - } - - $this->view->createbootmenuForm = $createbootmenuForm; - } - - public function editbootmenuAction() - { - $bootmenuID = $this->_request->getParam('bootmenuID'); - $groupmapper = new Application_Model_GroupMapper(); - - if (!isset($_POST["editbootmenu"])){ - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ - $this->_redirect('/bootmenu'); - } else { - $bootmenu = new Application_Model_BootMenu(); - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenumapper->find($bootmenuID, $bootmenu); - - $editbootmenuForm = new user_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll())); - $editbootmenuForm->populate($bootmenu->toArray()); - } - }else{ - $editbootmenuForm = new user_Form_BootmenuEdit(array('grouplist' => $groupmapper->fetchAll()),$_POST); - - if ($editbootmenuForm->isValid($_POST)) { - - $bootmenu = new Application_Model_BootMenu($_POST); - $bootmenu->setMembershipID('1'); - $bootmenu->setCreated(time()); - $bootmenumapper = new Application_Model_BootMenuMapper(); - - $bootmenu->setID($bootmenuID); - - try { - - $bootmenumapper->save($bootmenu); - }catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - } - - $this->_redirect('/user/bootmenu'); - } - - } - - $this->view->editbootmenuForm = $editbootmenuForm; - } - public function editbootmenuentryAction() { $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); @@ -202,7 +263,7 @@ class user_BootmenuController extends Zend_Controller_Action $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - $editbootmenuentryForm = new user_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl())); + $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl())); if(!isset($_POST['configID'])){ $editbootmenuentryForm->populate($bootmenuentry->toArray()); @@ -214,7 +275,7 @@ class user_BootmenuController extends Zend_Controller_Action } } }else{ - $editbootmenuentryForm = new user_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl()),$_POST); + $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl()),$_POST); if ($editbootmenuentryForm->isValid($_POST)) { @@ -263,20 +324,6 @@ class user_BootmenuController extends Zend_Controller_Action $this->_redirect('/user/bootmenu'); } - public function deletebootmenuAction() - { - $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ - $this->_redirect('/user/bootmenu'); - } else { - $bootmenu = new Application_Model_BootMenu(); - $bootmenu->setID($bootmenuID); - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenumapper->delete($bootmenu); - } - $this->_redirect('/user/bootmenu'); - } - private function arrayDiff($a, $b){ foreach($a as $k1 => $i1){ foreach($b as $k2 => $i2){ -- cgit v1.2.3-55-g7522