summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/BootmenuController.php66
-rw-r--r--application/forms/BootmenuEntriesAdd.php13
-rw-r--r--application/forms/BootmenuEntriesEdit.php11
-rw-r--r--application/models/BootOsMapper.php4
4 files changed, 68 insertions, 26 deletions
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);
diff --git a/application/forms/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php
index 0f2109e..2731f60 100644
--- a/application/forms/BootmenuEntriesAdd.php
+++ b/application/forms/BootmenuEntriesAdd.php
@@ -8,7 +8,6 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
public function setBootoslist($bootoslist){
$this->bootoslist = $bootoslist;
-
}
public function setMaxorder($maxorder){
@@ -21,9 +20,15 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
}
-
+
public function init()
{
+
+ if(!isset($_POST['bootosID'])){
+ $firstbootos = array_slice($this->bootoslist,0,1);
+ $_POST['bootosID'] = $firstbootos[0]->getID();
+ }
+
$this->setName("BootMenuEntryAdd");
$this->setMethod('post');
@@ -38,6 +43,8 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
$bootosfield = $this->createElement('select','bootosID');
$bootosfield ->setLabel('BootOs:');
+ $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
+
if(count($this->bootoslist)>0){
foreach($this->bootoslist as $bootos => $b){
@@ -45,6 +52,7 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
}
}
$bootosfield->setRegisterInArrayValidator(false);
+
$this->addElement($bootosfield);
$this->addElement('textarea', 'kcl', array(
@@ -56,6 +64,7 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form
'cols' => 50,
'rows' => 5,
'label' => 'KCL:',
+ 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl()
));
diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php
index 7fd97fe..8eb4b95 100644
--- a/application/forms/BootmenuEntriesEdit.php
+++ b/application/forms/BootmenuEntriesEdit.php
@@ -24,6 +24,12 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
public function init()
{
+
+ if(!isset($_POST['bootosID'])){
+ $firstbootos = array_slice($this->bootoslist,0,1);
+ $_POST['bootosID'] = $firstbootos[0]->getID();
+ }
+
$this->setName("BootMenuEntryAdd");
$this->setMethod('post');
@@ -37,7 +43,9 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
));
$bootosfield = $this->createElement('select','bootosID');
- $bootosfield ->setLabel('BootOs:');
+ $bootosfield->setLabel('BootOs:');
+ $bootosfield->setAttrib('onChange', "document.getElementById('BootMenuEntryAdd').submit();");
+
if(count($this->bootoslist)>0){
foreach($this->bootoslist as $bootos => $b){
@@ -56,6 +64,7 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form
'cols' => 50,
'rows' => 5,
'label' => 'KCL:',
+ 'value' => $this->bootoslist[$_POST['bootosID']]->getDefaultkcl()
));
$configfield = $this->createElement('select','configID');
diff --git a/application/models/BootOsMapper.php b/application/models/BootOsMapper.php
index a6e9a7f..66de08d 100644
--- a/application/models/BootOsMapper.php
+++ b/application/models/BootOsMapper.php
@@ -14,7 +14,9 @@ class Application_Model_BootOsMapper
->where($criteria . ' = ?', $value);
$stmt = $select->query();
$result = $stmt->fetchAll();
+
return $result;
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
@@ -87,7 +89,7 @@ class Application_Model_BootOsMapper
$entry->setID($row->bootosID)->setConfigID($row->configID)->setGroupID($row->groupID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath_init($row->path_init)->setPath_kernel($row->path_kernel)->setDefaultkcl($row->defaultkcl)->setCreated($row->created)->setDescription($row->description)->setExpires($row->expires)->setPublic($row->public);
- $entries[] = $entry;
+ $entries[$row->bootosID] = $entry;
}
return $entries;
}