diff options
| author | michael pereira | 2011-03-07 04:56:52 +0100 |
|---|---|---|
| committer | michael pereira | 2011-03-07 04:56:52 +0100 |
| commit | c2e98ec0e67d0f0221ad05981c32510781f8ce4b (patch) | |
| tree | 392515126ebca6b6c7d93d8b05a535e76a8c90c1 | |
| parent | BootIso Interface fertig (diff) | |
| download | pbs2-c2e98ec0e67d0f0221ad05981c32510781f8ce4b.tar.gz pbs2-c2e98ec0e67d0f0221ad05981c32510781f8ce4b.tar.xz pbs2-c2e98ec0e67d0f0221ad05981c32510781f8ce4b.zip | |
BootMenuEntries angelegt
| -rw-r--r-- | application/controllers/BootmenuController.php | 26 | ||||
| -rw-r--r-- | application/forms/BootmenuEntriesAdd.php | 64 | ||||
| -rw-r--r-- | application/forms/BootmenuEntriesEdit.php | 65 | ||||
| -rw-r--r-- | application/models/BootMenuEntries.php | 10 | ||||
| -rw-r--r-- | application/models/BootMenuEntriesMapper.php | 14 | ||||
| -rw-r--r-- | application/views/scripts/bootmenu/addbootmenuentry.phtml | 5 | ||||
| -rw-r--r-- | application/views/scripts/bootmenu/editbootmenuentry.phtml | 5 | ||||
| -rw-r--r-- | application/views/scripts/bootmenu/index.phtml | 8 | ||||
| -rw-r--r-- | pbs.sql | 38 |
9 files changed, 190 insertions, 45 deletions
diff --git a/application/controllers/BootmenuController.php b/application/controllers/BootmenuController.php index e20ef23..1dfa641 100644 --- a/application/controllers/BootmenuController.php +++ b/application/controllers/BootmenuController.php @@ -16,7 +16,31 @@ class BootmenuController extends Zend_Controller_Action public function addbootmenuentryAction() { - // action body + if (!isset($_POST["addbootmenuentry"])){ + $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd(); + } else { + + $addbootmenuentryForm = new Application_Form_BootmenuEntriesAdd($_POST); + + if ($addbootmenuentryForm->isValid($_POST)) { + + $bootmenuentry = new Application_Model_BootMenuEntries($_POST); + $bootmenuentrymapper = new Application_Model_BootMenuEntriesMapper(); + + try { + $bootmenuentrymapper->save($bootmenuentry); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + + } + $this->_redirect('/bootmenu'); + } + } + + $this->view->addbootmenuentryForm = $addbootmenuentryForm; + } public function createbootmenuAction() diff --git a/application/forms/BootmenuEntriesAdd.php b/application/forms/BootmenuEntriesAdd.php index 56de36d..0577ede 100644 --- a/application/forms/BootmenuEntriesAdd.php +++ b/application/forms/BootmenuEntriesAdd.php @@ -3,10 +3,70 @@ class Application_Form_BootmenuEntriesAdd extends Zend_Form { - public function init() + public function init() { - /* Form Elements & Other Definitions Here ... */ + $this->setName("BootMenuEntryAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('text', 'bootosID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'BootOsID:', + 'value' => '1', + )); + + $this->addElement('text', 'kcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'KCL:', + )); + + $this->addElement('text', 'configID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'ConfigID:', + 'value' => '1', + )); + + $this->addElement('text', 'order', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'order:', + )); + + $this->addElement('submit', 'addbootmenuentry', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Add Bootmenuentry', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootmenu"' + )); + } + } diff --git a/application/forms/BootmenuEntriesEdit.php b/application/forms/BootmenuEntriesEdit.php index a63621d..e69dc8b 100644 --- a/application/forms/BootmenuEntriesEdit.php +++ b/application/forms/BootmenuEntriesEdit.php @@ -3,11 +3,70 @@ class Application_Form_BootmenuEntriesEdit extends Zend_Form { - public function init() + public function init() { - /* Form Elements & Other Definitions Here ... */ - } + $this->setName("BootMenuEntryAdd"); + $this->setMethod('post'); + + $this->addElement('text', 'title', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Title:', + )); + + $this->addElement('text', 'bootosID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'BootOsID:', + 'value' => '1', + )); + + $this->addElement('text', 'kcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'KCL:', + )); + + $this->addElement('text', 'configID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'ConfigID:', + 'value' => '1', + )); + + $this->addElement('text', 'order', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'order:', + )); + + $this->addElement('submit', 'editbootmenuentry', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit Bootmenuentry', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootmenu"' + )); + } + } diff --git a/application/models/BootMenuEntries.php b/application/models/BootMenuEntries.php index 9b6985c..d27fd20 100644 --- a/application/models/BootMenuEntries.php +++ b/application/models/BootMenuEntries.php @@ -6,6 +6,7 @@ class Application_Model_BootMenuEntries protected $_bootmenuID; protected $_title; protected $_kcl; + protected $_configID; protected $_order; public function __construct(array $options = null) @@ -80,6 +81,15 @@ class Application_Model_BootMenuEntries $this->_kcl = $_kcl; return $this; } + public function getConfigID() + { + return $this->_configID; + } + public function setConfigID($_configID) + { + $this->_configID = $_configID; + return $this; + } public function getOrder() { return $this->_order; diff --git a/application/models/BootMenuEntriesMapper.php b/application/models/BootMenuEntriesMapper.php index cf7ba46..2dac085 100644 --- a/application/models/BootMenuEntriesMapper.php +++ b/application/models/BootMenuEntriesMapper.php @@ -32,13 +32,13 @@ class Application_Model_BootMenuEntriesMapper public function save(Application_Model_BootMenuEntries $botmenuentries) { - $data = array('bootosID'=> $botmenuentries->getBootosID() ,'bootmenuID'=> $botmenuentries->getBootmenuID() ,'title'=> $botmenuentries->getTitle() ,'kcl'=> $botmenuentries->getKcl() ,'order'=> $botmenuentries->getOrder() ); + $data = array('bootosID'=> $botmenuentries->getBootosID() ,'bootmenuID'=> $botmenuentries->getBootmenuID() ,'configID'=> $botmenuentries->getConfigID() ,'title'=> $botmenuentries->getTitle() ,'kcl'=> $botmenuentries->getKcl() ,'order'=> $botmenuentries->getOrder() ); - if (null === ($id = $botmenuentries->getID()) ) { - unset($data['botmenuentriesID']); + if (null === ($id1 = $botmenuentries->getID()) ) { + $this->getDbTable()->insert($data); } else { - $this->getDbTable()->update($data, array('botmenuentriesID = ?' => $id)); + $this->getDbTable()->update($data, array('bootosID = ?' => $id1, 'bootmenuID = ?' => $id2)); } } @@ -47,7 +47,7 @@ class Application_Model_BootMenuEntriesMapper if (null === ($id = $botmenuentries->getID()) ) { return; } else { - $this->getDbTable()->delete(array('botmenuentriesID = ?' => $id)); + $this->getDbTable()->delete(array('bootmenuentriesID = ?' => $id)); } } @@ -60,7 +60,7 @@ class Application_Model_BootMenuEntriesMapper $row = $result->current(); - $botmenuentries->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setKcl($row->kcl)->setOrder($row->order); + $botmenuentries->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order); } public function fetchAll() @@ -70,7 +70,7 @@ class Application_Model_BootMenuEntriesMapper foreach ($resultSet as $row) { $entry = new Application_Model_BootMenuEntries(); - $entry->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setKcl($row->kcl)->setOrder($row->order); + $entry->setBootosID($row->bootosID)->setBootmenuID($row->bootmenuID)->setTitle($row->title)->setConfigID($row->configID)->setKcl($row->kcl)->setOrder($row->order); $entries[] = $entry; } diff --git a/application/views/scripts/bootmenu/addbootmenuentry.phtml b/application/views/scripts/bootmenu/addbootmenuentry.phtml index 3854273..914cc9c 100644 --- a/application/views/scripts/bootmenu/addbootmenuentry.phtml +++ b/application/views/scripts/bootmenu/addbootmenuentry.phtml @@ -1 +1,4 @@ -<br /><br /><center>View script for controller <b>Bootmenu</b> and script/action name <b>addbootmenuentry</b></center>
\ No newline at end of file +<?php +$this->addbootmenuentryForm->setAction($this->url()); +echo $this->addbootmenuentryForm; +?>
\ No newline at end of file diff --git a/application/views/scripts/bootmenu/editbootmenuentry.phtml b/application/views/scripts/bootmenu/editbootmenuentry.phtml index fcfb558..5680d65 100644 --- a/application/views/scripts/bootmenu/editbootmenuentry.phtml +++ b/application/views/scripts/bootmenu/editbootmenuentry.phtml @@ -1 +1,4 @@ -<br /><br /><center>View script for controller <b>Bootmenu</b> and script/action name <b>editbootmenuentry</b></center>
\ No newline at end of file +<?php +$this->editbootmenuentryForm->setAction($this->url()); +echo $this->editbootmenuentryForm; +?>
\ No newline at end of file diff --git a/application/views/scripts/bootmenu/index.phtml b/application/views/scripts/bootmenu/index.phtml index 3f29b9e..c4cdb99 100644 --- a/application/views/scripts/bootmenu/index.phtml +++ b/application/views/scripts/bootmenu/index.phtml @@ -30,6 +30,14 @@ ), 'default', true) ?>">Delete BootMenu</a></td> + <td><a href="<?php echo $this->url( + array( + 'controller' => 'bootmenu', + 'action' => 'addbootmenuentry', + 'bootmenuID' => $bootmenu->getID() + ), + 'default', + true) ?>">Add BootMenuEntry</a></td> </tr> <?php endforeach; ?> </table> @@ -105,7 +105,7 @@ CREATE TABLE IF NOT EXISTS `pbs_config` ( `configID` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(30) NOT NULL, `groupID` int(11) NOT NULL, - `membershipID` int(11) NOT NULL, + `membershipID` int(11), `shellscript` text NOT NULL, `created` VARCHAR(14) NOT NULL, PRIMARY KEY (`configID`), @@ -114,22 +114,9 @@ CREATE TABLE IF NOT EXISTS `pbs_config` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ALTER TABLE `pbs_config` - ADD CONSTRAINT `pbs_config_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`), + ADD CONSTRAINT `pbs_config_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE, ADD CONSTRAINT `pbs_config_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; -CREATE TABLE IF NOT EXISTS `pbs_userconfig` ( - `userconfigID` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(30) NOT NULL, - `membershipID` int(11) NOT NULL, - `shellscript` text NOT NULL, - `created` VARCHAR(14) NOT NULL, - PRIMARY KEY (`userconfigID`), - KEY `membershipID` (`membershipID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; - -ALTER TABLE `pbs_userconfig` - ADD CONSTRAINT `pbs_userconfig_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE; - CREATE TABLE IF NOT EXISTS `pbs_bootos` ( `bootosID` int(11) NOT NULL AUTO_INCREMENT, @@ -167,34 +154,25 @@ CREATE TABLE IF NOT EXISTS `pbs_bootmenu` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ALTER TABLE `pbs_bootmenu` - ADD CONSTRAINT `pbs_bootmenu_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`), + ADD CONSTRAINT `pbs_bootmenu_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE, ADD CONSTRAINT `pbs_bootmenu_ibfk_2` FOREIGN KEY (`groupID`) REFERENCES `pbs_group` (`groupID`) ON DELETE CASCADE; - CREATE TABLE IF NOT EXISTS `pbs_userbootmenu` ( - `userbootmenuID` int(11) NOT NULL AUTO_INCREMENT, - `membershipID` int(11) NOT NULL, - `title` varchar(30) NOT NULL, - `created` varchar(14) NOT NULL, - PRIMARY KEY (`userbootmenuID`), - KEY `membershipID` (`membershipID`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; - -ALTER TABLE `pbs_userbootmenu` - ADD CONSTRAINT `pbs_userbootmenu_ibfk_1` FOREIGN KEY (`membershipID`) REFERENCES `pbs_membership` (`membershipID`) ON DELETE CASCADE; - CREATE TABLE IF NOT EXISTS `pbs_bootmenuentries` ( `bootosID` int(11) NOT NULL, `bootmenuID` int(11) NOT NULL, `title` varchar(30) NOT NULL, `kcl` varchar(140), + `configID` int(11) NOT NULL, `order` int(11) NOT NULL, KEY `bootosID` (`bootosID`), - KEY `bootmenuID` (`bootmenuID`) + KEY `bootmenuID` (`bootmenuID`), + KEY `configID` (`configID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; ALTER TABLE `pbs_bootmenuentries` ADD CONSTRAINT `pbs_bootmenuentries_ibfk_1` FOREIGN KEY (`bootmenuID`) REFERENCES `pbs_bootmenu` (`bootmenuID`) ON DELETE CASCADE, - ADD CONSTRAINT `pbs_bootmenuentries_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE; + ADD CONSTRAINT `pbs_bootmenuentries_ibfk_2` FOREIGN KEY (`bootosID`) REFERENCES `pbs_bootos` (`bootosID`) ON DELETE CASCADE, + ADD CONSTRAINT `pbs_bootmenuentries_ibfk_3` FOREIGN KEY (`configID`) REFERENCES `pbs_config` (`configID`) ON DELETE CASCADE; CREATE TABLE IF NOT EXISTS `pbs_bootiso` ( `bootisoID` int(11) NOT NULL AUTO_INCREMENT, |
