Completed
Push — 16.1 ( ca3a66...2b6741 )
by Nathan
14:28
created
calendar/inc/class.calendar_bo.inc.php 1 patch
Braces   +197 added lines, -49 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Link;
16 16
 use EGroupware\Api\Acl;
17 17
 
18
-if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
18
+if (!defined('ACL_TYPE_IDENTIFER'))
19
+{
20
+	// used to mark ACL-values for the debug_message methode
19 21
 {
20 22
 	define('ACL_TYPE_IDENTIFER','***ACL***');
21 23
 }
24
+}
22 25
 
23 26
 define('HOUR_s',60*60);
24 27
 define('DAY_s',24*HOUR_s);
@@ -219,7 +222,10 @@  discard block
 block discarded – undo
219 222
 	 */
220 223
 	function __construct()
221 224
 	{
222
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
225
+		if ($this->debug > 0)
226
+		{
227
+			$this->debug_message('calendar_bo::bocal() started',True);
228
+		}
223 229
 
224 230
 		$this->so = new calendar_so();
225 231
 
@@ -305,7 +311,10 @@  discard block
 block discarded – undo
305 311
 	 */
306 312
 	static function email_info($ids)
307 313
 	{
308
-		if (!$ids) return null;
314
+		if (!$ids)
315
+		{
316
+			return null;
317
+		}
309 318
 
310 319
 		$data = array();
311 320
 		foreach((array)$ids as $id)
@@ -398,10 +407,13 @@  discard block
 block discarded – undo
398 407
 				}
399 408
 				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
400 409
 				{
401
-					if ($contact && !in_array($contact,$contact_list))	// already added?
410
+					if ($contact && !in_array($contact,$contact_list))
411
+					{
412
+						// already added?
402 413
 					{
403 414
 						$contact_list[] = $contact;
404 415
 					}
416
+					}
405 417
 				}
406 418
 			}
407 419
 		}
@@ -461,21 +473,27 @@  discard block
 block discarded – undo
461 473
 			{
462 474
 				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
463 475
 				{
464
-					if ($contact && !in_array($contact,$users))	// already added?
476
+					if ($contact && !in_array($contact,$users))
477
+					{
478
+						// already added?
465 479
 					{
466 480
 						$users[] = $contact;
467 481
 					}
482
+					}
468 483
 				}
469 484
 				continue;
470 485
 			}
471 486
 			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
