1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - iCalendar Parser * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Written by Mark Peters <skeeter@phpgroupware.org> * |
---|
6 | * -------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | |
---|
14 | define('FOLD_LENGTH',75); |
---|
15 | |
---|
16 | define('VEVENT',1); |
---|
17 | define('VTODO',2); |
---|
18 | |
---|
19 | define('NONE',0); |
---|
20 | define('CHAIR',1); |
---|
21 | define('REQ_PARTICIPANT',2); |
---|
22 | define('OPT_PARTICIPANT',3); |
---|
23 | define('NON_PARTICIPANT',4); |
---|
24 | |
---|
25 | define('INDIVIDUAL',1); |
---|
26 | define('GROUP',2); |
---|
27 | define('RESOURCE',4); |
---|
28 | define('ROOM',8); |
---|
29 | define('UNKNOWN',16); |
---|
30 | |
---|
31 | define('NEEDS_ACTION',0); |
---|
32 | define('ACCEPTED',1); |
---|
33 | define('DECLINED',2); |
---|
34 | define('TENTATIVE',3); |
---|
35 | define('DELEGATED',4); |
---|
36 | define('COMPLETED',5); |
---|
37 | define('IN_PROCESS',6); |
---|
38 | |
---|
39 | /* |
---|
40 | * Class |
---|
41 | */ |
---|
42 | define('_PRIVATE',0); |
---|
43 | define('_PUBLIC',1); |
---|
44 | define('_CONFIDENTIAL',3); |
---|
45 | |
---|
46 | /* |
---|
47 | * Transparency |
---|
48 | */ |
---|
49 | define('TRANSPARENT',0); |
---|
50 | define('OPAQUE',1); |
---|
51 | |
---|
52 | /* |
---|
53 | * Frequency |
---|
54 | */ |
---|
55 | define('SECONDLY',1); |
---|
56 | define('MINUTELY',2); |
---|
57 | define('HOURLY',3); |
---|
58 | define('DAILY',4); |
---|
59 | define('WEEKLY',5); |
---|
60 | define('MONTHLY',6); |
---|
61 | define('YEARLY',7); |
---|
62 | |
---|
63 | define('FREE',0); |
---|
64 | define('BUSY',1); |
---|
65 | define('BUSY_UNAVAILABLE',2); |
---|
66 | define('BUSY_TENTATIVE',3); |
---|
67 | |
---|
68 | define('THISANDPRIOR',0); |
---|
69 | define('THISANDFUTURE',1); |
---|
70 | |
---|
71 | define('START',0); |
---|
72 | define('END',1); |
---|
73 | |
---|
74 | define('_8BIT',0); |
---|
75 | define('_BASE64',1); |
---|
76 | |
---|
77 | define('OTHER',99); |
---|
78 | |
---|
79 | class boicalendar |
---|
80 | { |
---|
81 | var $public_functions = array( |
---|
82 | 'import' => True, |
---|
83 | 'export' => True, |
---|
84 | 'freebusy' => True, |
---|
85 | ); |
---|
86 | |
---|
87 | var $ical; |
---|
88 | var $line = 0; |
---|
89 | var $event = Array(); |
---|
90 | var $todo = Array(); |
---|
91 | var $journal = Array(); |
---|
92 | var $freebusy = Array(); |
---|
93 | var $timezone = Array(); |
---|
94 | var $property = Array(); |
---|
95 | var $parameter = Array(); |
---|
96 | var $debug_str = False; |
---|
97 | var $api = True; |
---|
98 | var $chunk_split = True; |
---|
99 | |
---|
100 | /* |
---|
101 | * Base Functions |
---|
102 | */ |
---|
103 | |
---|
104 | function boicalendar() |
---|
105 | { |
---|
106 | $this->property = Array( |
---|
107 | 'action' => Array( |
---|
108 | 'type' => 'text', |
---|
109 | 'to_text' => True, |
---|
110 | 'valarm' => Array( |
---|
111 | 'state' => 'required', |
---|
112 | 'multiples' => False |
---|
113 | ) |
---|
114 | ), |
---|
115 | 'attach' => Array( |
---|
116 | 'type' => 'uri', |
---|
117 | 'to_text' => True, |
---|
118 | 'vevent' => Array( |
---|
119 | 'state' => 'optional', |
---|
120 | 'multiples' => True |
---|
121 | ), |
---|
122 | 'vtodo' => Array( |
---|
123 | 'state' => 'optional', |
---|
124 | 'multiples' => True |
---|
125 | ), |
---|
126 | 'vjournal' => Array( |
---|
127 | 'state' => 'optional', |
---|
128 | 'multiples' => True |
---|
129 | ), |
---|
130 | 'valarm' => Array( |
---|
131 | 'state' => 'optional', |
---|
132 | 'multiples' => True |
---|
133 | ) |
---|
134 | ), |
---|
135 | 'attendee' => Array( |
---|
136 | 'type' => 'cal-address', |
---|
137 | 'to_text' => False, |
---|
138 | 'vevent' => Array( |
---|
139 | 'state' => 'optional', |
---|
140 | 'multiples' => True |
---|
141 | ), |
---|
142 | 'vtodo' => Array( |
---|
143 | 'state' => 'optional', |
---|
144 | 'multiples' => True |
---|
145 | ), |
---|
146 | 'vjournal' => Array( |
---|
147 | 'state' => 'optional', |
---|
148 | 'multiples' => True |
---|
149 | ), |
---|
150 | 'valarm' => Array( |
---|
151 | 'state' => 'optional', |
---|
152 | 'multiples' => True |
---|
153 | ), |
---|
154 | 'vfreebusy' => Array( |
---|
155 | 'state' => 'optional', |
---|
156 | 'multiples' => True |
---|
157 | ) |
---|
158 | ), |
---|
159 | 'categories' => Array( |
---|
160 | 'type' => 'text', |
---|
161 | 'to_text' => True, |
---|
162 | 'vevent' => Array( |
---|
163 | 'state' => 'optional', |
---|
164 | 'multiples' => True |
---|
165 | ), |
---|
166 | 'vtodo' => Array( |
---|
167 | 'state' => 'optional', |
---|
168 | 'multiples' => False |
---|
169 | ), |
---|
170 | 'vjournal' => Array( |
---|
171 | 'state' => 'optional', |
---|
172 | 'multiples' => True |
---|
173 | ) |
---|
174 | ), |
---|
175 | 'class' => Array( |
---|
176 | 'type' => 'text', |
---|
177 | 'to_text' => True, |
---|
178 | 'vevent' => Array( |
---|
179 | 'state' => 'optional', |
---|
180 | 'multiples' => False |
---|
181 | ), |
---|
182 | 'vtodo' => Array( |
---|
183 | 'state' => 'optional', |
---|
184 | 'multiples' => False |
---|
185 | ), |
---|
186 | 'vjournal' => Array( |
---|
187 | 'state' => 'optional', |
---|
188 | 'multiples' => False |
---|
189 | ) |
---|
190 | ), |
---|
191 | 'comment' => Array( |
---|
192 | 'type' => 'text', |
---|
193 | 'to_text' => True, |
---|
194 | 'daylight' => Array( |
---|
195 | 'state' => 'optional', |
---|
196 | 'multiples' => True |
---|
197 | ), |
---|
198 | 'standard' => Array( |
---|
199 | 'state' => 'optional', |
---|
200 | 'multiples' => True |
---|
201 | ), |
---|
202 | 'valarm' => Array( |
---|
203 | 'state' => 'optional', |
---|
204 | 'multiples' => True |
---|
205 | ), |
---|
206 | 'vevent' => Array( |
---|
207 | 'state' => 'optional', |
---|
208 | 'multiples' => True |
---|
209 | ), |
---|
210 | 'vfreebusy' => Array( |
---|
211 | 'state' => 'optional', |
---|
212 | 'multiples' => True |
---|
213 | ), |
---|
214 | 'vjournal' => Array( |
---|
215 | 'state' => 'optional', |
---|
216 | 'multiples' => True |
---|
217 | ), |
---|
218 | 'vtodo' => Array( |
---|
219 | 'state' => 'optional', |
---|
220 | 'multiples' => True |
---|
221 | ) |
---|
222 | ), |
---|
223 | 'completed' => Array( |
---|
224 | 'type' => 'date-time', |
---|
225 | 'to_text' => False, |
---|
226 | 'vtodo' => Array( |
---|
227 | 'state' => 'optional', |
---|
228 | 'multiples' => False |
---|
229 | ) |
---|
230 | ), |
---|
231 | 'contact' => Array( |
---|
232 | 'type' => 'text', |
---|
233 | 'to_text' => True, |
---|
234 | 'vevent' => Array( |
---|
235 | 'state' => 'optional', |
---|
236 | 'multiples' => True |
---|
237 | ), |
---|
238 | 'vfreebusy' => Array( |
---|
239 | 'state' => 'optional', |
---|
240 | 'multiples' => False |
---|
241 | ), |
---|
242 | 'vjournal' => Array( |
---|
243 | 'state' => 'optional', |
---|
244 | 'multiples' => True |
---|
245 | ) |
---|
246 | ), |
---|
247 | 'created' => Array( |
---|
248 | 'type' => 'date-time', |
---|
249 | 'to_text' => False, |
---|
250 | 'vevent' => Array( |
---|
251 | 'state' => 'optional', |
---|
252 | 'multiples' => False |
---|
253 | ), |
---|
254 | 'vtodo' => Array( |
---|
255 | 'state' => 'optional', |
---|
256 | 'multiples' => False |
---|
257 | ), |
---|
258 | 'vjournal' => Array( |
---|
259 | 'state' => 'optional', |
---|
260 | 'multiples' => False |
---|
261 | ) |
---|
262 | ), |
---|
263 | 'description' => Array( |
---|
264 | 'type' => 'text', |
---|
265 | 'to_text' => True, |
---|
266 | 'vevent' => Array( |
---|
267 | 'state' => 'optional', |
---|
268 | 'multiples' => False |
---|
269 | ), |
---|
270 | 'vtodo' => Array( |
---|
271 | 'state' => 'optional', |
---|
272 | 'multiples' => False |
---|
273 | ), |
---|
274 | 'vjournal' => Array( |
---|
275 | 'state' => 'optional', |
---|
276 | 'multiples' => True |
---|
277 | ), |
---|
278 | 'valarm' => Array( |
---|
279 | 'state' => 'optional', |
---|
280 | 'multiples' => False |
---|
281 | ) |
---|
282 | ), |
---|
283 | 'dtend' => Array( |
---|
284 | 'type' => 'date-time', |
---|
285 | 'to_text' => False, |
---|
286 | 'vevent' => Array( |
---|
287 | 'state' => 'optional', |
---|
288 | 'multiples' => False |
---|
289 | ), |
---|
290 | 'vfreebusy' => Array( |
---|
291 | 'state' => 'optional', |
---|
292 | 'multiples' => False |
---|
293 | ) |
---|
294 | ), |
---|
295 | 'dtstamp' => Array( |
---|
296 | 'type' => 'date-time', |
---|
297 | 'to_text' => False, |
---|
298 | 'vevent' => Array( |
---|
299 | 'state' => 'optional', |
---|
300 | 'multiples' => False |
---|
301 | ), |
---|
302 | 'vtodo' => Array( |
---|
303 | 'state' => 'optional', |
---|
304 | 'multiples' => False |
---|
305 | ), |
---|
306 | 'vjournal' => Array( |
---|
307 | 'state' => 'optional', |
---|
308 | 'multiples' => True |
---|
309 | ), |
---|
310 | 'vfreebusy' => Array( |
---|
311 | 'state' => 'optional', |
---|
312 | 'multiples' => False |
---|
313 | ) |
---|
314 | ), |
---|
315 | 'dtstart' => Array( |
---|
316 | 'type' => 'date-time', |
---|
317 | 'to_text' => False, |
---|
318 | 'daylight' => Array( |
---|
319 | 'state' => 'required', |
---|
320 | 'multiples' => False |
---|
321 | ), |
---|
322 | 'standard' => Array( |
---|
323 | 'state' => 'required', |
---|
324 | 'multiples' => False |
---|
325 | ), |
---|
326 | 'vevent' => Array( |
---|
327 | 'state' => 'optional', |
---|
328 | 'multiples' => False |
---|
329 | ), |
---|
330 | 'vfreebusy' => Array( |
---|
331 | 'state' => 'optional', |
---|
332 | 'multiples' => False |
---|
333 | ), |
---|
334 | 'vjournal' => Array( |
---|
335 | 'state' => 'optional', |
---|
336 | 'multiples' => False |
---|
337 | ), |
---|
338 | 'vtodo' => Array( |
---|
339 | 'state' => 'optional', |
---|
340 | 'multiples' => False |
---|
341 | ) |
---|
342 | ), |
---|
343 | 'due' => Array( |
---|
344 | 'type' => 'date-time', |
---|
345 | 'to_text' => False, |
---|
346 | 'vtodo' => Array( |
---|
347 | 'state' => 'optional', |
---|
348 | 'multiples' => False |
---|
349 | ) |
---|
350 | ), |
---|
351 | 'duration' => Array( |
---|
352 | 'type' => 'duration', |
---|
353 | 'to_text' => False, |
---|
354 | 'valarm' => Array( |
---|
355 | 'state' => 'optional', |
---|
356 | 'multiples' => False |
---|
357 | ), |
---|
358 | 'vevent' => Array( |
---|
359 | 'state' => 'optional', |
---|
360 | 'multiples' => False |
---|
361 | ), |
---|
362 | 'vfreebusy' => Array( |
---|
363 | 'state' => 'optional', |
---|
364 | 'multiples' => False |
---|
365 | ), |
---|
366 | 'vtodo' => Array( |
---|
367 | 'state' => 'optional', |
---|
368 | 'multiples' => False |
---|
369 | ) |
---|
370 | ), |
---|
371 | 'exdate' => Array( |
---|
372 | 'type' => 'date-time', |
---|
373 | 'to_text' => False, |
---|
374 | 'vevent' => Array( |
---|
375 | 'state' => 'optional', |
---|
376 | 'multiples' => True |
---|
377 | ), |
---|
378 | 'vjournal' => Array( |
---|
379 | 'state' => 'optional', |
---|
380 | 'multiples' => True |
---|
381 | ), |
---|
382 | 'vtodo' => Array( |
---|
383 | 'state' => 'optional', |
---|
384 | 'multiples' => True |
---|
385 | ) |
---|
386 | ), |
---|
387 | 'exrule' => Array( |
---|
388 | 'type' => 'recur', |
---|
389 | 'to_text' => False, |
---|
390 | 'vevent' => Array( |
---|
391 | 'state' => 'optional', |
---|
392 | 'multiples' => True |
---|
393 | ), |
---|
394 | 'vjournal' => Array( |
---|
395 | 'state' => 'optional', |
---|
396 | 'multiples' => True |
---|
397 | ), |
---|
398 | 'vtodo' => Array( |
---|
399 | 'state' => 'optional', |
---|
400 | 'multiples' => True |
---|
401 | ) |
---|
402 | ), |
---|
403 | 'freebusy' => Array( |
---|
404 | 'type' => 'freebusy', |
---|
405 | 'to_text' => False, |
---|
406 | 'vfreebusy' => Array( |
---|
407 | 'state' => 'optional', |
---|
408 | 'multiples' => True |
---|
409 | ) |
---|
410 | ), |
---|
411 | 'geo' => Array( |
---|
412 | 'type' => 'float', |
---|
413 | 'to_text' => True, |
---|
414 | 'vevent' => Array( |
---|
415 | 'state' => 'optional', |
---|
416 | 'multiples' => False |
---|
417 | ), |
---|
418 | 'vtodo' => Array( |
---|
419 | 'state' => 'optional', |
---|
420 | 'multiples' => False |
---|
421 | ) |
---|
422 | ), |
---|
423 | 'last_modified' => Array( |
---|
424 | 'type' => 'date-time', |
---|
425 | 'to_text' => False, |
---|
426 | 'vevent' => Array( |
---|
427 | 'state' => 'optional', |
---|
428 | 'multiples' => False |
---|
429 | ), |
---|
430 | 'vtodo' => Array( |
---|
431 | 'state' => 'optional', |
---|
432 | 'multiples' => False |
---|
433 | ), |
---|
434 | 'vjournal' => Array( |
---|
435 | 'state' => 'optional', |
---|
436 | 'multiples' => False |
---|
437 | ), |
---|
438 | 'vtimezone' => Array( |
---|
439 | 'state' => 'optional', |
---|
440 | 'multiples' => False |
---|
441 | ) |
---|
442 | ), |
---|
443 | 'location' => Array( |
---|
444 | 'type' => 'text', |
---|
445 | 'to_text' => True, |
---|
446 | 'vevent' => Array( |
---|
447 | 'state' => 'optional', |
---|
448 | 'multiples' => False |
---|
449 | ), |
---|
450 | 'vtodo' => Array( |
---|
451 | 'state' => 'optional', |
---|
452 | 'multiples' => False |
---|
453 | ) |
---|
454 | ), |
---|
455 | 'method' => Array( |
---|
456 | 'type' => 'text', |
---|
457 | 'to_text' => True, |
---|
458 | 'ical' => Array( |
---|
459 | 'state' => 'required', |
---|
460 | 'multiples' => False |
---|
461 | ) |
---|
462 | ), |
---|
463 | 'organizer' => Array( |
---|
464 | 'type' => 'cal-address', |
---|
465 | 'to_text' => False, |
---|
466 | 'vevent' => Array( |
---|
467 | 'state' => 'optional', |
---|
468 | 'multiples' => False |
---|
469 | ), |
---|
470 | 'vtodo' => Array( |
---|
471 | 'state' => 'optional', |
---|
472 | 'multiples' => False |
---|
473 | ), |
---|
474 | 'vjournal' => Array( |
---|
475 | 'state' => 'optional', |
---|
476 | 'multiples' => False |
---|
477 | ), |
---|
478 | 'vfreebusy' => Array( |
---|
479 | 'state' => 'optional', |
---|
480 | 'multiples' => False |
---|
481 | ) |
---|
482 | ), |
---|
483 | 'percent_complete' => Array( |
---|
484 | 'type' => 'integer', |
---|
485 | 'to_text' => False, |
---|
486 | 'vtodo' => Array( |
---|
487 | 'state' => 'optional', |
---|
488 | 'multiples' => False |
---|
489 | ) |
---|
490 | ), |
---|
491 | 'priority' => Array( |
---|
492 | 'type' => 'integer', |
---|
493 | 'to_text' => True, |
---|
494 | 'vevent' => Array( |
---|
495 | 'state' => 'optional', |
---|
496 | 'multiples' => False |
---|
497 | ), |
---|
498 | 'vtodo' => Array( |
---|
499 | 'state' => 'optional', |
---|
500 | 'multiples' => False |
---|
501 | ) |
---|
502 | ), |
---|
503 | 'prodid' => Array( |
---|
504 | 'type' => 'text', |
---|
505 | 'to_text' => True, |
---|
506 | 'ical' => Array( |
---|
507 | 'state' => 'required', |
---|
508 | 'multiples' => False |
---|
509 | ) |
---|
510 | ), |
---|
511 | 'rdate' => Array( |
---|
512 | 'type' => 'date-time', |
---|
513 | 'to_text' => False, |
---|
514 | 'daylight' => Array( |
---|
515 | 'state' => 'optional', |
---|
516 | 'multiples' => True |
---|
517 | ), |
---|
518 | 'standard' => Array( |
---|
519 | 'state' => 'optional', |
---|
520 | 'multiples' => True |
---|
521 | ), |
---|
522 | 'vevent' => Array( |
---|
523 | 'state' => 'optional', |
---|
524 | 'multiples' => True |
---|
525 | ), |
---|
526 | 'vtodo' => Array( |
---|
527 | 'state' => 'optional', |
---|
528 | 'multiples' => True |
---|
529 | ), |
---|
530 | 'vjournal' => Array( |
---|
531 | 'state' => 'optional', |
---|
532 | 'multiples' => True |
---|
533 | ) |
---|
534 | ), |
---|
535 | 'recurrence_id' => Array( |
---|
536 | 'type' => 'date-time', |
---|
537 | 'to_text' => False, |
---|
538 | 'vevent' => Array( |
---|
539 | 'state' => 'optional', |
---|
540 | 'multiples' => False |
---|
541 | ), |
---|
542 | 'vjournal' => Array( |
---|
543 | 'state' => 'optional', |
---|
544 | 'multiples' => False |
---|
545 | ), |
---|
546 | 'vtodo' => Array( |
---|
547 | 'state' => 'optional', |
---|
548 | 'multiples' => False |
---|
549 | ) |
---|
550 | ), |
---|
551 | 'related_to' => Array( |
---|
552 | 'type' => 'text', |
---|
553 | 'to_text' => False, |
---|
554 | 'vevent' => Array( |
---|
555 | 'state' => 'optional', |
---|
556 | 'multiples' => False |
---|
557 | ), |
---|
558 | 'vjournal' => Array( |
---|
559 | 'state' => 'optional', |
---|
560 | 'multiples' => True |
---|
561 | ), |
---|
562 | 'vtodo' => Array( |
---|
563 | 'state' => 'optional', |
---|
564 | 'multiples' => True |
---|
565 | ) |
---|
566 | ), |
---|
567 | 'request_status' => Array( |
---|
568 | 'type' => 'text', |
---|
569 | 'to_text' => True, |
---|
570 | 'vevent' => Array( |
---|
571 | 'state' => 'optional', |
---|
572 | 'multiples' => False |
---|
573 | ), |
---|
574 | 'vtodo' => Array( |
---|
575 | 'state' => 'optional', |
---|
576 | 'multiples' => False |
---|
577 | ), |
---|
578 | 'vjournal' => Array( |
---|
579 | 'state' => 'optional', |
---|
580 | 'multiples' => True |
---|
581 | ), |
---|
582 | 'vfreebusy' => Array( |
---|
583 | 'state' => 'optional', |
---|
584 | 'multiples' => True |
---|
585 | ) |
---|
586 | ), |
---|
587 | 'resources' => Array( |
---|
588 | 'type' => 'text', |
---|
589 | 'to_text' => False, |
---|
590 | 'vevent' => Array( |
---|
591 | 'state' => 'optional', |
---|
592 | 'multiples' => False |
---|
593 | ), |
---|
594 | 'vtodo' => Array( |
---|
595 | 'state' => 'optional', |
---|
596 | 'multiples' => False |
---|
597 | ) |
---|
598 | ), |
---|
599 | 'rrule' => Array( |
---|
600 | 'type' => 'recur', |
---|
601 | 'to_text' => False, |
---|
602 | 'daylight' => Array( |
---|
603 | 'state' => 'optional', |
---|
604 | 'multiples' => True |
---|
605 | ), |
---|
606 | 'standard' => Array( |
---|
607 | 'state' => 'optional', |
---|
608 | 'multiples' => True |
---|
609 | ), |
---|
610 | 'vevent' => Array( |
---|
611 | 'state' => 'optional', |
---|
612 | 'multiples' => True |
---|
613 | ), |
---|
614 | 'vtodo' => Array( |
---|
615 | 'state' => 'optional', |
---|
616 | 'multiples' => True |
---|
617 | ), |
---|
618 | 'vjournal' => Array( |
---|
619 | 'state' => 'optional', |
---|
620 | 'multiples' => True |
---|
621 | ) |
---|
622 | ), |
---|
623 | 'sequence' => Array( |
---|
624 | 'type' => 'integer', |
---|
625 | 'to_text' => True, |
---|
626 | 'vevent' => Array( |
---|
627 | 'state' => 'optional', |
---|
628 | 'multiples' => False |
---|
629 | ), |
---|
630 | 'vjournal' => Array( |
---|
631 | 'state' => 'optional', |
---|
632 | 'multiples' => False |
---|
633 | ), |
---|
634 | 'vtodo' => Array( |
---|
635 | 'state' => 'optional', |
---|
636 | 'multiples' => False |
---|
637 | ) |
---|
638 | ), |
---|
639 | 'status' => Array( |
---|
640 | 'type' => 'text', |
---|
641 | 'to_text' => True, |
---|
642 | 'vevent' => Array( |
---|
643 | 'state' => 'optional', |
---|
644 | 'multiples' => False |
---|
645 | ), |
---|
646 | 'vjournal' => Array( |
---|
647 | 'state' => 'optional', |
---|
648 | 'multiples' => False |
---|
649 | ), |
---|
650 | 'vtodo' => Array( |
---|
651 | 'state' => 'optional', |
---|
652 | 'multiples' => False |
---|
653 | ) |
---|
654 | ), |
---|
655 | 'summary' => Array( |
---|
656 | 'type' => 'text', |
---|
657 | 'to_text' => True, |
---|
658 | 'vevent' => Array( |
---|
659 | 'state' => 'optional', |
---|
660 | 'multiples' => False |
---|
661 | ), |
---|
662 | 'vtodo' => Array( |
---|
663 | 'state' => 'optional', |
---|
664 | 'multiples' => False |
---|
665 | ), |
---|
666 | 'vjournal' => Array( |
---|
667 | 'state' => 'optional', |
---|
668 | 'multiples' => False |
---|
669 | ), |
---|
670 | 'valarm' => Array( |
---|
671 | 'state' => 'optional', |
---|
672 | 'multiples' => False |
---|
673 | ) |
---|
674 | ), |
---|
675 | 'transp' => Array( |
---|
676 | 'type' => 'text', |
---|
677 | 'to_text' => True, |
---|
678 | 'vevent' => Array( |
---|
679 | 'state' => 'optional', |
---|
680 | 'multiples' => False |
---|
681 | ) |
---|
682 | ), |
---|
683 | 'trigger' => Array( |
---|
684 | 'type' => 'text', |
---|
685 | 'to_text' => True, |
---|
686 | 'valarm' => Array( |
---|
687 | 'state' => 'optional', |
---|
688 | 'multiples' => False |
---|
689 | ) |
---|
690 | ), |
---|
691 | 'tzid' => Array( |
---|
692 | 'type' => 'text', |
---|
693 | 'to_text' => True, |
---|
694 | 'vtimezone' => Array( |
---|
695 | 'state' => 'required', |
---|
696 | 'multiples' => False |
---|
697 | ) |
---|
698 | ), |
---|
699 | 'tzname' => Array( |
---|
700 | 'type' => 'text', |
---|
701 | 'to_text' => True, |
---|
702 | 'daylight' => Array( |
---|
703 | 'state' => 'optional', |
---|
704 | 'multiples' => True |
---|
705 | ), |
---|
706 | 'standard' => Array( |
---|
707 | 'state' => 'optional', |
---|
708 | 'multiples' => True |
---|
709 | ) |
---|
710 | ), |
---|
711 | 'tzoffsetfrom' => Array( |
---|
712 | 'type' => 'utc-offset', |
---|
713 | 'to_text' => True, |
---|
714 | 'daylight' => Array( |
---|
715 | 'state' => 'required', |
---|
716 | 'multiples' => False |
---|
717 | ), |
---|
718 | 'standard' => Array( |
---|
719 | 'state' => 'required', |
---|
720 | 'multiples' => False |
---|
721 | ) |
---|
722 | ), |
---|
723 | 'tzoffsetto' => Array( |
---|
724 | 'type' => 'utc-offset', |
---|
725 | 'to_text' => True, |
---|
726 | 'daylight' => Array( |
---|
727 | 'state' => 'required', |
---|
728 | 'multiples' => False |
---|
729 | ), |
---|
730 | 'standard' => Array( |
---|
731 | 'state' => 'required', |
---|
732 | 'multiples' => False |
---|
733 | ) |
---|
734 | ), |
---|
735 | 'tzurl' => Array( |
---|
736 | 'type' => 'uri', |
---|
737 | 'to_text' => True, |
---|
738 | 'vtimezone' => Array( |
---|
739 | 'state' => 'optional', |
---|
740 | 'multiples' => False |
---|
741 | ) |
---|
742 | ), |
---|
743 | 'uid' => Array( |
---|
744 | 'type' => 'text', |
---|
745 | 'to_text' => True, |
---|
746 | 'vevent' => Array( |
---|
747 | 'state' => 'required', |
---|
748 | 'multiples' => False |
---|
749 | ), |
---|
750 | 'vfreebusy' => Array( |
---|
751 | 'state' => 'required', |
---|
752 | 'multiples' => False |
---|
753 | ), |
---|
754 | 'vjournal' => Array( |
---|
755 | 'state' => 'required', |
---|
756 | 'multiples' => False |
---|
757 | ), |
---|
758 | 'vtodo' => Array( |
---|
759 | 'state' => 'required', |
---|
760 | 'multiples' => False |
---|
761 | ) |
---|
762 | ), |
---|
763 | 'url' => Array( |
---|
764 | 'type' => 'text', |
---|
765 | 'to_text' => True, |
---|
766 | 'vevent' => Array( |
---|
767 | 'state' => 'required', |
---|
768 | 'multiples' => False |
---|
769 | ), |
---|
770 | 'vfreebusy' => Array( |
---|
771 | 'state' => 'required', |
---|
772 | 'multiples' => False |
---|
773 | ), |
---|
774 | 'vjournal' => Array( |
---|
775 | 'state' => 'optional', |
---|
776 | 'multiples' => False |
---|
777 | ), |
---|
778 | 'vtodo' => Array( |
---|
779 | 'state' => 'required', |
---|
780 | 'multiples' => False |
---|
781 | ) |
---|
782 | ), |
---|
783 | 'version' => Array( |
---|
784 | 'type' => 'text', |
---|
785 | 'to_text' => True, |
---|
786 | 'ical' => Array( |
---|
787 | 'state' => 'required', |
---|
788 | 'multiples' => False |
---|
789 | ) |
---|
790 | ) |
---|
791 | ); |
---|
792 | $this->parameter = Array( |
---|
793 | 'altrep' => Array( |
---|
794 | 'type' => 'uri', |
---|
795 | 'quoted' => True, |
---|
796 | 'to_text' => True, |
---|
797 | 'properties' => Array( |
---|
798 | 'comment' => True, |
---|
799 | 'description' => True, |
---|
800 | 'location' => True, |
---|
801 | 'prodid' => True, |
---|
802 | 'resources' => True, |
---|
803 | 'summary' => True, |
---|
804 | 'contact' => True |
---|
805 | ) |
---|
806 | ), |
---|
807 | 'byday' => Array( |
---|
808 | 'type' => 'text', |
---|
809 | 'quoted' => False, |
---|
810 | 'to_text' => False, |
---|
811 | 'properties' => Array( |
---|
812 | 'rrule' => True |
---|
813 | ) |
---|
814 | ), |
---|
815 | 'byhour' => Array( |
---|
816 | 'type' => 'text', |
---|
817 | 'quoted' => False, |
---|
818 | 'to_text' => False, |
---|
819 | 'properties' => Array( |
---|
820 | 'rrule' => True |
---|
821 | ) |
---|
822 | ), |
---|
823 | 'byminute' => Array( |
---|
824 | 'type' => 'text', |
---|
825 | 'quoted' => False, |
---|
826 | 'to_text' => False, |
---|
827 | 'properties' => Array( |
---|
828 | 'rrule' => True |
---|
829 | ) |
---|
830 | ), |
---|
831 | 'bymonth' => Array( |
---|
832 | 'type' => 'text', |
---|
833 | 'quoted' => False, |
---|
834 | 'to_text' => False, |
---|
835 | 'properties' => Array( |
---|
836 | 'rrule' => True |
---|
837 | ) |
---|
838 | ), |
---|
839 | 'bymonthday' => Array( |
---|
840 | 'type' => 'text', |
---|
841 | 'quoted' => False, |
---|
842 | 'to_text' => False, |
---|
843 | 'properties' => Array( |
---|
844 | 'rrule' => True |
---|
845 | ) |
---|
846 | ), |
---|
847 | 'bysecond' => Array( |
---|
848 | 'type' => 'text', |
---|
849 | 'quoted' => False, |
---|
850 | 'to_text' => False, |
---|
851 | 'properties' => Array( |
---|
852 | 'rrule' => True |
---|
853 | ) |
---|
854 | ), |
---|
855 | 'bysetpos' => Array( |
---|
856 | 'type' => 'text', |
---|
857 | 'quoted' => False, |
---|
858 | 'to_text' => False, |
---|
859 | 'properties' => Array( |
---|
860 | 'rrule' => True |
---|
861 | ) |
---|
862 | ), |
---|
863 | 'byweekno' => Array( |
---|
864 | 'type' => 'text', |
---|
865 | 'quoted' => False, |
---|
866 | 'to_text' => False, |
---|
867 | 'properties' => Array( |
---|
868 | 'rrule' => True |
---|
869 | ) |
---|
870 | ), |
---|
871 | 'byyearday' => Array( |
---|
872 | 'type' => 'text', |
---|
873 | 'quoted' => False, |
---|
874 | 'to_text' => False, |
---|
875 | 'properties' => Array( |
---|
876 | 'rrule' => True |
---|
877 | ) |
---|
878 | ), |
---|
879 | 'class' => Array( |
---|
880 | 'type' => 'function', |
---|
881 | 'function' => 'switch_class', |
---|
882 | 'quoted' => False, |
---|
883 | 'to_text' => False, |
---|
884 | 'properties' => Array( |
---|
885 | 'class' => True |
---|
886 | ) |
---|
887 | ), |
---|
888 | 'cn' => Array( |
---|
889 | 'type' => 'text', |
---|
890 | 'quoted' => True, |
---|
891 | 'to_text' => False, |
---|
892 | 'properties' => Array( |
---|
893 | 'attendee' => True, |
---|
894 | 'organizer' => True |
---|
895 | ) |
---|
896 | ), |
---|
897 | 'count' => Array( |
---|
898 | 'type' => 'integer', |
---|
899 | 'quoted' => False, |
---|
900 | 'to_text' => False, |
---|
901 | 'properties' => Array( |
---|
902 | 'rrule' => True |
---|
903 | ) |
---|
904 | ), |
---|
905 | 'cu' => Array( |
---|
906 | 'type' => 'function', |
---|
907 | 'function' => 'switch_cu', |
---|
908 | 'quoted' => False, |
---|
909 | 'to_text' => False, |
---|
910 | 'properties' => Array( |
---|
911 | 'attendee' => True |
---|
912 | ) |
---|
913 | ), |
---|
914 | 'delegated_from' => Array( |
---|
915 | 'type' => 'function', |
---|
916 | 'function' => 'switch_mailto', |
---|
917 | 'quoted' => True, |
---|
918 | 'to_text' => False, |
---|
919 | 'properties' => Array( |
---|
920 | 'attendee' => True |
---|
921 | ) |
---|
922 | ), |
---|
923 | 'delegated_to' => Array( |
---|
924 | 'type' => 'function', |
---|
925 | 'function' => 'switch_mailto', |
---|
926 | 'quoted' => True, |
---|
927 | 'to_text' => False, |
---|
928 | 'properties' => Array( |
---|
929 | 'attendee' => True |
---|
930 | ) |
---|
931 | ), |
---|
932 | 'dir' => Array( |
---|
933 | 'type' => 'dir', |
---|
934 | 'quoted' => True, |
---|
935 | 'to_text' => True, |
---|
936 | 'properties' => Array( |
---|
937 | 'attendee' => True, |
---|
938 | 'organizer' => True |
---|
939 | ) |
---|
940 | ), |
---|
941 | 'dtend' => Array( |
---|
942 | 'type' => 'function', |
---|
943 | 'function' => 'switch_date', |
---|
944 | 'quoted' => False, |
---|
945 | 'to_text' => False, |
---|
946 | 'properties' => Array( |
---|
947 | 'dtend' => True |
---|
948 | ) |
---|
949 | ), |
---|
950 | 'dtstamp' => Array( |
---|
951 | 'type' => 'function', |
---|
952 | 'function' => 'switch_date', |
---|
953 | 'quoted' => False, |
---|
954 | 'to_text' => False, |
---|
955 | 'properties' => Array( |
---|
956 | 'dtstamp' => True |
---|
957 | ) |
---|
958 | ), |
---|
959 | 'dtstart' => Array( |
---|
960 | 'type' => 'function', |
---|
961 | 'function' => 'switch_date', |
---|
962 | 'quoted' => False, |
---|
963 | 'to_text' => False, |
---|
964 | 'properties' => Array( |
---|
965 | 'dtstart' => True |
---|
966 | ) |
---|
967 | ), |
---|
968 | 'encoding' => Array( // was enocding ??? |
---|
969 | 'type' => 'function', |
---|
970 | 'function' => 'switch_encoding', |
---|
971 | 'quoted' => False, |
---|
972 | 'to_text' => False, |
---|
973 | 'properties' => Array( |
---|
974 | 'attach' => True |
---|
975 | ) |
---|
976 | ), |
---|
977 | 'fmttype' => Array( |
---|
978 | 'type' => 'text', |
---|
979 | 'quoted' => False, |
---|
980 | 'to_text' => False, |
---|
981 | 'properties' => Array( |
---|
982 | 'attach' => True |
---|
983 | ) |
---|
984 | ), |
---|
985 | 'fbtype' => Array( |
---|
986 | 'type' => 'function', |
---|
987 | 'function' => 'switch_fbtype', |
---|
988 | 'quoted' => False, |
---|
989 | 'to_text' => False, |
---|
990 | 'properties' => Array( |
---|
991 | 'attach' => True |
---|
992 | ) |
---|
993 | ), |
---|
994 | 'freq' => Array( |
---|
995 | 'type' => 'function', |
---|
996 | 'function' => 'switch_freq', |
---|
997 | 'quoted' => False, |
---|
998 | 'to_text' => False, |
---|
999 | 'properties' => Array( |
---|
1000 | 'rrule' => True |
---|
1001 | ) |
---|
1002 | ), |
---|
1003 | 'interval' => Array( |
---|
1004 | 'type' => 'integer', |
---|
1005 | 'quoted' => False, |
---|
1006 | 'to_text' => False, |
---|
1007 | 'properties' => Array( |
---|
1008 | 'rrule' => True |
---|
1009 | ) |
---|
1010 | ), |
---|
1011 | 'language' => Array( |
---|
1012 | 'type' => 'text', |
---|
1013 | 'quoted' => False, |
---|
1014 | 'to_text' => False, |
---|
1015 | 'properties' => Array( |
---|
1016 | 'categories' => True, |
---|
1017 | 'comment' => True, |
---|
1018 | 'description' => True, |
---|
1019 | 'location' => True, |
---|
1020 | 'resources' => True, |
---|
1021 | 'summary' => True, |
---|
1022 | 'tzname' => True, |
---|
1023 | 'attendee' => True, |
---|
1024 | 'contact' => True, |
---|
1025 | 'organizer' => True, |
---|
1026 | 'x-type' => True |
---|
1027 | ) |
---|
1028 | ), |
---|
1029 | 'last_modified' => Array( |
---|
1030 | 'type' => 'function', |
---|
1031 | 'function' => 'switch_date', |
---|
1032 | 'quoted' => False, |
---|
1033 | 'to_text' => False, |
---|
1034 | 'properties' => Array( |
---|
1035 | 'last_modified' => True |
---|
1036 | ) |
---|
1037 | ), |
---|
1038 | 'mailto' => Array( |
---|
1039 | 'type' => 'function', |
---|
1040 | 'function' => 'switch_mailto', |
---|
1041 | 'quoted' => False, |
---|
1042 | 'to_text' => False, |
---|
1043 | 'properties' => Array( |
---|
1044 | 'attendee' => True, |
---|
1045 | 'organizer' => True |
---|
1046 | ) |
---|
1047 | ), |
---|
1048 | 'member' => Array( |
---|
1049 | 'type' => 'function', |
---|
1050 | 'function' => 'switch_mailto', |
---|
1051 | 'quoted' => True, |
---|
1052 | 'to_text' => False, |
---|
1053 | 'properties' => Array( |
---|
1054 | 'attendee' => True |
---|
1055 | ) |
---|
1056 | ), |
---|
1057 | 'partstat' => Array( |
---|
1058 | 'type' => 'function', |
---|
1059 | 'function' => 'switch_partstat', |
---|
1060 | 'quoted' => False, |
---|
1061 | 'to_text' => False, |
---|
1062 | 'properties' => Array( |
---|
1063 | 'attendee' => True, |
---|
1064 | 'organizer' => True |
---|
1065 | ) |
---|
1066 | ), |
---|
1067 | 'range' => Array( |
---|
1068 | 'type' => 'function', |
---|
1069 | 'function' => 'switch_range', |
---|
1070 | 'quoted' => False, |
---|
1071 | 'to_text' => False, |
---|
1072 | 'properties' => Array( |
---|
1073 | 'recurrence_id' => True |
---|
1074 | ) |
---|
1075 | ), |
---|
1076 | 'related' => Array( |
---|
1077 | 'type' => 'function', |
---|
1078 | 'function' => 'switch_related', |
---|
1079 | 'quoted' => False, |
---|
1080 | 'to_text' => False, |
---|
1081 | 'properties' => Array( |
---|
1082 | 'related_to' => True |
---|
1083 | ) |
---|
1084 | ), |
---|
1085 | 'role' => Array( |
---|
1086 | 'type' => 'function', |
---|
1087 | 'function' => 'switch_role', |
---|
1088 | 'quoted' => False, |
---|
1089 | 'to_text' => False, |
---|
1090 | 'properties' => Array( |
---|
1091 | 'attendee' => True, |
---|
1092 | 'organizer' => True |
---|
1093 | ) |
---|
1094 | ), |
---|
1095 | 'rsvp' => Array( |
---|
1096 | 'type' => 'function', |
---|
1097 | 'function' => 'switch_rsvp', |
---|
1098 | 'quoted' => False, |
---|
1099 | 'to_text' => False, |
---|
1100 | 'properties' => Array( |
---|
1101 | 'attendee' => True |
---|
1102 | ) |
---|
1103 | ), |
---|
1104 | 'sent_by' => Array( |
---|
1105 | 'type' => 'function', |
---|
1106 | 'function' => 'parse_user_host', |
---|
1107 | 'quoted' => True, |
---|
1108 | 'to_text' => False, |
---|
1109 | 'properties' => Array( |
---|
1110 | 'attendee' => True, |
---|
1111 | 'organizer' => True |
---|
1112 | ) |
---|
1113 | ), |
---|
1114 | 'tzid' => Array( |
---|
1115 | 'type' => 'text', |
---|
1116 | 'quoted' => False, |
---|
1117 | 'to_text' => False, |
---|
1118 | 'properties' => Array( |
---|
1119 | 'dtend' => True, |
---|
1120 | 'due' => True, |
---|
1121 | 'dtstart' => True, |
---|
1122 | 'exdate' => True, |
---|
1123 | 'rdate' => True, |
---|
1124 | 'recurrence_id' => True |
---|
1125 | ) |
---|
1126 | ), |
---|
1127 | 'until' => Array( |
---|
1128 | 'type' => 'function', |
---|
1129 | 'function' => 'switch_date', |
---|
1130 | 'quoted' => False, |
---|
1131 | 'to_text' => False, |
---|
1132 | 'properties' => Array( |
---|
1133 | 'rrule' => True |
---|
1134 | ) |
---|
1135 | ), |
---|
1136 | 'value' => Array( |
---|
1137 | 'type' => 'value', |
---|
1138 | 'quoted' => False, |
---|
1139 | 'to_text' => False, |
---|
1140 | 'properties' => Array( |
---|
1141 | 'calscale' => True, |
---|
1142 | 'prodid' => True, |
---|
1143 | 'method' => True, |
---|
1144 | 'version' => True, |
---|
1145 | 'attach' => True, |
---|
1146 | 'categories' => True, |
---|
1147 | 'class' => True, |
---|
1148 | 'comment' => True, |
---|
1149 | 'description' => True, |
---|
1150 | 'geo' => True, |
---|
1151 | 'location' => True, |
---|
1152 | 'percent' => True, |
---|
1153 | 'priority' => True, |
---|
1154 | 'resources' => True, |
---|
1155 | 'status' => True, |
---|
1156 | 'summary' => True, |
---|
1157 | 'completed' => True, |
---|
1158 | 'dtend' => True, |
---|
1159 | 'due' => True, |
---|
1160 | 'dtstart' => True, |
---|
1161 | 'duration' => True, |
---|
1162 | 'freebusy' => True, |
---|
1163 | 'transp' => True, |
---|
1164 | 'tzid' => True, |
---|
1165 | 'tzname' => True, |
---|
1166 | 'tzoffsetfrom' => True, |
---|
1167 | 'tzoffsetto' => True, |
---|
1168 | 'tzurl' => True, |
---|
1169 | 'attendee' => True, |
---|
1170 | 'contact' => True, |
---|
1171 | 'organizer' => True, |
---|
1172 | 'recurrence_id' => True, |
---|
1173 | 'url' => True, |
---|
1174 | 'uid' => True, |
---|
1175 | 'exdate' => True, |
---|
1176 | 'exrule' => True, |
---|
1177 | 'rdate' => True, |
---|
1178 | 'rrule' => True, |
---|
1179 | 'action' => True, |
---|
1180 | 'repeat' => True, |
---|
1181 | 'trigger' => True, |
---|
1182 | 'created' => True, |
---|
1183 | 'dtstamp' => True, |
---|
1184 | 'last_modified' => True, |
---|
1185 | 'sequence' => True, |
---|
1186 | 'x_type' => True, |
---|
1187 | 'request_status' => True |
---|
1188 | ) |
---|
1189 | ), |
---|
1190 | 'wkst' => Array( |
---|
1191 | 'type' => 'string', |
---|
1192 | 'quoted' => False, |
---|
1193 | 'to_text' => False, |
---|
1194 | 'properties' => Array( |
---|
1195 | 'rrule' => True |
---|
1196 | ) |
---|
1197 | ), |
---|
1198 | 'x_type' => Array( |
---|
1199 | 'type' => 'x_type', |
---|
1200 | 'quoted' => False, |
---|
1201 | 'to_text' => False, |
---|
1202 | 'properties' => Array( |
---|
1203 | 'calscale' => True, |
---|
1204 | 'method' => True, |
---|
1205 | 'prodid' => True, |
---|
1206 | 'version' => True, |
---|
1207 | 'attach' => True, |
---|
1208 | 'categories' => True, |
---|
1209 | 'class' => True, |
---|
1210 | 'comment' => True, |
---|
1211 | 'description' => True, |
---|
1212 | 'geo' => True, |
---|
1213 | 'location' => True, |
---|
1214 | 'percent' => True, |
---|
1215 | 'priority' => True, |
---|
1216 | 'resources' => True, |
---|
1217 | 'status' => True, |
---|
1218 | 'summary' => True, |
---|
1219 | 'completed' => True, |
---|
1220 | 'dtend' => True, |
---|
1221 | 'due' => True, |
---|
1222 | 'dtstart' => True, |
---|
1223 | 'duration' => True, |
---|
1224 | 'freebusy' => True, |
---|
1225 | 'transp' => True, |
---|
1226 | 'tzid' => True, |
---|
1227 | 'tzname' => True, |
---|
1228 | 'tzoffsetfrom' => True, |
---|
1229 | 'tzoffsetto' => True, |
---|
1230 | 'tzurl' => True, |
---|
1231 | 'attendee' => True, |
---|
1232 | 'contact' => True, |
---|
1233 | 'organizer' => True, |
---|
1234 | 'recurrence_id' => True, |
---|
1235 | 'url' => True, |
---|
1236 | 'uid' => True, |
---|
1237 | 'exdate' => True, |
---|
1238 | 'exrule' => True, |
---|
1239 | 'rdate' => True, |
---|
1240 | 'rrule' => True, |
---|
1241 | 'action' => True, |
---|
1242 | 'repeat' => True, |
---|
1243 | 'trigger' => True, |
---|
1244 | 'created' => True, |
---|
1245 | 'dtstamp' => True, |
---|
1246 | 'last_modified' => True, |
---|
1247 | 'sequence' => True, |
---|
1248 | 'x_type' => True, |
---|
1249 | 'request_status' => True |
---|
1250 | ) |
---|
1251 | ) |
---|
1252 | ); |
---|
1253 | if(!is_object($GLOBALS['phpgw']->datetime)) |
---|
1254 | { |
---|
1255 | $GLOBALS['phpgw']->datetime = createobject('phpgwapi.date_time'); |
---|
1256 | } |
---|
1257 | } |
---|
1258 | |
---|
1259 | function set_var(&$event,$type,$value) |
---|
1260 | { |
---|
1261 | $type = strtolower(str_replace('-','_',$type)); |
---|
1262 | $event[$type] = $value; |
---|
1263 | if(is_string($value)) |
---|
1264 | { |
---|
1265 | $this->debug("Setting ".$type." = ".$value); |
---|
1266 | } |
---|
1267 | else |
---|
1268 | { |
---|
1269 | $this->debug("Setting ".$type." = "._debug_array($value,False)); |
---|
1270 | } |
---|
1271 | } |
---|
1272 | |
---|
1273 | function read_line_unfold($ical_text) |
---|
1274 | { |
---|
1275 | if($this->line < count($ical_text)) |
---|
1276 | { |
---|
1277 | $str = str_replace("\r\n",'',$ical_text[$this->line]); |
---|
1278 | $this->line = $this->line + 1; |
---|
1279 | while(ereg("^[[:space:]]",$ical_text[$this->line])) |
---|
1280 | { |
---|
1281 | $str .= substr(str_replace("\r\n",'',$ical_text[$this->line]),1); |
---|
1282 | $this->line = $this->line + 1; |
---|
1283 | } |
---|
1284 | $this->debug("LINE : ".$str); |
---|
1285 | return $str; |
---|
1286 | } |
---|
1287 | else |
---|
1288 | { |
---|
1289 | return False; |
---|
1290 | } |
---|
1291 | } |
---|
1292 | |
---|
1293 | function fold($str) |
---|
1294 | { |
---|
1295 | return $this->chunk_split==True ? chunk_split($str,FOLD_LENGTH,"\r\n") : $str."\r\n"; |
---|
1296 | } |
---|
1297 | |
---|
1298 | function strip_quotes($str) |
---|
1299 | { |
---|
1300 | return str_replace('"','',$str); |
---|
1301 | } |
---|
1302 | |
---|
1303 | function from_text($str) |
---|
1304 | { |
---|
1305 | $str = str_replace("\\,",",",$str); |
---|
1306 | $str = str_replace("\\;",";",$str); |
---|
1307 | $str = str_replace("\\N","\n",$str); |
---|
1308 | $str = str_replace("\\n","\n",$str); |
---|
1309 | $str = str_replace("\\\\","\\",$str); |
---|
1310 | return "$str"; |
---|
1311 | } |
---|
1312 | |
---|
1313 | function to_text($str) |
---|
1314 | { |
---|
1315 | $str = str_replace("\\","\\\\",$str); |
---|
1316 | $str = str_replace(",","\\,",$str); |
---|
1317 | $str = str_replace(";","\\;",$str); |
---|
1318 | $str = str_replace("\n","\\n",$str); |
---|
1319 | return "$str"; |
---|
1320 | } |
---|
1321 | |
---|
1322 | function from_dir($str) |
---|
1323 | { |
---|
1324 | return str_replace('=3D','=',str_replace('%20',' ',$str)); |
---|
1325 | } |
---|
1326 | |
---|
1327 | function to_dir($str) |
---|
1328 | { |
---|
1329 | return str_replace('=','=3D',str_replace(' ','%20',$str)); |
---|
1330 | } |
---|
1331 | |
---|
1332 | function find_parameters($property) |
---|
1333 | { |
---|
1334 | static $cached_returns; |
---|
1335 | |
---|
1336 | if(isset($cached_returns[$property])) |
---|
1337 | { |
---|
1338 | reset($cached_returns[$property]); |
---|
1339 | return $cached_returns[$property]; |
---|
1340 | } |
---|
1341 | |
---|
1342 | reset($this->parameter); |
---|
1343 | while(list($key,$param_array) = each($this->parameter)) |
---|
1344 | { |
---|
1345 | if($param_array['properties'][$property]) |
---|
1346 | { |
---|
1347 | $param[] = $key; |
---|
1348 | $this->debug('Property : '.$property.' = Parameter : '.$key); |
---|
1349 | } |
---|
1350 | } |
---|
1351 | reset($param); |
---|
1352 | $cached_returns[$property] = $param; |
---|
1353 | return $param; |
---|
1354 | } |
---|
1355 | |
---|
1356 | function find_properties($ical_type) |
---|
1357 | { |
---|
1358 | static $cached_returns; |
---|
1359 | |
---|
1360 | if(isset($cached_returns[$ical_type])) |
---|
1361 | { |
---|
1362 | reset($cached_returns[$ical_type]); |
---|
1363 | return $cached_returns[$ical_type]; |
---|
1364 | } |
---|
1365 | |
---|
1366 | reset($this->property); |
---|
1367 | while(list($key,$param_array) = each($this->property)) |
---|
1368 | { |
---|
1369 | if($param_array[$ical_type]) |
---|
1370 | { |
---|
1371 | $prop[] = $key; |
---|
1372 | } |
---|
1373 | } |
---|
1374 | reset($prop); |
---|
1375 | $cached_returns[$ical_type] = $prop; |
---|
1376 | return $prop; |
---|
1377 | } |
---|
1378 | |
---|
1379 | function new_ical() |
---|
1380 | { |
---|
1381 | return Array(); |
---|
1382 | } |
---|
1383 | |
---|
1384 | /* |
---|
1385 | * Parse Functions |
---|
1386 | */ |
---|
1387 | |
---|
1388 | function parse_geo(&$event,$value) |
---|
1389 | { |
---|
1390 | // $return_value = $this->explode_param($value,True); |
---|
1391 | if(count($return_value) == 2) |
---|
1392 | { |
---|
1393 | $event['lat'] = $return_value[0]; |
---|
1394 | $event['lon'] = $return_value[1]; |
---|
1395 | } |
---|
1396 | } |
---|
1397 | |
---|
1398 | function parse_xtype(&$event,$majortype,$value) |
---|
1399 | { |
---|
1400 | $temp_x_type['name'] = strtoupper(substr($majortype,2)); |
---|
1401 | $temp_x_type['value'] = $value; |
---|
1402 | $event['x_type'][] = $temp_x_type; |
---|
1403 | } |
---|
1404 | |
---|
1405 | function parse_parameters(&$event,$majortype,$value) |
---|
1406 | { |
---|
1407 | if(!ereg('[\=\;]',$value)) |
---|
1408 | { |
---|
1409 | $return_value[] = Array( |
---|
1410 | 'param' => $majortype, |
---|
1411 | 'value' => $value |
---|
1412 | ); |
---|
1413 | $value = ''; |
---|
1414 | } |
---|
1415 | elseif(ereg('(.*(\:\\\\)?.*):(.*)',$value,$temp)) |
---|
1416 | { |
---|
1417 | $this->debug('Value : '._debug_array($temp,False)); |
---|
1418 | $this->debug('Param '.$majortype.' Value : '.$temp[3]); |
---|
1419 | if($temp[3]) |
---|
1420 | { |
---|
1421 | $return_value[] = Array( |
---|
1422 | 'param' => $majortype, |
---|
1423 | 'value' => $temp[3] |
---|
1424 | ); |
---|
1425 | $value = str_replace(':MAILTO','',$temp[1]); |
---|
1426 | } |
---|
1427 | while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) |
---|
1428 | { |
---|
1429 | $this->debug('Value : '._debug_array($temp,False)); |
---|
1430 | $this->debug('Param '.$temp[2].' Value : '.$temp[3]); |
---|
1431 | $return_value[] = Array( |
---|
1432 | 'param' => $temp[2], |
---|
1433 | 'value' => $temp[3] |
---|
1434 | ); |
---|
1435 | $value = chop($temp[5]); |
---|
1436 | $this->debug('Value would be = '.$value); |
---|
1437 | } |
---|
1438 | } |
---|
1439 | else |
---|
1440 | { |
---|
1441 | while(ereg('(([A-Z\-]*)[=]([[:alnum:] \_\)\(\/\$\.\,\:\\\|\*\&\^\%\#\!\~\"\?\&\@\<\>\-]*))([\;]?)(.*)',$value,$temp)) |
---|
1442 | { |
---|
1443 | $this->debug('Value : '._debug_array($temp,False)); |
---|
1444 | $this->debug('Param '.$temp[2].' Value : '.$temp[3]); |
---|
1445 | $return_value[] = Array( |
---|
1446 | 'param' => $temp[2], |
---|
1447 | 'value' => $temp[3] |
---|
1448 | ); |
---|
1449 | $value = chop($temp[5]); |
---|
1450 | $this->debug('Value would be = '.$value); |
---|
1451 | } |
---|
1452 | } |
---|
1453 | |
---|
1454 | for($i=0;$i<count($return_value);$i++) |
---|
1455 | { |
---|
1456 | $name = strtolower($return_value[$i]['param']); |
---|
1457 | $value = $this->strip_quotes($return_value[$i]['value']); |
---|
1458 | if(substr($name,0,2) == 'x-') |
---|
1459 | { |
---|
1460 | $param = 'x_type'; |
---|
1461 | $name = str_replace('-','_',$return_value[$i]['param']); |
---|
1462 | } |
---|
1463 | else |
---|
1464 | { |
---|
1465 | $param = str_replace('-','_',strtolower($name)); |
---|
1466 | if(!isset($this->parameter[$param]) || $majortype == 'tzid') |
---|
1467 | { |
---|
1468 | if($majortype == 'attendee' || $majortype == 'organizer') |
---|
1469 | { |
---|
1470 | $param = 'mailto'; |
---|
1471 | $name = $param; |
---|
1472 | } |
---|
1473 | else |
---|
1474 | { |
---|
1475 | $param = 'value'; |
---|
1476 | } |
---|
1477 | } |
---|
1478 | } |
---|
1479 | $this->debug('name : '.$name.' : Param = '.$param); |
---|
1480 | if(@$this->parameter[$param]['properties'][$majortype]) |
---|
1481 | { |
---|
1482 | switch(@$this->parameter[$param]['type']) |
---|
1483 | { |
---|
1484 | case 'dir': |
---|
1485 | $this->set_var($event,$name,$this->from_dir($value)); |
---|
1486 | break; |
---|
1487 | case 'text': |
---|
1488 | $this->set_var($event,$name,$value); |
---|
1489 | break; |
---|
1490 | case 'x_type': |
---|
1491 | $this->parse_xtype($event,$name,$value); |
---|
1492 | break; |
---|
1493 | case 'function': |
---|
1494 | $function = $this->parameter[$param]['function']; |
---|
1495 | $this->set_var($event,$name,$this->$function($value)); |
---|
1496 | break; |
---|
1497 | case 'uri': |
---|
1498 | if(@$this->parameter[$param]['to_text']) |
---|
1499 | { |
---|
1500 | $value = $this->to_text($value); |
---|
1501 | } |
---|
1502 | $this->set_var($event,$name,$value); |
---|
1503 | break; |
---|
1504 | case 'integer': |
---|
1505 | $this->set_var($event,$name,(int)$value); |
---|
1506 | break; |
---|
1507 | case 'value': |
---|
1508 | if(@$this->property[$majortype]['type'] == 'date-time') |
---|
1509 | { |
---|
1510 | $this->set_var($event,$param,$this->switch_date($name)); |
---|
1511 | } |
---|
1512 | elseif($value <> "\\n" && $value) |
---|
1513 | { |
---|
1514 | $this->set_var($event[$majortype],$param,$value); |
---|
1515 | } |
---|
1516 | $this->debug('Event : '._debug_array($event,False)); |
---|
1517 | break; |
---|
1518 | } |
---|
1519 | } |
---|
1520 | } |
---|
1521 | } |
---|
1522 | |
---|
1523 | function parse_value(&$event,$majortype,$value,$mode) |
---|
1524 | { |
---|
1525 | $var = Array(); |
---|
1526 | $this->debug('Mode : '.$mode.' Majortype : '.$majortype); |
---|
1527 | $this->parse_parameters($var,$majortype,$value); |
---|
1528 | if($this->property[$majortype][$mode]['multiples']) |
---|
1529 | { |
---|
1530 | $this->debug(_debug_array($var,False)); |
---|
1531 | $event[$majortype][] = $var; |
---|
1532 | } |
---|
1533 | else |
---|
1534 | { |
---|
1535 | $this->debug('Majortype : '.$majortype); |
---|
1536 | $this->debug('Property : '.$this->property[$majortype]['type']); |
---|
1537 | if($this->property[$majortype]['type'] == 'date-time') |
---|
1538 | { |
---|
1539 | $this->debug('Got a DATE-TIME type!'); |
---|
1540 | $t_var = $var[$majortype]; |
---|
1541 | unset($var[$majortype]); |
---|
1542 | reset($t_var); |
---|
1543 | while(list($key,$val) = each($t_var)) |
---|
1544 | { |
---|
1545 | $var[$key] = $val; |
---|
1546 | } |
---|
1547 | $this->debug($majortype.' : '._debug_array($var,False)); |
---|
1548 | } |
---|
1549 | $this->set_var($event,$majortype,$var); |
---|
1550 | } |
---|
1551 | } |
---|
1552 | |
---|
1553 | /* |
---|
1554 | * Build-Card Functions |
---|
1555 | */ |
---|
1556 | |
---|
1557 | function build_xtype($x_type,$seperator='=') |
---|
1558 | { |
---|
1559 | $quote = ''; |
---|
1560 | if($seperator == '=') |
---|
1561 | { |
---|
1562 | $quote = '"'; |
---|
1563 | } |
---|
1564 | |
---|
1565 | $return_value = $this->fold('X-'.$x_type['name'].$seperator.$quote.$x_type['value'].$quote); |
---|
1566 | if($seperator == '=') |
---|
1567 | { |
---|
1568 | return str_replace("\r\n",'',$return_value); |
---|
1569 | } |
---|
1570 | else |
---|
1571 | { |
---|
1572 | return $return_value; |
---|
1573 | } |
---|
1574 | } |
---|
1575 | |
---|
1576 | function build_parameters($event,$property) |
---|
1577 | { |
---|
1578 | $str = ''; |
---|
1579 | $include_mailto = False; |
---|
1580 | $include_datetime = False; |
---|
1581 | $param = $this->find_parameters($property); |
---|
1582 | |
---|
1583 | if($property == 'exdate') |
---|
1584 | { |
---|
1585 | while(list($key,$value) = each($event)) |
---|
1586 | { |
---|
1587 | $exdates[] = $this->switch_date($value); |
---|
1588 | } |
---|
1589 | return ':'.implode($exdates,','); |
---|
1590 | } |
---|
1591 | else |
---|
1592 | { |
---|
1593 | while(list($dumb_key,$key) = each($param)) |
---|
1594 | { |
---|
1595 | if($key == 'value') |
---|
1596 | { |
---|
1597 | continue; |
---|
1598 | } |
---|
1599 | if($key == 'mailto') |
---|
1600 | { |
---|
1601 | $include_mailto = True; |
---|
1602 | continue; |
---|
1603 | } |
---|
1604 | $param_array = @$this->parameter[$key]; |
---|
1605 | $type = @$this->parameter[$key]['type']; |
---|
1606 | if($type == 'date-time') |
---|
1607 | { |
---|
1608 | $include_datetime = True; |
---|
1609 | continue; |
---|
1610 | } |
---|
1611 | $quote = (@$this->parameter[$key]['quoted']?'"':''); |
---|
1612 | if(isset($event[$key]) && @$this->parameter[$key]['properties'][$property]) |
---|
1613 | { |
---|
1614 | $change_text = @$this->parameter[$key]['to_text']; |
---|
1615 | $value = $event[$key]; |
---|
1616 | if($change_text && $type == 'text') |
---|
1617 | { |
---|
1618 | $value = $this->to_text($value); |
---|
1619 | } |
---|
1620 | switch($type) |
---|
1621 | { |
---|
1622 | case 'dir': |
---|
1623 | $str .= ';'.str_replace('_','-',strtoupper($key)).'='.$quote.$this->to_dir($value).$quote; |
---|
1624 | break; |
---|
1625 | case 'function': |
---|
1626 | $str .= ';'.str_replace('_','-',strtoupper($key)).'='; |
---|
1627 | $function = $this->parameter[$key]['function']; |
---|
1628 | $this->debug($key.' Function Param : '.$value); |
---|
1629 | $str .= $quote.$this->$function($value).$quote; |
---|
1630 | break; |
---|
1631 | case 'text': |
---|
1632 | case 'string': |
---|
1633 | $str .= ';'.strtoupper($key).'='.$quote.$value.$quote; |
---|
1634 | break; |
---|
1635 | case 'date-time': |
---|
1636 | $str .= ($key=='until'?':':';UNTIL=').date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':''); |
---|
1637 | break; |
---|
1638 | } |
---|
1639 | unset($value); |
---|
1640 | } |
---|
1641 | } |
---|
1642 | |
---|
1643 | if(!empty($event['x_type'])) |
---|
1644 | { |
---|
1645 | $c_x_type = count($event['x_type']); |
---|
1646 | for($j=0;$j<$c_x_type;$j++) |
---|
1647 | { |
---|
1648 | $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); |
---|
1649 | } |
---|
1650 | } |
---|
1651 | if(!empty($event['value'])) |
---|
1652 | { |
---|
1653 | if($property == 'trigger') |
---|
1654 | { |
---|
1655 | $seperator = ';'; |
---|
1656 | } |
---|
1657 | else |
---|
1658 | { |
---|
1659 | $seperator = ':'; |
---|
1660 | } |
---|
1661 | $str .= $seperator.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); |
---|
1662 | } |
---|
1663 | if($include_mailto == True) |
---|
1664 | { |
---|
1665 | $key = 'mailto'; |
---|
1666 | $function = $this->parameter[$key]['function']; |
---|
1667 | $ret_value = $this->$function($event[$key]); |
---|
1668 | $str .= ($ret_value?':'.$ret_value:''); |
---|
1669 | } |
---|
1670 | if($include_datetime == True || @$this->property[$property]['type'] == 'date-time') |
---|
1671 | { |
---|
1672 | $str .= ':'.date('Ymd\THis',mktime($event['hour'],$event['min'],$event['sec'],$event['month'],$event['mday'],$event['year'])).(!@isset($event['tzid'])?'Z':''); |
---|
1673 | } |
---|
1674 | return ($property=='rrule'?':'.substr($str,1):$str); |
---|
1675 | } |
---|
1676 | } |
---|
1677 | |
---|
1678 | function build_text($event,$property) |
---|
1679 | { |
---|
1680 | $str = ''; |
---|
1681 | $param = $this->find_parameters($property); |
---|
1682 | while(list($dumb_key,$key) = each($param)) |
---|
1683 | { |
---|
1684 | if(!empty($event[$key]) && $key != 'value') |
---|
1685 | { |
---|
1686 | $type = @$this->parameter[$key]['type']; |
---|
1687 | $quote = @$this->parameter[$key]['quote']; |
---|
1688 | if(@$this->parameter[$key]['to_text'] == True) |
---|
1689 | { |
---|
1690 | $value = $this->to_text($event[$key]); |
---|
1691 | } |
---|
1692 | else |
---|
1693 | { |
---|
1694 | $value = $event[$key]; |
---|
1695 | } |
---|
1696 | switch($type) |
---|
1697 | { |
---|
1698 | case 'text': |
---|
1699 | $str .= ';'.strtoupper($key).'='.$quote.$value.$quote; |
---|
1700 | break; |
---|
1701 | } |
---|
1702 | } |
---|
1703 | } |
---|
1704 | if(!empty($event['x_type'])) |
---|
1705 | { |
---|
1706 | $c_x_type = count($event['x_type']); |
---|
1707 | for($j=0;$j<$c_x_type;$j++) |
---|
1708 | { |
---|
1709 | $str .= ';'.$this->build_xtype($event['x_type'][$j],'='); |
---|
1710 | } |
---|
1711 | } |
---|
1712 | if(!empty($event['value'])) |
---|
1713 | { |
---|
1714 | $str .= ':'.($this->parameter['value']['to_text']?$this->to_text($event['value']):$event['value']); |
---|
1715 | } |
---|
1716 | return $str; |
---|
1717 | } |
---|
1718 | |
---|
1719 | function build_card_internals($ical_item,$event) |
---|
1720 | { |
---|
1721 | $prop = $this->find_properties($ical_item); |
---|
1722 | reset($prop); |
---|
1723 | while(list($dumb_key,$key) = each($prop)) |
---|
1724 | { |
---|
1725 | $value = $key; |
---|
1726 | $varray = $this->property[$key]; |
---|
1727 | $type = $varray['type']; |
---|
1728 | $to_text = $varray['to_text']; |
---|
1729 | $state = @$varray[$ical_item]['state']; |
---|
1730 | $multiples = @$varray[$ical_item]['multiples']; |
---|
1731 | switch($type) |
---|
1732 | { |
---|
1733 | case 'date-time': |
---|
1734 | if(!empty($event[$value])) |
---|
1735 | { |
---|
1736 | if($multiples && $value != 'exdate') |
---|
1737 | { |
---|
1738 | for($i=0;$i<count($event[$value]);$i++) |
---|
1739 | { |
---|
1740 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); |
---|
1741 | } |
---|
1742 | } |
---|
1743 | else |
---|
1744 | { |
---|
1745 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); |
---|
1746 | } |
---|
1747 | } |
---|
1748 | elseif($value == 'dtstamp' || $value == 'created') |
---|
1749 | { |
---|
1750 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.gmdate('Ymd\THis\Z')); |
---|
1751 | } |
---|
1752 | break; |
---|
1753 | case 'uri': |
---|
1754 | if(!empty($event[$value])) |
---|
1755 | { |
---|
1756 | for($i=0;$i<count($event[$value]);$i++) |
---|
1757 | { |
---|
1758 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$to_text)); |
---|
1759 | } |
---|
1760 | } |
---|
1761 | break; |
---|
1762 | case 'recur': |
---|
1763 | if(!empty($event[$value])) |
---|
1764 | { |
---|
1765 | if($multiples) |
---|
1766 | { |
---|
1767 | for($i=0;$i<count($event[$value]);$i++) |
---|
1768 | { |
---|
1769 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); |
---|
1770 | } |
---|
1771 | } |
---|
1772 | else |
---|
1773 | { |
---|
1774 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); |
---|
1775 | } |
---|
1776 | } |
---|
1777 | break; |
---|
1778 | case 'integer': |
---|
1779 | if(!empty($event[$value])) |
---|
1780 | { |
---|
1781 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]); |
---|
1782 | } |
---|
1783 | elseif($value == 'sequence' || $value == 'percent_complete') |
---|
1784 | { |
---|
1785 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':0'); |
---|
1786 | } |
---|
1787 | break; |
---|
1788 | case 'function': |
---|
1789 | $str .= ';'.str_replace('_','-',strtoupper($value)).'='; |
---|
1790 | $function = @$this->parameter[$key]['function']; |
---|
1791 | $str .= (@$this->parameter[$key]['quoted']?'"':'').$this->$function($event[$key]).(@$this->parameter[$key]['quoted']?'"':''); |
---|
1792 | break; |
---|
1793 | case 'float': |
---|
1794 | if(!empty($event[$value])) |
---|
1795 | { |
---|
1796 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$event[$value]['lat'].';'.$event[$value]['lon']); |
---|
1797 | } |
---|
1798 | break; |
---|
1799 | case 'text': |
---|
1800 | if(isset($event[$value])) |
---|
1801 | { |
---|
1802 | if(@$this->parameter[$key]['type'] != 'function') |
---|
1803 | { |
---|
1804 | if($multiples && count($event[$value]) > 1) |
---|
1805 | { |
---|
1806 | for($i=0;$i<count($event[$value]);$i++) |
---|
1807 | { |
---|
1808 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value][$i],$value)); |
---|
1809 | } |
---|
1810 | } |
---|
1811 | else |
---|
1812 | { |
---|
1813 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$this->build_parameters($event[$value],$value)); |
---|
1814 | } |
---|
1815 | } |
---|
1816 | else |
---|
1817 | { |
---|
1818 | $function = $this->parameter[$value]['function']; |
---|
1819 | if($multiples) |
---|
1820 | { |
---|
1821 | for($i=0;$i<count($event[$value]);$i++) |
---|
1822 | { |
---|
1823 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value][$i])); |
---|
1824 | } |
---|
1825 | } |
---|
1826 | else |
---|
1827 | { |
---|
1828 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).':'.$this->$function($event[$value])); |
---|
1829 | } |
---|
1830 | } |
---|
1831 | } |
---|
1832 | break; |
---|
1833 | case 'cal-address': |
---|
1834 | if(is_array($event[$value][0])) |
---|
1835 | { |
---|
1836 | for($j=0;$j<count($event[$value]);$j++) |
---|
1837 | { |
---|
1838 | $temp_output = $this->build_parameters($event[$value][$j],$value); |
---|
1839 | if($temp_output) |
---|
1840 | { |
---|
1841 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); |
---|
1842 | } |
---|
1843 | } |
---|
1844 | } |
---|
1845 | else |
---|
1846 | { |
---|
1847 | $temp_output = $this->build_parameters($event[$value],$value); |
---|
1848 | if($temp_output) |
---|
1849 | { |
---|
1850 | $str .= $this->fold(strtoupper(str_replace('_','-',$value)).$temp_output); |
---|
1851 | } |
---|
1852 | } |
---|
1853 | break; |
---|
1854 | } |
---|
1855 | } |
---|
1856 | if(!empty($event['x_type'])) |
---|
1857 | { |
---|
1858 | for($i=0;$i<count($event['x_type']);$i++) |
---|
1859 | { |
---|
1860 | $str .= $this->build_xtype($event['x_type'][$i],':'); |
---|
1861 | } |
---|
1862 | } |
---|
1863 | |
---|
1864 | if($ical_item == 'vtimezone') |
---|
1865 | { |
---|
1866 | if($event['tzdata']) |
---|
1867 | { |
---|
1868 | for($k=0;$k<count($event['tzdata']);$k++) |
---|
1869 | { |
---|
1870 | $str .= 'BEGIN:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; |
---|
1871 | $str .= $this->build_card_internals(strtolower($event['tzdata'][$k]['type']),$event['tzdata'][$k]); |
---|
1872 | $str .= 'END:'.strtoupper($event['tzdata'][$k]['type'])."\r\n"; |
---|
1873 | } |
---|
1874 | } |
---|
1875 | } |
---|
1876 | elseif($event['alarm']) |
---|
1877 | { |
---|
1878 | for($k=0;$k<count($event['alarm']);$k++) |
---|
1879 | { |
---|
1880 | $str .= 'BEGIN:VALARM'."\r\n"; |
---|
1881 | $str .= $this->build_card_internals('valarm',$event['alarm'][$k]); |
---|
1882 | $str .= 'END:VALARM'."\r\n"; |
---|
1883 | } |
---|
1884 | } |
---|
1885 | return $str; |
---|
1886 | } |
---|
1887 | |
---|
1888 | /* |
---|
1889 | * Switching Functions |
---|
1890 | */ |
---|
1891 | |
---|
1892 | function switch_class($var) |
---|
1893 | { |
---|
1894 | if(is_string($var)) |
---|
1895 | { |
---|
1896 | switch($var) |
---|
1897 | { |
---|
1898 | case '_PRIVATE': |
---|
1899 | $var = _PRIVATE; |
---|
1900 | break; |
---|
1901 | case '_PUBLIC': |
---|
1902 | $var = _PUBLIC; |
---|
1903 | break; |
---|
1904 | case '_CONFIDENTIAL': |
---|
1905 | $var = _CONFIDENTIAL; |
---|
1906 | break; |
---|
1907 | } |
---|
1908 | } |
---|
1909 | elseif(is_int($var)) |
---|
1910 | { |
---|
1911 | switch((int)$var) |
---|
1912 | { |
---|
1913 | case _PRIVATE: |
---|
1914 | $var = '_PRIVATE'; |
---|
1915 | break; |
---|
1916 | case _PUBLIC: |
---|
1917 | $var = '_PUBLIC'; |
---|
1918 | break; |
---|
1919 | case _CONFIDENTIAL: |
---|
1920 | $var = '_CONFIDENTIAL'; |
---|
1921 | break; |
---|
1922 | } |
---|
1923 | } |
---|
1924 | return $var; |
---|
1925 | } |
---|
1926 | |
---|
1927 | function switch_cu($var) |
---|
1928 | { |
---|
1929 | if(gettype($var) == 'string') |
---|
1930 | { |
---|
1931 | switch($var) |
---|
1932 | { |
---|
1933 | case 'INDIVIDUAL': |
---|
1934 | return INDIVIDUAL; |
---|
1935 | break; |
---|
1936 | case 'GROUP': |
---|
1937 | return GROUP; |
---|
1938 | break; |
---|
1939 | case 'RESOURCE': |
---|
1940 | return RESOURCE; |
---|
1941 | break; |
---|
1942 | case 'ROOM': |
---|
1943 | return ROOM; |
---|
1944 | break; |
---|
1945 | case 'UNKNOWN': |
---|
1946 | return UNKNOWN; |
---|
1947 | break; |
---|
1948 | default: |
---|
1949 | return OTHER; |
---|
1950 | break; |
---|
1951 | } |
---|
1952 | } |
---|
1953 | elseif(gettype($var) == 'integer') |
---|
1954 | { |
---|
1955 | switch($var) |
---|
1956 | { |
---|
1957 | case INDIVIDUAL: |
---|
1958 | return 'INDIVIDUAL'; |
---|
1959 | break; |
---|
1960 | case GROUP: |
---|
1961 | return 'GROUP'; |
---|
1962 | break; |
---|
1963 | case RESOURCE: |
---|
1964 | return 'RESOURCE'; |
---|
1965 | break; |
---|
1966 | case ROOM: |
---|
1967 | return 'ROOM'; |
---|
1968 | break; |
---|
1969 | case UNKNOWN: |
---|
1970 | return 'UNKNOWN'; |
---|
1971 | break; |
---|
1972 | default: |
---|
1973 | return 'X-OTHER'; |
---|
1974 | break; |
---|
1975 | } |
---|
1976 | } |
---|
1977 | else |
---|
1978 | { |
---|
1979 | return $var; |
---|
1980 | } |
---|
1981 | } |
---|
1982 | |
---|
1983 | function switch_date($var) |
---|
1984 | { |
---|
1985 | $this->debug('SWITCH_DATE: gettype = '.gettype($var)); |
---|
1986 | if(is_string($var)) |
---|
1987 | { |
---|
1988 | $dtime = Array(); |
---|
1989 | if(strpos($var,':')) |
---|
1990 | { |
---|
1991 | $pos = explode(':',$var); |
---|
1992 | $var = $pos[1]; |
---|
1993 | } |
---|
1994 | $this->set_var($dtime,'year',(int)(substr($var,0,4))); |
---|
1995 | $this->set_var($dtime,'month',(int)(substr($var,4,2))); |
---|
1996 | $this->set_var($dtime,'mday',(int)(substr($var,6,2))); |
---|
1997 | if(substr($var,8,1) == 'T') |
---|
1998 | { |
---|
1999 | $this->set_var($dtime,'hour',(int)(substr($var,9,2))); |
---|
2000 | $this->set_var($dtime,'min',(int)(substr($var,11,2))); |
---|
2001 | $this->set_var($dtime,'sec',(int)(substr($var,13,2))); |
---|
2002 | if(strlen($var) > 14) |
---|
2003 | { |
---|
2004 | if(substr($var,14,1) != 'Z') |
---|
2005 | { |
---|
2006 | if($this->api) |
---|
2007 | { |
---|
2008 | $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; |
---|
2009 | if($dtime['hour'] < 0) |
---|
2010 | { |
---|
2011 | $dtime['mday'] -= 1; |
---|
2012 | $dtime['hour'] = 24 - $dtime['hour']; |
---|
2013 | } |
---|
2014 | elseif($dtime['hour'] >= 24) |
---|
2015 | { |
---|
2016 | $dtime['mday'] += 1; |
---|
2017 | $dtime['hour'] = $dtime['hour'] - 24; |
---|
2018 | } |
---|
2019 | } |
---|
2020 | } |
---|
2021 | } |
---|
2022 | else |
---|
2023 | { |
---|
2024 | /* |
---|
2025 | * The time provided by the iCal is considered local time. |
---|
2026 | * |
---|
2027 | * The implementor will need to consider how to convert that time to UTC. |
---|
2028 | */ |
---|
2029 | // if($this->api) |
---|
2030 | // { |
---|
2031 | // $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; |
---|
2032 | // if($dtime['hour'] < 0) |
---|
2033 | // { |
---|
2034 | // $dtime['mday'] -= 1; |
---|
2035 | // $dtime['hour'] = 24 - $dtime['hour']; |
---|
2036 | // } |
---|
2037 | // elseif($dtime['hour'] >= 24) |
---|
2038 | // { |
---|
2039 | // $dtime['mday'] += 1; |
---|
2040 | // $dtime['hour'] = $dtime['hour'] - 24; |
---|
2041 | // } |
---|
2042 | // } |
---|
2043 | } |
---|
2044 | } |
---|
2045 | else |
---|
2046 | { |
---|
2047 | $this->set_var($dtime,'hour',0); |
---|
2048 | $this->set_var($dtime,'min',0); |
---|
2049 | $this->set_var($dtime,'sec',0); |
---|
2050 | if($this->api) |
---|
2051 | { |
---|
2052 | $dtime['hour'] -= $GLOBALS['phpgw_info']['users']['common']['tz_offset']; |
---|
2053 | if($dtime['hour'] < 0) |
---|
2054 | { |
---|
2055 | $dtime['mday'] -= 1; |
---|
2056 | $dtime['hour'] = 24 - $dtime['hour']; |
---|
2057 | } |
---|
2058 | elseif($dtime['hour'] >= 24) |
---|
2059 | { |
---|
2060 | $dtime['mday'] += 1; |
---|
2061 | $dtime['hour'] = $dtime['hour'] - 24; |
---|
2062 | } |
---|
2063 | } |
---|
2064 | } |
---|
2065 | $this->debug('DATETIME : '._debug_array($dtime,False)); |
---|
2066 | return $dtime; |
---|
2067 | } |
---|
2068 | elseif(is_array($var)) |
---|
2069 | { |
---|
2070 | return date('Ymd\THis\Z',mktime($var['hour'],$var['min'],$var['sec'],$var['month'],$var['mday'],$var['year'])); |
---|
2071 | } |
---|
2072 | else |
---|
2073 | { |
---|
2074 | return $var; |
---|
2075 | } |
---|
2076 | } |
---|
2077 | |
---|
2078 | function switch_encoding($var) |
---|
2079 | { |
---|
2080 | if(is_string($var)) |
---|
2081 | { |
---|
2082 | switch($var) |
---|
2083 | { |
---|
2084 | case '8BIT': |
---|
2085 | return _8BIT; |
---|
2086 | break; |
---|
2087 | case 'BASE64': |
---|
2088 | return _BASE64; |
---|
2089 | break; |
---|
2090 | default: |
---|
2091 | return OTHER; |
---|
2092 | break; |
---|
2093 | } |
---|
2094 | } |
---|
2095 | elseif(is_int($var)) |
---|
2096 | { |
---|
2097 | switch($var) |
---|
2098 | { |
---|
2099 | case _8BIT: |
---|
2100 | return '8BIT'; |
---|
2101 | break; |
---|
2102 | case _BASE64: |
---|
2103 | return 'BASE64'; |
---|
2104 | break; |
---|
2105 | case OTHER: |
---|
2106 | return 'OTHER'; |
---|
2107 | break; |
---|
2108 | } |
---|
2109 | } |
---|
2110 | else |
---|
2111 | { |
---|
2112 | return $var; |
---|
2113 | } |
---|
2114 | } |
---|
2115 | |
---|
2116 | function switch_fbtype($var) |
---|
2117 | { |
---|
2118 | if(is_string($var)) |
---|
2119 | { |
---|
2120 | switch($var) |
---|
2121 | { |
---|
2122 | case 'FREE': |
---|
2123 | return FREE; |
---|
2124 | break; |
---|
2125 | case 'BUSY': |
---|
2126 | return BUSY; |
---|
2127 | break; |
---|
2128 | case 'BUSY-UNAVAILABLE': |
---|
2129 | return BUSY_UNAVAILABLE; |
---|
2130 | break; |
---|
2131 | case 'BUSY-TENTATIVE': |
---|
2132 | return BUSY_TENTATIVE; |
---|
2133 | break; |
---|
2134 | default: |
---|
2135 | return OTHER; |
---|
2136 | break; |
---|
2137 | } |
---|
2138 | } |
---|
2139 | elseif(is_int($var)) |
---|
2140 | { |
---|
2141 | switch($var) |
---|
2142 | { |
---|
2143 | case FREE: |
---|
2144 | return 'FREE'; |
---|
2145 | break; |
---|
2146 | case BUSY: |
---|
2147 | return 'BUSY'; |
---|
2148 | break; |
---|
2149 | case BUSY_UNAVAILABLE: |
---|
2150 | return 'BUSY-UNAVAILABLE'; |
---|
2151 | break; |
---|
2152 | case BUSY_TENTATIVE: |
---|
2153 | return 'BUSY-TENTATIVE'; |
---|
2154 | break; |
---|
2155 | default: |
---|
2156 | return 'OTHER'; |
---|
2157 | break; |
---|
2158 | } |
---|
2159 | } |
---|
2160 | else |
---|
2161 | { |
---|
2162 | return $var; |
---|
2163 | } |
---|
2164 | } |
---|
2165 | |
---|
2166 | function switch_freq($var) |
---|
2167 | { |
---|
2168 | if(is_string($var)) |
---|
2169 | { |
---|
2170 | switch($var) |
---|
2171 | { |
---|
2172 | case 'SECONDLY': |
---|
2173 | return SECONDLY; |
---|
2174 | break; |
---|
2175 | case 'MINUTELY': |
---|
2176 | return MINUTELY; |
---|
2177 | break; |
---|
2178 | case 'HOURLY': |
---|
2179 | return HOURLY; |
---|
2180 | break; |
---|
2181 | case 'DAILY': |
---|
2182 | return DAILY; |
---|
2183 | break; |
---|
2184 | case 'WEEKLY': |
---|
2185 | return WEEKLY; |
---|
2186 | break; |
---|
2187 | case 'MONTHLY': |
---|
2188 | return MONTHLY; |
---|
2189 | break; |
---|
2190 | case 'YEARLY': |
---|
2191 | return YEARLY; |
---|
2192 | break; |
---|
2193 | } |
---|
2194 | } |
---|
2195 | elseif(is_int($var)) |
---|
2196 | { |
---|
2197 | switch($var) |
---|
2198 | { |
---|
2199 | case SECONDLY: |
---|
2200 | return 'SECONDLY'; |
---|
2201 | break; |
---|
2202 | case MINUTELY: |
---|
2203 | return 'MINUTELY'; |
---|
2204 | break; |
---|
2205 | case HOURLY: |
---|
2206 | return 'HOURLY'; |
---|
2207 | break; |
---|
2208 | case DAILY: |
---|
2209 | return 'DAILY'; |
---|
2210 | break; |
---|
2211 | case WEEKLY: |
---|
2212 | return 'WEEKLY'; |
---|
2213 | break; |
---|
2214 | case MONTHLY: |
---|
2215 | return 'MONTHLY'; |
---|
2216 | break; |
---|
2217 | case YEARLY: |
---|
2218 | return 'YEARLY'; |
---|
2219 | break; |
---|
2220 | } |
---|
2221 | } |
---|
2222 | else |
---|
2223 | { |
---|
2224 | return $var; |
---|
2225 | } |
---|
2226 | } |
---|
2227 | |
---|
2228 | function switch_mailto($var) |
---|
2229 | { |
---|
2230 | if(is_string($var)) |
---|
2231 | { |
---|
2232 | if(strpos(' '.$var,':')) |
---|
2233 | { |
---|
2234 | $parts = explode(':',$var); |
---|
2235 | $var = $parts[1]; |
---|
2236 | } |
---|
2237 | |
---|
2238 | $parts = explode('@',$var); |
---|
2239 | $this->debug("Count of mailto parts : ".count($parts)); |
---|
2240 | if(count($parts) == 2) |
---|
2241 | { |
---|
2242 | $this->debug("Splitting ".$parts[0]." @ ".$parts[1]); |
---|
2243 | $temp_address = Array(); |
---|
2244 | $temp_address['user'] = $parts[0]; |
---|
2245 | $temp_address['host'] = $parts[1]; |
---|
2246 | return $temp_address; |
---|
2247 | } |
---|
2248 | else |
---|
2249 | { |
---|
2250 | return False; |
---|
2251 | } |
---|
2252 | } |
---|
2253 | elseif(is_array($var)) |
---|
2254 | { |
---|
2255 | // return 'MAILTO:'.$var['user'].'@'.$var['host']; |
---|
2256 | return $var['user'].'@'.$var['host']; |
---|
2257 | } |
---|
2258 | } |
---|
2259 | |
---|
2260 | function switch_partstat($var) |
---|
2261 | { |
---|
2262 | // $this->debug_str = True; |
---|
2263 | $this->debug('PARTSTAT = '.$var); |
---|
2264 | // $this->debug_str = False; |
---|
2265 | if(is_string($var)) |
---|
2266 | { |
---|
2267 | switch($var) |
---|
2268 | { |
---|
2269 | case 'NEEDS-ACTION': |
---|
2270 | return 0; // NEEDS_ACTION; |
---|
2271 | break; |
---|
2272 | case 'ACCEPTED': |
---|
2273 | return 1; // ACCEPTED; |
---|
2274 | break; |
---|
2275 | case 'DECLINED': |
---|
2276 | return 2; // DECLINED; |
---|
2277 | break; |
---|
2278 | case 'TENTATIVE': |
---|
2279 | return 3; // TENTATIVE; |
---|
2280 | break; |
---|
2281 | case 'DELEGATED': |
---|
2282 | return 4; // DELEGATED; |
---|
2283 | break; |
---|
2284 | case 'COMPLETED': |
---|
2285 | return 5; // COMPLETED; |
---|
2286 | break; |
---|
2287 | case 'IN-PROCESS': |
---|
2288 | return 6; // IN_PROCESS; |
---|
2289 | break; |
---|
2290 | default: |
---|
2291 | return 99; // OTHER; |
---|
2292 | break; |
---|
2293 | } |
---|
2294 | } |
---|
2295 | elseif(is_int($var)) |
---|
2296 | { |
---|
2297 | switch((int)$var) |
---|
2298 | { |
---|
2299 | case 0: // NEEDS_ACTION: |
---|
2300 | return 'NEEDS-ACTION'; |
---|
2301 | break; |
---|
2302 | case 1: // ACCEPTED: |
---|
2303 | return 'ACCEPTED'; |
---|
2304 | break; |
---|
2305 | case 2: // DECLINED: |
---|
2306 | return 'DECLINED'; |
---|
2307 | break; |
---|
2308 | case 3: // TENTATIVE: |
---|
2309 | return 'TENTATIVE'; |
---|
2310 | break; |
---|
2311 | case 4: // DELEGATED: |
---|
2312 | return 'DELEGATED'; |
---|
2313 | break; |
---|
2314 | case 5: // COMPLETED: |
---|
2315 | return 'COMPLETED'; |
---|
2316 | break; |
---|
2317 | case 6: // IN_PROCESS: |
---|
2318 | return 'IN-PROCESS'; |
---|
2319 | break; |
---|
2320 | default: |
---|
2321 | return 'X-OTHER'; |
---|
2322 | break; |
---|
2323 | } |
---|
2324 | } |
---|
2325 | else |
---|
2326 | { |
---|
2327 | return $var; |
---|
2328 | } |
---|
2329 | } |
---|
2330 | |
---|
2331 | function switch_range($var) |
---|
2332 | { |
---|
2333 | if(is_string($var)) |
---|
2334 | { |
---|
2335 | switch($var) |
---|
2336 | { |
---|
2337 | case 'THISANDPRIOR': |
---|
2338 | return THISANDPRIOR; |
---|
2339 | break; |
---|
2340 | case 'THISANDFUTURE': |
---|
2341 | return THISANDFUTURE; |
---|
2342 | break; |
---|
2343 | } |
---|
2344 | } |
---|
2345 | elseif(is_int($var)) |
---|
2346 | { |
---|
2347 | switch($var) |
---|
2348 | { |
---|
2349 | case THISANDPRIOR: |
---|
2350 | return 'THISANDPRIOR'; |
---|
2351 | break; |
---|
2352 | case THISANDFUTURE: |
---|
2353 | return 'THISANDFUTURE'; |
---|
2354 | break; |
---|
2355 | } |
---|
2356 | } |
---|
2357 | else |
---|
2358 | { |
---|
2359 | return $var; |
---|
2360 | } |
---|
2361 | } |
---|
2362 | |
---|
2363 | function switch_related($var) |
---|
2364 | { |
---|
2365 | if(is_string($var)) |
---|
2366 | { |
---|
2367 | switch($var) |
---|
2368 | { |
---|
2369 | case 'START': |
---|
2370 | return START; |
---|
2371 | break; |
---|
2372 | case 'END': |
---|
2373 | return END; |
---|
2374 | break; |
---|
2375 | } |
---|
2376 | } |
---|
2377 | elseif(is_int($var)) |
---|
2378 | { |
---|
2379 | switch($var) |
---|
2380 | { |
---|
2381 | case START: |
---|
2382 | return 'START'; |
---|
2383 | break; |
---|
2384 | case END: |
---|
2385 | return 'END'; |
---|
2386 | break; |
---|
2387 | } |
---|
2388 | } |
---|
2389 | else |
---|
2390 | { |
---|
2391 | return $var; |
---|
2392 | } |
---|
2393 | } |
---|
2394 | |
---|
2395 | function switch_reltype($var) |
---|
2396 | { |
---|
2397 | if(is_string($var)) |
---|
2398 | { |
---|
2399 | switch($var) |
---|
2400 | { |
---|
2401 | case 'PARENT': |
---|
2402 | return PARENT; |
---|
2403 | break; |
---|
2404 | case 'CHILD': |
---|
2405 | return CHILD; |
---|
2406 | break; |
---|
2407 | case 'SIBLING': |
---|
2408 | return SIBLING; |
---|
2409 | break; |
---|
2410 | } |
---|
2411 | } |
---|
2412 | elseif(is_int($var)) |
---|
2413 | { |
---|
2414 | switch($var) |
---|
2415 | { |
---|
2416 | case PARENT: |
---|
2417 | return 'PARENT'; |
---|
2418 | break; |
---|
2419 | case CHILD: |
---|
2420 | return 'CHILD'; |
---|
2421 | break; |
---|
2422 | case SIBLING: |
---|
2423 | return 'SIBLING'; |
---|
2424 | break; |
---|
2425 | } |
---|
2426 | } |
---|
2427 | else |
---|
2428 | { |
---|
2429 | return $var; |
---|
2430 | } |
---|
2431 | } |
---|
2432 | |
---|
2433 | function switch_role($var) |
---|
2434 | { |
---|
2435 | if(is_string($var)) |
---|
2436 | { |
---|
2437 | switch($var) |
---|
2438 | { |
---|
2439 | case 'NONE': |
---|
2440 | return NONE; |
---|
2441 | break; |
---|
2442 | case 'CHAIR': |
---|
2443 | return CHAIR; |
---|
2444 | break; |
---|
2445 | case 'REQ-PARTICIPANT': |
---|
2446 | return REQ_PARTICIPANT; |
---|
2447 | break; |
---|
2448 | case 'OPT-PARTICIPANT': |
---|
2449 | return OPT_PARTICIPANT; |
---|
2450 | break; |
---|
2451 | case 'NON-PARTICIPANT': |
---|
2452 | return NON_PARTICIPANT; |
---|
2453 | break; |
---|
2454 | } |
---|
2455 | } |
---|
2456 | elseif(is_int($var)) |
---|
2457 | { |
---|
2458 | switch($var) |
---|
2459 | { |
---|
2460 | case NONE: |
---|
2461 | return 'NONE'; |
---|
2462 | break; |
---|
2463 | case CHAIR: |
---|
2464 | return 'CHAIR'; |
---|
2465 | break; |
---|
2466 | case REQ_PARTICIPANT: |
---|
2467 | return 'REQ-PARTICIPANT'; |
---|
2468 | break; |
---|
2469 | case OPT_PARTICIPANT: |
---|
2470 | return 'OPT-PARTICIPANT'; |
---|
2471 | break; |
---|
2472 | case NON_PARTICIPANT: |
---|
2473 | return 'NON-PARTICIPANT'; |
---|
2474 | break; |
---|
2475 | } |
---|
2476 | } |
---|
2477 | else |
---|
2478 | { |
---|
2479 | return $var; |
---|
2480 | } |
---|
2481 | } |
---|
2482 | |
---|
2483 | function switch_rsvp($var) |
---|
2484 | { |
---|
2485 | if(is_string($var)) |
---|
2486 | { |
---|
2487 | if($var == 'TRUE') |
---|
2488 | { |
---|
2489 | return 1; |
---|
2490 | } |
---|
2491 | elseif($var == 'FALSE') |
---|
2492 | { |
---|
2493 | return 0; |
---|
2494 | } |
---|
2495 | } |
---|
2496 | elseif(is_int($var) || $var == False) |
---|
2497 | { |
---|
2498 | if($var == 1) |
---|
2499 | { |
---|
2500 | return 'TRUE'; |
---|
2501 | } |
---|
2502 | elseif($var == 0) |
---|
2503 | { |
---|
2504 | return 'FALSE'; |
---|
2505 | } |
---|
2506 | } |
---|
2507 | else |
---|
2508 | { |
---|
2509 | return $var; |
---|
2510 | } |
---|
2511 | } |
---|
2512 | |
---|
2513 | function switch_transp($var) |
---|
2514 | { |
---|
2515 | if(is_string($var)) |
---|
2516 | { |
---|
2517 | switch($var) |
---|
2518 | { |
---|
2519 | case 'TRANSPARENT': |
---|
2520 | return TRANSPARENT; |
---|
2521 | break; |
---|
2522 | case 'OPAQUE': |
---|
2523 | return OPAQUE; |
---|
2524 | break; |
---|
2525 | } |
---|
2526 | } |
---|
2527 | elseif(is_int($var)) |
---|
2528 | { |
---|
2529 | switch($var) |
---|
2530 | { |
---|
2531 | case TRANSPARENT: |
---|
2532 | return 'TRANSPARENT'; |
---|
2533 | break; |
---|
2534 | case OPAQUE: |
---|
2535 | return 'OPAQUE'; |
---|
2536 | break; |
---|
2537 | } |
---|
2538 | } |
---|
2539 | else |
---|
2540 | { |
---|
2541 | return $var; |
---|
2542 | } |
---|
2543 | } |
---|
2544 | |
---|
2545 | /* |
---|
2546 | * The brunt of the class |
---|
2547 | */ |
---|
2548 | |
---|
2549 | function parse($ical_text) |
---|
2550 | { |
---|
2551 | $begin_regexp = '^'; |
---|
2552 | $semi_colon_regexp = '[\;\:]'; |
---|
2553 | $colon_regexp = '[\:]'; |
---|
2554 | $catch_all_regexp = '(.*)'; |
---|
2555 | $end_regexp = '$'; |
---|
2556 | $property_regexp = $begin_regexp.'([A-Z\-]*)'.$semi_colon_regexp.$catch_all_regexp.$end_regexp; |
---|
2557 | $param_regexp = $begin_regexp.$catch_all_regexp.':'.$catch_all_regexp.$end_regexp; |
---|
2558 | |
---|
2559 | $mode = 'none'; |
---|
2560 | $text = $this->read_line_unfold($ical_text); |
---|
2561 | while($text) |
---|
2562 | { |
---|
2563 | // if(strlen($ical_text[$i]) > 75) |
---|
2564 | // { |
---|
2565 | // continue; |
---|
2566 | // } |
---|
2567 | |
---|
2568 | ereg($property_regexp,$text,$temp); |
---|
2569 | $majortype = str_replace('-','_',strtolower($temp[1])); |
---|
2570 | $value = chop($temp[2]); |
---|
2571 | |
---|
2572 | if($mode != 'none' && ($majortype != 'begin' && $majortype != 'end')) |
---|
2573 | { |
---|
2574 | $this->debug('PARSE:MAJORTYPE : '.$majortype); |
---|
2575 | if(isset($this->property[$majortype])) |
---|
2576 | { |
---|
2577 | $state = @$this->property[$majortype]["$mode"]['state']; |
---|
2578 | $type = @$this->property[$majortype]['type']; |
---|
2579 | $multiples = @$this->property[$majortype]["$mode"]['multiples']; |
---|
2580 | $do_to_text = @$this->property[$majortype]['to_text']; |
---|
2581 | } |
---|
2582 | elseif(substr($majortype,0,2) == 'x_') |
---|
2583 | { |
---|
2584 | $state = 'optional'; |
---|
2585 | $type = 'xtype'; |
---|
2586 | $multiples = True; |
---|
2587 | $do_to_test = True; |
---|
2588 | } |
---|
2589 | else |
---|
2590 | { |
---|
2591 | $state = ''; |
---|
2592 | } |
---|
2593 | } |
---|
2594 | else |
---|
2595 | { |
---|
2596 | $state = 'required'; |
---|
2597 | } |
---|
2598 | |
---|
2599 | if($majortype == 'duration') |
---|
2600 | { |
---|
2601 | // Unset dur var |
---|
2602 | unset($dur); |
---|
2603 | |
---|
2604 | // Split «DURATION» |
---|
2605 | list($_f_['day_raw'], $_f_['time_raw']) = split('T', substr($value, 1, strlen($value)-1)); |
---|
2606 | |
---|
2607 | /* Datecode */ |
---|
2608 | if(isset($_f_['day_raw']) OR $_f_['day_raw']) |
---|
2609 | { |
---|
2610 | // Days |
---|
2611 | // if(ereg('D', $_f_['day_raw'])) |
---|
2612 | if(strstr($_f_['day_raw'],'D')) |
---|
2613 | { |
---|
2614 | $dur['days'] = eregi_replace("([0-9]+)D(.*)", "\\1", $_f_['day_raw']); |
---|
2615 | } |
---|
2616 | |
---|
2617 | // Weeks |
---|
2618 | // if(ereg("W", $_f_["day_raw"])) |
---|
2619 | if(strstr($_f_['day_raw'],'W')) |
---|
2620 | { |
---|
2621 | $dur['weeks'] = eregi_replace("([^|.*]+D)?([0-9]+)W", "\\2", $_f_['day_raw']); |
---|
2622 | } |
---|
2623 | } |
---|
2624 | |
---|
2625 | /* Timecode */ |
---|
2626 | if(isset($_f_['time_raw']) OR $_f_['time_raw']) |
---|
2627 | { |
---|
2628 | // Hours |
---|
2629 | // if(ereg("H", $_f_["time_raw"])) |
---|
2630 | if(strstr($_f_['time_raw'],'H')) |
---|
2631 | { |
---|
2632 | $dur['hours'] = eregi_replace("([0-9]+)H(.*)", "\\1", $_f_['time_raw']); |
---|
2633 | } |
---|
2634 | |
---|
2635 | // Minutes |
---|
2636 | /* If you find better, contact me very quickly :) */ |
---|
2637 | // if(ereg("M", $_f_["time_raw"])) |
---|
2638 | if(strstr($_f_['time_raw'],'M')) |
---|
2639 | { |
---|
2640 | $dur['minutes'] = eregi_replace("([^|.*]+H)?([0-9]+)M(.*)", "\\2", $_f_['time_raw']); |
---|
2641 | } |
---|
2642 | |
---|
2643 | // Seconds |
---|
2644 | /* Same comment :) */ |
---|
2645 | // if(ereg("S", $_f_["time_raw"]) ) |
---|
2646 | if(strstr($_f_['time_raw'],'S')) |
---|
2647 | { |
---|
2648 | $dur['seconds'] = eregi_replace("([^|.*]+M)?([0-9]+)S(.*)", "\\2", $_f_['time_raw']); |
---|
2649 | } |
---|
2650 | } |
---|
2651 | |
---|
2652 | $dur['raw'] = Array( |
---|
2653 | 'timecode' => $_f_['time_raw'], |
---|
2654 | 'datecode' => $_f_['day_raw'], |
---|
2655 | 'all' => $value |
---|
2656 | ); |
---|
2657 | // Add new parameters in Event |
---|
2658 | $this->set_var($event, $majortype, $dur); |
---|
2659 | } |
---|
2660 | |
---|
2661 | if($majortype == 'begin') |
---|
2662 | { |
---|
2663 | $tmode = $mode; |
---|
2664 | $mode = strtolower($value); |
---|
2665 | switch(strtolower($value)) |
---|
2666 | { |
---|
2667 | case 'daylight': |
---|
2668 | case 'standard': |
---|
2669 | $t_event = Array(); |
---|
2670 | $t_event = $event; |
---|
2671 | $event = Array(); |
---|
2672 | break; |
---|
2673 | case 'valarm': |
---|
2674 | if($tmode == 'vevent' || $tmode == 'vtodo') |
---|
2675 | { |
---|
2676 | $t_event = $event; |
---|
2677 | unset($event); |
---|
2678 | $event = Array(); |
---|
2679 | } |
---|
2680 | else |
---|
2681 | { |
---|
2682 | $mode = $tmode; |
---|
2683 | } |
---|
2684 | break; |
---|
2685 | case 'vcalendar': |
---|
2686 | $ical = $this->new_ical(); |
---|
2687 | break; |
---|
2688 | case 'vevent': |
---|
2689 | case 'vfreebusy': |
---|
2690 | case 'vjournal': |
---|
2691 | case 'vtimezone': |
---|
2692 | case 'vtodo': |
---|
2693 | $event = Array(); |
---|
2694 | break; |
---|
2695 | } |
---|
2696 | $event['type'] = strtolower($value); |
---|
2697 | } |
---|
2698 | elseif($majortype == 'end') |
---|
2699 | { |
---|
2700 | $mode = 'none'; |
---|
2701 | switch(strtolower($value)) |
---|
2702 | { |
---|
2703 | case 'daylight': |
---|
2704 | case 'standard': |
---|
2705 | $tzdata[] = $event; |
---|
2706 | unset($event); |
---|
2707 | $event = $t_event; |
---|
2708 | unset($t_event); |
---|
2709 | $mode = 'vtimezone'; |
---|
2710 | break; |
---|
2711 | case 'valarm': |
---|
2712 | $alarm[] = $event; |
---|
2713 | unset($event); |
---|
2714 | $event = $t_event; |
---|
2715 | unset($t_event); |
---|
2716 | $mode = $tmode; |
---|
2717 | break; |
---|
2718 | case 'vevent': |
---|
2719 | if(!empty($alarm)) |
---|
2720 | { |
---|
2721 | $event['alarm'] = $alarm; |
---|
2722 | unset($alarm); |
---|
2723 | } |
---|
2724 | $this->event[] = $event; |
---|
2725 | unset($event); |
---|
2726 | break; |
---|
2727 | case 'vfreebusy': |
---|
2728 | $this->freebusy[] = $event; |
---|
2729 | unset($event); |
---|
2730 | break; |
---|
2731 | case 'vjournal': |
---|
2732 | $this->journal[] = $event; |
---|
2733 | unset($event); |
---|
2734 | break; |
---|
2735 | case 'vtimezone': |
---|
2736 | if(!empty($tzdata)) |
---|
2737 | { |
---|
2738 | $event['tzdata'] = $tzdata; |
---|
2739 | unset($tzdata); |
---|
2740 | } |
---|
2741 | $this->timezone[] = $event; |
---|
2742 | unset($event); |
---|
2743 | break; |
---|
2744 | case 'vtodo': |
---|
2745 | if(!empty($alarm)) |
---|
2746 | { |
---|
2747 | $event['alarm'] = $alarm; |
---|
2748 | unset($alarm); |
---|
2749 | } |
---|
2750 | $this->todo[] = $event['alarm']; |
---|
2751 | unset($event); |
---|
2752 | break; |
---|
2753 | case 'vcalendar': |
---|
2754 | $this->ical = $ical; |
---|
2755 | $this->ical['event'] = $this->event; |
---|
2756 | $this->ical['freebusy'] = $this->freebusy; |
---|
2757 | $this->ical['journal'] = $this->journal; |
---|
2758 | $this->ical['timezone'] = $this->timezone; |
---|
2759 | $this->ical['todo'] = $this->todo; |
---|
2760 | break 2; |
---|
2761 | } |
---|
2762 | } |
---|
2763 | elseif($majortype == 'prodid' || $majortype == 'version' || $majortype == 'method' || $majortype == 'calscale') |
---|
2764 | { |
---|
2765 | $this->parse_parameters($ical,$majortype,$this->from_text($value)); |
---|
2766 | } |
---|
2767 | elseif($state == 'optional' || $state == 'required') |
---|
2768 | { |
---|
2769 | $this->debug('Mode : '.$mode.' Majortype : '.$majortype); |
---|
2770 | if($do_to_text) |
---|
2771 | { |
---|
2772 | $value = $this->from_text($value); |
---|
2773 | } |
---|
2774 | switch($type) |
---|
2775 | { |
---|
2776 | case 'text': |
---|
2777 | $this->parse_parameters($event,$majortype,$value); |
---|
2778 | break; |
---|
2779 | case 'recur': |
---|
2780 | case 'date-time': |
---|
2781 | case 'cal-address': |
---|
2782 | $this->parse_value($event,$majortype,$value,$mode); |
---|
2783 | break; |
---|
2784 | case 'integer': |
---|
2785 | if($multiples) |
---|
2786 | { |
---|
2787 | $event[$majortype][] = (int)$value; |
---|
2788 | } |
---|
2789 | else |
---|
2790 | { |
---|
2791 | $this->set_var($event,$majortype,(int)$value); |
---|
2792 | } |
---|
2793 | break; |
---|
2794 | case 'float': |
---|
2795 | $event->$majortype = new class_geo; |
---|
2796 | $this->parse_geo($event->$majortype,$value); |
---|
2797 | break; |
---|
2798 | case 'utc-offset': |
---|
2799 | $this->set_var($event,$majortype,(int)$value); |
---|
2800 | break; |
---|
2801 | case 'uri': |
---|
2802 | $new_var = Array(); |
---|
2803 | $this->parse_parameters($new_var,$majortype,$value); |
---|
2804 | if($multiples) |
---|
2805 | { |
---|
2806 | switch($mode) |
---|
2807 | { |
---|
2808 | case 'valarm': |
---|
2809 | $alarm['attach'][] = $new_var; |
---|
2810 | break; |
---|
2811 | default: |
---|
2812 | $event[$majortype][] = $new_var; |
---|
2813 | break; |
---|
2814 | } |
---|
2815 | } |
---|
2816 | else |
---|
2817 | { |
---|
2818 | $event[$majortype] = $new_var; |
---|
2819 | } |
---|
2820 | unset($new_var); |
---|
2821 | break; |
---|
2822 | case 'xtype': |
---|
2823 | $this->parse_xtype($event,$majortype,$value); |
---|
2824 | break; |
---|
2825 | } |
---|
2826 | } |
---|
2827 | $text = $this->read_line_unfold($ical_text); |
---|
2828 | } |
---|
2829 | return $this->ical; |
---|
2830 | } |
---|
2831 | |
---|
2832 | |
---|
2833 | function switch_to_phpgw_status($partstat) |
---|
2834 | { |
---|
2835 | switch($partstat) |
---|
2836 | { |
---|
2837 | case 0: |
---|
2838 | return 'U'; |
---|
2839 | break; |
---|
2840 | case 1: |
---|
2841 | return 'A'; |
---|
2842 | break; |
---|
2843 | case 2: |
---|
2844 | return 'R'; |
---|
2845 | break; |
---|
2846 | case 3: |
---|
2847 | return 'T'; |
---|
2848 | break; |
---|
2849 | default: |
---|
2850 | return 'U'; |
---|
2851 | break; |
---|
2852 | } |
---|
2853 | } |
---|
2854 | |
---|
2855 | function switch_phpgw_status($status) |
---|
2856 | { |
---|
2857 | switch($status) |
---|
2858 | { |
---|
2859 | case 'U': |
---|
2860 | return 0; |
---|
2861 | break; |
---|
2862 | case 'A': |
---|
2863 | return 1; |
---|
2864 | break; |
---|
2865 | case 'R': |
---|
2866 | return 2; |
---|
2867 | break; |
---|
2868 | case 'T': |
---|
2869 | return 3; |
---|
2870 | break; |
---|
2871 | } |
---|
2872 | } |
---|
2873 | |
---|
2874 | function is_owner($part_record) |
---|
2875 | { |
---|
2876 | if(($part_record['user'].'@'.$part_record['host'] == $GLOBALS['phpgw_info']['user']['preferences']['email']['address']) || |
---|
2877 | ($part_record['cn'] == $GLOBALS['phpgw_info']['user']['account_lid'])) |
---|
2878 | { |
---|
2879 | return True; |
---|
2880 | } |
---|
2881 | else |
---|
2882 | { |
---|
2883 | return False; |
---|
2884 | } |
---|
2885 | } |
---|
2886 | |
---|
2887 | function check_owner(&$event,$ical,$so_event) |
---|
2888 | { |
---|
2889 | if(!isset($event['participant'][$GLOBALS['phpgw_info']['user']['account_id']])) |
---|
2890 | { |
---|
2891 | if(isset($ical['organizer'])) |
---|
2892 | { |
---|
2893 | if($this->is_owner($ical['organizer'])) |
---|
2894 | { |
---|
2895 | $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); |
---|
2896 | $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['organizer']['partstat']),$GLOBALS['phpgw_info']['user']['account_id']); |
---|
2897 | } |
---|
2898 | } |
---|
2899 | elseif(isset($ical['attendee'])) |
---|
2900 | { |
---|
2901 | $attendee_count = count($ical['attendee']); |
---|
2902 | |
---|
2903 | for($j=0;$j<$attendee_count;$j++) |
---|
2904 | { |
---|
2905 | if($this->is_owner($ical['attendee'][$j])) |
---|
2906 | { |
---|
2907 | $so_event->add_attribute('participants',$this->switch_to_phpgw_status($ical['attendee'][$j]['partstat']),(int)$GLOBALS['phpgw_info']['user']['account_id']); |
---|
2908 | } |
---|
2909 | } |
---|
2910 | } |
---|
2911 | else |
---|
2912 | { |
---|
2913 | $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); |
---|
2914 | $so_event->add_attribute('participants','A',$GLOBALS['phpgw_info']['user']['account_id']); |
---|
2915 | } |
---|
2916 | } |
---|
2917 | } |
---|
2918 | |
---|
2919 | function import_file() |
---|
2920 | { |
---|
2921 | if($_FILES['uploadedfile']['tmp_name'] == 'none' || $_FILES['uploadedfile']['tmp_name'] == '') |
---|
2922 | { |
---|
2923 | Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', |
---|
2924 | Array( |
---|
2925 | 'menuaction' => 'calendar.uiicalendar.import', |
---|
2926 | 'action' => 'GetFile' |
---|
2927 | ) |
---|
2928 | ) |
---|
2929 | ); |
---|
2930 | $GLOBALS['phpwg']->common->phpgw_exit(); |
---|
2931 | } |
---|
2932 | $uploaddir = $GLOBALS['phpgw_info']['server']['temp_dir'] . SEP; |
---|
2933 | |
---|
2934 | srand((double)microtime()*1000000); |
---|
2935 | $random_number = rand(100000000,999999999); |
---|
2936 | $newfilename = md5($_FILES['uploadedfile']['tmp_name'].", ".$uploadedfile_name.", " |
---|
2937 | . time() . getenv("REMOTE_ADDR") . $random_number ); |
---|
2938 | |
---|
2939 | $filename = $uploaddir . $newfilename; |
---|
2940 | |
---|
2941 | move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $filename); |
---|
2942 | // $ftp = fopen($uploaddir . $newfilename . '.info','wb'); |
---|
2943 | // fputs($ftp,$uploadedfile_type."\n".$uploadedfile_name."\n"); |
---|
2944 | // fclose($ftp); |
---|
2945 | return $filename; |
---|
2946 | } |
---|
2947 | |
---|
2948 | function import($mime_msg='', $from_ajax = false) |
---|
2949 | { |
---|
2950 | if($_FILES['uploadedfile']['tmp_name'] != 'none' && $_FILES['uploadedfile']['tmp_name'] != '') |
---|
2951 | { |
---|
2952 | $filename = $this->import_file(); |
---|
2953 | $fp=fopen($filename,'rt'); |
---|
2954 | $mime_msg = explode("\n",fread($fp, filesize($filename))); |
---|
2955 | fclose($fp); |
---|
2956 | unlink($filename); |
---|
2957 | } |
---|
2958 | elseif(!$mime_msg) |
---|
2959 | { |
---|
2960 | Header('Location: ' . $GLOBALS['phpgw']->link('/index.php', |
---|
2961 | Array( |
---|
2962 | 'menuaction' => 'calendar.uiicalendar.import', |
---|
2963 | 'action' => 'GetFile' |
---|
2964 | ) |
---|
2965 | ) |
---|
2966 | ); |
---|
2967 | $GLOBALS['phpwg']->common->phpgw_exit(); |
---|
2968 | } |
---|
2969 | |
---|
2970 | if(!is_object($GLOBALS['uicalendar'])) |
---|
2971 | { |
---|
2972 | $so_event = createobject('calendar.socalendar', |
---|
2973 | Array( |
---|
2974 | 'owner' => 0, |
---|
2975 | 'filter' => '', |
---|
2976 | 'category' => '' |
---|
2977 | ) |
---|
2978 | ); |
---|
2979 | } |
---|
2980 | else |
---|
2981 | { |
---|
2982 | $so_event = $GLOBALS['uicalendar']->bo->so; |
---|
2983 | } |
---|
2984 | |
---|
2985 | $datetime_vars = Array( |
---|
2986 | 'start' => 'dtstart', |
---|
2987 | 'end' => 'dtend', |
---|
2988 | 'modtime' => 'dtstamp', |
---|
2989 | 'modtime' => 'last_modified' |
---|
2990 | ); |
---|
2991 | |
---|
2992 | $date_array = Array( |
---|
2993 | 'Y' => 'year', |
---|
2994 | 'm' => 'month', |
---|
2995 | 'd' => 'mday', |
---|
2996 | 'H' => 'hour', |
---|
2997 | 'i' => 'min', |
---|
2998 | 's' => 'sec' |
---|
2999 | ); |
---|
3000 | |
---|
3001 | // time limit should be controlled elsewhere |
---|
3002 | @set_time_limit(0); |
---|
3003 | |
---|
3004 | $GLOBALS['phpgw_info']['user']['preferences'] = $GLOBALS['phpgw']->preferences->create_email_preferences(); |
---|
3005 | $users_email = $GLOBALS['phpgw_info']['user']['preferences']['email']['address']; |
---|
3006 | $cats = CreateObject('phpgwapi.categories'); |
---|
3007 | $ical = $this->parse($mime_msg); |
---|
3008 | switch($ical['version']['value']) |
---|
3009 | { |
---|
3010 | case '1.0': |
---|
3011 | $cat_sep = ';'; |
---|
3012 | break; |
---|
3013 | case '2.0': |
---|
3014 | default: |
---|
3015 | $cat_sep = ','; |
---|
3016 | break; |
---|
3017 | } |
---|
3018 | $c_events = count($ical['event']); |
---|
3019 | for($i=0;$i<$c_events;$i++) |
---|
3020 | { |
---|
3021 | if($ical['event'][$i]['uid']['value']) |
---|
3022 | { |
---|
3023 | $uid_exists = $so_event->find_uid($ical['event'][$i]['uid']['value']); |
---|
3024 | } |
---|
3025 | else |
---|
3026 | { |
---|
3027 | $uid_exists = False; |
---|
3028 | } |
---|
3029 | if($uid_exists) |
---|
3030 | { |
---|
3031 | $event = $so_event->read_entry($uid_exists); |
---|
3032 | $this->check_owner($event,$ical['event'][$i],$so_event); |
---|
3033 | $event = $so_event->get_cached_event(); |
---|
3034 | $so_event->add_entry($event); |
---|
3035 | // $event = $so_event->get_cached_event(); |
---|
3036 | } |
---|
3037 | else |
---|
3038 | { |
---|
3039 | $so_event->event_init(); |
---|
3040 | $so_event->add_attribute('id',0); |
---|
3041 | $so_event->add_attribute('reference',0); |
---|
3042 | if($ical['event'][$i]['uid']['value']) |
---|
3043 | { |
---|
3044 | $so_event->add_attribute('uid',$ical['event'][$i]['uid']['value']); |
---|
3045 | } |
---|
3046 | if($ical['event'][$i]['summary']['value']) |
---|
3047 | { |
---|
3048 | $so_event->set_title($ical['event'][$i]['summary']['value']); |
---|
3049 | } |
---|
3050 | if($ical['event'][$i]['description']['value']) |
---|
3051 | { |
---|
3052 | $so_event->set_description($ical['event'][$i]['description']['value']); |
---|
3053 | } |
---|
3054 | if($ical['event'][$i]['ex_participants']['value']) |
---|
3055 | { |
---|
3056 | $so_event->set_ex_participants($ical['event'][$i]['ex_participants']['value']); |
---|
3057 | } |
---|
3058 | if($ical['event'][$i]['location']['value']) |
---|
3059 | { |
---|
3060 | $so_event->add_attribute('location',$ical['event'][$i]['location']['value']); |
---|
3061 | } |
---|
3062 | if(isset($ical['event'][$i]['priority'])) |
---|
3063 | { |
---|
3064 | $so_event->add_attribute('priority',$ical['event'][$i]['priority']); |
---|
3065 | } |
---|
3066 | else |
---|
3067 | { |
---|
3068 | $so_event->add_attribute('priority',2); |
---|
3069 | } |
---|
3070 | if(!isset($ical['event'][$i]['class'])) |
---|
3071 | { |
---|
3072 | $ical['event'][$i]['class'] = 1; |
---|
3073 | } |
---|
3074 | $so_event->set_class($ical['event'][$i]['class']); |
---|
3075 | |
---|
3076 | @reset($datetime_vars); |
---|
3077 | while(list($e_datevar,$i_datevar) = each($datetime_vars)) |
---|
3078 | { |
---|
3079 | if(isset($ical['event'][$i][$i_datevar])) |
---|
3080 | { |
---|
3081 | $temp_time = $so_event->maketime($ical['event'][$i][$i_datevar]) + $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3082 | @reset($date_array); |
---|
3083 | while(list($key,$var) = each($date_array)) |
---|
3084 | { |
---|
3085 | $event[$e_datevar][$var] = (int)(date($key,$temp_time)); |
---|
3086 | } |
---|
3087 | $so_event->set_date($e_datevar,$event[$e_datevar]['year'],$event[$e_datevar]['month'],$event[$e_datevar]['mday'],$event[$e_datevar]['hour'],$event[$e_datevar]['min'],$event[$e_datevar]['sec']); |
---|
3088 | } |
---|
3089 | } |
---|
3090 | if(!isset($ical['event'][$i]['categories']['value']) || !$ical['event'][$i]['categories']['value']) |
---|
3091 | { |
---|
3092 | $so_event->set_category(0); |
---|
3093 | } |
---|
3094 | else |
---|
3095 | { |
---|
3096 | $ical_cats = Array(); |
---|
3097 | if(strpos($ical['event'][$i]['categories']['value'],$cat_sep)) |
---|
3098 | { |
---|
3099 | $ical_cats = explode($cat_sep,$ical['event'][$i]['categories']['value']); |
---|
3100 | } |
---|
3101 | else |
---|
3102 | { |
---|
3103 | $ical_cats[] = $ical['event'][$i]['categories']['value']; |
---|
3104 | } |
---|
3105 | |
---|
3106 | @reset($ical_cats); |
---|
3107 | $cat_id_nums = Array(); |
---|
3108 | while(list($key,$cat) = each($ical_cats)) |
---|
3109 | { |
---|
3110 | if(!$cats->exists('appandmains',$cat)) |
---|
3111 | { |
---|
3112 | $cats->add( |
---|
3113 | Array( |
---|
3114 | 'name' => $cat, |
---|
3115 | 'descr' => $cat, |
---|
3116 | 'parent' => '', |
---|
3117 | 'access' => 'private', |
---|
3118 | 'data' => '' |
---|
3119 | ) |
---|
3120 | ); |
---|
3121 | } |
---|
3122 | // $temp_id = $cats->name2id($cat); |
---|
3123 | // echo 'Category Name : '.$cat.' : Category ID :'.$temp_id."<br>\n"; |
---|
3124 | // $cat_id_nums[] = $temp_id; |
---|
3125 | $cat_id_nums[] = $cats->name2id($cat); |
---|
3126 | } |
---|
3127 | @reset($cat_id_nums); |
---|
3128 | if(count($cat_id_nums) > 1) |
---|
3129 | { |
---|
3130 | $so_event->set_category(implode($cat_id_nums,',')); |
---|
3131 | } |
---|
3132 | else |
---|
3133 | { |
---|
3134 | $so_event->set_category($cat_id_nums[0]); |
---|
3135 | } |
---|
3136 | } |
---|
3137 | |
---|
3138 | //rrule |
---|
3139 | if(isset($ical['event'][$i]['rrule']) OR isset($ical['event'][$i]['duration']) ) |
---|
3140 | { |
---|
3141 | // recur_enddate |
---|
3142 | if(isset($ical['event'][$i]['rrule']['until'])) |
---|
3143 | { |
---|
3144 | $recur_enddate['year'] = (int)($ical['event'][$i]['rrule']['until']['year']); |
---|
3145 | $recur_enddate['month'] = (int)($ical['event'][$i]['rrule']['until']['month']); |
---|
3146 | $recur_enddate['mday'] = (int)($ical['event'][$i]['rrule']['until']['mday']); |
---|
3147 | } |
---|
3148 | elseif( isset($ical['event'][$i]['duration']) ) |
---|
3149 | { |
---|
3150 | // Create timecode for strtotime |
---|
3151 | $ptimer = mktime($ical['event'][$i]['dtstart']['hour'], |
---|
3152 | $ical['event'][$i]['dtstart']['min'], |
---|
3153 | $ical['event'][$i]['dtstart']['sec'], |
---|
3154 | $ical['event'][$i]['dtstart']['month'], |
---|
3155 | $ical['event'][$i]['dtstart']['mday'], |
---|
3156 | $ical['event'][$i]['dtstart']['year'] |
---|
3157 | ); |
---|
3158 | |
---|
3159 | /* -- Fixbug -- |
---|
3160 | * if "DURATION" has 1 day (for example). |
---|
3161 | * Event takes places between the first date |
---|
3162 | * (this define in "start" tag) and next day :( |
---|
3163 | * This "fix" destroy one day and set hours as "23" and minutes as "59" |
---|
3164 | */ |
---|
3165 | |
---|
3166 | // Weeks::Day-- |
---|
3167 | if( $ical['event'][$i]['duration']['weeks'] |
---|
3168 | AND |
---|
3169 | ( $ical['event'][$i]['duration']['hours'] == 0 ) |
---|
3170 | AND |
---|
3171 | ( $ical['event'][$i]['duration']['minutes'] == 0 ) |
---|
3172 | ) |
---|
3173 | { |
---|
3174 | $ical['event'][$i]['duration']['days'] = ( |
---|
3175 | $ical['event'][$i]['duration']['days'] + |
---|
3176 | ($ical['event'][$i]['duration']['weeks']*7))-1; |
---|
3177 | unset($ical['event'][$i]['duration']['weeks']); |
---|
3178 | $ical['event'][$i]['duration']['hours'] = "23"; |
---|
3179 | $ical['event'][$i]['duration']['minutes'] = "59"; |
---|
3180 | $ical['event'][$i]['duration']['seconds'] = "59"; |
---|
3181 | } |
---|
3182 | // Days::Day-- |
---|
3183 | if( |
---|
3184 | $ical['event'][$i]['duration']['days'] |
---|
3185 | AND |
---|
3186 | ( $ical['event'][$i]['duration']['hours'] == 0 ) |
---|
3187 | AND |
---|
3188 | ( $ical['event'][$i]['duration']['minutes'] == 0 ) |
---|
3189 | ) |
---|
3190 | { |
---|
3191 | $ical['event'][$i]['duration']['days']--; |
---|
3192 | $ical['event'][$i]['duration']['hours'] = "23"; |
---|
3193 | $ical['event'][$i]['duration']['minutes'] = "59"; |
---|
3194 | $ical['event'][$i]['duration']['seconds'] = "59"; |
---|
3195 | } |
---|
3196 | |
---|
3197 | // Create string contains datetime for strtotime |
---|
3198 | $pdate = "+"; |
---|
3199 | if( isset($ical['event'][$i]['duration']['weeks']) ) |
---|
3200 | $pdate .= $ical['event'][$i]['duration']['weeks'] . " weeks "; |
---|
3201 | if( isset($ical['event'][$i]['duration']['days']) ) |
---|
3202 | $pdate .= $ical['event'][$i]['duration']['days'] . " days "; |
---|
3203 | if( isset($ical['event'][$i]['duration']['hours']) ) |
---|
3204 | $pdate .= $ical['event'][$i]['duration']['hours'] . " hours "; |
---|
3205 | if( isset($ical['event'][$i]['duration']['minutes']) ) |
---|
3206 | $pdate .= $ical['event'][$i]['duration']['minutes'] . " minutes "; |
---|
3207 | if( isset($ical['event'][$i]['duration']['seconds']) ) |
---|
3208 | $pdate .= $ical['event'][$i]['duration']['seconds'] . " seconds "; |
---|
3209 | |
---|
3210 | // What is datetime in 2192 ? |
---|
3211 | $enddate = strtotime($pdate, $ptimer); |
---|
3212 | list( $recur_enddate['year'], |
---|
3213 | $recur_enddate['month'], |
---|
3214 | $recur_enddate['mday'], |
---|
3215 | $recur_enddate['hour'], |
---|
3216 | $recur_enddate['min'], |
---|
3217 | $recur_enddate['sec'] ) = split(":", date("Y:m:d:H:i:s", $enddate)); |
---|
3218 | |
---|
3219 | // Set End of event |
---|
3220 | $so_event->set_end( $recur_enddate['year'], |
---|
3221 | $recur_enddate['month'], |
---|
3222 | $recur_enddate['mday'], |
---|
3223 | $recur_enddate['hour'], |
---|
3224 | $recur_enddate['min'], |
---|
3225 | $recur_enddate['sec']); |
---|
3226 | |
---|
3227 | } |
---|
3228 | else |
---|
3229 | { |
---|
3230 | $recur_enddate['year'] = 0; |
---|
3231 | $recur_enddate['month'] = 0; |
---|
3232 | $recur_enddate['mday'] = 0; |
---|
3233 | } |
---|
3234 | |
---|
3235 | // recur_data |
---|
3236 | $recur_data = 0; |
---|
3237 | if(isset($ical['event'][$i]['rrule']['byday'])) |
---|
3238 | { |
---|
3239 | $week_days = Array( |
---|
3240 | MCAL_M_SUNDAY => 'SU', |
---|
3241 | MCAL_M_MONDAY => 'MO', |
---|
3242 | MCAL_M_TUESDAY => 'TU', |
---|
3243 | MCAL_M_WEDNESDAY => 'WE', |
---|
3244 | MCAL_M_THURSDAY => 'TH', |
---|
3245 | MCAL_M_FRIDAY => 'FR', |
---|
3246 | MCAL_M_SATURDAY => 'SA' |
---|
3247 | ); |
---|
3248 | @reset($week_days); |
---|
3249 | while(list($key,$val) = each($week_days)) |
---|
3250 | { |
---|
3251 | if(strpos(' '.$ical['event'][$i]['rrule']['byday'],$val)) |
---|
3252 | { |
---|
3253 | $recur_data += $key; |
---|
3254 | } |
---|
3255 | } |
---|
3256 | } |
---|
3257 | |
---|
3258 | // interval |
---|
3259 | if(!isset($ical['event'][$i]['rrule']['interval'])) |
---|
3260 | { |
---|
3261 | $interval = 1; |
---|
3262 | } |
---|
3263 | else |
---|
3264 | { |
---|
3265 | $interval = (int)$ical['event'][$i]['rrule']['interval']; |
---|
3266 | } |
---|
3267 | // recur_type |
---|
3268 | switch($ical['event'][$i]['rrule']['freq']) |
---|
3269 | { |
---|
3270 | case DAILY: |
---|
3271 | $recur_type = MCAL_RECUR_DAILY; |
---|
3272 | break; |
---|
3273 | case WEEKLY: |
---|
3274 | $so_event->set_recur_weekly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval,$recur_data); |
---|
3275 | break; |
---|
3276 | case MONTHLY: |
---|
3277 | // Still need to determine if this is by day or by week for the month.. |
---|
3278 | // $recur_type = MCAL_RECUR_M??????; |
---|
3279 | break; |
---|
3280 | case YEARLY: |
---|
3281 | $so_event->set_recur_yearly($recur_enddate['year'],$recur_enddate['month'],$recur_enddate['mday'],$interval); |
---|
3282 | break; |
---|
3283 | } |
---|
3284 | } |
---|
3285 | else |
---|
3286 | { |
---|
3287 | $so_event->set_recur_none(); |
---|
3288 | } |
---|
3289 | |
---|
3290 | // Owner |
---|
3291 | if(!isset($ical['event'][$i]['organizer']) || (isset($ical['event'][$i]['organizer']) && $this->is_owner($ical['event'][$i]['organizer']))) |
---|
3292 | { |
---|
3293 | $so_event->add_attribute('owner',$GLOBALS['phpgw_info']['user']['account_id']); |
---|
3294 | $so_event->add_attribute('participants','A',(int)$GLOBALS['phpgw_info']['user']['account_id']); |
---|
3295 | } |
---|
3296 | else |
---|
3297 | { |
---|
3298 | //owner |
---|
3299 | } |
---|
3300 | |
---|
3301 | $event = $so_event->get_cached_event(); |
---|
3302 | $so_event->add_entry($event); |
---|
3303 | // $event = $so_event->get_cached_event(); |
---|
3304 | } |
---|
3305 | } |
---|
3306 | if(!$from_ajax) { |
---|
3307 | Header('Location: '.$GLOBALS['phpgw']->link('/index.php', |
---|
3308 | Array( |
---|
3309 | 'menuaction' => 'calendar.uicalendar.view', |
---|
3310 | 'cal_id' => $event['id'] |
---|
3311 | ) |
---|
3312 | ) |
---|
3313 | ); |
---|
3314 | $GLOBALS['phpgw']->common->phpgw_exit(); |
---|
3315 | } |
---|
3316 | else |
---|
3317 | return true; |
---|
3318 | } |
---|
3319 | |
---|
3320 | function export($params) |
---|
3321 | { |
---|
3322 | $event_id = $params['l_event_id'] ? $params['l_event_id'] : $_GET['cal_id']; |
---|
3323 | $this->chunk_split = $params['chunk_split']; |
---|
3324 | $method = $params['method'] ? $params['method'] : 'publish'; |
---|
3325 | $vtype = $params['vtype'] ? $params['vtype'] : 'event'; |
---|
3326 | |
---|
3327 | $string_array = Array( |
---|
3328 | 'summary' => 'description', |
---|
3329 | 'location' => 'location', |
---|
3330 | 'description' => 'title', |
---|
3331 | 'uid' => 'uid' |
---|
3332 | ); |
---|
3333 | |
---|
3334 | $cats = CreateObject('phpgwapi.categories'); |
---|
3335 | |
---|
3336 | include(PHPGW_SERVER_ROOT.'/calendar/setup/setup.inc.php'); |
---|
3337 | if(!is_array($event_id)) |
---|
3338 | { |
---|
3339 | $ids[] = $event_id; |
---|
3340 | } |
---|
3341 | else |
---|
3342 | { |
---|
3343 | $ids = $event_id; |
---|
3344 | } |
---|
3345 | |
---|
3346 | $ical = $this->new_ical(); |
---|
3347 | |
---|
3348 | $this->set_var($ical['prodid'],'value','-//eGroupWare//eGroupWare '.$setup_info['calendar']['version'].' MIMEDIR//'.strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang'])); |
---|
3349 | $this->set_var($ical['version'],'value','2.0'); |
---|
3350 | $this->set_var($ical['method'],'value',strtoupper($method)); |
---|
3351 | |
---|
3352 | if(!$GLOBALS['phpgw_info']['flags']['included_classes']['uicalendar']) |
---|
3353 | { |
---|
3354 | if(!$GLOBALS['phpgw_info']['flags']['included_classes']['bocalendar']) |
---|
3355 | { |
---|
3356 | $so_event = createobject('calendar.socalendar', |
---|
3357 | Array( |
---|
3358 | 'owner' => 0, |
---|
3359 | 'filter' => '', |
---|
3360 | 'category' => '' |
---|
3361 | ) |
---|
3362 | ); |
---|
3363 | } |
---|
3364 | else |
---|
3365 | { |
---|
3366 | $so_event = $GLOBALS['bocalendar']->so; |
---|
3367 | } |
---|
3368 | } |
---|
3369 | else |
---|
3370 | { |
---|
3371 | $so_event = $GLOBALS['uicalendar']->bo->so; |
---|
3372 | } |
---|
3373 | |
---|
3374 | foreach($ids as $event) |
---|
3375 | { |
---|
3376 | $ical_event = Array(); |
---|
3377 | if (!is_array($event)) |
---|
3378 | { |
---|
3379 | $event = $so_event->read_entry($event); |
---|
3380 | } |
---|
3381 | if($event['alarm']) |
---|
3382 | { |
---|
3383 | foreach($event['alarm'] as $alarm) |
---|
3384 | { |
---|
3385 | $ical_temp = Array(); |
---|
3386 | $ical_temp['action']['value'] = 'DISPLAY'; |
---|
3387 | $ical_temp['description']['value'] = $alarm['text']; |
---|
3388 | $this->set_var($ical_temp['trigger'],'value','VALUE=DATE-TIME:'.date('Ymd\THis\Z',$alarm['time']),'valarm'); |
---|
3389 | $ical_event['alarm'][] = $ical_temp; |
---|
3390 | } |
---|
3391 | } |
---|
3392 | |
---|
3393 | // use system's date info for caluculating local timezone's offset in minutes |
---|
3394 | // |
---|
3395 | $gmt_offset = date('O',$GLOBALS['phpgw']->datetime->users_localtime); // offset to GMT |
---|
3396 | $offset = (int)(substr($gmt_offset, 0, 3)) * 60 + (int)(substr($gmt_offset, 3, 2)); |
---|
3397 | $event['start']['min'] -= $offset; |
---|
3398 | $event['end']['min'] -= $offset; |
---|
3399 | $event['modtime']['min'] -= $offset; |
---|
3400 | |
---|
3401 | $ical_event['priority'] = $event['priority']; |
---|
3402 | $ical_event['class'] = (int)$event['public']; |
---|
3403 | $dtstart_mktime = $so_event->maketime($event['start']); |
---|
3404 | $this->parse_value($ical_event,'dtstart',date('Ymd\THis\Z',$dtstart_mktime),'vevent'); |
---|
3405 | $dtend_mktime = $so_event->maketime($event['end']); |
---|
3406 | $this->parse_value($ical_event,'dtend',date('Ymd\THis\Z',$dtend_mktime),'vevent'); |
---|
3407 | $mod_mktime = $so_event->maketime($event['modtime']); |
---|
3408 | $this->parse_value($ical_event,'last_modified',date('Ymd\THis\Z',$mod_mktime),'vevent'); |
---|
3409 | foreach($string_array as $ical_value => $event_value) |
---|
3410 | { |
---|
3411 | if($event[$event_value]) |
---|
3412 | { |
---|
3413 | $this->set_var($ical_event[$ical_value],'value',$event[$event_value]); |
---|
3414 | } |
---|
3415 | } |
---|
3416 | |
---|
3417 | if ($event['category']) |
---|
3418 | { |
---|
3419 | $cats->categories(0,'calendar'); |
---|
3420 | foreach(explode(',',$event['category']) as $cat) |
---|
3421 | { |
---|
3422 | $_cat = $cats->return_single($cat); |
---|
3423 | $cat_string[] = $_cat[0]['name']; |
---|
3424 | } |
---|
3425 | @reset($cat_string); |
---|
3426 | $this->set_var($ical_event['categories'],'value',implode($cat_string,',')); |
---|
3427 | } |
---|
3428 | |
---|
3429 | if(count($event['participants']) > 1) |
---|
3430 | { |
---|
3431 | if(!is_object($db)) |
---|
3432 | { |
---|
3433 | $db = $GLOBALS['phpgw']->db; |
---|
3434 | } |
---|
3435 | foreach($event['participants'] as $part => $status) |
---|
3436 | { |
---|
3437 | $GLOBALS['phpgw']->accounts->get_account_name($part,$lid,$fname,$lname); |
---|
3438 | $name = $fname.' '.$lname; |
---|
3439 | |
---|
3440 | $owner_status = $this->switch_partstat((int)$this->switch_phpgw_status($event['participants'][$part])); |
---|
3441 | |
---|
3442 | $mail_prefs = $GLOBALS['phpgw']->preferences->create_email_preferences($part); |
---|
3443 | $mailto = $mail_prefs['email']['address']; |
---|
3444 | |
---|
3445 | $str = 'CN="'.$name.'";PARTSTAT='.$owner_status.':'.$mailto; |
---|
3446 | if($part == $event['owner']) |
---|
3447 | { |
---|
3448 | $str = 'ROLE=CHAIR;'.$str; |
---|
3449 | } |
---|
3450 | else |
---|
3451 | { |
---|
3452 | $str = 'ROLE=REQ-PARTICIPANT;'.$str; |
---|
3453 | } |
---|
3454 | if ($method != 'reply' || $part == $GLOBALS['phpgw_info']['user']['account_id']) |
---|
3455 | { |
---|
3456 | $this->parse_value($ical_event,'attendee',$str,'vevent'); |
---|
3457 | } |
---|
3458 | if($part == $event['owner']) |
---|
3459 | { |
---|
3460 | $this->parse_value($ical_event,'organizer',$str,'vevent'); |
---|
3461 | } |
---|
3462 | } |
---|
3463 | } |
---|
3464 | if($event['recur_type']) |
---|
3465 | { |
---|
3466 | $str = ''; |
---|
3467 | switch($event['recur_type']) |
---|
3468 | { |
---|
3469 | case MCAL_RECUR_DAILY: |
---|
3470 | $str .= 'FREQ=DAILY'; |
---|
3471 | break; |
---|
3472 | case MCAL_RECUR_WEEKLY: |
---|
3473 | $str .= 'FREQ=WEEKLY'; |
---|
3474 | if($event['recur_data']) |
---|
3475 | { |
---|
3476 | $str .= ';BYDAY='; |
---|
3477 | for($i=1;$i<MCAL_M_ALLDAYS;$i=$i*2) |
---|
3478 | { |
---|
3479 | if($i & $event['recur_data']) |
---|
3480 | { |
---|
3481 | switch($i) |
---|
3482 | { |
---|
3483 | case MCAL_M_SUNDAY: |
---|
3484 | $day[] = 'SU'; |
---|
3485 | break; |
---|
3486 | case MCAL_M_MONDAY: |
---|
3487 | $day[] = 'MO'; |
---|
3488 | break; |
---|
3489 | CASE MCAL_M_TUESDAY: |
---|
3490 | $day[] = 'TU'; |
---|
3491 | break; |
---|
3492 | case MCAL_M_WEDNESDAY: |
---|
3493 | $day[] = 'WE'; |
---|
3494 | break; |
---|
3495 | case MCAL_M_THURSDAY: |
---|
3496 | $day[] = 'TH'; |
---|
3497 | break; |
---|
3498 | case MCAL_M_FRIDAY: |
---|
3499 | $day[] = 'FR'; |
---|
3500 | break; |
---|
3501 | case MCAL_M_SATURDAY: |
---|
3502 | $day[] = 'SA'; |
---|
3503 | break; |
---|
3504 | } |
---|
3505 | } |
---|
3506 | } |
---|
3507 | $str .= implode(',',$day); |
---|
3508 | } |
---|
3509 | break; |
---|
3510 | case MCAL_RECUR_MONTHLY_MDAY: |
---|
3511 | break; |
---|
3512 | case MCAL_RECUR_MONTHLY_WDAY: |
---|
3513 | break; |
---|
3514 | case MCAL_RECUR_YEARLY: |
---|
3515 | $str .= 'FREQ=YEARLY'; |
---|
3516 | break; |
---|
3517 | } |
---|
3518 | if($event['recur_interval']) |
---|
3519 | { |
---|
3520 | $str .= ';INTERVAL='.$event['recur_interval']; |
---|
3521 | } |
---|
3522 | if($event['recur_enddate']['month'] != 0 && $event['recur_enddate']['mday'] != 0 && $event['recur_enddate']['year'] != 0) |
---|
3523 | { |
---|
3524 | $recur_mktime = $so_event->maketime($event['recur_enddate']) - $GLOBALS['phpgw']->datetime->tz_offset; |
---|
3525 | $str .= ';UNTIL='.date('Ymd\THis\Z',$recur_mktime); |
---|
3526 | } |
---|
3527 | $this->parse_value($ical_event,'rrule',$str,'vevent'); |
---|
3528 | |
---|
3529 | $exceptions = $event['recur_exception']; |
---|
3530 | if(is_array($exceptions)) |
---|
3531 | { |
---|
3532 | foreach($exceptions as $except_datetime) |
---|
3533 | { |
---|
3534 | $ical_event['exdate'][] = $this->switch_date(date('Ymd\THis\Z',$except_datetime)); |
---|
3535 | } |
---|
3536 | } |
---|
3537 | } |
---|
3538 | $ical_events[] = $ical_event; |
---|
3539 | } |
---|
3540 | |
---|
3541 | $ical[$vtype] = $ical_events; |
---|
3542 | |
---|
3543 | // iCals are by default utf-8 |
---|
3544 | return $GLOBALS['phpgw']->translation->convert($this->build_ical($ical),$GLOBALS['phpgw']->translation->charset(),'utf-8'); |
---|
3545 | } |
---|
3546 | |
---|
3547 | function freebusy($params=False) |
---|
3548 | { |
---|
3549 | if (!$params) $params = $_GET; |
---|
3550 | $user = is_numeric($params['user']) ? (int) $params['user'] : $GLOBALS['phpgw']->accounts->name2id($params['user']); |
---|
3551 | $start = isset($params['start']) ? $params['start'] : date('Ymd'); |
---|
3552 | $end = isset($params['end']) ? $params['end'] : (date('Y')+1).date('md'); |
---|
3553 | |
---|
3554 | $this->bo = CreateObject('calendar.bocalendar'); |
---|
3555 | $events_per_day = $this->bo->store_to_cache(array( |
---|
3556 | 'owner' => $user, |
---|
3557 | 'syear' => (int) substr($start,0,4), |
---|
3558 | 'smonth' => (int) substr($start,4,2), |
---|
3559 | 'sday' => (int) substr($start,6,2), |
---|
3560 | 'eyear' => (int) substr($end,0,4), |
---|
3561 | 'emonth' => (int) substr($end,4,2), |
---|
3562 | 'eday' => (int) substr($end,6,2), |
---|
3563 | 'no_doubles' => True, // report events only on the startday |
---|
3564 | )); |
---|
3565 | if (!is_array($events_per_day)) $events_per_day = array(); |
---|
3566 | $ids = array(); |
---|
3567 | foreach($events_per_day as $day => $events) |
---|
3568 | { |
---|
3569 | foreach($events as $event) |
---|
3570 | { |
---|
3571 | $ids[] = $event; |
---|
3572 | } |
---|
3573 | } |
---|
3574 | $browser = CreateObject('phpgwapi.browser'); |
---|
3575 | $browser->content_header($GLOBALS['phpgw']->accounts->id2name($user).'.ifb','text/calendar'); |
---|
3576 | |
---|
3577 | echo $this->export(array( |
---|
3578 | 'vtype' => 'freebusy', |
---|
3579 | 'l_event_id' => $ids, |
---|
3580 | )); |
---|
3581 | } |
---|
3582 | |
---|
3583 | function debug($str='') |
---|
3584 | { |
---|
3585 | if($this->debug_str) |
---|
3586 | { |
---|
3587 | echo $str."<br>\n"; |
---|
3588 | } |
---|
3589 | } |
---|
3590 | } |
---|
3591 | ?> |
---|