@@ -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(); |
@@ -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; |