Test Setup Failed
Push — master ( 44d9fc...476d4b )
by Ralf
20:38
created
calendar/inc/class.calendar_groupdav.inc.php 2 patches
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $id =''
154 154
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
155 155
 	 */
156
-	function propfind($path,&$options,&$files,$user,$id='')
156
+	function propfind($path, &$options, &$files, $user, $id = '')
157 157
 	{
158 158
 		if ($this->debug)
159 159
 		{
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 			'enum_recuring' => false,
180 180
 			'daywise' => false,
181 181
 			'date_format' => 'server',
182
-			'no_total' => true,	// we need no total number of rows (saves extra query)
183
-			'cfs' => array(),	// return custom-fields, as we use them to store X- attributes
182
+			'no_total' => true, // we need no total number of rows (saves extra query)
183
+			'cfs' => array(), // return custom-fields, as we use them to store X- attributes
184 184
 		);
185
-		foreach(array(
185
+		foreach (array(
186 186
 			'start' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-past-limit'],
187 187
 			'end' => $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-future-limit'],
188 188
 		) as $name => $value)
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 			{
192 192
 				$value = $name == 'start' ? self::PAST_LIMIT : self::FUTURE_LIMIT;
193 193
 			}
194
-			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
194
+			$filter[$name] = $this->bo->now + 24 * 3600 * ($name == 'start' ? -1 : 1) * abs($value);
195 195
 		}
196 196
 		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
197 197
 		{
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 			$filter['filter'] = 'owner';
204 204
 		}
205 205
 		// scheduling inbox, shows only not yet accepted or rejected events
206
-		elseif (substr($path,-7) == '/inbox/')
206
+		elseif (substr($path, -7) == '/inbox/')
207 207
 		{
208 208
 			$filter['filter'] = 'unknown';
209
-			$filter['start'] = $this->bo->now;	// only return future invitations
209
+			$filter['start'] = $this->bo->now; // only return future invitations
210 210
 		}
211 211
 		// ToDo: not sure what scheduling outbox is supposed to show, leave it empty for now
212
-		elseif (substr($path,-8) == '/outbox/')
212
+		elseif (substr($path, -8) == '/outbox/')
213 213
 		{
214 214
 			return true;
215 215
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 			// when trying to request not supported components, eg. VTODO on a calendar collection
227 227
 			return true;
228 228
 		}
229
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
229
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
230 230
 
231 231
 		if ($this->debug > 1)
232 232
 		{
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 			$this->sync_collection_token = null;
245 245
 
246
-			$filter['order'] = 'cal_modified ASC';	// return oldest modifications first
246
+			$filter['order'] = 'cal_modified ASC'; // return oldest modifications first
247 247
 			$filter['sync-collection'] = true;
248 248
 			// no end-date / limit into the future, as unchanged entries would never be transferted later on
249 249
 			unset($filter['end']);
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 
252 252
 		if (isset($nresults))
253 253
 		{
254
-			unset($filter['no_total']);	// we need the total!
254
+			unset($filter['no_total']); // we need the total!
255 255
 			$files['files'] = $this->propfind_callback($path, $filter, array(0, (int)$nresults));
256 256
 
257 257
 			// hack to support limit with sync-collection report: events are returned in modified ASC order (oldest first)
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
261 261
 			{
262 262
 				--$this->sync_collection_token;
263
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
263
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
264 264
 			}
265 265
 		}
266 266
 		else
267 267
 		{
268 268
 			// return iterator, calling ourself to return result in chunks
269
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
269
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
270 270
 		}
271 271
 		if (isset($_GET['download']))
272 272
 		{
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
 		Api\Header\Content::type('calendar.ics', 'text/calendar');
287 287
 
288 288
 		$n = 0;
289
-		foreach($files as $file)
289
+		foreach ($files as $file)
290 290
 		{
291
-			if (!$n++) continue;	// first entry is collection itself
291
+			if (!$n++) continue; // first entry is collection itself
292 292
 
293 293
 			$icalendar = $file['props']['calendar-data']['val'];
294 294
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 						echo substr($icalendar, 0, $start);
313 313
 					}
314 314
 				}
315
-				echo substr($icalendar, $start, $end-$start);
315
+				echo substr($icalendar, $start, $end - $start);
316 316
 			}
317 317
 		}
318 318
 		if ($icalendar && $end)
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 	 * @param array|boolean $start =false false=return all or array(start,num)
331 331
 	 * @return array with "files" array with values for keys path and props
332 332
 	 */
333
-	function &propfind_callback($path,array $filter,$start=false)
333
+	function &propfind_callback($path, array $filter, $start = false)
334 334
 	{
335 335
 		if ($this->debug) $starttime = microtime(true);
336 336
 
337 337
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
338
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
338
+		if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex
339 339
 
340 340
 		$files = array();
341 341
 
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 		$requested_multiget_ids = (array)$filter['query'][self::$path_attr];
348 348
 		$sync_collection = $filter['sync-collection'];
349 349
 
350
-		$events =& $this->bo->search($filter);
350
+		$events = & $this->bo->search($filter);
351 351
 
352 352
 		if ($events)
353 353
 		{
354
-			foreach($events as $event)
354
+			foreach ($events as $event)
355 355
 			{
356 356
 				// remove event from requested multiget ids, to be able to report not found urls
357 357
 				if ($requested_multiget_ids && ($k = array_search($event[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					unset($requested_multiget_ids[$k]);
360 360
 				}
361 361
 				// sync-collection report: deleted entries need to be reported without properties, same for rejected or deleted invitations
362
-				if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R','X'))))
362
+				if ($sync_collection && ($event['deleted'] && !$event['cal_reference'] || in_array($event['participants'][$filter['users']][0], array('R', 'X'))))
363 363
 				{
364 364
 					$files[] = array('path' => $path.urldecode($this->get_path($event)));
365 365
 					continue;
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 						!isset($calendar_data['children']['expand']) ? false :
391 391
 							($calendar_data['children']['expand']['attrs'] ? $calendar_data['children']['expand']['attrs'] : true));
392 392
 					$props['getcontentlength'] = bytes($content);
393
-					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
393
+					$props['calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
394 394
 				}
395 395
 				/* Calendarserver reports new events with schedule-changes: action: create, which iCal request
396 396
 				 * adding it, unfortunately does not lead to showing the new event in the users inbox
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
 		// report not found multiget urls
410 410
 		if ($requested_multiget_ids)
411 411
 		{
412
-			foreach($requested_multiget_ids as $id)
412
+			foreach ($requested_multiget_ids as $id)
413 413
 			{
414 414
 				$files[] = array('path' => $path.$id.self::$path_extension);
415 415
 			}
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	private function _created_updated_by_prop($user, $time)
446 446
 	{
447 447
 		$props = array();
448
-		foreach(array(
448
+		foreach (array(
449 449
 			'first-name' => 'account_firstname',
450 450
 			'last-name' => 'account_lastname',
451 451
 			'href' => 'account_email',
@@ -488,23 +488,23 @@  discard block
 block discarded – undo
488 488
 			$cal_end = $cal_filters['end']; unset($cal_filters['end']);
489 489
 			$num_filters = count($cal_filters);
490 490
 
491
-			foreach($options['filters'] as $filter)
491
+			foreach ($options['filters'] as $filter)
492 492
 			{
493
-				switch($filter['name'])
493
+				switch ($filter['name'])
494 494
 				{
495 495
 					case 'comp-filter':
496 496
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
497 497
 
498
-						switch($filter['attrs']['name'])
498
+						switch ($filter['attrs']['name'])
499 499
 						{
500 500
 							case 'VTODO':
501
-								return false;	// return nothing for now, todo: check if we can pass it on to the infolog handler
501
+								return false; // return nothing for now, todo: check if we can pass it on to the infolog handler
502 502
 								// todos are handled by the infolog handler
503 503
 								//$infolog_handler = new groupdav_infolog();
504 504
 								//return $infolog_handler->propfind($options['path'],$options,$options['files'],$user,$method);
505 505
 							case 'VCALENDAR':
506 506
 							case 'VEVENT':
507
-								break;			// that's our default anyway
507
+								break; // that's our default anyway
508 508
 						}
509 509
 						break;
510 510
 					case 'prop-filter':
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
 						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
528 528
 						break;
529 529
 					case 'time-range':
530
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
530
+				 		if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
531 531
 				 		if (!empty($filter['attrs']['start']))
532 532
 				 		{
533 533
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
534 534
 				 		}
535 535
 				 		if (!empty($filter['attrs']['end']))
536 536
 				 		{
537
-					 		$cal_filters['end']   = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
537
+					 		$cal_filters['end'] = $this->vCalendar->_parseDateTime($filter['attrs']['end']);
538 538
 				 		}
539 539
 						break;
540 540
 					default:
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
 		    <B:nresults>10</B:nresults>
556 556
 		  </B:limit>
557 557
 		*/
558
-		foreach((array)$options['other'] as $option)
558
+		foreach ((array)$options['other'] as $option)
559 559
 		{
560
-			switch($option['name'])
560
+			switch ($option['name'])
561 561
 			{
562 562
 				case 'nresults':
563 563
 					$nresults = (int)$option['data'];
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 				case 'limit':
567 567
 					break;
568 568
 				case 'href':
569
-					break;	// from addressbook-multiget, handled below
569
+					break; // from addressbook-multiget, handled below
570 570
 				// rfc 6578 sync-report
571 571
 				case 'sync-token':
572 572
 					if (!empty($option['data']))
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 						$parts = explode('/', $option['data']);
575 575
 						$sync_token = array_pop($parts);
576 576
 						$cal_filters['query'][] = 'cal_modified>'.(int)$sync_token;
577
-						$cal_filters['filter'] = 'everything';	// to return deleted entries too
577
+						$cal_filters['filter'] = 'everything'; // to return deleted entries too
578 578
 						// no standard time-range!
579 579
 						unset($cal_filters['start']);
580 580
 					}
@@ -603,25 +603,25 @@  discard block
 block discarded – undo
603 603
 			if ($id)
604 604
 			{
605 605
 				$cal_filters['query'][self::$path_attr] = self::$path_extension ?
606
-					basename($id,self::$path_extension) : $id;
606
+					basename($id, self::$path_extension) : $id;
607 607
 			}
608 608
 			else	// fetch all given url's
609 609
 			{
610
-				foreach($options['other'] as $option)
610
+				foreach ($options['other'] as $option)
611 611
 				{
612 612
 					if ($option['name'] == 'href')
613 613
 					{
614
-						$parts = explode('/',$option['data']);
614
+						$parts = explode('/', $option['data']);
615 615
 						if (($id = urldecode(array_pop($parts))))
616 616
 						{
617 617
 							$cal_filters['query'][self::$path_attr][] = self::$path_extension ?
618
-								basename($id,self::$path_extension) : $id;
618
+								basename($id, self::$path_extension) : $id;
619 619
 						}
620 620
 					}
621 621
 				}
622 622
 			}
623 623
 
624
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
624
+			if ($this->debug > 1) error_log(__FILE__.__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids).', cal_filters='.array2string($cal_filters));
625 625
 		}
626 626
 		return true;
627 627
 	}
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param int $user =null account_id
635 635
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
636 636
 	 */
637
-	function get(&$options,$id,$user=null)
637
+	function get(&$options, $id, $user = null)
638 638
 	{
639
-		if (!is_array($event = $this->_common_get_put_delete('GET',$options,$id)))
639
+		if (!is_array($event = $this->_common_get_put_delete('GET', $options, $id)))
640 640
 		{
641 641
 			return $event;
642 642
 		}
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	 * @param boolean|array $expand =false true or array with values for 'start', 'end' to expand recurrences
665 665
 	 * @return string
666 666
 	 */
667
-	private function iCal(array $event,$user=null, $method=null, $expand=false)
667
+	private function iCal(array $event, $user = null, $method = null, $expand = false)
668 668
 	{
669 669
 		static $handler = null;
670 670
 		if (is_null($handler)) $handler = $this->_get_handler();
@@ -689,14 +689,14 @@  discard block
 block discarded – undo
689 689
 				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
690 690
 			}
691 691
 			// pass in original event as master, as it has correct start-date even if first recurrence is an exception
692
-			$events =& self::get_series($event['uid'], $this->bo, $expand, $user, $event);
692
+			$events = & self::get_series($event['uid'], $this->bo, $expand, $user, $event);
693 693
 
694 694
 			// as alarm is now only on next recurrence, set alarm from original event on master
695 695
 			if ($event['alarm']) $events[0]['alarm'] = $event['alarm'];
696 696
 		}
697
-		elseif(!$this->client_shared_uid_exceptions && $event['reference'])
697
+		elseif (!$this->client_shared_uid_exceptions && $event['reference'])
698 698
 		{
699
-			$events[0]['uid'] .= '-'.$event['id'];	// force a different uid
699
+			$events[0]['uid'] .= '-'.$event['id']; // force a different uid
700 700
 		}
701 701
 		return $handler->exportVCal($events, '2.0', $method);
702 702
 	}
@@ -713,32 +713,32 @@  discard block
 block discarded – undo
713 713
 	 * @param array $master =null use provided event as master to fix wrong start-date if first recurrence is an exception
714 714
 	 * @return array
715 715
 	 */
716
-	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null, $master=null)
716
+	private static function &get_series($uid, calendar_bo $bo = null, $expand = false, $user = null, $master = null)
717 717
 	{
718 718
 		if (is_null($bo)) $bo = new calendar_bopdate();
719 719
 
720 720
 		$params = array(
721 721
 			'query' => array('cal_uid' => $uid),
722
-			'filter' => 'owner',  // return all possible entries
722
+			'filter' => 'owner', // return all possible entries
723 723
 			'daywise' => false,
724 724
 			'date_format' => 'server',
725
-			'cfs' => array(),	// read cfs as we use them to store X- attributes
725
+			'cfs' => array(), // read cfs as we use them to store X- attributes
726 726
 		);
727 727
 		if (is_array($expand)) $params += $expand;
728 728
 
729
-		if (!($events =& $bo->search($params)))
729
+		if (!($events = & $bo->search($params)))
730 730
 		{
731 731
 			return array();
732 732
 		}
733 733
 
734 734
 		// find master, which is not always first event, eg. when first event is an exception
735 735
 		$exceptions = array();
736
-		foreach($events as $k => &$recurrence)
736
+		foreach ($events as $k => &$recurrence)
737 737
 		{
738 738
 			if ($recurrence['recur_type'])
739 739
 			{
740 740
 				if (!isset($master)) $master = $recurrence;
741
-				$exceptions =& $master['recur_exception'];
741
+				$exceptions = & $master['recur_exception'];
742 742
 				unset($events[$k]);
743 743
 				break;
744 744
 			}
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
747 747
 		if (!isset($master)) $master = $bo->read($uid);
748 748
 
749
-		foreach($events as $k => &$recurrence)
749
+		foreach ($events as $k => &$recurrence)
750 750
 		{
751 751
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence));
752 752
 			if ($master && $recurrence['reference'] && $recurrence['reference'] != $master['id'])
753 753
 			{
754 754
 				unset($events[$k]);
755
-				continue;	// same uid, but references a different event or is own master
755
+				continue; // same uid, but references a different event or is own master
756 756
 			}
757 757
 			if (!$master || $recurrence['id'] != $master['id'])	// real exception
758 758
 			{
@@ -773,11 +773,11 @@  discard block
 block discarded – undo
773 773
 				// at least Lightning "understands" EXDATE as exception from what's included
774 774
 				// in the whole resource / VCALENDAR component
775 775
 				// not removing it causes Lightning to remove the exception itself
776
-				if (($e = array_search($recurrence['recurrence'],$exceptions)) !== false)
776
+				if (($e = array_search($recurrence['recurrence'], $exceptions)) !== false)
777 777
 				{
778 778
 					unset($exceptions[$e]);
779 779
 				}
780
-				continue;	// nothing to change
780
+				continue; // nothing to change
781 781
 			}
782 782
 			// add alarms from master to recurrences, as clients otherwise have no alarms on virtual exceptions
783 783
 			if ($master && $master['alarm'])
@@ -788,14 +788,14 @@  discard block
 block discarded – undo
788 788
 			if (!$expand && $master && $master['participants'] == $recurrence['participants'])
789 789
 			{
790 790
 				//error_log('NO exception: '.array2string($recurrence));
791
-				unset($events[$k]);	// no exception --> remove it
791
+				unset($events[$k]); // no exception --> remove it
792 792
 				continue;
793 793
 			}
794 794
 			// this is a virtual exception now (no extra event/cal_id in DB)
795 795
 			//error_log('virtual exception: '.array2string($recurrence));
796 796
 			$recurrence['recurrence'] = $recurrence['start'];
797 797
 			if ($master) $recurrence['reference'] = $master['id'];
798
-			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
798
+			$recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master
799 799
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
800 800
 		}
801 801
 		// only add master if we are not expanding and current user participates in master (and not just some exceptions)
@@ -831,11 +831,11 @@  discard block
 block discarded – undo
831 831
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
832 832
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
833 833
 	 */
834
-	function put(&$options,$id,$user=null,$prefix=null)
834
+	function put(&$options, $id, $user = null, $prefix = null)
835 835
 	{
836
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
836
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
837 837
 
838
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
838
+		if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway)
839 839
 
840 840
 		// work around missing handling / racecondition in Lightning, if event already exists on server,
841 841
 		// but Lightning has not yet synced with the server: Lightning just retries the PUT, not GETing the event
@@ -852,12 +852,12 @@  discard block
 block discarded – undo
852 852
 		{
853 853
 			$_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'] = $_SERVER['HTTP_IF_SCHEDULE'];
854 854
 		}
855
-		$return_no_access = true;	// as handled by importVCal anyway and allows it to set the status for participants
856
-		$oldEvent = $this->_common_get_put_delete('PUT',$options,$id,$return_no_access,
857
-			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
855
+		$return_no_access = true; // as handled by importVCal anyway and allows it to set the status for participants
856
+		$oldEvent = $this->_common_get_put_delete('PUT', $options, $id, $return_no_access,
857
+			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case
858 858
 		if (!is_null($oldEvent) && !is_array($oldEvent))
859 859
 		{
860
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
860
+			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent, true).function_backtrace());
861 861
 			return $oldEvent;
862 862
 		}
863 863
 
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 				if (($events = $handler->icaltoegw($vCalendar)))
950 950
 				{
951 951
 					$modified = 0;
952
-					foreach($events as $n => $event)
952
+					foreach ($events as $n => $event)
953 953
 					{
954 954
 						// for recurrances of event series, we need to read correct recurrence (or if series master is no first event)
955 955
 						if ($event['recurrence'] || $n && !$event['recurrence'] || isset($series))
@@ -960,7 +960,7 @@  discard block
 block discarded – undo
960 960
 								$series = self::get_series($event['uid'], $this->bo);
961 961
 								//foreach($series as $s => $sEvent) error_log("series[$s]: ".array2string($sEvent));
962 962
 							}
963
-							foreach($series as $oldEvent)
963
+							foreach ($series as $oldEvent)
964 964
 							{
965 965
 								if ($oldEvent['recurrence'] == $event['recurrence']) break;
966 966
 							}
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
 					isset($oldEvent['participants'][$GLOBALS['egw_info']['user']['account_id']]))
1026 1026
 				{
1027 1027
 					// just update etag in database
1028
-					$GLOBALS['egw']->db->update($this->bo->so->cal_table,'cal_etag=cal_etag+1',array(
1028
+					$GLOBALS['egw']->db->update($this->bo->so->cal_table, 'cal_etag=cal_etag+1', array(
1029 1029
 						'cal_id' => $eventId,
1030
-					),__LINE__,__FILE__,'calendar');
1030
+					), __LINE__, __FILE__, 'calendar');
1031 1031
 				}
1032 1032
 			}
1033 1033
 		}
@@ -1079,9 +1079,9 @@  discard block
 block discarded – undo
1079 1079
 	 * @param int $user =null account_id of owner, default null
1080 1080
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1081 1081
 	 */
1082
-	function post(&$options,$id,$user=null)
1082
+	function post(&$options, $id, $user = null)
1083 1083
 	{
1084
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1084
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
1085 1085
 
1086 1086
 		$vCalendar = htmlspecialchars_decode($options['content']);
1087 1087
 		$charset = null;
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 			}
1104 1104
 		}
