Completed
Push — 16.1 ( f8fa80...82e10b )
by Ralf
32:17 queued 16:35
created
calendar/inc/class.calendar_groupdav.inc.php 2 patches
Braces   +229 added lines, -57 removed lines patch added patch discarded remove patch
@@ -120,7 +120,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param string $id =''
142 142
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
143 143
 	 */
144
-	function propfind($path,&$options,&$files,$user,$id='')
144
+	function propfind($path, &$options, &$files, $user, $id = '')
145 145
 	{
146 146
 		if ($this->debug)
147 147
 		{
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 			'enum_recuring' => false,
168 168
 			'daywise' => false,
169 169
 			'date_format' => 'server',
170
-			'no_total' => true,	// we need no total number of rows (saves extra query)
171
-			'cfs' => array(),	// return custom-fields, as we use them to store X- attributes
170
+			'no_total' => true, // we need no total number of rows (saves extra query)
171
+			'cfs' => array(), // return custom-fields, as we use them to store X- attributes
172 172
 		);
173
-		foreach(array(
173
+		foreach (array(
174 174
 			'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'],
175 175
 			'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'],
176 176
 		) as $name => $value)
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			{
180 180
 				$value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT;
181 181
 			}
182
-			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
182
+			$filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value);
183 183
 		}
184 184
 		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
185 185
 		{
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 			$filter['filter'] = 'owner';
192 192
 		}
193 193
 		// scheduling inbox, shows only not yet accepted or rejected events
194
-		elseif (substr($path,-7) == '/inbox/')
194
+		elseif (substr($path, -7) == '/inbox/')
195 195
 		{
196 196
 			$filter['filter'] = 'unknown';
197
-			$filter['start'] = $this->bo->now;	// only return future invitations
197
+			$filter['start'] = $this->bo->now; // only return future invitations
198 198
 		}
199 199
 		// ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now
200
-		elseif (substr($path,-8) == '/outbox/')
200
+		elseif (substr($path, -8) == '/outbox/')
201 201
 		{
202 202
 			return true;
203 203
 		}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			// when trying to request not supported components, eg. VTODO on a calendar collection
215 215
 			return true;
216 216
 		}
217
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
217
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
218 218
 
219 219
 		if ($this->debug > 1)
220 220
 		{
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 			$this->sync_collection_token = null;
233 233
 
234
-			$filter['order'] = 'cal_modified ASC';	// return oldest modifications first
234
+			$filter['order'] = 'cal_modified ASC'; // return oldest modifications first
235 235
 			$filter['sync-collection'] = true;
236 236
 			// no end-date / limit into the future, as unchanged entries would never be transferted later on
237 237
 			unset($filter['end']);
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 		if (isset($nresults))
241 241
 		{
242
-			unset($filter['no_total']);	// we need the total!
242
+			unset($filter['no_total']); // we need the total!
243 243
 			$files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults));
244 244
 
245 245
 			// hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first)
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
249 249
 			{
250 250
 				--$this->sync_collection_token;
251
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
251
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
252 252
 			}
253 253
 		}
254 254
 		else
255 255
 		{
256 256
 			// return iterator, calling ourself to return result in chunks
257
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
257
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
258 258
 		}
259 259
 		if (isset($_GET['download']))
260 260
 		{
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 		Api\Header\Content::type('calendar.ics', 'text/calendar');
275 275
 
276 276
 		$n = 0;
277
-		foreach($files as $file)
277
+		foreach ($files as $file)
278 278
 		{
279
-			if (!$n++) continue;	// first entry is collection itself
279
+			if (!$n++) continue; // first entry is collection itself
280 280
 
281 281
 			$icalendar = $file['props']['calendar-data']['val'];
282 282
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 						echo substr($icalendar, 0, $start);
301 301
 					}
302 302
 				}
303
-				echo substr($icalendar, $start, $end-$start);
303
+				echo substr($icalendar, $start, $end - $start);
304 304
 			}
305 305
 		}
306 306
 		if ($icalendar && $end)
@@ -318,12 +318,12 @@  discard block
 block discarded – undo
318 318
 	 * @param array|boolean $start =false false=return all or array(start,num)
319 319
 	 * @return array with "files" array with values for keys path and props
320 320
 	 */
