Completed
Pull Request — master (#43)
by Marcel
27:43
created
calendar/inc/class.calendar_boupdate.inc.php 1 patch
Braces   +221 added lines, -57 removed lines patch added patch discarded remove patch
@@ -91,13 +91,19 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	function __construct()
93 93
 	{
94
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
94
+		if ($this->debug > 0)
95
+		{
96
+			$this->debug_message('calendar_boupdate::__construct() started',True);
97
+		}
95 98
 
96 99
 		parent::__construct();	// calling the parent constructor
97 100
 		
98 101
 		$this->resources_so = new resources_so();
99 102
 
100
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
103
+		if ($this->debug > 0)
104
+		{
105
+			$this->debug_message('calendar_boupdate::__construct() finished',True);
106
+		}
101 107
 	}
102 108
 
103 109
 	/**
@@ -128,7 +134,10 @@  discard block
 block discarded – undo
128 134
 	{
129 135
 		unset($updateTS);	// ignored, as updating timestamps is required for sync!
130 136
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
131
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
137
+		if (!is_array($messages))
138
+		{
139
+			$messages = $messages ? (array)$messages : array();
140
+		}
132 141
 
133 142
 		if ($this->debug > 1 || $this->debug == 'update')
134 143
 		{
@@ -148,10 +157,13 @@  discard block
 block discarded – undo
148 157
 
149 158
 		$status_reset_to_unknown = false;
150 159
 
151
-		if (($new_event = !$event['id']))	// some defaults for new entries
160
+		if (($new_event = !$event['id']))
161
+		{
162
+			// some defaults for new entries
152 163
 		{
153 164
 			// if no owner given, set user to owner
154 165
 			if (!$event['owner']) $event['owner'] = $this->user;
166
+		}
155 167
 			// set owner as participant if none is given
156 168
 			if (!is_array($event['participants']) || !count($event['participants']))
157 169
 			{
@@ -191,7 +203,10 @@  discard block
 block discarded – undo
191 203
 		// check category based ACL
192 204
 		if ($event['category'])
193 205
 		{
194
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
206
+			if (!is_array($event['category']))
207
+			{
208
+				$event['category'] = explode(',',$event['category']);
209
+			}
195 210
 			if (!$old_event || !isset($old_event['category']))
196 211
 			{
197 212
 				$old_event['category'] = array();
@@ -243,13 +258,16 @@  discard block
 block discarded – undo
243 258
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) &&
244 259
 			(($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding))
245 260
 		{
246
-			if ($checked_excluding)	// warn user if not all recurrences have been checked
261
+			if ($checked_excluding)
262
+			{
263
+				// warn user if not all recurrences have been checked
247 264
 			{
248 265
 				$conflicts['warning'] = array(
249 266
 					'start' => $checked_excluding,
250 267
 					'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)),
251 268
 				);
252 269
 			}
270
+			}
253 271
 			return $conflicts;
254 272
 		}
255 273
 
@@ -313,7 +331,10 @@  discard block
 block discarded – undo
313 331
 		$types_with_quantity = array();
314 332
 		foreach($this->resources as $type => $data)
315 333
 		{
316
-			if ($data['max_quantity']) $types_with_quantity[] = $type;
334
+			if ($data['max_quantity'])
335
+			{
336
+				$types_with_quantity[] = $type;
337
+			}
317 338
 		}
318 339
 		// get all NOT rejected participants and evtl. their quantity
319 340
 		$quantity = $users = array();
@@ -321,12 +342,19 @@  discard block
 block discarded – undo
321 342
 		{
322 343
 			$q = $role = null;
323 344
 			calendar_so::split_status($status, $q, $role);
324
-			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;	// ignore rejected or non-participants
345
+			if ($status == 'R' || $role == 'NON-PARTICIPANT')
346
+			{
347
+				continue;
348
+			}
349
+			// ignore rejected or non-participants
325 350
 
326
-			if ($uid < 0)	// group, check it's members too
351
+			if ($uid < 0)
352
+			{
353
+				// group, check it's members too
327 354
 			{
328 355
 				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
329 356
 			}
357
+			}
330 358
 			$users[] = $uid;
331 359
 			if (in_array($uid[0],$types_with_quantity))
332 360
 			{
@@ -357,18 +385,24 @@  discard block
 block discarded – undo
357 385
 			$startts = $date->format('ts');
358 386
 
359 387
 			// skip past events or recurrences
360
-			if ($startts+$duration < $this->now_su) continue;
388
+			if ($startts+$duration < $this->now_su)
389
+			{
390
+				continue;
391
+			}
361 392
 
362 393
 			// abort check if configured limits are exceeded
363 394
 			if ($event['recur_type'] &&
364 395
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
365 396
 				microtime(true) > $start+$max_check_time ||	// max check time exceeded
366
-				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
397
+				$startts > $this->config['horizont']))
398
+			{
399
+				// we are behind horizon for which recurrences are rendered
367 400
 			{
368 401
 				if ($this->debug > 2 || $this->debug == 'conflicts')
369 402
 				{
370 403
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
371 404
 						$checked, microtime(true)-$start, $date);
405
+			}
372 406
 				}
373 407
 				$checked_excluding = $date;
374 408
 				break;
@@ -392,10 +426,13 @@  discard block
 block discarded – undo
392 426
 			{
393 427
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
394 428
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
395
-					$overlap['non_blocking'])			// that's a non_blocking event
429
+					$overlap['non_blocking'])
430
+				{
431
+					// that's a non_blocking event
396 432
 				{
397 433
 					continue;
398 434
 				}
435
+				}
399 436
 				if ($this->debug > 3 || $this->debug == 'conflicts')
400 437
 				{
401 438
 					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
@@ -518,7 +555,8 @@  discard block
 block discarded – undo
518 555
 		if (!is_numeric($uid))
519 556
 		{
520 557
 			$resources_config = Api\Config::read('resources');
521
-			if ($resources_config['bookingrequests'] === 'disabled') {
558
+			if ($resources_config['bookingrequests'] === 'disabled')
559
+			{
522 560
 				$cat_id = $this->resources_so->get_value('cat_id', intval(substr($uid, 1)));
523 561
 				return resources_acl_bo::is_permitted($cat_id, resources_acl_bo::DIRECT_BOOKING);
524 562
 			}
@@ -888,14 +926,20 @@  discard block
 block discarded – undo
888 926
 		$startdate = new Api\DateTime($event['start']);
889 927
 		$enddate = new Api\DateTime($event['end']);
890 928
 		$modified = new Api\DateTime($event['modified']);
891
-		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
929
+		if ($old_event)
930
+		{
931
+			$olddate = new Api\DateTime($old_event['start']);
932
+		}
892 933
 		//error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : ''));
893 934
 		$owner_prefs = $ics = null;
894 935
 		foreach($to_notify as $userid => $statusid)
895 936
 		{
896 937
 			$res_info = $quantity = $role = null;
897 938
 			calendar_so::split_status($statusid, $quantity, $role);
898
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
939
+			if ($this->debug > 0)
940
+			{
941
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
942
+			}
899 943
 
900 944
 			if (!is_numeric($userid))
901 945
 			{
@@ -914,7 +958,11 @@  discard block
 block discarded – undo
914 958
 
915 959
 				if (!isset($userid))
916 960
 				{
917
-					if (empty($res_info['email'])) continue;	// no way to notify
961
+					if (empty($res_info['email']))
962
+					{
963
+						continue;
964
+					}
965
+					// no way to notify
918 966
 					// check if event-owner wants non-EGroupware users notified
919 967
 					if (is_null($owner_prefs))
920 968
 					{
@@ -988,7 +1036,10 @@  discard block
 block discarded – undo
988 1036
 				$details['to-lastname'] = isset($tln)? $tln: '';
989 1037
 
990 1038
 				// event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account
991
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1039
+				if (!isset($part_prefs['common']['tz']))
1040
+				{
1041
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1042
+				}
992 1043
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
993 1044
 				$timeformat = $part_prefs['common']['timeformat'];
994 1045
 				switch($timeformat)
@@ -1023,9 +1074,12 @@  discard block
 block discarded – undo
1023 1074
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
1024 1075
 				{
1025 1076
 					case 'ical':
1026
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
1077
+						if (is_null($ics) || $m_type != $msg_type)
1078
+						{
1079
+							// need different ical for organizer notification
1027 1080
 						{
1028 1081
 							$calendar_ical = new calendar_ical();
1082
+						}
1029 1083
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
1030 1084
 							// we need to pass $event[id] so iCal class reads event again,
1031 1085
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -1041,7 +1095,10 @@  discard block
 block discarded – undo
1041 1095
 							'encoding' => '8bit',
1042 1096
 							'type' => 'text/calendar; method='.$method,
1043 1097
 						);
1044
-						if ($m_type != $msg_type) unset($ics);
1098
+						if ($m_type != $msg_type)
1099
+						{
1100
+							unset($ics);
1101
+						}
1045 1102
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
1046 1103
 						// fall through
1047 1104
 					case 'extended':
@@ -1098,11 +1155,16 @@  discard block
 block discarded – undo
1098 1155
 								'user_id' => $userid
1099 1156
 							));
1100 1157
 						}
1101
-						if ($m_type === MSG_ALARM) $notification->set_popupdata('calendar', array('egw_pr_notify' => 1));
1158
+						if ($m_type === MSG_ALARM)
1159
+						{
1160
+							$notification->set_popupdata('calendar', array('egw_pr_notify' => 1));
1161
+						}
1102 1162
 						$notification->set_popupmessage($subject."\n\n".$notify_body."\n\n".$details['description']."\n\n".$details_body."\n\n");
1103 1163
 						$notification->set_popuplinks(array($details['link_arr']+array('app'=>'calendar')));
1104 1164
 
1105
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1165
+						if(is_array($attachment))
1166
+						{
1167
+$notification->set_attachments(array($attachment)); }
1106 1168
 						$notification->send();
1107 1169
 						foreach(notifications::errors(true) as $error)
1108 1170
 						{
@@ -1138,7 +1200,10 @@  discard block
 block discarded – undo
1138 1200
 			Api\Translation::init();
1139 1201
 		}
1140 1202
 		// restore timezone, in case we had to reset it to server-timezone
1141
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1203
+		if ($restore_tz)
1204
+		{
1205
+			date_default_timezone_set($restore_tz);
1206
+		}
1142 1207
 
1143 1208
 		return true;
1144 1209
 	}
@@ -1173,10 +1238,13 @@  discard block
 block discarded – undo
1173 1238
 		{
1174 1239
 			$to_notify = $event['participants'];
1175 1240
 		}
1176
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1241
+		elseif ($this->check_perms(Acl::READ,$event))
1242
+		{
1243
+			// checks agains $this->owner set to $alarm[owner]
1177 1244
 		{
1178 1245
 			$to_notify[$alarm['owner']] = 'A';
1179 1246
 		}
1247
+		}
1180 1248
 		else
1181 1249
 		{
1182 1250
 			return False;	// no rights
@@ -1225,14 +1293,20 @@  discard block
 block discarded – undo
1225 1293
 		if ($event['id'])
1226 1294
 		{
1227 1295
 			// invalidate the read-cache if it contains the event we store now
1228
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1296
+			if ($event['id'] == self::$cached_event['id'])
1297
+			{
1298
+				self::$cached_event = array();
1299
+			}
1229 1300
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1230 1301
 		}
1231 1302
 		else
1232 1303
 		{
1233 1304
 			$old_event = null;
1234 1305
 		}
1235
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1306
+		if (!isset($event['whole_day']))
1307
+		{
1308
+			$event['whole_day'] = $this->isWholeDay($event);
1309
+		}
1236 1310
 
1237 1311
 		// set recur-enddate/range-end to real end-date of last recurrence
1238 1312
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'])
@@ -1309,7 +1383,10 @@  discard block
 block discarded – undo
1309 1383
 		foreach($timestamps as $ts)
1310 1384
 		{
1311 1385
 			// we convert here from user-time to timestamps in server-time!
1312
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1386
+			if (isset($event[$ts]))
1387
+			{
1388
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1389
+			}
1313 1390
 		}
1314 1391
 		// convert tzid name to integer tz_id, of set user default
1315 1392
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1360,7 +1437,10 @@  discard block
 block discarded – undo
1360 1437
 				if (!isset($event['alarm'][$id]))
1361 1438
 				{
1362 1439
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1363
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1440
+					if ($alarm['time'] < time())
1441
+					{
1442
+						calendar_so::shift_alarm($event, $alarm);
1443
+					}
1364 1444
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1365 1445
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1366 1446
 						$old_event['participants'][$alarm['owner']];
@@ -1416,7 +1496,10 @@  discard block
 block discarded – undo
1416 1496
 
1417 1497
 		// Update history
1418 1498
 		$tracking = new calendar_tracking($this);
1419
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1499
+		if (empty($event['id']) && !empty($cal_id))
1500
+		{
1501
+			$event['id']=$cal_id;
1502
+		}
1420 1503
 		$tracking->track($event, $old_event);
1421 1504
 
1422 1505
 		return $cal_id;
@@ -1433,9 +1516,12 @@  discard block
 block discarded – undo
1433 1516
 	 */
1434 1517
 	function check_status_perms($uid,$event)
1435 1518
 	{
1436
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1519
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1520
+		{
1521
+			// for contact we use the owner of the event
1437 1522
 		{
1438 1523
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1524
+		}
1439 1525
 
1440 1526
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1441 1527
 		}
@@ -1446,13 +1532,19 @@  discard block
 block discarded – undo
1446 1532
 			return $access;
1447 1533
 		}
1448 1534
 		// no access or denied access because of category acl --> regular check
1449
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1535
+		if (!is_numeric($uid))
1536
+		{
1537
+			// this is eg. for resources (r123)
1450 1538
 		{
1451 1539
 			$resource = $this->resource_info($uid);
1540
+		}
1452 1541
 
1453 1542
 			return Acl::EDIT & $resource['rights'];
1454 1543
 		}
1455
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1544
+		if (!is_array($event) && !($event = $this->read($event)))
1545
+		{
1546
+			return false;
1547
+		}
1456 1548
 
1457 1549
 		// regular user and groups (need to check memberships too)
1458 1550
 		if (!isset($event['participants'][$uid]))
@@ -1476,7 +1568,10 @@  discard block
 block discarded – undo
1476 1568
 	 */
1477 1569
 	function check_cat_acl($right,$event)
1478 1570
 	{
1479
-		if (!is_array($event)) $event = $this->read($event);
1571
+		if (!is_array($event))
1572
+		{
1573
+			$event = $this->read($event);
1574
+		}
1480 1575
 
1481 1576
 		$ret = null;
1482 1577
 		if ($event['category'])
@@ -1533,7 +1628,10 @@  discard block
 block discarded – undo
1533 1628
 	public static function set_cat_rights($cat_id,$user,$rights)
1534 1629
 	{
1535 1630
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1536
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1631
+		if (!isset(self::$cat_rights_cache))
1632
+		{
1633
+			self::get_cat_rights($cat_id);
1634
+		}
1537 1635
 
1538 1636
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1539 1637
 		{
@@ -1545,7 +1643,10 @@  discard block
 block discarded – undo
1545 1643
 			else
1546 1644
 			{
1547 1645
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1548
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1646
+				if (!self::$cat_rights_cache['L'.$cat_id])
1647
+				{
1648
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1649
+				}
1549 1650
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1550 1651
 			}
1551 1652
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1578,7 +1679,10 @@  discard block
 block discarded – undo
1578 1679
 				foreach($cat_rights as $uid => $value)
1579 1680
 				{
1580 1681
 					$all |= $value;
1581
-					if (in_array($uid,$memberships)) $own |= $value;
1682
+					if (in_array($uid,$memberships))
1683
+					{
1684
+						$own |= $value;
1685
+					}
1582 1686
 				}
1583 1687
 			}
1584 1688
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1625,13 +1729,16 @@  discard block
 block discarded – undo
1625 1729
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1626 1730
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1627 1731
 		{
1628
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1732
+			if ($status == 'R')
1733
+			{
1734
+				// remove alarms belonging to rejected participants
1629 1735
 			{
1630 1736
 				foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1631 1737
 				{
1632 1738
 					if ((string)$alarm['owner'] === (string)$uid)
1633 1739
 					{
1634 1740
 						$this->so->delete_alarm($id);
1741
+			}
1635 1742
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1636 1743
 					}
1637 1744
 				}
@@ -1648,8 +1755,15 @@  discard block
 block discarded – undo
1648 1755
 
1649 1756
 			if (isset($status2msg[$status]) && !$skip_notification)
1650 1757
 			{
1651
-				if (!is_array($event)) $event = $this->read($cal_id);
1652
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1758
+				if (!is_array($event))
1759
+				{
1760
+					$event = $this->read($cal_id);
1761
+				}
1762
+				if (isset($recur_date))
1763
+				{
1764
+					$event = $this->read($event['id'],$recur_date);
1765
+				}
1766
+				//re-read the actually edited recurring event
1653 1767
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1654 1768
 			}
1655 1769
 
@@ -1672,12 +1786,16 @@  discard block
 block discarded – undo
1672 1786
 	 */
1673 1787
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1674 1788
 	{
1675
-		if (!isset($new_event['participants'])) return;
1789
+		if (!isset($new_event['participants']))
1790
+		{
1791
+			return;
1792
+		}
1676 1793
 
1677 1794
 		// check the old list against the new list
1678 1795
 		foreach ($old_event['participants'] as $userid => $status)
1679
-  		{
1680
-            if (!isset($new_event['participants'][$userid])){
1796
+		{
1797
+            if (!isset($new_event['participants'][$userid]))
1798
+            {
1681 1799
             	// Attendee will be deleted this way
1682 1800
             	$new_event['participants'][$userid] = 'G';
1683 1801
             }
@@ -1760,7 +1878,10 @@  discard block
 block discarded – undo
1760 1878
 					}
1761 1879
 					else
1762 1880
 					{
1763
-						if (!($exception = $this->read($id))) continue;
1881
+						if (!($exception = $this->read($id)))
1882
+						{
1883
+							continue;
1884
+						}
1764 1885
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1765 1886
 						$exception['reference'] = $exception['recurrence'] = 0;
1766 1887
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1831,7 +1952,10 @@  discard block
 block discarded – undo
1831 1952
 		$event_arr = $this->event2array($event);
1832 1953
 		foreach($event_arr as $key => $val)
1833 1954
 		{
1834
-			if ($key == 'recur_type') $key = 'repetition';
1955
+			if ($key == 'recur_type')
1956
+			{
1957
+				$key = 'repetition';
1958
+			}
1835 1959
 			$details[$key] = $val['data'];
1836 1960
 		}
1837 1961
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1840,7 +1964,10 @@  discard block
 block discarded – undo
1840 1964
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
1841 1965
 		$link = $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit&cal_id='.$event['id'].'&date='.$eventStart_arr['full'].'&no_popup=1&ajax=true';
1842 1966
 		// if url is only a path, try guessing the rest ;-)
1843
-		if ($link[0] == '/') $link = Api\Framework::getUrl($link);
1967
+		if ($link[0] == '/')
1968
+		{
1969
+			$link = Api\Framework::getUrl($link);
1970
+		}
1844 1971
 		$event_arr['link']['data'] = $details['link'] = $link;
1845 1972
 
1846 1973
 		/* this is needed for notification-app
@@ -1999,7 +2126,10 @@  discard block
 block discarded – undo
1999 2126
 	 */
2000 2127
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
2001 2128
 	{
2002
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
2129
+		if ($old_event !== null && $event['start'] == $old_event['start'])
2130
+		{
2131
+			return;
2132
+		}
2003 2133
 
2004 2134
 		$time = new Api\DateTime($event['start']);
2005 2135
 		if(!is_array($event['alarm']))
@@ -2073,7 +2203,10 @@  discard block
 block discarded – undo
2073 2203
 		if (is_array($old_event) || $old_event > 0)
2074 2204
 		{
2075 2205
 			// preserve categories without users read access
2076
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2206
+			if (!is_array($old_event))
2207
+			{
2208
+				$old_event = $this->read($old_event);
2209
+			}
2077 2210
 			$old_categories = explode(',',$old_event['category']);
2078 2211
 			$old_cats_preserve = array();
2079 2212
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -2164,7 +2297,10 @@  discard block
 block discarded – undo
2164 2297
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2165 2298
 		}
2166 2299
 
2167
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2300
+		if (!isset($event['recurrence']))
2301
+		{
2302
+			$event['recurrence'] = 0;
2303
+		}
2168 2304
 
2169 2305
 		if ($filter == 'master')
2170 2306
 		{
@@ -2218,19 +2354,26 @@  discard block
 block discarded – undo
2218 2354
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2219 2355
 						}
2220 2356
 					}
2221
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2357
+				}
2358
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2222 2359
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2223 2360
 							strpos($egwEvent['title'], $event['title']) === 0))
2224 2361
 				{
2225 2362
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2226 2363
 				}
2227 2364
 			}
2228
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2365
+			if (!empty($matchingEvents) || $filter == 'exact')
2366
+			{
2367
+				return $matchingEvents;
2368
+			}
2229 2369
 		}
2230 2370
 		unset($event['id']);
2231 2371
 
2232 2372
 		// No chance to find a master without [U]ID
2233
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2373
+		if ($filter == 'master' && empty($event['uid']))
2374
+		{
2375
+			return $matchingEvents;
2376
+		}
2234 2377
 
2235 2378
 		// only query calendars of users, we have READ-grants from
2236 2379
 		$users = array();
@@ -2239,17 +2382,23 @@  discard block
 block discarded – undo
2239 2382
 			$user = trim($user);
2240 2383
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2241 2384
 			{
2242
-				if ($user && !in_array($user,$users))	// already added?
2385
+				if ($user && !in_array($user,$users))
2386
+				{
2387
+					// already added?
2243 2388
 				{
2244 2389
 					$users[] = $user;
2245 2390
 				}
2391
+				}
2246 2392
 			}
2247 2393
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2248 2394
 			{
2249 2395
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2250 2396
 			}
2251 2397
 			// the further code is only for real users
2252
-			if (!is_numeric($user)) continue;
2398
+			if (!is_numeric($user))
2399
+			{
2400
+				continue;
2401
+			}
2253 2402
 
2254 2403
 			// for groups we have to include the members
2255 2404
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2329,7 +2478,10 @@  discard block
 block discarded – undo
2329 2478
 			}
2330 2479
 			foreach ($matchFields as $key)
2331 2480
 			{
2332
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2481
+				if (isset($event[$key]))
2482
+				{
2483
+					$query['cal_'.$key] = $event[$key];
2484
+				}
2333 2485
 			}
2334 2486
 		}
2335 2487
 
@@ -2369,7 +2521,10 @@  discard block
 block discarded – undo
2369 2521
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2370 2522
 			}
2371 2523
 
2372
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2524
+			if (in_array($egwEvent['id'], $matchingEvents))
2525
+			{
2526
+				continue;
2527
+			}
2373 2528
 
2374 2529
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2375 2530
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2536,13 +2691,16 @@  discard block
 block discarded – undo
2536 2691
 					foreach ($event['participants'] as $attendee => $status)
2537 2692
 					{
2538 2693
 						if (!isset($egwEvent['participants'][$attendee]) &&
2539
-								$attendee != $egwEvent['owner']) // ||
2694
+								$attendee != $egwEvent['owner'])
2695
+						{
2696
+							// ||
2540 2697
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2541 2698
 						{
2542 2699
 							if ($this->log)
2543 2700
 							{
2544 2701
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2545 2702
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2703
+						}
2546 2704
 							}
2547 2705
 							continue 2;
2548 2706
 						}
@@ -2864,7 +3022,10 @@  discard block
 block discarded – undo
2864 3022
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2865 3023
 		{
2866 3024
 			// we convert here from server-time to timestamps in user-time!
2867
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
3025
+			if (isset($event[$ts]))
3026
+			{
3027
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
3028
+			}
2868 3029
 		}
2869 3030
 		// same with the recur exceptions
2870 3031
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2892,9 +3053,12 @@  discard block
 block discarded – undo
2892 3053
 	 */
2893 3054
 	function purge($age)
2894 3055
 	{
2895
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
3056
+		if (is_numeric($age) && $age > 0)
3057
+		{
3058
+			// just make sure bogus values dont delete everything
2896 3059
 		{
2897 3060
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2898 3061
 		}
3062
+		}
2899 3063
 	}
2900 3064
 }
Please login to merge, or discard this patch.