summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Wagner2011-10-25 17:43:19 +0200
committerSebastian Wagner2011-10-25 17:43:19 +0200
commit6212159c89402e562e5a66bf01cc05bc3b8f7b69 (patch)
tree321a5ac9d6f8aafe28df2c678cac5c260e4a982f
parentwas weiß ich (diff)
downloadpoolctrl-6212159c89402e562e5a66bf01cc05bc3b8f7b69.tar.gz
poolctrl-6212159c89402e562e5a66bf01cc05bc3b8f7b69.tar.xz
poolctrl-6212159c89402e562e5a66bf01cc05bc3b8f7b69.zip
was weiß ich
-rwxr-xr-xapplication/controllers/EventController.php150
-rwxr-xr-xapplication/models/EventMapper.php26
-rwxr-xr-xapplication/views/scripts/event/index.phtml2
-rwxr-xr-xlibrary/Poolctrl/Validate/EventOverlapping.php24
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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- 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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- $event->setRunning(false);
- $event->setRunningtype(null);
- try {
- $this->eventMapper->save($event);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- 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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- 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) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- return;
- }
- $event->setRunning(false);
- $event->setRunningtype(null);
- try {
- $this->eventMapper->save($event);
- } catch(Zend_Exception $e)
- {
- echo "Caught exception: " . get_class($e) . "<br/>";
- echo "Message: " . $e->getMessage() . "<br/>";
- 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;
}