diff options
Diffstat (limited to '3rdparty/Sabre/VObject/Component')
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VAlarm.php | 34 | ||||
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VCalendar.php | 129 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Component/VCard.php | 105 | ||||
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VEvent.php | 21 | ||||
-rw-r--r-- | 3rdparty/Sabre/VObject/Component/VFreeBusy.php | 68 | ||||
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VJournal.php | 14 | ||||
-rw-r--r--[-rwxr-xr-x] | 3rdparty/Sabre/VObject/Component/VTodo.php | 14 |
7 files changed, 336 insertions, 49 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 { } } - -?> diff --git a/3rdparty/Sabre/VObject/Component/VCalendar.php b/3rdparty/Sabre/VObject/Component/VCalendar.php index f3be29afdbb..73f2f6d34fc 100755..100644 --- a/3rdparty/Sabre/VObject/Component/VCalendar.php +++ b/3rdparty/Sabre/VObject/Component/VCalendar.php @@ -1,17 +1,19 @@ <?php +namespace Sabre\VObject\Component; + +use Sabre\VObject; + /** * The VCalendar component * * This component adds functionality to a component, specific for a VCALENDAR. * - * @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_VCalendar extends Sabre_VObject_Component { +class VCalendar extends VObject\Component { /** * Returns a list of all 'base components'. For instance, if an Event has @@ -28,7 +30,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { $components = array(); foreach($this->children as $component) { - if (!$component instanceof Sabre_VObject_Component) + if (!$component instanceof VObject\Component) continue; if (isset($component->{'RECURRENCE-ID'})) @@ -69,7 +71,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { * @param DateTime $end * @return void */ - public function expand(DateTime $start, DateTime $end) { + public function expand(\DateTime $start, \DateTime $end) { $newEvents = array(); @@ -91,10 +93,10 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { $uid = (string)$vevent->uid; if (!$uid) { - throw new LogicException('Event did not have a UID!'); + throw new \LogicException('Event did not have a UID!'); } - $it = new Sabre_VObject_RecurrenceIterator($this, $vevent->uid); + $it = new VObject\RecurrenceIterator($this, $vevent->uid); $it->fastForward($start); while($it->valid() && $it->getDTStart() < $end) { @@ -114,9 +116,9 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { foreach($newEvents as $newEvent) { foreach($newEvent->children as $child) { - if ($child instanceof Sabre_VObject_Property_DateTime && - $child->getDateType() == Sabre_VObject_Property_DateTime::LOCALTZ) { - $child->setDateTime($child->getDateTime(),Sabre_VObject_Property_DateTime::UTC); + if ($child instanceof VObject\Property\DateTime && + $child->getDateType() == VObject\Property\DateTime::LOCALTZ) { + $child->setDateTime($child->getDateTime(),VObject\Property\DateTime::UTC); } } @@ -129,5 +131,112 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { } + /** + * Validates the node for correctness. + * An array is returned with warnings. + * + * Every item in the array has the following properties: + * * level - (number between 1 and 3 with severity information) + * * message - (human readable message) + * * node - (reference to the offending node) + * + * @return array + */ + /* + public function validate() { + + $warnings = array(); + + $version = $this->select('VERSION'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The VERSION property must appear in the VCALENDAR component exactly 1 time', + 'node' => $this, + ); + } else { + if ((string)$this->VERSION !== '2.0') { + $warnings[] = array( + 'level' => 1, + 'message' => 'Only iCalendar version 2.0 as defined in rfc5545 is supported.', + 'node' => $this, + ); + } + } + $version = $this->select('PRODID'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 2, + 'message' => 'The PRODID property must appear in the VCALENDAR component exactly 1 time', + 'node' => $this, + ); + } + if (count($this->CALSCALE) > 1) { + $warnings[] = array( + 'level' => 2, + 'message' => 'The CALSCALE property must not be specified more than once.', + 'node' => $this, + ); + } + if (count($this->METHOD) > 1) { + $warnings[] = array( + 'level' => 2, + 'message' => 'The METHOD property must not be specified more than once.', + 'node' => $this, + ); + } + + $allowedComponents = array( + 'VEVENT', + 'VTODO', + 'VJOURNAL', + 'VFREEBUSY', + 'VTIMEZONE', + ); + $allowedProperties = array( + 'PRODID', + 'VERSION', + 'CALSCALE', + 'METHOD', + ); + $componentsFound = 0; + foreach($this->children as $child) { + if($child instanceof Component) { + $componentsFound++; + if (!in_array($child->name, $allowedComponents)) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The ' . $child->name . " component is not allowed in the VCALENDAR component", + 'node' => $this, + ); + } + } + if ($child instanceof Property) { + if (!in_array($child->name, $allowedProperties)) { + $warnings[] = array( + 'level' => 2, + 'message' => 'The ' . $child->name . " property is not allowed in the VCALENDAR component", + 'node' => $this, + ); + } + } + } + + if ($componentsFound===0) { + $warnings[] = array( + 'level' => 1, + 'message' => 'An iCalendar object must have at least 1 component.', + 'node' => $this, + ); + } + + return array_merge( + $warnings, + parent::validate() + ); + + } + */ + } diff --git a/3rdparty/Sabre/VObject/Component/VCard.php b/3rdparty/Sabre/VObject/Component/VCard.php new file mode 100644 index 00000000000..b2926985550 --- /dev/null +++ b/3rdparty/Sabre/VObject/Component/VCard.php @@ -0,0 +1,105 @@ +<?php + +namespace Sabre\VObject\Component; + +use Sabre\VObject; + +/** + * The VCard component + * + * This component represents the BEGIN:VCARD and END:VCARD found in every + * vcard. + * + * @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 VCard extends VObject\Component { + + /** + * VCards with version 2.1, 3.0 and 4.0 are found. + * + * If the VCARD doesn't know its version, 4.0 is assumed. + */ + const DEFAULT_VERSION = '4.0'; + + /** + * Validates the node for correctness. + * + * The following options are supported: + * - Node::REPAIR - If something is broken, and automatic repair may + * be attempted. + * + * An array is returned with warnings. + * + * Every item in the array has the following properties: + * * level - (number between 1 and 3 with severity information) + * * message - (human readable message) + * * node - (reference to the offending node) + * + * @param int $options + * @return array + */ + public function validate($options = 0) { + + $warnings = array(); + + $version = $this->select('VERSION'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The VERSION property must appear in the VCARD component exactly 1 time', + 'node' => $this, + ); + if ($options & self::REPAIR) { + $this->VERSION = self::DEFAULT_VERSION; + } + } else { + $version = (string)$this->VERSION; + if ($version!=='2.1' && $version!=='3.0' && $version!=='4.0') { + $warnings[] = array( + 'level' => 1, + 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', + 'node' => $this, + ); + if ($options & self::REPAIR) { + $this->VERSION = '4.0'; + } + } + + } + $version = $this->select('FN'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The FN property must appear in the VCARD component exactly 1 time', + 'node' => $this, + ); + if (($options & self::REPAIR) && count($version) === 0) { + // We're going to try to see if we can use the contents of the + // N property. + if (isset($this->N)) { + $value = explode(';', (string)$this->N); + if (isset($value[1]) && $value[1]) { + $this->FN = $value[1] . ' ' . $value[0]; + } else { + $this->FN = $value[0]; + } + + // Otherwise, the ORG property may work + } elseif (isset($this->ORG)) { + $this->FN = (string)$this->ORG; + } + + } + } + + return array_merge( + parent::validate($options), + $warnings + ); + + } + +} + diff --git a/3rdparty/Sabre/VObject/Component/VEvent.php b/3rdparty/Sabre/VObject/Component/VEvent.php index d6b910874d0..9d10966e203 100755..100644 --- a/3rdparty/Sabre/VObject/Component/VEvent.php +++ b/3rdparty/Sabre/VObject/Component/VEvent.php @@ -1,17 +1,18 @@ <?php +namespace Sabre\VObject\Component; +use Sabre\VObject; + /** * VEvent component * * This component contains some additional functionality specific for VEVENT's. * - * @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_VEvent extends Sabre_VObject_Component { +class VEvent extends VObject\Component { /** * Returns true or false depending on if the event falls in the specified @@ -20,14 +21,14 @@ class Sabre_VObject_Component_VEvent 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) { if ($this->RRULE) { - $it = new Sabre_VObject_RecurrenceIterator($this); + $it = new VObject\RecurrenceIterator($this); $it->fastForward($start); // We fast-forwarded to a spot where the end-time of the @@ -53,8 +54,8 @@ class Sabre_VObject_Component_VEvent extends Sabre_VObject_Component { } elseif (isset($this->DURATION)) { $effectiveEnd = clone $effectiveStart; - $effectiveEnd->add( Sabre_VObject_DateTimeParser::parseDuration($this->DURATION) ); - } elseif ($this->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE) { + $effectiveEnd->add( VObject\DateTimeParser::parseDuration($this->DURATION) ); + } elseif ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) { $effectiveEnd = clone $effectiveStart; $effectiveEnd->modify('+1 day'); } else { @@ -67,5 +68,3 @@ class Sabre_VObject_Component_VEvent extends Sabre_VObject_Component { } } - -?> diff --git a/3rdparty/Sabre/VObject/Component/VFreeBusy.php b/3rdparty/Sabre/VObject/Component/VFreeBusy.php new file mode 100644 index 00000000000..d6da52cbd77 --- /dev/null +++ b/3rdparty/Sabre/VObject/Component/VFreeBusy.php @@ -0,0 +1,68 @@ +<?php + +namespace Sabre\VObject\Component; + +use Sabre\VObject; + +/** + * The VFreeBusy component + * + * This component adds functionality to a component, specific for VFREEBUSY + * components. + * + * @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 VFreeBusy extends VObject\Component { + + /** + * Checks based on the contained FREEBUSY information, if a timeslot is + * available. + * + * @param DateTime $start + * @param Datetime $end + * @return bool + */ + public function isFree(\DateTime $start, \Datetime $end) { + + foreach($this->select('FREEBUSY') as $freebusy) { + + // We are only interested in FBTYPE=BUSY (the default), + // FBTYPE=BUSY-TENTATIVE or FBTYPE=BUSY-UNAVAILABLE. + if (isset($freebusy['FBTYPE']) && strtoupper(substr((string)$freebusy['FBTYPE'],0,4))!=='BUSY') { + continue; + } + + // The freebusy component can hold more than 1 value, separated by + // commas. + $periods = explode(',', (string)$freebusy); + + foreach($periods as $period) { + // Every period is formatted as [start]/[end]. The start is an + // absolute UTC time, the end may be an absolute UTC time, or + // duration (relative) value. + list($busyStart, $busyEnd) = explode('/', $period); + + $busyStart = VObject\DateTimeParser::parse($busyStart); + $busyEnd = VObject\DateTimeParser::parse($busyEnd); + if ($busyEnd instanceof \DateInterval) { + $tmp = clone $busyStart; + $tmp->add($busyEnd); + $busyEnd = $tmp; + } + + if($start < $busyEnd && $end > $busyStart) { + return false; + } + + } + + } + + return true; + + } + +} + diff --git a/3rdparty/Sabre/VObject/Component/VJournal.php b/3rdparty/Sabre/VObject/Component/VJournal.php index 22b3ec921e5..f104a1f66ed 100755..100644 --- a/3rdparty/Sabre/VObject/Component/VJournal.php +++ b/3rdparty/Sabre/VObject/Component/VJournal.php @@ -1,17 +1,19 @@ <?php +namespace Sabre\VObject\Component; + +use Sabre\VObject; + /** * VJournal component * * This component contains some additional functionality specific for VJOURNALs. * - * @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_VJournal extends Sabre_VObject_Component { +class VJournal extends VObject\Component { /** * Returns true or false depending on if the event falls in the specified @@ -24,12 +26,12 @@ class Sabre_VObject_Component_VJournal extends Sabre_VObject_Component { * @param DateTime $end * @return bool */ - public function isInTimeRange(DateTime $start, DateTime $end) { + public function isInTimeRange(\DateTime $start, \DateTime $end) { $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null; if ($dtstart) { $effectiveEnd = clone $dtstart; - if ($this->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE) { + if ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) { $effectiveEnd->modify('+1 day'); } @@ -42,5 +44,3 @@ class Sabre_VObject_Component_VJournal extends Sabre_VObject_Component { } } - -?> diff --git a/3rdparty/Sabre/VObject/Component/VTodo.php b/3rdparty/Sabre/VObject/Component/VTodo.php index 79d06298d7f..5f879aea435 100755..100644 --- a/3rdparty/Sabre/VObject/Component/VTodo.php +++ b/3rdparty/Sabre/VObject/Component/VTodo.php @@ -1,17 +1,19 @@ <?php +namespace Sabre\VObject\Component; + +use Sabre\VObject; + /** * VTodo component * * This component contains some additional functionality specific for VTODOs. * - * @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_VTodo extends Sabre_VObject_Component { +class VTodo extends VObject\Component { /** * Returns true or false depending on if the event falls in the specified @@ -24,10 +26,10 @@ class Sabre_VObject_Component_VTodo extends Sabre_VObject_Component { * @param DateTime $end * @return bool */ - public function isInTimeRange(DateTime $start, DateTime $end) { + public function isInTimeRange(\DateTime $start, \DateTime $end) { $dtstart = isset($this->DTSTART)?$this->DTSTART->getDateTime():null; - $duration = isset($this->DURATION)?Sabre_VObject_DateTimeParser::parseDuration($this->DURATION):null; + $duration = isset($this->DURATION)?VObject\DateTimeParser::parseDuration($this->DURATION):null; $due = isset($this->DUE)?$this->DUE->getDateTime():null; $completed = isset($this->COMPLETED)?$this->COMPLETED->getDateTime():null; $created = isset($this->CREATED)?$this->CREATED->getDateTime():null; @@ -64,5 +66,3 @@ class Sabre_VObject_Component_VTodo extends Sabre_VObject_Component { } } - -?> |