321
-	function &propfind_callback($path,array $filter,$start=false)
321
+	function &propfind_callback($path, array $filter, $start = false)
322 322
 	{
323 323
 		if ($this->debug) $starttime = microtime(true);
324 324
 
325 325
 		$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
326
+		if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex
327 327
 
328 328
 		$files = array();
329 329
 
@@ -335,11 +335,11 @@  discard block
 block discarded – undo
335 335
 		$requested_multiget_ids = (array)$filter['query'][self::$path_attr];
336 336
 		$sync_collection = $filter['sync-collection'];
337 337
 
338
-		$events =& $this->bo->search($filter);
338
+		$events = & $this->bo->search($filter);
339 339
 
340 340
 		if ($events)
341 341
 		{
342
-			foreach($events as $event)
342
+			foreach ($events as $event)
343 343
 			{
344 344
 				// remove event from requested multiget ids, to be able to report not found urls
345 345
 				if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 					unset($requested_multiget_ids[$k]);
348 348
 				}
349 349
 				// sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations
350
-				if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R','X'))))
350
+				if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R', 'X'))))
351 351
 				{
352 352
 					$files[] = array('path' => $path.urldecode($this->get_path($event)));
353 353
 					continue;
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 						!isset($calendar_data['children']['expand']) ? false :
379 379
 							($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
380 380
 					$props['getcontentlength'] = bytes($content);
381
-					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
381
+					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
382 382
 				}
383 383
 				/* Calendarserver reports new events with schedule-changes: action: create, which iCal request
384 384
 				 * adding it, unfortunately does not lead to showing the new event in the users inbox
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 		// report not found multiget urls
398 398
 		if ($requested_multiget_ids)
399 399
 		{
400
-			foreach($requested_multiget_ids as $id)
400
+			foreach ($requested_multiget_ids as $id)
401 401
 			{
402 402
 				$files[] = array('path' => $path.$id.self::$path_extension);
403 403
 			}
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	private function _created_updated_by_prop($user, $time)
434 434
 	{
435 435
 		$props = array();
436
-		foreach(array(
436
+		foreach (array(
437 437
 			'first-name' => 'account_firstname',
438 438
 			'last-name' => 'account_lastname',
439 439
 			'href' => 'account_email',
@@ -476,23 +476,23 @@  discard block
 block discarded – undo
476 476
 			$cal_end = $cal_filters['end']; unset($cal_filters['end']);
477 477
 			$num_filters = count($cal_filters);
478 478
 
479
-			foreach($options['filters'] as $filter)
479
+			foreach ($options['filters'] as $filter)
480 480
 			{
481
-				switch($filter['name'])
481
+				switch ($filter['name'])
482 482
 				{
483 483
 					case 'comp-filter':
484 484
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
485 485
 
486
-						switch($filter['attrs']['name'])
486
+						switch ($filter['attrs']['name'])
487 487
 						{
488 488
 							case 'VTODO':
489
-								return false;	// return nothing for now, todo: check if we can pass it on to the infolog handler
489
+								return false; // return nothing for now, todo: check if we can pass it on to the infolog handler
490 490
 								// todos are handled by the infolog handler
491 491
 								//$infolog_handler = new groupdav_infolog();
492 492
 								//return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method);
493 493
 							case 'VCALENDAR':
494 494
 							case 'VEVENT':
495
-								break;			// that's our default anyway
495
+								break; // that's our default anyway
496 496
 						}
497 497
 						break;
498 498
 					case 'prop-filter':
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
 						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
516 516
 						break;
517 517
 					case 'time-range':
518
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
518
+				 		if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
519 519
 				 		if (!empty($filter['attrs']['start']))
520 520
 				 		{
521 521
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
522 522
 				 		}
523 523
 				 		if (!empty($filter['attrs']['end']))
524 524
 				 		{
525
-					 		$cal_filters['end']   = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
525
+					 		$cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
526 526
 				 		}
527 527
 						break;
528 528
 					default:
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 		    <B:nresults>10</B:nresults>
544 544
 		  </B:limit>
545 545
 		*/
546
-		foreach((array)$options['other'] as $option)
546
+		foreach ((array)$options['other'] as $option)
547 547
 		{
548
-			switch($option['name'])
548
+			switch ($option['name'])
549 549
 			{
550 550
 				case 'nresults':
551 551
 					$nresults = (int)$option['data'];
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				case 'limit':
555 555
 					break;
556 556
 				case 'href':
557
-					break;	// from addressbook-multiget, handled below
557
+					break; // from addressbook-multiget, handled below
558 558
 				// rfc 6578 sync-report
559 559
 				case 'sync-token':
560 560
 					if (!empty($option['data']))
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 						$parts = explode('/', $option['data']);
563 563
 						$sync_token = array_pop($parts);
564 564
 						$cal_filters['query'][] = 'cal_modified>'.(int)$sync_token;
565
-						$cal_filters['filter'] = 'everything';	// to return deleted entries too
565
+						$cal_filters['filter'] = 'everything'; // to return deleted entries too
566 566
 						// no standard time-range!
567 567
 						unset($cal_filters['start']);
568 568
 					}
@@ -591,25 +591,25 @@  discard block
 block discarded – undo
591 591
 			if ($id)
592 592
 			{
593 593
 				$cal_filters['query'][self::$path_attr] = self::$path_extension ?
594
-					basename($id,self::$path_extension) : $id;
594
+					basename($id, self::$path_extension) : $id;
595 595
 			}
596 596
 			else	// fetch all given url's
597 597
 			{
598
-				foreach($options['other'] as $option)
598
+				foreach ($options['other'] as $option)
599 599
 				{
600 600
 					if ($option['name'] == 'href')
601 601
 					{
602
-						$parts = explode('/',$option['data']);
602
+						$parts = explode('/', $option['data']);
603 603
 						if (($id = urldecode(array_pop($parts))))
604 604
 						{
605 605
 							$cal_filters['query'][self::$path_attr][] = self::$path_extension ?
606
-								basename($id,self::$path_extension) : $id;
606
+								basename($id, self::$path_extension) : $id;
607 607
 						}
608 608
 					}
609 609
 				}
610 610
 			}
611 611
 
612
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
612
+			if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters));
613 613
 		}
614 614
 		return true;
615 615
 	}
