Completed
Push — 16.1 ( 5f2519...698380 )
by Hadi
30:57 queued 13:55
created
calendar/inc/class.calendar_ical.inc.php 1 patch
Braces   +326 added lines, -84 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,15 +325,21 @@  discard block
 block discarded – undo
312 325
 				try {
313 326
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
314 327
 			}
315
-				catch (Exception $e) {
328
+			catch (Exception $e) {
316 329
 					// log unknown timezones
317
-					if (!empty($event['tzid'])) _egw_log_exception($e);
330
+					if (!empty($event['tzid']))
331
+					{
332
+						_egw_log_exception($e);
333
+					}
318 334
 					// default for no timezone and unkown to user timezone
319 335
 					self::$tz_cache[$event['tzid']] = Api\DateTime::$user_timezone;
320 336
 				}
321 337
 			}
322 338
 
323
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
339
+			if ($this->so->isWholeDay($event))
340
+			{
341
+				$event['whole_day'] = true;
342
+			}
324 343
 
325 344
 			if ($this->log)
326 345
 			{
@@ -331,7 +350,10 @@  discard block
 block discarded – undo
331 350
 
332 351
 			if ($recurrence)
333 352
 			{
334
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
353
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
354
+				{
355
+					continue;
356
+				}
335 357
 
336 358
 				if (!isset($this->supportedFields['participants']))
337 359
 				{
@@ -388,7 +410,8 @@  discard block
 block discarded – undo
388 410
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
389 411
 			{
390 412
 				// Append UID to DESCRIPTION
391
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
413
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
414
+				{
392 415
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
393 416
 				}
394 417
 			}
@@ -448,11 +471,21 @@  discard block
 block discarded – undo
448 471
 							$quantity = $role = null;
449 472
 							calendar_so::split_status($status, $quantity, $role);
450 473
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
451
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
474
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
475
+							{
476
+								continue;
477
+							}
452 478
 
453
-							if (!($info = $this->resource_info($uid))) continue;
479
+							if (!($info = $this->resource_info($uid)))
480
+							{
481
+								continue;
482
+							}
454 483
 
455
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
484
+							if (in_array($status, array('X','E')))
485
+							{
486
+								continue;
487
+							}
488
+							// dont include deleted participants
456 489
 
457 490
 							if ($this->log)
458 491
 							{
@@ -531,24 +564,49 @@  discard block
 block discarded – undo
531 564
 							}
532 565
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
533 566
 							$options = array();
534
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
535
-							if (!empty($role)) $options['ROLE'] = $role;
536
-							if (!empty($status)) $options['PARTSTAT'] = $status;
537
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
538
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
567
+							if (!empty($participantCN))
568
+							{
569
+								$options['CN'] = $participantCN;
570
+							}
571
+							if (!empty($role))
572
+							{
573
+								$options['ROLE'] = $role;
574
+							}
575
+							if (!empty($status))
576
+							{
577
+								$options['PARTSTAT'] = $status;
578
+							}
579
+							if (!empty($cutype))
580
+							{
581
+								$options['CUTYPE'] = $cutype;
582
+							}
583
+							if (!empty($rsvp))
584
+							{
585
+								$options['RSVP'] = $rsvp;
586
+							}
539 587
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
540 588
 							{
541 589
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
542 590
 							}
543
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
544
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
591
+							if ($info['type'] != 'e')
592
+							{
593
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
594
+							}
595
+							if ($quantity > 1)
596
+							{
597
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
598
+							}
545 599
 							$attributes['ATTENDEE'][] = $participantURL;
546 600
 							$parameters['ATTENDEE'][] = $options;
547 601
 						}
548 602
 						break;
549 603
 
550 604
 					case 'CLASS':
551
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
605
+						if ($event['public'])
606
+						{
607
+							continue;
608
+						}
609
+						// public is default, no need to export, fails CalDAVTester if added as default
552 610
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
553 611
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
554 612
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -580,9 +638,18 @@  discard block
 block discarded – undo
580 638
 									'CUTYPE'   => 'INDIVIDUAL',
581 639
 									//'RSVP'     => 'FALSE',
582 640
 									);
583
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
584
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
585
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
641
+								if (!empty($organizerCN))
642
+								{
643
+									$options['CN'] = $organizerCN;
644
+								}
645
+								if (!empty($organizerEMail))
646
+								{
647
+									$options['EMAIL'] = $organizerEMail;
648
+								}
649
+								if (!empty($event['owner']))
650
+								{
651
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
652
+								}
586 653
 								$attributes['ATTENDEE'][] = $organizerURL;
587 654
 			    				$parameters['ATTENDEE'][] = $options;
588 655
 		    				}
