From 6212159c89402e562e5a66bf01cc05bc3b8f7b69 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 25 Oct 2011 17:43:19 +0200 Subject: was weiß ich --- application/controllers/EventController.php | 150 ------------------------- application/models/EventMapper.php | 26 ----- application/views/scripts/event/index.phtml | 2 +- library/Poolctrl/Validate/EventOverlapping.php | 24 ++-- 4 files changed, 14 insertions(+), 188 deletions(-) diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php index 85483b5..e0f72f0 100755 --- a/application/controllers/EventController.php +++ b/application/controllers/EventController.php @@ -795,9 +795,6 @@ class EventController extends Zend_Controller_Action $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(); @@ -1449,20 +1446,6 @@ class EventController extends Zend_Controller_Action $this->view->right = $this->acl->checkRight($rightShortcut); } - public function getrepeateventsAction() { - $this->_helper->layout->disableLayout(); - $this->_helper->viewRenderer->setNoRender(); - $eventTitle = $this->_request->getParam("title"); - $eventlist = $this->eventMapper->findBy(array('title' => $eventTitle)); - if(count($eventlist)) { - $events = array(); - foreach($eventlist as $event) { - $events[] = $event->toArray(); - } - echo json_encode($events); - } - } - /* * ---------------------- * END CALENDAR FUNCTIONS @@ -2071,139 +2054,6 @@ class EventController extends Zend_Controller_Action } } - private function reportEvent(Application_Model_Event $event) { - $boot = false; - $shutdown = false; - switch($event->getCategory()) { - case $eventcategories['Boot']: - $boot = true; - - break; - - case $eventcategories['Shutdown']: - $shutdown = true; - - break; - } - $eventreportMapper = new Application_Model_EventreportMapper(); - $runningtypeMapper = new Application_Model_RunningtypeMapper(); - if($boot) { - $data = array( - 'type' => 'getBootState', - 'events' => $event->getTitle(), - ); - - $dataString = json_encode($data); - $bootResult = $this->gearmanClient->do("status", $dataString, 'bootStatus'); - if (! $this->gearmanClient->runTasks()) - { - echo "ERROR " . $gmc->error() . "\n"; - exit; - } - $bootResultDecode = json_decode($bootResult); - $eventResult = $bootResultDecode[$event->getTitle()]; - $results['boot results'] = $bootResultDecode; - $eventResult->$resultShortcutName = sprintf('%s', $eventResult->$resultShortcutName); - if($eventResult->$resultShortcutName == "not finished") { - continue; - } else if($eventResult->$resultShortcutName == 'not founded') { - $event->setRunning(false); - $event->setRunningtype(null); - try { - $this->eventMapper->save($event); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - continue; - } - $eventreport = new Application_Model_Eventreport(); - $eventreport->setEventID($event->getID()); - $eventreport->setResult($eventResult->$resultShortcutName); - if($eventResult->$resultShortcutName == "failed") { - $eventreport->setErrors(json_encode($eventResult->$errorsName)); - } - $eventreport->setType($runningtypeBoot->getID()); - try { - $eventreportMapper->save($eventreport); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - $event->setRunning(false); - $event->setRunningtype(null); - try { - $this->eventMapper->save($event); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - } else if($shutdown) { - $data = array( - 'type' => 'getShutdownState', - 'events' => $event->getTitle(), - ); - - $dataString = json_encode($data); - $shutdownResult = $this->gearmanClient->do("status", $dataString, 'shutdownStatus'); - if (! $this->gearmanClient->runTasks()) - { - echo "ERROR " . $gmc->error() . "\n"; - exit; - } - $shutdownResultDecode = json_decode($shutdownResult); - $eventResult = $shutdownResultDecode[$event->getTitle()]; - $results['shutdown results'] = $shutdownResultDecode; - $eventResult->$resultShortcutName = sprintf('%s', $eventResult->$resultShortcutName); - if($eventResult->$resultShortcutName == "not finished") { - continue; - } else if($eventResult->$resultShortcutName == 'not founded') { - $event->setRunning(false); - $event->setRunningtype(null); - try { - $this->eventMapper->save($event); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - continue; - } - $eventreport = new Application_Model_Eventreport(); - $eventreport->setEventID($event->getID()); - $eventreport->setResult($eventResult->$resultShortcutName); - if($eventResult->$resultShortcutName == "failed") { - $eventreport->setErrors(json_encode($eventResult->$errorsName)); - } - $eventreport->setType($runningtypeShutdown->getID()); - try { - $eventreportMapper->save($eventreport); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - $event->setRunning(false); - $event->setRunningtype(null); - try { - $this->eventMapper->save($event); - } catch(Zend_Exception $e) - { - echo "Caught exception: " . get_class($e) . "
"; - echo "Message: " . $e->getMessage() . "
"; - return; - } - } - } - private function repeatEvent(Application_Model_Event $event) { try { $eventID = $this->eventMapper->save($event); diff --git a/application/models/EventMapper.php b/application/models/EventMapper.php index 4092bc3..3df8d30 100755 --- a/application/models/EventMapper.php +++ b/application/models/EventMapper.php @@ -186,20 +186,6 @@ class Application_Model_EventMapper return array_diff_assoc($vv1,$vv2); } - public function fetchAllasArray($poolID) { - - $db = Zend_Db_Table::getDefaultAdapter(); - $select = $this->getDbTable()->select() - ->setIntegrityCheck(false) - ->from(array('pce' => 'poolctrl_event')) - ->where('pce.pbs_poolID = ?', $poolID); - - $stmt = $db->query($select); - $result = $stmt->fetchAll(); - - return $result; - } - public function getCategoryBarCount($poolID) { $db = Zend_Db_Table::getDefaultAdapter(); @@ -447,18 +433,6 @@ class Application_Model_EventMapper return $return; } - // Fetch all notDragging events - public function getNotDraggingEvents($eventID) { - - $db = Zend_Db_Table::getDefaultAdapter(); - $select = 'SELECT * FROM poolctrl_event WHERE title <> (SELECT title FROM poolctrl_event WHERE eventID = ?)'; - $stmt = $db->query($select, array(''.$eventID)); - $return = $stmt->fetchAll(); - - return $return; - - } - public function getOverlappingEvents($start, $end, $poolID, Application_Model_Event $event = null, $repeat = false) { $db = Zend_Db_Table::getDefaultAdapter(); $return = array(); diff --git a/application/views/scripts/event/index.phtml b/application/views/scripts/event/index.phtml index c3603ed..489c6e4 100755 --- a/application/views/scripts/event/index.phtml +++ b/application/views/scripts/event/index.phtml @@ -355,7 +355,7 @@ var dayClick = false; }, "OK": function() { if(returndata == -1) { - if(startDate < currentDate) { + if(startDate > currentDate) { $(this).dialog("close"); self.location="/event/add/evstart/" + startDate + "/evend/" + endDate + "/poolID/" + $("#poolselectbox option:selected").val(); } else { diff --git a/library/Poolctrl/Validate/EventOverlapping.php b/library/Poolctrl/Validate/EventOverlapping.php index b28630b..f3f1d71 100755 --- a/library/Poolctrl/Validate/EventOverlapping.php +++ b/library/Poolctrl/Validate/EventOverlapping.php @@ -6,16 +6,12 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract const EVENT_OVERLAPPING = 'overlapping'; protected $_messageTemplates = array( - self::EVENT_OVERLAPPING => "This Event is overlapping the Event %overlappingEvent%", - ); - - protected $_messageVariables = array( - 'overlappingEvent' => '_overlappingevent', + self::EVENT_OVERLAPPING => "This Event is overlapping an other Event", ); protected $_start; + protected $_repeat; protected $_poolID; - protected $_overlappingevent; public function __construct($option) { @@ -36,9 +32,16 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract require_once 'Zend/Validate/Exception.php'; throw new Zend_Validate_Exception("Missing option 'poolID'"); } + if (array_key_exists('repeat', $option)) { + $_repeat = strtotime($option['repeat']); + } else { + require_once 'Zend/Validate/Exception.php'; + throw new Zend_Validate_Exception("Missing option 'repeat'"); + } } $this->_setStart($_start); + $this->_setRepeat($r_repeat); $this->_setPoolID($_poolID); } @@ -52,14 +55,14 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract $this->_start = $_start; } - public function _getOverlappingevent() + public function _getRepeat() { - return $this->_overlappingevent; + return $this->_repeat; } - public function _setOverlappingevent($_overlappingevent) + public function _setRepeat($_repeat) { - $this->_overlappingevent = $_overlappingevent; + $this->_repeat = $_repeat; } public function _getPoolID() @@ -79,7 +82,6 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract $overlappingEvents = $eventMapper->getOverlappingEvents(date('Y-m-d H:i:s', $this->_start), date('Y-m-d H:i:s', $this->_value), $this->_poolID); if (count($overlappingEvents) > 0) { - $this->_setOverlappingevent($overlappingEvents[0]->getTitle()); $this->_error(self::EVENT_OVERLAPPING); return false; } -- cgit v1.2.3-55-g7522