@@ -622,9 +622,9 @@  discard block
 block discarded – undo
622 622
 	 * @param int $user =null account_id
623 623
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
624 624
 	 */
625
-	function get(&$options,$id,$user=null)
625
+	function get(&$options, $id, $user = null)
626 626
 	{
627
-		if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id)))
627
+		if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id)))
628 628
 		{
629 629
 			return $event;
630 630
 		}
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences
653 653
 	 * @return string
654 654
 	 */
655
-	private function iCal(array $event,$user=null, $method=null, $expand=false)
655
+	private function iCal(array $event, $user = null, $method = null, $expand = false)
656 656
 	{
657 657
 		static $handler = null;
658 658
 		if (is_null($handler)) $handler = $this->_get_handler();
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
 				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
677 677
 				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
678 678
 			}
679
-			$events =& self::get_series($event['uid'], $this->bo, $expand, $user);
679
+			$events = & self::get_series($event['uid'], $this->bo, $expand, $user);
680 680
 			// as alarm is now only on next recurrence, set alarm from original event on master
681 681
 			if ($event['alarm']) $events[0]['alarm'] = $event['alarm'];
682 682
 		}
683
-		elseif(!$this->client_shared_uid_exceptions && $event['reference'])
683
+		elseif (!$this->client_shared_uid_exceptions && $event['reference'])
684 684
 		{
685
-			$events[0]['uid'] .= '-'.$event['id'];	// force a different uid
685
+			$events[0]['uid'] .= '-'.$event['id']; // force a different uid
686 686
 		}
687 687
 		return $handler->exportVCal($events, '2.0', $method);
688 688
 	}
@@ -698,20 +698,20 @@  discard block
 block discarded – undo
698 698
 	 * @param int $user =null account_id of calendar to display, to remove master, if current user does not participate in
699 699
 	 * @return array
700 700
 	 */
