@@ -120,7 +120,10 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
| 123 | - if (!is_array($event)) $event = $this->bo->read($event); |
|
| 123 | + if (!is_array($event)) |
|
| 124 | + { |
|
| 125 | + $event = $this->bo->read($event); |
|
| 126 | + } |
|
| 124 | 127 | $name = $event[self::$path_attr]; |
| 125 | 128 | } |
| 126 | 129 | $name .= self::$path_extension; |
@@ -181,10 +184,13 @@ discard block |
||
| 181 | 184 | } |
| 182 | 185 | $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
| 183 | 186 | } |
| 184 | - if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
|
| 187 | + if ($this->client_shared_uid_exceptions) |
|
| 188 | + { |
|
| 189 | + // do NOT return (non-virtual) exceptions |
|
| 185 | 190 | { |
| 186 | 191 | $filter['query'] = array('cal_reference' => 0); |
| 187 | 192 | } |
| 193 | + } |
|
| 188 | 194 | |
| 189 | 195 | if ($path == '/calendar/') |
| 190 | 196 | { |
@@ -214,7 +220,11 @@ discard block |
||
| 214 | 220 | // when trying to request not supported components, eg. VTODO on a calendar collection |
| 215 | 221 | return true; |
| 216 | 222 | } |
| 217 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
| 223 | + if ($id) |
|
| 224 | + { |
|
| 225 | + $path = dirname($path).'/'; |
|
| 226 | + } |
|
| 227 | + // caldav_name get's added anyway in the callback |
|
| 218 | 228 | |
| 219 | 229 | if ($this->debug > 1) |
| 220 | 230 | { |
@@ -276,7 +286,11 @@ discard block |
||
| 276 | 286 | $n = 0; |
| 277 | 287 | foreach($files as $file) |
| 278 | 288 | { |
| 279 | - if (!$n++) continue; // first entry is collection itself |
|
| 289 | + if (!$n++) |
|
| 290 | + { |
|
| 291 | + continue; |
|
| 292 | + } |
|
| 293 | + // first entry is collection itself |
|
| 280 | 294 | |
| 281 | 295 | $icalendar = $file['props']['calendar-data']['val']; |
| 282 | 296 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -320,10 +334,17 @@ discard block |
||
| 320 | 334 | */ |
| 321 | 335 | function &propfind_callback($path,array $filter,$start=false) |
| 322 | 336 | { |
| 323 | - if ($this->debug) $starttime = microtime(true); |
|
| 337 | + if ($this->debug) |
|
| 338 | + { |
|
| 339 | + $starttime = microtime(true); |
|
| 340 | + } |
|
| 324 | 341 | |
| 325 | 342 | $calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true); |
| 326 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
| 343 | + if (!is_array($calendar_data)) |
|
| 344 | + { |
|
| 345 | + $calendar_data = false; |
|
| 346 | + } |
|
| 347 | + // not in allprop or autoindex |
|
| 327 | 348 | |
| 328 | 349 | $files = array(); |
| 329 | 350 | |
@@ -481,7 +502,10 @@ discard block |
||
| 481 | 502 | switch($filter['name']) |
| 482 | 503 | { |
| 483 | 504 | case 'comp-filter': |
| 484 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
| 505 | + if ($this->debug > 1) |
|
| 506 | + { |
|
| 507 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
| 508 | + } |
|
| 485 | 509 | |
| 486 | 510 | switch($filter['attrs']['name']) |
| 487 | 511 | { |
@@ -496,14 +520,23 @@ discard block |
||
| 496 | 520 | } |
| 497 | 521 | break; |
| 498 | 522 | case 'prop-filter': |
| 499 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
| 523 | + if ($this->debug > 1) |
|
| 524 | + { |
|
| 525 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
| 526 | + } |
|
| 500 | 527 | $prop_filter = $filter['attrs']['name']; |
| 501 | 528 | break; |
| 502 | 529 | case 'text-match': |
| 503 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
| 530 | + if ($this->debug > 1) |
|
| 531 | + { |
|
| 532 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
| 533 | + } |
|
| 504 | 534 | if (!isset($this->filter_prop2cal[strtoupper($prop_filter)])) |
| 505 | 535 | { |
| 506 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
| 536 | + if ($this->debug) |
|
| 537 | + { |
|
| 538 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
| 539 | + } |
|
| 507 | 540 | } |
| 508 | 541 | else |
| 509 | 542 | { |
@@ -512,10 +545,16 @@ discard block |
||
| 512 | 545 | unset($prop_filter); |
| 513 | 546 | break; |
| 514 | 547 | case 'param-filter': |
| 515 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
| 548 | + if ($this->debug) |
|
| 549 | + { |
|
| 550 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
| 551 | + } |
|
| 516 | 552 | break; |
| 517 | 553 | case 'time-range': |
| 518 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
| 554 | + if ($this->debug > 1) |
|
| 555 | + { |
|
| 556 | + error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
| 557 | + } |
|
| 519 | 558 | if (!empty($filter['attrs']['start'])) |
| 520 | 559 | { |
| 521 | 560 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
@@ -526,13 +565,19 @@ discard block |
||
| 526 | 565 | } |
| 527 | 566 | break; |
| 528 | 567 | default: |
| 529 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
| 568 | + if ($this->debug) |
|
| 569 | + { |
|
| 570 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
| 571 | + } |
|
| 530 | 572 | break; |
| 531 | 573 | } |
| 532 | 574 | } |
| 533 | - if (count($cal_filters) == $num_filters) // no filters set --> restore default start and end time |
|
| 575 | + if (count($cal_filters) == $num_filters) |
|
| 576 | + { |
|
| 577 | + // no filters set --> restore default start and end time |
|
| 534 | 578 | { |
| 535 | 579 | $cal_filters['start'] = $cal_start; |
| 580 | + } |
|
| 536 | 581 | $cal_filters['end'] = $cal_end; |
| 537 | 582 | } |
| 538 | 583 | } |
@@ -609,7 +654,10 @@ discard block |
||
| 609 | 654 | } |
| 610 | 655 | } |
| 611 | 656 | |
| 612 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
| 657 | + if ($this->debug > 1) |
|
| 658 | + { |
|
| 659 | + error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
| 660 | + } |
|
| 613 | 661 | } |
| 614 | 662 | return true; |
| 615 | 663 | } |
@@ -655,9 +703,15 @@ discard block |
||
| 655 | 703 | private function iCal(array $event,$user=null, $method=null, $expand=false) |
| 656 | 704 | { |
| 657 | 705 | static $handler = null; |
| 658 | - if (is_null($handler)) $handler = $this->_get_handler(); |
|
| 706 | + if (is_null($handler)) |
|
| 707 | + { |
|
| 708 | + $handler = $this->_get_handler(); |
|
| 709 | + } |
|
| 659 | 710 | |
| 660 | - if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 711 | + if (!$user) |
|
| 712 | + { |
|
| 713 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 714 | + } |
|
| 661 | 715 | |
| 662 | 716 | // only return alarms in own calendar, not other users calendars |
| 663 | 717 | if ($user != $GLOBALS['egw_info']['user']['account_id']) |
@@ -673,12 +727,21 @@ discard block |
||
| 673 | 727 | { |
| 674 | 728 | if (is_array($expand)) |
| 675 | 729 | { |
| 676 | - if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
| 677 | - if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
| 730 | + if (isset($expand['start'])) |
|
| 731 | + { |
|
| 732 | + $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
| 733 | + } |
|
| 734 | + if (isset($expand['end'])) |
|
| 735 | + { |
|
| 736 | + $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
| 737 | + } |
|
| 678 | 738 | } |
| 679 | 739 | $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
| 680 | 740 | // as alarm is now only on next recurrence, set alarm from original event on master |
| 681 | - if ($event['alarm']) $events[0]['alarm'] = $event['alarm']; |
|
| 741 | + if ($event['alarm']) |
|
| 742 | + { |
|
| 743 | + $events[0]['alarm'] = $event['alarm']; |
|
| 744 | + } |
|
| 682 | 745 | } |
| 683 | 746 | elseif(!$this->client_shared_uid_exceptions && $event['reference']) |
| 684 | 747 | { |
@@ -700,7 +763,10 @@ discard block |
||
| 700 | 763 | */ |
| 701 | 764 | private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
| 702 | 765 | { |
| 703 | - if (is_null($bo)) $bo = new calendar_bopdate(); |
|
| 766 | + if (is_null($bo)) |
|
| 767 | + { |
|
| 768 | + $bo = new calendar_bopdate(); |
|
| 769 | + } |
|
| 704 | 770 | |
| 705 | 771 | $params = array( |
| 706 | 772 | 'query' => array('cal_uid' => $uid), |
@@ -709,7 +775,10 @@ discard block |
||
| 709 | 775 | 'date_format' => 'server', |
| 710 | 776 | 'cfs' => array(), // read cfs as we use them to store X- attributes |
| 711 | 777 | ); |
| 712 | - if (is_array($expand)) $params += $expand; |
|
| 778 | + if (is_array($expand)) |
|
| 779 | + { |
|
| 780 | + $params += $expand; |
|
| 781 | + } |
|
| 713 | 782 | |
| 714 | 783 | if (!($events =& $bo->search($params))) |
| 715 | 784 | { |
@@ -730,7 +799,10 @@ discard block |
||
| 730 | 799 | } |
| 731 | 800 | } |
| 732 | 801 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
| 733 | - if (!isset($master)) $master = $bo->read($uid); |
|
| 802 | + if (!isset($master)) |
|
| 803 | + { |
|
| 804 | + $master = $bo->read($uid); |
|
| 805 | + } |
|
| 734 | 806 | |
| 735 | 807 | foreach($events as $k => &$recurrence) |
| 736 | 808 | { |
@@ -740,7 +812,9 @@ discard block |
||
| 740 | 812 | unset($events[$k]); |
| 741 | 813 | continue; // same uid, but references a different event or is own master |
| 742 | 814 | } |
| 743 | - if (!$master || $recurrence['id'] != $master['id']) // real exception |
|
| 815 | + if (!$master || $recurrence['id'] != $master['id']) |
|
| 816 | + { |
|
| 817 | + // real exception |
|
| 744 | 818 | { |
| 745 | 819 | // user is NOT participating in this exception |
| 746 | 820 | if ($user && !self::isParticipant($recurrence, $user)) |
@@ -749,6 +823,7 @@ discard block |
||
| 749 | 823 | if (!$master || !self::isParticipant($master, $user)) |
| 750 | 824 | { |
| 751 | 825 | unset($events[$k]); |
| 826 | + } |
|
| 752 | 827 | continue; |
| 753 | 828 | } |
| 754 | 829 | // otherwise mark him in this exception as rejected |
@@ -780,7 +855,10 @@ discard block |
||
| 780 | 855 | // this is a virtual exception now (no extra event/cal_id in DB) |
| 781 | 856 | //error_log('virtual exception: '.array2string($recurrence)); |
| 782 | 857 | $recurrence['recurrence'] = $recurrence['start']; |
| 783 | - if ($master) $recurrence['reference'] = $master['id']; |
|
| 858 | + if ($master) |
|
| 859 | + { |
|
| 860 | + $recurrence['reference'] = $master['id']; |
|
| 861 | + } |
|
| 784 | 862 | $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
| 785 | 863 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
| 786 | 864 | } |
@@ -817,9 +895,16 @@ discard block |
||
| 817 | 895 | */ |
| 818 | 896 | function put(&$options,$id,$user=null,$prefix=null) |
| 819 | 897 | { |
| 820 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 898 | + if ($this->debug) |
|
| 899 | + { |
|
| 900 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 901 | + } |
|
| 821 | 902 | |
| 822 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 903 | + if (!$prefix) |
|
| 904 | + { |
|
| 905 | + $user = null; |
|
| 906 | + } |
|
| 907 | + // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 823 | 908 | |
| 824 | 909 | // fix for iCal4OL using WinHTTP only supporting a certain header length |
| 825 | 910 | if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
@@ -831,7 +916,10 @@ discard block |
||
| 831 | 916 | isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
| 832 | 917 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
| 833 | 918 | { |
| 834 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 919 | + if ($this->debug) |
|
| 920 | + { |
|
| 921 | + error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 922 | + } |
|
| 835 | 923 | return $oldEvent; |
| 836 | 924 | } |
| 837 | 925 | |
@@ -842,7 +930,10 @@ discard block |
||
| 842 | 930 | { |
| 843 | 931 | // we have no add permission on this user's calendar |
| 844 | 932 | // ToDo: create event in current users calendar and invite only $user |
| 845 | - if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 933 | + if ($this->debug) |
|
| 934 | + { |
|
| 935 | + error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 936 | + } |
|
| 846 | 937 | return '403 Forbidden'; |
| 847 | 938 | } |
| 848 | 939 | |
@@ -890,13 +981,19 @@ discard block |
||
| 890 | 981 | if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
| 891 | 982 | { |
| 892 | 983 | $schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']; |
| 893 | - if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 984 | + if ($schedule_tag_match[0] == '"') |
|
| 985 | + { |
|
| 986 | + $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 987 | + } |
|
| 894 | 988 | $schedule_tag = null; |
| 895 | 989 | $this->get_etag($oldEvent, $schedule_tag); |
| 896 | 990 | |
| 897 | 991 | if ($schedule_tag_match !== $schedule_tag) |
| 898 | 992 | { |
| 899 | - if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 993 | + if ($this->debug) |
|
| 994 | + { |
|
| 995 | + error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 996 | + } |
|
| 900 | 997 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 901 | 998 | $this->check_return_representation($options, $id, $user); |
| 902 | 999 | return '412 Precondition Failed'; |
@@ -911,7 +1008,10 @@ discard block |
||
| 911 | 1008 | // above can be true, if current user is not in master but just a recurrence |
| 912 | 1009 | (!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo)))) |
| 913 | 1010 | { |
| 914 | - if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1011 | + if ($this->debug) |
|
| 1012 | + { |
|
| 1013 | + error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1014 | + } |
|
| 915 | 1015 | return '403 Forbidden'; |
| 916 | 1016 | } |
| 917 | 1017 | // update only participant status and alarms of current user |
@@ -931,7 +1031,10 @@ discard block |
||
| 931 | 1031 | } |
| 932 | 1032 | foreach($series as $oldEvent) |
| 933 | 1033 | { |
| 934 | - if ($oldEvent['recurrence'] == $event['recurrence']) break; |
|
| 1034 | + if ($oldEvent['recurrence'] == $event['recurrence']) |
|
| 1035 | + { |
|
| 1036 | + break; |
|
| 1037 | + } |
|
| 935 | 1038 | } |
| 936 | 1039 | // if no exception found, check if it might be just a recurrence (no exception) |
| 937 | 1040 | if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence']) |
@@ -946,7 +1049,10 @@ discard block |
||
| 946 | 1049 | } |
| 947 | 1050 | } |
| 948 | 1051 | } |
| 949 | - 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)); |
|
| 1052 | + if ($this->debug) |
|
| 1053 | + { |
|
| 1054 | + 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)); |
|
| 1055 | + } |
|
| 950 | 1056 | if (isset($event['participants']) && isset($event['participants'][$user]) && |
| 951 | 1057 | $event['participants'][$user] !== $oldEvent['participants'][$user]) |
| 952 | 1058 | { |
@@ -954,13 +1060,19 @@ discard block |
||
| 954 | 1060 | // real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence! |
| 955 | 1061 | $recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0)) |
| 956 | 1062 | { |
| 957 | - if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1063 | + if ($this->debug) |
|
| 1064 | + { |
|
| 1065 | + error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1066 | + } |
|
| 958 | 1067 | return '403 Forbidden'; |
| 959 | 1068 | } |
| 960 | 1069 | else |
| 961 | 1070 | { |
| 962 | 1071 | ++$modified; |
| 963 | - if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1072 | + if ($this->debug) |
|
| 1073 | + { |
|
| 1074 | + error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1075 | + } |
|
| 964 | 1076 | } |
| 965 | 1077 | } |
| 966 | 1078 | // import alarms, if given and changed |
@@ -970,15 +1082,21 @@ discard block |
||
| 970 | 1082 | $modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user); |
| 971 | 1083 | } |
| 972 | 1084 | } |
| 973 | - if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 1085 | + if (!$modified) |
|
| 1086 | + { |
|
| 1087 | + // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 974 | 1088 | { |
| 975 | 1089 | $this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent)); |
| 976 | 1090 | } |
| 1091 | + } |
|
| 977 | 1092 | $this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name'); |
| 978 | 1093 | |
| 979 | 1094 | return '204 No Content'; |
| 980 | 1095 | } |
| 981 | - if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1096 | + if ($this->debug && !isset($events)) |
|
| 1097 | + { |
|
| 1098 | + error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1099 | + } |
|
| 982 | 1100 | } |
| 983 | 1101 | if ($return_no_access) |
| 984 | 1102 | { |
@@ -1010,17 +1128,23 @@ discard block |
||
| 1010 | 1128 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, |
| 1011 | 1129 | self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id))) |
| 1012 | 1130 | { |
| 1013 | - if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1131 | + if ($this->debug) |
|
| 1132 | + { |
|
| 1133 | + error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1134 | + } |
|
| 1014 | 1135 | if ($eventId && $cal_id === false) |
| 1015 | 1136 | { |
| 1016 | 1137 | // ignore import failures |
| 1017 | 1138 | $cal_id = $eventId; |
| 1018 | 1139 | $retval = true; |
| 1019 | 1140 | } |
| 1020 | - elseif ($cal_id === 0) // etag failure |
|
| 1141 | + elseif ($cal_id === 0) |
|
| 1142 | + { |
|
| 1143 | + // etag failure |
|
| 1021 | 1144 | { |
| 1022 | 1145 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 1023 | 1146 | $this->check_return_representation($options, $id, $user); |
| 1147 | + } |
|
| 1024 | 1148 | return '412 Precondition Failed'; |
| 1025 | 1149 | } |
| 1026 | 1150 | else |
@@ -1045,7 +1169,10 @@ discard block |
||
| 1045 | 1169 | */ |
| 1046 | 1170 | function post(&$options,$id,$user=null) |
| 1047 | 1171 | { |
| 1048 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1172 | + if ($this->debug) |
|
| 1173 | + { |
|
| 1174 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1175 | + } |
|
| 1049 | 1176 | |
| 1050 | 1177 | $vCalendar = htmlspecialchars_decode($options['content']); |
| 1051 | 1178 | $charset = null; |
@@ -1100,7 +1227,10 @@ discard block |
||
| 1100 | 1227 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null, |
| 1101 | 1228 | false, 0, $this->caldav->current_user_principal, $user, $charset))) |
| 1102 | 1229 | { |
| 1103 | - if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1230 | + if ($this->debug) |
|
| 1231 | + { |
|
| 1232 | + error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1233 | + } |
|
| 1104 | 1234 | } |
| 1105 | 1235 | header('ETag: "'.$this->get_etag($eventId).'"'); |
| 1106 | 1236 | } |
@@ -1268,7 +1398,10 @@ discard block |
||
| 1268 | 1398 | $org_recurrences = $exceptions = array(); |
| 1269 | 1399 | foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
| 1270 | 1400 | { |
| 1271 | - if (!$k) $master = $event; |
|
| 1401 | + if (!$k) |
|
| 1402 | + { |
|
| 1403 | + $master = $event; |
|
| 1404 | + } |
|
| 1272 | 1405 | if ($event['recurrence']) |
| 1273 | 1406 | { |
| 1274 | 1407 | $org_recurrences[$event['recurrence']] = $event; |
@@ -1288,10 +1421,13 @@ discard block |
||
| 1288 | 1421 | |
| 1289 | 1422 | // from now on we deal with exceptions |
| 1290 | 1423 | $org_recurrence = $org_recurrences[$recurrence['recurrence']]; |
| 1291 | - if (isset($org_recurrence)) // already existing recurrence |
|
| 1424 | + if (isset($org_recurrence)) |
|
| 1425 | + { |
|
| 1426 | + // already existing recurrence |
|
| 1292 | 1427 | { |
| 1293 | 1428 | //error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); |
| 1294 | 1429 | $recurrence['id'] = $org_recurrence['id']; |
| 1430 | + } |
|
| 1295 | 1431 | |
| 1296 | 1432 | // re-add (non-virtual) exceptions to master's recur_exception |
| 1297 | 1433 | if ($recurrence['id'] != $master['id']) |
@@ -1308,10 +1444,14 @@ discard block |
||
| 1308 | 1444 | // delete not longer existing recurrences |
| 1309 | 1445 | foreach($org_recurrences as $org_recurrence) |
| 1310 | 1446 | { |
| 1311 | - if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
|
| 1447 | + if ($org_recurrence['id'] != $master['id']) |
|
| 1448 | + { |
|
| 1449 | + // non-virtual recurrence |
|
| 1312 | 1450 | { |
| 1313 | 1451 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
| 1314 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
| 1452 | + $bo->delete($org_recurrence['id']); |
|
| 1453 | + } |
|
| 1454 | + // might fail because of permissions |
|
| 1315 | 1455 | } |
| 1316 | 1456 | else // virtual recurrence |
| 1317 | 1457 | { |
@@ -1342,7 +1482,7 @@ discard block |
||
| 1342 | 1482 | if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access) |
| 1343 | 1483 | { |
| 1344 | 1484 | if (!$return_no_access) |
| 1345 | - { |
|
| 1485 | + { |
|
| 1346 | 1486 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
| 1347 | 1487 | $ret = '403 Forbidden'; |
| 1348 | 1488 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
@@ -1365,7 +1505,10 @@ discard block |
||
| 1365 | 1505 | { |
| 1366 | 1506 | $ret = $this->bo->delete($event['id']); |
| 1367 | 1507 | } |
| 1368 | - 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)); |
|
| 1508 | + if ($this->debug) |
|
| 1509 | + { |
|
| 1510 | + 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)); |
|
| 1511 | + } |
|
| 1369 | 1512 | return $ret; |
| 1370 | 1513 | } |
| 1371 | 1514 | |
@@ -1380,16 +1523,26 @@ discard block |
||
| 1380 | 1523 | */ |
| 1381 | 1524 | function read($id) |
| 1382 | 1525 | { |
| 1383 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
| 1526 | + if (strpos($column=self::$path_attr,'_') === false) |
|
| 1527 | + { |
|
| 1528 | + $column = 'cal_'.$column; |
|
| 1529 | + } |
|
| 1384 | 1530 | |
| 1385 | 1531 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
| 1386 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
| 1532 | + if ($event) |
|
| 1533 | + { |
|
| 1534 | + $event = array_shift($event); |
|
| 1535 | + } |
|
| 1536 | + // read with array as 1. param, returns an array of events! |
|
| 1387 | 1537 | |
| 1388 | 1538 | if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) && |
| 1389 | 1539 | // above can be true, if current user is not in master but just a recurrence |
| 1390 | 1540 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
| 1391 | 1541 | { |
| 1392 | - if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1542 | + if ($this->debug > 0) |
|
| 1543 | + { |
|
| 1544 | + error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1545 | + } |
|
| 1393 | 1546 | return $retval; |
| 1394 | 1547 | } |
| 1395 | 1548 | if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server')) |
@@ -1397,9 +1550,15 @@ discard block |
||
| 1397 | 1550 | $this->bo->clear_private_infos($event, array($this->bo->user, $event['owner'])); |
| 1398 | 1551 | } |
| 1399 | 1552 | // handle deleted events, as not existing |
| 1400 | - if ($event['deleted']) $event = null; |
|
| 1553 | + if ($event['deleted']) |
|
| 1554 | + { |
|
| 1555 | + $event = null; |
|
| 1556 | + } |
|
| 1401 | 1557 | |
| 1402 | - if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1558 | + if ($this->debug > 1) |
|
| 1559 | + { |
|
| 1560 | + error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1561 | + } |
|
| 1403 | 1562 | |
| 1404 | 1563 | return $event; |
| 1405 | 1564 | } |
@@ -1411,7 +1570,10 @@ discard block |
||
| 1411 | 1570 | */ |
| 1412 | 1571 | public function update_tags($entry) |
| 1413 | 1572 | { |
| 1414 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
| 1573 | + if (!is_array($entry)) |
|
| 1574 | + { |
|
| 1575 | + $entry = $this->read($entry); |
|
| 1576 | + } |
|
| 1415 | 1577 | |
| 1416 | 1578 | $this->bo->update($entry, true); |
| 1417 | 1579 | } |
@@ -1425,7 +1587,10 @@ discard block |
||
| 1425 | 1587 | { |
| 1426 | 1588 | $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
| 1427 | 1589 | |
| 1428 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1590 | + if ($this->debug > 1) |
|
| 1591 | + { |
|
| 1592 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1593 | + } |
|
| 1429 | 1594 | |
| 1430 | 1595 | return $ctag; |
| 1431 | 1596 | } |
@@ -1555,7 +1720,10 @@ discard block |
||
| 1555 | 1720 | $handler = new calendar_ical(); |
| 1556 | 1721 | $handler->setSupportedFields('GroupDAV',$this->agent); |
| 1557 | 1722 | $handler->supportedFields['attachments'] = true; // enabling attachments |
| 1558 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
| 1723 | + if ($this->debug > 1) |
|
| 1724 | + { |
|
| 1725 | + error_log("ical Handler called: " . $this->agent); |
|
| 1726 | + } |
|
| 1559 | 1727 | return $handler; |
| 1560 | 1728 | } |
| 1561 | 1729 | |
@@ -1626,7 +1794,11 @@ discard block |
||
| 1626 | 1794 | { |
| 1627 | 1795 | $calendars[$entry['grantor']] = $entry['name']; |
| 1628 | 1796 | } |
| 1629 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
| 1797 | + if ($user > 0) |
|
| 1798 | + { |
|
| 1799 | + unset($calendars[$user]); |
|
| 1800 | + } |
|
| 1801 | + // skip current user |
|
| 1630 | 1802 | } |
| 1631 | 1803 | |
| 1632 | 1804 | $settings = array(); |