summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorBjörn Geiger2011-10-24 13:01:31 +0200
committerBjörn Geiger2011-10-24 13:01:31 +0200
commit767620295b5144d82edff74016a8722c3349e6d0 (patch)
treecbdd25ba7293b139d0c7f97f547cdb4cd4c03bb7 /library
parentmerge (diff)
downloadpoolctrl-767620295b5144d82edff74016a8722c3349e6d0.tar.gz
poolctrl-767620295b5144d82edff74016a8722c3349e6d0.tar.xz
poolctrl-767620295b5144d82edff74016a8722c3349e6d0.zip
verschiedenes
Diffstat (limited to 'library')
-rwxr-xr-xlibrary/Poolctrl/Validator/DateGreaterThan.php2
-rwxr-xr-xlibrary/Poolctrl/Validator/EventOverlapping.php72
2 files changed, 73 insertions, 1 deletions
diff --git a/library/Poolctrl/Validator/DateGreaterThan.php b/library/Poolctrl/Validator/DateGreaterThan.php
index d326f0d..d7be22d 100755
--- a/library/Poolctrl/Validator/DateGreaterThan.php
+++ b/library/Poolctrl/Validator/DateGreaterThan.php
@@ -37,7 +37,7 @@ class Poolctrl_Validate_DateGreaterThan extends Zend_Validate_Abstract
$element = $option['element'];
} else {
require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Missing option 'compare'");
+ throw new Zend_Validate_Exception("Missing option 'element'");
}
if (array_key_exists('compare', $option)) {
$compare = $option['compare'];
diff --git a/library/Poolctrl/Validator/EventOverlapping.php b/library/Poolctrl/Validator/EventOverlapping.php
new file mode 100755
index 0000000..6e095e5
--- /dev/null
+++ b/library/Poolctrl/Validator/EventOverlapping.php
@@ -0,0 +1,72 @@
+<?php
+require_once 'Zend/Validate/Abstract.php';
+
+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',
+ );
+
+ protected $_end;
+ protected $_overlappingevent;
+
+ public function __construct($option)
+ {
+ if ($option instanceof Zend_Config) {
+ $option = $option->toArray();
+ }
+
+ if (is_array($option)) {
+ if (array_key_exists('end', $option)) {
+ $end = $option['end'];
+ $endTimestamp = strtotime($end);
+ } else {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Missing option 'end'");
+ }
+ }
+
+ $this->_setEnd($end);
+ }
+
+ public function _getEnd()
+ {
+ return $this->_end;
+ }
+
+ public function _setEnd($end)
+ {
+ $this->_end = $end;
+ }
+
+ public function _getOverlappingevent()
+ {
+ return $this->_overlappingevent;
+ }
+
+ public function _setOverlappingevent($overlappingevent)
+ {
+ $this->_overlappingevent = $overlappingevent;
+ }
+
+
+ public function isValid($value)
+ {
+ $this->_setValue($value);
+ $eventMapper = new Application_Model_EventMapper();
+ $overlappingEvents = $eventMapper->getOverlappingEvents($value, $this->_end);
+
+ if (count($overlappingEvents) > 0) {
+ $this->_setOverlappingevent($overlappingEvents[0]->getTitle());
+ $this->_error(self::EVENT_OVERLAPPING);
+ return false;
+ }
+ return true;
+ }
+} \ No newline at end of file