701
-	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null)
701
+	private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null)
702 702
 	{
703 703
 		if (is_null($bo)) $bo = new calendar_bopdate();
704 704
 
705 705
 		$params = array(
706 706
 			'query' => array('cal_uid' => $uid),
707
-			'filter' => 'owner',  // return all possible entries
707
+			'filter' => 'owner', // return all possible entries
708 708
 			'daywise' => false,
709 709
 			'date_format' => 'server',
710
-			'cfs' => array(),	// read cfs as we use them to store X- attributes
710
+			'cfs' => array(), // read cfs as we use them to store X- attributes
711 711
 		);
712 712
 		if (is_array($expand)) $params += $expand;
713 713
 
714
-		if (!($events =& $bo->search($params)))
714
+		if (!($events = & $bo->search($params)))
715 715
 		{
716 716
 			return array();
717 717
 		}
@@ -719,12 +719,12 @@  discard block
 block discarded – undo
719 719
 		// find master, which is not always first event, eg. when first event is an exception
720 720
 		$master = null;
721 721
 		$exceptions = array();
722
-		foreach($events as $k => &$recurrence)
722
+		foreach ($events as $k => &$recurrence)
723 723
 		{
724 724
 			if ($recurrence['recur_type'])
725 725
 			{
726 726
 				$master = $recurrence;
727
-				$exceptions =& $master['recur_exception'];
727
+				$exceptions = & $master['recur_exception'];
728 728
 				unset($events[$k]);
729 729
 				break;
730 730
 			}
@@ -732,13 +732,13 @@  discard block
 block discarded – undo
732 732
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
733 733
 		if (!isset($master)) $master = $bo->read($uid);
734 734
 
735
-		foreach($events as $k => &$recurrence)
735
+		foreach ($events as $k => &$recurrence)
736 736
 		{
737 737
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
738 738
 			if ($master && $recurrence['reference'] != $master['id'])
739 739
 			{
740 740
 				unset($events[$k]);
741
-				continue;	// same uid, but references a different event or is own master
741
+				continue; // same uid, but references a different event or is own master
742 742
 			}
743 743
 			if (!$master || $recurrence['id'] != $master['id'])	// real exception
744 744
 			{
@@ -759,11 +759,11 @@  discard block
 block discarded – undo
759 759
 				// at least Lightning "understands" EXDATE as exception from what's included
760 760
 				// in the whole resource / VCALENDAR component
761 761
 				// not removing it causes Lightning to remove the exception itself
762
-				if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false)
762
+				if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false)
763 763
 				{
764 764
 					unset($exceptions[$e]);
765 765
 				}
766
-				continue;	// nothing to change
766
+				continue; // nothing to change
767 767
 			}
768 768
 			// add alarms from master to recurrences, as clients otherwise have no alarms on virtual exceptions
769 769
 			if ($master && $master['alarm'])
@@ -774,14 +774,14 @@  discard block
 block discarded – undo
774 774
 			if (!$expand && $master && $master['participants'] == $recurrence['participants'])
775 775
 			{
776 776
 				//error_log('NO exception: '.array2string($recurrence));
777
-				unset($events[$k]);	// no exception --> remove it
777
+				unset($events[$k]); // no exception --> remove it
778 778
 				continue;
779 779
 			}
780 780
 			// this is a virtual exception now (no extra event/cal_id in DB)
781 781
 			//error_log('virtual exception: '.array2string($recurrence));
782 782
 			$recurrence['recurrence'] = $recurrence['start'];
783 783
 			if ($master) $recurrence['reference'] = $master['id'];
784
-			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
784
+			$recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master
785 785
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
786 786
 		}
787 787
 		// only add master if we are not expanding and current user participates in master (and not just some exceptions)
@@ -815,23 +815,23 @@  discard block
 block discarded – undo
815 815
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
816 816
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
817 817
 	 */
818
-	function put(&$options,$id,$user=null,$prefix=null)
818
+	function put(&$options, $id, $user = null, $prefix = null)
819 819
 	{
820
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
820
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
821 821
 
822
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
822
+		if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway)
823 823
 
824 824
 		// fix for iCal4OL using WinHTTP only supporting a certain header length
825 825
 		if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
826 826
 		{
827 827
 			$_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE'];
828 828
 		}
829
-		$return_no_access = true;	// as handled by importVCal anyway and allows it to set the status for participants
830
-		$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access,
831
-			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
829
+		$return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants
830
+		$oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access,
831
+			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case
832 832
 		if (!is_null($oldEvent) && !is_array($oldEvent))
833 833
 		{
834
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
834
+			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace());
835 835
 			return $oldEvent;
836 836
 		}
837 837
 
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 					switch (strtolower($key))
863 863
 					{
864 864
 						case 'charset':
865
-							$charset = strtoupper(substr($value,1,-1));
865
+							$charset = strtoupper(substr($value, 1, -1));
866 866
 					}
867 867
 				}
868 868
 			}
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 				if (($events = $handler->icaltoegw($vCalendar)))
919 919
 				{
920 920
 					$modified = 0;
921
-					foreach($events as $n => $event)
921
+					foreach ($events as $n => $event)
922 922
 					{
923 923
 						// for recurrances of event series, we need to read correct recurrence (or if series master is no first event)
924 924
 						if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series))
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 								$series = self::get_series($event['uid'], $this->bo);
930 930
 								//foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent));
931 931
 							}
932
-							foreach($series as $oldEvent)
932
+							foreach ($series as $oldEvent)
933 933
 							{
934 934
 								if ($oldEvent['recurrence'] == $event['recurrence']) break;
935 935
 							}
@@ -994,9 +994,9 @@  discard block
 block discarded – undo
994 994
 					isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']]))
