@@ -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,14 +739,23 @@ 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 | // pass in original event as master, as it has correct start-date even if first recurrence is an exception |
| 692 | 752 | $events =& self::get_series($event['uid'], $this->bo, $expand, $user, $event); |
| 693 | 753 | |
| 694 | 754 | // as alarm is now only on next recurrence, set alarm from original event on master |
| 695 | - if ($event['alarm']) $events[0]['alarm'] = $event['alarm']; |
|
| 755 | + if ($event['alarm']) |
|
| 756 | + { |
|
| 757 | + $events[0]['alarm'] = $event['alarm']; |
|
| 758 | + } |
|
| 696 | 759 | } |
| 697 | 760 | elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
| 698 | 761 | { |
@@ -715,7 +778,10 @@ discard block |
||
| 715 | 778 | */ |
| 716 | 779 | private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null, $master=null) |
| 717 | 780 | { |
| 718 | - if (is_null($bo)) $bo = new calendar_bopdate(); |
|
| 781 | + if (is_null($bo)) |
|
| 782 | + { |
|
| 783 | + $bo = new calendar_bopdate(); |
|
| 784 | + } |
|
| 719 | 785 | |
| 720 | 786 | $params = array( |
| 721 | 787 | 'query' => array('cal_uid' => $uid), |
@@ -724,7 +790,10 @@ discard block |
||
| 724 | 790 | 'date_format' => 'server', |
| 725 | 791 | 'cfs' => array(), // read cfs as we use them to store X- attributes |
| 726 | 792 | ); |
| 727 | - if (is_array($expand)) $params += $expand; |
|
| 793 | + if (is_array($expand)) |
|
| 794 | + { |
|
| 795 | + $params += $expand; |
|
| 796 | + } |
|
| 728 | 797 | |
| 729 | 798 | if (!($events =& $bo->search($params))) |
| 730 | 799 | { |
@@ -737,14 +806,20 @@ discard block |
||
| 737 | 806 | { |
| 738 | 807 | if ($recurrence['recur_type']) |
| 739 | 808 | { |
| 740 | - if (!isset($master)) $master = $recurrence; |
|
| 809 | + if (!isset($master)) |
|
| 810 | + { |
|
| 811 | + $master = $recurrence; |
|
| 812 | + } |
|
| 741 | 813 | $exceptions =& $master['recur_exception']; |
| 742 | 814 | unset($events[$k]); |
| 743 | 815 | break; |
| 744 | 816 | } |
| 745 | 817 | } |
| 746 | 818 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
| 747 | - if (!isset($master)) $master = $bo->read($uid); |
|
| 819 | + if (!isset($master)) |
|
| 820 | + { |
|
| 821 | + $master = $bo->read($uid); |
|
| 822 | + } |
|
| 748 | 823 | |
| 749 | 824 | foreach($events as $k => &$recurrence) |
| 750 | 825 | { |
@@ -754,7 +829,9 @@ discard block |
||
| 754 | 829 | unset($events[$k]); |
| 755 | 830 | continue; // same uid, but references a different event or is own master |
| 756 | 831 | } |
| 757 | - if (!$master || $recurrence['id'] != $master['id']) // real exception |
|
| 832 | + if (!$master || $recurrence['id'] != $master['id']) |
|
| 833 | + { |
|
| 834 | + // real exception |
|
| 758 | 835 | { |
| 759 | 836 | // user is NOT participating in this exception |
| 760 | 837 | if ($user && !self::isParticipant($recurrence, $user)) |
@@ -763,6 +840,7 @@ discard block |
||
| 763 | 840 | if (!$master || !self::isParticipant($master, $user)) |
| 764 | 841 | { |
| 765 | 842 | unset($events[$k]); |
| 843 | + } |
|
| 766 | 844 | continue; |
| 767 | 845 | } |
| 768 | 846 | // otherwise mark him in this exception as rejected |
@@ -794,7 +872,10 @@ discard block |
||
| 794 | 872 | // this is a virtual exception now (no extra event/cal_id in DB) |
| 795 | 873 | //error_log('virtual exception: '.array2string($recurrence)); |
| 796 | 874 | $recurrence['recurrence'] = $recurrence['start']; |
| 797 | - if ($master) $recurrence['reference'] = $master['id']; |
|
| 875 | + if ($master) |
|
| 876 | + { |
|
| 877 | + $recurrence['reference'] = $master['id']; |
|
| 878 | + } |
|
| 798 | 879 | $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
| 799 | 880 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
| 800 | 881 | } |
@@ -833,9 +914,16 @@ discard block |
||
| 833 | 914 | */ |
| 834 | 915 | function put(&$options,$id,$user=null,$prefix=null) |
| 835 | 916 | { |
| 836 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 917 | + if ($this->debug) |
|
| 918 | + { |
|
| 919 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 920 | + } |
|
| 837 | 921 | |
| 838 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 922 | + if (!$prefix) |
|
| 923 | + { |
|
| 924 | + $user = null; |
|
| 925 | + } |
|
| 926 | + // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 839 | 927 | |
| 840 | 928 | // work around missing handling / racecondition in Lightning, if event already exists on server, |
| 841 | 929 | // but Lightning has not yet synced with the server: Lightning just retries the PUT, not GETing the event |
@@ -857,7 +945,10 @@ discard block |
||
| 857 | 945 | isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
| 858 | 946 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
| 859 | 947 | { |
| 860 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 948 | + if ($this->debug) |
|
| 949 | + { |
|
| 950 | + error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 951 | + } |
|
| 861 | 952 | return $oldEvent; |
| 862 | 953 | } |
| 863 | 954 | |
@@ -868,7 +959,10 @@ discard block |
||
| 868 | 959 | { |
| 869 | 960 | // we have no add permission on this user's calendar |
| 870 | 961 | // ToDo: create event in current users calendar and invite only $user |
| 871 | - if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 962 | + if ($this->debug) |
|
| 963 | + { |
|
| 964 | + error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 965 | + } |
|
| 872 | 966 | return '403 Forbidden'; |
| 873 | 967 | } |
| 874 | 968 | |
@@ -915,13 +1009,19 @@ discard block |
||
| 915 | 1009 | if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
| 916 | 1010 | { |
| 917 | 1011 | $schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']; |
| 918 | - if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 1012 | + if ($schedule_tag_match[0] == '"') |
|
| 1013 | + { |
|
| 1014 | + $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 1015 | + } |
|
| 919 | 1016 | $schedule_tag = null; |
| 920 | 1017 | $this->get_etag($oldEvent, $schedule_tag); |
| 921 | 1018 | |
| 922 | 1019 | if ($schedule_tag_match !== $schedule_tag) |
| 923 | 1020 | { |
| 924 | - if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 1021 | + if ($this->debug) |
|
| 1022 | + { |
|
| 1023 | + error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 1024 | + } |
|
| 925 | 1025 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 926 | 1026 | $this->check_return_representation($options, $id, $user); |
| 927 | 1027 | return '412 Precondition Failed'; |
@@ -942,7 +1042,10 @@ discard block |
||
| 942 | 1042 | // above can be true, if current user is not in master but just a recurrence |
| 943 | 1043 | (!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo)))) |
| 944 | 1044 | { |
| 945 | - if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1045 | + if ($this->debug) |
|
| 1046 | + { |
|
| 1047 | + error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1048 | + } |
|
| 946 | 1049 | return '403 Forbidden'; |
| 947 | 1050 | } |
| 948 | 1051 | // update only participant status and alarms of current user |
@@ -962,7 +1065,10 @@ discard block |
||
| 962 | 1065 | } |
| 963 | 1066 | foreach($series as $oldEvent) |
| 964 | 1067 | { |
| 965 | - if ($oldEvent['recurrence'] == $event['recurrence']) break; |
|
| 1068 | + if ($oldEvent['recurrence'] == $event['recurrence']) |
|
| 1069 | + { |
|
| 1070 | + break; |
|
| 1071 | + } |
|
| 966 | 1072 | } |
| 967 | 1073 | // if no exception found, check if it might be just a recurrence (no exception) |
| 968 | 1074 | if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence']) |
@@ -977,7 +1083,10 @@ discard block |
||
| 977 | 1083 | } |
| 978 | 1084 | } |
| 979 | 1085 | } |
| 980 | - 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)); |
|
| 1086 | + if ($this->debug) |
|
| 1087 | + { |
|
| 1088 | + 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)); |
|
| 1089 | + } |
|
| 981 | 1090 | if (isset($event['participants']) && isset($event['participants'][$user]) && |
| 982 | 1091 | $event['participants'][$user] !== $oldEvent['participants'][$user]) |
| 983 | 1092 | { |
@@ -985,13 +1094,19 @@ discard block |
||
| 985 | 1094 | // real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence! |
| 986 | 1095 | $recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0)) |
| 987 | 1096 | { |
| 988 | - if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1097 | + if ($this->debug) |
|
| 1098 | + { |
|
| 1099 | + error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1100 | + } |
|
| 989 | 1101 | return '403 Forbidden'; |
| 990 | 1102 | } |
| 991 | 1103 | else |
| 992 | 1104 | { |
| 993 | 1105 | ++$modified; |
| 994 | - if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1106 | + if ($this->debug) |
|
| 1107 | + { |
|
| 1108 | + error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1109 | + } |
|
| 995 | 1110 | } |
| 996 | 1111 | } |
| 997 | 1112 | // import alarms, if given and changed |
@@ -1001,15 +1116,21 @@ discard block |
||
| 1001 | 1116 | $modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user); |
| 1002 | 1117 | } |
| 1003 | 1118 | } |
| 1004 | - if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 1119 | + if (!$modified) |
|
| 1120 | + { |
|
| 1121 | + // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 1005 | 1122 | { |
| 1006 | 1123 | $this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent)); |
| 1007 | 1124 | } |
| 1125 | + } |
|
| 1008 | 1126 | $this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name'); |
| 1009 | 1127 | |
| 1010 | 1128 | return '204 No Content'; |
| 1011 | 1129 | } |
| 1012 | - if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1130 | + if ($this->debug && !isset($events)) |
|
| 1131 | + { |
|
| 1132 | + error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1133 | + } |
|
| 1013 | 1134 | } |
| 1014 | 1135 | if ($return_no_access) |
| 1015 | 1136 | { |
@@ -1046,17 +1167,23 @@ discard block |
||
| 1046 | 1167 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, |
| 1047 | 1168 | self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id))) |
| 1048 | 1169 | { |
| 1049 | - if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1170 | + if ($this->debug) |
|
| 1171 | + { |
|
| 1172 | + error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1173 | + } |
|
| 1050 | 1174 | if ($eventId && $cal_id === false) |
| 1051 | 1175 | { |
| 1052 | 1176 | // ignore import failures |
| 1053 | 1177 | $cal_id = $eventId; |
| 1054 | 1178 | $retval = true; |
| 1055 | 1179 | } |
| 1056 | - elseif ($cal_id === 0) // etag failure |
|
| 1180 | + elseif ($cal_id === 0) |
|
| 1181 | + { |
|
| 1182 | + // etag failure |
|
| 1057 | 1183 | { |
| 1058 | 1184 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 1059 | 1185 | $this->check_return_representation($options, $id, $user); |
| 1186 | + } |
|
| 1060 | 1187 | return '412 Precondition Failed'; |
| 1061 | 1188 | } |
| 1062 | 1189 | else |
@@ -1081,7 +1208,10 @@ discard block |
||
| 1081 | 1208 | */ |
| 1082 | 1209 | function post(&$options,$id,$user=null) |
| 1083 | 1210 | { |
| 1084 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1211 | + if ($this->debug) |
|
| 1212 | + { |
|
| 1213 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1214 | + } |
|
| 1085 | 1215 | |
| 1086 | 1216 | $vCalendar = htmlspecialchars_decode($options['content']); |
| 1087 | 1217 | $charset = null; |
@@ -1135,7 +1265,10 @@ discard block |
||
| 1135 | 1265 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null, |
| 1136 | 1266 | false, 0, $this->caldav->current_user_principal, $user, $charset))) |
| 1137 | 1267 | { |
| 1138 | - if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1268 | + if ($this->debug) |
|
| 1269 | + { |
|
| 1270 | + error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1271 | + } |
|
| 1139 | 1272 | } |
| 1140 | 1273 | header('ETag: "'.$this->get_etag($eventId).'"'); |
| 1141 | 1274 | } |
@@ -1303,7 +1436,10 @@ discard block |
||
| 1303 | 1436 | $org_recurrences = $exceptions = array(); |
| 1304 | 1437 | foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
| 1305 | 1438 | { |
| 1306 | - if (!$k) $master = $event; |
|
| 1439 | + if (!$k) |
|
| 1440 | + { |
|
| 1441 | + $master = $event; |
|
| 1442 | + } |
|
| 1307 | 1443 | if ($event['recurrence']) |
| 1308 | 1444 | { |
| 1309 | 1445 | $org_recurrences[$event['recurrence']] = $event; |
@@ -1323,10 +1459,13 @@ discard block |
||
| 1323 | 1459 | |
| 1324 | 1460 | // from now on we deal with exceptions |
| 1325 | 1461 | $org_recurrence = $org_recurrences[$recurrence['recurrence']]; |
| 1326 | - if (isset($org_recurrence)) // already existing recurrence |
|
| 1462 | + if (isset($org_recurrence)) |
|
| 1463 | + { |
|
| 1464 | + // already existing recurrence |
|
| 1327 | 1465 | { |
| 1328 | 1466 | //error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); |
| 1329 | 1467 | $recurrence['id'] = $org_recurrence['id']; |
| 1468 | + } |
|
| 1330 | 1469 | |
| 1331 | 1470 | // re-add (non-virtual) exceptions to master's recur_exception |
| 1332 | 1471 | if ($recurrence['id'] != $master['id']) |
@@ -1343,10 +1482,14 @@ discard block |
||
| 1343 | 1482 | // delete not longer existing recurrences |
| 1344 | 1483 | foreach($org_recurrences as $org_recurrence) |
| 1345 | 1484 | { |
| 1346 | - if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
|
| 1485 | + if ($org_recurrence['id'] != $master['id']) |
|
| 1486 | + { |
|
| 1487 | + // non-virtual recurrence |
|
| 1347 | 1488 | { |
| 1348 | 1489 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
| 1349 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
| 1490 | + $bo->delete($org_recurrence['id']); |
|
| 1491 | + } |
|
| 1492 | + // might fail because of permissions |
|
| 1350 | 1493 | } |
| 1351 | 1494 | else // virtual recurrence |
| 1352 | 1495 | { |
@@ -1424,9 +1567,14 @@ discard block |
||
| 1424 | 1567 | else |
| 1425 | 1568 | { |
| 1426 | 1569 | $ret = $this->bo->delete($event['id']); |
| 1427 | - if (!$ret) { error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event';} |
|
| 1570 | + if (!$ret) |
|
| 1571 | + { |
|
| 1572 | +error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event';} |
|
| 1573 | + } |
|
| 1574 | + if ($this->debug) |
|
| 1575 | + { |
|
| 1576 | + 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)); |
|
| 1428 | 1577 | } |
| 1429 | - 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)); |
|
| 1430 | 1578 | return $ret; |
| 1431 | 1579 | } |
| 1432 | 1580 | |
@@ -1441,16 +1589,26 @@ discard block |
||
| 1441 | 1589 | */ |
| 1442 | 1590 | function read($id) |
| 1443 | 1591 | { |
| 1444 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
| 1592 | + if (strpos($column=self::$path_attr,'_') === false) |
|
| 1593 | + { |
|
| 1594 | + $column = 'cal_'.$column; |
|
| 1595 | + } |
|
| 1445 | 1596 | |
| 1446 | 1597 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
| 1447 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
| 1598 | + if ($event) |
|
| 1599 | + { |
|
| 1600 | + $event = array_shift($event); |
|
| 1601 | + } |
|
| 1602 | + // read with array as 1. param, returns an array of events! |
|
| 1448 | 1603 | |
| 1449 | 1604 | if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) && |
| 1450 | 1605 | // above can be true, if current user is not in master but just a recurrence |
| 1451 | 1606 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
| 1452 | 1607 | { |
| 1453 | - if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1608 | + if ($this->debug > 0) |
|
| 1609 | + { |
|
| 1610 | + error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1611 | + } |
|
| 1454 | 1612 | return $retval; |
| 1455 | 1613 | } |
| 1456 | 1614 | if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server')) |
@@ -1458,9 +1616,15 @@ discard block |
||
| 1458 | 1616 | $this->bo->clear_private_infos($event, array($this->bo->user, $event['owner'])); |
| 1459 | 1617 | } |
| 1460 | 1618 | // handle deleted events, as not existing |
| 1461 | - if ($event['deleted']) $event = null; |
|
| 1619 | + if ($event['deleted']) |
|
| 1620 | + { |
|
| 1621 | + $event = null; |
|
| 1622 | + } |
|
| 1462 | 1623 | |
| 1463 | - if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1624 | + if ($this->debug > 1) |
|
| 1625 | + { |
|
| 1626 | + error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1627 | + } |
|
| 1464 | 1628 | |
| 1465 | 1629 | return $event; |
| 1466 | 1630 | } |
@@ -1472,7 +1636,10 @@ discard block |
||
| 1472 | 1636 | */ |
| 1473 | 1637 | public function update_tags($entry) |
| 1474 | 1638 | { |
| 1475 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
| 1639 | + if (!is_array($entry)) |
|
| 1640 | + { |
|
| 1641 | + $entry = $this->read($entry); |
|
| 1642 | + } |
|
| 1476 | 1643 | |
| 1477 | 1644 | $this->bo->update($entry, true); |
| 1478 | 1645 | } |
@@ -1486,7 +1653,10 @@ discard block |
||
| 1486 | 1653 | { |
| 1487 | 1654 | $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
| 1488 | 1655 | |
| 1489 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1656 | + if ($this->debug > 1) |
|
| 1657 | + { |
|
| 1658 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1659 | + } |
|
| 1490 | 1660 | |
| 1491 | 1661 | return $ctag; |
| 1492 | 1662 | } |
@@ -1616,7 +1786,10 @@ discard block |
||
| 1616 | 1786 | $handler = new calendar_ical(); |
| 1617 | 1787 | $handler->setSupportedFields('GroupDAV',$this->agent); |
| 1618 | 1788 | $handler->supportedFields['attachments'] = true; // enabling attachments |
| 1619 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
| 1789 | + if ($this->debug > 1) |
|
| 1790 | + { |
|
| 1791 | + error_log("ical Handler called: " . $this->agent); |
|
| 1792 | + } |
|
| 1620 | 1793 | return $handler; |
| 1621 | 1794 | } |
| 1622 | 1795 | |
@@ -1687,7 +1860,11 @@ discard block |
||
| 1687 | 1860 | { |
| 1688 | 1861 | $calendars[$entry['grantor']] = $entry['name']; |
| 1689 | 1862 | } |
| 1690 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
| 1863 | + if ($user > 0) |
|
| 1864 | + { |
|
| 1865 | + unset($calendars[$user]); |
|
| 1866 | + } |
|
| 1867 | + // skip current user |
|
| 1691 | 1868 | } |
| 1692 | 1869 | |
| 1693 | 1870 | $settings = array(); |