diff options
Diffstat (limited to '3rdparty/Sabre/VObject/Component/VAlarm.php')
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VAlarm.php | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/3rdparty/Sabre/VObject/Component/VAlarm.php b/3rdparty/Sabre/VObject/Component/VAlarm.php index ebb4a9b18f6..383e16eef14 100755..100644 --- a/3rdparty/Sabre/VObject/Component/VAlarm.php +++ b/3rdparty/Sabre/VObject/Component/VAlarm.php @@ -1,17 +1,18 @@ <?php +namespace Sabre\VObject\Component; +use Sabre\VObject; + /** * VAlarm component * * This component contains some additional functionality specific for VALARMs. * - * @package Sabre - * @subpackage VObject * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { +class VAlarm extends VObject\Component { /** * Returns a DateTime object when this alarm is going to trigger. @@ -24,12 +25,19 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { $trigger = $this->TRIGGER; if(!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') { - $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($this->TRIGGER); + $triggerDuration = VObject\DateTimeParser::parseDuration($this->TRIGGER); $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START'; $parentComponent = $this->parent; if ($related === 'START') { - $effectiveTrigger = clone $parentComponent->DTSTART->getDateTime(); + + if ($parentComponent->name === 'VTODO') { + $propName = 'DUE'; + } else { + $propName = 'DTSTART'; + } + + $effectiveTrigger = clone $parentComponent->$propName->getDateTime(); $effectiveTrigger->add($triggerDuration); } else { if ($parentComponent->name === 'VTODO') { @@ -37,7 +45,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { } elseif ($parentComponent->name === 'VEVENT') { $endProp = 'DTEND'; } else { - throw new Sabre_DAV_Exception('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT'); + throw new \LogicException('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT'); } if (isset($parentComponent->$endProp)) { @@ -45,7 +53,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { $effectiveTrigger->add($triggerDuration); } elseif (isset($parentComponent->DURATION)) { $effectiveTrigger = clone $parentComponent->DTSTART->getDateTime(); - $duration = Sabre_VObject_DateTimeParser::parseDuration($parentComponent->DURATION); + $duration = VObject\DateTimeParser::parseDuration($parentComponent->DURATION); $effectiveTrigger->add($duration); $effectiveTrigger->add($triggerDuration); } else { @@ -67,22 +75,22 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { * The rules used to determine if an event falls within the specified * time-range is based on the CalDAV specification. * - * @param DateTime $start - * @param DateTime $end + * @param \DateTime $start + * @param \DateTime $end * @return bool */ - public function isInTimeRange(DateTime $start, DateTime $end) { + public function isInTimeRange(\DateTime $start, \DateTime $end) { $effectiveTrigger = $this->getEffectiveTriggerTime(); if (isset($this->DURATION)) { - $duration = Sabre_VObject_DateTimeParser::parseDuration($this->DURATION); + $duration = VObject\DateTimeParser::parseDuration($this->DURATION); $repeat = (string)$this->repeat; if (!$repeat) { $repeat = 1; } - $period = new DatePeriod($effectiveTrigger, $duration, (int)$repeat); + $period = new \DatePeriod($effectiveTrigger, $duration, (int)$repeat); foreach($period as $occurrence) { @@ -98,5 +106,3 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { } } - -?> |