995 995
 				{
996 996
 					// just update etag in database
997
-					$GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array(
997
+					$GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array(
998 998
 						'cal_id' => $eventId,
999
-					),__LINE__,__FILE__,'calendar');
999
+					), __LINE__, __FILE__, 'calendar');
1000 1000
 				}
1001 1001
 			}
1002 1002
 		}
@@ -1043,9 +1043,9 @@  discard block
 block discarded – undo
1043 1043
 	 * @param int $user =null account_id of owner, default null
1044 1044
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1045 1045
 	 */
1046
-	function post(&$options,$id,$user=null)
1046
+	function post(&$options, $id, $user = null)
1047 1047
 	{
1048
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1048
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
1049 1049
 
1050 1050
 		$vCalendar = htmlspecialchars_decode($options['content']);
1051 1051
 		$charset = null;
@@ -1062,13 +1062,13 @@  discard block
 block discarded – undo
1062 1062
 					switch (strtolower($key))
1063 1063
 					{
1064 1064
 						case 'charset':
1065
-							$charset = strtoupper(substr($value,1,-1));
1065
+							$charset = strtoupper(substr($value, 1, -1));
1066 1066
 					}
1067 1067
 				}
1068 1068
 			}
1069 1069
 		}
1070 1070
 
1071
-		if (substr($options['path'],-8) == '/outbox/')
1071
+		if (substr($options['path'], -8) == '/outbox/')
1072 1072
 		{
1073 1073
 			if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar))
1074 1074
 			{
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	 */
1120 1120
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1121 1121
 	{
1122
-		unset($options);	// not used, but required by function signature
1122
+		unset($options); // not used, but required by function signature
1123 1123
 
1124 1124
 		$vcal = new Horde_Icalendar();
1125 1125
 		if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset))
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 
1133 1133
 		$handler = $this->_get_handler();
1134 1134
 		$handler->setSupportedFields('groupdav');
1135
-		$handler->calendarOwner = $handler->user = 0;	// to NOT default owner/organizer to something
1135
+		$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
1136 1136
 		if (!($component = $vcal->getComponent(0)) ||
1137 1137
 			!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
1138 1138
 		{
@@ -1157,13 +1157,13 @@  discard block
 block discarded – undo
1157 1157
 		$xml->startDocument('1.0', 'UTF-8');
1158 1158
 		$xml->startElementNs('C', 'schedule-response', Api\CalDAV::CALDAV);
1159 1159
 
1160
-		foreach(array_keys($event['participants']) as $uid)
1160
+		foreach (array_keys($event['participants']) as $uid)
1161 1161
 		{
1162 1162
 			$xml->startElementNs('C', 'response', null);
1163 1163
 
1164 1164
 			$xml->startElementNs('C', 'recipient', null);
1165
-			$xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees));
1166
-			$xml->endElement();	// recipient
1165
+			$xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees));
1166
+			$xml->endElement(); // recipient
1167 1167
 
1168 1168
 			$xml->writeElementNs('C', 'request-status', null, '2.0;Success');
1169 1169
 			$xml->writeElementNs('C', 'calendar-data', null,
@@ -1171,13 +1171,13 @@  discard block
 block discarded – undo
1171 1171
 					'UID' => $event['uid'],
1172 1172
 					'ORGANIZER' => $organizer,
1173 1173
 					'ATTENDEE' => $attendee,
1174
-				)+(empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1174
+				) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1175 1175
 					'X-CALENDARSERVER-MASK-UID' => $mask_uid,
1176 1176
 				))));
1177 1177
 
1178
-			$xml->endElement();	// response
1178
+			$xml->endElement(); // response
1179 1179
 		}
1180
-		$xml->endElement();	// schedule-response
1180
+		$xml->endElement(); // schedule-response
1181 1181
 		$xml->endDocument();
1182 1182
 		echo $xml->outputMemory();
1183 1183
 
@@ -1192,14 +1192,14 @@  discard block
 block discarded – undo
1192 1192
 	 * @param int $user account_id
1193 1193
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1194 1194
 	 */
