diff options
| author | michael pereira | 2011-04-04 03:46:09 +0200 |
|---|---|---|
| committer | michael pereira | 2011-04-04 03:46:09 +0200 |
| commit | 1898f0d3037d2f635570a4e43f317f4c90668a76 (patch) | |
| tree | 2416d2e5721cc3e1f5890132f0538e33575fe5c7 /application/modules/user/controllers | |
| parent | Json Anzeige für getRessources zu Notifier hinzugefügt (diff) | |
| download | pbs2-1898f0d3037d2f635570a4e43f317f4c90668a76.tar.gz pbs2-1898f0d3037d2f635570a4e43f317f4c90668a76.tar.xz pbs2-1898f0d3037d2f635570a4e43f317f4c90668a76.zip | |
Bootmenu im User Controller fertig
Diffstat (limited to 'application/modules/user/controllers')
| -rw-r--r-- | application/modules/user/controllers/BootmenuController.php | 225 |
1 files changed, 149 insertions, 76 deletions
diff --git a/application/modules/user/controllers/BootmenuController.php b/application/modules/user/controllers/BootmenuController.php index ea8cfd3..f20c093 100644 --- a/application/modules/user/controllers/BootmenuController.php +++ b/application/modules/user/controllers/BootmenuController.php @@ -4,7 +4,7 @@ class user_BootmenuController extends Zend_Controller_Action { protected $bootmenuMapper; - protected $bootmenuentriesMapper; + protected $bootmenuentryMapper; protected $membershipMapper; protected $membership; protected $page; @@ -18,6 +18,8 @@ class user_BootmenuController extends Zend_Controller_Action } $this->bootmenuMapper = new Application_Model_BootMenuMapper(); + $this->bootmenuentryMapper = new Application_Model_BootMenuEntriesMapper(); + $this->membershipMapper = new Application_Model_MembershipMapper(); $this->membership = new Application_Model_Membership(); @@ -48,6 +50,12 @@ class user_BootmenuController extends Zend_Controller_Action $pbsNotifier = new Pbs_Notifier(); $this->view->notification = $pbsNotifier->notify('modify',$result); } + $result = $this->_request->getParam('json'); + if($result != ""){ + $pbsNotifier = new Pbs_Notifier(); + $this->view->notification = $pbsNotifier->notify('json',$result); + } + //TODO ACL Darf er BootOsMenu sehen? if(false) @@ -194,9 +202,9 @@ class user_BootmenuController extends Zend_Controller_Action public function deletebootmenuAction() { - //TODO ACL Is he allowed to delete Bootos? + //TODO ACL Is he allowed to delete Bootmenu? if(false) - $this->_redirect('/user/bootos/index/page/'.$this->page.'/deleteresult/forbidden'); + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); try{ $bootmenuID = $this->_request->getParam('bootmenuID'); @@ -221,140 +229,205 @@ class user_BootmenuController extends Zend_Controller_Action public function addbootmenuentryAction() { + + //TODO ACL Darf er BootMenuEntries erstellen? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/forbidden'); + $bootmenuID = $this->_request->getParam('bootmenuID'); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); - + $maxorder = $this->_request->getParam('maxorder'); + + if (!is_numeric($bootmenuID) || !is_numeric($maxorder)) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error'); + + $bootosMapper = new Application_Model_BootOsMapper(); + $configMapper = new Application_Model_ConfigMapper(); + $bootoslist = $bootosMapper->fetchAll(); + $configlist = $configMapper->fetchAll(); + if (!isset($_POST["addbootmenuentry"])){ - $addbootmenuentryForm = new user_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(),'page' => $this->page)); - $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); + + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist'=> $bootoslist, + 'maxorder'=> $maxorder, + 'configlist'=> $configlist, + 'page' => $this->page, + 'action' => 'addbootmenuentry', + 'rights' => 'meta' + )); + + $bootmenuentryForm->populate(array('order' => $maxorder)); unset($_POST['kcl']); unset($_POST['configID']); - $addbootmenuentryForm->populate($_POST); + $bootmenuentryForm->populate($_POST); + } else { - $addbootmenuentryForm = new user_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(),'page' => $this->page),$_POST); + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist'=>$bootoslist, + 'maxorder'=> $maxorder, + 'configlist'=>$configlist, + 'page' => $this->page, + 'action' => 'addbootmenuentry', + 'rights' => 'meta'),$_POST); - if ($addbootmenuentryForm->isValid($_POST)) { + if ($bootmenuentryForm->isValid($_POST)) { $bootmenuentry = new Application_Model_BootMenuEntries($_POST); $bootmenuentry->setBootmenuID($bootmenuID); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - try { - if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')){ + if($bootmenuentry->getOrder() < $maxorder){ $bootmenuentry->setOrder($bootmenuentry->getOrder()); - $bootmenuentrymapper->order($bootmenuentry); + $this->bootmenuentryMapper->order($bootmenuentry); } //print_a($bootmenuentry); - $bootmenuentrymapper->save($bootmenuentry); + $this->bootmenuentryMapper->save($bootmenuentry); }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/error'); } - $this->_redirect('/user/bootmenu'); - } + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/addresult/ok'); + } } - $this->view->addbootmenuentryForm = $addbootmenuentryForm; + $this->view->bootmenuentryForm = $bootmenuentryForm; } public function editbootmenuentryAction() { - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - $bootmenuID = $this->_request->getParam('bootmenuID'); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); + //TODO ACL Is he allowed to edit BootMenus? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); + + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + $maxorder = $this->_request->getParam('maxorder'); + $oldorder = $this->_request->getParam('oldorder'); + if (!is_numeric($bootmenuentryID) || !is_numeric($maxorder) || !is_numeric($oldorder)) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error'); + + $bootosMapper = new Application_Model_BootOsMapper(); + $configMapper = new Application_Model_ConfigMapper(); + $bootoslist = $bootosMapper->fetchAll(); + $configlist = $configMapper->fetchAll(); + $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); + $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); if (!isset($_POST["editbootmenuentry"])){ - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ - $this->_redirect('/user/bootmenu'); - } else { - - $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - - $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl(),'page' => $this->page)); - - if(!isset($_POST['configID'])){ - $editbootmenuentryForm->populate($bootmenuentry->toArray()); - } - else{ - unset($_POST['kcl']); - unset($_POST['configID']); - $editbootmenuentryForm->populate($_POST); - } + + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist'=> $bootoslist, + 'maxorder'=> $maxorder-1, + 'configlist'=> $configlist, + 'kcl' => $bootmenuentry->getKcl(), + 'page' => $this->page, + 'action' => 'editbootmenuentry', + 'rights' => 'all' + )); + + if(!isset($_POST['configID'])){ + $bootmenuentryForm->populate($bootmenuentry->toArray()); + } + else{ + unset($_POST['kcl']); + unset($_POST['configID']); + $bootmenuentryForm->populate($_POST); } + }else{ - $editbootmenuentryForm = new user_Form_BootmenuEntries(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll(), 'kcl' => $bootmenuentry->getKcl(),'page' => $this->page),$_POST); + $bootmenuentryForm = new user_Form_BootmenuEntries(array( + 'bootoslist'=> $bootoslist, + 'maxorder'=> $maxorder-1, + 'configlist'=> $configlist, + 'kcl' => $bootmenuentry->getKcl(), + 'page' => $this->page, + 'action' => 'editbootmenuentry', + 'rights' => 'all'),$_POST); - if ($editbootmenuentryForm->isValid($_POST)) { + if ($bootmenuentryForm->isValid($_POST)) { - $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentryold= $bootmenuentry; - $bootmenuentry->setBootmenuID($bootmenuID); + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentry->setBootmenuID($bootmenu->getID()); $bootmenuentry->setID($bootmenuentryID); - - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - + + if( $bootmenuentryold->getBootosID() != $bootmenuentry->getBootosID() || + $bootmenuentryold->getConfigID() != $bootmenuentry->getConfigID() || + $bootmenuentryold->getKcl() != $bootmenuentry->getKcl() || + $bootmenuentryold->getKclappend() != $bootmenuentry->getKclappend()){ + //TODO ACL Is he allowed to edit this? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/forbidden'); + } + try { - if($bootmenuentry->getOrder() < $this->_request->getParam('oldorder')) - $bootmenuentrymapper->orderbefore($bootmenuentry, $this->_request->getParam('oldorder')); + if($bootmenuentry->getOrder() < $oldorder) + $this->bootmenuentryMapper->orderbefore($bootmenuentry, $oldorder); else - $bootmenuentrymapper->orderafter($bootmenuentry, $this->_request->getParam('oldorder')); + $this->bootmenuentryMapper->orderafter($bootmenuentry, $oldorder); - $bootmenuentrymapper->save($bootmenuentry); + $this->bootmenuentryMapper->save($bootmenuentry); }catch(Zend_Exception $e) { echo "Caught exception: " . get_class($e) . "<br/>"; echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/error'); + } - $this->_redirect('/user/bootmenu'); + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/modifyresult/ok'); } } - $this->view->editbootmenuentryForm = $editbootmenuentryForm; + $this->view->bootmenuentryForm = $bootmenuentryForm; } public function removebootmenuentryAction() { - $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); - if (!isset($bootmenuentryID) || !is_numeric($bootmenuentryID)){ - $this->_redirect('/bootmenu'); - } else { - $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - $bootmenuentrymapper->delete($bootmenuentry); - $bootmenuentrymapper->orderremove($bootmenuentry); + //TODO ACL Is he allowed to delete Bootos? + if(false) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); + + try{ + $bootmenuentryID = $this->_request->getParam('bootmenuentryID'); + if (!is_numeric($bootmenuentryID)) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); + + $bootmenuentry = new Application_Model_BootMenuEntries(); + $bootmenu = new Application_Model_BootMenu(); + $this->bootmenuentryMapper->find($bootmenuentryID, $bootmenuentry); + $this->bootmenuMapper->find($bootmenuentry->getBootmenuID(), $bootmenu); + + if($this->membership->getGroupID() != $bootmenu->getGroupID()) + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/forbidden'); + + $this->bootmenuentryMapper->delete($bootmenuentry); + $this->bootmenuentryMapper->orderremove($bootmenuentry); + + }catch(Zend_Exception $e){ + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/error'); } - $this->_redirect('/user/bootmenu'); + $this->_redirect('/user/bootmenu/index/page/'.$this->page.'/deleteresult/ok'); } - private function arrayDiff($a, $b){ - foreach($a as $k1 => $i1){ - foreach($b as $k2 => $i2){ - if($i1->getID() == $i2->getBootosID()){ - unset($a[$k1]); - } - } - } - return $a; - } - - } |
