summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormichael pereira2011-03-07 02:17:29 +0100
committermichael pereira2011-03-07 02:17:29 +0100
commitf7996a02542d145a682dcb1c059bd05cc573a942 (patch)
tree98e53b783dec4935526b91ad5d05eb997a72a4bc
parentbootstrap für benutzung von globalem css vorbereitet (diff)
downloadpbs2-f7996a02542d145a682dcb1c059bd05cc573a942.tar.gz
pbs2-f7996a02542d145a682dcb1c059bd05cc573a942.tar.xz
pbs2-f7996a02542d145a682dcb1c059bd05cc573a942.zip
BootIso Interface fertig
-rw-r--r--.zfproject.xml18
-rw-r--r--application/configs/application.ini2
-rw-r--r--application/controllers/BootisoController.php112
-rw-r--r--application/forms/BootisoCreate.php83
-rw-r--r--application/forms/BootisoEdit.php80
-rw-r--r--application/models/BootIso.php58
-rw-r--r--application/models/BootIsoMapper.php12
-rw-r--r--application/views/scripts/bootiso/createbootiso.phtml4
-rw-r--r--application/views/scripts/bootiso/editbootiso.phtml4
-rw-r--r--application/views/scripts/bootiso/index.phtml51
-rw-r--r--pbs.sql2
-rw-r--r--tests/application/controllers/BootisoControllerTest.php20
12 files changed, 424 insertions, 22 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index ea102b1..69a753a 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -65,6 +65,12 @@
<actionMethod actionName="deletepool"/>
<actionMethod actionName="editpool"/>
</controllerFile>
+ <controllerFile controllerName="Bootiso">
+ <actionMethod actionName="index"/>
+ <actionMethod actionName="createbootiso"/>
+ <actionMethod actionName="editbootiso"/>
+ <actionMethod actionName="deletebootiso"/>
+ </controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="AuthLogin"/>
@@ -80,6 +86,8 @@
<formFile formName="BootmenuEdit"/>
<formFile formName="BootmenuEntriesAdd"/>
<formFile formName="BootmenuEntriesEdit"/>
+ <formFile formName="BootisoCreate"/>
+ <formFile formName="BootisoEdit"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
@@ -254,6 +262,15 @@
<viewControllerScriptsDirectory forControllerName="Pool">
<viewScriptFile forActionName="editpool"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Bootiso">
+ <viewScriptFile forActionName="index"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Bootiso">
+ <viewScriptFile forActionName="createbootiso"/>
+ </viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Bootiso">
+ <viewScriptFile forActionName="editbootiso"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
@@ -296,6 +313,7 @@
<testApplicationControllerFile filesystemName="BootmenuControllerTest.php"/>
<testApplicationControllerFile filesystemName="ClientControllerTest.php"/>
<testApplicationControllerFile filesystemName="PoolControllerTest.php"/>
+ <testApplicationControllerFile filesystemName="BootisoControllerTest.php"/>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory>
diff --git a/application/configs/application.ini b/application/configs/application.ini
index 226dc30..c02bd7c 100644
--- a/application/configs/application.ini
+++ b/application/configs/application.ini
@@ -10,7 +10,7 @@ resources.frontController.params.displayExceptions = 0
resources.db.adapter = PDO_MYSQL
resources.db.params.host = localhost
resources.db.params.username = root
-resources.db.params.password = 123456
+resources.db.params.password = lsfks
resources.db.params.dbname = pbs
resources.db.isDefaultTableAdapter = true
resources.view[] = ""
diff --git a/application/controllers/BootisoController.php b/application/controllers/BootisoController.php
new file mode 100644
index 0000000..771a48d
--- /dev/null
+++ b/application/controllers/BootisoController.php
@@ -0,0 +1,112 @@
+<?php
+
+class BootisoController extends Zend_Controller_Action
+{
+
+ public function init()
+ {
+ $db = Zend_Db_Table::getDefaultAdapter();
+ }
+
+ public function indexAction()
+ {
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $this->view->bootisolist = $bootisomapper->fetchAll();
+ }
+
+ public function createbootisoAction()
+ {
+ if (!isset($_POST["createbootiso"])){
+ $createbootisoForm = new Application_Form_BootisoCreate();
+ } else {
+
+ $createbootisoForm = new Application_Form_BootisoCreate($_POST);
+
+ if ($createbootisoForm->isValid($_POST)) {
+
+ $bootiso = new Application_Model_BootIso($_POST);
+ $bootiso->setMembershipID('1');
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootiso->setCreated(time());
+
+ try {
+ $bootisomapper->save($bootiso);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+
+ }
+ $this->_redirect('/bootiso');
+ }
+ }
+
+ $this->view->createbootisoForm = $createbootisoForm;
+ }
+
+ public function editbootisoAction()
+ {
+ $bootisoID = $this->_request->getParam('bootisoID');
+
+ if (!isset($_POST["editbootiso"])){
+ $bootisoID = $this->_request->getParam('bootisoID');
+ if (!isset($bootisoID) || !is_numeric($bootisoID)){
+ $this->_redirect('/bootiso');
+ } else {
+ $bootiso = new Application_Model_BootIso();
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootisomapper->find($bootisoID, $bootiso);
+
+ $editbootisoForm = new Application_Form_BootisoEdit();
+ $editbootisoForm->populate($bootiso->toArray());
+ }
+ }else{
+ $editbootisoForm = new Application_Form_BootisoEdit($_POST);
+
+ if ($editbootisoForm->isValid($_POST)) {
+
+ $bootiso = new Application_Model_BootIso($_POST);
+ $bootiso->setMembershipID('1');
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootiso->setCreated(time());
+ $bootiso->setID($bootisoID);
+
+ try {
+ $bootisomapper->save($bootiso);
+ }catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ }
+
+ $this->_redirect('/bootiso');
+ }
+
+ }
+
+ $this->view->editbootisoForm = $editbootisoForm;
+ }
+
+ public function deletebootisoAction()
+ {
+ $bootisoID = $this->_request->getParam('bootisoID');
+ if (!isset($bootisoID)){
+ $this->_redirect('/bootiso');
+ } else {
+ $bootiso = new Application_Model_BootIso();
+ $bootiso->setID($bootisoID);
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootisomapper->delete($bootiso);
+ }
+ $this->_redirect('/bootiso');
+ }
+
+
+}
+
+
+
+
+
+
+
diff --git a/application/forms/BootisoCreate.php b/application/forms/BootisoCreate.php
new file mode 100644
index 0000000..035205d
--- /dev/null
+++ b/application/forms/BootisoCreate.php
@@ -0,0 +1,83 @@
+<?php
+
+class Application_Form_BootisoCreate extends Zend_Form
+{
+
+ public function init()
+ {
+ $this->setName("BootIsoCreate");
+ $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', 'groupID', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'GroupID:',
+ 'value' => '1',
+ ));
+
+ $this->addElement('text', 'path', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Path:',
+ ));
+
+ $this->addElement('text', 'serialnumber', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Serialnumber:',
+ ));
+
+ $date = new DateTime();
+ $date->add(new DateInterval('P1Y'));
+ $this->addElement('text', 'expires', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'Expires:',
+ 'value' => $date->format('Y-m-d'),
+ ));
+
+ $this->addElement('text', 'public', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Public-Level:',
+ ));
+
+ $this->addElement('submit', 'createbootiso', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Create BootISO',
+ ));
+
+ $this->addElement('button', 'Cancel', array(
+ 'onclick' => 'self.location="/bootiso"'
+ ));
+
+ }
+
+
+}
+
diff --git a/application/forms/BootisoEdit.php b/application/forms/BootisoEdit.php
new file mode 100644
index 0000000..7418a17
--- /dev/null
+++ b/application/forms/BootisoEdit.php
@@ -0,0 +1,80 @@
+<?php
+
+class Application_Form_BootisoEdit extends Zend_Form
+{
+ public function init()
+ {
+ $this->setName("BootIsoEdit");
+ $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', 'groupID', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'GroupID:',
+ 'value' => '1',
+ ));
+
+ $this->addElement('text', 'path', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Path:',
+ ));
+
+ $this->addElement('text', 'serialnumber', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Serialnumber:',
+ ));
+
+ $date = new DateTime();
+ $date->add(new DateInterval('P1Y'));
+ $this->addElement('text', 'expires', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => false,
+ 'label' => 'Expires:',
+ 'value' => $date->format('Y-m-d'),
+ ));
+
+ $this->addElement('text', 'public', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Public-Level:',
+ ));
+
+ $this->addElement('submit', 'editbootiso', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Edit BootISO',
+ ));
+
+ $this->addElement('button', 'Cancel', array(
+ 'onclick' => 'self.location="/bootiso"'
+ ));
+
+ }
+}
+
diff --git a/application/models/BootIso.php b/application/models/BootIso.php
index 0fce948..f5e2c15 100644
--- a/application/models/BootIso.php
+++ b/application/models/BootIso.php
@@ -3,6 +3,8 @@
class Application_Model_BootIso
{
protected $_bootisoID;
+ protected $_title;
+ protected $_path;
protected $_membershipID;
protected $_groupID;
protected $_serialnumber;
@@ -47,79 +49,105 @@ class Application_Model_BootIso
return $this;
}
+ public function getID()
+ {
+ return $this->_bootisoID;
+ }
+ public function setID($_bootisoID)
+ {
+ $this->_bootisoID = $_bootisoID;
+ return $this;
+ }
- public function get_membershipID()
+ public function getMembershipID()
{
return $this->_membershipID;
}
- public function set_membershipID($_membershipID)
+ public function setMembershipID($_membershipID)
{
$this->_membershipID = $_membershipID;
return $this;
}
- public function get_groupID()
+ public function getGroupID()
{
return $this->_groupID;
}
- public function set_groupID($_groupID)
+ public function setGroupID($_groupID)
{
$this->_groupID = $_groupID;
return $this;
}
-
- public function get_serialnumber()
+ public function getTitle()
+ {
+ return $this->_title;
+ }
+ public function setTitle($_title)
+ {
+ $this->_title = $_title;
+ return $this;
+ }
+ public function getPath()
+ {
+ return $this->_path;
+ }
+ public function setPath($_path)
+ {
+ $this->_path = $_path;
+ return $this;
+ }
+ public function getSerialnumber()
{
return $this->_serialnumber;
}
- public function set_serialnumber($_serialnumber)
+ public function setSerialnumber($_serialnumber)
{
$this->_serialnumber = $_serialnumber;
return $this;
}
- public function get_created()
+ public function getCreated()
{
return $this->_created;
}
- public function set_created($_created)
+ public function setCreated($_created)
{
$this->_created = $_created;
return $this;
}
- public function get_expires()
+ public function getExpires()
{
return $this->_expires;
}
- public function set_expires($_expires)
+ public function setExpires($_expires)
{
$this->_expires = $_expires;
return $this;
}
- public function get_public()
+ public function getPublic()
{
return $this->_public;
}
- public function set_public($_public)
+ public function setPublic($_public)
{
$this->_public = $_public;
return $this;
}
- public function get_bootisoID()
+ public function getBootisoID()
{
return $this->_bootisoID;
}
- public function set_bootisoID($_bootisoID)
+ public function setBootisoID($_bootisoID)
{
$this->_bootisoID = $_bootisoID;
return $this;
diff --git a/application/models/BootIsoMapper.php b/application/models/BootIsoMapper.php
index 624940b..0039677 100644
--- a/application/models/BootIsoMapper.php
+++ b/application/models/BootIsoMapper.php
@@ -32,13 +32,13 @@ class Application_Model_BootIsoMapper
public function save(Application_Model_BootIso $botiso)
{
- $data = array('bootisoID'=> $botiso->getBootisoID() ,'membershipID'=> $botiso->getMembershipID() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() );
+ $data = array('bootisoID'=> $botiso->getID() ,'membershipID'=> $botiso->getMembershipID() ,'title'=> $botiso->getTitle(),'path'=> $botiso->getPath() ,'groupID'=> $botiso->getGroupID() ,'serialnumber'=> $botiso->getSerialnumber() ,'created'=> $botiso->getCreated() ,'expires'=> $botiso->getExpires() ,'public'=> $botiso->getPublic() );
if (null === ($id = $botiso->getID()) ) {
- unset($data['botisoID']);
+ unset($data['bootisoID']);
$this->getDbTable()->insert($data);
} else {
- $this->getDbTable()->update($data, array('botisoID = ?' => $id));
+ $this->getDbTable()->update($data, array('bootisoID = ?' => $id));
}
}
@@ -47,7 +47,7 @@ class Application_Model_BootIsoMapper
if (null === ($id = $botiso->getID()) ) {
return;
} else {
- $this->getDbTable()->delete(array('botisoID = ?' => $id));
+ $this->getDbTable()->delete(array('bootisoID = ?' => $id));
}
}
@@ -60,7 +60,7 @@ class Application_Model_BootIsoMapper
$row = $result->current();
- $botiso->setBootisoID($row->bootisoID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
+ $botiso->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath($row->path)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
}
public function fetchAll()
@@ -70,7 +70,7 @@ class Application_Model_BootIsoMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_BootIso();
- $entry->setBootisoID($row->bootisoID)->setMembershipID($row->membershipID)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
+ $entry->setID($row->bootisoID)->setMembershipID($row->membershipID)->setTitle($row->title)->setPath($row->path)->setGroupID($row->groupID)->setSerialnumber($row->serialnumber)->setCreated($row->created)->setExpires($row->expires)->setPublic($row->public);
$entries[] = $entry;
}
diff --git a/application/views/scripts/bootiso/createbootiso.phtml b/application/views/scripts/bootiso/createbootiso.phtml
new file mode 100644
index 0000000..a5ad609
--- /dev/null
+++ b/application/views/scripts/bootiso/createbootiso.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->createbootisoForm->setAction($this->url());
+echo $this->createbootisoForm;
+?>
diff --git a/application/views/scripts/bootiso/editbootiso.phtml b/application/views/scripts/bootiso/editbootiso.phtml
new file mode 100644
index 0000000..9b04c95
--- /dev/null
+++ b/application/views/scripts/bootiso/editbootiso.phtml
@@ -0,0 +1,4 @@
+<?php
+$this->editbootisoForm->setAction($this->url());
+echo $this->editbootisoForm;
+?>
diff --git a/application/views/scripts/bootiso/index.phtml b/application/views/scripts/bootiso/index.phtml
new file mode 100644
index 0000000..d1b939a
--- /dev/null
+++ b/application/views/scripts/bootiso/index.phtml
@@ -0,0 +1,51 @@
+<h1>BootISO</h1>
+<table border=1>
+ <tr>
+ <th>ID</th>
+ <th>Title</th>
+ <th>GroupID</th>
+ <th>MembershipID</th>
+ <th>Path</th>
+ <th>Serialnumber</th>
+ <th>Created</th>
+ <th>Expires</th>
+ <th>Public</th>
+ </tr>
+ <?php foreach ($this->bootisolist as $bootiso): ?>
+ <tr>
+ <td><?php echo $this->escape($bootiso->getID()); ?></td>
+ <td><?php echo $this->escape($bootiso->getTitle()); ?></td>
+ <td><?php echo $this->escape($bootiso->getGroupID()); ?></td>
+ <td><?php echo $this->escape($bootiso->getMembershipID()); ?></td>
+ <td><?php echo $this->escape($bootiso->getPath()); ?></td>
+ <td><?php echo $this->escape($bootiso->getSerialnumber()); ?></td>
+ <td><?php echo $this->escape(date('Y-m-d H:i:s', $bootiso->getCreated())); ?></td>
+ <td><?php echo $this->escape($bootiso->getExpires()); ?></td>
+ <td><?php echo $this->escape($bootiso->getPublic()); ?></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'bootiso',
+ 'action' => 'editbootiso',
+ 'bootisoID' => $bootiso->getID()
+ ),
+ 'default',
+ true, false) ?>">Edit BootISO</a></td>
+ <td><a href="<?php echo $this->url(
+ array(
+ 'controller' => 'bootiso',
+ 'action' => 'deletebootiso',
+ 'bootisoID' => $bootiso->getID()
+ ),
+ 'default',
+ true) ?>">Delete BootISO</a></td>
+ </tr>
+ <?php endforeach; ?>
+</table>
+<br/>
+<?php echo $this->formButton('createbootiso', 'Create BootISO', array(
+ 'onclick' => 'self.location="/bootiso/createbootiso"'))?>
+
+
+
+
+
diff --git a/pbs.sql b/pbs.sql
index feeda70..5cbe84f 100644
--- a/pbs.sql
+++ b/pbs.sql
@@ -198,8 +198,10 @@ ALTER TABLE `pbs_bootmenuentries`
CREATE TABLE IF NOT EXISTS `pbs_bootiso` (
`bootisoID` int(11) NOT NULL AUTO_INCREMENT,
+ `title` varchar(30) NOT NULL,
`membershipID` int(11),
`groupID` int(11) NOT NULL,
+ `path` varchar(30) NOT NULL,
`serialnumber` int(11) NOT NULL,
`created` VARCHAR(14) NOT NULL,
`expires` VARCHAR(14),
diff --git a/tests/application/controllers/BootisoControllerTest.php b/tests/application/controllers/BootisoControllerTest.php
new file mode 100644
index 0000000..6c7239e
--- /dev/null
+++ b/tests/application/controllers/BootisoControllerTest.php
@@ -0,0 +1,20 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+class BootisoControllerTest extends PHPUnit_Framework_TestCase
+{
+
+ public function setUp()
+ {
+ /* Setup Routine */
+ }
+
+ public function tearDown()
+ {
+ /* Tear Down Routine */
+ }
+
+
+}
+