1105 1105
 
1106
-		if (substr($options['path'],-8) == '/outbox/')
1106
+		if (substr($options['path'], -8) == '/outbox/')
1107 1107
 		{
1108 1108
 			if (preg_match('/^METHOD:REQUEST(\r\n|\r|\n)(.*)^BEGIN:VFREEBUSY/ism', $vCalendar))
1109 1109
 			{
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 	 */
1155 1155
 	protected function outbox_freebusy_request($ical, $charset, $user, array &$options)
1156 1156
 	{
1157
-		unset($options);	// not used, but required by function signature
1157
+		unset($options); // not used, but required by function signature
1158 1158
 
1159 1159
 		$vcal = new Horde_Icalendar();
1160 1160
 		if (!$vcal->parsevCalendar($ical, 'VCALENDAR', $charset))
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 
1168 1168
 		$handler = $this->_get_handler();
1169 1169
 		$handler->setSupportedFields('groupdav');
1170
-		$handler->calendarOwner = $handler->user = 0;	// to NOT default owner/organizer to something
1170
+		$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
1171 1171
 		if (!($component = $vcal->getComponent(0)) ||
1172 1172
 			!($event = $handler->vevent2egw($component, $version, $handler->supportedFields, $this->caldav->current_user_principal, 'Horde_Icalendar_Vfreebusy')))
1173 1173
 		{
@@ -1192,13 +1192,13 @@  discard block
 block discarded – undo
1192 1192
 		$xml->startDocument('1.0', 'UTF-8');
1193 1193
 		$xml->startElementNs('C', 'schedule-response', Api\CalDAV::CALDAV);
1194 1194
 
1195
-		foreach(array_keys($event['participants']) as $uid)
1195
+		foreach (array_keys($event['participants']) as $uid)
1196 1196
 		{
1197 1197
 			$xml->startElementNs('C', 'response', null);
1198 1198
 
1199 1199
 			$xml->startElementNs('C', 'recipient', null);
1200
-			$xml->writeElementNs('D', 'href', 'DAV:', $attendee=array_shift($attendees));
1201
-			$xml->endElement();	// recipient
1200
+			$xml->writeElementNs('D', 'href', 'DAV:', $attendee = array_shift($attendees));
1201
+			$xml->endElement(); // recipient
1202 1202
 
1203 1203
 			$xml->writeElementNs('C', 'request-status', null, '2.0;Success');
1204 1204
 			$xml->writeElementNs('C', 'calendar-data', null,
@@ -1206,13 +1206,13 @@  discard block
 block discarded – undo
1206 1206
 					'UID' => $event['uid'],
1207 1207
 					'ORGANIZER' => $organizer,
1208 1208
 					'ATTENDEE' => $attendee,
1209
-				)+(empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1209
+				) + (empty($mask_uid) || !is_string($mask_uid) ? array() : array(
1210 1210
 					'X-CALENDARSERVER-MASK-UID' => $mask_uid,
1211 1211
 				))));
1212 1212
 
1213
-			$xml->endElement();	// response
1213
+			$xml->endElement(); // response
1214 1214
 		}
1215
-		$xml->endElement();	// schedule-response
1215
+		$xml->endElement(); // schedule-response
1216 1216
 		$xml->endDocument();
1217 1217
 		echo $xml->outputMemory();
1218 1218
 
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
 	 * @param int $user account_id
1228 1228
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1229 1229
 	 */
1230
-	function free_busy_report($path,$options,$user)
1230
+	function free_busy_report($path, $options, $user)
1231 1231
 	{
1232
-		unset($path);	// unused, but required by function signature
1232
+		unset($path); // unused, but required by function signature
1233 1233
 		if (!$this->bo->check_perms(calendar_bo::ACL_FREEBUSY, 0, $user))
1234 1234
 		{
1235 1235
 			return '403 Forbidden';
1236 1236
 		}
1237
-		foreach($options['other'] as $filter)
1237
+		foreach ($options['other'] as $filter)
1238 1238
 		{
1239 1239
 			if ($filter['name'] == 'time-range')
1240 1240
 			{
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		header('Content-Type: text/calendar');
1247 1247
 		echo $handler->freebusy($user, $end, true, 'utf-8', $start, 'REPLY', array());
1248 1248
 
1249
-		exit();	// otherwise we get a 207 multistatus, not 200 Ok
1249
+		exit(); // otherwise we get a 207 multistatus, not 200 Ok
1250 1250
 	}
1251 1251
 
1252 1252
 	/**
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 	 * @param int $user =null owner of the collection, default current user
1259 1259
 	 * @return array with privileges
1260 1260
 	 */
1261
-	public function current_user_privileges($path, $user=null)
1261
+	public function current_user_privileges($path, $user = null)
1262 1262
 	{
1263 1263
 		$privileges = parent::current_user_privileges($path, $user);
1264 1264
 		//error_log(__METHOD__."('$path', $user) parent gave ".array2string($privileges));
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 
1302 1302
 		// get array with orginal recurrences indexed by recurrence-id
1303 1303
 		$org_recurrences = $exceptions = array();
1304
-		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1304
+		foreach (self::get_series($events[0]['uid'], $bo) as $k => $event)
1305 1305
 		{
1306 1306
 			if (!$k) $master = $event;
1307 1307
 			if ($event['recurrence'])
@@ -1311,13 +1311,13 @@  discard block
 block discarded – undo
1311 1311
 		}
1312 1312
 
1313 1313
 		// assign cal_id's to already existing recurrences and evtl. re-add recur_exception to master
1314
-		foreach($events as $k => &$recurrence)
1314
+		foreach ($events as $k => &$recurrence)
1315 1315
 		{
1316 1316
 			if (!$recurrence['recurrence'])
1317 1317
 			{
1318 1318
 				// master
1319 1319
 				$recurrence['id'] = $master['id'];
1320
-				$master =& $events[$k];
1320
+				$master = & $events[$k];
1321 1321
 				continue;
1322 1322
 			}
1323 1323
 
@@ -1341,12 +1341,12 @@  discard block
 block discarded – undo
1341 1341
 		$master['recur_exception'] = array_merge($exceptions, $master['recur_exception']);
1342 1342
 
1343 1343
 		// delete not longer existing recurrences
1344
-		foreach($org_recurrences as $org_recurrence)
1344
+		foreach ($org_recurrences as $org_recurrence)
1345 1345
 		{
1346 1346
 			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1347 1347
 			{
1348 1348
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1349
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1349
+				$bo->delete($org_recurrence['id']); // might fail because of permissions
1350 1350
 			}
1351 1351
 			else	// virtual recurrence
1352 1352
 			{
@@ -1368,14 +1368,14 @@  discard block
 block discarded – undo
1368 1368
 	 * @param int $user account_id of collection owner
1369 1369
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1370 1370
 	 */
1371
-	function delete(&$options,$id,$user)
1371
+	function delete(&$options, $id, $user)
1372 1372
 	{
1373 1373
 		if (strpos($options['path'], '/inbox/') !== false)
1374 1374
 		{
1375
-			return true;	// simply ignore DELETE in inbox for now
1375
+			return true; // simply ignore DELETE in inbox for now
1376 1376
 		}
1377
-		$return_no_access = true;	// to allow to check if current use is a participant and reject the event for him
1378
-		$event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access);
1377
+		$return_no_access = true; // to allow to check if current use is a participant and reject the event for him
1378
+		$event = $this->_common_get_put_delete('DELETE', $options, $id, $return_no_access);
1379 1379
 
1380 1380
 		// no event found --> 404 Not Found
1381 1381
 		if (!is_array($event))
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
 			// check if user is a participant or one of the groups he is a member of --> reject the meeting request
1395 1395
 			$ret = '403 Forbidden';
1396 1396
 			$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1397
-			foreach(array_keys($event['participants']) as $uid)
1397
+			foreach (array_keys($event['participants']) as $uid)
1398 1398
 			{
1399 1399
 				if ($user == $uid || in_array($uid, $memberships))
1400 1400
 				{
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 			// check if current user is a participant or one of the groups he is a member of --> reject the meeting request
1411 1411
 			$ret = '403 Forbidden';
1412 1412
 			$memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true);
1413
-			foreach(array_keys($event['participants']) as $uid)
1413
+			foreach (array_keys($event['participants']) as $uid)
1414 1414
 			{
1415 1415
 				if ($this->bo->user == $uid || in_array($uid, $memberships))
1416 1416
 				{
@@ -1424,9 +1424,9 @@  discard block
 block discarded – undo
1424 1424
 		else
1425 1425
 		{
1426 1426
 			$ret = $this->bo->delete($event['id']);
1427
-			if (!$ret) { error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event';}
1427
+			if (!$ret) { error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event'; }
1428 1428
 		}
1429
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1429
+		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event) ? $event['participants'] : null).", user={$this->bo->user} --> return ".array2string($ret));
1430 1430
 		return $ret;
1431 1431
 	}
1432 1432
 
@@ -1441,12 +1441,12 @@  discard block
 block discarded – undo
1441 1441
 	 */
1442 1442
 	function read($id)
1443 1443
 	{
1444
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1444
+		if (strpos($column = self::$path_attr, '_') === false) $column = 'cal_'.$column;
1445 1445
 
1446 1446
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1447
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1447
+		if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events!
1448 1448
 
1449
-		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1449
+		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY, $event, 0, 'server')) &&
1450 1450
 			// above can be true, if current user is not in master but just a recurrence
1451 1451
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1452 1452
 		{
@@ -1482,11 +1482,11 @@  discard block
 block discarded – undo
1482 1482
 	 *
1483 1483
 	 * @return string
1484 1484
 	 */
1485
-	public function getctag($path,$user)
1485
+	public function getctag($path, $user)
1486 1486
 	{
1487
-		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1487
+		$ctag = $this->bo->get_ctag($user, $path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1488 1488
 
1489
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1489
+		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($path)[$user] = $ctag");
1490 1490
 
1491 1491
 		return $ctag;
1492 1492
 	}
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
 	 * @param string $schedule_tag =null on return schedule-tag
1499 1499
 	 * @return string|boolean string with etag or false
1500 1500
 	 */
1501
-	function get_etag($entry, &$schedule_tag=null)
1501
+	function get_etag($entry, &$schedule_tag = null)
1502 1502
 	{
1503 1503
 		$etag = $this->bo->get_etag($entry, $schedule_tag, $this->client_shared_uid_exceptions);
1504 1504
 
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 	 * @param int|string $retval
1517 1517
 	 * @param boolean $path_attr_is_name =true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
1518 1518
 	 */
1519
-	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true)
1519
+	function put_response_headers($entry, $path, $retval, $path_attr_is_name = true)
1520 1520
 	{
1521 1521
 		$schedule_tag = null;
1522 1522
 		$etag = $this->get_etag($entry, $schedule_tag);
@@ -1535,14 +1535,14 @@  discard block
 block discarded – undo
1535 1535
 	 * @param array|int $event event-array or id
1536 1536
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1537 1537
 	 */
1538
-	function check_access($acl,$event)
1538
+	function check_access($acl, $event)
1539 1539
 	{
1540 1540
 		if ($acl == Acl::READ)
1541 1541
 		{
1542 1542
 			// we need at least calendar_bo::ACL_FREEBUSY to get some information
1543 1543
 			$acl = calendar_bo::ACL_FREEBUSY;
1544 1544
 		}
1545
-		return $this->bo->check_perms($acl,$event,0,'server');
1545
+		return $this->bo->check_perms($acl, $event, 0, 'server');
1546 1546
 	}
1547 1547
 
1548 1548
 	/**
@@ -1555,52 +1555,52 @@  discard block
 block discarded – undo
1555 1555
 	 * @param string $path =null path of the collection
1556 1556
 	 * @return array
1557 1557
 	 */
1558
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null, $path=null)
1558
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null, $path = null)
1559 1559
 	{
1560
-		unset($base_uri);	// unused, but required by function signature
1560
+		unset($base_uri); // unused, but required by function signature
1561 1561
 		if (!isset($props['calendar-description']))
1562 1562
 		{
1563 1563
 			// default calendar description: can be overwritten via PROPPATCH, in which case it's already set
1564
-			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
1564
+			$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
1565 1565
 		}
1566 1566
 		$supported_components = array(
1567
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VEVENT')),
1567
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VEVENT')),
1568 1568
 		);
1569 1569
 		// outbox supports VFREEBUSY too, it is required from OS X iCal to autocomplete locations
1570
-		if (substr($path,-8) == '/outbox/')
1570
+		if (substr($path, -8) == '/outbox/')
1571 1571
 		{
1572
-			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VFREEBUSY'));
1572
+			$supported_components[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VFREEBUSY'));
1573 1573
 		}
1574 1574
 		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,
1575
-			'supported-calendar-component-set',$supported_components);
1575
+			'supported-calendar-component-set', $supported_components);
1576 1576
 		// supported reports
1577 1577
 		$props['supported-report-set'] = array(
1578
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
1579
-				Api\CalDAV::mkprop('report',array(
1580
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
1581
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
1582
-				Api\CalDAV::mkprop('report',array(
1583
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
1584
-			'free-busy-query' => Api\CalDAV::mkprop('supported-report',array(
1585
-				Api\CalDAV::mkprop('report',array(
1586
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'free-busy-query',''))))),
1578
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
1579
+				Api\CalDAV::mkprop('report', array(
1580
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
1581
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
1582
+				Api\CalDAV::mkprop('report', array(
1583
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
1584
+			'free-busy-query' => Api\CalDAV::mkprop('supported-report', array(
1585
+				Api\CalDAV::mkprop('report', array(
1586
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'free-busy-query', ''))))),
1587 1587
 		);
1588 1588
 		// rfc 6578 sync-collection report for everything but outbox
1589 1589
 		// only if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
1590 1590
 		if (strpos($path, '/outbox/') === false && $GLOBALS['egw_info']['server']['calendar_delete_history'])
1591 1591
 		{
1592
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
1593
-				Api\CalDAV::mkprop('report',array(
1594
-					Api\CalDAV::mkprop('sync-collection','')))));
1592
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
1593
+				Api\CalDAV::mkprop('report', array(
1594
+					Api\CalDAV::mkprop('sync-collection', '')))));
1595 1595
 		}
1596
-		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-data',array(
1597
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1598
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1596
+		$props['supported-calendar-data'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-data', array(
1597
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/calendar', 'version'=> '2.0')),
1598
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', array('content-type' => 'text/x-calendar', 'version'=> '1.0'))));
1599 1599
 
1600 1600
 		// get timezone of calendar
1601 1601
 		if ($this->caldav->prop_requested('calendar-timezone'))
1602 1602
 		{
1603
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
1603
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
1604 1604
 				calendar_timezones::user_timezone($user));
1605 1605
 		}
1606 1606
 		return $props;
@@ -1614,9 +1614,9 @@  discard block
 block discarded – undo
1614 1614
 	private function _get_handler()
1615 1615
 	{
1616 1616
 		$handler = new calendar_ical();
1617
-		$handler->setSupportedFields('GroupDAV',$this->agent);
1618
-		$handler->supportedFields['attachments'] = true;	// enabling attachments
1619
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1617
+		$handler->setSupportedFields('GroupDAV', $this->agent);
1618
+		$handler->supportedFields['attachments'] = true; // enabling attachments
1619
+		if ($this->debug > 1) error_log("ical Handler called: ".$this->agent);
1620 1620
 		return $handler;
1621 1621
 	}
1622 1622
 
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 		$pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set'];
1632 1632
 		$calendar_home_set = $pref ? explode(',', $pref) : array();
1633 1633
 		// replace symbolic id's with real nummeric id's
1634
-		foreach(array(
1634
+		foreach (array(
1635 1635
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1636 1636
 		) as $sym => $id)
1637 1637
 		{
@@ -1640,11 +1640,11 @@  discard block
 block discarded – undo
1640 1640
 				$calendar_home_set[$key] = $id;
1641 1641
 			}
1642 1642
 		}
1643
-		foreach(ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1643
+		foreach (ExecMethod('calendar.calendar_bo.list_cals') as $entry)
1644 1644
 		{
1645 1645
 			$id = $entry['grantor'];
1646
-			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user
1647
-				(in_array('A',$calendar_home_set) || in_array((string)$id,$calendar_home_set)) &&
1646
+			if ($id && $GLOBALS['egw_info']['user']['account_id'] != $id && // no current user
1647
+				(in_array('A', $calendar_home_set) || in_array((string)$id, $calendar_home_set)) &&
1648 1648
 				is_numeric($id) && ($owner = $this->accounts->id2name($id)))
1649 1649
 			{
1650 1650
 				$shared[$id] = 'calendar-'.$owner;
@@ -1653,11 +1653,11 @@  discard block
 block discarded – undo
1653 1653
 		// shared locations and resources
1654 1654
 		if ($GLOBALS['egw_info']['user']['apps']['resources'])
1655 1655
 		{
1656
-			foreach(array('locations','resources') as $res)
1656
+			foreach (array('locations', 'resources') as $res)
1657 1657
 			{
1658 1658
 				if (($pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['calendar-home-set-'.$res]))
1659 1659
 				{
1660
-					foreach(explode(',', $pref) as $res_id)
1660
+					foreach (explode(',', $pref) as $res_id)
1661 1661
 					{
1662 1662
 						$is_location = $res == 'locations';
1663 1663
 						$shared['r'.$res_id] = str_replace('s/', '-', Api\CalDAV\Principals::resource2name($res_id, $is_location));
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
 			{
1688 1688
 				$calendars[$entry['grantor']] = $entry['name'];
1689 1689
 			}
1690
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1690
+			if ($user > 0) unset($calendars[$user]); // skip current user
1691 1691
 		}
1692 1692
 
1693 1693
 		$settings = array();
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 			'type'   => 'multiselect',
1696 1696
 			'label'  => 'Calendars to sync in addition to personal calendar',
1697 1697
 			'name'   => 'calendar-home-set',
1698
-			'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"'),
1698
+			'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"'),
1699 1699
 			'values' => $calendars,
1700 1700
 			'xmlrpc' => True,
1701 1701
 			'admin'  => False,
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 		if ($GLOBALS['egw_info']['user']['apps']['resources'] && ($all_resources = Api\CalDAV\Principals::get_resources()))
1722 1722
 		{
1723 1723
 			$resources = $locations = array();
1724
-			foreach($all_resources as $resource)
1724
+			foreach ($all_resources as $resource)
1725 1725
 			{
1726 1726
 				if (Api\CalDAV\Principals::resource_is_location($resource))
1727 1727
 				{
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 					$resources[$resource['res_id']] = $resource['name'];
1733 1733
 				}
1734 1734
 			}
1735
-			foreach(array(
1735
+			foreach (array(
1736 1736
 				'locations' => $locations,
1737 1737
 				'resources' => $resources,
1738 1738
 			) as $name => $options)
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 						'label'  => lang('%1 to sync', lang($name == 'locations' ? 'Location calendars' : 'Resource calendars')),
1746 1746
 						'no_lang'=> true,
1747 1747
 						'name'   => 'calendar-home-set-'.$name,
1748
-						'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"'),
1748
+						'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"'),
1749 1749
 						'values' => $options,
1750 1750
 						'xmlrpc' => True,
1751 1751
 						'admin'  => False,
Please login to merge, or discard this patch.
Braces   +235 added lines, -58 removed lines patch added patch discarded remove patch
@@ -132,7 +132,10 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 		else
134 134
 		{
135
-			if (!is_array($event)) $event = $this->bo->read($event);
135
+			if (!is_array($event))
136
+			{
137
+				$event = $this->bo->read($event);
138
+			}
136 139
 			$name = $event[self::$path_attr];
137 140
 		}
138 141
 		$name .= self::$path_extension;
@@ -193,10 +196,13 @@  discard block
 block discarded – undo
193 196
 			}
194 197
 			$filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value);
195 198
 		}
196
-		if ($this->client_shared_uid_exceptions)	// do NOT return (non-virtual) exceptions
199
+		if ($this->client_shared_uid_exceptions)
200
+		{
201
+			// do NOT return (non-virtual) exceptions
197 202
 		{
198 203
 			$filter['query'] = array('cal_reference' => 0);
199 204
 		}
205
+		}
200 206
 
201 207
 		if ($path == '/calendar/')
202 208
 		{
@@ -226,7 +232,11 @@  discard block
 block discarded – undo
226 232
 			// when trying to request not supported components, eg. VTODO on a calendar collection
227 233
 			return true;
228 234
 		}
229
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
235
+		if ($id)
236
+		{
237
+			$path = dirname($path).'/';
238
+		}
239
+		// caldav_name get's added anyway in the callback
230 240
 
231 241
 		if ($this->debug > 1)
232 242
 		{
@@ -288,7 +298,11 @@  discard block
 block discarded – undo
288 298
 		$n = 0;
289 299
 		foreach($files as $file)
290 300
 		{
291
-			if (!$n++) continue;	// first entry is collection itself
301
+			if (!$n++)
302
+			{
303
+				continue;
304
+			}
305
+			// first entry is collection itself
292 306
 
293 307
 			$icalendar = $file['props']['calendar-data']['val'];
294 308
 			if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false &&
@@ -332,10 +346,17 @@  discard block
 block discarded – undo
332 346
 	 */
333 347
 	function &propfind_callback($path,array $filter,$start=false)
334 348
 	{
335
-		if ($this->debug) $starttime = microtime(true);
349
+		if ($this->debug)
350
+		{
351
+			$starttime = microtime(true);
352
+		}
336 353
 
337 354
 		$calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true);
338
-		if (!is_array($calendar_data)) $calendar_data = false;	// not in allprop or autoindex
355
+		if (!is_array($calendar_data))
356
+		{
357
+			$calendar_data = false;
358
+		}
359
+		// not in allprop or autoindex
339 360
 
340 361
 		$files = array();
341 362
 
@@ -493,7 +514,10 @@  discard block
 block discarded – undo
493 514
 				switch($filter['name'])
494 515
 				{
495 516
 					case 'comp-filter':
496
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
517
+						if ($this->debug > 1)
518
+						{
519
+							error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
520
+						}
497 521
 
498 522
 						switch($filter['attrs']['name'])
499 523
 						{
@@ -508,14 +532,23 @@  discard block
 block discarded – undo
508 532
 						}
509 533
 						break;
510 534
 					case 'prop-filter':
511
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
535
+						if ($this->debug > 1)
536
+						{
537
+							error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
538
+						}
512 539
 						$prop_filter = $filter['attrs']['name'];
513 540
 						break;
514 541
 					case 'text-match':
515
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
542
+						if ($this->debug > 1)
543
+						{
544
+							error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
545
+						}
516 546
 						if (!isset($this->filter_prop2cal[strtoupper($prop_filter)]))
517 547
 						{
518
-							if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
548
+							if ($this->debug)
549
+							{
550
+								error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
551
+							}
519 552
 						}
520 553
 						else
521 554
 						{
@@ -524,10 +557,16 @@  discard block
 block discarded – undo
524 557
 						unset($prop_filter);
525 558
 						break;
526 559
 					case 'param-filter':
527
-						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
560
+						if ($this->debug)
561
+						{
562
+							error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
563
+						}
528 564
 						break;
529 565
 					case 'time-range':
530
-				 		if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
566
+				 		if ($this->debug > 1)
567
+				 		{
568
+				 			error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}");
569
+				 		}
531 570
 				 		if (!empty($filter['attrs']['start']))
532 571
 				 		{
533 572
 					 		$cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']);
@@ -538,13 +577,19 @@  discard block
 block discarded – undo
538 577
 				 		}
539 578
 						break;
540 579
 					default:
541
-						if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
580
+						if ($this->debug)
581
+						{
582
+							error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
583
+						}
542 584
 						break;
543 585
 				}
544 586
 			}
545
-			if (count($cal_filters) == $num_filters)	// no filters set --> restore default start and end time
587
+			if (count($cal_filters) == $num_filters)
588
+			{
589
+				// no filters set --> restore default start and end time
546 590
 			{
547 591
 				$cal_filters['start'] = $cal_start;
592
+			}
548 593
 				$cal_filters['end']   = $cal_end;
549 594
 			}
550 595
 		}
@@ -621,7 +666,10 @@  discard block
 block discarded – undo
621 666
 				}
622 667
 			}
623 668
 
624
-			if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
669
+			if ($this->debug > 1)
670
+			{
671
+				error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters));
672
+			}
625 673
 		}
626 674
 		return true;
627 675
 	}
@@ -667,9 +715,15 @@  discard block
 block discarded – undo
667 715
 	private function iCal(array $event,$user=null, $method=null, $expand=false)
668 716
 	{
669 717
 		static $handler = null;
670
-		if (is_null($handler)) $handler = $this->_get_handler();
718
+		if (is_null($handler))
719
+		{
720
+			$handler = $this->_get_handler();
721
+		}
671 722
 
672
-		if (!$user) $user = $GLOBALS['egw_info']['user']['account_id'];
723
+		if (!$user)
724
+		{
725
+			$user = $GLOBALS['egw_info']['user']['account_id'];
726
+		}
673 727
 
674 728
 		// only return alarms in own calendar, not other users calendars
675 729
 		if ($user != $GLOBALS['egw_info']['user']['account_id'])
@@ -685,14 +739,23 @@  discard block
 block discarded – undo
685 739
 		{
686 740
 			if (is_array($expand))
687 741
 			{
688
-				if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
689
-				if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
742
+				if (isset($expand['start']))
743
+				{
744
+					$expand['start'] = $this->vCalendar->_parseDateTime($expand['start']);
745
+				}
746
+				if (isset($expand['end']))
747
+				{
748
+					$expand['end'] = $this->vCalendar->_parseDateTime($expand['end']);
749
+				}
690 750
 			}
691 751
 			// pass in original event as master, as it has correct start-date even if first recurrence is an exception
692 752
 			$events =& self::get_series($event['uid'], $this->bo, $expand, $user, $event);
693 753
 
694 754
 			// as alarm is now only on next recurrence, set alarm from original event on master
695
-			if ($event['alarm']) $events[0]['alarm'] = $event['alarm'];
755
+			if ($event['alarm'])
756
+			{
757
+				$events[0]['alarm'] = $event['alarm'];
758
+			}
696 759
 		}
697 760
 		elseif(!$this->client_shared_uid_exceptions && $event['reference'])
698 761
 		{
@@ -715,7 +778,10 @@  discard block
 block discarded – undo
715 778
 	 */
716 779
 	private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null, $master=null)
717 780
 	{
718
-		if (is_null($bo)) $bo = new calendar_bopdate();
781
+		if (is_null($bo))
782
+		{
783
+			$bo = new calendar_bopdate();
784
+		}
719 785
 
720 786
 		$params = array(
721 787
 			'query' => array('cal_uid' => $uid),
@@ -724,7 +790,10 @@  discard block
 block discarded – undo
724 790
 			'date_format' => 'server',
725 791
 			'cfs' => array(),	// read cfs as we use them to store X- attributes
726 792
 		);
727
-		if (is_array($expand)) $params += $expand;
793
+		if (is_array($expand))
794
+		{
795
+			$params += $expand;
796
+		}
728 797
 
729 798
 		if (!($events =& $bo->search($params)))
730 799
 		{
@@ -737,14 +806,20 @@  discard block
 block discarded – undo
737 806
 		{
738 807
 			if ($recurrence['recur_type'])
739 808
 			{
740
-				if (!isset($master)) $master = $recurrence;
809
+				if (!isset($master))
810
+				{
811
+					$master = $recurrence;
812
+				}
741 813
 				$exceptions =& $master['recur_exception'];
742 814
 				unset($events[$k]);
743 815
 				break;
744 816
 			}
745 817
 		}
746 818
 		// if recurring event starts in future behind horizont, nothing will be returned by bo::search()
747
-		if (!isset($master)) $master = $bo->read($uid);
819
+		if (!isset($master))
820
+		{
821
+			$master = $bo->read($uid);
822
+		}
748 823
 
749 824
 		foreach($events as $k => &$recurrence)
750 825
 		{
@@ -754,7 +829,9 @@  discard block
 block discarded – undo
754 829
 				unset($events[$k]);
755 830
 				continue;	// same uid, but references a different event or is own master
756 831
 			}
757
-			if (!$master || $recurrence['id'] != $master['id'])	// real exception
832
+			if (!$master || $recurrence['id'] != $master['id'])
833
+			{
834
+				// real exception
758 835
 			{
759 836
 				// user is NOT participating in this exception
760 837
 				if ($user && !self::isParticipant($recurrence, $user))
@@ -763,6 +840,7 @@  discard block
 block discarded – undo
763 840
 					if (!$master || !self::isParticipant($master, $user))
764 841
 					{
765 842
 						unset($events[$k]);
843
+			}
766 844
 						continue;
767 845
 					}
768 846
 					// otherwise mark him in this exception as rejected
@@ -794,7 +872,10 @@  discard block
 block discarded – undo
794 872
 			// this is a virtual exception now (no extra event/cal_id in DB)
795 873
 			//error_log('virtual exception: '.array2string($recurrence));
796 874
 			$recurrence['recurrence'] = $recurrence['start'];
797
-			if ($master) $recurrence['reference'] = $master['id'];
875
+			if ($master)
876
+			{
877
+				$recurrence['reference'] = $master['id'];
878
+			}
798 879
 			$recurrence['recur_type'] = MCAL_RECUR_NONE;	// is set, as this is a copy of the master
799 880
 			// not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start'];
800 881
 		}
@@ -833,9 +914,16 @@  discard block
 block discarded – undo
833 914
 	 */
834 915
 	function put(&$options,$id,$user=null,$prefix=null)
835 916
 	{
836
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
917
+		if ($this->debug)
918
+		{
919
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
920
+		}
837 921
 
838
-		if (!$prefix) $user = null;	// /infolog/ does not imply setting the current user (for new entries it's done anyway)
922
+		if (!$prefix)
923
+		{
924
+			$user = null;
925
+		}
926
+		// /infolog/ does not imply setting the current user (for new entries it's done anyway)
839 927
 
840 928
 		// work around missing handling / racecondition in Lightning, if event already exists on server,
841 929
 		// but Lightning has not yet synced with the server: Lightning just retries the PUT, not GETing the event
@@ -857,7 +945,10 @@  discard block
 block discarded – undo
857 945
 			isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']));	// dont fail with 412 Precondition Failed in that case
858 946
 		if (!is_null($oldEvent) && !is_array($oldEvent))
859 947
 		{
860
-			if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
948
+			if ($this->debug)
949
+			{
950
+				error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace());
951
+			}
861 952
 			return $oldEvent;
862 953
 		}
863 954
 
@@ -868,7 +959,10 @@  discard block
 block discarded – undo
868 959
 		{
869 960
 			// we have no add permission on this user's calendar
870 961
 			// ToDo: create event in current users calendar and invite only $user
871
-			if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
962
+			if ($this->debug)
963
+			{
964
+				error_log(__METHOD__."(,,$user) we have not enough rights on this calendar");
965
+			}
872 966
 			return '403 Forbidden';
873 967
 		}
874 968
 
@@ -915,13 +1009,19 @@  discard block
 block discarded – undo
915 1009
 			if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']))
916 1010
 			{
917 1011
 				$schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'];
918
-				if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1);
1012
+				if ($schedule_tag_match[0] == '"')
1013
+				{
1014
+					$schedule_tag_match = substr($schedule_tag_match, 1, -1);
1015
+				}
919 1016
 				$schedule_tag = null;
920 1017
 				$this->get_etag($oldEvent, $schedule_tag);
921 1018
 
922 1019
 				if ($schedule_tag_match !== $schedule_tag)
923 1020
 				{
924
-					if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
1021
+					if ($this->debug)
1022
+					{
1023
+						error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'");
1024
+					}
925 1025
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
926 1026
 					$this->check_return_representation($options, $id, $user);
927 1027
 					return '412 Precondition Failed';
@@ -942,7 +1042,10 @@  discard block
 block discarded – undo
942 1042
 					// above can be true, if current user is not in master but just a recurrence
943 1043
 					(!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo))))
944 1044
 				{
945
-					if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1045
+					if ($this->debug)
1046
+					{
1047
+						error_log(__METHOD__."(,,$user) user $user is NOT an attendee!");
1048
+					}
946 1049
 					return '403 Forbidden';
947 1050
 				}
948 1051
 				// update only participant status and alarms of current user
@@ -962,7 +1065,10 @@  discard block
 block discarded – undo
962 1065
 							}
963 1066
 							foreach($series as $oldEvent)
964 1067
 							{
965
-								if ($oldEvent['recurrence'] == $event['recurrence']) break;
1068
+								if ($oldEvent['recurrence'] == $event['recurrence'])
1069
+								{
1070
+									break;
1071
+								}
966 1072
 							}
967 1073
 							// if no exception found, check if it might be just a recurrence (no exception)
968 1074
 							if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence'])
@@ -977,7 +1083,10 @@  discard block
 block discarded – undo
977 1083
 								}
978 1084
 							}
979 1085
 						}
980
-						if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1086
+						if ($this->debug)
1087
+						{
1088
+							error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event));
1089
+						}
981 1090
 						if (isset($event['participants']) && isset($event['participants'][$user]) &&
982 1091
 							$event['participants'][$user] !== $oldEvent['participants'][$user])
983 1092
 						{
@@ -985,13 +1094,19 @@  discard block
 block discarded – undo
985 1094
 								// real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence!
986 1095
 								$recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0))
987 1096
 							{
988
-								if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1097
+								if ($this->debug)
1098
+								{
1099
+									error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')');
1100
+								}
989 1101
 								return '403 Forbidden';
990 1102
 							}
991 1103
 							else
992 1104
 							{
993 1105
 								++$modified;
994
-								if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1106
+								if ($this->debug)
1107
+								{
1108
+									error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')');
1109
+								}
995 1110
 							}
