From 67a08738a5f688f1050b83572a717c727e7d29c3 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Wed, 9 Mar 2011 20:53:33 +0100 Subject: KCL und BootMenuFilter --- application/controllers/BootmenuController.php | 66 +++++++++++++++++--------- 1 file changed, 44 insertions(+), 22 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 93d541d..26dba2d 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -10,26 +10,44 @@ class BootmenuController extends Zend_Controller_Action public function indexAction() { - $bootmenumapper = new Application_Model_BootMenuMapper(); - $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); - $bootosmapper = new Application_Model_BootOsMapper(); - $configmapper = new Application_Model_ConfigMapper(); - $membershipmapper = new Application_Model_MembershipMapper(); - $groupmapper = new Application_Model_GroupMapper(); - $personmapper = new Application_Model_PersonMapper(); - - $this->view->bootosmapper = $bootosmapper; - $this->view->configmapper = $configmapper; - $this->view->bootmenulist = $bootmenumapper->fetchAll(); - - $bootmenuentries = array(); - foreach ($this->view->bootmenulist as $bootmenu){ - $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - } + $bootmenumapper = new Application_Model_BootMenuMapper(); + $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); + $bootosmapper = new Application_Model_BootOsMapper(); + $configmapper = new Application_Model_ConfigMapper(); + $membershipmapper = new Application_Model_MembershipMapper(); + $groupmapper = new Application_Model_GroupMapper(); + $personmapper = new Application_Model_PersonMapper(); + + $this->view->bootosmapper = $bootosmapper; + $this->view->configmapper = $configmapper; + + $bootmenuID = $this->_request->getParam('bootmenuid'); + + if($bootmenuID == "") + { + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + $bootmenuentries = array(); + foreach ($this->view->bootmenulist as $bootmenu){ + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + } + }else{ + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $bootmenuentries = array(); + $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + + $this->view->bootmenulist = array($bootmenu); + + } + $this->view->bootmenuentrylist = $bootmenuentries; + } public function addbootmenuentryAction() @@ -37,13 +55,12 @@ class BootmenuController extends Zend_Controller_Action $bootmenuID = $this->_request->getParam('bootmenuID'); $bootosmapper = new Application_Model_BootOsMapper(); $configmapper = new Application_Model_ConfigMapper(); -// $bootmenuentriesmapper = new Application_Model_BootMenuEntriesMapper(); -// -// $bootoslist = $this->arrayDiff($bootosmapper->fetchAll(), $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID)); if (!isset($_POST["addbootmenuentry"])){ $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll())); $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); + unset($_POST['kcl']); + $addbootmenuentryForm->populate($_POST); } else { $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST); @@ -170,7 +187,12 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll())); - $editbootmenuentryForm->populate($bootmenuentry->toArray()); + if(!isset($_POST['kcl'])) + $editbootmenuentryForm->populate($bootmenuentry->toArray()); + else + unset($_POST['bootmenuID']); + $editbootmenuentryForm->populate($_POST); + } }else{ $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST); -- cgit v1.2.3-55-g7522 From 98b708fd4b640cccff3e24a3d08edbd673a9f8e9 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Thu, 10 Mar 2011 10:56:48 +0100 Subject: default kcl und config hinzugefuegt --- application/controllers/BootmenuController.php | 12 ++++++++---- application/forms/BootmenuEntriesAdd.php | 9 ++++++--- application/forms/BootmenuEntriesEdit.php | 8 ++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 26dba2d..e2f4a2b 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -60,6 +60,7 @@ class BootmenuController extends Zend_Controller_Action $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll())); $addbootmenuentryForm->populate(array('order' => $this->_request->getParam('maxorder'))); unset($_POST['kcl']); + unset($_POST['configID']); $addbootmenuentryForm->populate($_POST); } else { @@ -154,6 +155,7 @@ class BootmenuController extends Zend_Controller_Action $bootmenu->setID($bootmenuID); try { + $bootmenumapper->save($bootmenu); }catch(Zend_Exception $e) { @@ -187,12 +189,14 @@ class BootmenuController extends Zend_Controller_Action $bootmenuentrymapper->find($bootmenuentryID, $bootmenuentry); $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder' => $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll())); - if(!isset($_POST['kcl'])) + if(!isset($_POST['kcl'])){ $editbootmenuentryForm->populate($bootmenuentry->toArray()); - else - unset($_POST['bootmenuID']); + } + else{ + unset($_POST['kcl']); + unset($_POST['configID']); $editbootmenuentryForm->populate($_POST); - + } } }else{ $editbootmenuentryForm = new Application_Form_BootmenuEntriesEdit(array('bootoslist'=>$bootosmapper->fetchAll(), 'maxorder'=> $this->_request->getParam('maxorder'), 'configlist'=>$configmapper->fetchAll()),$_POST); diff --git a/application/forms/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php index 2731f60..4aea750 100644 --- a/application/forms/BootmenuEntriesAdd.php +++ b/application/forms/BootmenuEntriesAdd.php @@ -45,7 +45,6 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form $bootosfield ->setLabel('BootOs:'); $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();"); - if(count($this->bootoslist)>0){ foreach($this->bootoslist as $bootos => $b){ $bootosfield->addMultiOption($b->getID(), $b->getTitle()); @@ -68,14 +67,18 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form )); + $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); $configfield = $this->createElement('select','configID'); - $configfield ->setLabel('Config:'); + $configfield->setLabel('Config:'); + $configfield->addMultiOption($defaultconfigid, 'default'); if(count($this->configlist)>0){ foreach($this->configlist as $config => $c){ - $configfield->addMultiOption($c->getID(), $c->getTitle()); + if($c->getID() != $defaultconfigid) + $configfield->addMultiOption($c->getID(), $c->getTitle()); } } + $configfield->setRegisterInArrayValidator(false); $this->addElement($configfield); diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php index 8eb4b95..1548129 100644 --- a/application/forms/BootmenuEntriesEdit.php +++ b/application/forms/BootmenuEntriesEdit.php @@ -67,12 +67,16 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl() )); + $defaultconfigid = $this->bootoslist[$_POST['bootosID']]->getConfigID(); $configfield = $this->createElement('select','configID'); - $configfield ->setLabel('Config:'); + $configfield->setLabel('Config:'); + $configfield->addMultiOption($defaultconfigid, 'default'); + if(count($this->configlist)>0){ foreach($this->configlist as $config => $c){ - $configfield->addMultiOption($c->getID(), $c->getTitle()); + if($c->getID() != $defaultconfigid) + $configfield->addMultiOption($c->getID(), $c->getTitle()); } } $configfield->setRegisterInArrayValidator(false); -- cgit v1.2.3-55-g7522 From 7c35f7c3005131f8351404c78489820d44bef5bb Mon Sep 17 00:00:00 2001 From: michael pereira Date: Thu, 10 Mar 2011 16:16:38 +0100 Subject: BootMenu an preboot JSON --- application/controllers/BootmenuController.php | 86 +++++++++++++++++++------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index e2f4a2b..8cda756 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -22,32 +22,72 @@ class BootmenuController extends Zend_Controller_Action $this->view->configmapper = $configmapper; $bootmenuID = $this->_request->getParam('bootmenuid'); + $preboot = $this->_request->getParam('preboot'); - if($bootmenuID == "") - { - $this->view->bootmenulist = $bootmenumapper->fetchAll(); - $bootmenuentries = array(); - foreach ($this->view->bootmenulist as $bootmenu){ - $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - } - }else{ - $bootmenu = new Application_Model_BootMenu(); - $bootmenumapper->find($bootmenuID, $bootmenu); - - $bootmenuentries = array(); - $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + if($preboot=="") + { + if($bootmenuID == "") + { + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + $bootmenuentries = array(); + foreach ($this->view->bootmenulist as $bootmenu){ + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + } + }else{ + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $bootmenuentries = array(); + $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + + $this->view->bootmenulist = array($bootmenu); + + } + + $this->view->bootmenuentrylist = $bootmenuentries; + + }else{ + $this->_helper->layout->disableLayout(); + $this->_helper->viewRenderer->setNoRender(); + + if($bootmenuID == "") + { + $this->view->bootmenulist = $bootmenumapper->fetchAll(); + $bootmenuentries = array(); + foreach ($this->view->bootmenulist as $bootmenu){ + $bootmenuentries[$bootmenu->getID()] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenu->getID()); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + } + }else{ + $bootmenu = new Application_Model_BootMenu(); + $bootmenumapper->find($bootmenuID, $bootmenu); + + $bootmenuentries = array(); + $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); + $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); + $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); + + $this->view->bootmenulist = array($bootmenu); - $this->view->bootmenulist = array($bootmenu); - - } + } + + $this->view->bootmenuentrylist = $bootmenuentries; + - - $this->view->bootmenuentrylist = $bootmenuentries; - + echo json_encode( + array( + 'bootosmapper' => $this->view->bootosmapper, + 'configmapper' => $this->view->configmapper, + 'bootmenulist' => $this->view->bootmenulist, + 'bootmenuentrylist' => $this->view->bootmenuentrylist + ) + ); + } } public function addbootmenuentryAction() -- cgit v1.2.3-55-g7522 From 6af55d49f3984d086872860832d0d296a2591647 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Thu, 10 Mar 2011 16:40:22 +0100 Subject: Bootmenu auf preboot JSON --- application/controllers/BootmenuController.php | 32 ++++++++++++-------------- application/models/BootMenuEntriesMapper.php | 18 +++++++++++++++ 2 files changed, 33 insertions(+), 17 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 8cda756..9a212d6 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -66,27 +66,25 @@ class BootmenuController extends Zend_Controller_Action }else{ $bootmenu = new Application_Model_BootMenu(); $bootmenumapper->find($bootmenuID, $bootmenu); + + $cc['title'] = $bootmenu->getTitle(); $bootmenuentries = array(); - $bootmenuentries[$bootmenuID] = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); - $bootmenu->setGroupID("[".$bootmenu->getGroupID()."] ".$groupmapper->find($bootmenu->getGroupID())->getTitle()); - $bootmenu->setMembershipID("[".$bootmenu->getMembershipID()."] ".$personmapper->find($membershipmapper->find($bootmenu->getMembershipID())->getPersonID())->getFirstname()); - - $this->view->bootmenulist = array($bootmenu); - + $bootmenuentries = $bootmenuentriesmapper->findBy('bootmenuID',$bootmenuID); + + foreach($bootmenuentries as $bootmenuentry){ + $ar = array(); + $ar['title'] = $bootmenu->getTitle(); + $ar['id'] = $bootmenu->getID(); + $cc['data'][] = $ar; + } + + echo json_encode($cc); + + // print_a($cc); + } - $this->view->bootmenuentrylist = $bootmenuentries; - - - echo json_encode( - array( - 'bootosmapper' => $this->view->bootosmapper, - 'configmapper' => $this->view->configmapper, - 'bootmenulist' => $this->view->bootmenulist, - 'bootmenuentrylist' => $this->view->bootmenuentrylist - ) - ); } } diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index 7a2da59..a0a5309 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -30,6 +30,24 @@ class Application_Model_BootMenuEntriesMapper echo "Error message 2: " . $e->getMessage() . "\n"; } } + + public function findByArray($criteria, $value) + { + try{ + $db = Zend_Db_Table::getDefaultAdapter(); + $select = $this->getDbTable()->select() + ->from($this->_dbTable) + ->where($criteria . ' = ?', $value) + ->order('order'); + $stmt = $select->query(); + $result = $stmt->fetchAll(); + + return $result; + + }catch (Zend_Exception $e) { + echo "Error message 2: " . $e->getMessage() . "\n"; + } + } public function setDbTable($dbTable) { -- cgit v1.2.3-55-g7522 From fa86fafd4bb81d921f418f100b5097c63ffce490 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Thu, 10 Mar 2011 16:51:45 +0100 Subject: Bootmenu auf preboot JSON --- application/controllers/BootmenuController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index 9a212d6..abb046e 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -74,14 +74,14 @@ class BootmenuController extends Zend_Controller_Action foreach($bootmenuentries as $bootmenuentry){ $ar = array(); - $ar['title'] = $bootmenu->getTitle(); - $ar['id'] = $bootmenu->getID(); + $ar['title'] = $bootmenuentry->getTitle(); + $ar['id'] = $bootmenuentry->getID(); $cc['data'][] = $ar; } echo json_encode($cc); - // print_a($cc); + print_a($cc); } -- cgit v1.2.3-55-g7522 From d34e6d303cb5c5d9b16de1c7076be38ef1feb6e8 Mon Sep 17 00:00:00 2001 From: michael pereira Date: Thu, 10 Mar 2011 16:52:36 +0100 Subject: Bootmenu auf preboot JSON --- application/controllers/BootmenuController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'application/controllers/BootmenuController.php') diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index abb046e..641b547 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -81,7 +81,7 @@ class BootmenuController extends Zend_Controller_Action echo json_encode($cc); - print_a($cc); + //print_a($cc); } -- cgit v1.2.3-55-g7522