diff options
| author | sf34 | 2011-03-05 19:57:06 +0100 |
|---|---|---|
| committer | sf34 | 2011-03-05 19:57:06 +0100 |
| commit | 5016fdbdeacefa697856c3576f7b57537536f031 (patch) | |
| tree | 02cda90db98a659eaec19eb7576605bbb8bfbd5d | |
| parent | Primary Key inn filterentries eingeführt um meherere Elemente eines Filterty... (diff) | |
| parent | BootOS create, edit und delete done (diff) | |
| download | pbs2-5016fdbdeacefa697856c3576f7b57537536f031.tar.gz pbs2-5016fdbdeacefa697856c3576f7b57537536f031.tar.xz pbs2-5016fdbdeacefa697856c3576f7b57537536f031.zip | |
Merge branch 'master' of openslx.org:lsfks/master-teamprojekt/pbs2
| -rw-r--r-- | application/configs/application.ini | 2 | ||||
| -rw-r--r-- | application/controllers/BootosController.php | 58 | ||||
| -rw-r--r-- | application/forms/BootosCreate.php | 5 | ||||
| -rw-r--r-- | application/forms/BootosEdit.php | 103 | ||||
| -rw-r--r-- | application/views/scripts/bootos/editbootos.phtml | 5 | ||||
| -rw-r--r-- | application/views/scripts/bootos/index.phtml | 42 | ||||
| -rw-r--r-- | pbs-randomDelete.php | 6 |
7 files changed, 200 insertions, 21 deletions
diff --git a/application/configs/application.ini b/application/configs/application.ini index 9bfaec2..6970da3 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 diff --git a/application/controllers/BootosController.php b/application/controllers/BootosController.php index 7ce4ae3..5f096a6 100644 --- a/application/controllers/BootosController.php +++ b/application/controllers/BootosController.php @@ -39,8 +39,7 @@ class BootosController extends Zend_Controller_Action echo "Message: " . $e->getMessage() . "<br/>"; } - echo "BootOS erfolgreich angelegt. <br/>"; - return; + $this->_redirect('/bootos'); } } @@ -49,12 +48,63 @@ class BootosController extends Zend_Controller_Action public function editbootosAction() { - // action body + $bootosID = $this->_request->getParam('bootosID'); + + if (!isset($_POST["editbootos"])){ + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID)){ + $this->_redirect('/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootosmapper->find($bootosID, $bootos); + + $editbootosForm = new Application_Form_BootosEdit(); + $editbootosForm->populate($bootos->toArray()); + } + }else{ + $editbootosForm = new Application_Form_BootosEdit($_POST); + + if ($editbootosForm->isValid($_POST)) { + + $bootos = new Application_Model_BootOs($_POST); + if($bootos->getConfigID() == '') + $bootos->setConfigID(NULL); + $bootosmapper = new Application_Model_BootOsMapper(); + $date = new DateTime(); + $bootos->setCreated($date->getTimestamp()); + $bootos->setID($bootosID); + + try { + $bootosmapper->save($bootos); + }catch(Zend_Exception $e) + { + echo "Caught exception: " . get_class($e) . "<br/>"; + echo "Message: " . $e->getMessage() . "<br/>"; + } + + $this->_redirect('/bootos'); + } + + } + + $this->view->editbootosForm = $editbootosForm; + } public function deletebootosAction() { - // action body + $bootosID = $this->_request->getParam('bootosID'); + if (!isset($bootosID)){ + $this->_redirect('/bootos'); + } else { + $bootos = new Application_Model_BootOs(); + $bootos->setID($bootosID); + $bootosmapper = new Application_Model_BootOsMapper(); + $bootosmapper->delete($bootos); + } + $this->_redirect('/bootos'); + } diff --git a/application/forms/BootosCreate.php b/application/forms/BootosCreate.php index ca279a0..a9648e4 100644 --- a/application/forms/BootosCreate.php +++ b/application/forms/BootosCreate.php @@ -100,6 +100,11 @@ class Application_Form_BootosCreate extends Zend_Form 'ignore' => true, 'label' => 'Create BootOS', )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootos"' + )); + } diff --git a/application/forms/BootosEdit.php b/application/forms/BootosEdit.php index 70f11da..3bc522f 100644 --- a/application/forms/BootosEdit.php +++ b/application/forms/BootosEdit.php @@ -5,9 +5,110 @@ class Application_Form_BootosEdit extends Zend_Form public function init() { - /* Form Elements & Other Definitions Here ... */ + $this->setName("BootOsEdit"); + $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', 'configID', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'ConfigID:', + )); + + $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_init', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Init-Path:', + )); + + $this->addElement('text', 'path_kernel', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Kernel-Path:', + )); + + $this->addElement('text', 'defaultkcl', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => true, + 'label' => 'Default-KCL:', + )); + + $this->addElement('textarea', 'description', array( + 'filters' => array('StringTrim'), + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'required' => false, + 'label' => 'Description:', + )); + + $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', 'editbootos', array( + 'required' => false, + 'ignore' => true, + 'label' => 'Edit BootOS', + )); + + $this->addElement('button', 'Cancel', array( + 'onclick' => 'self.location="/bootos"' + )); + } } + + diff --git a/application/views/scripts/bootos/editbootos.phtml b/application/views/scripts/bootos/editbootos.phtml index f36d3d0..43813de 100644 --- a/application/views/scripts/bootos/editbootos.phtml +++ b/application/views/scripts/bootos/editbootos.phtml @@ -1 +1,4 @@ -<br /><br /><center>View script for controller <b>Bootos</b> and script/action name <b>editbootos</b></center>
\ No newline at end of file +<?php +$this->editbootosForm->setAction($this->url()); +echo $this->editbootosForm; +?> diff --git a/application/views/scripts/bootos/index.phtml b/application/views/scripts/bootos/index.phtml index 2fef182..828a8bf 100644 --- a/application/views/scripts/bootos/index.phtml +++ b/application/views/scripts/bootos/index.phtml @@ -15,20 +15,40 @@ </tr> <?php foreach ($this->bootoslist as $bootos): ?> <tr> - <td><?php echo $bootos->getID(); ?></td> - <td><?php echo $bootos->getTitle(); ?></td> - <td><?php echo $bootos->getGroupID(); ?></td> - <td><?php echo $bootos->getConfigID(); ?></td> - <td><?php echo $bootos->getPath_init(); ?></td> - <td><?php echo $bootos->getPath_kernel(); ?></td> - <td><?php echo $bootos->getDefaultkcl(); ?></td> - <td><?php echo $bootos->getDescription(); ?></td> - <td><?php echo $bootos->getCreated(); ?></td> - <td><?php echo $bootos->getExpires(); ?></td> - <td><?php echo $bootos->getPublic(); ?></td> + <td><?php echo $this->escape($bootos->getID()); ?></td> + <td><?php echo $this->escape($bootos->getTitle()); ?></td> + <td><?php echo $this->escape($bootos->getGroupID()); ?></td> + <td><?php echo $this->escape($bootos->getConfigID()); ?></td> + <td><?php echo $this->escape($bootos->getPath_init()); ?></td> + <td><?php echo $this->escape($bootos->getPath_kernel()); ?></td> + <td><?php echo $this->escape($bootos->getDefaultkcl()); ?></td> + <td><?php echo $this->escape($bootos->getDescription()); ?></td> + <td><?php echo $this->escape($bootos->getCreated()); ?></td> + <td><?php echo $this->escape($bootos->getExpires()); ?></td> + <td><?php echo $this->escape($bootos->getPublic()); ?></td> + <td><a href="<?php echo $this->url( + array( + 'controller' => 'bootos', + 'action' => 'editbootos', + 'bootosID' => $bootos->getID() + ), + 'default', + true, false) ?>">Edit BootOS</a></td> + <td><a href="<?php echo $this->url( + array( + 'controller' => 'bootos', + 'action' => 'deletebootos', + 'bootosID' => $bootos->getID() + ), + 'default', + true) ?>">Delete BootOS</a></td> </tr> <?php endforeach; ?> </table> +<br/> +<?php echo $this->formButton('createbootos', 'Create BootOS', array( + 'onclick' => 'self.location="/bootos/createbootos"'))?> + diff --git a/pbs-randomDelete.php b/pbs-randomDelete.php index e894d5c..c3a7014 100644 --- a/pbs-randomDelete.php +++ b/pbs-randomDelete.php @@ -17,9 +17,9 @@ class deleteClass{ } public function deletePerson($i){ - $anz = mysql_num_rows(mysql_query("SELECT * FROM pbs_membership WHERE personID = $i;"); - mysql_query("DELETE FROM pbs_person WHERE personID = $i;"); - if(mysql_num_rows(mysql_query("SELECT * FROM pbs_person WHERE personID = $i;") < 1) { + $anz = mysql_num_rows(mysql_query('SELECT * FROM pbs_membership WHERE personID = $i')); + mysql_query('DELETE FROM pbs_person WHERE personID = $i;'); + if(mysql_num_rows(mysql_query("SELECT * FROM pbs_person WHERE personID = $i;") < 1)){ if($anz > 0) { if(mysql_num_rows(mysql_query("SELECT * FROM pbs_membership WHERE personID = $i;")) < 1) { echo "Löschen erfolgreich"; |