996 1111
 						}
997 1112
 						// import alarms, if given and changed
@@ -1001,15 +1116,21 @@  discard block
 block discarded – undo
1001 1116
 							$modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user);
1002 1117
 						}
1003 1118
 					}
1004
-					if (!$modified)	// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
1119
+					if (!$modified)
1120
+					{
1121
+						// NO modififictions, or none we understood --> log it and return Ok: "204 No Content"
1005 1122
 					{
1006 1123
 						$this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent));
1007 1124
 					}
1125
+					}
1008 1126
 					$this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name');
1009 1127
 
1010 1128
 					return '204 No Content';
1011 1129
 				}
1012
-				if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1130
+				if ($this->debug && !isset($events))
1131
+				{
1132
+					error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT");
1133
+				}
1013 1134
 			}
1014 1135
 			if ($return_no_access)
1015 1136
 			{
@@ -1046,17 +1167,23 @@  discard block
 block discarded – undo
1046 1167
 		if (!($cal_id = $handler->importVCal($vCalendar, $eventId,
1047 1168
 			self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id)))
1048 1169
 		{
1049
-			if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1170
+			if ($this->debug)
1171
+			{
1172
+				error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id));
1173
+			}
1050 1174
 			if ($eventId && $cal_id === false)
1051 1175
 			{
1052 1176
 				// ignore import failures
1053 1177
 				$cal_id = $eventId;
1054 1178
 				$retval = true;
1055 1179
 			}
