Completed
Push — 16.1 ( 4b9eb7...a61395 )
by Ralf
40:21 queued 20:29
created
calendar/inc/class.calendar_ical.inc.php 1 patch
Braces   +321 added lines, -82 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 	function __construct(&$_clientProperties = array())
184 184
 	{
185 185
 		parent::__construct();
186
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
186
+		if ($this->log)
187
+		{
188
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
189
+		}
187 190
 		$this->clientProperties = $_clientProperties;
188 191
 		$this->vCalendar = new Horde_Icalendar;
189 192
 		$this->addressbook = new Api\Contacts;
@@ -232,10 +235,14 @@  discard block
 block discarded – undo
232 235
 			'ATTACH'        => 'attachments',
233 236
 		);
234 237
 
235
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
238
+		if (!is_array($this->supportedFields))
239
+		{
240
+			$this->setSupportedFields();
241
+		}
236 242
 
237 243
 		if ($this->productManufacturer == '' )
238
-		{	// syncevolution is broken
244
+		{
245
+// syncevolution is broken
239 246
 			$version = '2.0';
240 247
 		}
241 248
 
@@ -243,10 +250,16 @@  discard block
 block discarded – undo
243 250
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
244 251
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
245 252
 		$vcal->setAttribute('VERSION', $version);
246
-		if ($method) $vcal->setAttribute('METHOD', $method);
253
+		if ($method)
254
+		{
255
+			$vcal->setAttribute('METHOD', $method);
256
+		}
247 257
 		$events_exported = false;
248 258
 
249
-		if (!is_array($events)) $events = array($events);
259
+		if (!is_array($events))
260
+		{
261
+			$events = array($events);
262
+		}
250 263
 
251 264
 		$vtimezones_added = array();
252 265
 		foreach ($events as $event)
@@ -312,7 +325,10 @@  discard block
 block discarded – undo
312 325
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
313 326
 			}
314 327
 
315
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
328
+			if ($this->so->isWholeDay($event))
329
+			{
330
+				$event['whole_day'] = true;
331
+			}
316 332
 
317 333
 			if ($this->log)
318 334
 			{
@@ -323,7 +339,10 @@  discard block
 block discarded – undo
323 339
 
324 340
 			if ($recurrence)
325 341
 			{
326
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
342
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
343
+				{
344
+					continue;
345
+				}
327 346
 
328 347
 				if (!isset($this->supportedFields['participants']))
329 348
 				{
@@ -380,7 +399,8 @@  discard block
 block discarded – undo
380 399
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
381 400
 			{
382 401
 				// Append UID to DESCRIPTION
383
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
402
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
403
+				{
384 404
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
385 405
 				}
386 406
 			}
@@ -440,11 +460,21 @@  discard block
 block discarded – undo
440 460
 							$quantity = $role = null;
441 461
 							calendar_so::split_status($status, $quantity, $role);
442 462
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
443
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
463
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
464
+							{
465
+								continue;
466
+							}
444 467
 
445
-							if (!($info = $this->resource_info($uid))) continue;
468
+							if (!($info = $this->resource_info($uid)))
469
+							{
470
+								continue;
471
+							}
446 472
 
447
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
473
+							if (in_array($status, array('X','E')))
474
+							{
475
+								continue;
476
+							}
477
+							// dont include deleted participants
448 478
 
449 479
 							if ($this->log)
450 480
 							{
@@ -523,24 +553,49 @@  discard block
 block discarded – undo
523 553
 							}
524 554
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
525 555
 							$options = array();
526
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
527
-							if (!empty($role)) $options['ROLE'] = $role;
528
-							if (!empty($status)) $options['PARTSTAT'] = $status;
529
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
530
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
556
+							if (!empty($participantCN))
557
+							{
558
+								$options['CN'] = $participantCN;
559
+							}
560
+							if (!empty($role))
561
+							{
562
+								$options['ROLE'] = $role;
563
+							}
564
+							if (!empty($status))
565
+							{
566
+								$options['PARTSTAT'] = $status;
567
+							}
568
+							if (!empty($cutype))
569
+							{
570
+								$options['CUTYPE'] = $cutype;
571
+							}
572
+							if (!empty($rsvp))
573
+							{
574
+								$options['RSVP'] = $rsvp;
575
+							}
531 576
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
532 577
 							{
533 578
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
534 579
 							}
535
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
536
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
580
+							if ($info['type'] != 'e')
581
+							{
582
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
583
+							}
584
+							if ($quantity > 1)
585
+							{
586
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
587
+							}
537 588
 							$attributes['ATTENDEE'][] = $participantURL;
538 589
 							$parameters['ATTENDEE'][] = $options;
539 590
 						}
540 591
 						break;
541 592
 
542 593
 					case 'CLASS':
543
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
594
+						if ($event['public'])
595
+						{
596
+							continue;
597
+						}
598
+						// public is default, no need to export, fails CalDAVTester if added as default
544 599
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
545 600
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
546 601
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -572,9 +627,18 @@  discard block
 block discarded – undo
572 627
 									'CUTYPE'   => 'INDIVIDUAL',
573 628
 									//'RSVP'     => 'FALSE',
574 629
 									);
575
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
576
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
577
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
630
+								if (!empty($organizerCN))
631
+								{
632
+									$options['CN'] = $organizerCN;
633
+								}
634
+								if (!empty($organizerEMail))
635
+								{
636
+									$options['EMAIL'] = $organizerEMail;
637
+								}
638
+								if (!empty($event['owner']))
639
+								{
640
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
641
+								}
578 642
 								$attributes['ATTENDEE'][] = $organizerURL;
579 643
 			    				$parameters['ATTENDEE'][] = $options;
580 644
 		    				}
