summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Geiger2011-10-24 13:15:49 +0200
committerBjörn Geiger2011-10-24 13:15:49 +0200
commit142aefa6588380e46bbee0ad5fa75f9cb461caa8 (patch)
tree5deb774ba81b424b8ccb7a7c861469b72498bfcd
parentMerge branch 'master' of git.openslx.org:lsfks/projekte/poolctrl (diff)
downloadpoolctrl-142aefa6588380e46bbee0ad5fa75f9cb461caa8.tar.gz
poolctrl-142aefa6588380e46bbee0ad5fa75f9cb461caa8.tar.xz
poolctrl-142aefa6588380e46bbee0ad5fa75f9cb461caa8.zip
korrektur von eben
-rwxr-xr-xapplication/forms/EventAdd.php2
-rwxr-xr-xapplication/forms/EventEdit.php2
-rwxr-xr-xlibrary/Poolctrl/Validator/EventOverlapping.php30
3 files changed, 25 insertions, 9 deletions
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index 6f579b5..9027917 100755
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -199,7 +199,7 @@ class Application_Form_EventAdd extends Zend_Form
'value' => $this->end,
));
$this->getElement('end')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');
- $this->getElement('start')->addValidator(new Poolctrl_Validate_EventOverlapping(), array('end' => $this->getElement('end')->getValue()));
+ $this->getElement('start')->addValidator(new Poolctrl_Validate_EventOverlapping(), array('end' => $this->getElement('end')->getValue(), 'poolID' => $this->poolID));
$this->addElement('checkbox', 'repeat', array(
'onchange' => 'repeatChanged("repeat")',
diff --git a/application/forms/EventEdit.php b/application/forms/EventEdit.php
index baee5b4..72e3d7e 100755
--- a/application/forms/EventEdit.php
+++ b/application/forms/EventEdit.php
@@ -185,7 +185,7 @@ class Application_Form_EventEdit extends Zend_Form
));
$this->getElement('end')->addPrefixPath('Poolctrl_Validate', 'Poolctrl/Validator/', 'validate');
}
- $this->getElement('start')->addValidator(new Poolctrl_Validate_EventOverlapping(array('end' => $this->getElement('end')->getValue())));
+ $this->getElement('start')->addValidator(new Poolctrl_Validate_EventOverlapping(), array('end' => $this->getElement('end')->getValue(), 'poolID' => $this->params['pbs_poolID']));
if( $this->params['repeat'] == 1) {
$this->addElement('checkbox', 'repeat', array(
diff --git a/library/Poolctrl/Validator/EventOverlapping.php b/library/Poolctrl/Validator/EventOverlapping.php
index 6e095e5..f2a0779 100755
--- a/library/Poolctrl/Validator/EventOverlapping.php
+++ b/library/Poolctrl/Validator/EventOverlapping.php
@@ -14,6 +14,7 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
);
protected $_end;
+ protected $_poolID;
protected $_overlappingevent;
public function __construct($option)
@@ -24,15 +25,21 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
if (is_array($option)) {
if (array_key_exists('end', $option)) {
- $end = $option['end'];
- $endTimestamp = strtotime($end);
+ $_end = strtotime($option['end']);
} else {
require_once 'Zend/Validate/Exception.php';
throw new Zend_Validate_Exception("Missing option 'end'");
}
+ if (array_key_exists('poolID', $option)) {
+ $_poolID = $option['poolID'];
+ } else {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Missing option 'poolID'");
+ }
}
- $this->_setEnd($end);
+ $this->_setEnd($_end);
+ $this->_setPoolID($_poolID);
}
public function _getEnd()
@@ -40,9 +47,9 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
return $this->_end;
}
- public function _setEnd($end)
+ public function _setEnd($_end)
{
- $this->_end = $end;
+ $this->_end = $_end;
}
public function _getOverlappingevent()
@@ -55,12 +62,21 @@ class Poolctrl_Validate_EventOverlapping extends Zend_Validate_Abstract
$this->_overlappingevent = $overlappingevent;
}
+ public function _getPoolID()
+ {
+ return $this->_poolID;
+ }
+
+ public function _setPoolID($_poolID)
+ {
+ $this->_poolID = $_poolID;
+ }
public function isValid($value)
{
- $this->_setValue($value);
+ $this->_setValue(strtotime($value));
$eventMapper = new Application_Model_EventMapper();
- $overlappingEvents = $eventMapper->getOverlappingEvents($value, $this->_end);
+ $overlappingEvents = $eventMapper->getOverlappingEvents($this->_value, $this->_end);
if (count($overlappingEvents) > 0) {
$this->_setOverlappingevent($overlappingEvents[0]->getTitle());