1056
-			elseif ($cal_id === 0)	// etag failure
1180
+			elseif ($cal_id === 0)
1181
+			{
1182
+				// etag failure
1057 1183
 			{
1058 1184
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
1059 1185
 				$this->check_return_representation($options, $id, $user);
1186
+			}
1060 1187
 				return '412 Precondition Failed';
1061 1188
 			}
1062 1189
 			else
@@ -1081,7 +1208,10 @@  discard block
 block discarded – undo
1081 1208
 	 */
1082 1209
 	function post(&$options,$id,$user=null)
1083 1210
 	{
1084
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
1211
+		if ($this->debug)
1212
+		{
1213
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
1214
+		}
1085 1215
 
1086 1216
 		$vCalendar = htmlspecialchars_decode($options['content']);
1087 1217
 		$charset = null;
@@ -1135,7 +1265,10 @@  discard block
 block discarded – undo
1135 1265
 				if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null,
1136 1266
 					false, 0, $this->caldav->current_user_principal, $user, $charset)))
1137 1267
 				{
1138
-					if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false");
1268
+					if ($this->debug)
1269
+					{
1270
+						error_log(__METHOD__."() importVCal($eventId) returned false");
1271
+					}
1139 1272
 				}
1140 1273
 				header('ETag: "'.$this->get_etag($eventId).'"');
1141 1274
 			}
@@ -1303,7 +1436,10 @@  discard block
 block discarded – undo
1303 1436
 		$org_recurrences = $exceptions = array();
1304 1437
 		foreach(self::get_series($events[0]['uid'],$bo) as $k => $event)
1305 1438
 		{
1306
-			if (!$k) $master = $event;
1439
+			if (!$k)
1440
+			{
1441
+				$master = $event;
1442
+			}
1307 1443
 			if ($event['recurrence'])
1308 1444
 			{
1309 1445
 				$org_recurrences[$event['recurrence']] = $event;
@@ -1323,10 +1459,13 @@  discard block
 block discarded – undo
1323 1459
 
1324 1460
 			// from now on we deal with exceptions
1325 1461
 			$org_recurrence = $org_recurrences[$recurrence['recurrence']];
1326
-			if (isset($org_recurrence))	// already existing recurrence
1462
+			if (isset($org_recurrence))
1463
+			{
1464
+				// already existing recurrence
1327 1465
 			{
1328 1466
 				//error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']);
1329 1467
 				$recurrence['id'] = $org_recurrence['id'];
1468
+			}
1330 1469
 
1331 1470
 				// re-add (non-virtual) exceptions to master's recur_exception
1332 1471
 				if ($recurrence['id'] != $master['id'])
@@ -1343,10 +1482,14 @@  discard block
 block discarded – undo
1343 1482
 		// delete not longer existing recurrences
1344 1483
 		foreach($org_recurrences as $org_recurrence)
1345 1484
 		{
1346
-			if ($org_recurrence['id'] != $master['id'])	// non-virtual recurrence
1485
+			if ($org_recurrence['id'] != $master['id'])
1486
+			{
1487
+				// non-virtual recurrence
1347 1488
 			{
1348 1489
 				//error_log(__METHOD__.'() deleting #'.$org_recurrence['id']);
1349
-				$bo->delete($org_recurrence['id']);	// might fail because of permissions
1490
+				$bo->delete($org_recurrence['id']);
1491
+			}
1492
+			// might fail because of permissions
1350 1493
 			}
1351 1494
 			else	// virtual recurrence
1352 1495
 			{
@@ -1424,9 +1567,14 @@  discard block
 block discarded – undo
1424 1567
 		else
1425 1568
 		{
1426 1569
 			$ret = $this->bo->delete($event['id']);
1427
-			if (!$ret) { error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event';}
1570
+			if (!$ret)
1571
+			{
1572
+error_log("delete($event[id]) returned FALSE"); $ret = '400 Failed to delete event';}
1573
+		}
1574
+		if ($this->debug)
1575
+		{
1576
+			error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1428 1577
 		}
1429
-		if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret));
1430 1578
 		return $ret;
1431 1579
 	}
1432 1580
 
@@ -1441,16 +1589,26 @@  discard block
 block discarded – undo
1441 1589
 	 */
1442 1590
 	function read($id)
1443 1591
 	{
1444
-		if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column;
1592
+		if (strpos($column=self::$path_attr,'_') === false)
1593
+		{
1594
+			$column = 'cal_'.$column;
1595
+		}
1445 1596
 
1446 1597
 		$event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server');
1447
-		if ($event) $event = array_shift($event);	// read with array as 1. param, returns an array of events!
1598
+		if ($event)
1599
+		{
1600
+			$event = array_shift($event);
1601
+		}
1602
+		// read with array as 1. param, returns an array of events!
1448 1603
 
1449 1604
 		if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) &&
1450 1605
 			// above can be true, if current user is not in master but just a recurrence
1451 1606
 			(!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo))))
1452 1607
 		{
1453
-			if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1608
+			if ($this->debug > 0)
1609
+			{
1610
+				error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval));
1611
+			}
1454 1612
 			return $retval;
1455 1613
 		}
1456 1614
 		if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server'))
@@ -1458,9 +1616,15 @@  discard block
 block discarded – undo
1458 1616
 			$this->bo->clear_private_infos($event, array($this->bo->user, $event['owner']));
1459 1617
 		}
1460 1618
 		// handle deleted events, as not existing
1461
-		if ($event['deleted']) $event = null;
1619
+		if ($event['deleted'])
1620
+		{
1621
+			$event = null;
1622
+		}
1462 1623
 
1463
-		if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event));
1624
+		if ($this->debug > 1)
1625
+		{
1626
+			error_log(__METHOD__."($id) returning ".array2string($event));
1627
+		}
1464 1628
 
1465 1629
 		return $event;
1466 1630
 	}
@@ -1472,7 +1636,10 @@  discard block
 block discarded – undo
1472 1636
 	 */
1473 1637
 	public function update_tags($entry)
1474 1638
 	{
1475
-		if (!is_array($entry)) $entry = $this->read($entry);
1639
+		if (!is_array($entry))
1640
+		{
1641
+			$entry = $this->read($entry);
1642
+		}
1476 1643
 
1477 1644
 		$this->bo->update($entry, true);
1478 1645
 	}
@@ -1486,7 +1653,10 @@  discard block
 block discarded – undo
1486 1653
 	{
1487 1654
 		$ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected
1488 1655
 
1489
-		if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1656
+		if ($this->debug > 1)
1657
+		{
1658
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag");
1659
+		}
1490 1660
 
1491 1661
 		return $ctag;
1492 1662
 	}
@@ -1616,7 +1786,10 @@  discard block
 block discarded – undo
