eventMapper = new Application_Model_EventMapper(); $this->eventcategoryMapper = new Application_Model_EventcategoryMapper(); $this->membershipMapper = new Application_Model_MembershipMapper(); $this->personMapper = new Application_Model_PersonMapper(); } public function indexAction() { $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; } public function addAction() { $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; } if (!isset($_POST["add"])){ $addForm = new Application_Form_EventAdd(array('eventcategorylist' => $eventcategorylist, 'bootoslist' => $bootoslist, 'poollist' => $poollist)); } 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) . "
"; echo "Message: " . $e->getMessage() . "
"; return; } $this->_redirect('/event/'); } } $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) . "
"; echo "Message: " . $e->getMessage() . "
"; return; } $this->_redirect('/event/'); } else { $this->_redirect('/event/'); return; } } 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; } $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) . "
"; echo "Message: " . $e->getMessage() . "
"; 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)); } $this->view->editForm = $editForm; } } }