Available.php
6 months ago
VAlarm.php
6 months ago
VAvailability.php
6 months ago
VCalendar.php
6 months ago
VCard.php
6 months ago
VEvent.php
6 months ago
VFreeBusy.php
6 months ago
VJournal.php
6 months ago
VTimeZone.php
6 months ago
VTodo.php
6 months ago
VJournal.php
102 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaVendor\Sabre\VObject\Component; |
| 4 | |
| 5 | use DateTimeInterface; |
| 6 | use AmeliaVendor\Sabre\VObject; |
| 7 | |
| 8 | /** |
| 9 | * VJournal component. |
| 10 | * |
| 11 | * This component contains some additional functionality specific for VJOURNALs. |
| 12 | * |
| 13 | * @copyright Copyright (C) fruux GmbH (https://fruux.com/) |
| 14 | * @author Evert Pot (http://evertpot.com/) |
| 15 | * @license http://sabre.io/license/ Modified BSD License |
| 16 | */ |
| 17 | class VJournal extends VObject\Component |
| 18 | { |
| 19 | /** |
| 20 | * Returns true or false depending on if the event falls in the specified |
| 21 | * time-range. This is used for filtering purposes. |
| 22 | * |
| 23 | * The rules used to determine if an event falls within the specified |
| 24 | * time-range is based on the CalDAV specification. |
| 25 | * |
| 26 | * @return bool |
| 27 | */ |
| 28 | public function isInTimeRange(DateTimeInterface $start, DateTimeInterface $end) |
| 29 | { |
| 30 | $dtstart = isset($this->DTSTART) ? $this->DTSTART->getDateTime() : null; |
| 31 | if ($dtstart) { |
| 32 | $effectiveEnd = $dtstart; |
| 33 | if (!$this->DTSTART->hasTime()) { |
| 34 | $effectiveEnd = $effectiveEnd->modify('+1 day'); |
| 35 | } |
| 36 | |
| 37 | return $start <= $effectiveEnd && $end > $dtstart; |
| 38 | } |
| 39 | |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * A simple list of validation rules. |
| 45 | * |
| 46 | * This is simply a list of properties, and how many times they either |
| 47 | * must or must not appear. |
| 48 | * |
| 49 | * Possible values per property: |
| 50 | * * 0 - Must not appear. |
| 51 | * * 1 - Must appear exactly once. |
| 52 | * * + - Must appear at least once. |
| 53 | * * * - Can appear any number of times. |
| 54 | * * ? - May appear, but not more than once. |
| 55 | * |
| 56 | * @var array |
| 57 | */ |
| 58 | public function getValidationRules() |
| 59 | { |
| 60 | return [ |
| 61 | 'UID' => 1, |
| 62 | 'DTSTAMP' => 1, |
| 63 | |
| 64 | 'CLASS' => '?', |
| 65 | 'CREATED' => '?', |
| 66 | 'DTSTART' => '?', |
| 67 | 'LAST-MODIFIED' => '?', |
| 68 | 'ORGANIZER' => '?', |
| 69 | 'RECURRENCE-ID' => '?', |
| 70 | 'SEQUENCE' => '?', |
| 71 | 'STATUS' => '?', |
| 72 | 'SUMMARY' => '?', |
| 73 | 'URL' => '?', |
| 74 | |
| 75 | 'RRULE' => '?', |
| 76 | |
| 77 | 'ATTACH' => '*', |
| 78 | 'ATTENDEE' => '*', |
| 79 | 'CATEGORIES' => '*', |
| 80 | 'COMMENT' => '*', |
| 81 | 'CONTACT' => '*', |
| 82 | 'DESCRIPTION' => '*', |
| 83 | 'EXDATE' => '*', |
| 84 | 'RELATED-TO' => '*', |
| 85 | 'RDATE' => '*', |
| 86 | ]; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * This method should return a list of default property values. |
| 91 | * |
| 92 | * @return array |
| 93 | */ |
| 94 | protected function getDefaults() |
| 95 | { |
| 96 | return [ |
| 97 | 'UID' => 'sabre-vobject-'.VObject\UUIDUtil::getUUID(), |
| 98 | 'DTSTAMP' => gmdate('Ymd\\THis\\Z'), |
| 99 | ]; |
| 100 | } |
| 101 | } |
| 102 |