@@ -603,9 +667,12 @@  discard block
 block discarded – undo
603 667
 						{
604 668
 							// Hack for CalDAVTester to export duration instead of endtime
605 669
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
606
-								$attributes['duration'] = $event['end'] - $event['start'];
607
-							else
608
-								$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
670
+							{
671
+															$attributes['duration'] = $event['end'] - $event['start'];
672
+							}
673
+							else {
674
+															$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
675
+							}
609 676
 						}
610 677
 						else
611 678
 						{
@@ -625,7 +692,11 @@  discard block
 block discarded – undo
625 692
 						break;
626 693
 
627 694
 					case 'RRULE':
628
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
695
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
696
+						{
697
+							break;
698
+						}
699
+						// no recuring event
629 700
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
630 701
 						$rrule = $rriter->generate_rrule($version);
631 702
 						if ($event['recur_enddate'])
@@ -667,7 +738,10 @@  discard block
 block discarded – undo
667 738
 						break;
668 739
 
669 740
 					case 'EXDATE':
670
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
741
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
742
+						{
743
+							break;
744
+						}
671 745
 						if (!empty($event['recur_exception']))
672 746
 						{
673 747
 							if (empty($event['whole_day']))
@@ -694,14 +768,21 @@  discard block
 block discarded – undo
694 768
 									);
695 769
 								}
696 770
 								$event['recur_exception'] = $days;
697
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
771
+								if ($version != '1.0')
772
+								{
773
+									$parameters['EXDATE']['VALUE'] = 'DATE';
774
+								}
698 775
 							}
699 776
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
700 777
 						}
701 778
 						break;
702 779
 
703 780
 					case 'PRIORITY':
