summaryrefslogtreecommitdiffstats
path: root/application/controllers/EventController.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/controllers/EventController.php')
-rwxr-xr-xapplication/controllers/EventController.php230
1 files changed, 220 insertions, 10 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
index 4055e93..f7711ed 100755
--- a/application/controllers/EventController.php
+++ b/application/controllers/EventController.php
@@ -659,7 +659,7 @@ class EventController extends Zend_Controller_Action
$this->view->poollist = $poollist;
}
- public function checkoverlapeventsAction() {
+ public function checkoverlapdropAction() {
if(!$this->acl->checkRight('eo')) {
$this->_redirect('/');
}
@@ -667,12 +667,13 @@ class EventController extends Zend_Controller_Action
$eventID = $this->getRequest()->getParam('eventID');
$date = intval(strtotime(substr($this->getRequest()->getParam('date'), 0, 24)));
-
+ $poolID = $this->getRequest()->getParam('poolID');
$events['withrepeat'] = $this->eventMapper->getDraggingEvents($eventID);
$events['withoutrepeat'] = $this->eventMapper->getDraggingEvent($eventID);
$others = $this->eventMapper->getNotDraggingEvents($eventID);
+ $allEvents = $this->eventMapper->fetchAllasArray($poolID);
// Calculate time shift
$diff=0;
@@ -683,38 +684,158 @@ class EventController extends Zend_Controller_Action
// Check for overlap with repeat
$overlapswithrepeat = array();
+ $cfeventswithrepeat = array();
+
foreach($events['withrepeat'] as $e) {
$enewstart = strtotime($e['start']) + $diff;
$enewend = strtotime($e['end']) + $diff;
-
+ $cfv = true;
+
+ // overlap events
foreach($others as $o) {
if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start'])
- || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']))
+ || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end'])) {
$overlapswithrepeat[] = $o;
+ $cfv = false;
+ }
+ }
+ // conflict free events with repeat
+ if($cfv) {
+ $cfeventswithrepeat[] = $e;
}
}
// Check for overlap without repeat
$overlapswithoutrepeat = array();
+ $cfeventswithoutrepeat = array();
+ $cfv = true;
+
foreach($events['withoutrepeat'] as $e) {
$enewstart = strtotime($e['start']) + $diff;
$enewend = strtotime($e['end']) + $diff;
- foreach($others as $o) {
- if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start'])
- || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']))
+ // overlap events
+ foreach($allEvents as $o) {
+ if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start']) && $o['eventID'] != $eventID
+ || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']) && $o['eventID'] != $eventID) {
$overlapswithoutrepeat[] = $o;
+ $cfv = false;
+ }
+ }
+ // conflict free events without repeat
+ if($cfv) {
+ $cfeventswithoutrepeat[] = $e;
}
}
$this->view->events = $events;
$this->view->others = $others;
$this->view->overlapswithrepeat = $overlapswithrepeat;
+ $this->view->cfeventswithrepeat = $cfeventswithrepeat;
$this->view->overlapswithoutrepeat = $overlapswithoutrepeat;
-
+ $this->view->cfeventswithoutrepeat = $cfeventswithoutrepeat;
+
}
+
+ public function checkoverlapselectAction() {
+ if(!$this->acl->checkRight('eo')) {
+ $this->_redirect('/');
+ }
+ $this->_helper->layout->disableLayout();
+
+ $poolID = $this->getRequest()->getParam('poolID');
+ $startDate = intval(strtotime(substr($this->getRequest()->getParam('startDate'), 0, 24)));
+ $endDate = intval(strtotime(substr($this->getRequest()->getParam('endDate'), 0, 24)));
+
+ $allEvents = $this->eventMapper->fetchAllasArray($poolID);
+
+ $overlaps = array();
+ foreach($allEvents as $e) {
+ if($startDate <= strtotime($e['start']) && $endDate >= strtotime($e['start'])
+ || $startDate >= strtotime($e['start']) && $startDate <= strtotime($e['end']))
+ $overlaps[] = $e;
+ }
+
+ $this->view->overlaps = $overlaps;
+ }
+
+ public function checkoverlapresizeAction() {
+ if(!$this->acl->checkRight('eo')) {
+ $this->_redirect('/');
+ }
+ $this->_helper->layout->disableLayout();
+
+ $poolID = $this->getRequest()->getParam('poolID');
+
+ $eventID = $this->getRequest()->getParam('eventID');
+ $minuteDelta = intval($this->getRequest()->getParam('minuteDelta')*60);
+ $dayDelta = intval($this->getRequest()->getParam('dayDelta')*24*60*60);
+ $diffDelta = intval($minuteDelta + $dayDelta);
+
+ $events['withrepeat'] = $this->eventMapper->getDraggingEvents($eventID);
+ $events['withoutrepeat'] = $this->eventMapper->getDraggingEvent($eventID);
+
+ $others = $this->eventMapper->getNotDraggingEvents($eventID);
+ $allEvents = $this->eventMapper->fetchAllasArray($poolID);
+
+ // Check for overlap with repeat
+ $overlapswithrepeat = array();
+ $cfeventswithrepeat = array();
+
+ foreach($events['withrepeat'] as $e) {
+
+ $enewstart = strtotime($e['start']);
+ $enewend = strtotime($e['end']) + $diffDelta;
+ $cfv = true;
+
+ // overlap events
+ foreach($allEvents as $o) {
+ if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start']) && $o['eventID'] != $e['eventID'] && $o['eventID'] != $eventID
+ || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']) && $o['eventID'] != $e['eventID'] && $o['eventID'] != $eventID) {
+ $overlapswithrepeat[] = $o;
+ $cfv = false;
+ }
+ }
+ // conflict free events with repeat
+ if($cfv) {
+ $cfeventswithrepeat[] = $e;
+ }
+ }
+
+ // Check for overlap without repeat
+ $overlapswithoutrepeat = array();
+ $cfeventswithoutrepeat = array();
+
+ foreach($events['withoutrepeat'] as $e) {
+
+ $enewstart = strtotime($e['start']);
+ $enewend = strtotime($e['end']) + $diffDelta;
+ $cfv = true;
+
+ // overlap events
+ foreach($allEvents as $o) {
+ if($enewstart <= strtotime($o['start']) && $enewend >= strtotime($o['start']) && $o['eventID'] != $eventID
+ || $enewstart >= strtotime($o['start']) && $enewstart <= strtotime($o['end']) && $o['eventID'] != $eventID) {
+ $overlapswithoutrepeat[] = $o;
+ $cfv = false;
+ }
+ }
+ // conflict free events without repeat
+ if($cfv) {
+ $cfeventswithoutrepeat[] = $e;
+ }
+ }
+
+ $this->view->events = $events;
+ $this->view->others = $others;
+ $this->view->overlapswithrepeat = $overlapswithrepeat;
+ $this->view->cfeventswithrepeat = $cfeventswithrepeat;
+ $this->view->overlapswithoutrepeat = $overlapswithoutrepeat;
+ $this->view->cfeventswithoutrepeat = $cfeventswithoutrepeat;
+
+ }
public function eventmoveAction() {
if(!$this->acl->checkRight('eo')) {
@@ -734,7 +855,8 @@ class EventController extends Zend_Controller_Action
if ($evid!="null") {
$this->eventMapper->find($evid,$event); //locate the event in the DB
$this->eventMapper->find($evid,$oldEvent);
- $event->setRepeat(0);
+ //es beleibt ein repeatEvent! ob alle verschoben werden oder nur das selektierte wird über den kalender abgefragt
+ //$event->setRepeat(0);
$event->setRepeattype(null);
$event->setRepeatend(null);
$event->setRepeatdate(null);
@@ -884,6 +1006,91 @@ class EventController extends Zend_Controller_Action
return;
}
}
+
+ public function eventmovecfAction() {
+ if(!$this->acl->checkRight('eo')) {
+ $this->_redirect('/');
+ }
+ $this->_helper->layout->disableLayout();
+ $this->_helper->viewRenderer->setNoRender();
+
+ $cfevents = $this->getRequest()->getParam('cfevents');
+ $evmindelta = $this->getRequest()->getParam('evmindelta');
+ $evdaydelta = $this->getRequest()->getParam('evdaydelta');
+ $poolID = $this->getRequest()->getParam('poolID');
+
+ $eventsArray = (array) $cfevents;
+
+ //$event = new Application_Model_Event($cfevents);
+
+ var_dump($eventsArray);
+
+ //print_r($cfevents['eventID']);
+
+ /*if ($cfevents!=null) {
+
+ $events = $this->eventMapper->findBy(array("eventID" => $cfevents['eventID']));
+ if ($events[0]->getPbs_membershipID() != $this->userIDsNamespace['membershipID']) {
+ if (!$this->acl->checkRight('edo')) {
+ $this->_redirect('/');
+ }
+ }
+ try {
+ foreach($events as $event) {
+ //1min = 60sec, 1d = 86400sec
+ $oldStartTime = date('H:i', strtotime($event->getStart()));
+ $oldStartDate = date('d.m.Y', strtotime($event->getStart()));
+ $evstartTime = intval(strtotime($event->getStart())) + intval($evmindelta*60) + intval($evdaydelta*86400);
+ $newStartTime = date('H:i', $evstartTime);
+ $newStartDate = date('d.m.Y', $evstartTime);
+ $eventStart = date('Y-m-d H:i:s', $evstartTime);
+ $event->setStart($eventStart);
+ if($event->getEnd()) {
+ $oldEndTime = date('H:i', strtotime($event->getEnd()));
+ $oldEndDate = date('d.m.Y', strtotime($event->getEnd()));
+ $evendTime = intval(strtotime($event->getEnd())) + intval($evmindelta*60) + intval($evdaydelta*86400);
+ $newEndTime = date('H:i', $evendTime);
+ $newEndDate = date('d.m.Y', $evendTime);
+ $eventEnd = date('Y-m-d H:i:s', $evendTime);
+ $event->setEnd($eventEnd);
+ }
+ $event->setPbs_poolID($poolID);
+ $result = $this->eventcategoryMapper->findBy(array('title' => 'Shutdown'));
+ $shutdownCategory = $result[0];
+ if($event->getCategory() != $shutdownCategory->getID()) {
+ if($event->getPbs_filterID()) {
+ if($event->getRepeat()) {
+ $repeattypeMapper = new Application_Model_RepeattypeMapper();
+ $repeattype = new Application_Model_Repeattype();
+ $repeattypeMapper->find($event->getRepeattype(), $repeattype);
+ if($repeattype == "Once a week") {
+ $oldStartDate = date("N", strototime($oldStartDate));
+ $oldEndDate = '';
+ $newStartDate = date("N", strototime($newStartDate));
+ $newEndDate = '';
+ }
+ }
+ $filterentriesQuerie = "filterid=" . $event->getPbs_filterID() . "&oldvalue1=" . strtotime($oldStartDate) . "&oldvalue2=" . strtotime($oldEndDate) . "&value1=" . strtotime($newStartDate) . "&value2=" . strtotime($newEndDate);
+ $filterApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['changefilterentry'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $filterentriesQuerie);
+ unset($filterApiResult);
+ $filterentriesQuerie = "filterid=" . $event->getPbs_filterID() . "&oldvalue1=" . $oldStartTime . "&oldvalue2=" . $oldEndTime . "&value1=" . $newStartTime . "&value2=" . $newEndTime;
+ $filterApiResult = PostToHost($this->pbs2host, $this->config['pbs2']['changefilterentry'] . $this->userIDsNamespace['apikey'], 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'poolctrl', $filterentriesQuerie);
+ unset($filterApiResult);
+ }
+ }
+ $this->eventMapper->save($event); //save the event with the new data
+ }
+ } 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;
+ }*/
+ }
public function eventresizeAction() {
if(!$this->acl->checkRight('eo')) {
@@ -902,7 +1109,7 @@ class EventController extends Zend_Controller_Action
if ($evid!=null) {
$this->eventMapper->find($evid,$event); //locate the event in the DB
$this->eventMapper->find($evid,$oldEvent);
- $event->setRepeat(0);
+ //$event->setRepeat(0);
$event->setRepeattype(null);
$event->setRepeatend(null);
$event->setRepeatdate(null);
@@ -983,6 +1190,7 @@ class EventController extends Zend_Controller_Action
}
try {
foreach($events as $event) {
+ if($event->getRunning() == 0) {
$eventEnd = date('Y-m-d H:i:s', intval(strtotime($event->getEnd())) + intval($evmindelta*60));
$event->setEnd($eventEnd);
$event->setPbs_poolID($poolID);
@@ -997,6 +1205,7 @@ class EventController extends Zend_Controller_Action
}
$this->eventMapper->save($event); //save the event with the new data
}
+ }
} catch (Zend_Exception $e) {
echo "Caught exception: " . get_class($e) . "<br/>";
echo "Message: " . $e->getMessage() . "<br/>";
@@ -1052,6 +1261,7 @@ class EventController extends Zend_Controller_Action
'repeat' => $event->getRepeat(),
'opacity' => 1,
'immediate' => $event->getImmediate(),
+ 'running' => $event->getRunning(),
)
);
}