From 08e59ba66fd7281f74d053461043855f06aa4e01 Mon Sep 17 00:00:00 2001 From: Michael Neves Date: Thu, 26 Jan 2012 17:58:53 +0100 Subject: Preboot add/edit --- .../modules/user/controllers/PrebootController.php | 13 +++++++++++++ application/modules/user/forms/Bootiso.php | 20 ++++++++++---------- application/modules/user/forms/Preboot.php | 12 ++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/application/modules/user/controllers/PrebootController.php b/application/modules/user/controllers/PrebootController.php index 4f83820..a22ae18 100644 --- a/application/modules/user/controllers/PrebootController.php +++ b/application/modules/user/controllers/PrebootController.php @@ -104,14 +104,19 @@ class User_PrebootController extends Zend_Controller_Action { if(!Pbs_Acl::checkRight('prc')) { $this->_redirect('/user/preboot/index/page/'.$this->page.'/addresult/forbidden'); } + $preboottypeMapper = new Application_Model_PreBootTypeMapper(); + $preboottype = $preboottypeMapper->fetchAll(); + if (!isset($_POST["createpreboot"])) { $prebootForm = new user_Form_Preboot(array( 'action' => 'createpreboot', + 'preboottype' => $preboottype, 'page' => $this->page)); } else { $prebootForm = new user_Form_Preboot(array( 'action' => 'createpreboot', + 'preboottype' => $preboottype, 'page' => $this->page), $_POST); if ($prebootForm->isValid($_POST)) { @@ -171,10 +176,17 @@ class User_PrebootController extends Zend_Controller_Action { if($this->membership->getGroupID() != $preboot->getGroupID()) { $this->_redirect('/user/preboot/index/page/'.$this->page.'/modifyresult/forbidden'); } + $preboottypeMapper = new Application_Model_PreBootTypeMapper(); + $preboottype = $preboottypeMapper->fetchAll(); + if (!isset($_POST["editpreboot"])) { + if(!isset($_POST['preboottypeID'])) { + $_POST['preboottypeID'] = $preboot->getPreboottypeID(); + } $prebootForm = new user_Form_Preboot(array( 'action' => 'editpreboot', + 'preboottype' => $preboottype, 'page' => $this->page)); $prebootForm->populate($preboot->toArray()); @@ -182,6 +194,7 @@ class User_PrebootController extends Zend_Controller_Action { $prebootForm = new user_Form_Preboot(array( 'action' => 'editpreboot', + 'preboottype' => $preboottype, 'page' => $this->page), $_POST); if ($prebootForm->isValid($_POST)) { diff --git a/application/modules/user/forms/Bootiso.php b/application/modules/user/forms/Bootiso.php index ba19437..a56f360 100644 --- a/application/modules/user/forms/Bootiso.php +++ b/application/modules/user/forms/Bootiso.php @@ -16,6 +16,7 @@ class user_Form_Bootiso extends Zend_Form { private $groupdepth; private $action; private $page; + private $preboottype; public function setAction($action) { $this->action = $action; @@ -63,17 +64,16 @@ class user_Form_Bootiso extends Zend_Form { 'label' => 'Description:', )); - $prebootfield = $this->createElement('select', 'prebootID'); - $prebootfield->setLabel('Preboot:'); - $prebootfield->setAttrib('readOnly', $meta); - - if(count($this->prebootlist) > 0) { - foreach($this->prebootlist as $preboot => $p) { - $prebootfield->addMultiOption($p->getID(), $p->getTitle()); - } + $preboottypefield = $this->createElement('select', 'preboottypeID'); + $preboottypefield->setLabel('Type:'); + $preboottypefield->setAttrib('readOnly', $meta); + $preboottypefield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); + $preboottypefield->setValue($_POST['preboottypeID']); + foreach($this->preboottype as $k => $pt) { + $preboottypefield->addMultiOption($pt->getID(), $pt->getName()); } - $prebootfield->setRegisterInArrayValidator(false); - $this->addElement($prebootfield); + + $this->addElement($preboottypefield); $serial = time(); for($i = 2; $i < 14; $i += 3) diff --git a/application/modules/user/forms/Preboot.php b/application/modules/user/forms/Preboot.php index bb90f65..cff3e26 100644 --- a/application/modules/user/forms/Preboot.php +++ b/application/modules/user/forms/Preboot.php @@ -14,6 +14,7 @@ class user_Form_Preboot extends Zend_Form { private $action; private $page; + private $preboottype; public function setAction($action) { $this->action = $action; @@ -58,6 +59,17 @@ class user_Form_Preboot extends Zend_Form { 'label' => 'Description:', )); + $preboottypefield = $this->createElement('select', 'preboottypeID'); + $preboottypefield->setLabel('Type:'); + $preboottypefield->setAttrib('readOnly', $meta); + $preboottypefield->setAttrib('onChange', "document.getElementById('".$this->action."').submit();"); + $preboottypefield->setValue($_POST['preboottypeID']); + foreach($this->preboottype as $k => $pt) { + $preboottypefield->addMultiOption($pt->getID(), $pt->getName()); + } + + $this->addElement($preboottypefield); + $serial = time(); for($i = 2; $i < 14; $i += 3) { -- cgit v1.2.3-55-g7522