diff options
Diffstat (limited to 'application/controllers/BootmenuController.php')
| -rw-r--r-- | application/controllers/BootmenuController.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 1b4bbfb..b7909b4 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -12,9 +12,10 @@ class BootmenuController extends Zend_Controller_Action { $bootmenumapper = new Application_Model_BootMenuMapper(); $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); - + $bootosmapper = new Application_Model_BootOsMapper(); + $this->view->bootmenulist = $bootmenumapper->fetchAll(); - + $bootmenuentries = array(); foreach ($this->view->bootmenulist as $bootmenu){ $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); @@ -31,8 +32,8 @@ class BootmenuController extends Zend_Controller_Action // $bootoslist = $this->arrayDiff($bootosmapper->fetchAll(), $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID)); if (!isset($_POST["addbootmenuentry"])){ - $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll())); - + $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'))); + $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); } else { $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd($_POST); @@ -41,9 +42,14 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentry = new Application_Model_BootMenuEntries($_POST); $bootmenuentry->setBootmenuID($bootmenuID); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); - + try { + if($bootmenuentry->getOrder() < $this->_request->getParam('maxorder')){ + $bootmenuentry->setOrder($bootmenuentry->getOrder()); + $bootmenuentrymapper->order($bootmenuentry); + } $bootmenuentrymapper->save($bootmenuentry); }catch(Zend_Exception $e) { @@ -92,7 +98,6 @@ class BootmenuController extends Zend_Controller_Action public function editbootmenuAction() { $bootmenuID = $this->_request->getParam('bootmenuID'); - if (!isset($_POST["editbootmenu"])){ $bootmenuID = $this->_request->getParam('bootmenuID'); if (!isset($bootmenuID) || !is_numeric($bootmenuID)){ @@ -148,7 +153,7 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); - $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll())); + $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'))); $editbootmenuentryForm->populate($bootmenuentry->toArray()); } @@ -188,9 +193,10 @@ class BootmenuController extends Zend_Controller_Action $this->_redirect('/bootmenu'); } else { $bootmenuentry = new Application_Model_BootMenuEntries(); - $bootmenuentry->setID($bootmenuentryID); $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); $bootmenuentrymapper->delete($bootmenuentry); + $bootmenuentrymapper->orderremove($bootmenuentry); } $this->_redirect('/bootmenu'); } |
