@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $id ='' |
154 | 154 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
155 | 155 | */ |
156 | - function propfind($path,&$options,&$files,$user,$id='') |
|
156 | + function propfind($path, &$options, &$files, $user, $id = '') |
|
157 | 157 | { |
158 | 158 | if ($this->debug) |
159 | 159 | { |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | 'enum_recuring' => false, |
180 | 180 | 'daywise' => false, |
181 | 181 | 'date_format' => 'server', |
182 | - 'no_total' => true, // we need no total number of rows (saves extra query) |
|
183 | - 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
182 | + 'no_total' => true, // we need no total number of rows (saves extra query) |
|
183 | + 'cfs' => array(), // return custom-fields, as we use them to store X- attributes |
|
184 | 184 | ); |
185 | - foreach(array( |
|
185 | + foreach (array( |
|
186 | 186 | 'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'], |
187 | 187 | 'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'], |
188 | 188 | ) as $name => $value) |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | { |
192 | 192 | $value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT; |
193 | 193 | } |
194 | - $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
|
194 | + $filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value); |
|
195 | 195 | } |
196 | 196 | if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
197 | 197 | { |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | $filter['filter'] = 'owner'; |
204 | 204 | } |
205 | 205 | // scheduling inbox, shows only not yet accepted or rejected events |
206 | - elseif (substr($path,-7) == '/inbox/') |
|
206 | + elseif (substr($path, -7) == '/inbox/') |
|
207 | 207 | { |
208 | 208 | $filter['filter'] = 'unknown'; |
209 | - $filter['start'] = $this->bo->now; // only return future invitations |
|
209 | + $filter['start'] = $this->bo->now; // only return future invitations |
|
210 | 210 | } |
211 | 211 | // ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now |
212 | - elseif (substr($path,-8) == '/outbox/') |
|
212 | + elseif (substr($path, -8) == '/outbox/') |
|
213 | 213 | { |
214 | 214 | return true; |
215 | 215 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | // when trying to request not supported components, eg. VTODO on a calendar collection |
227 | 227 | return true; |
228 | 228 | } |
229 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
229 | + if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
230 | 230 | |
231 | 231 | if ($this->debug > 1) |
232 | 232 | { |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | |
244 | 244 | $this->sync_collection_token = null; |
245 | 245 | |
246 | - $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
246 | + $filter['order'] = 'cal_modified ASC'; // return oldest modifications first |
|
247 | 247 | $filter['sync-collection'] = true; |
248 | 248 | // no end-date / limit into the future, as unchanged entries would never be transferted later on |
249 | 249 | unset($filter['end']); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | |
252 | 252 | if (isset($nresults)) |
253 | 253 | { |
254 | - unset($filter['no_total']); // we need the total! |
|
254 | + unset($filter['no_total']); // we need the total! |
|
255 | 255 | $files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults)); |
256 | 256 | |
257 | 257 | // hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first) |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults) |
261 | 261 | { |
262 | 262 | --$this->sync_collection_token; |
263 | - $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
263 | + $files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | else |
267 | 267 | { |
268 | 268 | // return iterator, calling ourself to return result in chunks |
269 | - $files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']); |
|
269 | + $files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']); |
|
270 | 270 | } |
271 | 271 | if (isset($_GET['download'])) |
272 | 272 | { |
@@ -286,9 +286,9 @@ discard block |
||
286 | 286 | Api\Header\Content::type('calendar.ics', 'text/calendar'); |
287 | 287 | |
288 | 288 | $n = 0; |
289 | - foreach($files as $file) |
|
289 | + foreach ($files as $file) |
|
290 | 290 | { |
291 | - if (!$n++) continue; // first entry is collection itself |
|
291 | + if (!$n++) continue; // first entry is collection itself |
|
292 | 292 | |
293 | 293 | $icalendar = $file['props']['calendar-data']['val']; |
294 | 294 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | echo substr($icalendar, 0, $start); |
313 | 313 | } |
314 | 314 | } |
315 | - echo substr($icalendar, $start, $end-$start); |
|
315 | + echo substr($icalendar, $start, $end - $start); |
|
316 | 316 | } |
317 | 317 | } |
318 | 318 | if ($icalendar && $end) |
@@ -330,12 +330,12 @@ discard block |
||
330 | 330 | * @param array|boolean $start =false false=return all or array(start,num) |
331 | 331 | * @return array with "files" array with values for keys path and props |
332 | 332 | */ |
333 | - function &propfind_callback($path,array $filter,$start=false) |
|
333 | + function &propfind_callback($path, array $filter, $start = false) |
|
334 | 334 | { |
335 | 335 | if ($this->debug) $starttime = microtime(true); |
336 | 336 | |
337 | 337 | $calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true); |
338 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
338 | + if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
339 | 339 | |
340 | 340 | $files = array(); |
341 | 341 | |
@@ -347,11 +347,11 @@ discard block |
||
347 | 347 | $requested_multiget_ids = (array)$filter['query'][self::$path_attr]; |
348 | 348 | $sync_collection = $filter['sync-collection']; |
349 | 349 | |
350 | - $events =& $this->bo->search($filter); |
|
350 | + $events = & $this->bo->search($filter); |
|
351 | 351 | |
352 | 352 | if ($events) |
353 | 353 | { |
354 | - foreach($events as $event) |
|
354 | + foreach ($events as $event) |
|
355 | 355 | { |
356 | 356 | // remove event from requested multiget ids, to be able to report not found urls |
357 | 357 | if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false) |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | unset($requested_multiget_ids[$k]); |
360 | 360 | } |
361 | 361 | // sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations |
362 | - if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R','X')))) |
|
362 | + if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R', 'X')))) |
|
363 | 363 | { |
364 | 364 | $files[] = array('path' => $path.urldecode($this->get_path($event))); |
365 | 365 | continue; |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | !isset($calendar_data['children']['expand']) ? false : |
391 | 391 | ($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true)); |
392 | 392 | $props['getcontentlength'] = bytes($content); |
393 | - $props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content); |
|
393 | + $props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content); |
|
394 | 394 | } |
395 | 395 | /* Calendarserver reports new events with schedule-changes: action: create, which iCal request |
396 | 396 | * adding it, unfortunately does not lead to showing the new event in the users inbox |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | // report not found multiget urls |
410 | 410 | if ($requested_multiget_ids) |
411 | 411 | { |
412 | - foreach($requested_multiget_ids as $id) |
|
412 | + foreach ($requested_multiget_ids as $id) |
|
413 | 413 | { |
414 | 414 | $files[] = array('path' => $path.$id.self::$path_extension); |
415 | 415 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | private function _created_updated_by_prop($user, $time) |
446 | 446 | { |
447 | 447 | $props = array(); |
448 | - foreach(array( |
|
448 | + foreach (array( |
|
449 | 449 | 'first-name' => 'account_firstname', |
450 | 450 | 'last-name' => 'account_lastname', |
451 | 451 | 'href' => 'account_email', |
@@ -488,23 +488,23 @@ discard block |
||
488 | 488 | $cal_end = $cal_filters['end']; unset($cal_filters['end']); |
489 | 489 | $num_filters = count($cal_filters); |
490 | 490 | |
491 | - foreach($options['filters'] as $filter) |
|
491 | + foreach ($options['filters'] as $filter) |
|
492 | 492 | { |
493 | - switch($filter['name']) |
|
493 | + switch ($filter['name']) |
|
494 | 494 | { |
495 | 495 | case 'comp-filter': |
496 | 496 | if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
497 | 497 | |
498 | - switch($filter['attrs']['name']) |
|
498 | + switch ($filter['attrs']['name']) |
|
499 | 499 | { |
500 | 500 | case 'VTODO': |
501 | - return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
501 | + return false; // return nothing for now, todo: check if we can pass it on to the infolog handler |
|
502 | 502 | // todos are handled by the infolog handler |
503 | 503 | //$infolog_handler = new groupdav_infolog(); |
504 | 504 | //return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method); |
505 | 505 | case 'VCALENDAR': |
506 | 506 | case 'VEVENT': |
507 | - break; // that's our default anyway |
|
507 | + break; // that's our default anyway |
|
508 | 508 | } |
509 | 509 | break; |
510 | 510 | case 'prop-filter': |
@@ -527,14 +527,14 @@ discard block |
||
527 | 527 | if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
528 | 528 | break; |
529 | 529 | case 'time-range': |
530 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
530 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
531 | 531 | if (!empty($filter['attrs']['start'])) |
532 | 532 | { |
533 | 533 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
534 | 534 | } |
535 | 535 | if (!empty($filter['attrs']['end'])) |
536 | 536 | { |
537 | - $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
537 | + $cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']); |
|
538 | 538 | } |
539 | 539 | break; |
540 | 540 | default: |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | <B:nresults>10</B:nresults> |
556 | 556 | </B:limit> |
557 | 557 | */ |
558 | - foreach((array)$options['other'] as $option) |
|
558 | + foreach ((array)$options['other'] as $option) |
|
559 | 559 | { |
560 | - switch($option['name']) |
|
560 | + switch ($option['name']) |
|
561 | 561 | { |
562 | 562 | case 'nresults': |
563 | 563 | $nresults = (int)$option['data']; |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | case 'limit': |
567 | 567 | break; |
568 | 568 | case 'href': |
569 | - break; // from addressbook-multiget, handled below |
|
569 | + break; // from addressbook-multiget, handled below |
|
570 | 570 | // rfc 6578 sync-report |
571 | 571 | case 'sync-token': |
572 | 572 | if (!empty($option['data'])) |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $parts = explode('/', $option['data']); |
575 | 575 | $sync_token = array_pop($parts); |
576 | 576 | $cal_filters['query'][] = 'cal_modified>'.(int)$sync_token; |
577 | - $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
577 | + $cal_filters['filter'] = 'everything'; // to return deleted entries too |
|
578 | 578 | // no standard time-range! |
579 | 579 | unset($cal_filters['start']); |
580 | 580 | } |
@@ -603,25 +603,25 @@ discard block |
||
603 | 603 | if ($id) |
604 | 604 | { |
605 | 605 | $cal_filters['query'][self::$path_attr] = self::$path_extension ? |
606 | - basename($id,self::$path_extension) : $id; |
|
606 | + basename($id, self::$path_extension) : $id; |
|
607 | 607 | } |
608 | 608 | else // fetch all given url's |
609 | 609 | { |
610 | - foreach($options['other'] as $option) |
|
610 | + foreach ($options['other'] as $option) |
|
611 | 611 | { |
612 | 612 | if ($option['name'] == 'href') |
613 | 613 | { |
614 | - $parts = explode('/',$option['data']); |
|
614 | + $parts = explode('/', $option['data']); |
|
615 | 615 | if (($id = urldecode(array_pop($parts)))) |
616 | 616 | { |
617 | 617 | $cal_filters['query'][self::$path_attr][] = self::$path_extension ? |
618 | - basename($id,self::$path_extension) : $id; |
|
618 | + basename($id, self::$path_extension) : $id; |
|
619 | 619 | } |
620 | 620 | } |
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
624 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
624 | + if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters)); |
|
625 | 625 | } |
626 | 626 | return true; |
627 | 627 | } |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @param int $user =null account_id |
635 | 635 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
636 | 636 | */ |
637 | - function get(&$options,$id,$user=null) |
|
637 | + function get(&$options, $id, $user = null) |
|
638 | 638 | { |
639 | - if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id))) |
|
639 | + if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id))) |
|
640 | 640 | { |
641 | 641 | return $event; |
642 | 642 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences |
665 | 665 | * @return string |
666 | 666 | */ |
667 | - private function iCal(array $event,$user=null, $method=null, $expand=false) |
|
667 | + private function iCal(array $event, $user = null, $method = null, $expand = false) |
|
668 | 668 | { |
669 | 669 | static $handler = null; |
670 | 670 | if (is_null($handler)) $handler = $this->_get_handler(); |
@@ -688,13 +688,13 @@ discard block |
||
688 | 688 | if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
689 | 689 | if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
690 | 690 | } |
691 | - $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
|
691 | + $events = & self::get_series($event['uid'], $this->bo, $expand, $user); |
|
692 | 692 | // as alarm is now only on next recurrence, set alarm from original event on master |
693 | 693 | if ($event['alarm']) $events[0]['alarm'] = $event['alarm']; |
694 | 694 | } |
695 | - elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
|
695 | + elseif (!$this->client_shared_uid_exceptions && $event['reference']) |
|
696 | 696 | { |
697 | - $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
697 | + $events[0]['uid'] .= '-'.$event['id']; // force a different uid |
|
698 | 698 | } |
699 | 699 | return $handler->exportVCal($events, '2.0', $method); |
700 | 700 | } |
@@ -710,20 +710,20 @@ discard block |
||
710 | 710 | * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in |
711 | 711 | * @return array |
712 | 712 | */ |
713 | - private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
|
713 | + private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null) |
|
714 | 714 | { |
715 | 715 | if (is_null($bo)) $bo = new calendar_bopdate(); |
716 | 716 | |
717 | 717 | $params = array( |
718 | 718 | 'query' => array('cal_uid' => $uid), |
719 | - 'filter' => 'owner', // return all possible entries |
|
719 | + 'filter' => 'owner', // return all possible entries |
|
720 | 720 | 'daywise' => false, |
721 | 721 | 'date_format' => 'server', |
722 | - 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
722 | + 'cfs' => array(), // read cfs as we use them to store X- attributes |
|
723 | 723 | ); |
724 | 724 | if (is_array($expand)) $params += $expand; |
725 | 725 | |
726 | - if (!($events =& $bo->search($params))) |
|
726 | + if (!($events = & $bo->search($params))) |
|
727 | 727 | { |
728 | 728 | return array(); |
729 | 729 | } |
@@ -731,12 +731,12 @@ discard block |
||
731 | 731 | // find master, which is not always first event, eg. when first event is an exception |
732 | 732 | $master = null; |
733 | 733 | $exceptions = array(); |
734 | - foreach($events as $k => &$recurrence) |
|
734 | + foreach ($events as $k => &$recurrence) |
|
735 | 735 | { |
736 | 736 | if ($recurrence['recur_type']) |
737 | 737 | { |
738 | 738 | $master = $recurrence; |
739 | - $exceptions =& $master['recur_exception']; |
|
739 | + $exceptions = & $master['recur_exception']; |
|
740 | 740 | unset($events[$k]); |
741 | 741 | break; |
742 | 742 | } |
@@ -744,13 +744,13 @@ discard block |
||
744 | 744 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
745 | 745 | if (!isset($master)) $master = $bo->read($uid); |
746 | 746 | |
747 | - foreach($events as $k => &$recurrence) |
|
747 | + foreach ($events as $k => &$recurrence) |
|
748 | 748 | { |
749 | 749 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); |
750 | 750 | if ($master && $recurrence['reference'] != $master['id']) |
751 | 751 | { |
752 | 752 | unset($events[$k]); |
753 | - continue; // same uid, but references a different event or is own master |
|
753 | + continue; // same uid, but references a different event or is own master |
|
754 | 754 | } |
755 | 755 | if (!$master || $recurrence['id'] != $master['id']) // real exception |
756 | 756 | { |
@@ -771,11 +771,11 @@ discard block |
||
771 | 771 | // at least Lightning "understands" EXDATE as exception from what's included |
772 | 772 | // in the whole resource / VCALENDAR component |
773 | 773 | // not removing it causes Lightning to remove the exception itself |
774 | - if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false) |
|
774 | + if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false) |
|
775 | 775 | { |
776 | 776 | unset($exceptions[$e]); |
777 | 777 | } |
778 | - continue; // nothing to change |
|
778 | + continue; // nothing to change |
|
779 | 779 | } |
780 | 780 | // add alarms from master to recurrences, as clients otherwise have no alarms on virtual exceptions |
781 | 781 | if ($master && $master['alarm']) |
@@ -786,14 +786,14 @@ discard block |
||
786 | 786 | if (!$expand && $master && $master['participants'] == $recurrence['participants']) |
787 | 787 | { |
788 | 788 | //error_log('NO exception: '.array2string($recurrence)); |
789 | - unset($events[$k]); // no exception --> remove it |
|
789 | + unset($events[$k]); // no exception --> remove it |
|
790 | 790 | continue; |
791 | 791 | } |
792 | 792 | // this is a virtual exception now (no extra event/cal_id in DB) |
793 | 793 | //error_log('virtual exception: '.array2string($recurrence)); |
794 | 794 | $recurrence['recurrence'] = $recurrence['start']; |
795 | 795 | if ($master) $recurrence['reference'] = $master['id']; |
796 | - $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
796 | + $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
|
797 | 797 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
798 | 798 | } |
799 | 799 | // only add master if we are not expanding and current user participates in master (and not just some exceptions) |
@@ -829,11 +829,11 @@ discard block |
||
829 | 829 | * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook) |
830 | 830 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
831 | 831 | */ |
832 | - function put(&$options,$id,$user=null,$prefix=null) |
|
832 | + function put(&$options, $id, $user = null, $prefix = null) |
|
833 | 833 | { |
834 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
834 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
835 | 835 | |
836 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
836 | + if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
837 | 837 | |
838 | 838 | // work around missing handling / racecondition in Lightning, if event already exists on server, |
839 | 839 | // but Lightning has not yet synced with the server: Lightning just retries the PUT, not GETing the event |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | { |
851 | 851 | $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE']; |
852 | 852 | } |
853 | - $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
854 | - $oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access, |
|
855 | - isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
853 | + $return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants |
|
854 | + $oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access, |
|
855 | + isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
|
856 | 856 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
857 | 857 | { |
858 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
858 | + if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace()); |
|
859 | 859 | return $oldEvent; |
860 | 860 | } |
861 | 861 | |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | if (($events = $handler->icaltoegw($vCalendar))) |
948 | 948 | { |
949 | 949 | $modified = 0; |
950 | - foreach($events as $n => $event) |
|
950 | + foreach ($events as $n => $event) |
|
951 | 951 | { |
952 | 952 | // for recurrances of event series, we need to read correct recurrence (or if series master is no first event) |
953 | 953 | if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series)) |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | $series = self::get_series($event['uid'], $this->bo); |
959 | 959 | //foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent)); |
960 | 960 | } |
961 | - foreach($series as $oldEvent) |
|
961 | + foreach ($series as $oldEvent) |
|
962 | 962 | { |
963 | 963 | if ($oldEvent['recurrence'] == $event['recurrence']) break; |
964 | 964 | } |
@@ -1023,9 +1023,9 @@ discard block |
||
1023 | 1023 | isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']])) |
1024 | 1024 | { |
1025 | 1025 | // just update etag in database |
1026 | - $GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array( |
|
1026 | + $GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array( |
|
1027 | 1027 | 'cal_id' => $eventId, |
1028 | - ),__LINE__,__FILE__,'calendar'); |
|
1028 | + ), __LINE__, __FILE__, 'calendar'); |
|
1029 | 1029 | } |
1030 | 1030 | } |
1031 | 1031 | } |
@@ -1077,9 +1077,9 @@ discard block |
||
1077 | 1077 | * @param int $user =null account_id of owner, default null |
1078 | 1078 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1079 | 1079 | */ |
1080 | - function post(&$options,$id,$user=null) |
|
1080 | + function post(&$options, $id, $user = null) |
|
1081 | 1081 | { |
1082 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1082 | + if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true)); |
|
1083 | 1083 | |
1084 | 1084 | $vCalendar = htmlspecialchars_decode($options['content']); |
1085 | 1085 | $charset = null; |
@@ -1101,7 +1101,7 @@ discard block |
||
1101 | 1101 | } |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - if (substr($options['path'],-8) == '/outbox/') |
|
1104 | + if (substr($options['path'], -8) == '/outbox/') |
|
1105 | 1105 | { |
1106 | 1106 | if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar)) |
1107 | 1107 | { |
@@ -1152,7 +1152,7 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | protected function outbox_freebusy_request($ical, $charset, $user, array &$options) |
1154 | 1154 | { |
1155 | - unset($options); // not used, but required by function signature |
|
1155 | + unset($options); // not used, but required by function signature |
|
1156 | 1156 | |
1157 | 1157 | $vcal = new Horde_Icalendar(); |
1158 | 1158 | if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset)) |
@@ -1165,7 +1165,7 @@ discard block |
||
1165 | 1165 | |
1166 | 1166 | $handler = $this->_get_handler(); |
1167 | 1167 | $handler->setSupportedFields('groupdav'); |
1168 | - $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1168 | + $handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something |
|
1169 | 1169 | if (!($component = $vcal->getComponent(0)) || |
1170 | 1170 | !($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy'))) |
1171 | 1171 | { |
@@ -1190,13 +1190,13 @@ discard block |
||
1190 | 1190 | $xml->startDocument('1.0', 'UTF-8'); |
1191 | 1191 | $xml->startElementNs('C', 'schedule-response', Api\CalDAV::CALDAV); |
1192 | 1192 | |
1193 | - foreach(array_keys($event['participants']) as $uid) |
|
1193 | + foreach (array_keys($event['participants']) as $uid) |
|
1194 | 1194 | { |
1195 | 1195 | $xml->startElementNs('C', 'response', null); |
1196 | 1196 | |
1197 | 1197 | $xml->startElementNs('C', 'recipient', null); |
1198 | - $xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees)); |
|
1199 | - $xml->endElement(); // recipient |
|
1198 | + $xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees)); |
|
1199 | + $xml->endElement(); // recipient |
|
1200 | 1200 | |
1201 | 1201 | $xml->writeElementNs('C', 'request-status', null, '2.0;Success'); |
1202 | 1202 | $xml->writeElementNs('C', 'calendar-data', null, |
@@ -1204,13 +1204,13 @@ discard block |
||
1204 | 1204 | 'UID' => $event['uid'], |
1205 | 1205 | 'ORGANIZER' => $organizer, |
1206 | 1206 | 'ATTENDEE' => $attendee, |
1207 | - )+(empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1207 | + ) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array( |
|
1208 | 1208 | 'X-CALENDARSERVER-MASK-UID' => $mask_uid, |
1209 | 1209 | )))); |
1210 | 1210 | |
1211 | - $xml->endElement(); // response |
|
1211 | + $xml->endElement(); // response |
|
1212 | 1212 | } |
1213 | - $xml->endElement(); // schedule-response |
|
1213 | + $xml->endElement(); // schedule-response |
|
1214 | 1214 | $xml->endDocument(); |
1215 | 1215 | echo $xml->outputMemory(); |
1216 | 1216 | |
@@ -1225,14 +1225,14 @@ discard block |
||
1225 | 1225 | * @param int $user account_id |
1226 | 1226 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1227 | 1227 | */ |
1228 | - function free_busy_report($path,$options,$user) |
|
1228 | + function free_busy_report($path, $options, $user) |
|
1229 | 1229 | { |
1230 | - unset($path); // unused, but required by function signature |
|
1230 | + unset($path); // unused, but required by function signature |
|
1231 | 1231 | if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user)) |
1232 | 1232 | { |
1233 | 1233 | return '403 Forbidden'; |
1234 | 1234 | } |
1235 | - foreach($options['other'] as $filter) |
|
1235 | + foreach ($options['other'] as $filter) |
|
1236 | 1236 | { |
1237 | 1237 | if ($filter['name'] == 'time-range') |
1238 | 1238 | { |
@@ -1244,7 +1244,7 @@ discard block |
||
1244 | 1244 | header('Content-Type: text/calendar'); |
1245 | 1245 | echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array()); |
1246 | 1246 | |
1247 | - exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1247 | + exit(); // otherwise we get a 207 multistatus, not 200 Ok |
|
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | /** |
@@ -1256,7 +1256,7 @@ discard block |
||
1256 | 1256 | * @param int $user =null owner of the collection, default current user |
1257 | 1257 | * @return array with privileges |
1258 | 1258 | */ |
1259 | - public function current_user_privileges($path, $user=null) |
|
1259 | + public function current_user_privileges($path, $user = null) |
|
1260 | 1260 | { |
1261 | 1261 | $privileges = parent::current_user_privileges($path, $user); |
1262 | 1262 | //error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges)); |
@@ -1299,7 +1299,7 @@ discard block |
||
1299 | 1299 | |
1300 | 1300 | // get array with orginal recurrences indexed by recurrence-id |
1301 | 1301 | $org_recurrences = $exceptions = array(); |
1302 | - foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
|
1302 | + foreach (self::get_series($events[0]['uid'], $bo) as $k => $event) |
|
1303 | 1303 | { |
1304 | 1304 | if (!$k) $master = $event; |
1305 | 1305 | if ($event['recurrence']) |
@@ -1309,13 +1309,13 @@ discard block |
||
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | // assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master |
1312 | - foreach($events as $k => &$recurrence) |
|
1312 | + foreach ($events as $k => &$recurrence) |
|
1313 | 1313 | { |
1314 | 1314 | if (!$recurrence['recurrence']) |
1315 | 1315 | { |
1316 | 1316 | // master |
1317 | 1317 | $recurrence['id'] = $master['id']; |
1318 | - $master =& $events[$k]; |
|
1318 | + $master = & $events[$k]; |
|
1319 | 1319 | continue; |
1320 | 1320 | } |
1321 | 1321 | |
@@ -1339,12 +1339,12 @@ discard block |
||
1339 | 1339 | $master['recur_exception'] = array_merge($exceptions, $master['recur_exception']); |
1340 | 1340 | |
1341 | 1341 | // delete not longer existing recurrences |
1342 | - foreach($org_recurrences as $org_recurrence) |
|
1342 | + foreach ($org_recurrences as $org_recurrence) |
|
1343 | 1343 | { |
1344 | 1344 | if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
1345 | 1345 | { |
1346 | 1346 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
1347 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1347 | + $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1348 | 1348 | } |
1349 | 1349 | else // virtual recurrence |
1350 | 1350 | { |
@@ -1366,14 +1366,14 @@ discard block |
||
1366 | 1366 | * @param int $user account_id of collection owner |
1367 | 1367 | * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') |
1368 | 1368 | */ |
1369 | - function delete(&$options,$id,$user) |
|
1369 | + function delete(&$options, $id, $user) |
|
1370 | 1370 | { |
1371 | 1371 | if (strpos($options['path'], '/inbox/') !== false) |
1372 | 1372 | { |
1373 | - return true; // simply ignore DELETE in inbox for now |
|
1373 | + return true; // simply ignore DELETE in inbox for now |
|
1374 | 1374 | } |
1375 | - $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1376 | - if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access || |
|
1375 | + $return_no_access = true; // to allow to check if current use is a participant and reject the event for him |
|
1376 | + if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access || |
|
1377 | 1377 | // Work around problems with Outlook CalDAV Synchroniser (https://caldavsynchronizer.org/) |
1378 | 1378 | // - sends a DELETE to reject a meeting request --> deletes event for all participants, if user has delete rights on the calendar |
1379 | 1379 | // --> only set status for everyone else but the organizer |
@@ -1384,11 +1384,11 @@ discard block |
||
1384 | 1384 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
1385 | 1385 | $ret = '403 Forbidden'; |
1386 | 1386 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
1387 | - foreach(array_keys($event['participants']) as $uid) |
|
1387 | + foreach (array_keys($event['participants']) as $uid) |
|
1388 | 1388 | { |
1389 | 1389 | if ($this->bo->user == $uid || in_array($uid, $memberships)) |
1390 | 1390 | { |
1391 | - $this->bo->set_status($event,$this->bo->user, 'R'); |
|
1391 | + $this->bo->set_status($event, $this->bo->user, 'R'); |
|
1392 | 1392 | $ret = true; |
1393 | 1393 | break; |
1394 | 1394 | } |
@@ -1403,7 +1403,7 @@ discard block |
||
1403 | 1403 | { |
1404 | 1404 | $ret = $this->bo->delete($event['id']); |
1405 | 1405 | } |
1406 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1406 | + if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1407 | 1407 | return $ret; |
1408 | 1408 | } |
1409 | 1409 | |
@@ -1418,12 +1418,12 @@ discard block |
||
1418 | 1418 | */ |
1419 | 1419 | function read($id) |
1420 | 1420 | { |
1421 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
1421 | + if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column; |
|
1422 | 1422 | |
1423 | 1423 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
1424 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1424 | + if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1425 | 1425 | |
1426 | - if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) && |
|
1426 | + if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server')) && |
|
1427 | 1427 | // above can be true, if current user is not in master but just a recurrence |
1428 | 1428 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
1429 | 1429 | { |
@@ -1459,11 +1459,11 @@ discard block |
||
1459 | 1459 | * |
1460 | 1460 | * @return string |
1461 | 1461 | */ |
1462 | - public function getctag($path,$user) |
|
1462 | + public function getctag($path, $user) |
|
1463 | 1463 | { |
1464 | - $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1464 | + $ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
|
1465 | 1465 | |
1466 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1466 | + if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag"); |
|
1467 | 1467 | |
1468 | 1468 | return $ctag; |
1469 | 1469 | } |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | * @param string $schedule_tag =null on return schedule-tag |
1476 | 1476 | * @return string|boolean string with etag or false |
1477 | 1477 | */ |
1478 | - function get_etag($entry, &$schedule_tag=null) |
|
1478 | + function get_etag($entry, &$schedule_tag = null) |
|
1479 | 1479 | { |
1480 | 1480 | $etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions); |
1481 | 1481 | |
@@ -1493,7 +1493,7 @@ discard block |
||
1493 | 1493 | * @param int|string $retval |
1494 | 1494 | * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header) |
1495 | 1495 | */ |
1496 | - function put_response_headers($entry, $path, $retval, $path_attr_is_name=true) |
|
1496 | + function put_response_headers($entry, $path, $retval, $path_attr_is_name = true) |
|
1497 | 1497 | { |
1498 | 1498 | $schedule_tag = null; |
1499 | 1499 | $etag = $this->get_etag($entry, $schedule_tag); |
@@ -1512,14 +1512,14 @@ discard block |
||
1512 | 1512 | * @param array|int $event event-array or id |
1513 | 1513 | * @return boolean null if entry does not exist, false if no access, true if access permitted |
1514 | 1514 | */ |
1515 | - function check_access($acl,$event) |
|
1515 | + function check_access($acl, $event) |
|
1516 | 1516 | { |
1517 | 1517 | if ($acl == Acl::READ) |
1518 | 1518 | { |
1519 | 1519 | // we need at least calendar_bo::ACL_FREEBUSY to get some information |
1520 | 1520 | $acl = calendar_bo::ACL_FREEBUSY; |
1521 | 1521 | } |
1522 | - return $this->bo->check_perms($acl,$event,0,'server'); |
|
1522 | + return $this->bo->check_perms($acl, $event, 0, 'server'); |
|
1523 | 1523 | } |
1524 | 1524 | |
1525 | 1525 | /** |
@@ -1532,52 +1532,52 @@ discard block |
||
1532 | 1532 | * @param string $path =null path of the collection |
1533 | 1533 | * @return array |
1534 | 1534 | */ |
1535 | - public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null) |
|
1535 | + public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null) |
|
1536 | 1536 | { |
1537 | - unset($base_uri); // unused, but required by function signature |
|
1537 | + unset($base_uri); // unused, but required by function signature |
|
1538 | 1538 | if (!isset($props['calendar-description'])) |
1539 | 1539 | { |
1540 | 1540 | // default calendar description: can be overwritten via PROPPATCH, in which case it's already set |
1541 | - $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname); |
|
1541 | + $props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname); |
|
1542 | 1542 | } |
1543 | 1543 | $supported_components = array( |
1544 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')), |
|
1544 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VEVENT')), |
|
1545 | 1545 | ); |
1546 | 1546 | // outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations |
1547 | - if (substr($path,-8) == '/outbox/') |
|
1547 | + if (substr($path, -8) == '/outbox/') |
|
1548 | 1548 | { |
1549 | - $supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY')); |
|
1549 | + $supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VFREEBUSY')); |
|
1550 | 1550 | } |
1551 | 1551 | $props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, |
1552 | - 'supported-calendar-component-set',$supported_components); |
|
1552 | + 'supported-calendar-component-set', $supported_components); |
|
1553 | 1553 | // supported reports |
1554 | 1554 | $props['supported-report-set'] = array( |
1555 | - 'calendar-query' => Api\CalDAV::mkprop('supported-report',array( |
|
1556 | - Api\CalDAV::mkprop('report',array( |
|
1557 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))), |
|
1558 | - 'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array( |
|
1559 | - Api\CalDAV::mkprop('report',array( |
|
1560 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))), |
|
1561 | - 'free-busy-query' => Api\CalDAV::mkprop('supported-report',array( |
|
1562 | - Api\CalDAV::mkprop('report',array( |
|
1563 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))), |
|
1555 | + 'calendar-query' => Api\CalDAV::mkprop('supported-report', array( |
|
1556 | + Api\CalDAV::mkprop('report', array( |
|
1557 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))), |
|
1558 | + 'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array( |
|
1559 | + Api\CalDAV::mkprop('report', array( |
|
1560 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))), |
|
1561 | + 'free-busy-query' => Api\CalDAV::mkprop('supported-report', array( |
|
1562 | + Api\CalDAV::mkprop('report', array( |
|
1563 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'free-busy-query', ''))))), |
|
1564 | 1564 | ); |
1565 | 1565 | // rfc 6578 sync-collection report for everything but outbox |
1566 | 1566 | // only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted |
1567 | 1567 | if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history']) |
1568 | 1568 | { |
1569 | - $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array( |
|
1570 | - Api\CalDAV::mkprop('report',array( |
|
1571 | - Api\CalDAV::mkprop('sync-collection',''))))); |
|
1569 | + $props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array( |
|
1570 | + Api\CalDAV::mkprop('report', array( |
|
1571 | + Api\CalDAV::mkprop('sync-collection', ''))))); |
|
1572 | 1572 | } |
1573 | - $props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array( |
|
1574 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1575 | - Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1573 | + $props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-data', array( |
|
1574 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')), |
|
1575 | + Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0')))); |
|
1576 | 1576 | |
1577 | 1577 | // get timezone of calendar |
1578 | 1578 | if ($this->caldav->prop_requested('calendar-timezone')) |
1579 | 1579 | { |
1580 | - $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone', |
|
1580 | + $props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone', |
|
1581 | 1581 | calendar_timezones::user_timezone($user)); |
1582 | 1582 | } |
1583 | 1583 | return $props; |
@@ -1591,9 +1591,9 @@ discard block |
||
1591 | 1591 | private function _get_handler() |
1592 | 1592 | { |
1593 | 1593 | $handler = new calendar_ical(); |
1594 | - $handler->setSupportedFields('GroupDAV',$this->agent); |
|
1595 | - $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1596 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
1594 | + $handler->setSupportedFields('GroupDAV', $this->agent); |
|
1595 | + $handler->supportedFields['attachments'] = true; // enabling attachments |
|
1596 | + if ($this->debug > 1) error_log("ical Handler called: ".$this->agent); |
|
1597 | 1597 | return $handler; |
1598 | 1598 | } |
1599 | 1599 | |
@@ -1608,7 +1608,7 @@ discard block |
||
1608 | 1608 | $pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set']; |
1609 | 1609 | $calendar_home_set = $pref ? explode(',', $pref) : array(); |
1610 | 1610 | // replace symbolic id's with real nummeric id's |
1611 | - foreach(array( |
|
1611 | + foreach (array( |
|
1612 | 1612 | 'G' => $GLOBALS['egw_info']['user']['account_primary_group'], |
1613 | 1613 | ) as $sym => $id) |
1614 | 1614 | { |
@@ -1617,11 +1617,11 @@ discard block |
||
1617 | 1617 | $calendar_home_set[$key] = $id; |
1618 | 1618 | } |
1619 | 1619 | } |
1620 | - foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1620 | + foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry) |
|
1621 | 1621 | { |
1622 | 1622 | $id = $entry['grantor']; |
1623 | - if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1624 | - (in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) && |
|
1623 | + if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user |
|
1624 | + (in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) && |
|
1625 | 1625 | is_numeric($id) && ($owner = $this->accounts->id2name($id))) |
1626 | 1626 | { |
1627 | 1627 | $shared[$id] = 'calendar-'.$owner; |
@@ -1630,11 +1630,11 @@ discard block |
||
1630 | 1630 | // shared locations and resources |
1631 | 1631 | if ($GLOBALS['egw_info']['user']['apps']['resources']) |
1632 | 1632 | { |
1633 | - foreach(array('locations','resources') as $res) |
|
1633 | + foreach (array('locations', 'resources') as $res) |
|
1634 | 1634 | { |
1635 | 1635 | if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res])) |
1636 | 1636 | { |
1637 | - foreach(explode(',', $pref) as $res_id) |
|
1637 | + foreach (explode(',', $pref) as $res_id) |
|
1638 | 1638 | { |
1639 | 1639 | $is_location = $res == 'locations'; |
1640 | 1640 | $shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location)); |
@@ -1664,7 +1664,7 @@ discard block |
||
1664 | 1664 | { |
1665 | 1665 | $calendars[$entry['grantor']] = $entry['name']; |
1666 | 1666 | } |
1667 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
1667 | + if ($user > 0) unset($calendars[$user]); // skip current user |
|
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | $settings = array(); |
@@ -1672,7 +1672,7 @@ discard block |
||
1672 | 1672 | 'type' => 'multiselect', |
1673 | 1673 | 'label' => 'Calendars to sync in addition to personal calendar', |
1674 | 1674 | 'name' => 'calendar-home-set', |
1675 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1675 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1676 | 1676 | 'values' => $calendars, |
1677 | 1677 | 'xmlrpc' => True, |
1678 | 1678 | 'admin' => False, |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = Api\CalDAV\Principals::get_resources())) |
1699 | 1699 | { |
1700 | 1700 | $resources = $locations = array(); |
1701 | - foreach($all_resources as $resource) |
|
1701 | + foreach ($all_resources as $resource) |
|
1702 | 1702 | { |
1703 | 1703 | if (Api\CalDAV\Principals::resource_is_location($resource)) |
1704 | 1704 | { |
@@ -1709,7 +1709,7 @@ discard block |
||
1709 | 1709 | $resources[$resource['res_id']] = $resource['name']; |
1710 | 1710 | } |
1711 | 1711 | } |
1712 | - foreach(array( |
|
1712 | + foreach (array( |
|
1713 | 1713 | 'locations' => $locations, |
1714 | 1714 | 'resources' => $resources, |
1715 | 1715 | ) as $name => $options) |
@@ -1722,7 +1722,7 @@ discard block |
||
1722 | 1722 | 'label' => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')), |
1723 | 1723 | 'no_lang'=> true, |
1724 | 1724 | 'name' => 'calendar-home-set-'.$name, |
1725 | - 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'), |
|
1725 | + 'help' => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'), |
|
1726 | 1726 | 'values' => $options, |
1727 | 1727 | 'xmlrpc' => True, |
1728 | 1728 | 'admin' => False, |
@@ -132,7 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | else |
134 | 134 | { |
135 | - if (!is_array($event)) $event = $this->bo->read($event); |
|
135 | + if (!is_array($event)) |
|
136 | + { |
|
137 | + $event = $this->bo->read($event); |
|
138 | + } |
|
136 | 139 | $name = $event[self::$path_attr]; |
137 | 140 | } |
138 | 141 | $name .= self::$path_extension; |
@@ -193,10 +196,13 @@ discard block |
||
193 | 196 | } |
194 | 197 | $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
195 | 198 | } |
196 | - if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
|
199 | + if ($this->client_shared_uid_exceptions) |
|
200 | + { |
|
201 | + // do NOT return (non-virtual) exceptions |
|
197 | 202 | { |
198 | 203 | $filter['query'] = array('cal_reference' => 0); |
199 | 204 | } |
205 | + } |
|
200 | 206 | |
201 | 207 | if ($path == '/calendar/') |
202 | 208 | { |
@@ -226,7 +232,11 @@ discard block |
||
226 | 232 | // when trying to request not supported components, eg. VTODO on a calendar collection |
227 | 233 | return true; |
228 | 234 | } |
229 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
235 | + if ($id) |
|
236 | + { |
|
237 | + $path = dirname($path).'/'; |
|
238 | + } |
|
239 | + // caldav_name get's added anyway in the callback |
|
230 | 240 | |
231 | 241 | if ($this->debug > 1) |
232 | 242 | { |
@@ -288,7 +298,11 @@ discard block |
||
288 | 298 | $n = 0; |
289 | 299 | foreach($files as $file) |
290 | 300 | { |
291 | - if (!$n++) continue; // first entry is collection itself |
|
301 | + if (!$n++) |
|
302 | + { |
|
303 | + continue; |
|
304 | + } |
|
305 | + // first entry is collection itself |
|
292 | 306 | |
293 | 307 | $icalendar = $file['props']['calendar-data']['val']; |
294 | 308 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -332,10 +346,17 @@ discard block |
||
332 | 346 | */ |
333 | 347 | function &propfind_callback($path,array $filter,$start=false) |
334 | 348 | { |
335 | - if ($this->debug) $starttime = microtime(true); |
|
349 | + if ($this->debug) |
|
350 | + { |
|
351 | + $starttime = microtime(true); |
|
352 | + } |
|
336 | 353 | |
337 | 354 | $calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true); |
338 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
355 | + if (!is_array($calendar_data)) |
|
356 | + { |
|
357 | + $calendar_data = false; |
|
358 | + } |
|
359 | + // not in allprop or autoindex |
|
339 | 360 | |
340 | 361 | $files = array(); |
341 | 362 | |
@@ -493,7 +514,10 @@ discard block |
||
493 | 514 | switch($filter['name']) |
494 | 515 | { |
495 | 516 | case 'comp-filter': |
496 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
517 | + if ($this->debug > 1) |
|
518 | + { |
|
519 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
520 | + } |
|
497 | 521 | |
498 | 522 | switch($filter['attrs']['name']) |
499 | 523 | { |
@@ -508,14 +532,23 @@ discard block |
||
508 | 532 | } |
509 | 533 | break; |
510 | 534 | case 'prop-filter': |
511 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
535 | + if ($this->debug > 1) |
|
536 | + { |
|
537 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
538 | + } |
|
512 | 539 | $prop_filter = $filter['attrs']['name']; |
513 | 540 | break; |
514 | 541 | case 'text-match': |
515 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
542 | + if ($this->debug > 1) |
|
543 | + { |
|
544 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
545 | + } |
|
516 | 546 | if (!isset($this->filter_prop2cal[strtoupper($prop_filter)])) |
517 | 547 | { |
518 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
548 | + if ($this->debug) |
|
549 | + { |
|
550 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
551 | + } |
|
519 | 552 | } |
520 | 553 | else |
521 | 554 | { |
@@ -524,10 +557,16 @@ discard block |
||
524 | 557 | unset($prop_filter); |
525 | 558 | break; |
526 | 559 | case 'param-filter': |
527 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
560 | + if ($this->debug) |
|
561 | + { |
|
562 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
563 | + } |
|
528 | 564 | break; |
529 | 565 | case 'time-range': |
530 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
566 | + if ($this->debug > 1) |
|
567 | + { |
|
568 | + error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
569 | + } |
|
531 | 570 | if (!empty($filter['attrs']['start'])) |
532 | 571 | { |
533 | 572 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
@@ -538,13 +577,19 @@ discard block |
||
538 | 577 | } |
539 | 578 | break; |
540 | 579 | default: |
541 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
580 | + if ($this->debug) |
|
581 | + { |
|
582 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
583 | + } |
|
542 | 584 | break; |
543 | 585 | } |
544 | 586 | } |
545 | - if (count($cal_filters) == $num_filters) // no filters set --> restore default start and end time |
|
587 | + if (count($cal_filters) == $num_filters) |
|
588 | + { |
|
589 | + // no filters set --> restore default start and end time |
|
546 | 590 | { |
547 | 591 | $cal_filters['start'] = $cal_start; |
592 | + } |
|
548 | 593 | $cal_filters['end'] = $cal_end; |
549 | 594 | } |
550 | 595 | } |
@@ -621,7 +666,10 @@ discard block |
||
621 | 666 | } |
622 | 667 | } |
623 | 668 | |
624 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
669 | + if ($this->debug > 1) |
|
670 | + { |
|
671 | + error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
672 | + } |
|
625 | 673 | } |
626 | 674 | return true; |
627 | 675 | } |
@@ -667,9 +715,15 @@ discard block |
||
667 | 715 | private function iCal(array $event,$user=null, $method=null, $expand=false) |
668 | 716 | { |
669 | 717 | static $handler = null; |
670 | - if (is_null($handler)) $handler = $this->_get_handler(); |
|
718 | + if (is_null($handler)) |
|
719 | + { |
|
720 | + $handler = $this->_get_handler(); |
|
721 | + } |
|
671 | 722 | |
672 | - if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
723 | + if (!$user) |
|
724 | + { |
|
725 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
726 | + } |
|
673 | 727 | |
674 | 728 | // only return alarms in own calendar, not other users calendars |
675 | 729 | if ($user != $GLOBALS['egw_info']['user']['account_id']) |
@@ -685,12 +739,21 @@ discard block |
||
685 | 739 | { |
686 | 740 | if (is_array($expand)) |
687 | 741 | { |
688 | - if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
689 | - if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
742 | + if (isset($expand['start'])) |
|
743 | + { |
|
744 | + $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
745 | + } |
|
746 | + if (isset($expand['end'])) |
|
747 | + { |
|
748 | + $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
749 | + } |
|
690 | 750 | } |
691 | 751 | $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
692 | 752 | // as alarm is now only on next recurrence, set alarm from original event on master |
693 | - if ($event['alarm']) $events[0]['alarm'] = $event['alarm']; |
|
753 | + if ($event['alarm']) |
|
754 | + { |
|
755 | + $events[0]['alarm'] = $event['alarm']; |
|
756 | + } |
|
694 | 757 | } |
695 | 758 | elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
696 | 759 | { |
@@ -712,7 +775,10 @@ discard block |
||
712 | 775 | */ |
713 | 776 | private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
714 | 777 | { |
715 | - if (is_null($bo)) $bo = new calendar_bopdate(); |
|
778 | + if (is_null($bo)) |
|
779 | + { |
|
780 | + $bo = new calendar_bopdate(); |
|
781 | + } |
|
716 | 782 | |
717 | 783 | $params = array( |
718 | 784 | 'query' => array('cal_uid' => $uid), |
@@ -721,7 +787,10 @@ discard block |
||
721 | 787 | 'date_format' => 'server', |
722 | 788 | 'cfs' => array(), // read cfs as we use them to store X- attributes |
723 | 789 | ); |
724 | - if (is_array($expand)) $params += $expand; |
|
790 | + if (is_array($expand)) |
|
791 | + { |
|
792 | + $params += $expand; |
|
793 | + } |
|
725 | 794 | |
726 | 795 | if (!($events =& $bo->search($params))) |
727 | 796 | { |
@@ -742,7 +811,10 @@ discard block |
||
742 | 811 | } |
743 | 812 | } |
744 | 813 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
745 | - if (!isset($master)) $master = $bo->read($uid); |
|
814 | + if (!isset($master)) |
|
815 | + { |
|
816 | + $master = $bo->read($uid); |
|
817 | + } |
|
746 | 818 | |
747 | 819 | foreach($events as $k => &$recurrence) |
748 | 820 | { |
@@ -752,7 +824,9 @@ discard block |
||
752 | 824 | unset($events[$k]); |
753 | 825 | continue; // same uid, but references a different event or is own master |
754 | 826 | } |
755 | - if (!$master || $recurrence['id'] != $master['id']) // real exception |
|
827 | + if (!$master || $recurrence['id'] != $master['id']) |
|
828 | + { |
|
829 | + // real exception |
|
756 | 830 | { |
757 | 831 | // user is NOT participating in this exception |
758 | 832 | if ($user && !self::isParticipant($recurrence, $user)) |
@@ -761,6 +835,7 @@ discard block |
||
761 | 835 | if (!$master || !self::isParticipant($master, $user)) |
762 | 836 | { |
763 | 837 | unset($events[$k]); |
838 | + } |
|
764 | 839 | continue; |
765 | 840 | } |
766 | 841 | // otherwise mark him in this exception as rejected |
@@ -792,7 +867,10 @@ discard block |
||
792 | 867 | // this is a virtual exception now (no extra event/cal_id in DB) |
793 | 868 | //error_log('virtual exception: '.array2string($recurrence)); |
794 | 869 | $recurrence['recurrence'] = $recurrence['start']; |
795 | - if ($master) $recurrence['reference'] = $master['id']; |
|
870 | + if ($master) |
|
871 | + { |
|
872 | + $recurrence['reference'] = $master['id']; |
|
873 | + } |
|
796 | 874 | $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
797 | 875 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
798 | 876 | } |
@@ -831,9 +909,16 @@ discard block |
||
831 | 909 | */ |
832 | 910 | function put(&$options,$id,$user=null,$prefix=null) |
833 | 911 | { |
834 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
912 | + if ($this->debug) |
|
913 | + { |
|
914 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
915 | + } |
|
835 | 916 | |
836 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
917 | + if (!$prefix) |
|
918 | + { |
|
919 | + $user = null; |
|
920 | + } |
|
921 | + // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
837 | 922 | |
838 | 923 | // work around missing handling / racecondition in Lightning, if event already exists on server, |
839 | 924 | // but Lightning has not yet synced with the server: Lightning just retries the PUT, not GETing the event |
@@ -855,7 +940,10 @@ discard block |
||
855 | 940 | isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
856 | 941 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
857 | 942 | { |
858 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
943 | + if ($this->debug) |
|
944 | + { |
|
945 | + error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
946 | + } |
|
859 | 947 | return $oldEvent; |
860 | 948 | } |
861 | 949 | |
@@ -866,7 +954,10 @@ discard block |
||
866 | 954 | { |
867 | 955 | // we have no add permission on this user's calendar |
868 | 956 | // ToDo: create event in current users calendar and invite only $user |
869 | - if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
957 | + if ($this->debug) |
|
958 | + { |
|
959 | + error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
960 | + } |
|
870 | 961 | return '403 Forbidden'; |
871 | 962 | } |
872 | 963 | |
@@ -913,13 +1004,19 @@ discard block |
||
913 | 1004 | if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
914 | 1005 | { |
915 | 1006 | $schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']; |
916 | - if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
1007 | + if ($schedule_tag_match[0] == '"') |
|
1008 | + { |
|
1009 | + $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
1010 | + } |
|
917 | 1011 | $schedule_tag = null; |
918 | 1012 | $this->get_etag($oldEvent, $schedule_tag); |
919 | 1013 | |
920 | 1014 | if ($schedule_tag_match !== $schedule_tag) |
921 | 1015 | { |
922 | - if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
1016 | + if ($this->debug) |
|
1017 | + { |
|
1018 | + error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
1019 | + } |
|
923 | 1020 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
924 | 1021 | $this->check_return_representation($options, $id, $user); |
925 | 1022 | return '412 Precondition Failed'; |
@@ -940,7 +1037,10 @@ discard block |
||
940 | 1037 | // above can be true, if current user is not in master but just a recurrence |
941 | 1038 | (!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo)))) |
942 | 1039 | { |
943 | - if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
1040 | + if ($this->debug) |
|
1041 | + { |
|
1042 | + error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
1043 | + } |
|
944 | 1044 | return '403 Forbidden'; |
945 | 1045 | } |
946 | 1046 | // update only participant status and alarms of current user |
@@ -960,7 +1060,10 @@ discard block |
||
960 | 1060 | } |
961 | 1061 | foreach($series as $oldEvent) |
962 | 1062 | { |
963 | - if ($oldEvent['recurrence'] == $event['recurrence']) break; |
|
1063 | + if ($oldEvent['recurrence'] == $event['recurrence']) |
|
1064 | + { |
|
1065 | + break; |
|
1066 | + } |
|
964 | 1067 | } |
965 | 1068 | // if no exception found, check if it might be just a recurrence (no exception) |
966 | 1069 | if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence']) |
@@ -975,7 +1078,10 @@ discard block |
||
975 | 1078 | } |
976 | 1079 | } |
977 | 1080 | } |
978 | - if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event)); |
|
1081 | + if ($this->debug) |
|
1082 | + { |
|
1083 | + error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event)); |
|
1084 | + } |
|
979 | 1085 | if (isset($event['participants']) && isset($event['participants'][$user]) && |
980 | 1086 | $event['participants'][$user] !== $oldEvent['participants'][$user]) |
981 | 1087 | { |
@@ -983,13 +1089,19 @@ discard block |
||
983 | 1089 | // real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence! |
984 | 1090 | $recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0)) |
985 | 1091 | { |
986 | - if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
1092 | + if ($this->debug) |
|
1093 | + { |
|
1094 | + error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
1095 | + } |
|
987 | 1096 | return '403 Forbidden'; |
988 | 1097 | } |
989 | 1098 | else |
990 | 1099 | { |
991 | 1100 | ++$modified; |
992 | - if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
1101 | + if ($this->debug) |
|
1102 | + { |
|
1103 | + error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
1104 | + } |
|
993 | 1105 | } |
994 | 1106 | } |
995 | 1107 | // import alarms, if given and changed |
@@ -999,15 +1111,21 @@ discard block |
||
999 | 1111 | $modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user); |
1000 | 1112 | } |
1001 | 1113 | } |
1002 | - if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
1114 | + if (!$modified) |
|
1115 | + { |
|
1116 | + // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
1003 | 1117 | { |
1004 | 1118 | $this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent)); |
1005 | 1119 | } |
1120 | + } |
|
1006 | 1121 | $this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name'); |
1007 | 1122 | |
1008 | 1123 | return '204 No Content'; |
1009 | 1124 | } |
1010 | - if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
1125 | + if ($this->debug && !isset($events)) |
|
1126 | + { |
|
1127 | + error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
1128 | + } |
|
1011 | 1129 | } |
1012 | 1130 | if ($return_no_access) |
1013 | 1131 | { |
@@ -1044,17 +1162,23 @@ discard block |
||
1044 | 1162 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, |
1045 | 1163 | self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id))) |
1046 | 1164 | { |
1047 | - if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
1165 | + if ($this->debug) |
|
1166 | + { |
|
1167 | + error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
1168 | + } |
|
1048 | 1169 | if ($eventId && $cal_id === false) |
1049 | 1170 | { |
1050 | 1171 | // ignore import failures |
1051 | 1172 | $cal_id = $eventId; |
1052 | 1173 | $retval = true; |
1053 | 1174 | } |
1054 | - elseif ($cal_id === 0) // etag failure |
|
1175 | + elseif ($cal_id === 0) |
|
1176 | + { |
|
1177 | + // etag failure |
|
1055 | 1178 | { |
1056 | 1179 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
1057 | 1180 | $this->check_return_representation($options, $id, $user); |
1181 | + } |
|
1058 | 1182 | return '412 Precondition Failed'; |
1059 | 1183 | } |
1060 | 1184 | else |
@@ -1079,7 +1203,10 @@ discard block |
||
1079 | 1203 | */ |
1080 | 1204 | function post(&$options,$id,$user=null) |
1081 | 1205 | { |
1082 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1206 | + if ($this->debug) |
|
1207 | + { |
|
1208 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
1209 | + } |
|
1083 | 1210 | |
1084 | 1211 | $vCalendar = htmlspecialchars_decode($options['content']); |
1085 | 1212 | $charset = null; |
@@ -1133,7 +1260,10 @@ discard block |
||
1133 | 1260 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null, |
1134 | 1261 | false, 0, $this->caldav->current_user_principal, $user, $charset))) |
1135 | 1262 | { |
1136 | - if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
1263 | + if ($this->debug) |
|
1264 | + { |
|
1265 | + error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
1266 | + } |
|
1137 | 1267 | } |
1138 | 1268 | header('ETag: "'.$this->get_etag($eventId).'"'); |
1139 | 1269 | } |
@@ -1301,7 +1431,10 @@ discard block |
||
1301 | 1431 | $org_recurrences = $exceptions = array(); |
1302 | 1432 | foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
1303 | 1433 | { |
1304 | - if (!$k) $master = $event; |
|
1434 | + if (!$k) |
|
1435 | + { |
|
1436 | + $master = $event; |
|
1437 | + } |
|
1305 | 1438 | if ($event['recurrence']) |
1306 | 1439 | { |
1307 | 1440 | $org_recurrences[$event['recurrence']] = $event; |
@@ -1321,10 +1454,13 @@ discard block |
||
1321 | 1454 | |
1322 | 1455 | // from now on we deal with exceptions |
1323 | 1456 | $org_recurrence = $org_recurrences[$recurrence['recurrence']]; |
1324 | - if (isset($org_recurrence)) // already existing recurrence |
|
1457 | + if (isset($org_recurrence)) |
|
1458 | + { |
|
1459 | + // already existing recurrence |
|
1325 | 1460 | { |
1326 | 1461 | //error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); |
1327 | 1462 | $recurrence['id'] = $org_recurrence['id']; |
1463 | + } |
|
1328 | 1464 | |
1329 | 1465 | // re-add (non-virtual) exceptions to master's recur_exception |
1330 | 1466 | if ($recurrence['id'] != $master['id']) |
@@ -1341,10 +1477,14 @@ discard block |
||
1341 | 1477 | // delete not longer existing recurrences |
1342 | 1478 | foreach($org_recurrences as $org_recurrence) |
1343 | 1479 | { |
1344 | - if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
|
1480 | + if ($org_recurrence['id'] != $master['id']) |
|
1481 | + { |
|
1482 | + // non-virtual recurrence |
|
1345 | 1483 | { |
1346 | 1484 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
1347 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
1485 | + $bo->delete($org_recurrence['id']); |
|
1486 | + } |
|
1487 | + // might fail because of permissions |
|
1348 | 1488 | } |
1349 | 1489 | else // virtual recurrence |
1350 | 1490 | { |
@@ -1380,7 +1520,7 @@ discard block |
||
1380 | 1520 | self::get_agent() == 'caldavsynchronizer' && is_array($event) && $event['owner'] != $user) |
1381 | 1521 | { |
1382 | 1522 | if (is_array($event) && (!$return_no_access || $event['owner'] != $user)) |
1383 | - { |
|
1523 | + { |
|
1384 | 1524 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
1385 | 1525 | $ret = '403 Forbidden'; |
1386 | 1526 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
@@ -1403,7 +1543,10 @@ discard block |
||
1403 | 1543 | { |
1404 | 1544 | $ret = $this->bo->delete($event['id']); |
1405 | 1545 | } |
1406 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1546 | + if ($this->debug) |
|
1547 | + { |
|
1548 | + error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
1549 | + } |
|
1407 | 1550 | return $ret; |
1408 | 1551 | } |
1409 | 1552 | |
@@ -1418,16 +1561,26 @@ discard block |
||
1418 | 1561 | */ |
1419 | 1562 | function read($id) |
1420 | 1563 | { |
1421 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
1564 | + if (strpos($column=self::$path_attr,'_') === false) |
|
1565 | + { |
|
1566 | + $column = 'cal_'.$column; |
|
1567 | + } |
|
1422 | 1568 | |
1423 | 1569 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
1424 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
1570 | + if ($event) |
|
1571 | + { |
|
1572 | + $event = array_shift($event); |
|
1573 | + } |
|
1574 | + // read with array as 1. param, returns an array of events! |
|
1425 | 1575 | |
1426 | 1576 | if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) && |
1427 | 1577 | // above can be true, if current user is not in master but just a recurrence |
1428 | 1578 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
1429 | 1579 | { |
1430 | - if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
1580 | + if ($this->debug > 0) |
|
1581 | + { |
|
1582 | + error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
1583 | + } |
|
1431 | 1584 | return $retval; |
1432 | 1585 | } |
1433 | 1586 | if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server')) |
@@ -1435,9 +1588,15 @@ discard block |
||
1435 | 1588 | $this->bo->clear_private_infos($event, array($this->bo->user, $event['owner'])); |
1436 | 1589 | } |
1437 | 1590 | // handle deleted events, as not existing |
1438 | - if ($event['deleted']) $event = null; |
|
1591 | + if ($event['deleted']) |
|
1592 | + { |
|
1593 | + $event = null; |
|
1594 | + } |
|
1439 | 1595 | |
1440 | - if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event)); |
|
1596 | + if ($this->debug > 1) |
|
1597 | + { |
|
1598 | + error_log(__METHOD__."($id) returning ".array2string($event)); |
|
1599 | + } |
|
1441 | 1600 | |
1442 | 1601 | return $event; |
1443 | 1602 | } |
@@ -1449,7 +1608,10 @@ discard block |
||
1449 | 1608 | */ |
1450 | 1609 | public function update_tags($entry) |
1451 | 1610 | { |
1452 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
1611 | + if (!is_array($entry)) |
|
1612 | + { |
|
1613 | + $entry = $this->read($entry); |
|
1614 | + } |
|
1453 | 1615 | |
1454 | 1616 | $this->bo->update($entry, true); |
1455 | 1617 | } |
@@ -1463,7 +1625,10 @@ discard block |
||
1463 | 1625 | { |
1464 | 1626 | $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
1465 | 1627 | |
1466 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1628 | + if ($this->debug > 1) |
|
1629 | + { |
|
1630 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
1631 | + } |
|
1467 | 1632 | |
1468 | 1633 | return $ctag; |
1469 | 1634 | } |
@@ -1593,7 +1758,10 @@ discard block |
||
1593 | 1758 | $handler = new calendar_ical(); |
1594 | 1759 | $handler->setSupportedFields('GroupDAV',$this->agent); |
1595 | 1760 | $handler->supportedFields['attachments'] = true; // enabling attachments |
1596 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
1761 | + if ($this->debug > 1) |
|
1762 | + { |
|
1763 | + error_log("ical Handler called: " . $this->agent); |
|
1764 | + } |
|
1597 | 1765 | return $handler; |
1598 | 1766 | } |
1599 | 1767 | |
@@ -1664,7 +1832,11 @@ discard block |
||
1664 | 1832 | { |
1665 | 1833 | $calendars[$entry['grantor']] = $entry['name']; |
1666 | 1834 | } |
1667 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
1835 | + if ($user > 0) |
|
1836 | + { |
|
1837 | + unset($calendars[$user]); |
|
1838 | + } |
|
1839 | + // skip current user |
|
1668 | 1840 | } |
1669 | 1841 | |
1670 | 1842 | $settings = array(); |
@@ -487,15 +487,15 @@ discard block |
||
487 | 487 | { |
488 | 488 | $user = $this->resource_info($this->user); |
489 | 489 | $attributes['ATTENDEE'][] = 'mailto:' . $user['email']; |
490 | - $parameters['ATTENDEE'][] = array( |
|
491 | - 'CN' => $user['name'], |
|
492 | - 'ROLE' => 'REQ-PARTICIPANT', |
|
490 | + $parameters['ATTENDEE'][] = array( |
|
491 | + 'CN' => $user['name'], |
|
492 | + 'ROLE' => 'REQ-PARTICIPANT', |
|
493 | 493 | 'PARTSTAT' => 'NEEDS-ACTION', |
494 | 494 | 'CUTYPE' => 'INDIVIDUAL', |
495 | 495 | 'RSVP' => 'TRUE', |
496 | 496 | 'X-EGROUPWARE-UID' => (string)$this->user, |
497 | - ); |
|
498 | - $event['participants'][$this->user] = true; |
|
497 | + ); |
|
498 | + $event['participants'][$this->user] = true; |
|
499 | 499 | } |
500 | 500 | break; |
501 | 501 | case 'r': |
@@ -551,33 +551,33 @@ discard block |
||
551 | 551 | } |
552 | 552 | break; |
553 | 553 | |
554 | - case 'ORGANIZER': |
|
555 | - if (!$organizerURL) |
|
556 | - { |
|
557 | - $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
558 | - . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
559 | - $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
560 | - if ($version == '1.0') |
|
561 | - { |
|
562 | - $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
563 | - } |
|
564 | - else |
|
565 | - { |
|
566 | - $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
567 | - } |
|
568 | - $organizerUID = $event['owner']; |
|
569 | - } |
|
570 | - // do NOT use ORGANIZER for events without further participants or a different organizer |
|
571 | - if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
572 | - { |
|
573 | - $attributes['ORGANIZER'] = $organizerURL; |
|
574 | - $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
575 | - if (!empty($organizerUID)) |
|
576 | - { |
|
577 | - $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
578 | - } |
|
579 | - } |
|
580 | - break; |
|
554 | + case 'ORGANIZER': |
|
555 | + if (!$organizerURL) |
|
556 | + { |
|
557 | + $organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname') |
|
558 | + . ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"'; |
|
559 | + $organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email'); |
|
560 | + if ($version == '1.0') |
|
561 | + { |
|
562 | + $organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>')); |
|
563 | + } |
|
564 | + else |
|
565 | + { |
|
566 | + $organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail; |
|
567 | + } |
|
568 | + $organizerUID = $event['owner']; |
|
569 | + } |
|
570 | + // do NOT use ORGANIZER for events without further participants or a different organizer |
|
571 | + if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']])) |
|
572 | + { |
|
573 | + $attributes['ORGANIZER'] = $organizerURL; |
|
574 | + $parameters['ORGANIZER']['CN'] = $organizerCN; |
|
575 | + if (!empty($organizerUID)) |
|
576 | + { |
|
577 | + $parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID; |
|
578 | + } |
|
579 | + } |
|
580 | + break; |
|
581 | 581 | |
582 | 582 | case 'DTSTART': |
583 | 583 | if (empty($event['whole_day'])) |
@@ -1003,12 +1003,12 @@ discard block |
||
1003 | 1003 | foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData) |
1004 | 1004 | { |
1005 | 1005 | $valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset); |
1006 | - $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
1007 | - $parameters[$key][$valueID] : $parameters[$key], |
|
1008 | - Api\Translation::charset(),$charset); |
|
1009 | - $valuesData = (array) Api\Translation::convert($values[$key], |
|
1010 | - Api\Translation::charset(),$charset); |
|
1011 | - $content = $valueData . implode(';', $valuesData); |
|
1006 | + $paramData = (array) Api\Translation::convert(is_array($value) ? |
|
1007 | + $parameters[$key][$valueID] : $parameters[$key], |
|
1008 | + Api\Translation::charset(),$charset); |
|
1009 | + $valuesData = (array) Api\Translation::convert($values[$key], |
|
1010 | + Api\Translation::charset(),$charset); |
|
1011 | + $content = $valueData . implode(';', $valuesData); |
|
1012 | 1012 | |
1013 | 1013 | if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) || |
1014 | 1014 | ($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN'])))) |
@@ -2298,7 +2298,7 @@ discard block |
||
2298 | 2298 | * @param string|resource $_vcalData |
2299 | 2299 | * @param string $principalURL ='' Used for CalDAV imports |
2300 | 2300 | * @param string $charset The encoding charset for $text. Defaults to |
2301 | - * utf-8 for new format, iso-8859-1 for old format. |
|
2301 | + * utf-8 for new format, iso-8859-1 for old format. |
|
2302 | 2302 | * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure |
2303 | 2303 | */ |
2304 | 2304 | function icaltoegw($_vcalData, $principalURL='', $charset=null) |
@@ -2716,10 +2716,10 @@ discard block |
||
2716 | 2716 | // work around Ligthning sending @ as %40 |
2717 | 2717 | $attributes['value'] = str_replace('%40', '@', $attributes['value']); |
2718 | 2718 | if (isset($attributes['params']['PARTSTAT'])) |
2719 | - { |
|
2720 | - $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
2721 | - } |
|
2722 | - if (isset($attributes['params']['STATUS'])) |
|
2719 | + { |
|
2720 | + $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
|
2721 | + } |
|
2722 | + if (isset($attributes['params']['STATUS'])) |
|
2723 | 2723 | { |
2724 | 2724 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
2725 | 2725 | if (empty($status)) $status = 'X'; |
@@ -3137,7 +3137,7 @@ discard block |
||
3137 | 3137 | array2string($event)."\n",3,$this->logfile); |
3138 | 3138 | } |
3139 | 3139 | //Horde::logMessage("vevent2egw:\n" . print_r($event, true), |
3140 | - // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
3140 | + // __FILE__, __LINE__, PEAR_LOG_DEBUG); |
|
3141 | 3141 | return $event; |
3142 | 3142 | } |
3143 | 3143 |
@@ -183,7 +183,10 @@ discard block |
||
183 | 183 | function __construct(&$_clientProperties = array()) |
184 | 184 | { |
185 | 185 | parent::__construct(); |
186 | - if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
186 | + if ($this->log) |
|
187 | + { |
|
188 | + $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal"; |
|
189 | + } |
|
187 | 190 | $this->clientProperties = $_clientProperties; |
188 | 191 | $this->vCalendar = new Horde_Icalendar; |
189 | 192 | $this->addressbook = new Api\Contacts; |
@@ -232,10 +235,14 @@ discard block |
||
232 | 235 | 'ATTACH' => 'attachments', |
233 | 236 | ); |
234 | 237 | |
235 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
238 | + if (!is_array($this->supportedFields)) |
|
239 | + { |
|
240 | + $this->setSupportedFields(); |
|
241 | + } |
|
236 | 242 | |
237 | 243 | if ($this->productManufacturer == '' ) |
238 | - { // syncevolution is broken |
|
244 | + { |
|
245 | +// syncevolution is broken |
|
239 | 246 | $version = '2.0'; |
240 | 247 | } |
241 | 248 | |
@@ -243,10 +250,16 @@ discard block |
||
243 | 250 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
244 | 251 | strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); |
245 | 252 | $vcal->setAttribute('VERSION', $version); |
246 | - if ($method) $vcal->setAttribute('METHOD', $method); |
|
253 | + if ($method) |
|
254 | + { |
|
255 | + $vcal->setAttribute('METHOD', $method); |
|
256 | + } |
|
247 | 257 | $events_exported = false; |
248 | 258 | |
249 | - if (!is_array($events)) $events = array($events); |
|
259 | + if (!is_array($events)) |
|
260 | + { |
|
261 | + $events = array($events); |
|
262 | + } |
|
250 | 263 | |
251 | 264 | $vtimezones_added = array(); |
252 | 265 | foreach ($events as $event) |
@@ -314,13 +327,19 @@ discard block |
||
314 | 327 | } |
315 | 328 | catch (Exception $e) { |
316 | 329 | // log unknown timezones |
317 | - if (!empty($event['tzid'])) _egw_log_exception($e); |
|
330 | + if (!empty($event['tzid'])) |
|
331 | + { |
|
332 | + _egw_log_exception($e); |
|
333 | + } |
|
318 | 334 | // default for no timezone and unkown to user timezone |
319 | 335 | self::$tz_cache[$event['tzid']] = Api\DateTime::$user_timezone; |
320 | 336 | } |
321 | 337 | } |
322 | 338 | |
323 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
339 | + if ($this->so->isWholeDay($event)) |
|
340 | + { |
|
341 | + $event['whole_day'] = true; |
|
342 | + } |
|
324 | 343 | |
325 | 344 | if ($this->log) |
326 | 345 | { |
@@ -331,7 +350,10 @@ discard block |
||
331 | 350 | |
332 | 351 | if ($recurrence) |
333 | 352 | { |
334 | - if (!($master = $this->read($event['id'], 0, true, 'server'))) continue; |
|
353 | + if (!($master = $this->read($event['id'], 0, true, 'server'))) |
|
354 | + { |
|
355 | + continue; |
|
356 | + } |
|
335 | 357 | |
336 | 358 | if (!isset($this->supportedFields['participants'])) |
337 | 359 | { |
@@ -388,7 +410,8 @@ discard block |
||
388 | 410 | if ($this->productManufacturer != 'file' && $this->uidExtension) |
389 | 411 | { |
390 | 412 | // Append UID to DESCRIPTION |
391 | - if (!preg_match('/\[UID:.+\]/m', $event['description'])) { |
|
413 | + if (!preg_match('/\[UID:.+\]/m', $event['description'])) |
|
414 | + { |
|
392 | 415 | $event['description'] .= "\n[UID:" . $event['uid'] . "]"; |
393 | 416 | } |
394 | 417 | } |
@@ -448,11 +471,21 @@ discard block |
||
448 | 471 | $quantity = $role = null; |
449 | 472 | calendar_so::split_status($status, $quantity, $role); |
450 | 473 | // do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant |
451 | - if (count($event['participants']) == 1 && $event['owner'] == $uid) continue; |
|
474 | + if (count($event['participants']) == 1 && $event['owner'] == $uid) |
|
475 | + { |
|
476 | + continue; |
|
477 | + } |
|
452 | 478 | |
453 | - if (!($info = $this->resource_info($uid))) continue; |
|
479 | + if (!($info = $this->resource_info($uid))) |
|
480 | + { |
|
481 | + continue; |
|
482 | + } |
|
454 | 483 | |
455 | - if (in_array($status, array('X','E'))) continue; // dont include deleted participants |
|
484 | + if (in_array($status, array('X','E'))) |
|
485 | + { |
|
486 | + continue; |
|
487 | + } |
|
488 | + // dont include deleted participants |
|
456 | 489 | |
457 | 490 | if ($this->log) |
458 | 491 | { |
@@ -531,16 +564,34 @@ discard block |
||
531 | 564 | } |
532 | 565 | // ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*} |
533 | 566 | $options = array(); |
534 | - if (!empty($participantCN)) $options['CN'] = $participantCN; |
|
535 | - if (!empty($role)) $options['ROLE'] = $role; |
|
536 | - if (!empty($status)) $options['PARTSTAT'] = $status; |
|
537 | - if (!empty($cutype)) $options['CUTYPE'] = $cutype; |
|
538 | - if (!empty($rsvp)) $options['RSVP'] = $rsvp; |
|
567 | + if (!empty($participantCN)) |
|
568 | + { |
|
569 | + $options['CN'] = $participantCN; |
|
570 | + } |
|
571 | + if (!empty($role)) |
|
572 | + { |
|
573 | + $options['ROLE'] = $role; |
|
574 | + } |
|
575 | + if (!empty($status)) |
|
576 | + { |
|
577 | + $options['PARTSTAT'] = $status; |
|
578 | + } |
|
579 | + if (!empty($cutype)) |
|
580 | + { |
|
581 | + $options['CUTYPE'] = $cutype; |
|
582 | + } |
|
583 | + if (!empty($rsvp)) |
|
584 | + { |
|
585 | + $options['RSVP'] = $rsvp; |
|
586 | + } |
|
539 | 587 | if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email']) |
540 | 588 | { |
541 | 589 | $options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it |
542 | 590 | } |
543 | - if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
591 | + if ($info['type'] != 'e') |
|
592 | + { |
|
593 | + $options['X-EGROUPWARE-UID'] = (string)$uid; |
|
594 | + } |
|
544 | 595 | if ($quantity > 1) |
545 | 596 | { |
546 | 597 | $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity; |
@@ -552,7 +603,11 @@ discard block |
||
552 | 603 | break; |
553 | 604 | |
554 | 605 | case 'CLASS': |
555 | - if ($event['public']) continue 2; // public is default, no need to export, fails CalDAVTester if added as default |
|
606 | + if ($event['public']) |
|
607 | + { |
|
608 | + continue 2; |
|
609 | + } |
|
610 | + // public is default, no need to export, fails CalDAVTester if added as default |
|
556 | 611 | $attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE'; |
557 | 612 | // Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!) |
558 | 613 | if (!$event['public'] && $this->productManufacturer == 'groupdav') |
@@ -601,9 +656,12 @@ discard block |
||
601 | 656 | { |
602 | 657 | // Hack for CalDAVTester to export duration instead of endtime |
603 | 658 | if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400) |
604 | - $attributes['duration'] = $event['end'] - $event['start']; |
|
605 | - else |
|
606 | - $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
659 | + { |
|
660 | + $attributes['duration'] = $event['end'] - $event['start']; |
|
661 | + } |
|
662 | + else { |
|
663 | + $attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']); |
|
664 | + } |
|
607 | 665 | } |
608 | 666 | else |
609 | 667 | { |
@@ -623,7 +681,11 @@ discard block |
||
623 | 681 | break; |
624 | 682 | |
625 | 683 | case 'RRULE': |
626 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event |
|
684 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
685 | + { |
|
686 | + break; |
|
687 | + } |
|
688 | + // no recuring event |
|
627 | 689 | $rriter = calendar_rrule::event2rrule($event, false, $tzid); |
628 | 690 | $rrule = $rriter->generate_rrule($version); |
629 | 691 | if ($event['recur_enddate']) |
@@ -665,7 +727,10 @@ discard block |
||
665 | 727 | break; |
666 | 728 | |
667 | 729 | case 'EXDATE': |
668 | - if ($event['recur_type'] == MCAL_RECUR_NONE) break; |
|
730 | + if ($event['recur_type'] == MCAL_RECUR_NONE) |
|
731 | + { |
|
732 | + break; |
|
733 | + } |
|
669 | 734 | if (!empty($event['recur_exception'])) |
670 | 735 | { |
671 | 736 | if (empty($event['whole_day'])) |
@@ -692,14 +757,21 @@ discard block |
||
692 | 757 | ); |
693 | 758 | } |
694 | 759 | $event['recur_exception'] = $days; |
695 | - if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
760 | + if ($version != '1.0') |
|
761 | + { |
|
762 | + $parameters['EXDATE']['VALUE'] = 'DATE'; |
|
763 | + } |
|
696 | 764 | } |
697 | 765 | $vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']); |
698 | 766 | } |
699 | 767 | break; |
700 | 768 | |
701 | 769 | case 'PRIORITY': |
702 | - if (!$event['priority']) continue 2; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
770 | + if (!$event['priority']) |
|
771 | + { |
|
772 | + continue 2; |
|
773 | + } |
|
774 | + // 0=undefined is default, no need to export, fails CalDAVTester if our default is added |
|
703 | 775 | if ($this->productManufacturer == 'funambol' && |
704 | 776 | (strpos($this->productName, 'outlook') !== false |
705 | 777 | || strpos($this->productName, 'pocket pc') !== false)) |
@@ -713,7 +785,11 @@ discard block |
||
713 | 785 | break; |
714 | 786 | |
715 | 787 | case 'TRANSP': |
716 | - if (!$event['non_blocking']) continue 2; // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
788 | + if (!$event['non_blocking']) |
|
789 | + { |
|
790 | + continue 2; |
|
791 | + } |
|
792 | + // OPAQUE is default, no need to export, fails CalDAVTester if added as default |
|
717 | 793 | if ($version == '1.0') |
718 | 794 | { |
719 | 795 | $attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0); |
@@ -770,7 +846,11 @@ discard block |
||
770 | 846 | elseif ($event['recurrence'] && $event['reference']) |
771 | 847 | { |
772 | 848 | // $event['reference'] is a calendar_id, not a timestamp |
773 | - if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist |
|
849 | + if (!($revent = $this->read($event['reference']))) |
|
850 | + { |
|
851 | + break; |
|
852 | + } |
|
853 | + // referenced event does not exist |
|
774 | 854 | |
775 | 855 | if (empty($revent['whole_day'])) |
776 | 856 | { |
@@ -864,7 +944,10 @@ discard block |
||
864 | 944 | if (count($attr) === 1 && !empty($attr['gzcompress'])) |
865 | 945 | { |
866 | 946 | $attr = json_decode(gzuncompress(base64_decode($attr['gzcompress'])), true); |
867 | - if (!is_array($attr)) continue; |
|
947 | + if (!is_array($attr)) |
|
948 | + { |
|
949 | + continue; |
|
950 | + } |
|
868 | 951 | } |
869 | 952 | $vevent->setAttribute(substr($name, 2), $attr['value'], $attr['params'], true, $attr['values']); |
870 | 953 | } |
@@ -905,7 +988,10 @@ discard block |
||
905 | 988 | foreach ((array)$event['alarm'] as $alarmData) |
906 | 989 | { |
907 | 990 | // skip over alarms that don't have the minimum required info |
908 | - if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue; |
|
991 | + if (!isset($alarmData['offset']) && !isset($alarmData['time'])) |
|
992 | + { |
|
993 | + continue; |
|
994 | + } |
|
909 | 995 | |
910 | 996 | // skip alarms not being set for all users and alarms owned by other users |
911 | 997 | if ($alarmData['all'] != true && $alarmData['owner'] != $this->user) |
@@ -922,7 +1008,10 @@ discard block |
||
922 | 1008 | |
923 | 1009 | if ($version == '1.0') |
924 | 1010 | { |
925 | - if ($event['title']) $description = $event['title']; |
|
1011 | + if ($event['title']) |
|
1012 | + { |
|
1013 | + $description = $event['title']; |
|
1014 | + } |
|
926 | 1015 | if ($description) |
927 | 1016 | { |
928 | 1017 | $values['DALARM']['snooze_time'] = ''; |
@@ -942,7 +1031,10 @@ discard block |
||
942 | 1031 | // VCalendar 2.0 / RFC 2445 |
943 | 1032 | |
944 | 1033 | // RFC requires DESCRIPTION for DISPLAY |
945 | - if (!$event['title'] && !$description) $description = 'Alarm'; |
|
1034 | + if (!$event['title'] && !$description) |
|
1035 | + { |
|
1036 | + $description = 'Alarm'; |
|
1037 | + } |
|
946 | 1038 | |
947 | 1039 | /* Disabling for now |
948 | 1040 | // Lightning infinitly pops up alarms for recuring events, if the only use an offset |
@@ -1133,13 +1225,20 @@ discard block |
||
1133 | 1225 | $this->events_imported = 0; |
1134 | 1226 | $replace = $delete_exceptions= false; |
1135 | 1227 | |
1136 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
1228 | + if (!is_array($this->supportedFields)) |
|
1229 | + { |
|
1230 | + $this->setSupportedFields(); |
|
1231 | + } |
|
1137 | 1232 | |
1138 | 1233 | if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset))) |
1139 | 1234 | { |
1140 | 1235 | return false; |
1141 | 1236 | } |
1142 | - if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
1237 | + if (!is_array($events)) |
|
1238 | + { |
|
1239 | + $cal_id = -1; |
|
1240 | + } |
|
1241 | + // just to be sure, as iterator does NOT allow array access (eg. $events[0]) |
|
1143 | 1242 | |
1144 | 1243 | if ($cal_id > 0) |
1145 | 1244 | { |
@@ -1147,8 +1246,14 @@ discard block |
||
1147 | 1246 | { |
1148 | 1247 | $replace = $recur_date == 0; |
1149 | 1248 | $events[0]['id'] = $cal_id; |
1150 | - if (!is_null($etag)) $events[0]['etag'] = (int) $etag; |
|
1151 | - if ($recur_date) $events[0]['recurrence'] = $recur_date; |
|
1249 | + if (!is_null($etag)) |
|
1250 | + { |
|
1251 | + $events[0]['etag'] = (int) $etag; |
|
1252 | + } |
|
1253 | + if ($recur_date) |
|
1254 | + { |
|
1255 | + $events[0]['recurrence'] = $recur_date; |
|
1256 | + } |
|
1152 | 1257 | } |
1153 | 1258 | elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) && |
1154 | 1259 | ($eventId = array_shift($foundEvent)) && |
@@ -1156,7 +1261,10 @@ discard block |
||
1156 | 1261 | { |
1157 | 1262 | foreach ($events as $k => $event) |
1158 | 1263 | { |
1159 | - if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid']; |
|
1264 | + if (!isset($event['uid'])) |
|
1265 | + { |
|
1266 | + $events[$k]['uid'] = $egwEvent['uid']; |
|
1267 | + } |
|
1160 | 1268 | } |
1161 | 1269 | } |
1162 | 1270 | } |
@@ -1186,10 +1294,17 @@ discard block |
||
1186 | 1294 | $msg = null; |
1187 | 1295 | foreach ($events as $event) |
1188 | 1296 | { |
1189 | - if (!is_array($event)) continue; // the iterator may return false |
|
1297 | + if (!is_array($event)) |
|
1298 | + { |
|
1299 | + continue; |
|
1300 | + } |
|
1301 | + // the iterator may return false |
|
1190 | 1302 | ++$this->events_imported; |
1191 | 1303 | |
1192 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
1304 | + if ($this->so->isWholeDay($event)) |
|
1305 | + { |
|
1306 | + $event['whole_day'] = true; |
|
1307 | + } |
|
1193 | 1308 | if (is_array($event['category'])) |
1194 | 1309 | { |
1195 | 1310 | $event['category'] = $this->find_or_add_categories($event['category'], |
@@ -1226,7 +1341,10 @@ discard block |
||
1226 | 1341 | } |
1227 | 1342 | else |
1228 | 1343 | { |
1229 | - if (!($exception = $this->read($id))) continue; |
|
1344 | + if (!($exception = $this->read($id))) |
|
1345 | + { |
|
1346 | + continue; |
|
1347 | + } |
|
1230 | 1348 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
1231 | 1349 | $exception['reference'] = $exception['recurrence'] = 0; |
1232 | 1350 | $this->update($exception, true,true,false,true,$msg,$skip_notification); |
@@ -1326,7 +1444,10 @@ discard block |
||
1326 | 1444 | break; |
1327 | 1445 | |
1328 | 1446 | default: |
1329 | - if (!empty($value)) $event[$key] = $value; |
|
1447 | + if (!empty($value)) |
|
1448 | + { |
|
1449 | + $event[$key] = $value; |
|
1450 | + } |
|
1330 | 1451 | } |
1331 | 1452 | } |
1332 | 1453 | } |
@@ -1424,7 +1545,10 @@ discard block |
||
1424 | 1545 | else // common adjustments for new events |
1425 | 1546 | { |
1426 | 1547 | unset($event['id']); |
1427 | - if ($caldav_name) $event['caldav_name'] = $caldav_name; |
|
1548 | + if ($caldav_name) |
|
1549 | + { |
|
1550 | + $event['caldav_name'] = $caldav_name; |
|
1551 | + } |
|
1428 | 1552 | // set non blocking all day depending on the user setting |
1429 | 1553 | if (!empty($event['whole_day']) && $this->nonBlockingAllday) |
1430 | 1554 | { |
@@ -1472,7 +1596,10 @@ discard block |
||
1472 | 1596 | || !isset($event['participants'][$event['owner']])) |
1473 | 1597 | { |
1474 | 1598 | $status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR'); |
1475 | - if (!is_array($event['participants'])) $event['participants'] = array(); |
|
1599 | + if (!is_array($event['participants'])) |
|
1600 | + { |
|
1601 | + $event['participants'] = array(); |
|
1602 | + } |
|
1476 | 1603 | $event['participants'][$event['owner']] = $status; |
1477 | 1604 | } |
1478 | 1605 | else |
@@ -1625,7 +1752,10 @@ discard block |
||
1625 | 1752 | $occurence = $exception = false; |
1626 | 1753 | foreach ($event_info['master_event']['recur_exception'] as $exception) |
1627 | 1754 | { |
1628 | - if ($exception > $event['start']) break; |
|
1755 | + if ($exception > $event['start']) |
|
1756 | + { |
|
1757 | + break; |
|
1758 | + } |
|
1629 | 1759 | $occurence = $exception; |
1630 | 1760 | } |
1631 | 1761 | if (!$occurence) |
@@ -1715,12 +1845,15 @@ discard block |
||
1715 | 1845 | case 'SERIES-MASTER': |
1716 | 1846 | case 'SERIES-EXCEPTION': |
1717 | 1847 | case 'SERIES-EXCEPTION-PROPAGATE': |
1718 | - if (is_array($event_info['stored_event'])) // status update requires a stored event |
|
1848 | + if (is_array($event_info['stored_event'])) |
|
1849 | + { |
|
1850 | + // status update requires a stored event |
|
1719 | 1851 | { |
1720 | 1852 | if ($event_info['acl_edit']) |
1721 | 1853 | { |
1722 | 1854 | // update all participants if we have the right to do that |
1723 | 1855 | $this->update_status($event, $event_info['stored_event'],0,$skip_notification); |
1856 | + } |
|
1724 | 1857 | } |
1725 | 1858 | elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user])) |
1726 | 1859 | { |
@@ -1732,9 +1865,12 @@ discard block |
||
1732 | 1865 | break; |
1733 | 1866 | |
1734 | 1867 | case 'SERIES-PSEUDO-EXCEPTION': |
1735 | - if (is_array($event_info['master_event'])) // status update requires a stored master event |
|
1868 | + if (is_array($event_info['master_event'])) |
|
1869 | + { |
|
1870 | + // status update requires a stored master event |
|
1736 | 1871 | { |
1737 | 1872 | $recurrence = $this->date2usertime($event['recurrence']); |
1873 | + } |
|
1738 | 1874 | if ($event_info['acl_edit']) |
1739 | 1875 | { |
1740 | 1876 | // update all participants if we have the right to do that |
@@ -1842,7 +1978,10 @@ discard block |
||
1842 | 1978 | */ |
1843 | 1979 | public function sync_alarms(array &$event, array $old_alarms, $user) |
1844 | 1980 | { |
1845 | - if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
1981 | + if ($this->debug) |
|
1982 | + { |
|
1983 | + error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)"); |
|
1984 | + } |
|
1846 | 1985 | $modified = 0; |
1847 | 1986 | foreach($event['alarm'] as &$alarm) |
1848 | 1987 | { |
@@ -1864,29 +2003,56 @@ discard block |
||
1864 | 2003 | break; |
1865 | 2004 | } |
1866 | 2005 | } |
1867 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
2006 | + if ($this->debug) |
|
2007 | + { |
|
2008 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm)); |
|
2009 | + } |
|
1868 | 2010 | if (!empty($alarm['attrs']['X-LIC-ERROR'])) |
1869 | 2011 | { |
1870 | - if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
2012 | + if ($this->debug) |
|
2013 | + { |
|
2014 | + error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR'])); |
|
2015 | + } |
|
1871 | 2016 | unset($alarm['attrs']['X-LIC-ERROR']); |
1872 | 2017 | } |
1873 | 2018 | // alarm not found --> add it |
1874 | 2019 | if (!$found) |
1875 | 2020 | { |
1876 | 2021 | $alarm['owner'] = $user; |
1877 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
1878 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
1879 | - if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
1880 | - if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
2022 | + if (!isset($alarm['time'])) |
|
2023 | + { |
|
2024 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
2025 | + } |
|
2026 | + if ($alarm['time'] < time()) |
|
2027 | + { |
|
2028 | + calendar_so::shift_alarm($event, $alarm); |
|
2029 | + } |
|
2030 | + if ($this->debug) |
|
2031 | + { |
|
2032 | + error_log(__METHOD__."() adding new alarm from client ".array2string($alarm)); |
|
2033 | + } |
|
2034 | + if ($event['id']) |
|
2035 | + { |
|
2036 | + $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
|
2037 | + } |
|
1881 | 2038 | ++$modified; |
1882 | 2039 | } |
1883 | 2040 | // existing alarm --> update it |
1884 | 2041 | else |
1885 | 2042 | { |
1886 | - if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset']; |
|
1887 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
2043 | + if (!isset($alarm['time'])) |
|
2044 | + { |
|
2045 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
2046 | + } |
|
2047 | + if ($alarm['time'] < time()) |
|
2048 | + { |
|
2049 | + calendar_so::shift_alarm($event, $alarm); |
|
2050 | + } |
|
1888 | 2051 | $alarm = array_merge($old_alarm, $alarm); |
1889 | - if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
2052 | + if ($this->debug) |
|
2053 | + { |
|
2054 | + error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm)); |
|
2055 | + } |
|
1890 | 2056 | $alarm['id'] = $this->save_alarm($event['id'], $alarm); |
1891 | 2057 | ++$modified; |
1892 | 2058 | } |
@@ -1900,7 +2066,10 @@ discard block |
||
1900 | 2066 | unset($old_alarm[$id]); |
1901 | 2067 | continue; |
1902 | 2068 | } |
1903 | - if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
2069 | + if ($this->debug) |
|
2070 | + { |
|
2071 | + error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm)); |
|
2072 | + } |
|
1904 | 2073 | $this->delete_alarm($id); |
1905 | 2074 | ++$modified; |
1906 | 2075 | } |
@@ -2319,7 +2488,10 @@ discard block |
||
2319 | 2488 | array2string($_vcalData)."\n",3,$this->logfile); |
2320 | 2489 | } |
2321 | 2490 | |
2322 | - if (!is_array($this->supportedFields)) $this->setSupportedFields(); |
|
2491 | + if (!is_array($this->supportedFields)) |
|
2492 | + { |
|
2493 | + $this->setSupportedFields(); |
|
2494 | + } |
|
2323 | 2495 | |
2324 | 2496 | // we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0]) |
2325 | 2497 | if (is_resource($_vcalData)) |
@@ -2687,19 +2859,27 @@ discard block |
||
2687 | 2859 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2688 | 2860 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2])); |
2689 | 2861 | } |
2690 | - else break; |
|
2862 | + else { |
|
2863 | + break; |
|
2864 | + } |
|
2691 | 2865 | // fall-through |
2692 | 2866 | case 'DAILY': // 2.0 |
2693 | 2867 | $vcardData['recur_type'] = MCAL_RECUR_DAILY; |
2694 | - if (stripos($recurence, 'BYDAY') === false) break; |
|
2868 | + if (stripos($recurence, 'BYDAY') === false) |
|
2869 | + { |
|
2870 | + break; |
|
2871 | + } |
|
2695 | 2872 | // hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval |
2696 | 2873 | // fall-through |
2697 | 2874 | case 'W': |
2698 | 2875 | case 'WEEKLY': |
2699 | 2876 | $days = array(); |
2700 | - if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) // 1.0 |
|
2877 | + if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches)) |
|
2878 | + { |
|
2879 | + // 1.0 |
|
2701 | 2880 | { |
2702 | 2881 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2882 | + } |
|
2703 | 2883 | if (empty($recurenceMatches[2])) |
2704 | 2884 | { |
2705 | 2885 | $days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2)); |
@@ -2712,7 +2892,10 @@ discard block |
||
2712 | 2892 | $repeatMatches = null; |
2713 | 2893 | if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches)) |
2714 | 2894 | { |
2715 | - if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1]; |
|
2895 | + if ($repeatMatches[1]) |
|
2896 | + { |
|
2897 | + $vcardData['recur_count'] = $repeatMatches[1]; |
|
2898 | + } |
|
2716 | 2899 | } |
2717 | 2900 | else |
2718 | 2901 | { |
@@ -2721,9 +2904,12 @@ discard block |
||
2721 | 2904 | |
2722 | 2905 | $recur_days = $this->recur_days_1_0; |
2723 | 2906 | } |
2724 | - elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) // 2.0 |
|
2907 | + elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches)) |
|
2908 | + { |
|
2909 | + // 2.0 |
|
2725 | 2910 | { |
2726 | 2911 | $days = explode(',',$recurenceMatches[1]); |
2912 | + } |
|
2727 | 2913 | $recur_days = $this->recur_days; |
2728 | 2914 | } |
2729 | 2915 | else // no day given, use the day of dtstart |
@@ -2782,7 +2968,10 @@ discard block |
||
2782 | 2968 | { |
2783 | 2969 | $vcardData['recur_interval'] = $recurenceMatches[1]; |
2784 | 2970 | $vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]); |
2785 | - } else break; |
|
2971 | + } |
|
2972 | + else { |
|
2973 | + break; |
|
2974 | + } |
|
2786 | 2975 | // fall-through |
2787 | 2976 | case 'YEARLY': // 2.0 |
2788 | 2977 | if (strpos($recurence, 'BYDAY') === false) |
@@ -2877,13 +3066,16 @@ discard block |
||
2877 | 3066 | // work around Ligthning sending @ as %40 |
2878 | 3067 | $attributes['value'] = str_replace('%40', '@', $attributes['value']); |
2879 | 3068 | if (isset($attributes['params']['PARTSTAT'])) |
2880 | - { |
|
3069 | + { |
|
2881 | 3070 | $attributes['params']['STATUS'] = $attributes['params']['PARTSTAT']; |
2882 | 3071 | } |
2883 | 3072 | if (isset($attributes['params']['STATUS'])) |
2884 | - { |
|
3073 | + { |
|
2885 | 3074 | $status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])]; |
2886 | - if (empty($status)) $status = 'X'; |
|
3075 | + if (empty($status)) |
|
3076 | + { |
|
3077 | + $status = 'X'; |
|
3078 | + } |
|
2887 | 3079 | } |
2888 | 3080 | else |
2889 | 3081 | { |
@@ -2943,7 +3135,10 @@ discard block |
||
2943 | 3135 | $uid = $this->user; |
2944 | 3136 | } |
2945 | 3137 | // check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY |
2946 | - if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
3138 | + if (!$uid) |
|
3139 | + { |
|
3140 | + $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn); |
|
3141 | + } |
|
2947 | 3142 | |
2948 | 3143 | // try to find an email address |
2949 | 3144 | if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email'))) |
@@ -3011,7 +3206,10 @@ discard block |
||
3011 | 3206 | } |
3012 | 3207 | $status = 'U'; // keep the group |
3013 | 3208 | } |
3014 | - else continue 2; // can't find this group |
|
3209 | + else { |
|
3210 | + continue 2; |
|
3211 | + } |
|
3212 | + // can't find this group |
|
3015 | 3213 | } |
3016 | 3214 | elseif (empty($searcharray)) |
3017 | 3215 | { |
@@ -3074,7 +3272,9 @@ discard block |
||
3074 | 3272 | |
3075 | 3273 | try { |
3076 | 3274 | if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR') |
3077 | - $component->getAttribute('ORGANIZER'); |
|
3275 | + { |
|
3276 | + $component->getAttribute('ORGANIZER'); |
|
3277 | + } |
|
3078 | 3278 | } |
3079 | 3279 | catch(Horde_Icalendar_Exception $e) |
3080 | 3280 | { |
@@ -3114,7 +3314,10 @@ discard block |
||
3114 | 3314 | } |
3115 | 3315 | break; |
3116 | 3316 | case 'CREATED': // will be written direct to the event |
3117 | - if ($event['modified']) break; |
|
3317 | + if ($event['modified']) |
|
3318 | + { |
|
3319 | + break; |
|
3320 | + } |
|
3118 | 3321 | // fall through |
3119 | 3322 | case 'LAST-MODIFIED': // will be written direct to the event |
3120 | 3323 | $event['modified'] = $attributes['value']; |
@@ -3135,7 +3338,11 @@ discard block |
||
3135 | 3338 | break; |
3136 | 3339 | |
3137 | 3340 | case 'ATTACH': |
3138 | - if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code |
|
3341 | + if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) |
|
3342 | + { |
|
3343 | + break; |
|
3344 | + } |
|
3345 | + // handeled by managed attachment code |
|
3139 | 3346 | // fall throught to store external attachment url |
3140 | 3347 | default: // X- attribute or other by EGroupware unsupported property |
3141 | 3348 | //error_log(__METHOD__."() $attributes[name] = ".array2string($attributes)); |
@@ -3286,7 +3493,10 @@ discard block |
||
3286 | 3493 | $event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength']; |
3287 | 3494 | } |
3288 | 3495 | |
3289 | - if ($this->calendarOwner) $event['owner'] = $this->calendarOwner; |
|
3496 | + if ($this->calendarOwner) |
|
3497 | + { |
|
3498 | + $event['owner'] = $this->calendarOwner; |
|
3499 | + } |
|
3290 | 3500 | |
3291 | 3501 | // parsing ATTACH attributes for managed attachments |
3292 | 3502 | $event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE'; |
@@ -3312,7 +3522,10 @@ discard block |
||
3312 | 3522 | $filter = $relax ? 'relax' : 'check'; |
3313 | 3523 | $event = array_shift($events); |
3314 | 3524 | $eventId = -1; |
3315 | - if ($this->so->isWholeDay($event)) $event['whole_day'] = true; |
|
3525 | + if ($this->so->isWholeDay($event)) |
|
3526 | + { |
|
3527 | + $event['whole_day'] = true; |
|
3528 | + } |
|
3316 | 3529 | if ($contentID) |
3317 | 3530 | { |
3318 | 3531 | $parts = preg_split('/:/', $contentID); |
@@ -3365,8 +3578,16 @@ discard block |
||
3365 | 3578 | */ |
3366 | 3579 | function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null) |
3367 | 3580 | { |
3368 | - if (!$start) $start = time(); // default now |
|
3369 | - if (!$end) $end = time() + 100*DAY_s; // default next 100 days |
|
3581 | + if (!$start) |
|
3582 | + { |
|
3583 | + $start = time(); |
|
3584 | + } |
|
3585 | + // default now |
|
3586 | + if (!$end) |
|
3587 | + { |
|
3588 | + $end = time() + 100*DAY_s; |
|
3589 | + } |
|
3590 | + // default next 100 days |
|
3370 | 3591 | |
3371 | 3592 | $vcal = new Horde_Icalendar; |
3372 | 3593 | $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'. |
@@ -3388,10 +3609,13 @@ discard block |
||
3388 | 3609 | $attributes[$attr] = date('Ymd\THis', $value); |
3389 | 3610 | } |
3390 | 3611 | } |
3391 | - if (is_null($extra)) $extra = array( |
|
3612 | + if (is_null($extra)) |
|
3613 | + { |
|
3614 | + $extra = array( |
|
3392 | 3615 | 'URL' => $this->freebusy_url($user), |
3393 | 3616 | 'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'), |
3394 | 3617 | ); |
3618 | + } |
|
3395 | 3619 | foreach($attributes+$extra as $attr => $value) |
3396 | 3620 | { |
3397 | 3621 | $vfreebusy->setAttribute($attr, $value); |
@@ -3409,18 +3633,30 @@ discard block |
||
3409 | 3633 | |
3410 | 3634 | foreach ($events as $event) |
3411 | 3635 | { |
3412 | - if ($event['non_blocking']) continue; |
|
3413 | - if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue; |
|
3636 | + if ($event['non_blocking']) |
|
3637 | + { |
|
3638 | + continue; |
|
3639 | + } |
|
3640 | + if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) |
|
3641 | + { |
|
3642 | + continue; |
|
3643 | + } |
|
3414 | 3644 | $status = $event['participants'][$user]; |
3415 | 3645 | $quantity = $role = null; |
3416 | 3646 | calendar_so::split_status($status, $quantity, $role); |
3417 | - if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; |
|
3647 | + if ($status == 'R' || $role == 'NON-PARTICIPANT') |
|
3648 | + { |
|
3649 | + continue; |
|
3650 | + } |
|
3418 | 3651 | |
3419 | 3652 | $fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY'; |
3420 | 3653 | |
3421 | 3654 | // hack to fix end-time to be non-inclusive |
3422 | 3655 | // all-day events end in our data-model at 23:59:59 (of given TZ) |
3423 | - if (date('is', $event['end']) == '5959') ++$event['end']; |
|
3656 | + if (date('is', $event['end']) == '5959') |
|
3657 | + { |
|
3658 | + ++$event['end']; |
|
3659 | + } |
|
3424 | 3660 | |
3425 | 3661 | $fbdata[$fbtype][] = $event; |
3426 | 3662 | } |
@@ -3472,7 +3708,10 @@ discard block |
||
3472 | 3708 | foreach($events as $event) |
3473 | 3709 | { |
3474 | 3710 | error_log(__METHOD__."(..., $start, $end) event[start]=$event[start], event[end]=$event[end], fbdata=".array2string($fbdata)); |
3475 | - if ($event['end'] <= $start || $event['start'] >= $end) continue; |
|
3711 | + if ($event['end'] <= $start || $event['start'] >= $end) |
|
3712 | + { |
|
3713 | + continue; |
|
3714 | + } |
|
3476 | 3715 | |
3477 | 3716 | if (!$fbdata) |
3478 | 3717 | { |
@@ -3501,7 +3740,10 @@ discard block |
||
3501 | 3740 | } |
3502 | 3741 | $last =& $fbdata[count($fbdata)-1]; |
3503 | 3742 | |
3504 | - if ($last['end'] > $end) $last['end'] = $end; |
|
3743 | + if ($last['end'] > $end) |
|
3744 | + { |
|
3745 | + $last['end'] = $end; |
|
3746 | + } |
|
3505 | 3747 | |
3506 | 3748 | error_log(__METHOD__."(..., $start, $end) returning ".array2string($fbdata)); |
3507 | 3749 | return $fbdata; |