472 487
 			{
473
-				if ($user && !in_array($user,$users))	// already added?
488
+				if ($user && !in_array($user,$users))
489
+				{
490
+					// already added?
474 491
 				{
475 492
 					// General expansion check
476 493
 					if (!is_numeric($user) && $this->resources[$user[0]]['info'])
477 494
 					{
478 495
 						$info = $this->resource_info($user);
496
+				}
479 497
 						if($info && $info['resources'])
480 498
 						{
481 499
 							foreach($info['resources'] as $_user)
@@ -496,12 +514,18 @@  discard block
 block discarded – undo
496 514
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
497 515
 			}
498 516
 			// the further code is only for real users
499
-			if (!is_numeric($user)) continue;
517
+			if (!is_numeric($user))
518
+			{
519
+				continue;
520
+			}
500 521
 
501 522
 			// for groups we have to include the members
502 523
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
503 524
 			{
504
-				if ($no_enum_groups) continue;
525
+				if ($no_enum_groups)
526
+				{
527
+					continue;
528
+				}
505 529
 
506 530
 				$members = $GLOBALS['egw']->accounts->members($user, true);
507 531
 				if (is_array($members))
@@ -581,11 +605,14 @@  discard block
 block discarded – undo
581 605
 		}
582 606
 
583 607
 		if (!isset($params['users']) || !$params['users'] ||
584
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
608
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
609
+		{
610
+			// null or '' casted to an array
585 611
 		{
586 612
 			// for a search use all account you have read grants from
587 613
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
588 614
 		}
615
+		}
589 616
 		// resolve users to add memberships for users and members for groups
590 617
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
591 618
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -596,7 +623,10 @@  discard block
 block discarded – undo
596 623
 			$params['private_grants'] = array();
597 624
 			foreach($this->grants as $user => $rights)
598 625
 			{
599
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
626
+				if ($rights & Acl::PRIVAT)
627
+				{
628
+					$params['private_grants'][] = $user;
629
+				}
600 630
 			}
601 631
 		}
602 632
 
@@ -611,7 +641,10 @@  discard block
 block discarded – undo
611 641
 		{
612 642
 			return false;
613 643
 		}
614
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
644
+		if (isset($params['start']))
645
+		{
646
+			$start = $this->date2ts($params['start']);
647
+		}
615 648
 
616 649
 		if (isset($params['end']))
617 650
 		{
@@ -675,10 +708,13 @@  discard block
 block discarded – undo
675 708
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
676 709
 			}
677 710
 			// create empty entries for each day in the reported time
678
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
711
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
712
+			{
713
+				// good enough for array creation, but see while loop below.
679 714
 			{
680 715
 				$daysEvents[$this->date2string($ts)] = array();
681 716
 			}
717
+			}
682 718
 			foreach($events as $k => $event)
683 719
 			{
684 720
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -730,7 +766,10 @@  discard block
 block discarded – undo
730 766
 			$integration_data = calendar_so::get_integration_data();
731 767
 		}
732 768
 
733
-		if (!isset($integration_data[$app])) return null;
769
+		if (!isset($integration_data[$app]))
770
+		{
771
+			return null;
772
+		}
734 773
 
735 774
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
736 775
 	}
@@ -777,8 +816,14 @@  discard block
 block discarded – undo
777 816
 	 */
778 817
 	function clear_private_infos(&$event,$allowed_participants = array())
779 818
 	{
780
-		if ($event == false) return;
781
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
819
+		if ($event == false)
820
+		{
821
+			return;
822
+		}
823
+		if (!is_array($event['participants']))
824
+		{
825
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
826
+		}
782 827
 
783 828
 		$event = array(
784 829
 			'id'    => $event['id'],
@@ -823,19 +868,29 @@  discard block
 block discarded – undo
823 868
 		}
824 869
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
825 870
 
826
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
871
+		if ($new_horizont <= $this->config['horizont'])
872
+		{
873
+			// no move necessary
827 874
 		{
828 875
 			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']);
876
+		}
829 877
 			return;
830 878
 		}
831 879
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
832 880
 		{
833 881
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
834 882
 		}
835
-		if (empty($maxdays)) $maxdays = 1000; // old default
836
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
883
+		if (empty($maxdays))
884
+		{
885
+			$maxdays = 1000;
886
+		}
887
+		// old default
888
+		if ($new_horizont > time()+$maxdays*DAY_s)
889
+		{
890
+			// some user tries to "look" more then the maximum number of days in the future
837 891
 		{
838 892
 			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);
893
+		}
839 894
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
840 895
 			return;
841 896
 		}
@@ -863,7 +918,10 @@  discard block
 block discarded – undo
863 918
 		// update the horizont
864 919
 		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
865 920
 
866
-		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']);
921
+		if ($this->debug == 'check_move_horizont')
922
+		{
923
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
924
+		}
867 925
 	}
868 926
 
869 927
 	/**
@@ -894,7 +952,10 @@  discard block
 block discarded – undo
894 952
 				$event['end'] = $this->date2usertime($event_read['end']);
895 953
 			}
896 954
 		}
897
-		if (!$start) $start = $event['start'];
955
+		if (!$start)
956
+		{
957
+			$start = $event['start'];
958
+		}
898 959
 		$start_obj = new Api\DateTime($start);
899 960
 		$read_start = new Api\DateTime($event_read['start']);
900 961
 
@@ -936,7 +997,10 @@  discard block
 block discarded – undo
936 997
 	 */
937 998
 	function db2data(&$events,$date_format='ts')
938 999
 	{
939
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
1000
+		if (!is_array($events))
1001
+		{
1002
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
1003
+		}
940 1004
 		foreach ($events as &$event)
941 1005
 		{
942 1006
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -1020,7 +1084,10 @@  discard block
 block discarded – undo
1020 1084
 	 */
1021 1085
 	function date2usertime($ts,$date_format='ts')
1022 1086
 	{
1023
-		if (empty($ts) || $date_format == 'server') return $ts;
1087
+		if (empty($ts) || $date_format == 'server')
1088
+		{
1089
+			return $ts;
1090
+		}
1024 1091
 
1025 1092
 		return Api\DateTime::server2user($ts,$date_format);
1026 1093
 	}
@@ -1038,9 +1105,15 @@  discard block
 block discarded – undo
1038 1105
 	 */
1039 1106
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1040 1107
 	{
1041
-		if (!$ids) return false;
1108
+		if (!$ids)
1109
+		{
1110
+			return false;
1111
+		}
1042 1112
 
1043
-		if ($date) $date = $this->date2ts($date);
1113
+		if ($date)
1114
+		{
1115
+			$date = $this->date2ts($date);
1116
+		}
1044 1117
 
1045 1118
 		$return = null;
1046 1119
 
@@ -1205,7 +1278,10 @@  discard block
 block discarded – undo
1205 1278
 	{
1206 1279
 		static $res_info_cache = array();
1207 1280
 
1208
-		if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1281
+		if (!is_scalar($uid))
1282
+		{
1283
+			throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1284
+		}
1209 1285
 
1210 1286
 		if (!isset($res_info_cache[$uid]))
1211 1287
 		{
@@ -1260,7 +1336,10 @@  discard block
 block discarded – undo
1260 1336
 	 */
1261 1337
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1262 1338
 	{
1263
-		if (!$user) $user = $this->user;
1339
+		if (!$user)
1340
+		{
1341
+			$user = $this->user;
1342
+		}
1264 1343
 		if ($user == $this->user)
1265 1344
 		{
1266 1345
 			$grants = $this->grants;
@@ -1299,7 +1378,10 @@  discard block
 block discarded – undo
1299 1378
 		$grant = $grants[$owner];
1300 1379
 
1301 1380
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1302
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1381
+		if ($grant & ~self::ACL_INVITE)
1382
+		{
1383
+			$grant |= self::ACL_FREEBUSY;
1384
+		}
1303 1385
 
1304 1386
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1305 1387
 		{
@@ -1325,7 +1407,10 @@  discard block
 block discarded – undo
1325 1407
 					elseif (!is_numeric($uid))
1326 1408
 					{
1327 1409
 						// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
1328
-						if ($grant == self::ACL_FREEBUSY) continue;
1410
+						if ($grant == self::ACL_FREEBUSY)
1411
+						{
1412
+							continue;
1413
+						}
1329 1414
 						// if we have a resource as participant
1330 1415
 						$resource = $this->resource_info($uid);
1331 1416
 						$grant |= $resource['rights'];
@@ -1476,14 +1561,20 @@  discard block
 block discarded – undo
1476 1561
 						$param = $param ? 'True' : 'False';
1477 1562
 						break;
1478 1563
 					case 'integer':
1479
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1564
+						if ($param >= mktime(0,0,0,1,1,2000))
1565
+						{
1566
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1567
+						}
1480 1568
 						break;
1481 1569
 				}
1482 1570
 			}
1483 1571
 			$msg = str_replace('%'.($i-1),$param,$msg);
1484 1572
 		}
1485 1573
 		error_log($msg);
1486
-		if ($backtrace) error_log(function_backtrace(1));
1574
+		if ($backtrace)
1575
+		{
1576
+			error_log(function_backtrace(1));
1577
+		}
1487 1578
 	}
1488 1579
 
1489 1580
 	/**
@@ -1591,14 +1682,20 @@  discard block
 block discarded – undo
1591 1682
 	function timespan($start_m,$end_m,$both=false)
1592 1683
 	{
1593 1684
 		$duration = $end_m - $start_m;
1594
-		if ($end_m == 24*60-1) ++$duration;
1685
+		if ($end_m == 24*60-1)
1686
+		{
1687
+			++$duration;
1688
+		}
1595 1689
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1596 1690
 
1597 1691
 		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1598 1692
 
1599
-		if ($both)	// end-time too
1693
+		if ($both)
1694
+		{
1695
+			// end-time too
1600 1696
 		{
1601 1697
 			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1698
+		}
1602 1699
 			// dont double am/pm if they are the same in both times
1603 1700
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1604 1701
 			{
@@ -1622,7 +1719,10 @@  discard block
 block discarded – undo
1622 1719
 		static $id2lid = array();
1623 1720
 		static $id2email = array();
1624 1721
 
1625
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1722
+		if ($use_type && $use_type != 'u')
1723
+		{
1724
+			$id = $use_type.$id;
1725
+		}
1626 1726
 
1627 1727
 		if (!isset($id2lid[$id]))
1628 1728
 		{
@@ -1632,7 +1732,10 @@  discard block
 block discarded – undo
1632 1732
 				if (($info = $this->resource_info($id)))
1633 1733
 				{
1634 1734
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1635
-					if ($info['name']) $id2email[$id] = $info['email'];
1735
+					if ($info['name'])
1736
+					{
1737
+						$id2email[$id] = $info['email'];
1738
+					}
1636 1739
 				}
1637 1740
 			}
1638 1741
 			else
@@ -1658,11 +1761,18 @@  discard block
 block discarded – undo
1658 1761
 		$names = array();
1659 1762
 		foreach((array)$event['participants'] as $id => $status)
1660 1763
 		{
1661
-			if (!is_string($status)) continue;
1764
+			if (!is_string($status))
1765
+			{
1766
+				continue;
1767
+			}
1662 1768
 			$quantity = $role = null;
1663 1769
 			calendar_so::split_status($status,$quantity,$role);
1664 1770
 
1665
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1771
+			if ($status == 'G' && !$show_group_invitation)
1772
+			{
1773
+				continue;
1774
+			}
1775
+			// dont show group-invitation
1666 1776
 
1667 1777
 			$lang_status = lang($this->verbose_status[$status]);
1668 1778
 			if (!$long_status)
@@ -1735,7 +1845,10 @@  discard block
 block discarded – undo
1735 1845
 
1736 1846
 		foreach(explode(',',$category) as $cat_id)
1737 1847
 		{
1738
-			if (!$cat_id) continue;
1848
+			if (!$cat_id)
1849
+			{
1850
+				continue;
1851
+			}
1739 1852
 
1740 1853
 			if (!isset($id2cat[$cat_id]))
1741 1854
 			{
@@ -1801,7 +1914,10 @@  discard block
 block discarded – undo
1801 1914
 	 */
1802 1915
 	public static function list_calendars($user, array $grants=null)
1803 1916
 	{
1804
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1917
+		if (is_null($grants))
1918
+		{
1919
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1920
+		}
1805 1921
 
1806 1922
 		$users = $groups = array();
1807 1923
 		foreach(array_keys($grants) as $id)
@@ -1849,7 +1965,10 @@  discard block
 block discarded – undo
1849 1965
 	 */
1850 1966
 	function recure2string($event)
1851 1967
 	{
1852
-		if (!is_array($event)) return false;
1968
+		if (!is_array($event))
1969
+		{
1970
+			return false;
1971
+		}
1853 1972
 		return (string)calendar_rrule::event2rrule($event);
1854 1973
 	}
1855 1974
 
@@ -1868,7 +1987,10 @@  discard block
 block discarded – undo
1868 1987
 	 */
1869 1988
 	function read_holidays($year=0)
1870 1989
 	{
1871
-		if (!$year) $year = (int) date('Y',$this->now_su);
1990
+		if (!$year)
1991
+		{
1992
+			$year = (int) date('Y',$this->now_su);
1993
+		}
1872 1994
 
1873 1995
 		$holidays = calendar_holidays::read(
1874 1996
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
@@ -1963,7 +2085,10 @@  discard block
 block discarded – undo
1963 2085
 				}
1964 2086
 			}
1965 2087
 			$str_fields = implode(', ',$extra_fields);
1966
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2088
+			if (is_array($extra_fields))
2089
+			{
2090
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2091
+			}
1967 2092
 		}
1968 2093
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1969 2094
 	}
@@ -1984,7 +2109,8 @@  discard block
 block discarded – undo
1984 2109
 			'offset' =>	$options['start'],
1985 2110
 			'order' => 'cal_start DESC',
1986 2111
 		);
1987
-		if($options['num_rows']) {
2112
+		if($options['num_rows'])
2113
+		{
1988 2114
 			$query['num_rows'] = $options['num_rows'];
1989 2115
 		}
1990 2116
 		foreach((array) $this->search($query) as $event)
@@ -2045,7 +2171,10 @@  discard block
 block discarded – undo
2045 2171
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2046 2172
 			{
2047 2173
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2048
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2174
+				if ($type == 'forced')
2175
+				{
2176
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2177
+				}
2049 2178
 				$this->cal_prefs[$var] = $default;
2050 2179
 				$need_save = True;
2051 2180
 			}
@@ -2065,7 +2194,10 @@  discard block
 block discarded – undo
2065 2194
 	 */
2066 2195
 	static function freebusy_url($user='',$pw=null)
2067 2196
 	{
2068
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2197
+		if (is_numeric($user))
2198
+		{
2199
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2200
+		}
2069 2201
 
2070 2202
 		$credentials = '';
2071 2203
 
@@ -2133,13 +2265,19 @@  discard block
 block discarded – undo
2133 2265
 	 */
2134 2266
 	public function get_ctag($user, $filter='owner', $master_only=false)
2135 2267
 	{
2136
-		if ($this->debug > 1) $startime = microtime(true);
2268
+		if ($this->debug > 1)
2269
+		{
2270
+			$startime = microtime(true);
2271
+		}
2137 2272
 
2138 2273
 		// resolve users to add memberships for users and members for groups
2139 2274
 		$users = $this->resolve_users($user);
2140 2275
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2141 2276
 
2142
-		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");
2277
+		if ($this->debug > 1)
2278
+		{
2279
+			error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2280
+		}
2143 2281
 		return $ctag;
2144 2282
 	}
2145 2283
 
@@ -2181,15 +2319,21 @@  discard block
 block discarded – undo
2181 2319
 				$content['link_app'][] = $link['app'];
2182 2320
 				$content['link_id'][]  = $link['id'];
2183 2321
 			}
2184
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2322
+			if ($link['app'] == 'addressbook')
2323
+			{
2324
+				// prefering contact as primary contact over calendar entry set above
2185 2325
 			{
2186 2326
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2187 2327
 			}
2328
+			}
2188 2329
 		}
2189 2330
 		// Copy same custom fields
2190 2331
 		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2191 2332
 		{
2192
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2333
+			if ($this->customfields[$name])
2334
+			{
2335
+				$content['#'.$name] = $calendar['#'.$name];
2336
+			}
2193 2337
 		}
2194 2338
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2195 2339
 		return $content;
@@ -2212,7 +2356,11 @@  discard block
 block discarded – undo
2212 2356
 			$set['ts_title'] = $this->link_title($event);
2213 2357
 			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2214 2358
 			$set['ts_description'] = $event['description'];
2215
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2359
+			if ($this->isWholeDay($event))
2360
+			{
2361
+				$event['end']++;
2362
+			}
2363
+			// whole day events are 1sec short
2216 2364
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2217 2365
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2218 2366
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.