704
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
781
+						if (!$event['priority'])
782
+						{
783
+							continue;
784
+						}
785
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
705 786
 						if ($this->productManufacturer == 'funambol' &&
706 787
 							(strpos($this->productName, 'outlook') !== false
707 788
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -715,7 +796,11 @@  discard block
 block discarded – undo
715 796
 						break;
716 797
 
717 798
 					case 'TRANSP':
718
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
799
+						if (!$event['non_blocking'])
800
+						{
801
+							continue;
802
+						}
803
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
719 804
 						if ($version == '1.0')
720 805
 						{
721 806
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -772,7 +857,11 @@  discard block
 block discarded – undo
772 857
 						elseif ($event['recurrence'] && $event['reference'])
773 858
 						{
774 859
 							// $event['reference'] is a calendar_id, not a timestamp
775
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
860
+							if (!($revent = $this->read($event['reference'])))
861
+							{
862
+								break;
863
+							}
864
+							// referenced event does not exist
776 865
 
777 866
 							if (empty($revent['whole_day']))
778 867
 							{
@@ -898,7 +987,10 @@  discard block
 block discarded – undo
898 987
 			foreach ((array)$event['alarm'] as $alarmData)
899 988
 			{
900 989
 				// skip over alarms that don't have the minimum required info
901
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
990
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
991
+				{
992
+					continue;
993
+				}
902 994
 
903 995
 				// skip alarms not being set for all users and alarms owned by other users
904 996
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -915,7 +1007,10 @@  discard block
 block discarded – undo
915 1007
 
916 1008
 				if ($version == '1.0')
917 1009
 				{
918
-					if ($event['title']) $description = $event['title'];
1010
+					if ($event['title'])
1011
+					{
1012
+						$description = $event['title'];
1013
+					}
919 1014
 					if ($description)
920 1015
 					{
921 1016
 						$values['DALARM']['snooze_time'] = '';
@@ -935,7 +1030,10 @@  discard block
 block discarded – undo
935 1030
 					// VCalendar 2.0 / RFC 2445
936 1031
 
937 1032
 					// RFC requires DESCRIPTION for DISPLAY
938
-					if (!$event['title'] && !$description) $description = 'Alarm';
1033
+					if (!$event['title'] && !$description)
1034
+					{
1035
+						$description = 'Alarm';
1036
+					}
939 1037
 
940 1038
 					/* Disabling for now
941 1039
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1126,13 +1224,20 @@  discard block
 block discarded – undo
1126 1224
 		$this->events_imported = 0;
1127 1225
 		$replace = $delete_exceptions= false;
1128 1226
 
1129
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1227
+		if (!is_array($this->supportedFields))
1228
+		{
1229
+			$this->setSupportedFields();
1230
+		}
1130 1231
 
1131 1232
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1132 1233
 		{
1133 1234
 			return false;
1134 1235
 		}
1135
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1236
+		if (!is_array($events))
1237
+		{
1238
+			$cal_id = -1;
1239
+		}
1240
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1136 1241
 
1137 1242
 		if ($cal_id > 0)
1138 1243
 		{
@@ -1140,8 +1245,14 @@  discard block
 block discarded – undo
1140 1245
 			{
1141 1246
 				$replace = $recur_date == 0;
1142 1247
 				$events[0]['id'] = $cal_id;
1143
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1144
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1248
+				if (!is_null($etag))
1249
+				{
1250
+					$events[0]['etag'] = (int) $etag;
1251
+				}
1252
+				if ($recur_date)
1253
+				{
1254
+					$events[0]['recurrence'] = $recur_date;
1255
+				}
1145 1256
 			}
1146 1257
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1147 1258
 					($eventId = array_shift($foundEvent)) &&
@@ -1149,7 +1260,10 @@  discard block
 block discarded – undo
1149 1260
 			{
1150 1261
 				foreach ($events as $k => $event)
1151 1262
 				{
1152
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1263
+					if (!isset($event['uid']))
1264
+					{
1265
+						$events[$k]['uid'] = $egwEvent['uid'];
1266
+					}
1153 1267
 				}
1154 1268
 			}
1155 1269
 		}
@@ -1179,10 +1293,17 @@  discard block
 block discarded – undo
1179 1293
 		$msg = null;
1180 1294
 		foreach ($events as $event)
1181 1295
 		{
1182
-			if (!is_array($event)) continue; // the iterator may return false
1296
+			if (!is_array($event))
1297
+			{
1298
+				continue;
1299
+			}
1300
+			// the iterator may return false
1183 1301
 			++$this->events_imported;
1184 1302
 
1185
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1303
+			if ($this->so->isWholeDay($event))
1304
+			{
1305
+				$event['whole_day'] = true;
1306
+			}
1186 1307
 			if (is_array($event['category']))
1187 1308
 			{
1188 1309
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1219,7 +1340,10 @@  discard block
 block discarded – undo
1219 1340
 						}
1220 1341
 						else
1221 1342
 						{
1222
-							if (!($exception = $this->read($id))) continue;
1343
+							if (!($exception = $this->read($id)))
1344
+							{
1345
+								continue;
1346
+							}
1223 1347
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1224 1348
 							$exception['reference'] = $exception['recurrence'] = 0;
1225 1349
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1308,7 +1432,10 @@  discard block
 block discarded – undo
1308 1432
 								break;
1309 1433
 
1310 1434
 							default:
1311
-								if (!empty($value)) $event[$key] = $value;
1435
+								if (!empty($value))
1436
+								{
1437
+									$event[$key] = $value;
1438
+								}
1312 1439
 						}
1313 1440
 					}
1314 1441
 				}
@@ -1406,7 +1533,10 @@  discard block
 block discarded – undo
1406 1533
 			else // common adjustments for new events
1407 1534
 			{
1408 1535
 				unset($event['id']);
1409
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1536
+				if ($caldav_name)
1537
+				{
1538
+					$event['caldav_name'] = $caldav_name;
1539
+				}
1410 1540
 				// set non blocking all day depending on the user setting
1411 1541
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1412 1542
 				{
@@ -1454,7 +1584,10 @@  discard block
 block discarded – undo
1454 1584
 					|| !isset($event['participants'][$event['owner']]))
1455 1585
 				{
1456 1586
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1457
-					if (!is_array($event['participants'])) $event['participants'] = array();
1587
+					if (!is_array($event['participants']))
1588
+					{
1589
+						$event['participants'] = array();
1590
+					}
1458 1591
 					$event['participants'][$event['owner']] = $status;
1459 1592
 				}
1460 1593
 				else
@@ -1607,7 +1740,10 @@  discard block
 block discarded – undo
1607 1740
 								$occurence = $exception = false;
1608 1741
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1609 1742
 								{
1610
-									if ($exception > $event['start']) break;
1743
+									if ($exception > $event['start'])
1744
+									{
1745
+										break;
1746
+									}
1611 1747
 									$occurence = $exception;
1612 1748
 								}
1613 1749
 								if (!$occurence)
@@ -1697,12 +1833,15 @@  discard block
 block discarded – undo
1697 1833
 					case 'SERIES-MASTER':
1698 1834
 					case 'SERIES-EXCEPTION':
1699 1835
 					case 'SERIES-EXCEPTION-PROPAGATE':
1700
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1836
+						if (is_array($event_info['stored_event']))
1837
+						{
1838
+							// status update requires a stored event
1701 1839
 						{
1702 1840
 							if ($event_info['acl_edit'])
1703 1841
 							{
1704 1842
 								// update all participants if we have the right to do that
1705 1843
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1844
+						}
1706 1845
 							}
1707 1846
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1708 1847
 							{
@@ -1714,9 +1853,12 @@  discard block
 block discarded – undo
1714 1853
 						break;
1715 1854
 
1716 1855
 					case 'SERIES-PSEUDO-EXCEPTION':
1717
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1856
+						if (is_array($event_info['master_event']))
1857
+						{
1858
+							// status update requires a stored master event
1718 1859
 						{
1719 1860
 							$recurrence = $this->date2usertime($event['recurrence']);
1861
+						}
1720 1862
 							if ($event_info['acl_edit'])
1721 1863
 							{
1722 1864
 								// update all participants if we have the right to do that
@@ -1824,7 +1966,10 @@  discard block
 block discarded – undo
1824 1966
 	 */
1825 1967
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1826 1968
 	{
1827
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1969
+		if ($this->debug)
1970
+		{
1971
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1972
+		}
1828 1973
 		$modified = 0;
1829 1974
 		foreach($event['alarm'] as &$alarm)
1830 1975
 		{
@@ -1846,29 +1991,56 @@  discard block
 block discarded – undo
1846 1991
 					break;
1847 1992
 				}
1848 1993
 			}
1849
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
1994
+			if ($this->debug)
1995
+			{
1996
+				error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
1997
+			}
1850 1998
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1851 1999
 			{
1852
-				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2000
+				if ($this->debug)
2001
+				{
2002
+					error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2003
+				}
1853 2004
 				unset($alarm['attrs']['X-LIC-ERROR']);
1854 2005
 			}
1855 2006
 			// alarm not found --> add it
1856 2007
 			if (!$found)
1857 2008
 			{
1858 2009
 				$alarm['owner'] = $user;
1859
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1860
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1861
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1862
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
2010
+				if (!isset($alarm['time']))
2011
+				{
2012
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2013
+				}
2014
+				if ($alarm['time'] < time())
2015
+				{
2016
+					calendar_so::shift_alarm($event, $alarm);
2017
+				}
2018
+				if ($this->debug)
2019
+				{
2020
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
2021
+				}
2022
+				if ($event['id'])
2023
+				{
2024
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
2025
+				}
1863 2026
 				++$modified;
1864 2027
 			}
1865 2028
 			// existing alarm --> update it
1866 2029
 			else
1867 2030
 			{
1868
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1869
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
2031
+				if (!isset($alarm['time']))
2032
+				{
2033
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2034
+				}
2035
+				if ($alarm['time'] < time())
2036
+				{
2037
+					calendar_so::shift_alarm($event, $alarm);
2038
+				}
1870 2039
 				$alarm = array_merge($old_alarm, $alarm);
1871
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2040
+				if ($this->debug)
2041
+				{
2042
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2043
+				}
1872 2044
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1873 2045
 				++$modified;
1874 2046
 			}
@@ -1882,7 +2054,10 @@  discard block
 block discarded – undo
1882 2054
 				unset($old_alarm[$id]);
1883 2055
 				continue;
1884 2056
 			}
1885
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2057
+			if ($this->debug)
2058
+			{
2059
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2060
+			}
1886 2061
 			$this->delete_alarm($id);
1887 2062
 			++$modified;
1888 2063
 		}
@@ -2301,7 +2476,10 @@  discard block
 block discarded – undo
2301 2476
 				array2string($_vcalData)."\n",3,$this->logfile);
2302 2477
 		}
2303 2478
 
2304
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2479
+		if (!is_array($this->supportedFields))
2480
+		{
2481
+			$this->setSupportedFields();
2482
+		}
2305 2483
 
2306 2484
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2307 2485
 		if (is_resource($_vcalData))
@@ -2667,19 +2845,27 @@  discard block
 block discarded – undo
2667 2845
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2668 2846
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2669 2847
 							}
2670
-							else break;
2848
+							else {
2849
+								break;
2850
+							}
2671 2851
 							// fall-through
2672 2852
 						case 'DAILY':	// 2.0
2673 2853
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2674
-							if (stripos($recurence, 'BYDAY') === false) break;
2854
+							if (stripos($recurence, 'BYDAY') === false)
2855
+							{
2856
+								break;
2857
+							}
2675 2858
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2676 2859
 							// fall-through
2677 2860
 						case 'W':
2678 2861
 						case 'WEEKLY':
2679 2862
 							$days = array();
2680
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2863
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2864
+							{
2865
+								// 1.0
2681 2866
 							{
2682 2867
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2868
+							}
2683 2869
 								if (empty($recurenceMatches[2]))
2684 2870
 								{
2685 2871
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2692,7 +2878,10 @@  discard block
 block discarded – undo
2692 2878
 								$repeatMatches = null;
2693 2879
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2694 2880
 								{
2695
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2881
+									if ($repeatMatches[1])
2882
+									{
2883
+										$vcardData['recur_count'] = $repeatMatches[1];
2884
+									}
2696 2885
 								}
2697 2886
 								else
2698 2887
 								{
@@ -2701,9 +2890,12 @@  discard block
 block discarded – undo
2701 2890
 
2702 2891
 								$recur_days = $this->recur_days_1_0;
2703 2892
 							}
2704
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2893
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2894
+							{
2895
+								// 2.0
2705 2896
 							{
2706 2897
 								$days = explode(',',$recurenceMatches[1]);
2898
+							}
2707 2899
 								$recur_days = $this->recur_days;
2708 2900
 							}
2709 2901
 							else	// no day given, use the day of dtstart
@@ -2762,7 +2954,10 @@  discard block
 block discarded – undo
2762 2954
 							{
2763 2955
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2764 2956
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2765
-							} else break;
2957
+							}
2958
+							else {
2959
+								break;
2960
+							}
2766 2961
 							// fall-through
2767 2962
 						case 'YEARLY':	// 2.0
2768 2963
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2855,13 +3050,16 @@  discard block
 block discarded – undo
2855 3050
 					// fall throught
2856 3051
 				case 'ATTENDEE':
2857 3052
 					if (isset($attributes['params']['PARTSTAT']))
2858
-				    {
3053
+					{
2859 3054
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2860 3055
 				    }
2861 3056
 				    if (isset($attributes['params']['STATUS']))
2862
-					{
3057
+				    {
2863 3058
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2864
-						if (empty($status)) $status = 'X';
3059
+						if (empty($status))
3060
+						{
3061
+							$status = 'X';
3062
+						}
2865 3063
 					}
2866 3064
 					else
2867 3065
 					{
@@ -2921,7 +3119,10 @@  discard block
 block discarded – undo
2921 3119
 							$uid = $this->user;
2922 3120
 					}
2923 3121
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2924
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3122
+					if (!$uid)
3123
+					{
3124
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3125
+					}
2925 3126
 
2926 3127
 					// try to find an email address
2927 3128
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2989,7 +3190,10 @@  discard block
 block discarded – undo
2989 3190
 								}
2990 3191
 								$status = 'U'; // keep the group
2991 3192
 							}
2992
-							else continue; // can't find this group
3193
+							else {
3194
+								continue;
3195
+							}
3196
+							// can't find this group
2993 3197
 						}
2994 3198
 						elseif (empty($searcharray))
2995 3199
 						{
@@ -3048,7 +3252,9 @@  discard block
 block discarded – undo
3048 3252
 
3049 3253
 								try {
3050 3254
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3051
-										$component->getAttribute('ORGANIZER');
3255
+									{
3256
+																			$component->getAttribute('ORGANIZER');
3257
+									}
3052 3258
 								}
3053 3259
 								catch(Horde_Icalendar_Exception $e)
3054 3260
 								{
@@ -3085,7 +3291,10 @@  discard block
 block discarded – undo
3085 3291
 					}
3086 3292
 					break;
3087 3293
 				case 'CREATED':		// will be written direct to the event
3088
-					if ($event['modified']) break;
3294
+					if ($event['modified'])
3295
+					{
3296
+						break;
3297
+					}
3089 3298
 					// fall through
3090 3299
 				case 'LAST-MODIFIED':	// will be written direct to the event
3091 3300
 					$event['modified'] = $attributes['value'];
@@ -3106,7 +3315,11 @@  discard block
 block discarded – undo
3106 3315
 					break;
3107 3316
 
3108 3317
 				case 'ATTACH':
3109
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3318
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3319
+					{
3320
+						break;
3321
+					}
3322
+					// handeled by managed attachment code
3110 3323
 					// fall throught to store external attachment url
3111 3324
 				default:	// X- attribute or other by EGroupware unsupported property
3112 3325
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3237,7 +3450,10 @@  discard block
 block discarded – undo
3237 3450
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3238 3451
 		}
3239 3452
 
3240
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3453
+		if ($this->calendarOwner)
3454
+		{
3455
+			$event['owner'] = $this->calendarOwner;
3456
+		}
3241 3457
 
3242 3458
 		// parsing ATTACH attributes for managed attachments
3243 3459
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3263,7 +3479,10 @@  discard block
 block discarded – undo
3263 3479
 				$filter = $relax ? 'relax' : 'check';
3264 3480
 				$event = array_shift($events);
3265 3481
 				$eventId = -1;
3266
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3482
+				if ($this->so->isWholeDay($event))
3483
+				{
3484
+					$event['whole_day'] = true;
3485
+				}
3267 3486
 				if ($contentID)
3268 3487
 				{
3269 3488
 					$parts = preg_split('/:/', $contentID);
@@ -3316,8 +3535,16 @@  discard block
 block discarded – undo
3316 3535
 	 */
3317 3536
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3318 3537
 	{
3319
-		if (!$start) $start = time();	// default now
3320
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3538
+		if (!$start)
3539
+		{
3540
+			$start = time();
3541
+		}
3542
+		// default now
3543
+		if (!$end)
3544
+		{
3545
+			$end = time() + 100*DAY_s;
3546
+		}
3547
+		// default next 100 days
3321 3548
 
3322 3549
 		$vcal = new Horde_Icalendar;
3323 3550
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3339,10 +3566,13 @@  discard block
 block discarded – undo
3339 3566
 				$attributes[$attr] = date('Ymd\THis', $value);
3340 3567
 			}
3341 3568
 		}
3342
-		if (is_null($extra)) $extra = array(
3569
+		if (is_null($extra))
3570
+		{
3571
+			$extra = array(
3343 3572
 			'URL' => $this->freebusy_url($user),
3344 3573
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3345 3574
 		);
3575
+		}
3346 3576
 		foreach($attributes+$extra as $attr => $value)
3347 3577
 		{
3348 3578
 			$vfreebusy->setAttribute($attr, $value);
@@ -3358,12 +3588,21 @@  discard block
 block discarded – undo
3358 3588
 		{
3359 3589
 			foreach ($fbdata as $event)
3360 3590
 			{
3361
-				if ($event['non_blocking']) continue;
3362
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3591
+				if ($event['non_blocking'])
3592
+				{
3593
+					continue;
3594
+				}
3595
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3596
+				{
3597
+					continue;
3598
+				}
3363 3599
 				$status = $event['participants'][$user];
3364 3600
 				$quantity = $role = null;
3365 3601
 				calendar_so::split_status($status, $quantity, $role);
3366
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
3602
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
3603
+				{
3604
+					continue;
3605
+				}
3367 3606
 
3368 3607
 				$fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3369 3608
 
Please login to merge, or discard this patch.