1195
-	function free_busy_report($path,$options,$user)
1195
+	function free_busy_report($path, $options, $user)
1196 1196
 	{
1197
-		unset($path);	// unused, but required by function signature
1197
+		unset($path); // unused, but required by function signature
1198 1198
 		if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
1199 1199
 		{
1200 1200
 			return '403 Forbidden';
1201 1201
 		}
1202
-		foreach($options['other'] as $filter)
1202
+		foreach ($options['other'] as $filter)
1203 1203
 		{
1204 1204
 			if ($filter['name'] == 'time-range')
1205 1205
 			{
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 		header('Content-Type: text/calendar');
1212 1212
 		echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
1213 1213
 
1214
-		exit();	// otherwise we get a 207 multistatus, not 200 Ok
1214
+		exit(); // otherwise we get a 207 multistatus, not 200 Ok
1215 1215
 	}
1216 1216
 
1217 1217
 	/**
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 	 * @param int $user =null owner of the collection, default current user
1224 1224
 	 * @return array with privileges
1225 1225
 	 */
1226
-	public function current_user_privileges($path, $user=null)
1226
+	public function current_user_privileges($path, $user = null)
1227 1227
 	{
1228 1228
 		$privileges = parent::current_user_privileges($path, $user);
1229 1229
 		//error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges));
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 
1267 1267
 		// get array with orginal recurrences indexed by recurrence-id
1268 1268
 		$org_recurrences = $exceptions = array();
1269
-		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1269
+		foreach (self::get_series($events[0]['uid'], $bo) as $k => $event)
1270 1270
 		{
1271 1271
 			if (!$k) $master = $event;
1272 1272
 			if ($event['recurrence'])
@@ -1276,13 +1276,13 @@  discard block
 block discarded – undo
1276 1276
 		}
1277 1277
 
1278 1278
 		// assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master
1279
-		foreach($events as $k => &$recurrence)
1279
+		foreach ($events as $k => &$recurrence)
1280 1280
 		{
1281 1281
 			if (!$recurrence['recurrence'])
1282 1282
 			{
1283 1283
 				// master
1284 1284
 				$recurrence['id'] = $master['id'];
1285
-				$master =& $events[$k];
1285
+				$master = & $events[$k];
1286 1286
 				continue;
1287 1287
 			}
1288 1288
 
@@ -1306,12 +1306,12 @@  discard block
 block discarded – undo
1306 1306
 		$master['recur_exception'] = array_merge($exceptions, $master['recur_exception']);
1307 1307
 
1308 1308
 		// delete not longer existing recurrences
1309
-		foreach($org_recurrences as $org_recurrence)
1309
+		foreach ($org_recurrences as $org_recurrence)
1310 1310
 		{
1311 1311
 			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1312 1312
 			{
1313 1313
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1314
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1314
+				$bo->delete($org_recurrence['id']); // might fail because of permissions
1315 1315
 			}
1316 1316
 			else	// virtual recurrence
1317 1317
 			{
@@ -1332,25 +1332,25 @@  discard block
 block discarded – undo
1332 1332
 	 * @param int $id
1333 1333
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1334 1334
 	 */
1335
-	function delete(&$options,$id)
1335
+	function delete(&$options, $id)
1336 1336
 	{
1337 1337
 		if (strpos($options['path'], '/inbox/') !== false)
1338 1338
 		{
1339
-			return true;	// simply ignore DELETE in inbox for now
1339
+			return true; // simply ignore DELETE in inbox for now
1340 1340
 		}
1341
-		$return_no_access = true;	// to allow to check if current use is a participant and reject the event for him
1342
-		if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access)
1341
+		$return_no_access = true; // to allow to check if current use is a participant and reject the event for him
1342
+		if (!is_array($event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access)) || !$return_no_access)
1343 1343
 		{
1344 1344
  			if (!$return_no_access)
1345 1345
 			{
1346 1346
 				// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1347 1347
 				$ret = '403 Forbidden';
1348 1348
 				$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
1349
-				foreach(array_keys($event['participants']) as $uid)
1349
+				foreach (array_keys($event['participants']) as $uid)
1350 1350
 				{
1351 1351
 					if ($this->bo->user == $uid || in_array($uid, $memberships))
1352 1352
 					{
1353
-						$this->bo->set_status($event,$this->bo->user, 'R');
1353
+						$this->bo->set_status($event, $this->bo->user, 'R');
1354 1354
 						$ret = true;
1355 1355
 						break;
1356 1356
 					}
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 		{
1366 1366
 			$ret = $this->bo->delete($event['id']);
1367 1367
 		}
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));
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));
1369 1369
 		return $ret;
1370 1370
 	}
1371 1371
 
@@ -1380,12 +1380,12 @@  discard block
 block discarded – undo
1380 1380
 	 */
1381 1381
 	function read($id)
1382 1382
 	{
1383
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1383
+		if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column;
1384 1384
 
1385 1385
 		$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!
1386
+		if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
1387 1387
 
1388
-		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1388
+		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server')) &&
1389 1389
 			// above can be true, if current user is not in master but just a recurrence
1390 1390
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1391 1391
 		{
@@ -1421,11 +1421,11 @@  discard block
 block discarded – undo
1421 1421
 	 *
1422 1422
 	 * @return string
1423 1423
 	 */
1424
-	public function getctag($path,$user)
1424
+	public function getctag($path, $user)
1425 1425
 	{
1426
-		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1426
+		$ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1427 1427
 
1428
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1428
+		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag");
1429 1429
 
1430 1430
 		return $ctag;
1431 1431
 	}
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 	 * @param string $schedule_tag =null on return schedule-tag
1438 1438
 	 * @return string|boolean string with etag or false
1439 1439
 	 */
1440
-	function get_etag($entry, &$schedule_tag=null)
1440
+	function get_etag($entry, &$schedule_tag = null)
1441 1441
 	{
1442 1442
 		$etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions);
1443 1443
 
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 	 * @param int|string $retval
1456 1456
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1457 1457
 	 */
1458
-	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
1458
+	function put_response_headers($entry, $path, $retval, $path_attr_is_name = true)
1459 1459
 	{
1460 1460
 		$schedule_tag = null;
1461 1461
 		$etag = $this->get_etag($entry, $schedule_tag);
@@ -1474,14 +1474,14 @@  discard block
 block discarded – undo
1474 1474
 	 * @param array|int $event event-array or id
1475 1475
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1476 1476
 	 */
1477
-	function check_access($acl,$event)
1477
+	function check_access($acl, $event)
1478 1478
 	{
1479 1479
 		if ($acl == Acl::READ)
1480 1480
 		{
1481 1481
 			// we need at least calendar_bo::ACL_FREEBUSY to get some information
1482 1482
 			$acl = calendar_bo::ACL_FREEBUSY;
1483 1483
 		}
1484
-		return $this->bo->check_perms($acl,$event,0,'server');
1484
+		return $this->bo->check_perms($acl, $event, 0, 'server');
1485 1485
 	}
1486 1486
 
1487 1487
 	/**
@@ -1494,53 +1494,53 @@  discard block
 block discarded – undo
1494 1494
 	 * @param string $path =null path of the collection
1495 1495
 	 * @return array
1496 1496
 	 */
1497
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null)
1497
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null)
1498 1498
 	{
1499
-		unset($base_uri);	// unused, but required by function signature
1499
+		unset($base_uri); // unused, but required by function signature
1500 1500
 		if (!isset($props['calendar-description']))
1501 1501
 		{
1502 1502
 			// default calendar description: can be overwritten via PROPPATCH, in which case it's already set
1503
-			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
1503
+			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
1504 1504
 		}
1505 1505
 		$supported_components = array(
1506
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')),
1507
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')),
1506
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')),
1507
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VEVENT')),
1508 1508
 		);
1509 1509
 		// outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations
1510
-		if (substr($path,-8) == '/outbox/')
1510
+		if (substr($path, -8) == '/outbox/')
1511 1511
 		{
1512
-			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY'));
1512
+			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VFREEBUSY'));
1513 1513
 		}
1514 1514
 		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,
1515
-			'supported-calendar-component-set',$supported_components);
1515
+			'supported-calendar-component-set', $supported_components);
1516 1516
 		// supported reports
1517 1517
 		$props['supported-report-set'] = array(
1518
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
1519
-				Api\CalDAV::mkprop('report',array(
1520
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
1521
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
1522
-				Api\CalDAV::mkprop('report',array(
1523
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
1524
-			'free-busy-query' => Api\CalDAV::mkprop('supported-report',array(
1525
-				Api\CalDAV::mkprop('report',array(
1526
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))),
1518
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
1519
+				Api\CalDAV::mkprop('report', array(
1520
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
1521
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
1522
+				Api\CalDAV::mkprop('report', array(
1523
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
1524
+			'free-busy-query' => Api\CalDAV::mkprop('supported-report', array(
1525
+				Api\CalDAV::mkprop('report', array(
1526
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'free-busy-query', ''))))),
1527 1527
 		);
1528 1528
 		// rfc 6578 sync-collection report for everything but outbox
1529 1529
 		// only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
1530 1530
 		if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history'])
1531 1531
 		{
1532
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
1533
-				Api\CalDAV::mkprop('report',array(
1534
-					Api\CalDAV::mkprop('sync-collection','')))));
1532
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
1533
+				Api\CalDAV::mkprop('report', array(
1534
+					Api\CalDAV::mkprop('sync-collection', '')))));
1535 1535
 		}
1536
-		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array(
1537
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1538
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1536
+		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-data', array(
1537
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1538
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1539 1539
 
1540 1540
 		// get timezone of calendar
1541 1541
 		if ($this->caldav->prop_requested('calendar-timezone'))
1542 1542
 		{
1543
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
1543
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
1544 1544
 				calendar_timezones::user_timezone($user));
1545 1545
 		}
1546 1546
 		return $props;
@@ -1554,9 +1554,9 @@  discard block
 block discarded – undo
1554 1554
 	private function _get_handler()
1555 1555
 	{
1556 1556
 		$handler = new calendar_ical();
1557
-		$handler->setSupportedFields('GroupDAV',$this->agent);
1558
-		$handler->supportedFields['attachments'] = true;	// enabling attachments
1559
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1557
+		$handler->setSupportedFields('GroupDAV', $this->agent);
1558
+		$handler->supportedFields['attachments'] = true; // enabling attachments
1559
+		if ($this->debug > 1) error_log("ical Handler called: ".$this->agent);
1560 1560
 		return $handler;
1561 1561
 	}
1562 1562
 
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 		$pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set'];
1572 1572
 		$calendar_home_set = $pref ? explode(',', $pref) : array();
1573 1573
 		// replace symbolic id's with real nummeric id's
1574
-		foreach(array(
1574
+		foreach (array(
1575 1575
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1576 1576
 		) as $sym => $id)
1577 1577
 		{
@@ -1580,11 +1580,11 @@  discard block
 block discarded – undo
1580 1580
 				$calendar_home_set[$key] = $id;
1581 1581
 			}
1582 1582
 		}
1583
-		foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1583
+		foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1584 1584
 		{
1585 1585
 			$id = $entry['grantor'];
1586
-			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user
1587
-				(in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) &&
1586
+			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user
1587
+				(in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) &&
1588 1588
 				is_numeric($id) && ($owner = $this->accounts->id2name($id)))
1589 1589
 			{
1590 1590
 				$shared[$id] = 'calendar-'.$owner;
@@ -1593,11 +1593,11 @@  discard block
 block discarded – undo
1593 1593
 		// shared locations and resources
1594 1594
 		if ($GLOBALS['egw_info']['user']['apps']['resources'])
1595 1595
 		{
1596
-			foreach(array('locations','resources') as $res)
1596
+			foreach (array('locations', 'resources') as $res)
1597 1597
 			{
1598 1598
 				if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res]))
1599 1599
 				{
1600
-					foreach(explode(',', $pref) as $res_id)
1600
+					foreach (explode(',', $pref) as $res_id)
1601 1601
 					{
1602 1602
 						$is_location = $res == 'locations';
1603 1603
 						$shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location));
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 			{
1628 1628
 				$calendars[$entry['grantor']] = $entry['name'];
1629 1629
 			}
1630
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1630
+			if ($user > 0) unset($calendars[$user]); // skip current user
1631 1631
 		}
1632 1632
 
1633 1633
 		$settings = array();
@@ -1635,7 +1635,7 @@  discard block
 block discarded – undo
1635 1635
 			'type'   => 'multiselect',
1636 1636
 			'label'  => 'Calendars to sync in addition to personal calendar',
1637 1637
 			'name'   => 'calendar-home-set',
1638
-			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1638
+			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1639 1639
 			'values' => $calendars,
1640 1640
 			'xmlrpc' => True,
1641 1641
 			'admin'  => False,
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 		if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = Api\CalDAV\Principals::get_resources()))
1662 1662
 		{
1663 1663
 			$resources = $locations = array();
1664
-			foreach($all_resources as $resource)
1664
+			foreach ($all_resources as $resource)
1665 1665
 			{
1666 1666
 				if (Api\CalDAV\Principals::resource_is_location($resource))
1667 1667
 				{
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 					$resources[$resource['res_id']] = $resource['name'];
1673 1673
 				}
1674 1674
 			}
1675
-			foreach(array(
1675
+			foreach (array(
1676 1676
 				'locations' => $locations,
1677 1677
 				'resources' => $resources,
1678 1678
 			) as $name => $options)
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
 						'label'  => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')),
1686 1686
 						'no_lang'=> true,
1687 1687
 						'name'   => 'calendar-home-set-'.$name,
1688
-						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CalDAV "calendar-home-set"'),
1688
+						'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likly not be suppored!').'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CalDAV "calendar-home-set"'),
1689 1689
 						'values' => $options,
1690 1690
 						'xmlrpc' => True,
1691 1691
 						'admin'  => False,
Please login to merge, or discard this patch.