1616 1786
 		$handler = new calendar_ical();
1617 1787
 		$handler->setSupportedFields('GroupDAV',$this->agent);
1618 1788
 		$handler->supportedFields['attachments'] = true;	// enabling attachments
1619
-		if ($this->debug > 1) error_log("ical Handler called: " . $this->agent);
1789
+		if ($this->debug > 1)
1790
+		{
1791
+			error_log("ical Handler called: " . $this->agent);
1792
+		}
1620 1793
 		return $handler;
1621 1794
 	}
1622 1795
 
@@ -1687,7 +1860,11 @@  discard block
 block discarded – undo
1687 1860
 			{
1688 1861
 				$calendars[$entry['grantor']] = $entry['name'];
1689 1862
 			}
1690
-			if ($user > 0) unset($calendars[$user]);	// skip current user
1863
+			if ($user > 0)
1864
+			{
1865
+				unset($calendars[$user]);
1866
+			}
1867
+			// skip current user
1691 1868
 		}
1692 1869
 
1693 1870
 		$settings = array();
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 1 patch
Spacing   +308 added lines, -310 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
19 19
 {
20
-	define('ACL_TYPE_IDENTIFER','***ACL***');
20
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
21 21
 }
22 22
 
23
-define('HOUR_s',60*60);
24
-define('DAY_s',24*HOUR_s);
25
-define('WEEK_s',7*DAY_s);
23
+define('HOUR_s', 60 * 60);
24
+define('DAY_s', 24 * HOUR_s);
25
+define('WEEK_s', 7 * DAY_s);
26 26
 
27 27
 /**
28 28
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
72 72
 	 *	5 = function-calls to private functions
73 73
 	 */
74
-	var $debug=false;
74
+	var $debug = false;
75 75
 
76 76
 	/**
77 77
 	 * @var int $now timestamp in server-time
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var int $user nummerical id of the current user-id
103 103
 	 */
104
-	var $user=0;
104
+	var $user = 0;
105 105
 
106 106
 	/**
107 107
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
108 108
 	 */
109
-	var $grants=array();
109
+	var $grants = array();
110 110
 
111 111
 	/**
112 112
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	function __construct()
221 221
 	{
222
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
222
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
223 223
 
224 224
 		$this->so = new calendar_so();
225 225
 
226
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
227
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
226
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
227
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
228 228
 
229 229
 		$this->now = time();
230
-		$this->now_su = Api\DateTime::server2user($this->now,'ts');
230
+		$this->now_su = Api\DateTime::server2user($this->now, 'ts');
231 231
 
232 232
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
237 237
 		{
238 238
 			$this->resources = array();
239
-			foreach(Api\Hooks::process('calendar_resources') as $app => $data)
239
+			foreach (Api\Hooks::process('calendar_resources') as $app => $data)
240 240
 			{
241 241
 				if ($data && $data['type'])
242 242
 				{
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 				'app'  => 'email',
250 250
 			);
251 251
 			$this->resources['l'] = array(
252
-				'type' => 'l',// one char type-identifier for this resources
253
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
252
+				'type' => 'l', // one char type-identifier for this resources
253
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
254 254
 				'app' => 'Distribution list'
255 255
 			);
256 256
 			$this->resources[''] = array(
@@ -261,14 +261,14 @@  discard block
 block discarded – undo
261 261
 		}
262 262
 		//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
263 263
 
264
-		$this->config = Api\Config::read('calendar');	// only used for horizont, regular calendar config is under phpgwapi
264
+		$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
265 265
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
266 266
 
267
-		$this->categories = new Api\Categories($this->user,'calendar');
267
+		$this->categories = new Api\Categories($this->user, 'calendar');
268 268
 
269 269
 		$this->customfields = Api\Storage\Customfields::get('calendar');
270 270
 
271
-		foreach($this->alarms as $secs => &$label)
271
+		foreach ($this->alarms as $secs => &$label)
272 272
 		{
273 273
 			$label = self::secs2label($secs);
274 274
 		}
@@ -284,15 +284,15 @@  discard block
 block discarded – undo
284 284
 	{
285 285
 		if ($secs <= 3600)
286 286
 		{
287
-			$label = lang('%1 minutes', $secs/60);
287
+			$label = lang('%1 minutes', $secs / 60);
288 288
 		}
289
-		elseif($secs <= 86400)
289
+		elseif ($secs <= 86400)
290 290
 		{
291
-			$label = lang('%1 hours', $secs/3600);
291
+			$label = lang('%1 hours', $secs / 3600);
292 292
 		}
293 293
 		else
294 294
 		{
295
-			$label = lang('%1 days', $secs/86400);
295
+			$label = lang('%1 days', $secs / 86400);
296 296
 		}
297 297
 		return $label;
298 298
 	}
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 		if (!$ids) return null;
309 309
 
310 310
 		$data = array();
311
-		foreach((array)$ids as $id)
311
+		foreach ((array)$ids as $id)
312 312
 		{
313 313
 			$email = $id;
314 314
 			$name = '';
315 315
 			$matches = null;
316
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
316
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
317 317
 			{
318 318
 				$name = $matches[1];
319 319
 				$email = $matches[2];
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$data[] = array(
322 322
 				'res_id' => $id,
323 323
 				'email' => $email,
324
-				'rights' => self::ACL_READ_FOR_PARTICIPANTS | self::ACL_INVITE,
324
+				'rights' => self::ACL_READ_FOR_PARTICIPANTS|self::ACL_INVITE,
325 325
 				'name' => $name,
326 326
 			);
327 327
 		}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	static function mailing_lists($ids)
339 339
 	{
340
-		if(!is_array($ids))
340
+		if (!is_array($ids))
341 341
 		{
342 342
 			$ids = array($ids);
343 343
 		}
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		// Email list
347 347
 		$contacts_obj = new Api\Contacts();
348 348
 		$bo = new calendar_bo();
349
-		foreach($ids as $id)
349
+		foreach ($ids as $id)
350 350
 		{
351 351
 			$list = $contacts_obj->read_list((int)$id);
352 352
 
@@ -373,22 +373,22 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @return array
375 375
 	 */
