summaryrefslogtreecommitdiffstats
path: root/application/forms/EventEdit.php
diff options
context:
space:
mode:
authorBjörn Geiger2011-06-29 21:10:34 +0200
committerBjörn Geiger2011-06-29 21:10:34 +0200
commitdbabcd812c58340c83beafea3427a52f5ad9799c (patch)
tree10c634852d6b1fd31c11f37231abc451ee415fcc /application/forms/EventEdit.php
parentminor (diff)
downloadpoolctrl-dbabcd812c58340c83beafea3427a52f5ad9799c.tar.gz
poolctrl-dbabcd812c58340c83beafea3427a52f5ad9799c.tar.xz
poolctrl-dbabcd812c58340c83beafea3427a52f5ad9799c.zip
ausversehen verändertes wieder zurückgesetzt
Diffstat (limited to 'application/forms/EventEdit.php')
-rw-r--r--application/forms/EventEdit.php402
1 files changed, 178 insertions, 224 deletions
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
index 6eb3b07..112edde 100644
--- a/application/forms/EventEdit.php
+++ b/application/forms/EventEdit.php
@@ -1,245 +1,199 @@
<?php
-/*
- * Copyright (c) 2011 - OpenSLX GmbH, RZ Uni Freiburg
- * This program is free software distributed under the GPL version 2.
- * See http://gpl.openslx.org/
- *
- * If you have any feedback please consult http://feedback.openslx.org/ and
- * send your suggestions, praise, or complaints to feedback@openslx.org
- *
- * General information about OpenSLX can be found at http://openslx.org/
- */
-
-class EventController extends Zend_Controller_Action
+
+class Application_Form_EventEdit extends Zend_Form
{
- protected $eventMapper;
- protected $eventcategoryMapper;
- protected $membershipMapper;
- protected $personMapper;
+ private $membershiplist;
+ private $bootoslist;
+ private $poollist;
+ private $eventcategorylist;
- public function init()
+ public function setMembershiplist($membershiplist){
+ $this->membershiplist = $membershiplist;
+
+ }
+
+ public function getMembershiplist(){
+ return $this->membershiplist;
+ }
+
+ public function setBootoslist($bootoslist){
+ $this->bootoslist = $bootoslist;
+
+ }
+
+ public function getBootoslist(){
+ return $this->bootoslist;
+ }
+
+ public function setPoollist($poollist){
+ $this->poollist = $poollist;
+
+ }
+
+ public function getPoollist(){
+ return $this->poollist;
+ }
+
+ public function getEventcategorylist()
{
- $this->eventMapper = new Application_Model_EventMapper();
- $this->eventcategoryMapper = new Application_Model_EventcategoryMapper();
- $this->membershipMapper = new Application_Model_MembershipMapper();
- $this->personMapper = new Application_Model_PersonMapper();
+ return $this->eventcategorylist;
}
-
- public function indexAction()
+
+ public function setEventcategorylist($eventcategorylist)
{
- $events = $this->eventMapper->fetchAll();
- if(is_array($events)) {
- $bootOsApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getbootos/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $bootOsXMLString = $bootOsApiResult['http-body'];
- $bootOsXML = new SimpleXMLElement($bootOsXMLString);
- foreach($bootOsXML->bootoslist->bootos as $bootos) {
- $bootosobj = new Application_Model_BootOs();
- $bootosobj->setID(sprintf("%s", $bootos->id));
- $bootosobj->setCreated(sprintf("%s", $bootos->created));
- $bootosobj->setDefaultkcl(sprintf("%s", $bootos->defaultkcl));
- $bootosobj->setDescription(sprintf("%s", $bootos->description));
- $bootosobj->setDistro(sprintf("%s", $bootos->distro));
- $bootosobj->setDistroversion(sprintf("%s", $bootos->distroversion));
- $bootosobj->setExpires(sprintf("%s", $bootos->expires));
- $bootosobj->setGroupID(sprintf("%s", $bootos->groupid));
- $bootosobj->setMembershipID(sprintf("%s", $bootos->membershipid));
- $bootosobj->setPublic(sprintf("%s", $bootos->public));
- $bootosobj->setShare(sprintf("%s", $bootos->share));
- $bootosobj->setShortname(sprintf("%s", $bootos->shortname));
- $bootosobj->setSource(sprintf("%s", $bootos->source));
- $bootosobj->setTitle(sprintf("%s", $bootos->title));
- $bootoslist[$bootosobj->getID()] = $bootosobj;
- }
- $poolApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getpool/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $poolXMLString = $poolApiResult['http-body'];
- $poolXML = new SimpleXMLElement($poolXMLString);
- foreach($poolXML->poollist->pool as $pool) {
- $poolobj = new Application_Model_Pool();
- $poolobj->setID(sprintf("%s", $pool->id));
- $poolobj->setDescription(sprintf("%s", $pool->description));
- $poolobj->setGroupID(sprintf("%s", $pool->groupid));
- $poolobj->setLocation(sprintf("%s", $pool->location));
- $poolobj->setTitle(sprintf("%s", $pool->title));
- $poollist[$poolobj->getID()] = $poolobj;
- }
- foreach($events as $eventObj) {
- $event = $eventObj->toArray();
- $bootos = new Application_Model_BootOs();
- $event['pbs_bootos_title'] = $bootoslist[$event['pbs_bootosID']]->getTitle();
- $membership = new Application_Model_Membership();
- $this->membershipMapper->find($event['pbs_membershipID'], $membership);
- $person = new Application_Model_Person();
- $this->personMapper->find($membership->getPersonID(), $person);
- $event['pbs_person_name'] = $person->getFirstname() . " " . $person->getName();
- $eventcategory = new Application_Model_Eventcategory();
- $this->eventcategoryMapper->find($event['category'], $eventcategory);
- $event['category'] = $eventcategory->getTitle();
- $eventlist[$poollist[$event['pbs_poolID']]->getTitle()][] = $event;
- }
- }
-
- $this->view->eventlist = $eventlist;
+ $this->eventcategorylist = $eventcategorylist;
}
-
- public function addAction()
+
+ public function init()
{
- $eventcategorylist = $this->eventcategoryMapper->fetchAll();
- $bootOsApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getbootos/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $bootOsXMLString = $bootOsApiResult['http-body'];
- $bootOsXML = new SimpleXMLElement($bootOsXMLString);
- foreach($bootOsXML->bootoslist->bootos as $bootos) {
- $bootosobj = new Application_Model_BootOs();
- $bootosobj->setID(sprintf("%s", $bootos->id));
- $bootosobj->setCreated(sprintf("%s", $bootos->created));
- $bootosobj->setDefaultkcl(sprintf("%s", $bootos->defaultkcl));
- $bootosobj->setDescription(sprintf("%s", $bootos->description));
- $bootosobj->setDistro(sprintf("%s", $bootos->distro));
- $bootosobj->setDistroversion(sprintf("%s", $bootos->distroversion));
- $bootosobj->setExpires(sprintf("%s", $bootos->expires));
- $bootosobj->setGroupID(sprintf("%s", $bootos->groupid));
- $bootosobj->setMembershipID(sprintf("%s", $bootos->membershipid));
- $bootosobj->setPublic(sprintf("%s", $bootos->public));
- $bootosobj->setShare(sprintf("%s", $bootos->share));
- $bootosobj->setShortname(sprintf("%s", $bootos->shortname));
- $bootosobj->setSource(sprintf("%s", $bootos->source));
- $bootosobj->setTitle(sprintf("%s", $bootos->title));
- $bootoslist[$bootosobj->getID()] = $bootosobj;
- }
- $poolApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getpool/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $poolXMLString = $poolApiResult['http-body'];
- $poolXML = new SimpleXMLElement($poolXMLString);
- foreach($poolXML->poollist->pool as $pool) {
- $poolobj = new Application_Model_Pool();
- $poolobj->setID(sprintf("%s", $pool->id));
- $poolobj->setDescription(sprintf("%s", $pool->description));
- $poolobj->setGroupID(sprintf("%s", $pool->groupid));
- $poolobj->setLocation(sprintf("%s", $pool->location));
- $poolobj->setTitle(sprintf("%s", $pool->title));
- $poollist[$poolobj->getID()] = $poolobj;
+ $this->setName('EventEdit');
+ $this->setMethod('post');
+
+ $this->addElement('text', 'title', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Title:',
+ 'value' => $_POST['title'],
+ ));
+
+ if($_POST['immediate'] == 1) {
+ $this->addElement('checkbox', 'immediate', array(
+ 'required' => false,
+ 'label' => 'Immediate Event',
+ 'value'=>array(0,1),
+ 'checked' => 'checked',
+ ));
+ } else {
+ $this->addElement('checkbox', 'immediate', array(
+ 'required' => false,
+ 'label' => 'Immediate Event',
+ 'value'=>array(0,1),
+ ));
}
- if (!isset($_POST["add"])){
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist));
+
+ $this->addElement('text', 'start', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'Start (mm/dd/yyyy - H:min):',
+ 'value' => date ('m/d/Y - H:i', strtotime($_POST['start'])),
+ ));
+
+ $this->addElement('text', 'end', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 50)),
+ ),
+ 'required' => true,
+ 'label' => 'End (mm/dd/yyyy - H:min):',
+ 'value' => date ('m/d/Y H:i', strtotime($_POST['end'])),
+ ));
+
+ if($_POST['repeat'] == 1) {
+ $this->addElement('checkbox', 'repeat', array(
+ 'required' => false,
+ 'label' => 'Repeat:',
+ 'value'=>array(0,1),
+ 'checked' => 'checked',
+ ));
} else {
- $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $_POST));
- if ($addForm->isValid($_POST)) {
- $_POST['start'] = date ('Y-m-d H:i', strtotime($_POST['start']));
- $_POST['end'] = date ('Y-m-d H:i', strtotime($_POST['end']));
- $event = new Application_Model_Event($_POST);
- $event->setPbs_membershipID(1);
- try {
- $eventID = $this->eventMapper->save($event);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- $this->_redirect('/event/');
- }
+ $this->addElement('checkbox', 'repeat', array(
+ 'required' => false,
+ 'label' => 'Repeat:',
+ 'value'=>array(0,1),
+ ));
}
- $this->view->addForm = $addForm;
- }
+ $this->addElement('text', 'participants', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 140)),
+ ),
+ 'required' => false,
+ 'label' => 'Participants:',
+ 'value' => $_POST['participants'],
+ ));
- public function deleteAction()
- {
- $this->_helper->viewRenderer->setNoRender();
- $eventID = $this->_request->getParam('eventID');
- if(isset($eventID)) {
- $event = new Application_Model_Event();
- $this->eventMapper->find($eventID, $event);
- try {
- $this->eventMapper->delete($event);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- $this->_redirect('/event/');
- } else {
- $this->_redirect('/event/');
- return;
+ $eventcategoryfield = new Zend_Form_Element_Select('category');
+ $eventcategoryfield ->setLabel('Category:');
+ if(count($this->eventcategorylist)>0){
+ foreach($this->eventcategorylist as $category => $c){
+ $eventcategoryfield->addMultiOption($c->getID(), $c->getTitle());
+ }
}
- }
- public function editAction()
- {
- $eventcategorylist = $this->eventcategoryMapper->fetchAll();
- $bootOsApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getbootos/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $bootOsXMLString = $bootOsApiResult['http-body'];
- $bootOsXML = new SimpleXMLElement($bootOsXMLString);
- foreach($bootOsXML->bootoslist->bootos as $bootos) {
- $bootosobj = new Application_Model_BootOs();
- $bootosobj->setID(sprintf("%s", $bootos->id));
- $bootosobj->setCreated(sprintf("%s", $bootos->created));
- $bootosobj->setDefaultkcl(sprintf("%s", $bootos->defaultkcl));
- $bootosobj->setDescription(sprintf("%s", $bootos->description));
- $bootosobj->setDistro(sprintf("%s", $bootos->distro));
- $bootosobj->setDistroversion(sprintf("%s", $bootos->distroversion));
- $bootosobj->setExpires(sprintf("%s", $bootos->expires));
- $bootosobj->setGroupID(sprintf("%s", $bootos->groupid));
- $bootosobj->setMembershipID(sprintf("%s", $bootos->membershipid));
- $bootosobj->setPublic(sprintf("%s", $bootos->public));
- $bootosobj->setShare(sprintf("%s", $bootos->share));
- $bootosobj->setShortname(sprintf("%s", $bootos->shortname));
- $bootosobj->setSource(sprintf("%s", $bootos->source));
- $bootosobj->setTitle(sprintf("%s", $bootos->title));
- $bootoslist[$bootosobj->getID()] = $bootosobj;
- }
- $poolApiResult = PostToHost('pbs2poolctrl.mp.openslx.org', '/resource/getpool/apikey/apikey1', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', '');
- $poolXMLString = $poolApiResult['http-body'];
- $poolXML = new SimpleXMLElement($poolXMLString);
- foreach($poolXML->poollist->pool as $pool) {
- $poolobj = new Application_Model_Pool();
- $poolobj->setID(sprintf("%s", $pool->id));
- $poolobj->setDescription(sprintf("%s", $pool->description));
- $poolobj->setGroupID(sprintf("%s", $pool->groupid));
- $poolobj->setLocation(sprintf("%s", $pool->location));
- $poolobj->setTitle(sprintf("%s", $pool->title));
- $poollist[$poolobj->getID()] = $poolobj;
+ $eventcategoryfield->setRegisterInArrayValidator(false);
+ $eventcategoryfield->setValue($_POST['category']);
+ $this->addElement($eventcategoryfield);
+
+ $this->addElement('text', 'note', array(
+ 'filters' => array('StringTrim'),
+ 'validators' => array(
+ array('StringLength', false, array(0, 140)),
+ ),
+ 'required' => false,
+ 'label' => 'Note:',
+ 'value' => $_POST['note'],
+ ));
+
+ $poolfield = $this->createElement('select','pbs_poolID');
+ $poolfield ->setLabel('Pool:');
+
+ if(count($this->poollist)>0){
+ foreach($this->poollist as $pool => $p){
+ $poolfield->addMultiOption($p->getID(), $p->getTitle());
+ }
}
- $eventID = $this->_request->getParam('eventID');
- if(!isset($eventID)) {
- $this->_helper->redirector('add', 'event');
- return;
- } else {
- if (isset($_POST["save"])){
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist, $_POST));
- if ($editForm->isValid($_POST)) {
- $_POST['start'] = date ('Y-m-d H:i', strtotime($_POST['start']));
- $_POST['end'] = date ('Y-m-d H:i', strtotime($_POST['end']));
- $event = new Application_Model_Event($_POST);
- $event->setID($eventID);
- $event->setPbs_membershipID(1);
- try {
- $this->eventMapper->save($event);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- $this->_redirect('/event/');
- }
- } else {
- $event = new Application_Model_Event();
- $this->eventMapper->find($eventID, $event);
- $_POST['title'] = $event->getTitle();
- $_POST['immediate'] = $event->getImmediate();
- $_POST['start'] = $event->getStart();
- $_POST['end'] = $event->getEnd();
- $_POST['repeat'] = $event->getRepeat();
- $_POST['participants'] = $event->getParticipants();
- $_POST['category'] = $event->getCategory();
- $_POST['note'] = $event->getNote();
- $_POST['pbs_poolID'] = $event->getPbs_poolID();
- $_POST['pbs_bootosID'] = $event->getPbs_bootosID();
- $_POST['pbs_membershipID'] = $event->getPbs_membershipID();
- $editForm = new Application_Form_EventEdit(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist));
+
+ $poolfield->setRegisterInArrayValidator(false);
+ $poolfield->setValue($_POST['pbs_poolID']);
+ $this->addElement($poolfield);
+
+ // $membershipfield = $this->createElement('select','pbs_membershipID');
+ // $membershipfield ->setLabel('Membership:');
+ //
+ // if(count($this->membershiplist)>0){
+ // foreach($this->membershiplist as $membership => $m){
+ // $membershipfield->addMultiOption($m->getID(), $m->getPersonID());
+ // }
+ // }
+ //
+ // $membershipfield->setRegisterInArrayValidator(false);
+ // $this->addElement($membershipfield);
+
+ $bootosfield = $this->createElement('select','pbs_bootosID');
+ $bootosfield ->setLabel('BootOS:');
+
+ if(count($this->bootoslist)>0){
+ foreach($this->bootoslist as $bootos => $b){
+ $bootosfield->addMultiOption($b->getID(), $b->getTitle());
}
- $this->view->editForm = $editForm;
}
+
+ $bootosfield->setRegisterInArrayValidator(false);
+ $bootosfield->setValue($_POST['pbs_bootosID']);
+ $this->addElement($bootosfield);
+
+ $this->addElement('submit', 'save', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Save Event'
+ ));
+
+ $this->addElement('button', 'cancel', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Cancel',
+ 'onclick' => 'location.href="javascript:history.back();"',
+ ));
+
}
+
+
} \ No newline at end of file