@@ -611,9 +678,12 @@  discard block
 block discarded – undo
611 678
 						{
612 679
 							// Hack for CalDAVTester to export duration instead of endtime
613 680
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
614
-								$attributes['duration'] = $event['end'] - $event['start'];
615
-							else
616
-								$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
681
+							{
682
+															$attributes['duration'] = $event['end'] - $event['start'];
683
+							}
684
+							else {
685
+															$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
686
+							}
617 687
 						}
618 688
 						else
619 689
 						{
@@ -633,7 +703,11 @@  discard block
 block discarded – undo
633 703
 						break;
634 704
 
635 705
 					case 'RRULE':
636
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
706
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
707
+						{
708
+							break;
709
+						}
710
+						// no recuring event
637 711
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
638 712
 						$rrule = $rriter->generate_rrule($version);
639 713
 						if ($event['recur_enddate'])
@@ -675,7 +749,10 @@  discard block
 block discarded – undo
675 749
 						break;
676 750
 
677 751
 					case 'EXDATE':
678
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
752
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
753
+						{
754
+							break;
755
+						}
679 756
 						if (!empty($event['recur_exception']))
680 757
 						{
681 758
 							if (empty($event['whole_day']))
@@ -702,14 +779,21 @@  discard block
 block discarded – undo
702 779
 									);
703 780
 								}
704 781
 								$event['recur_exception'] = $days;
705
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
782
+								if ($version != '1.0')
783
+								{
784
+									$parameters['EXDATE']['VALUE'] = 'DATE';
785
+								}
706 786
 							}
707 787
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
708 788
 						}
709 789
 						break;
710 790
 
711 791
 					case 'PRIORITY':
