diff options
| author | michael pereira | 2011-04-01 16:46:47 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-01 16:46:47 +0200 |
| commit | 00a1bcc61d4b5c1e28b14c018332a934100e227f (patch) | |
| tree | 80ab563e840cd6305f8bc6974e89f57352badef1 /application/modules | |
| parent | Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2 (diff) | |
| download | pbs2-00a1bcc61d4b5c1e28b14c018332a934100e227f.tar.gz pbs2-00a1bcc61d4b5c1e28b14c018332a934100e227f.tar.xz pbs2-00a1bcc61d4b5c1e28b14c018332a934100e227f.zip | |
Bootmenu & BootOs Controller
Diffstat (limited to 'application/modules')
| -rw-r--r-- | application/modules/user/controllers/BootmenuController.php | 235 | ||||
| -rw-r--r-- | application/modules/user/controllers/BootosController.php | 15 |
2 files changed, 148 insertions, 102 deletions
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) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $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) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $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) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $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) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - - } - $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) . "<br/>"; - echo "Message: " . $e->getMessage() . "<br/>"; - } - - $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){ diff --git a/application/modules/user/controllers/BootosController.php b/application/modules/user/controllers/BootosController.php index eae0dcf..0a1f41f 100644 --- a/application/modules/user/controllers/BootosController.php +++ b/application/modules/user/controllers/BootosController.php @@ -265,14 +265,14 @@ class user_BootosController extends Zend_Controller_Action $configMapper = new Application_Model_ConfigMapper(); $configlist = $configMapper->findBy("groupID", $groupID); + $bootos = new Application_Model_BootOs(); + $bootos = $this->bootosMapper->find($bootosID); + + if($this->membership->getGroupID() != $bootos->getGroupID()) + $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); + if (!isset($_POST["editbootos"])){ - - $bootos = new Application_Model_BootOs(); - $bootos = $this->bootosMapper->find($bootosID); - if($this->membership->getGroupID() != $bootos->getGroupID()) - $this->_redirect('/user/bootos/index/page/'.$page.'/modifyresult/forbidden'); - $bootosForm = new user_Form_Bootos(array('action' => 'editbootos', 'groupdepth' => $childgroups, 'configlist'=>$configlist, 'rights' => 'meta')); $bootosForm->populate($bootos->toArray()); @@ -281,8 +281,7 @@ class user_BootosController extends Zend_Controller_Action if ($bootosForm->isValid($_POST)) { - $bootosold = new Application_Model_BootOs(); - $this->bootosMapper->find($bootosID, $bootosold); + $bootosold = $bootos; $bootos = new Application_Model_BootOs($_POST); $bootos->setMembershipID($this->membership->getID()); |
