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