annotate plugins/libcalendaring/lib/Sabre/VObject/Component/VCalendar.php @ 4:888e774ee983

libcalendar plugin as distributed
author Charlie Root
date Sat, 13 Jan 2018 08:57:56 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
1 <?php
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
2
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
3 namespace Sabre\VObject\Component;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
4
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
5 use Sabre\VObject;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
6
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
7 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
8 * The VCalendar component
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
9 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
10 * This component adds functionality to a component, specific for a VCALENDAR.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
11 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
12 * @copyright Copyright (C) 2007-2013 fruux GmbH (https://fruux.com/).
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
13 * @author Evert Pot (http://evertpot.com/)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
14 * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
15 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
16 class VCalendar extends VObject\Document {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
17
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
18 static $defaultName = 'VCALENDAR';
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
19
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
20 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
21 * Returns a list of all 'base components'. For instance, if an Event has
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
22 * a recurrence rule, and one instance is overridden, the overridden event
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
23 * will have the same UID, but will be excluded from this list.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
24 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
25 * VTIMEZONE components will always be excluded.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
26 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
27 * @param string $componentName filter by component name
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
28 * @return array
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
29 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
30 public function getBaseComponents($componentName = null) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
31
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
32 $components = array();
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
33 foreach($this->children as $component) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
34
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
35 if (!$component instanceof VObject\Component)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
36 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
37
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
38 if (isset($component->{'RECURRENCE-ID'}))
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
39 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
40
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
41 if ($componentName && $component->name !== strtoupper($componentName))
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
42 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
43
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
44 if ($component->name === 'VTIMEZONE')
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
45 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
46
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
47 $components[] = $component;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
48
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
49 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
50
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
51 return $components;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
52
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
53 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
54
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
55 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
56 * If this calendar object, has events with recurrence rules, this method
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
57 * can be used to expand the event into multiple sub-events.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
58 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
59 * Each event will be stripped from it's recurrence information, and only
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
60 * the instances of the event in the specified timerange will be left
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
61 * alone.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
62 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
63 * In addition, this method will cause timezone information to be stripped,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
64 * and normalized to UTC.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
65 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
66 * This method will alter the VCalendar. This cannot be reversed.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
67 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
68 * This functionality is specifically used by the CalDAV standard. It is
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
69 * possible for clients to request expand events, if they are rather simple
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
70 * clients and do not have the possibility to calculate recurrences.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
71 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
72 * @param DateTime $start
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
73 * @param DateTime $end
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
74 * @return void
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
75 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
76 public function expand(\DateTime $start, \DateTime $end) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
77
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
78 $newEvents = array();
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
79
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
80 foreach($this->select('VEVENT') as $key=>$vevent) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
81
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
82 if (isset($vevent->{'RECURRENCE-ID'})) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
83 unset($this->children[$key]);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
84 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
85 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
86
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
87
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
88 if (!$vevent->rrule) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
89 unset($this->children[$key]);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
90 if ($vevent->isInTimeRange($start, $end)) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
91 $newEvents[] = $vevent;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
92 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
93 continue;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
94 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
95
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
96 $uid = (string)$vevent->uid;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
97 if (!$uid) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
98 throw new \LogicException('Event did not have a UID!');
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
99 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
100
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
101 $it = new VObject\RecurrenceIterator($this, $vevent->uid);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
102 $it->fastForward($start);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
103
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
104 while($it->valid() && $it->getDTStart() < $end) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
105
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
106 if ($it->getDTEnd() > $start) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
107
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
108 $newEvents[] = $it->getEventObject();
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
109
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
110 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
111 $it->next();
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
112
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
113 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
114 unset($this->children[$key]);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
115
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
116 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
117
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
118 foreach($newEvents as $newEvent) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
119
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
120 foreach($newEvent->children as $child) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
121 if ($child instanceof VObject\Property\DateTime &&
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
122 $child->getDateType() == VObject\Property\DateTime::LOCALTZ) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
123 $child->setDateTime($child->getDateTime(),VObject\Property\DateTime::UTC);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
124 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
125 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
126
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
127 $this->add($newEvent);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
128
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
129 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
130
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
131 // Removing all VTIMEZONE components
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
132 unset($this->VTIMEZONE);
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
133
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
134 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
135
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
136 /**
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
137 * Validates the node for correctness.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
138 * An array is returned with warnings.
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
139 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
140 * Every item in the array has the following properties:
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
141 * * level - (number between 1 and 3 with severity information)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
142 * * message - (human readable message)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
143 * * node - (reference to the offending node)
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
144 *
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
145 * @return array
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
146 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
147 /*
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
148 public function validate() {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
149
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
150 $warnings = array();
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
151
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
152 $version = $this->select('VERSION');
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
153 if (count($version)!==1) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
154 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
155 'level' => 1,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
156 'message' => 'The VERSION property must appear in the VCALENDAR component exactly 1 time',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
157 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
158 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
159 } else {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
160 if ((string)$this->VERSION !== '2.0') {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
161 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
162 'level' => 1,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
163 'message' => 'Only iCalendar version 2.0 as defined in rfc5545 is supported.',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
164 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
165 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
166 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
167 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
168 $version = $this->select('PRODID');
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
169 if (count($version)!==1) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
170 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
171 'level' => 2,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
172 'message' => 'The PRODID property must appear in the VCALENDAR component exactly 1 time',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
173 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
174 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
175 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
176 if (count($this->CALSCALE) > 1) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
177 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
178 'level' => 2,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
179 'message' => 'The CALSCALE property must not be specified more than once.',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
180 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
181 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
182 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
183 if (count($this->METHOD) > 1) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
184 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
185 'level' => 2,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
186 'message' => 'The METHOD property must not be specified more than once.',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
187 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
188 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
189 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
190
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
191 $allowedComponents = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
192 'VEVENT',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
193 'VTODO',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
194 'VJOURNAL',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
195 'VFREEBUSY',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
196 'VTIMEZONE',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
197 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
198 $allowedProperties = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
199 'PRODID',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
200 'VERSION',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
201 'CALSCALE',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
202 'METHOD',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
203 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
204 $componentsFound = 0;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
205 foreach($this->children as $child) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
206 if($child instanceof Component) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
207 $componentsFound++;
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
208 if (!in_array($child->name, $allowedComponents)) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
209 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
210 'level' => 1,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
211 'message' => 'The ' . $child->name . " component is not allowed in the VCALENDAR component",
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
212 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
213 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
214 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
215 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
216 if ($child instanceof Property) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
217 if (!in_array($child->name, $allowedProperties)) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
218 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
219 'level' => 2,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
220 'message' => 'The ' . $child->name . " property is not allowed in the VCALENDAR component",
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
221 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
222 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
223 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
224 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
225 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
226
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
227 if ($componentsFound===0) {
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
228 $warnings[] = array(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
229 'level' => 1,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
230 'message' => 'An iCalendar object must have at least 1 component.',
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
231 'node' => $this,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
232 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
233 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
234
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
235 return array_merge(
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
236 $warnings,
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
237 parent::validate()
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
238 );
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
239
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
240 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
241 */
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
242
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
243 }
888e774ee983 libcalendar plugin as distributed
Charlie Root
parents:
diff changeset
244