summaryrefslogtreecommitdiffstats
path: root/library/Poolctrl/Validate/EventOverlapping.php
diff options
context:
space:
mode:
Diffstat (limited to 'library/Poolctrl/Validate/EventOverlapping.php')
-rwxr-xr-xlibrary/Poolctrl/Validate/EventOverlapping.php41
1 files changed, 35 insertions, 6 deletions
diff --git a/library/Poolctrl/Validate/EventOverlapping.php b/library/Poolctrl/Validate/EventOverlapping.php
index fb632af..fc1e0d5 100755
--- a/library/Poolctrl/Validate/EventOverlapping.php
+++ b/library/Poolctrl/Validate/EventOverlapping.php
@@ -10,7 +10,8 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
);
protected $_start;
- protected $_repeat;
+ protected $_eventMapper;
+ protected $_event;
protected $_poolID;
public function __construct($option)
@@ -20,22 +21,27 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
}
if (is_array($option)) {
+ $this->_eventMapper = new Application_Model_EventMapper();
if (array_key_exists('start', $option)) {
$_start = strtotime($option['start']);
+ $this->_setStart($_start);
} else {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Missing option 'start'");
}
if (array_key_exists('poolID', $option)) {
$_poolID = $option['poolID'];
+ $this->_setPoolID($_poolID);
} else {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Missing option 'poolID'");
}
+ if (array_key_exists('eventID', $option)) {
+ $_eventID = $option['eventID'];
+ $this->_event = new Application_Model_Event();
+ $this->_eventMapper->find($_eventID, $this->_event);
+ }
}
-
- $this->_setStart($_start);
- $this->_setPoolID($_poolID);
}
public function _getStart()
@@ -58,11 +64,34 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
$this->_poolID = $_poolID;
}
+ public function _getEvent()
+ {
+ return $this->_event;
+ }
+
+ public function _setEvent(Application_Model_Event $_event)
+ {
+ $this->_event = $_event;
+ }
+
+ public function _getEventMapper()
+ {
+ return $this->_eventMapper;
+ }
+
+ public function _setEventMapper(Application_Model_EventMapper $_eventMapper)
+ {
+ $this->_eventMapper = $_eventMapper;
+ }
+
public function isValid($value)
{
$this->_setValue(strtotime($value));
- $eventMapper = new Application_Model_EventMapper();
- $overlappingEvents = $eventMapper->getOverlappingEvents(date('Y-m-d H:i:s', $this->_start), date('Y-m-d H:i:s', $this->_value), $this->_poolID);
+ if(is_object($this->_event)) {
+ $overlappingEvents = $this->_eventMapper->getOverlappingEvents(date('Y-m-d H:i:s', $this->_start), date('Y-m-d H:i:s', $this->_value), $this->_poolID, $this->_event);
+ } else {
+ $overlappingEvents = $this->_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->_error(self::EVENT_OVERLAPPING);