From 767620295b5144d82edff74016a8722c3349e6d0 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Mon, 24 Oct 2011 13:01:31 +0200 Subject: verschiedenes --- library/Poolctrl/Validator/DateGreaterThan.php | 2 +- library/Poolctrl/Validator/EventOverlapping.php | 72 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 library/Poolctrl/Validator/EventOverlapping.php (limited to 'library') 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 @@ + "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 -- cgit v1.2.3-55-g7522