376
-	public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true)
376
+	public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true)
377 377
 	{
378 378
 		$contact_list = array();
379 379
 		$contacts = new Api\Contacts();
380
-		if($contacts->check_list((int)substr($id,1), ACL::READ) || (int)substr($id,1) < 0)
380
+		if ($contacts->check_list((int)substr($id, 1), ACL::READ) || (int)substr($id, 1) < 0)
381 381
 		{
382
-			$options = array('list' => substr($id,1));
383
-			$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
384
-			if(!$lists)
382
+			$options = array('list' => substr($id, 1));
383
+			$lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options);
384
+			if (!$lists)
385 385
 			{
386 386
 				return $contact_list;
387 387
 			}
388
-			foreach($lists as &$contact)
388
+			foreach ($lists as &$contact)
389 389
 			{
390 390
 				// Check for user account
391
-				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'],'person_id')))
391
+				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'], 'person_id')))
392 392
 				{
393 393
 					$contact = ''.$account_id;
394 394
 				}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
 				{
397 397
 					$contact = 'c'.$contact['id'];
398 398
 				}
399
-				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
399
+				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $contact))
400 400
 				{
401
-					if ($contact && !in_array($contact,$contact_list))	// already added?
401
+					if ($contact && !in_array($contact, $contact_list))	// already added?
402 402
 					{
403 403
 						$contact_list[] = $contact;
404 404
 					}
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 	function enum_groups(&$event)
418 418
 	{
419 419
 		$added = 0;
420
-		foreach(array_keys($event['participants']) as $uid)
420
+		foreach (array_keys($event['participants']) as $uid)
421 421
 		{
422 422
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
423 423
 				($members = $GLOBALS['egw']->accounts->members($uid, true)))
424 424
 			{
425
-				foreach($members as $member)
425
+				foreach ($members as $member)
426 426
 				{
427 427
 					if (!isset($event['participants'][$member]))
428 428
 					{
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
445 445
 	 * @return array of user-ids
446 446
 	 */
447
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
447
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
448 448
 	{
449 449
 		if (!is_array($_users))
450 450
 		{
@@ -452,35 +452,35 @@  discard block
 block discarded – undo
452 452
 		}
453 453
 		// only query calendars of users, we have READ-grants from
454 454
 		$users = array();
455
-		foreach($_users as $user)
455
+		foreach ($_users as $user)
456 456
 		{
457 457
 			$user = trim($user);
458 458
 
459 459
 			// Handle email lists
460
-			if(!is_numeric($user) && $user[0] == 'l')
460
+			if (!is_numeric($user) && $user[0] == 'l')
461 461
 			{
462
-				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
462
+				foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
463 463
 				{
464
-					if ($contact && !in_array($contact,$users))	// already added?
464
+					if ($contact && !in_array($contact, $users))	// already added?
465 465
 					{
466 466
 						$users[] = $contact;
467 467
 					}
468 468
 				}
469 469
 				continue;
470 470
 			}
471
-			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
471
+			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $user))
472 472
 			{
473
-				if ($user && !in_array($user,$users))	// already added?
473
+				if ($user && !in_array($user, $users))	// already added?
474 474
 				{
475 475
 					// General expansion check
476 476
 					if (!is_numeric($user) && $this->resources[$user[0]]['info'])
477 477
 					{
478 478
 						$info = $this->resource_info($user);
479
-						if($info && $info['resources'])
479
+						if ($info && $info['resources'])
480 480
 						{
481
-							foreach($info['resources'] as $_user)
481
+							foreach ($info['resources'] as $_user)
482 482
 							{
483
-								if($_user && !in_array($_user, $users))
483
+								if ($_user && !in_array($_user, $users))
484 484
 								{
485 485
 									$users[] = $_user;
486 486
 								}
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 			}
494 494
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
495 495
 			{
496
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
496
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
497 497
 			}
498 498
 			// the further code is only for real users
499 499
 			if (!is_numeric($user)) continue;
@@ -506,11 +506,11 @@  discard block
 block discarded – undo
506 506
 				$members = $GLOBALS['egw']->accounts->members($user, true);
507 507
 				if (is_array($members))
508 508
 				{
509
-					foreach($members as $member)
509
+					foreach ($members as $member)
510 510
 					{
511 511
 						// use only members which gave the user a read-grant
512 512
 						if (!in_array($member, $users) &&
513
-							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
513
+							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ?self::ACL_FREEBUSY : 0), 0, $member)))
514 514
 						{
515 515
 							$users[] = $member;
516 516
 						}
@@ -522,9 +522,9 @@  discard block
 block discarded – undo
522 522
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
523 523
 				if (is_array($memberships))
524 524
 				{
525
-					foreach($memberships as $group)
525
+					foreach ($memberships as $group)
526 526
 					{
527
-						if (!in_array($group,$users))
527
+						if (!in_array($group, $users))
528 528
 						{
529 529
 							$users[] = $group;
530 530
 						}
@@ -567,18 +567,18 @@  discard block
 block discarded – undo
567 567
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
568 568
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
569 569
 	 */
570
-	function &search($params,$sql_filter=null)
570
+	function &search($params, $sql_filter = null)
571 571
 	{
572 572
 		$params_in = $params;
573 573
 
574
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
574
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
575 575
 
576 576
 		// check if any resource wants to hook into
577
-		foreach($this->resources as $data)
577
+		foreach ($this->resources as $data)
578 578
 		{
579 579
 			if (isset($data['search_filter']))
580 580
 			{
581
-				$params = ExecMethod($data['search_filter'],$params);
581
+				$params = ExecMethod($data['search_filter'], $params);
582 582
 			}
583 583
 		}
584 584
 
@@ -591,18 +591,18 @@  discard block
 block discarded – undo
591 591
 		// resolve users to add memberships for users and members for groups
592 592
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
593 593
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
594
-		if($params['private_allowed'])
594
+		if ($params['private_allowed'])
595 595
 		{
596
-			$params['private_allowed'] = $this->resolve_users($params['private_allowed'],$params['filter'] == 'no-enum-groups',$params['ignore_acl'], empty($params['query']));
596
+			$params['private_allowed'] = $this->resolve_users($params['private_allowed'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
597 597
 		}
598 598
 
599 599
 		// supply so with private_grants, to not query them again from the database
600 600
 		if (!empty($params['query']))
601 601
 		{
602 602
 			$params['private_grants'] = array();
603
-			foreach($this->grants as $user => $rights)
603
+			foreach ($this->grants as $user => $rights)
604 604
 			{
605
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
605
+				if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user;
606 606
 			}
607 607
 		}
608 608
 
@@ -628,49 +628,49 @@  discard block
 block discarded – undo
628 628
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
629 629
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
630 630
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
631
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
631
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
632 632
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
633 633
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
634 634
 		$users_in = (array)$params_in['users'];
635
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
635
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
636 636
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
637 637
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
638 638
 
639 639
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
640 640
 		{
641 641
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
642
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
642
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
643 643
 		}
644 644
 		// date2ts(,true) converts to server time, db2data converts again to user-time
645
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
646
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
645
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
646
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
647 647
 
648 648
 		if (isset($params['cols']))
649 649
 		{
650 650
 			return $events;
651 651
 		}
652 652
 		$this->total = $this->so->total;
653
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
653
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
654 654
 
655 655
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
656
-		foreach($events as $id => $event)
656
+		foreach ($events as $id => $event)
657 657
 		{
658 658
 			if ($params['enum_groups'] && $this->enum_groups($event))
659 659
 			{
660 660
 				$events[$id] = $event;
661 661
 			}
662 662
 			$matches = null;
663
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
663
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
664 664
 			{
665
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
665
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
666 666
 			}
667 667
 			else
668 668
 			{
669
-				$is_private = !$this->check_perms(Acl::READ,$event);
669
+				$is_private = !$this->check_perms(Acl::READ, $event);
670 670
 			}
671 671
 			if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate')))
672 672
 			{
673
-				$this->clear_private_infos($events[$id],$params['private_allowed'] ? $params['private_allowed'] : $users);
673
+				$this->clear_private_infos($events[$id], $params['private_allowed'] ? $params['private_allowed'] : $users);
674 674
 			}
675 675
 		}
676 676
 
@@ -678,18 +678,18 @@  discard block
 block discarded – undo
678 678
 		{
679 679
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
680 680
 			{
681
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
681
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
682 682
 			}
683 683
 			// create empty entries for each day in the reported time
684
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
684
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
685 685
 			{
686 686
 				$daysEvents[$this->date2string($ts)] = array();
687 687
 			}
688
-			foreach($events as $k => $event)
688
+			foreach ($events as $k => $event)
689 689
 			{
690
-				$e_start = max($this->date2ts($event['start']),$start);
690
+				$e_start = max($this->date2ts($event['start']), $start);
691 691
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
692
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
692
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
693 693
 
694 694
 				// add event to each day in the reported time
695 695
 				$ts = $e_start;
@@ -698,23 +698,23 @@  discard block
 block discarded – undo
698 698
 				$ymd = null;
699 699
 				while ($ts <= $e_end)
700 700
 				{
701
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
702
-					$ts = strtotime("+1 day",$ts);
701
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
702
+					$ts = strtotime("+1 day", $ts);
703 703
 				}
704 704
 				if ($ymd != ($last = $this->date2string($e_end)))
705 705
 				{
706
-					$daysEvents[$last][] =& $events[$k];
706
+					$daysEvents[$last][] = & $events[$k];
707 707
 				}
708 708
 			}
709
-			$events =& $daysEvents;
709
+			$events = & $daysEvents;
710 710
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
711 711
 			{
712
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
712
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
713 713
 			}
714 714
 		}
715 715
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
716 716
 		{
717
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
717
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
718 718
 		}
719 719
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
720 720
 		return $events;
@@ -727,9 +727,9 @@  discard block
 block discarded – undo
727 727
 	 * @param string $part
728 728
 	 * @return array
729 729
 	 */
730
-	static function integration_get_data($app,$part=null)
730
+	static function integration_get_data($app, $part = null)
731 731
 	{
732
-		static $integration_data=null;
732
+		static $integration_data = null;
733 733
 
734 734
 		if (!isset($integration_data))
735 735
 		{
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
 	 * @param int|string $id
752 752
 	 * @return string
753 753
 	 */
754
-	static function integration_get_private($app,$id,$event)
754
+	static function integration_get_private($app, $id, $event)
755 755
 	{
756
-		$app_data = self::integration_get_data($app,'is_private');
756
+		$app_data = self::integration_get_data($app, 'is_private');
757 757
 
758 758
 		// no method, fall back to link title
759 759
 		if (is_null($app_data))
760 760
 		{
761
-			$is_private = !Link::title($app,$id);
761
+			$is_private = !Link::title($app, $id);
762 762
 		}
763 763
 		// boolean value to make all events of $app public (false) or private (true)
764 764
 		elseif (is_bool($app_data))
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 		}
768 768
 		else
769 769
 		{
770
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
770
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
771 771
 		}
772 772
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
773 773
 		return $is_private;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 	 * @param array &$event
782 782
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
783 783
 	 */
784
-	function clear_private_infos(&$event,$allowed_participants = array())
784
+	function clear_private_infos(&$event, $allowed_participants = array())
785 785
 	{
786 786
 		if ($event == false) return;
787 787
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -797,19 +797,19 @@  discard block
 block discarded – undo
797 797
 			'owner'		=> $event['owner'],
798 798
 			'uid'	=> $event['uid'],
799 799
 			'etag'	=> $event['etag'],
800
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
800
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
801 801
 			'public'=> 0,
802
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
802
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
803 803
 			'non_blocking' => $event['non_blocking'],
804 804
 			'caldav_name' => $event['caldav_name'],
805 805
 		// we need full recurrence information, as they are relevant free/busy information
806
-		)+($event['recur_type'] ? array(
806
+		) + ($event['recur_type'] ? array(
807 807
 			'recur_type'     => $event['recur_type'],
808 808
 			'recur_interval' => $event['recur_interval'],
809 809
 			'recur_data'     => $event['recur_data'],
810 810
 			'recur_enddate'  => $event['recur_enddate'],
811 811
 			'recur_exception'=> $event['recur_exception'],
812
-		):array(
812
+		) : array(
813 813
 			'reference'      => $event['reference'],
814 814
 			'recurrence'     => $event['recurrence'],
815 815
 		));
@@ -823,15 +823,15 @@  discard block
 block discarded – undo
823 823
 	 */
824 824
 	function check_move_horizont($_new_horizont)
825 825
 	{
826
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
826
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
827 827
 		{
828
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
828
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
829 829
 		}
830
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
830
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
831 831
 
832 832
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
833 833
 		{
834
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
834
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']);
835 835
 			return;
836 836
 		}
837 837
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -839,15 +839,15 @@  discard block
 block discarded – undo
839 839
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
840 840
 		}
841 841
 		if (empty($maxdays)) $maxdays = 1000; // old default
842
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
842
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
843 843
 		{
844
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
845
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
844
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays);
845
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays);
846 846
 			return;
847 847
 		}
848
-		if ($new_horizont < time()+31*DAY_s)
848
+		if ($new_horizont < time() + 31 * DAY_s)
849 849
 		{
850
-			$new_horizont = time()+31*DAY_s;
850
+			$new_horizont = time() + 31 * DAY_s;
851 851
 		}
852 852
 		$old_horizont = $this->config['horizont'];
853 853
 		$this->config['horizont'] = $new_horizont;
@@ -855,21 +855,21 @@  discard block
 block discarded – undo
855 855
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
856 856
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
857 857
 		{
858
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
859
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
858
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
859
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
860 860
 			{
861 861
 				if ($this->debug == 'check_move_horizont')
862 862
 				{
863
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
863
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
864 864
 				}
865 865
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
866
-				$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
866
+				$this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
867 867
 			}
868 868
 		}
869 869
 		// update the horizont
870
-		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
870
+		Api\Config::save_value('horizont', $this->config['horizont'], 'calendar');
871 871
 
872
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
872
+		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']);
873 873
 	}
874 874
 
875 875
 	/**
@@ -880,11 +880,11 @@  discard block
 block discarded – undo
880 880
 	 * @param array $event
881 881
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
882 882
 	 */
883
-	function set_recurrences($event,$start=0)
883
+	function set_recurrences($event, $start = 0)
884 884
 	{
885
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
885
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
886 886
 		{
887
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
887
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
888 888
 		}
889 889
 		// check if the caller gave us enough information and if not read it from the DB
890 890
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -904,29 +904,29 @@  discard block
 block discarded – undo
904 904
 
905 905
 		$events = array();
906 906
 
907
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
907
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
908 908
 
909 909
 		$exceptions = array();
910
-		foreach((array)$event['recur_exception'] as $exception)
910
+		foreach ((array)$event['recur_exception'] as $exception)
911 911
 		{
912
-			$exceptions[] = Api\DateTime::to($exception, true);	// true = date
912
+			$exceptions[] = Api\DateTime::to($exception, true); // true = date
913 913
 		}
914
-		foreach($events as $event)
914
+		foreach ($events as $event)
915 915
 		{
916 916
 			$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
917
-			$start = $this->date2ts($event['start'],true);
917
+			$start = $this->date2ts($event['start'], true);
918 918
 			if ($event['whole_day'])
919 919
 			{
920 920
 				$start = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
921
-				$start->setTime(0,0,0);
921
+				$start->setTime(0, 0, 0);
922 922
 				$start = $start->format('ts');
923 923
 				$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
924 924
 				$time->setTime(23, 59, 59);
925
-				$end = $this->date2ts($time,true);
925
+				$end = $this->date2ts($time, true);
926 926
 			}
927 927
 			else
928 928
 			{
929
-				$end = $this->date2ts($event['end'],true);
929
+				$end = $this->date2ts($event['end'], true);
930 930
 			}
931 931
 			//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
932 932
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 	 * @param array &$events array of event-arrays (reference)
943 943
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
944 944
 	 */
945
-	function db2data(&$events,$date_format='ts')
945
+	function db2data(&$events, $date_format = 'ts')
946 946
 	{
947 947
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
948 948
 		foreach ($events as &$event)
@@ -955,65 +955,65 @@  discard block
 block discarded – undo
955 955
 			// database returns timestamps as string, convert them to integer
956 956
 			// to avoid misinterpretation by Api\DateTime as Ymd string
957 957
 			// (this will fail on 32bit systems for times > 2038!)
958
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls Api\DateTime
958
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
959 959
 			$event['end'] = (int)$event['end'];
960 960
 			$event['whole_day'] = self::isWholeDay($event);
961 961
 			if ($event['whole_day'] && $date_format != 'server')
962 962
 			{
963 963
 				// Adjust dates to user TZ
964
-				$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
964
+				$stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
965 965
 				$event['start'] = Api\DateTime::to($stime, $date_format);
966
-				$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
966
+				$time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
967 967
 				$time->setTime(23, 59, 59);
968 968
 				$event['end'] = Api\DateTime::to($time, $date_format);
969 969
 				if (!empty($event['recurrence']))
970 970
 				{
971
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
971
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
972 972
 					$event['recurrence'] = Api\DateTime::to($time, $date_format);
973 973
 				}
974 974
 				if (!empty($event['recur_enddate']))
975 975
 				{
976
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
976
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
977 977
 					$time->setTime(23, 59, 59);
978 978
 					$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
979 979
 				}
980
-				$timestamps = array('modified','created','deleted');
980
+				$timestamps = array('modified', 'created', 'deleted');
981 981
 			}
982 982
 			else
983 983
 			{
984
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date','deleted');
984
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date', 'deleted');
985 985
 			}
986 986
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
987 987
 			foreach ($timestamps as $ts)
988 988
 			{
989 989
 				if (!empty($event[$ts]))
990 990
 				{
991
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
991
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
992 992
 				}
993 993
 			}
994 994
 			// same with the recur exceptions
995 995
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
996 996
 			{
997
-				foreach($event['recur_exception'] as &$date)
997
+				foreach ($event['recur_exception'] as &$date)
998 998
 				{
999 999
 					if ($event['whole_day'] && $date_format != 'server')
1000 1000
 					{
1001 1001
 						// Adjust dates to user TZ
1002
-						$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1002
+						$time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1003 1003
 						$date = Api\DateTime::to($time, $date_format);
1004 1004
 					}
1005 1005
 					else
1006 1006
 					{
1007
-						$date = $this->date2usertime((int)$date,$date_format);
1007
+						$date = $this->date2usertime((int)$date, $date_format);
1008 1008
 					}
1009 1009
 				}
1010 1010
 			}
1011 1011
 			// same with the alarms
1012 1012
 			if (isset($event['alarm']) && is_array($event['alarm']))
1013 1013
 			{
1014
-				foreach($event['alarm'] as &$alarm)
1014
+				foreach ($event['alarm'] as &$alarm)
1015 1015
 				{
1016
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
1016
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
1017 1017
 				}
1018 1018
 			}
1019 1019
 		}
@@ -1026,11 +1026,11 @@  discard block
 block discarded – undo
1026 1026
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
1027 1027
 	 * @return mixed depending of $date_format
1028 1028
 	 */
1029
-	function date2usertime($ts,$date_format='ts')
1029
+	function date2usertime($ts, $date_format = 'ts')
1030 1030
 	{
1031 1031
 		if (empty($ts) || $date_format == 'server') return $ts;
1032 1032
 
1033
-		return Api\DateTime::server2user($ts,$date_format);
1033
+		return Api\DateTime::server2user($ts, $date_format);
1034 1034
 	}
1035 1035
 
1036 1036
 	/**
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	 * @param boolean $read_recurrence =false true: read the exception, not the series master (only for recur_date && $ids='<uid>'!)
1046 1046
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
1047 1047
 	 */
1048
-	function read($ids,$date=null, $ignore_acl=False, $date_format='ts', $clear_private_infos_users=null, $read_recurrence=false)
1048
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null, $read_recurrence = false)
1049 1049
 	{
1050 1050
 		if (!$ids) return false;
1051 1051
 
@@ -1054,21 +1054,21 @@  discard block
 block discarded – undo
1054 1054
 		$return = null;
1055 1055
 
1056 1056
 		$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
1057
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
1057
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
1058 1058
 		{
1059 1059
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
1060 1060
 				self::$cached_event_date_format != $date_format || $read_recurrence ||
1061 1061
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
1062 1062
 			{
1063
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0, $read_recurrence);
1063
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0, $read_recurrence);
1064 1064
 
1065 1065
 				if ($events)
1066 1066
 				{
1067
-					$this->db2data($events,$date_format);
1067
+					$this->db2data($events, $date_format);
1068 1068
 
1069 1069
 					if (is_array($ids))
1070 1070
 					{
1071
-						$return =& $events;
1071
+						$return = & $events;
1072 1072
 					}
1073 1073
 					else
1074 1074
 					{
@@ -1084,13 +1084,13 @@  discard block
 block discarded – undo
1084 1084
 				$return = self::$cached_event;
1085 1085
 			}
1086 1086
 		}
1087
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
1087
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return))
1088 1088
 		{
1089 1089
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
1090 1090
 		}
1091 1091
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
1092 1092
 		{
1093
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
1093
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
1094 1094
 		}
1095 1095
 		return $return;
1096 1096
 	}
@@ -1108,17 +1108,17 @@  discard block
 block discarded – undo
1108 1108
 	 * @param array $events where the repetions get inserted
1109 1109
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
1110 1110
 	 */
1111
-	function insert_all_recurrences($event,$_start,$end,&$events)
1111
+	function insert_all_recurrences($event, $_start, $end, &$events)
1112 1112
 	{
1113
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1113
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1114 1114
 		{
1115
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
1115
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
1116 1116
 		}
1117 1117
 		$end_in = $end;
1118 1118
 
1119 1119
 		$start = $this->date2ts($_start);
1120 1120
 		$event_start_ts = $this->date2ts($event['start']);
1121
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
1121
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
1122 1122
 
1123 1123
 		// if $end is before recur_enddate, use it instead
1124 1124
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1127,40 +1127,39 @@  discard block
 block discarded – undo
1127 1127
 			// insert at least the event itself, if it's behind the horizont
1128 1128
 			$event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end;
1129 1129
 		}
1130
-		$event['recur_enddate'] = is_a($event['recur_enddate'],'DateTime') ?
1131
-				$event['recur_enddate'] :
1132
-				new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1130
+		$event['recur_enddate'] = is_a($event['recur_enddate'], 'DateTime') ?
1131
+				$event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1133 1132
 
1134 1133
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1135 1134
 		unset($event['recur_exception']);
1136 1135
 		// loop over all recurrences and insert them, if they are after $start
1137
- 		$rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName());	// true = we operate in usertime, like the rest of calendar_bo
1138
-		foreach($rrule as $time)
1136
+ 		$rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo
1137
+		foreach ($rrule as $time)
1139 1138
 		{
1140
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1141
-			if($event['whole_day'])
1139
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1140
+			if ($event['whole_day'])
1142 1141
 			{
1143 1142
 				// All day events are processed in server timezone
1144 1143
 				$time->setServer();
1145
-				$time->setTime(0,0,0);
1144
+				$time->setTime(0, 0, 0);
1146 1145
 			}
1147
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1146
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1148 1147
 			{
1149 1148
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1150
-				continue;	// to early or original event (returned by interator too)
1149
+				continue; // to early or original event (returned by interator too)
1151 1150
 			}
1152 1151
 
1153 1152
 			$ts_end = $ts + $event_length;
1154 1153
 			// adjust ts_end for whole day events in case it does not fit due to
1155 1154
 			// spans over summer/wintertime adjusted days
1156
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1155
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1157 1156
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1158 1157
 			{
1159 1158
 				$arr_end['hour'] = 23;
1160 1159
 				$arr_end['minute'] = 59;
1161 1160
 				$arr_end['second'] = 59;
1162 1161
 				$ts_end_guess = $this->date2ts($arr_end);
1163
-				if($ts_end_guess - $ts_end > DAY_s/2)
1162
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1164 1163
 				{
1165 1164
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1166 1165
 				}
@@ -1174,11 +1173,11 @@  discard block
 block discarded – undo
1174 1173
 			$event['end'] = $ts_end;
1175 1174
 			$events[] = $event;
1176 1175
 		}
1177
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1176
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1178 1177
 		{
1179 1178
 			$event['start'] = $event_start_ts;
1180 1179
 			$event['end'] = $event_start_ts + $event_length;
1181
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1180
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1182 1181
 		}
1183 1182
 	}
1184 1183
 
@@ -1189,18 +1188,18 @@  discard block
 block discarded – undo
1189 1188
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1190 1189
 	 * @param int|string $date_ymd of the date of the event
1191 1190
 	 */
1192
-	function add_adjusted_event(&$events,$event,$date_ymd)
1191
+	function add_adjusted_event(&$events, $event, $date_ymd)
1193 1192
 	{
1194 1193
 		$event_in = $event;
1195 1194
 		// calculate the new start- and end-time
1196 1195
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1197 1196
 		$event_start_arr = $this->date2array($event['start']);
1198 1197
 
1199
-		$date_arr = $this->date2array((string) $date_ymd);
1198
+		$date_arr = $this->date2array((string)$date_ymd);
1200 1199
 		$date_arr['hour'] = $event_start_arr['hour'];
1201 1200
 		$date_arr['minute'] = $event_start_arr['minute'];
1202 1201
 		$date_arr['second'] = $event_start_arr['second'];
1203
-		unset($date_arr['raw']);	// else date2ts would use it
1202
+		unset($date_arr['raw']); // else date2ts would use it
1204 1203
 		$event['start'] = $this->date2ts($date_arr);
1205 1204
 		$event['end'] = $event['start'] + $length_s;
1206 1205
 
@@ -1208,7 +1207,7 @@  discard block
 block discarded – undo
1208 1207
 
1209 1208
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1210 1209
 		{
1211
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1210
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1212 1211
 		}
1213 1212
 	}
1214 1213
 
@@ -1232,22 +1231,22 @@  discard block
 block discarded – undo
1232 1231
 			{
1233 1232
 				$info = array(
1234 1233
 					'res_id'    => $uid,
1235
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1236
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1237
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1234
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1235
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1236
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1238 1237
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1239 1238
 					'app'   => 'accounts',
1240 1239
 				);
1241 1240
 			}
1242 1241
 			else
1243 1242
 			{
1244
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1243
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1245 1244
 				if ($info)
1246 1245
 				{
1247 1246
 					$info['type'] = $uid[0];
1248 1247
 					if (!$info['email'] && $info['responsible'])
1249 1248
 					{
1250
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1249
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1251 1250
 					}
1252 1251
 					$info['app'] = $this->resources[$uid[0]]['app'];
1253 1252
 				}
@@ -1256,7 +1255,7 @@  discard block
 block discarded – undo
1256 1255
 		}
1257 1256
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1258 1257
 		{
1259
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1258
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1260 1259
 		}
1261 1260
 		return $res_info_cache[$uid];
1262 1261
 	}
@@ -1277,7 +1276,7 @@  discard block
 block discarded – undo
1277 1276
 	 * @param int $user =null for which user to check, default current user
1278 1277
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1279 1278
 	 */
1280
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1279
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1281 1280
 	{
1282 1281
 		if (!$user) $user = $this->user;
1283 1282
 		if ($user == $this->user)
@@ -1286,13 +1285,13 @@  discard block
 block discarded – undo
1286 1285
 		}
1287 1286
 		else
1288 1287
 		{
1289
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1288
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1290 1289
 		}
1291 1290
 
1292 1291
 		if ($other && !is_numeric($other))
1293 1292
 		{
1294 1293
 			$resource = $this->resource_info($other);
1295
-			return $needed & $resource['rights'];
1294
+			return $needed&$resource['rights'];
1296 1295
 		}
1297 1296
 		if (is_int($event) && $event == 0)
1298 1297
 		{
@@ -1302,15 +1301,15 @@  discard block
 block discarded – undo
1302 1301
 		{
1303 1302
 			if (!is_array($event))
1304 1303
 			{
1305
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1304
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1306 1305
 			}
1307 1306
 			if (!is_array($event))
1308 1307
 			{
1309 1308
 				if ($this->xmlrpc)
1310 1309
 				{
1311
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1310
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1312 1311
 				}
1313
-				return null;	// event not found
1312
+				return null; // event not found
1314 1313
 			}
1315 1314
 			$owner = $event['owner'];
1316 1315
 			$private = !$event['public'];
@@ -1318,7 +1317,7 @@  discard block
 block discarded – undo
1318 1317
 		$grant = $grants[$owner];
1319 1318
 
1320 1319
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1321
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1320
+		if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1322 1321
 
1323 1322
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1324 1323
 		{
@@ -1327,18 +1326,18 @@  discard block
 block discarded – undo
1327 1326
 			//
1328 1327
 			if ($event['participants'] && is_array($event['participants']))
1329 1328
 			{
1330
-				foreach(array_keys($event['participants']) as $uid)
1329
+				foreach (array_keys($event['participants']) as $uid)
1331 1330
 				{
1332
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1331
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1333 1332
 					{
1334 1333
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1335
-						$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
1334
+						$grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT;
1336 1335
 						break;
1337 1336
 					}
1338
-					elseif ($grants[$uid] & Acl::READ)
1337
+					elseif ($grants[$uid]&Acl::READ)
1339 1338
 					{
1340 1339
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1341
-						$grant |= self::ACL_FREEBUSY | Acl::READ;
1340
+						$grant |= self::ACL_FREEBUSY|Acl::READ;
1342 1341
 						// we cant break here, as we might be a participant too, and would miss the privat grant
1343 1342
 					}
1344 1343
 					elseif (!is_numeric($uid))
@@ -1354,12 +1353,12 @@  discard block
 block discarded – undo
1354 1353
 		}
1355 1354
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
1356 1355
 		{
1357
-			$access = False;	// a group can't be the owner of an event
1356
+			$access = False; // a group can't be the owner of an event
1358 1357
 		}
1359 1358
 		else
1360 1359
 		{
1361
-			$access = $user == $owner || $grant & $needed
1362
-				&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
1360
+			$access = $user == $owner || $grant&$needed
1361
+				&& ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT);
1363 1362
 		}
1364 1363
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1365 1364
 		if ($access && $needed == Acl::DELETE && $event['deleted'] &&
@@ -1370,7 +1369,7 @@  discard block
 block discarded – undo
1370 1369
 		}
1371 1370
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1372 1371
 		{
1373
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1372
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1374 1373
 		}
1375 1374
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1376 1375
 		return $access;
@@ -1385,9 +1384,9 @@  discard block
 block discarded – undo
1385 1384
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1386 1385
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1387 1386
 	 */
1388
-	static function date2ts($date,$user2server=False)
1387
+	static function date2ts($date, $user2server = False)
1389 1388
 	{
1390
-		return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
1389
+		return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts');
1391 1390
 	}
1392 1391
 
1393 1392
 	/**
@@ -1397,9 +1396,9 @@  discard block
 block discarded – undo
1397 1396
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1398 1397
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1399 1398
 	 */
1400
-	static function date2array($date,$server2user=False)
1399
+	static function date2array($date, $server2user = False)
1401 1400
 	{
1402
-		return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
1401
+		return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array');
1403 1402
 	}
1404 1403
 
1405 1404
 	/**
@@ -1410,9 +1409,9 @@  discard block
 block discarded – undo
1410 1409
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1411 1410
 	 * @return string date formatted according to $format
1412 1411
 	 */
1413
-	static function date2string($date,$server2user=False,$format='Ymd')
1412
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1414 1413
 	{
1415
-		return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
1414
+		return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format);
1416 1415
 	}
1417 1416
 
1418 1417
 	/**
@@ -1422,9 +1421,9 @@  discard block
 block discarded – undo
1422 1421
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1423 1422
 	 * @return string the formated date (incl. time)
1424 1423
 	 */
1425
-	static function format_date($date,$format='')
1424
+	static function format_date($date, $format = '')
1426 1425
 	{
1427
-		return Api\DateTime::to($date,$format);
1426
+		return Api\DateTime::to($date, $format);
1428 1427
 	}
1429 1428
 
1430 1429
 	/**
@@ -1446,7 +1445,7 @@  discard block
 block discarded – undo
1446 1445
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1447 1446
 	 *	arrays get serialized with print_r() !
1448 1447
 	 */
1449
-	static function debug_message($msg,$backtrace=True)
1448
+	static function debug_message($msg, $backtrace = True)
1450 1449
 	{
1451 1450
 		static $acl2string = array(
1452 1451
 			0               => 'ACL-UNKNOWN',
@@ -1457,22 +1456,22 @@  discard block
 block discarded – undo
1457 1456
 			Acl::PRIVAT => 'ACL_PRIVATE',
1458 1457
 			self::ACL_FREEBUSY => 'ACL_FREEBUSY',
1459 1458
 		);
1460
-		for($i = 2; $i < func_num_args(); ++$i)
1459
+		for ($i = 2; $i < func_num_args(); ++$i)
1461 1460
 		{
1462 1461
 			$param = func_get_arg($i);
1463 1462
 
1464 1463
 			if (is_null($param))
1465 1464
 			{
1466
-				$param='NULL';
1465
+				$param = 'NULL';
1467 1466
 			}
1468 1467
 			else
1469 1468
 			{
1470
-				switch(gettype($param))
1469
+				switch (gettype($param))
1471 1470
 				{
1472 1471
 					case 'string':
1473
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1472
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1474 1473
 						{
1475
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1474
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1476 1475
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1477 1476
 						}
1478 1477
 						else
@@ -1495,11 +1494,11 @@  discard block
 block discarded – undo
1495 1494
 						$param = $param ? 'True' : 'False';
1496 1495
 						break;
1497 1496
 					case 'integer':
1498
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1497
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1499 1498
 						break;
1500 1499
 				}
1501 1500
 			}
1502
-			$msg = str_replace('%'.($i-1),$param,$msg);
1501
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1503 1502
 		}
1504 1503
 		error_log($msg);
1505 1504
 		if ($backtrace) error_log(function_backtrace(1));
@@ -1514,7 +1513,7 @@  discard block
 block discarded – undo
1514 1513
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1515 1514
 	 * @return string with formated date
1516 1515
 	 */
1517
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1516
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1518 1517
 	{
1519 1518
 		$first = $this->date2array($_first);
1520 1519
 		if ($last)
@@ -1529,27 +1528,27 @@  discard block
 block discarded – undo
1529 1528
 
1530 1529
 		if ($display_day)
1531 1530
 		{
1532
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1531
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1533 1532
 		}
1534 1533
 		for ($i = 0; $i < 5; $i += 2)
1535 1534
 		{
1536
-			switch($datefmt[$i])
1535
+			switch ($datefmt[$i])
1537 1536
 			{
1538 1537
 				case 'd':
1539
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1538
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1540 1539
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1541 1540
 					{
1542 1541
 						if (!$month_before_day)
1543 1542
 						{
1544
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1543
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1545 1544
 						}
1546 1545
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1547 1546
 						{
1548
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1547
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1549 1548
 						}
1550 1549
 						if ($display_time)
1551 1550
 						{
1552
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1551
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1553 1552
 						}
1554 1553
 						if (!$last)
1555 1554
 						{
@@ -1559,43 +1558,43 @@  discard block
 block discarded – undo
1559 1558
 
1560 1559
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1561 1560
 						{
1562
-							$range .= $last['year'] . ', ';
1561
+							$range .= $last['year'].', ';
1563 1562
 						}
1564 1563
 
1565 1564
 						if ($month_before_day)
1566 1565
 						{
1567
-							$range .= lang(strftime('%B',$last['raw']));
1566
+							$range .= lang(strftime('%B', $last['raw']));
1568 1567
 						}
1569 1568
 					}
1570 1569
 					else
1571 1570
 					{
1572 1571
 						if ($display_time)
1573 1572
 						{
1574
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1573
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1575 1574
 						}
1576 1575
 						$range .= ' - ';
1577 1576
 					}
1578
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1577
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1579 1578
 					break;
1580 1579
 				case 'm':
1581 1580
 				case 'M':
1582
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1581
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1583 1582
 					break;
1584 1583
 				case 'Y':
1585 1584
 					if ($datefmt[0] != 'm')
1586 1585
 					{
1587
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1586
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1588 1587
 					}
1589 1588
 					break;
1590 1589
 			}
1591 1590
 		}
1592 1591
 		if ($display_time && $last)
1593 1592
 		{
1594
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1593
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1595 1594
 		}
1596 1595
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1597 1596
 		{
1598
-			$range .= ', ' . $last['year'];
1597
+			$range .= ', '.$last['year'];
1599 1598
 		}
1600 1599
 		return $range;
1601 1600
 	}
@@ -1607,25 +1606,25 @@  discard block
 block discarded – undo
1607 1606
 	 * @param int $end_m end time in minutes since 0h
1608 1607
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1609 1608
 	 */
1610
-	function timespan($start_m,$end_m,$both=false)
1609
+	function timespan($start_m, $end_m, $both = false)
1611 1610
 	{
1612 1611
 		$duration = $end_m - $start_m;
1613
-		if ($end_m == 24*60-1) ++$duration;
1614
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1612
+		if ($end_m == 24 * 60 - 1) ++$duration;
1613
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1615 1614
 
1616
-		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1615
+		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false);
1617 1616
 
1618 1617
 		if ($both)	// end-time too
1619 1618
 		{
1620
-			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1619
+			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false);
1621 1620
 			// dont double am/pm if they are the same in both times
1622
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1621
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1623 1622
 			{
1624
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1623
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1625 1624
 			}
1626 1625
 			$timespan .= ':';
1627 1626
 		}
1628
-		return $timespan . ' ' . $duration;
1627
+		return $timespan.' '.$duration;
1629 1628
 	}
1630 1629
 
1631 1630
 	/**
@@ -1636,7 +1635,7 @@  discard block
 block discarded – undo
1636 1635
 	* @param boolean $append_email =false append email (Name <email>)
1637 1636
 	* @return string with name
1638 1637
 	*/
1639
-	function participant_name($id,$use_type=false, $append_email=false)
1638
+	function participant_name($id, $use_type = false, $append_email = false)
1640 1639
 	{
1641 1640
 		static $id2lid = array();
1642 1641
 		static $id2email = array();
@@ -1657,7 +1656,7 @@  discard block
 block discarded – undo
1657 1656
 			else
1658 1657
 			{
1659 1658
 				$id2lid[$id] = Api\Accounts::username($id);
1660
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1659
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1661 1660
 			}
1662 1661
 		}
1663 1662
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1671,37 +1670,37 @@  discard block
 block discarded – undo
1671 1670
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1672 1671
 	* @return array with id / names with status pairs
1673 1672
 	*/
1674
-	function participants($event,$long_status=false,$show_group_invitation=false)
1673
+	function participants($event, $long_status = false, $show_group_invitation = false)
1675 1674
 	{
1676 1675
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1677 1676
 		$names = array();
1678
-		foreach((array)$event['participants'] as $id => $status)
1677
+		foreach ((array)$event['participants'] as $id => $status)
1679 1678
 		{
1680 1679
 			if (!is_string($status)) continue;
1681 1680
 			$quantity = $role = null;
1682
-			calendar_so::split_status($status,$quantity,$role);
1681
+			calendar_so::split_status($status, $quantity, $role);
1683 1682
 
1684
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1683
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1685 1684
 
1686 1685
 			$lang_status = lang($this->verbose_status[$status]);
1687 1686
 			if (!$long_status)
1688 1687
 			{
1689
-				switch($status[0])
1688
+				switch ($status[0])
1690 1689
 				{
1691 1690
 					case 'A':	// accepted
1692
-						$status = Api\Html::image('calendar','accepted',$lang_status);
1691
+						$status = Api\Html::image('calendar', 'accepted', $lang_status);
1693 1692
 						break;
1694 1693
 					case 'R':	// rejected
1695
-						$status = Api\Html::image('calendar','rejected',$lang_status);
1694
+						$status = Api\Html::image('calendar', 'rejected', $lang_status);
1696 1695
 						break;
1697 1696
 					case 'T':	// tentative
1698
-						$status = Api\Html::image('calendar','tentative',$lang_status);
1697
+						$status = Api\Html::image('calendar', 'tentative', $lang_status);
1699 1698
 						break;
1700 1699
 					case 'U':	// no response = unknown
1701
-						$status = Api\Html::image('calendar','needs-action',$lang_status);
1700
+						$status = Api\Html::image('calendar', 'needs-action', $lang_status);
1702 1701
 						break;
1703 1702
 					case 'D':	// delegated
1704
-						$status = Api\Html::image('calendar','forward',$lang_status);
1703
+						$status = Api\Html::image('calendar', 'forward', $lang_status);
1705 1704
 						break;
1706 1705
 					case 'G':	// group invitation
1707 1706
 						// Todo: Image, seems not to be used
@@ -1723,13 +1722,13 @@  discard block
 block discarded – undo
1723 1722
 					$role = lang($this->roles[$role]);
1724 1723
 				}
1725 1724
 				// allow to use cats as roles (beside regular iCal ones)
1726
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1725
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1727 1726
 				{
1728 1727
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1729 1728
 				}
1730 1729
 				else
1731 1730
 				{
1732
-					$role = lang(str_replace('X-','',$role));
1731
+					$role = lang(str_replace('X-', '', $role));
1733 1732
 				}
1734 1733
 				$names[$id] .= ' '.$role;
1735 1734
 			}
@@ -1746,13 +1745,13 @@  discard block
 block discarded – undo
1746 1745
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1747 1746
 	* @return array with id / names
1748 1747
 	*/
1749
-	function categories($category,&$color)
1748
+	function categories($category, &$color)
1750 1749
 	{
1751 1750
 		static $id2cat = array();
1752 1751
 		$cats = array();
1753 1752
 		$color = 0;
1754 1753
 
1755
-		foreach(explode(',',$category) as $cat_id)
1754
+		foreach (explode(',', $category) as $cat_id)
1756 1755
 		{
1757 1756
 			if (!$cat_id) continue;
1758 1757
 
@@ -1767,7 +1766,7 @@  discard block
 block discarded – undo
1767 1766
 			{
1768 1767
 				$color = $cat['data']['color'];
1769 1768
 			}
1770
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1769
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1771 1770
 			{
1772 1771
 				$color = $parts[1];
1773 1772
 			}
@@ -1779,12 +1778,12 @@  discard block
 block discarded – undo
1779 1778
 	/**
1780 1779
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1781 1780
 	 */
1782
-	private static function _list_cals_add($id,&$users,&$groups)
1781
+	private static function _list_cals_add($id, &$users, &$groups)
1783 1782
 	{
1784 1783
 		$name = Api\Accounts::username($id);
1785 1784
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1786 1785
 		{
1787
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1786
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1788 1787
 		}
1789 1788
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1790 1789
 		{
@@ -1796,7 +1795,7 @@  discard block
 block discarded – undo
1796 1795
 		}
1797 1796
 		$arr[$id] = array(
1798 1797
 			'grantor' => $id,
1799
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1798
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1800 1799
 			'name'    => $name,
1801 1800
 			'sname'	  => $egw_name
1802 1801
 		);
@@ -1818,26 +1817,26 @@  discard block
 block discarded – undo
1818 1817
 	 * @param int $user account_id of user to generate list for
1819 1818
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1820 1819
 	 */
1821
-	public static function list_calendars($user, array $grants=null)
1820
+	public static function list_calendars($user, array $grants = null)
1822 1821
 	{
1823 1822
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1824 1823
 
1825 1824
 		$users = $groups = array();
1826
-		foreach(array_keys($grants) as $id)
1825
+		foreach (array_keys($grants) as $id)
1827 1826
 		{
1828
-			self::_list_cals_add($id,$users,$groups);
1827
+			self::_list_cals_add($id, $users, $groups);
1829 1828
 		}
1830 1829
 		if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true)))
1831 1830
 		{
1832
-			foreach($memberships as $group)
1831
+			foreach ($memberships as $group)
1833 1832
 			{
1834
-				self::_list_cals_add($group,$users,$groups);
1833
+				self::_list_cals_add($group, $users, $groups);
1835 1834
 
1836
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
1835
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar')))
1837 1836
 				{
1838
-					foreach($account_perms as $id)
1837
+					foreach ($account_perms as $id)
1839 1838
 					{
1840
-						self::_list_cals_add($id,$users,$groups);
1839
+						self::_list_cals_add($id, $users, $groups);
1841 1840
 					}
1842 1841
 				}
1843 1842
 			}
@@ -1845,7 +1844,7 @@  discard block
 block discarded – undo
1845 1844
 		usort($users, array(__CLASS__, 'name_cmp'));
1846 1845
 		usort($groups, array(__CLASS__, 'name_cmp'));
1847 1846
 
1848
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1847
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1849 1848
 	}
1850 1849
 
1851 1850
 	/**
@@ -1885,43 +1884,42 @@  discard block
 block discarded – undo
1885 1884
 	 *	month: numerical month
1886 1885
 	 *	occurence: numerical year or 0 for every year
1887 1886
 	 */
1888
-	function read_holidays($year=0)
1887
+	function read_holidays($year = 0)
1889 1888
 	{
1890
-		if (!$year) $year = (int) date('Y',$this->now_su);
1889
+		if (!$year) $year = (int)date('Y', $this->now_su);
1891 1890
 
1892 1891
 		$holidays = calendar_holidays::read(
1893 1892
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
1894
-				$GLOBALS['egw_info']['server']['ical_holiday_url'] :
1895
-				$GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1893
+				$GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1896 1894
 
1897 1895
 		// search for birthdays
1898 1896
 		if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
1899 1897
 		{
1900 1898
 			$contacts = new Api\Contacts();
1901
-			foreach($contacts->get_addressbooks() as $owner => $name)
1899
+			foreach ($contacts->get_addressbooks() as $owner => $name)
1902 1900
 			{
1903 1901
 				$birthdays = $contacts->read_birthdays($owner, $year);
1904 1902
 
1905 1903
 				// Add them in, being careful not to override any existing
1906
-				foreach($birthdays as $date => $bdays)
1904
+				foreach ($birthdays as $date => $bdays)
1907 1905
 				{
1908
-					if(!array_key_exists($date, $holidays))
1906
+					if (!array_key_exists($date, $holidays))
1909 1907
 					{
1910 1908
 						$holidays[$date] = array();
1911 1909
 					}
1912
-					foreach($bdays as $birthday)
1910
+					foreach ($bdays as $birthday)
1913 1911
 					{
1914 1912
 						// Skip if name / date are already there - duplicate contacts
1915
-						if(in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue;
1913
+						if (in_array($birthday['name'], array_column($holidays[$date], 'name'))) continue;
1916 1914
 						$holidays[$date][] = $birthday;
1917 1915
 					}
1918 1916
 				}
1919 1917
 			}
1920 1918
 		}
1921 1919
 
1922
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1920
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1923 1921
 		{
1924
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$holidays);
1922
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $holidays);
1925 1923
 		}
1926 1924
 		return $holidays;
1927 1925
 	}
@@ -1932,10 +1930,10 @@  discard block
 block discarded – undo
1932 1930
 	 * @param type $event
1933 1931
 	 * @return array array of selected calendar fields
1934 1932
 	 */
1935
-	public static function get_link_options ($event = array())
1933
+	public static function get_link_options($event = array())
1936 1934
 	{
1937
-		unset($event);	// not used, but required by function signature
1938
-		$options = array (
1935
+		unset($event); // not used, but required by function signature
1936
+		$options = array(
1939 1937
 			'end' => lang('End date'),
1940 1938
 			'id' => lang('ID'),
1941 1939
 			'owner' => lang('Owner'),
@@ -1962,7 +1960,7 @@  discard block
 block discarded – undo
1962 1960
 			list($id, $recur) = explode('-', $event, 2);
1963 1961
 			$event = $this->read($id, $recur);
1964 1962
 		}
1965
-		else if (!is_array($event) && (int) $event > 0)
1963
+		else if (!is_array($event) && (int)$event > 0)
1966 1964
 		{
1967 1965
 			$event = $this->read($event);
1968 1966
 		}
@@ -1970,7 +1968,7 @@  discard block
 block discarded – undo
1970 1968
 		{
1971 1969
 			return $event;
1972 1970
 		}
1973
-		$type = explode(',',$this->cal_prefs['link_title']);
1971
+		$type = explode(',', $this->cal_prefs['link_title']);
1974 1972
 		if (is_array($type))
1975 1973
 		{
1976 1974
 			foreach ($type as &$val)
@@ -1999,10 +1997,10 @@  discard block
 block discarded – undo
1999 1997
 						$extra_fields [] = $event[$val];
2000 1998
 				}
2001 1999
 			}
2002
-			$str_fields = implode(', ',$extra_fields);
2003
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2000
+			$str_fields = implode(', ', $extra_fields);
2001
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
2004 2002
 		}
2005
-		return $this->format_date($event['start']) . ': ' . $event['title'];
2003
+		return $this->format_date($event['start']).': '.$event['title'];
2006 2004
 	}
2007 2005
 
2008 2006
 	/**
@@ -2021,10 +2019,10 @@  discard block
 block discarded – undo
2021 2019
 			'offset' =>	$options['start'],
2022 2020
 			'order' => 'cal_start DESC',
2023 2021
 		);
2024
-		if($options['num_rows']) {
2022
+		if ($options['num_rows']) {
2025 2023
 			$query['num_rows'] = $options['num_rows'];
2026 2024
 		}
2027
-		foreach((array) $this->search($query) as $event)
2025
+		foreach ((array)$this->search($query) as $event)
2028 2026
 		{
2029 2027
 			$result[$event['id']] = $this->link_title($event);
2030 2028
 		}
@@ -2041,11 +2039,11 @@  discard block
 block discarded – undo
2041 2039
 	 * @param int $user =null for which user to check, default current user
2042 2040
 	 * @return boolean true if access is granted or false otherwise
2043 2041
 	 */
2044
-	function file_access($id,$check,$rel_path,$user=null)
2042
+	function file_access($id, $check, $rel_path, $user = null)
2045 2043
 	{
2046
-		unset($rel_path);	// not used, but required by function signature
2044
+		unset($rel_path); // not used, but required by function signature
2047 2045
 
2048
-		return $this->check_perms($check,$id,0,'ts',null,$user);
2046
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
2049 2047
 	}
2050 2048
 
2051 2049
 	/**
@@ -2061,36 +2059,36 @@  discard block
 block discarded – undo
2061 2059
 		}
2062 2060
 		Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
2063 2061
 
2064
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
2065
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
2062
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
2063
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
2066 2064
 
2067
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
2065
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
2068 2066
 		$values = array(
2069
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
2070
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
2071
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
2072
-			'notifyDisinvited'=> $subject . lang ('You have been uninvited from the meeting at %1','$$startdate$$'),
2073
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
2074
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
2067
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
2068
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
2069
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
2070
+			'notifyDisinvited'=> $subject.lang('You have been uninvited from the meeting at %1', '$$startdate$$'),
2071
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
2072
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
2075 2073
 			'interval'        => 30,
2076 2074
 		);
2077
-		foreach($values as $var => $default)
2075
+		foreach ($values as $var => $default)
2078 2076
 		{
2079
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
2077
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
2080 2078
 
2081 2079
 			// only set, if neither default nor forced pref exists
2082 2080
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2083 2081
 			{
2084
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2085
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2082
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
2083
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
2086 2084
 				$this->cal_prefs[$var] = $default;
2087 2085
 				$need_save = True;
2088 2086
 			}
2089 2087
 		}
2090 2088
 		if ($need_save)
2091 2089
 		{
2092
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
2093
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
2090
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
2091
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
2094 2092
 		}
2095 2093
 	}
2096 2094
 
@@ -2100,7 +2098,7 @@  discard block
 block discarded – undo
2100 2098
 	 * @param int|string $user account_id or account_lid
2101 2099
 	 * @param string $pw =null password
2102 2100
 	 */
2103
-	static function freebusy_url($user='',$pw=null)
2101
+	static function freebusy_url($user = '', $pw = null)
2104 2102
 	{
2105 2103
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2106 2104
 
@@ -2113,8 +2111,8 @@  discard block
 block discarded – undo
2113 2111
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
2114 2112
 		{
2115 2113
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2116
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2117
-			$credentials = '&cred=' . base64_encode($credentials);
2114
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2115
+			$credentials = '&cred='.base64_encode($credentials);
2118 2116
 		}
2119 2117
 		return Api\Framework::getUrl($GLOBALS['egw_info']['server']['webserver_url']).
2120 2118
 			'/calendar/freebusy.php/?user='.urlencode($user).$credentials;
@@ -2145,11 +2143,11 @@  discard block
 block discarded – undo
2145 2143
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2146 2144
 	 * @return string|boolean string with etag or false
2147 2145
 	 */
2148
-	function get_etag($entry, &$schedule_tag=null)
2146
+	function get_etag($entry, &$schedule_tag = null)
2149 2147
 	{
2150 2148
 		if (!is_array($entry))
2151 2149
 		{
2152
-			list($id,$recur_date) = explode(':',$entry);
2150
+			list($id, $recur_date) = explode(':', $entry);
2153 2151
 			$entry = $this->read($id, $recur_date, true, 'server');
2154 2152
 		}
2155 2153
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2167,15 +2165,15 @@  discard block
 block discarded – undo
2167 2165
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2168 2166
 	 * @return integer
2169 2167
 	 */
2170
-	public function get_ctag($user, $filter='owner', $master_only=false)
2168
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2171 2169
 	{
2172 2170
 		if ($this->debug > 1) $startime = microtime(true);
2173 2171
 
2174 2172
 		// resolve users to add memberships for users and members for groups
2175 2173
 		$users = $this->resolve_users($user);
2176
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2174
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2177 2175
 
2178
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2176
+		if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs");
2179 2177
 		return $ctag;
2180 2178
 	}
2181 2179
 
@@ -2195,7 +2193,7 @@  discard block
 block discarded – undo
2195 2193
 
2196 2194
 		$content = array(
2197 2195
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
2198
-			'info_priority'  => $calendar['priority'] ,
2196
+			'info_priority'  => $calendar['priority'],
2199 2197
 			'info_public'    => $calendar['public'] != 'private',
2200 2198
 			'info_subject'   => $calendar['title'],
2201 2199
 			'info_des'       => $calendar['description'],
@@ -2210,7 +2208,7 @@  discard block
 block discarded – undo
2210 2208
 		$content['link_app'][] = $calendar['info_link']['app'];
2211 2209
 		$content['link_id'][]  = $calendar['info_link']['id'];
2212 2210
 		// Copy claendar's links
2213
-		foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2211
+		foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2214 2212
 		{
2215 2213
 			if ($link['app'] != Link::VFS_APPNAME)
2216 2214
 			{
@@ -2223,7 +2221,7 @@  discard block
 block discarded – undo
2223 2221
 			}
2224 2222
 		}
2225 2223
 		// Copy same custom fields
2226
-		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2224
+		foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2227 2225
 		{
2228 2226
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2229 2227
 		}
@@ -2241,20 +2239,20 @@  discard block
 block discarded – undo
2241 2239
 	function timesheet_set($data)
2242 2240
 	{
2243 2241
 		$set = array();
2244
-		list($id,$recurrence) = explode(':',$data['id']);
2245
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2242
+		list($id, $recurrence) = explode(':', $data['id']);
2243
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2246 2244
 		{
2247 2245
 			$set['ts_start'] = $event['start'];
2248 2246
 			$set['ts_title'] = $this->link_title($event);
2249
-			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2247
+			$set['start_time'] = Api\DateTime::to($event['start'], 'H:i');
2250 2248
 			$set['ts_description'] = $event['description'];
2251
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2249
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2252 2250
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2253 2251
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2254
-			$set['end_time'] = null;	// unset end-time
2252
+			$set['end_time'] = null; // unset end-time
2255 2253
 			$set['cat_id'] = (int)$event['category'];
2256 2254
 
2257
-			foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2255
+			foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2258 2256
 			{
2259 2257
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
2260 2258
 				{
Please login to merge, or discard this patch.