712
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
792
+						if (!$event['priority'])
793
+						{
794
+							continue;
795
+						}
796
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
713 797
 						if ($this->productManufacturer == 'funambol' &&
714 798
 							(strpos($this->productName, 'outlook') !== false
715 799
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -723,7 +807,11 @@  discard block
 block discarded – undo
723 807
 						break;
724 808
 
725 809
 					case 'TRANSP':
726
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
810
+						if (!$event['non_blocking'])
811
+						{
812
+							continue;
813
+						}
814
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
727 815
 						if ($version == '1.0')
728 816
 						{
729 817
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -780,7 +868,11 @@  discard block
 block discarded – undo
780 868
 						elseif ($event['recurrence'] && $event['reference'])
781 869
 						{
782 870
 							// $event['reference'] is a calendar_id, not a timestamp
783
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
871
+							if (!($revent = $this->read($event['reference'])))
872
+							{
873
+								break;
874
+							}
875
+							// referenced event does not exist
784 876
 
785 877
 							if (empty($revent['whole_day']))
786 878
 							{
@@ -906,7 +998,10 @@  discard block
 block discarded – undo
906 998
 			foreach ((array)$event['alarm'] as $alarmData)
907 999
 			{
908 1000
 				// skip over alarms that don't have the minimum required info
909
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
1001
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
1002
+				{
1003
+					continue;
1004
+				}
910 1005
 
911 1006
 				// skip alarms not being set for all users and alarms owned by other users
912 1007
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -923,7 +1018,10 @@  discard block
 block discarded – undo
923 1018
 
924 1019
 				if ($version == '1.0')
925 1020
 				{
926
-					if ($event['title']) $description = $event['title'];
1021
+					if ($event['title'])
1022
+					{
1023
+						$description = $event['title'];
1024
+					}
927 1025
 					if ($description)
928 1026
 					{
929 1027
 						$values['DALARM']['snooze_time'] = '';
@@ -943,7 +1041,10 @@  discard block
 block discarded – undo
943 1041
 					// VCalendar 2.0 / RFC 2445
944 1042
 
945 1043
 					// RFC requires DESCRIPTION for DISPLAY
946
-					if (!$event['title'] && !$description) $description = 'Alarm';
1044
+					if (!$event['title'] && !$description)
1045
+					{
1046
+						$description = 'Alarm';
1047
+					}
947 1048
 
948 1049
 					/* Disabling for now
949 1050
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1134,13 +1235,20 @@  discard block
 block discarded – undo
1134 1235
 		$this->events_imported = 0;
1135 1236
 		$replace = $delete_exceptions= false;
1136 1237
 
1137
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1238
+		if (!is_array($this->supportedFields))
1239
+		{
1240
+			$this->setSupportedFields();
1241
+		}
1138 1242
 
1139 1243
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1140 1244
 		{
1141 1245
 			return false;
1142 1246
 		}
1143
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1247
+		if (!is_array($events))
1248
+		{
1249
+			$cal_id = -1;
1250
+		}
1251
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1144 1252
 
1145 1253
 		if ($cal_id > 0)
1146 1254
 		{
@@ -1148,8 +1256,14 @@  discard block
 block discarded – undo
1148 1256
 			{
1149 1257
 				$replace = $recur_date == 0;
1150 1258
 				$events[0]['id'] = $cal_id;
1151
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1152
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1259
+				if (!is_null($etag))
1260
+				{
1261
+					$events[0]['etag'] = (int) $etag;
1262
+				}
1263
+				if ($recur_date)
1264
+				{
1265
+					$events[0]['recurrence'] = $recur_date;
1266
+				}
1153 1267
 			}
1154 1268
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1155 1269
 					($eventId = array_shift($foundEvent)) &&
@@ -1157,7 +1271,10 @@  discard block
 block discarded – undo
1157 1271
 			{
1158 1272
 				foreach ($events as $k => $event)
1159 1273
 				{
1160
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1274
+					if (!isset($event['uid']))
1275
+					{
1276
+						$events[$k]['uid'] = $egwEvent['uid'];
1277
+					}
1161 1278
 				}
1162 1279
 			}
1163 1280
 		}
@@ -1187,10 +1304,17 @@  discard block
 block discarded – undo
1187 1304
 		$msg = null;
1188 1305
 		foreach ($events as $event)
1189 1306
 		{
1190
-			if (!is_array($event)) continue; // the iterator may return false
1307
+			if (!is_array($event))
1308
+			{
1309
+				continue;
1310
+			}
1311
+			// the iterator may return false
1191 1312
 			++$this->events_imported;
1192 1313
 
1193
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1314
+			if ($this->so->isWholeDay($event))
1315
+			{
1316
+				$event['whole_day'] = true;
1317
+			}
1194 1318
 			if (is_array($event['category']))
1195 1319
 			{
1196 1320
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1227,7 +1351,10 @@  discard block
 block discarded – undo
1227 1351
 						}
1228 1352
 						else
1229 1353
 						{
1230
-							if (!($exception = $this->read($id))) continue;
1354
+							if (!($exception = $this->read($id)))
1355
+							{
1356
+								continue;
1357
+							}
1231 1358
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1232 1359
 							$exception['reference'] = $exception['recurrence'] = 0;
1233 1360
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1316,7 +1443,10 @@  discard block
 block discarded – undo
1316 1443
 								break;
1317 1444
 
1318 1445
 							default:
1319
-								if (!empty($value)) $event[$key] = $value;
1446
+								if (!empty($value))
1447
+								{
1448
+									$event[$key] = $value;
1449
+								}
1320 1450
 						}
1321 1451
 					}
1322 1452
 				}
@@ -1414,7 +1544,10 @@  discard block
 block discarded – undo
1414 1544
 			else // common adjustments for new events
1415 1545
 			{
1416 1546
 				unset($event['id']);
1417
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1547
+				if ($caldav_name)
1548
+				{
1549
+					$event['caldav_name'] = $caldav_name;
1550
+				}
1418 1551
 				// set non blocking all day depending on the user setting
1419 1552
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1420 1553
 				{
@@ -1462,7 +1595,10 @@  discard block
 block discarded – undo
1462 1595
 					|| !isset($event['participants'][$event['owner']]))
1463 1596
 				{
1464 1597
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1465
-					if (!is_array($event['participants'])) $event['participants'] = array();
1598
+					if (!is_array($event['participants']))
1599
+					{
1600
+						$event['participants'] = array();
1601
+					}
1466 1602
 					$event['participants'][$event['owner']] = $status;
1467 1603
 				}
1468 1604
 				else
@@ -1615,7 +1751,10 @@  discard block
 block discarded – undo
1615 1751
 								$occurence = $exception = false;
1616 1752
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1617 1753
 								{
1618
-									if ($exception > $event['start']) break;
1754
+									if ($exception > $event['start'])
1755
+									{
1756
+										break;
1757
+									}
1619 1758
 									$occurence = $exception;
1620 1759
 								}
1621 1760
 								if (!$occurence)
@@ -1705,12 +1844,15 @@  discard block
 block discarded – undo
1705 1844
 					case 'SERIES-MASTER':
1706 1845
 					case 'SERIES-EXCEPTION':
1707 1846
 					case 'SERIES-EXCEPTION-PROPAGATE':
1708
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1847
+						if (is_array($event_info['stored_event']))
1848
+						{
1849
+							// status update requires a stored event
1709 1850
 						{
1710 1851
 							if ($event_info['acl_edit'])
1711 1852
 							{
1712 1853
 								// update all participants if we have the right to do that
1713 1854
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1855
+						}
1714 1856
 							}
1715 1857
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1716 1858
 							{
@@ -1722,9 +1864,12 @@  discard block
 block discarded – undo
1722 1864
 						break;
1723 1865
 
1724 1866
 					case 'SERIES-PSEUDO-EXCEPTION':
1725
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1867
+						if (is_array($event_info['master_event']))
1868
+						{
1869
+							// status update requires a stored master event
1726 1870
 						{
1727 1871
 							$recurrence = $this->date2usertime($event['recurrence']);
1872
+						}
1728 1873
 							if ($event_info['acl_edit'])
1729 1874
 							{
1730 1875
 								// update all participants if we have the right to do that
@@ -1832,7 +1977,10 @@  discard block
 block discarded – undo
1832 1977
 	 */
1833 1978
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1834 1979
 	{
1835
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1980
+		if ($this->debug)
1981
+		{
1982
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1983
+		}
1836 1984
 		$modified = 0;
1837 1985
 		foreach($event['alarm'] as &$alarm)
1838 1986
 		{
@@ -1854,29 +2002,56 @@  discard block
 block discarded – undo
1854 2002
 					break;
1855 2003
 				}
1856 2004
 			}
1857
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2005
+			if ($this->debug)
2006
+			{
2007
+				error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2008
+			}
1858 2009
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1859 2010
 			{
1860
-				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2011
+				if ($this->debug)
2012
+				{
2013
+					error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2014
+				}
1861 2015
 				unset($alarm['attrs']['X-LIC-ERROR']);
1862 2016
 			}
1863 2017
 			// alarm not found --> add it
1864 2018
 			if (!$found)
1865 2019
 			{
1866 2020
 				$alarm['owner'] = $user;
1867
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1868
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1869
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1870
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
2021
+				if (!isset($alarm['time']))
2022
+				{
2023
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2024
+				}
2025
+				if ($alarm['time'] < time())
2026
+				{
2027
+					calendar_so::shift_alarm($event, $alarm);
2028
+				}
2029
+				if ($this->debug)
2030
+				{
2031
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
2032
+				}
2033
+				if ($event['id'])
2034
+				{
2035
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
2036
+				}
1871 2037
 				++$modified;
1872 2038
 			}
1873 2039
 			// existing alarm --> update it
1874 2040
 			else
1875 2041
 			{
1876
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1877
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
2042
+				if (!isset($alarm['time']))
2043
+				{
2044
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2045
+				}
2046
+				if ($alarm['time'] < time())
2047
+				{
2048
+					calendar_so::shift_alarm($event, $alarm);
2049
+				}
1878 2050
 				$alarm = array_merge($old_alarm, $alarm);
1879
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2051
+				if ($this->debug)
2052
+				{
2053
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2054
+				}
1880 2055
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1881 2056
 				++$modified;
1882 2057
 			}
@@ -1890,7 +2065,10 @@  discard block
 block discarded – undo
1890 2065
 				unset($old_alarm[$id]);
1891 2066
 				continue;
1892 2067
 			}
1893
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2068
+			if ($this->debug)
2069
+			{
2070
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2071
+			}
1894 2072
 			$this->delete_alarm($id);
1895 2073
 			++$modified;
1896 2074
 		}
@@ -2309,7 +2487,10 @@  discard block
 block discarded – undo
2309 2487
 				array2string($_vcalData)."\n",3,$this->logfile);
2310 2488
 		}
2311 2489
 
2312
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2490
+		if (!is_array($this->supportedFields))
2491
+		{
2492
+			$this->setSupportedFields();
2493
+		}
2313 2494
 
2314 2495
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2315 2496
 		if (is_resource($_vcalData))
@@ -2675,19 +2856,27 @@  discard block
 block discarded – undo
2675 2856
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2676 2857
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2677 2858
 							}
2678
-							else break;
2859
+							else {
2860
+								break;
2861
+							}
2679 2862
 							// fall-through
2680 2863
 						case 'DAILY':	// 2.0
2681 2864
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2682
-							if (stripos($recurence, 'BYDAY') === false) break;
2865
+							if (stripos($recurence, 'BYDAY') === false)
2866
+							{
2867
+								break;
2868
+							}
2683 2869
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2684 2870
 							// fall-through
2685 2871
 						case 'W':
2686 2872
 						case 'WEEKLY':
2687 2873
 							$days = array();
2688
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2874
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2875
+							{
2876
+								// 1.0
2689 2877
 							{
2690 2878
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2879
+							}
2691 2880
 								if (empty($recurenceMatches[2]))
2692 2881
 								{
2693 2882
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2700,7 +2889,10 @@  discard block
 block discarded – undo
2700 2889
 								$repeatMatches = null;
2701 2890
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2702 2891
 								{
2703
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2892
+									if ($repeatMatches[1])
2893
+									{
2894
+										$vcardData['recur_count'] = $repeatMatches[1];
2895
+									}
2704 2896
 								}
2705 2897
 								else
2706 2898
 								{
@@ -2709,9 +2901,12 @@  discard block
 block discarded – undo
2709 2901
 
2710 2902
 								$recur_days = $this->recur_days_1_0;
2711 2903
 							}
2712
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2904
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2905
+							{
2906
+								// 2.0
2713 2907
 							{
2714 2908
 								$days = explode(',',$recurenceMatches[1]);
2909
+							}
2715 2910
 								$recur_days = $this->recur_days;
2716 2911
 							}
2717 2912
 							else	// no day given, use the day of dtstart
@@ -2770,7 +2965,10 @@  discard block
 block discarded – undo
2770 2965
 							{
2771 2966
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2772 2967
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2773
-							} else break;
2968
+							}
2969
+							else {
2970
+								break;
2971
+							}
2774 2972
 							// fall-through
2775 2973
 						case 'YEARLY':	// 2.0
2776 2974
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2863,13 +3061,16 @@  discard block
 block discarded – undo
2863 3061
 					// fall throught
2864 3062
 				case 'ATTENDEE':
2865 3063
 					if (isset($attributes['params']['PARTSTAT']))
2866
-				    {
3064
+					{
2867 3065
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2868 3066
 				    }
2869 3067
 				    if (isset($attributes['params']['STATUS']))
2870
-					{
3068
+				    {
2871 3069
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2872
-						if (empty($status)) $status = 'X';
3070
+						if (empty($status))
3071
+						{
3072
+							$status = 'X';
3073
+						}
2873 3074
 					}
2874 3075
 					else
2875 3076
 					{
@@ -2929,7 +3130,10 @@  discard block
 block discarded – undo
2929 3130
 							$uid = $this->user;
2930 3131
 					}
2931 3132
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2932
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3133
+					if (!$uid)
3134
+					{
3135
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3136
+					}
2933 3137
 
2934 3138
 					// try to find an email address
2935 3139
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2997,7 +3201,10 @@  discard block
 block discarded – undo
2997 3201
 								}
2998 3202
 								$status = 'U'; // keep the group
2999 3203
 							}
3000
-							else continue; // can't find this group
3204
+							else {
3205
+								continue;
3206
+							}
3207
+							// can't find this group
3001 3208
 						}
3002 3209
 						elseif (empty($searcharray))
3003 3210
 						{
@@ -3056,7 +3263,9 @@  discard block
 block discarded – undo
3056 3263
 
3057 3264
 								try {
3058 3265
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3059
-										$component->getAttribute('ORGANIZER');
3266
+									{
3267
+																			$component->getAttribute('ORGANIZER');
3268
+									}
3060 3269
 								}
3061 3270
 								catch(Horde_Icalendar_Exception $e)
3062 3271
 								{
@@ -3093,7 +3302,10 @@  discard block
 block discarded – undo
3093 3302
 					}
3094 3303
 					break;
3095 3304
 				case 'CREATED':		// will be written direct to the event
3096
-					if ($event['modified']) break;
3305
+					if ($event['modified'])
3306
+					{
3307
+						break;
3308
+					}
3097 3309
 					// fall through
3098 3310
 				case 'LAST-MODIFIED':	// will be written direct to the event
3099 3311
 					$event['modified'] = $attributes['value'];
@@ -3114,7 +3326,11 @@  discard block
 block discarded – undo
3114 3326
 					break;
3115 3327
 
3116 3328
 				case 'ATTACH':
3117
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3329
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3330
+					{
3331
+						break;
3332
+					}
3333
+					// handeled by managed attachment code
3118 3334
 					// fall throught to store external attachment url
3119 3335
 				default:	// X- attribute or other by EGroupware unsupported property
3120 3336
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3245,7 +3461,10 @@  discard block
 block discarded – undo
3245 3461
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3246 3462
 		}
3247 3463
 
3248
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3464
+		if ($this->calendarOwner)
3465
+		{
3466
+			$event['owner'] = $this->calendarOwner;
3467
+		}
3249 3468
 
3250 3469
 		// parsing ATTACH attributes for managed attachments
3251 3470
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3271,7 +3490,10 @@  discard block
 block discarded – undo
3271 3490
 				$filter = $relax ? 'relax' : 'check';
3272 3491
 				$event = array_shift($events);
3273 3492
 				$eventId = -1;
3274
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3493
+				if ($this->so->isWholeDay($event))
3494
+				{
3495
+					$event['whole_day'] = true;
3496
+				}
3275 3497
 				if ($contentID)
3276 3498
 				{
3277 3499
 					$parts = preg_split('/:/', $contentID);
@@ -3324,8 +3546,16 @@  discard block
 block discarded – undo
3324 3546
 	 */
3325 3547
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3326 3548
 	{
3327
-		if (!$start) $start = time();	// default now
3328
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3549
+		if (!$start)
3550
+		{
3551
+			$start = time();
3552
+		}
3553
+		// default now
3554
+		if (!$end)
3555
+		{
3556
+			$end = time() + 100*DAY_s;
3557
+		}
3558
+		// default next 100 days
3329 3559
 
3330 3560
 		$vcal = new Horde_Icalendar;
3331 3561
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3347,10 +3577,13 @@  discard block
 block discarded – undo
3347 3577
 				$attributes[$attr] = date('Ymd\THis', $value);
3348 3578
 			}
3349 3579
 		}
3350
-		if (is_null($extra)) $extra = array(
3580
+		if (is_null($extra))
3581
+		{
3582
+			$extra = array(
3351 3583
 			'URL' => $this->freebusy_url($user),
3352 3584
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3353 3585
 		);
3586
+		}
3354 3587
 		foreach($attributes+$extra as $attr => $value)
3355 3588
 		{
3356 3589
 			$vfreebusy->setAttribute($attr, $value);
@@ -3366,12 +3599,21 @@  discard block
 block discarded – undo
3366 3599
 		{
3367 3600
 			foreach ($fbdata as $event)
3368 3601
 			{
3369
-				if ($event['non_blocking']) continue;
3370
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3602
+				if ($event['non_blocking'])
3603
+				{
3604
+					continue;
3605
+				}
3606
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3607
+				{
3608
+					continue;
3609
+				}
3371 3610
 				$status = $event['participants'][$user];
3372 3611
 				$quantity = $role = null;
3373 3612
 				calendar_so::split_status($status, $quantity, $role);
3374
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
3613
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
3614
+				{
3615
+					continue;
3616
+				}
3375 3617
 
3376 3618
 				$fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3377 3619
 
Please login to merge, or discard this patch.