summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/controllers/EventController.php100
-rw-r--r--application/forms/EventAdd.php13
-rw-r--r--application/forms/EventEdit.php13
-rw-r--r--application/views/scripts/event/add.phtml4
-rw-r--r--application/views/scripts/event/edit.phtml4
-rw-r--r--application/views/scripts/event/index.phtml2
6 files changed, 136 insertions, 0 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
new file mode 100644
index 0000000..85338f8
--- /dev/null
+++ b/application/controllers/EventController.php
@@ -0,0 +1,100 @@
+<?php
+
+class EventController extends Zend_Controller_Action
+{
+
+ protected $eventMapper = null;
+
+ public function init()
+ {
+ $this->eventMapper = new Application_Model_EventMapper();
+ }
+
+ public function indexAction()
+ {
+ $events = $this->eventMapper->fetchAll();
+ if(is_array($events)) {
+ foreach($events as $event) {
+ $eventlist[$event->getPbsPoolID()][] = $event;
+ }
+ }
+
+ $this->view->eventlist = $eventlist;
+ }
+
+ public function addAction()
+ {
+ if (!isset($_POST["add"])){
+ $addForm = new user_Form_EventAdd();
+ } else {
+ $addForm = new user_Form_EventAdd(array($_POST));
+
+ if ($addForm->isValid($_POST)) {
+ $event = new Application_Model_Event($_POST);
+
+ try {
+ $eventID = $this->eventMapper->save($event);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ }
+ }
+
+ $this->view->addForm = $addForm;
+ }
+
+ 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;
+ }
+ } else {
+ $this->_redirect('/event/');
+ return;
+
+ }
+ }
+
+ public function editAction()
+ {
+ $eventID = $this->_request->getParam('groupID');
+ if(!isset($eventID)) {
+ $this->_helper->redirector('add', 'event');
+ return;
+ } else {
+ if (isset($_POST["save"])){
+ $editForm = new user_Form_EventEdit(array($_POST));
+ if ($editForm->isValid($_POST)) {
+ $event = new Application_Model_Event($_POST);
+ $event->setID($eventID);
+ try {
+ $this->eventMapper->save($event);
+ } catch(Zend_Exception $e)
+ {
+ echo "Caught exception: " . get_class($e) . "<br/>";
+ echo "Message: " . $e->getMessage() . "<br/>";
+ return;
+ }
+ }
+ } else {
+ $event = new Application_Model_Event();
+ $this->eventMapper->find($eventID, $event);
+ $editForm = new user_Form_EventEdit();
+ }
+ $this->view->editForm = $editForm;
+ }
+ }
+} \ No newline at end of file
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
new file mode 100644
index 0000000..944f823
--- /dev/null
+++ b/application/forms/EventAdd.php
@@ -0,0 +1,13 @@
+<?php
+
+class Application_Form_EventAdd extends Zend_Form
+{
+
+ public function init()
+ {
+ /* Form Elements & Other Definitions Here ... */
+ }
+
+
+}
+
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
new file mode 100644
index 0000000..a34161d
--- /dev/null
+++ b/application/forms/EventEdit.php
@@ -0,0 +1,13 @@
+<?php
+
+class Application_Form_EventEdit extends Zend_Form
+{
+
+ public function init()
+ {
+ /* Form Elements & Other Definitions Here ... */
+ }
+
+
+}
+
diff --git a/application/views/scripts/event/add.phtml b/application/views/scripts/event/add.phtml
new file mode 100644
index 0000000..647fe1c
--- /dev/null
+++ b/application/views/scripts/event/add.phtml
@@ -0,0 +1,4 @@
+<h1>Add Event</h1>
+<?php
+echo $this->addForm;
+?> \ No newline at end of file
diff --git a/application/views/scripts/event/edit.phtml b/application/views/scripts/event/edit.phtml
new file mode 100644
index 0000000..e62b8b3
--- /dev/null
+++ b/application/views/scripts/event/edit.phtml
@@ -0,0 +1,4 @@
+<h1>Edit Event</h1>
+<?php
+echo $this->editForm;
+?> \ No newline at end of file
diff --git a/application/views/scripts/event/index.phtml b/application/views/scripts/event/index.phtml
new file mode 100644
index 0000000..a8c2b80
--- /dev/null
+++ b/application/views/scripts/event/index.phtml
@@ -0,0 +1,2 @@
+<h1>Events</h1>
+<?php print_r($this->eventlist); ?> \ No newline at end of file