Completed
Push — 16.1 ( ca7a53...0d360c )
by Ralf
48:00 queued 29:15
created
calendar/inc/class.calendar_uiforms.inc.php 2 patches
Braces   +294 added lines, -75 removed lines patch added patch discarded remove patch
@@ -121,11 +121,14 @@  discard block
 block discarded – undo
121 121
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
122 122
 			!$this->bo->check_perms(Acl::ADD,0,$owner))
123 123
 		{
124
-			if ($owner)	// make an owner who is no user or we have no add-rights a participant
124
+			if ($owner)
125
+			{
126
+				// make an owner who is no user or we have no add-rights a participant
125 127
 			{
126 128
 				if(!is_array($owner))
127 129
 				{
128 130
 					$owner = explode(',',$owner);
131
+			}
129 132
 				}
130 133
 				// if we come from ressources we don't need any users selected in calendar
131 134
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
@@ -157,9 +160,17 @@  discard block
 block discarded – undo
157 160
 		$participant_types['u'] = $participant_types = $participants = array();
158 161
 		foreach($extra_participants as $uid)
159 162
 		{
160
-			if (isset($participants[$uid])) continue;	// already included
163
+			if (isset($participants[$uid]))
164
+			{
165
+				continue;
166
+			}
167
+			// already included
161 168
 
162
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
169
+			if (!$this->bo->check_acl_invite($uid))
170
+			{
171
+				continue;
172
+			}
173
+			// no right to invite --> ignored
163 174
 
164 175
 			if (is_numeric($uid))
165 176
 			{
@@ -197,10 +208,13 @@  discard block
 block discarded – undo
197 208
 				}
198 209
 			}
199 210
 		}
200
-		if (!$participants)	// if all participants got removed, include current user
211
+		if (!$participants)
212
+		{
213
+			// if all participants got removed, include current user
201 214
 		{
202 215
 			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
203 216
 		}
217
+		}
204 218
 		if(isset($_GET['cat_id']))
205 219
 		{
206 220
 			$cat_id = explode(',',$_GET['cat_id']);
@@ -250,10 +264,13 @@  discard block
 block discarded – undo
250 264
 	 */
251 265
 	function process_edit($content)
252 266
 	{
253
-		if (!is_array($content))	// redirect from etemplate, if POST empty
267
+		if (!is_array($content))
268
+		{
269
+			// redirect from etemplate, if POST empty
254 270
 		{
255 271
 			return $this->edit(null,null,strip_tags($_GET['msg']));
256 272
 		}
273
+		}
257 274
 		// clear notification errors
258 275
 		notifications::errors(true);
259 276
 		$messages = null;
@@ -266,7 +283,11 @@  discard block
 block discarded – undo
266 283
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
267 284
 
268 285
 		list($button) = @each($content['button']);
269
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
286
+		if (!$button && $content['action'])
287
+		{
288
+			$button = $content['action'];
289
+		}
290
+		// action selectbox
270 291
 		unset($content['button']); unset($content['action']);
271 292
 
272 293
 		$view = $content['view'];
@@ -279,7 +300,10 @@  discard block
 block discarded – undo
279 300
 		{
280 301
 			list($date) = each($content['recur_exception']['delete_exception']);
281 302
 			// eT2 converts time to
282
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
303
+			if (!is_numeric($date))
304
+			{
305
+				$date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
306
+			}
283 307
 			unset($content['recur_exception']['delete_exception']);
284 308
 			if (($key = array_search($date,$content['recur_exception'])) !== false)
285 309
 			{
@@ -288,7 +312,10 @@  discard block
 block discarded – undo
288 312
 				foreach ($recur_exceptions as $id)
289 313
 				{
290 314
 					if (!($exception = $this->bo->read($id)) ||
291
-							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
315
+							$exception['recurrence'] != $content['recur_exception'][$key])
316
+					{
317
+						continue;
318
+					}
292 319
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
293 320
 					$exception['reference'] = $exception['recurrence'] = 0;
294 321
 					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
@@ -363,7 +390,10 @@  discard block
 block discarded – undo
363 390
 				$event['end'] = $this->bo->date2ts($event['end']);
364 391
 			}
365 392
 			// some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa
366
-			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
393
+			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data'])
394
+			{
395
+				$event['recur_type'] = MCAL_RECUR_WEEKLY;
396
+			}
367 397
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
368 398
 			{
369 399
 				$event['recur_data'] = 1 << (int)date('w',$event['start']);
@@ -490,7 +520,11 @@  discard block
 block discarded – undo
490 520
 							break;
491 521
 
492 522
 						default:		// existing participant row
493
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
523
+							if (!is_array($data))
524
+							{
525
+								continue;
526
+							}
527
+							// widgets in participant tab, above participant list
494 528
 							foreach(array('uid','status','quantity','role') as $name)
495 529
 							{
496 530
 								$$name = $data[$name];
@@ -622,7 +656,10 @@  discard block
 block discarded – undo
622 656
 			{
623 657
 				foreach($participants as $id => &$p_response)
624 658
 				{
625
-					if($type == 'u' && $id == $event['owner']) continue;
659
+					if($type == 'u' && $id == $event['owner'])
660
+					{
661
+						continue;
662
+					}
626 663
 					calendar_so::split_status($p_response, $quantity, $role);
627 664
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
628 665
 					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
@@ -704,17 +741,23 @@  discard block
 block discarded – undo
704 741
 			{
705 742
 				foreach (array_keys($event['participants']) as $uid)
706 743
 				{
707
-					if ($uid[0] == 'r') //ressource detection
744
+					if ($uid[0] == 'r')
745
+					{
746
+						//ressource detection
708 747
 					{
709 748
 						$msg = lang('Error: ressources reservation in private events is not allowed!!!');
749
+					}
710 750
 						$button = '';
711 751
 						break 2; //break foreach and case
712 752
 					}
713 753
 				}
714 754
 			}
715
-			if ($content['edit_single'])	// we edited a single event from a series
755
+			if ($content['edit_single'])
756
+			{
757
+				// we edited a single event from a series
716 758
 			{
717 759
 				$event['reference'] = $event['id'];
760
+			}
718 761
 				$event['recurrence'] = $content['edit_single'];
719 762
 				unset($event['id']);
720 763
 				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
@@ -816,7 +859,10 @@  discard block
 block discarded – undo
816 859
 										case 'no':
817 860
 											break;
818 861
 										case 'startday':
819
-											if ($sameday) break;
862
+											if ($sameday)
863
+											{
864
+												break;
865
+											}
820 866
 										default:
821 867
 											$status_reset_to_unknown = true;
822 868
 											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -984,7 +1030,10 @@  discard block
 block discarded – undo
984 1030
 				if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single'])
985 1031
 				{
986 1032
 					$msg = lang('Series deleted');
987
-					if ($exceptions_kept) $msg .= lang(', exceptions preserved');
1033
+					if ($exceptions_kept)
1034
+					{
1035
+						$msg .= lang(', exceptions preserved');
1036
+					}
988 1037
 				}
989 1038
 				else
990 1039
 				{
@@ -1020,11 +1069,14 @@  discard block
 block discarded – undo
1020 1069
 				{
1021 1070
 					$msg = lang("Can't add alarms in the past !!!");
1022 1071
 				}
1023
-				elseif ($event['id'])	// save the alarm immediatly
1072
+				elseif ($event['id'])
1073
+				{
1074
+					// save the alarm immediatly
1024 1075
 				{
1025 1076
 					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1026 1077
 					{
1027 1078
 						$alarm['id'] = $alarm_id;
1079
+				}
1028 1080
 						$event['alarm'][$alarm_id] = $alarm;
1029 1081
 
1030 1082
 						$msg = lang('Alarm added');
@@ -1037,7 +1089,9 @@  discard block
 block discarded – undo
1037 1089
 				}
1038 1090
 				else
1039 1091
 				{
1040
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1092
+					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++)
1093
+					{
1094
+}	// get a temporary non-conflicting, numeric id
1041 1095
 					$event['alarm'][$alarm['id']] = $alarm;
1042 1096
 				}
1043 1097
 			}
@@ -1060,10 +1114,13 @@  discard block
 block discarded – undo
1060 1114
 		}
1061 1115
 		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1062 1116
 		{
1063
-			if ($content['lock_token'])	// remove an existing lock
1117
+			if ($content['lock_token'])
1118
+			{
1119
+				// remove an existing lock
1064 1120
 			{
1065 1121
 				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1066 1122
 			}
1123
+			}
1067 1124
 			if ($content['no_popup'])
1068 1125
 			{
1069 1126
 				Egw::redirect_link('/index.php',array(
@@ -1120,13 +1177,19 @@  discard block
 block discarded – undo
1120 1177
 		}
1121 1178
 
1122 1179
 		// Copy links
1123
-		if(!is_array($event['link_to'])) $event['link_to'] = array();
1180
+		if(!is_array($event['link_to']))
1181
+		{
1182
+			$event['link_to'] = array();
1183
+		}
1124 1184
 		$event['link_to']['to_app'] = 'calendar';
1125 1185
 		$event['link_to']['to_id'] = 0;
1126 1186
 
1127 1187
 		foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1128 1188
 		{
1129
-			if(!$link['id']) continue;
1189
+			if(!$link['id'])
1190
+			{
1191
+				continue;
1192
+			}
1130 1193
 			if ($link['app'] != Link::VFS_APPNAME)
1131 1194
 			{
1132 1195
 				Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
@@ -1194,8 +1257,7 @@  discard block
 block discarded – undo
1194 1257
 		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1195 1258
 			// Adjust for requested date in the past
1196 1259
 			Api\DateTime::to($as_of_date,'ts') < time()
1197
-		)
1198
-		{
1260
+		) {
1199 1261
 
1200 1262
 			unset($orig_event);
1201 1263
 			// copy event by unsetting the id(s)
@@ -1283,30 +1345,48 @@  discard block
 block discarded – undo
1283 1345
 		foreach($event['participants'] as $uid => $status)
1284 1346
 		{
1285 1347
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1286
-			if (empty($status)) continue;
1348
+			if (empty($status))
1349
+			{
1350
+				continue;
1351
+			}
1287 1352
 			$toadd = '';
1288
-			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue;
1353
+			if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user))
1354
+			{
1355
+				continue;
1356
+			}
1289 1357
 
1290 1358
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1291 1359
 			{
1292
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1360
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email')))
1361
+				{
1362
+					continue;
1363
+				}
1293 1364
 
1294 1365
 				$toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '.
1295 1366
 					$GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>';
1296 1367
 
1297
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1368
+				if (!in_array($toadd,$to))
1369
+				{
1370
+					$to[] = $toadd;
1371
+				}
1298 1372
 			}
1299 1373
 			elseif ($uid < 0)
1300 1374
 			{
1301 1375
 				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1302 1376
 				{
1303
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1377
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email')))
1378
+					{
1379
+						continue;
1380
+					}
1304 1381
 
1305 1382
 					$toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1306 1383
 						$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>';
1307 1384
 
1308 1385
 					// dont add groupmembers if they already rejected the event, or are the current user
1309
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1386
+					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user))
1387
+					{
1388
+						$to[] = $toadd;
1389
+					}
1310 1390
 				}
1311 1391
 			}
1312 1392
 			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
@@ -1358,7 +1438,10 @@  discard block
 block discarded – undo
1358 1438
 			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1359 1439
 			'preset[size]'    => filesize($ics_file),
1360 1440
 		);
1361
-		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1441
+		if ($asrequest)
1442
+		{
1443
+			$vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
1444
+		}
1362 1445
 		$response = Api\Json\Response::get();
1363 1446
 		$response->call('app.calendar.custom_mail', $vars);
1364 1447
 	}
@@ -1544,9 +1627,15 @@  discard block
 block discarded – undo
1544 1627
 				}
1545 1628
 			}
1546 1629
 			// set new start and end if given by $_GET
1547
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1548
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1549
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1630
+			if(isset($_GET['start']))
1631
+			{
1632
+$event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1633
+			if(isset($_GET['end']))
1634
+			{
1635
+$event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1636
+			if(isset($_GET['non_blocking']))
1637
+			{
1638
+$event['non_blocking'] = (bool)$_GET['non_blocking']; }
1550 1639
 			// check if the event is the whole day
1551 1640
 			$start = $this->bo->date2array($event['start']);
1552 1641
 			$end = $this->bo->date2array($event['end']);
@@ -1559,10 +1648,13 @@  discard block
 block discarded – undo
1559 1648
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1560 1649
 				{
1561 1650
 					$link_id = $link_ids[$n];
1562
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1651
+					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
1652
+					{
1653
+						// guard against XSS
1563 1654
 					{
1564 1655
 						continue;
1565 1656
 					}
1657
+					}
1566 1658
 					if(!$n)
1567 1659
 					{
1568 1660
 						$event['title'] = Link::title($link_app,$link_id);
@@ -1571,7 +1663,10 @@  discard block
 block discarded – undo
1571 1663
 						{
1572 1664
 							foreach((array)$set['link_app'] as $i => $l_app)
1573 1665
 							{
1574
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1666
+								if (($l_id=$set['link_id'][$i]))
1667
+								{
1668
+									Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1669
+								}
1575 1670
 							}
1576 1671
 							unset($set['link_app']);
1577 1672
 							unset($set['link_id']);
@@ -1597,10 +1692,13 @@  discard block
 block discarded – undo
1597 1692
 			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1598 1693
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1599 1694
 
1600
-			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1695
+			if (($preserv['lock_token'] = $event['lock_token']))
1696
+			{
1697
+				// already locked --> refresh the lock
1601 1698
 			{
1602 1699
 				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1603 1700
 			}
1701
+			}
1604 1702
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1605 1703
 			{
1606 1704
 				$msg .= ' '.lang('This entry is currently opened by %1!',
@@ -1634,14 +1732,20 @@  discard block
 block discarded – undo
1634 1732
 		));
1635 1733
 		Framework::message($msg, $msg_type);
1636 1734
 		$content['duration'] = $content['end'] - $content['start'];
1637
-		if (isset($this->durations[$content['duration']])) $content['end'] = '';
1735
+		if (isset($this->durations[$content['duration']]))
1736
+		{
1737
+			$content['end'] = '';
1738
+		}
1638 1739
 
1639 1740
 		$row = 3;
1640 1741
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1641 1742
 		// preserve some ui elements, if set eg. under error-conditions
1642 1743
 		foreach(array('quantity','resource','role') as $n)
1643 1744
 		{
1644
-			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1745
+			if (isset($event['participants'][$n]))
1746
+			{
1747
+				$content['participants'][$n] = $event['participants'][$n];
1748
+			}
1645 1749
 		}
1646 1750
 		foreach($event['participant_types'] as $type => $participants)
1647 1751
 		{
@@ -1683,9 +1787,13 @@  discard block
 block discarded – undo
1683 1787
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1684 1788
 
1685 1789
 				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1686
-					$readonlys['participants'][$row]['status'] = $no_status;
1790
+				{
1791
+									$readonlys['participants'][$row]['status'] = $no_status;
1792
+				}
1687 1793
 				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1688
-					$readonlys['participants']['delete'][$uid] = true;
1794
+				{
1795
+									$readonlys['participants']['delete'][$uid] = true;
1796
+				}
1689 1797
 				// todo: make the participants available as links with email as title
1690 1798
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1691 1799
 				// enumerate group-invitations, so people can accept/reject them
@@ -1716,7 +1824,11 @@  discard block
 block discarded – undo
1716 1824
 			$content['participants']['cal_resources'] = '';
1717 1825
 			foreach($this->bo->resources as $data)
1718 1826
 			{
1719
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1827
+				if ($data['app'] == 'email')
1828
+				{
1829
+					continue;
1830
+				}
1831
+				// make no sense, as we cant search for email
1720 1832
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1721 1833
 			}
1722 1834
 		}
@@ -1744,9 +1856,18 @@  discard block
 block discarded – undo
1744 1856
 				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1745 1857
 				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1746 1858
 				$label = array();
1747
-				if ($days) $label[] = $days.' '.lang('days');
1748
-				if ($hours) $label[] = $hours.' '.lang('hours');
1749
-				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1859
+				if ($days)
1860
+				{
1861
+					$label[] = $days.' '.lang('days');
1862
+				}
1863
+				if ($hours)
1864
+				{
1865
+					$label[] = $hours.' '.lang('hours');
1866
+				}
1867
+				if ($minutes)
1868
+				{
1869
+					$label[] = $minutes.' '.lang('Minutes');
1870
+				}
1750 1871
 				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1751 1872
 				$content['alarm'][] = $alarm;
1752 1873
 
@@ -1809,25 +1930,34 @@  discard block
 block discarded – undo
1809 1930
 			'participants' => $this->accountsel->account_selection == 'none',
1810 1931
 			'history' => !$event['id'],
1811 1932
 		);
1812
-		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))	// no mail without mail-app
1933
+		if (!isset($GLOBALS['egw_info']['user']['apps']['mail']))
1934
+		{
1935
+			// no mail without mail-app
1813 1936
 		{
1814 1937
 			unset($sel_options['action']['mail']);
1938
+		}
1815 1939
 			unset($sel_options['action']['sendmeetingrequest']);
1816 1940
 		}
1817
-		if (!$event['id'])	// no ical export for new (not saved) events
1941
+		if (!$event['id'])
1942
+		{
1943
+			// no ical export for new (not saved) events
1818 1944
 		{
1819 1945
 			$readonlys['action'] = true;
1820 1946
 		}
1947
+		}
1821 1948
 		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1822 1949
 		{
1823 1950
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1824 1951
 		}
1825 1952
 		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1826 1953
 
1827
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1954
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))
1955
+		{
1956
+			// new event or edit rights to the event ==> allow to add alarm for all users
1828 1957
 		{
1829 1958
 			$sel_options['owner'][0] = lang('All participants');
1830 1959
 		}
1960
+		}
1831 1961
 		if (isset($event['participant_types']['u'][$this->user]))
1832 1962
 		{
1833 1963
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
@@ -1870,7 +2000,10 @@  discard block
 block discarded – undo
1870 2000
 
1871 2001
 		$content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh'];
1872 2002
 
1873
-		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
2003
+		if (!empty($preserved['lock_token']))
2004
+		{
2005
+			$content['lock_token'] = $preserved['lock_token'];
2006
+		}
1874 2007
 
1875 2008
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1876 2009
 		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
@@ -2072,7 +2205,10 @@  discard block
 block discarded – undo
2072 2205
 					// set status and send notification / meeting response
2073 2206
 					if ($this->bo->set_status($event['id'], $user, $status))
2074 2207
 					{
2075
-						if (!$msg) $msg = lang('Status changed');
2208
+						if (!$msg)
2209
+						{
2210
+							$msg = lang('Status changed');
2211
+						}
2076 2212
 					}
2077 2213
 					break;
2078 2214
 
@@ -2151,13 +2287,16 @@  discard block
 block discarded – undo
2151 2287
 
2152 2288
 		foreach (array_keys($allConflicts) as $pId)
2153 2289
 		{
2154
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2290
+			if(substr($pId,0,1) == 'r' && $resources_config )
2291
+			{
2292
+				// resources Allow ignore conflicts
2155 2293
 			{
2156 2294
 
2157 2295
 				switch ($resources_config['ignoreconflicts'])
2158 2296
 				{
2159 2297
 					case 'no':
2160 2298
 						$readonlys['button[ignore]'] = true;
2299
+			}
2161 2300
 						break;
2162 2301
 					case 'allusers':
2163 2302
 						$readonlys['button[ignore]'] = false;
@@ -2301,7 +2440,10 @@  discard block
 block discarded – undo
2301 2440
 		}
2302 2441
 		else
2303 2442
 		{
2304
-			if (!$content['duration']) $content['duration'] = $content['end'] - $content['start'];
2443
+			if (!$content['duration'])
2444
+			{
2445
+				$content['duration'] = $content['end'] - $content['start'];
2446
+			}
2305 2447
 			$weekds = 0;
2306 2448
 			foreach ($content['weekdays'] as &$wdays)
2307 2449
 			{
@@ -2323,7 +2465,10 @@  discard block
 block discarded – undo
2323 2465
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2324 2466
 
2325 2467
 		$sel_options['duration'] = $this->durations;
2326
-		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2468
+		if ($content['duration'] && isset($sel_options['duration'][$content['duration']]))
2469
+		{
2470
+			$content['end'] = '';
2471
+		}
2327 2472
 
2328 2473
 		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2329 2474
 				'participants'	=> $content['participants'],
@@ -2344,7 +2489,10 @@  discard block
 block discarded – undo
2344 2489
 	 */
2345 2490
 	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2346 2491
 	{
2347
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2492
+		if ($this->debug > 2)
2493
+		{
2494
+			$this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2495
+		}
2348 2496
 
2349 2497
 		$busy = $this->bo->search(array(
2350 2498
 			'start' => $start,
@@ -2361,9 +2509,17 @@  discard block
 block discarded – undo
2361 2509
 		$n = 0;
2362 2510
 		foreach($busy as $event)
2363 2511
 		{
2364
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2512
+			if ((int)$cal_id && $event['id'] == (int)$cal_id)
2513
+			{
2514
+				continue;
2515
+			}
2516
+			// ignore our own event
2365 2517
 
2366
- 			if ($event['non_blocking']) continue; // ignore non_blocking events
2518
+ 			if ($event['non_blocking'])
2519
+ 			{
2520
+ 				continue;
2521
+ 			}
2522
+ 			// ignore non_blocking events
2367 2523
 
2368 2524
 			// check if from all wanted participants at least one has a not rejected status in found event
2369 2525
 			$non_rejected_found = false;
@@ -2372,7 +2528,10 @@  discard block
 block discarded – undo
2372 2528
 				$status = $event['participants'][$uid];
2373 2529
 				$quantity = $role = null;
2374 2530
 				calendar_so::split_status($status, $quantity, $role);
2375
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
2531
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
2532
+				{
2533
+					continue;
2534
+				}
2376 2535
 
2377 2536
 				if (isset($event['participants'][$uid]) ||
2378 2537
 					$uid > 0 && array_intersect(array_keys((array)$event['participants']),
@@ -2382,7 +2541,10 @@  discard block
 block discarded – undo
2382 2541
 					break;
2383 2542
 				}
2384 2543
 			}
2385
-			if (!$non_rejected_found) continue;
2544
+			if (!$non_rejected_found)
2545
+			{
2546
+				continue;
2547
+			}
2386 2548
 
2387 2549
 			if ($this->debug)
2388 2550
 			{
@@ -2413,11 +2575,17 @@  discard block
 block discarded – undo
2413 2575
 					'start'	=> $ft_start,
2414 2576
 					'end'	=> $ft_end,
2415 2577
 				);
2416
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2578
+				if ($this->debug > 1)
2579
+				{
2580
+					echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2581
+				}
2417 2582
 			}
2418 2583
 			$ft_start = $event['end'];
2419 2584
 		}
2420
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2585
+		if ($this->debug > 0)
2586
+		{
2587
+			$this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2588
+		}
2421 2589
 
2422 2590
 		return $freetime;
2423 2591
 	}
@@ -2437,10 +2605,16 @@  discard block
 block discarded – undo
2437 2605
 	 */
2438 2606
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2439 2607
 	{
2440
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2608
+		if ($this->debug > 1)
2609
+		{
2610
+			$this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2611
+		}
2441 2612
 
2442 2613
 		$freetime_daywise = array();
2443
-		if (!is_array($sel_options)) $sel_options = array();
2614
+		if (!is_array($sel_options))
2615
+		{
2616
+			$sel_options = array();
2617
+		}
2444 2618
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2445 2619
 
2446 2620
 		$start_time = (int) $_start_time;	// ignore leading zeros
@@ -2450,7 +2624,10 @@  discard block
 block discarded – undo
2450 2624
 		if (($end_time - $start_time)*HOUR_s < $duration)
2451 2625
 		{
2452 2626
 			$end_time = 0;
2453
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2627
+			if ($this->debug > 1)
2628
+			{
2629
+				$this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2630
+			}
2454 2631
 		}
2455 2632
 		$n = 0;
2456 2633
 		foreach($freetime as $ft)
@@ -2471,13 +2648,19 @@  discard block
 block discarded – undo
2471 2648
 				}
2472 2649
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2473 2650
 
2474
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2651
+				if ($start-$daybegin < $start_time*HOUR_s)
2652
+				{
2653
+					// start earlier then start_time
2475 2654
 				{
2476 2655
 					$start = $daybegin + $start_time*HOUR_s;
2477 2656
 				}
2657
+				}
2478 2658
 				// if end_time given use it, else the original slot's end
2479 2659
 				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2480
-				if ($end > $ft['end']) $end = $ft['end'];
2660
+				if ($end > $ft['end'])
2661
+				{
2662
+					$end = $ft['end'];
2663
+				}
2481 2664
 
2482 2665
 				// slot to small for duration
2483 2666
 				if ($end - $start < $duration)
@@ -2519,7 +2702,10 @@  discard block
 block discarded – undo
2519 2702
 			{
2520 2703
 				$msg = lang('Permission denied');
2521 2704
 
2522
-				if ($return_error) return $msg;
2705
+				if ($return_error)
2706
+				{
2707
+					return $msg;
2708
+				}
2523 2709
 			}
2524 2710
 			else
2525 2711
 			{
@@ -2581,27 +2767,42 @@  discard block
 block discarded – undo
2581 2767
 		{
2582 2768
 			list($button) = each($_content['button']);
2583 2769
 			unset($_content['button']);
2584
-			if ($button != 'cancel')	// store changed Acl
2770
+			if ($button != 'cancel')
2771
+			{
2772
+				// store changed Acl
2585 2773
 			{
2586 2774
 				foreach($_content as $data)
2587 2775
 				{
2588 2776
 					if (!($cat_id = $data['cat_id'])) continue;
2777
+			}
2589 2778
 					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2590 2779
 					{
2591 2780
 						$rights = 0;
2592
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2593
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2594
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2781
+						if (in_array($account_id,(array)$data['add']))
2782
+						{
2783
+							$rights |= calendar_boupdate::CAT_ACL_ADD;
2784
+						}
2785
+						if (in_array($account_id,(array)$data['status']))
2786
+						{
2787
+							$rights |= calendar_boupdate::CAT_ACL_STATUS;
2788
+						}
2789
+						if ($account_id)
2790
+						{
2791
+							$this->bo->set_cat_rights($cat_id,$account_id,$rights);
2792
+						}
2595 2793
 					}
2596 2794
 				}
2597 2795
 			}
2598
-			if ($button != 'apply')	// end dialog
2796
+			if ($button != 'apply')
2797
+			{
2798
+				// end dialog
2599 2799
 			{
2600 2800
 				Egw::redirect_link('/index.php', array(
2601 2801
 					'menuaction' => 'admin.admin_ui.index',
2602 2802
 					'ajax' => 'true'
2603 2803
 				), 'admin');
2604 2804
 			}
2805
+			}
2605 2806
 		}
2606 2807
 		$content= $preserv = array();
2607 2808
 		$n = 1;
@@ -2615,8 +2816,14 @@  discard block
 block discarded – undo
2615 2816
 			);
2616 2817
 			foreach($data as $account_id => $rights)
2617 2818
 			{
2618
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2619
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2819
+				if ($rights & calendar_boupdate::CAT_ACL_ADD)
2820
+				{
2821
+					$row['add'][] = $account_id;
2822
+				}
2823
+				if ($rights & calendar_boupdate::CAT_ACL_STATUS)
2824
+				{
2825
+					$row['status'][] = $account_id;
2826
+				}
2620 2827
 			}
2621 2828
 			$content[$n] = $row;
2622 2829
 			$preserv[$n] = array(
@@ -2744,7 +2951,10 @@  discard block
 block discarded – undo
2744 2951
 					break;
2745 2952
 				}
2746 2953
 			}
2747
-			if($return) return;
2954
+			if($return)
2955
+			{
2956
+				return;
2957
+			}
2748 2958
 		}
2749 2959
 		$old_event=$event=$this->bo->read($eventId);
2750 2960
 		if (!$durationT)
@@ -2838,7 +3048,10 @@  discard block
 block discarded – undo
2838 3048
 			$this->bo->update($event,true, true, false, true, $message,true);
2839 3049
 
2840 3050
 			// Whole day non blocking with DAY_s would add a day
2841
-			if($duration==DAY_s) $duration=0;
3051
+			if($duration==DAY_s)
3052
+			{
3053
+				$duration=0;
3054
+			}
2842 3055
 		}
2843 3056
 
2844 3057
 		$status_reset_to_unknown = false;
@@ -2856,7 +3069,10 @@  discard block
 block discarded – undo
2856 3069
 					case 'no':
2857 3070
 						break;
2858 3071
 					case 'startday':
2859
-						if ($sameday) break;
3072
+						if ($sameday)
3073
+						{
3074
+							break;
3075
+						}
2860 3076
 					default:
2861 3077
 						$status_reset_to_unknown = true;
2862 3078
 						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
@@ -2900,7 +3116,10 @@  discard block
 block discarded – undo
2900 3116
 		{
2901 3117
 			$response->call('egw.message',  implode('<br />', $message));
2902 3118
 		}
2903
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
3119
+		if($event['id'] != $eventId )
3120
+		{
3121
+			$this->update_client($_eventId);
3122
+		}
2904 3123
 		if ($status_reset_to_unknown)
2905 3124
 		{
2906 3125
 			foreach((array)$event['participants'] as $uid => $status)
Please login to merge, or discard this patch.
Spacing   +466 added lines, -468 removed lines patch added patch discarded remove patch
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var locktime in seconds
57 57
 	 */
58
-	var $locktime_default=1;
58
+	var $locktime_default = 1;
59 59
 
60 60
 	/**
61 61
 	 * Constructor
62 62
 	 */
63 63
 	function __construct()
64 64
 	{
65
-		parent::__construct(true);	// call the parent's constructor
65
+		parent::__construct(true); // call the parent's constructor
66 66
 
67
-		for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
67
+		for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120))))
68 68
 		{
69
-			$this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60);
69
+			$this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60);
70 70
 		}
71 71
 	}
72 72
 
@@ -78,11 +78,10 @@  discard block
 block discarded – undo
78 78
 	function &default_add_event()
79 79
 	{
80 80
 		$extra_participants = $_GET['participants'] ?
81
-			(!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) :
82
-			array();
81
+			(!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array();
83 82
 
84 83
 		// if participant is a contact, add its link title as title
85
-		foreach($extra_participants as $uid)
84
+		foreach ($extra_participants as $uid)
86 85
 		{
87 86
 			if ($uid[0] == 'c')
88 87
 			{
@@ -94,14 +93,14 @@  discard block
 block discarded – undo
94 93
 		if (isset($_GET['owner']))
95 94
 		{
96 95
 			$owner = $_GET['owner'];
97
-			if(!is_array($owner) && strpos($owner, ','))
96
+			if (!is_array($owner) && strpos($owner, ','))
98 97
 			{
99
-				$owner = explode(',',$owner);
98
+				$owner = explode(',', $owner);
100 99
 			}
101
-			if(is_array($owner))
100
+			if (is_array($owner))
102 101
 			{
103 102
 				// old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0'
104
-				if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
103
+				if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1)
105 104
 				{
106 105
 					$extra_participants += $owner;
107 106
 				}
@@ -117,21 +116,21 @@  discard block
 block discarded – undo
117 116
 			// old behavior "selected" should also be used for not set preference, therefore we need to test for === '0'
118 117
 			$owner = $this->cal_prefs['default_participant'] === '0' ? $this->user : $this->owner;
119 118
 		}
120
-		error_log(__METHOD__ . ' owner: ' . array2string($owner));
119
+		error_log(__METHOD__.' owner: '.array2string($owner));
121 120
 
122 121
 		if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' ||
123
-			!$this->bo->check_perms(Acl::ADD,0,$owner))
122
+			!$this->bo->check_perms(Acl::ADD, 0, $owner))
124 123
 		{
125 124
 			if ($owner)	// make an owner who is no user or we have no add-rights a participant
126 125
 			{
127
-				if(!is_array($owner))
126
+				if (!is_array($owner))
128 127
 				{
129
-					$owner = explode(',',$owner);
128
+					$owner = explode(',', $owner);
130 129
 				}
131 130
 				// if we come from ressources we don't need any users selected in calendar
132 131
 				if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r')
133 132
 				{
134
-					foreach($owner as $uid)
133
+					foreach ($owner as $uid)
135 134
 					{
136 135
 						$extra_participants[] = $uid;
137 136
 					}
@@ -141,71 +140,71 @@  discard block
 block discarded – undo
141 140
 		}
142 141
 		//error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")");
143 142
 
144
-		if(isset($_GET['start']))
143
+		if (isset($_GET['start']))
145 144
 		{
146 145
 			$start = Api\DateTime::to($_GET['start'], 'ts');
147 146
 		}
148 147
 		else
149 148
 		{
150 149
 			$start = $this->bo->date2ts(array(
151
-				'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date,
152
-				'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
153
-				'minute' => (int) $_GET['minute'],
150
+				'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date,
151
+				'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']),
152
+				'minute' => (int)$_GET['minute'],
154 153
 			));
155 154
 		}
156 155
 		//echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n";
157 156
 
158 157
 		$participant_types['u'] = $participant_types = $participants = array();
159
-		foreach($extra_participants as $uid)
158
+		foreach ($extra_participants as $uid)
160 159
 		{
161
-			if (isset($participants[$uid])) continue;	// already included
160
+			if (isset($participants[$uid])) continue; // already included
162 161
 
163
-			if (!$this->bo->check_acl_invite($uid)) continue;	// no right to invite --> ignored
162
+			if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored
164 163
 
165 164
 			if (is_numeric($uid))
166 165
 			{
167 166
 				$participants[$uid] = $participant_types['u'][$uid] =
168
-					calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
169
-					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
167
+					calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
168
+					($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
170 169
 			}
171 170
 			elseif (is_array($this->bo->resources[$uid[0]]))
172 171
 			{
173 172
 				// Expand mailing lists
174
-				if($uid[0] == 'l')
173
+				if ($uid[0] == 'l')
175 174
 				{
176
-					foreach($this->bo->enum_mailing_list($uid) as $contact)
175
+					foreach ($this->bo->enum_mailing_list($uid) as $contact)
177 176
 					{
178
-						$participants[$contact] = $participant_types['c'][substr($contact,1)] =
179
-							calendar_so::combine_status('U',1,'REQ-PARTICIPANT');
177
+						$participants[$contact] = $participant_types['c'][substr($contact, 1)] =
178
+							calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT');
180 179
 					}
181 180
 					continue;
182 181
 				}
183 182
 				// if contact is a user, use the user instead (as the GUI)
184
-				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id')))
183
+				if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id')))
185 184
 				{
186 185
 					$uid = $account_id;
187 186
 					$participants[$uid] = $participant_types['u'][$uid] =
188
-						calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1,
189
-						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
187
+						calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1,
188
+						($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT');
190 189
 					continue;
191 190
 				}
192 191
 				$res_data = $this->bo->resources[$uid[0]];
193
-				list($id,$quantity) = explode(':',substr($uid,1));
194
-				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U'))
192
+				list($id, $quantity) = explode(':', substr($uid, 1));
193
+				if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U'))
195 194
 				{
196 195
 					$participants[$uid] = $participant_types[$uid[0]][$id] =
197
-						calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT');
196
+						calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT');
198 197
 				}
199 198
 			}
200 199
 		}
201 200
 		if (!$participants)	// if all participants got removed, include current user
202 201
 		{
203
-			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR');
202
+			$participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR');
204 203
 		}
205
-		if(isset($_GET['cat_id']))
204
+		if (isset($_GET['cat_id']))
206 205
 		{
207
-			$cat_id = explode(',',$_GET['cat_id']);
208
-			foreach($cat_id as &$cat)
206
+			$cat_id = explode(',', $_GET['cat_id']);
207
+			foreach ($cat_id as &$cat)
209 208
 			{
210 209
 				$cat = (int)$cat;
211 210
 			}
@@ -216,16 +215,16 @@  discard block
 block discarded – undo
216 215
 		if ((string)$this->cal_prefs['default-alarm'] !== '')
217 216
 		{
218 217
 			$offset = 60 * $this->cal_prefs['default-alarm'];
219
-			$alarms[1] =  array(
218
+			$alarms[1] = array(
220 219
 				'default' => 1,
221
-				'offset' => $offset ,
220
+				'offset' => $offset,
222 221
 				'time'   => $start - $offset,
223 222
 				'all'    => false,
224 223
 				'owner'  => $owner,
225 224
 				'id'	=> 1,
226 225
 			);
227 226
 		}
228
-		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60;
227
+		$duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60;
229 228
 		$end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration;
230 229
 		return array(
231 230
 			'participant_types' => $participant_types,
@@ -234,7 +233,7 @@  discard block
 block discarded – undo
234 233
 			'start' => $start,
235 234
 			'end'   => $end,
236 235
 			'tzid'  => $this->bo->common_prefs['tz'],
237
-			'priority' => 2,	// normal
236
+			'priority' => 2, // normal
238 237
 			'public'=> $this->cal_prefs['default_private'] ? 0 : 1,
239 238
 			'alarm' => $alarms,
240 239
 			'recur_exception' => array(),
@@ -253,7 +252,7 @@  discard block
 block discarded – undo
253 252
 	{
254 253
 		if (!is_array($content))	// redirect from etemplate, if POST empty
255 254
 		{
256
-			return $this->edit(null,null,strip_tags($_GET['msg']));
255
+			return $this->edit(null, null, strip_tags($_GET['msg']));
257 256
 		}
258 257
 		// clear notification errors
259 258
 		notifications::errors(true);
@@ -267,22 +266,22 @@  discard block
 block discarded – undo
267 266
 		$update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add';
268 267
 
269 268
 		list($button) = @each($content['button']);
270
-		if (!$button && $content['action']) $button = $content['action'];	// action selectbox
269
+		if (!$button && $content['action']) $button = $content['action']; // action selectbox
271 270
 		unset($content['button']); unset($content['action']);
272 271
 
273 272
 		$view = $content['view'];
274 273
 		if ($button == 'ical')
275 274
 		{
276
-			$msg = $this->export($content['id'],true);
275
+			$msg = $this->export($content['id'], true);
277 276
 		}
278 277
 		// delete a recur-exception
279 278
 		if ($content['recur_exception']['delete_exception'])
280 279
 		{
281 280
 			list($date) = each($content['recur_exception']['delete_exception']);
282 281
 			// eT2 converts time to
283
-			if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts');
282
+			if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts');
284 283
 			unset($content['recur_exception']['delete_exception']);
285
-			if (($key = array_search($date,$content['recur_exception'])) !== false)
284
+			if (($key = array_search($date, $content['recur_exception'])) !== false)
286 285
 			{
287 286
 				// propagate the exception to a single event
288 287
 				$recur_exceptions = $this->bo->so->get_related($content['uid']);
@@ -292,7 +291,7 @@  discard block
 block discarded – undo
292 291
 							$exception['recurrence'] != $content['recur_exception'][$key]) continue;
293 292
 					$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
294 293
 					$exception['reference'] = $exception['recurrence'] = 0;
295
-					$this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']);
294
+					$this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']);
296 295
 					break;
297 296
 				}
298 297
 				unset($content['recur_exception'][$key]);
@@ -333,7 +332,7 @@  discard block
 block discarded – undo
333 332
 			$def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')];
334 333
 			if ((string)$def_alarm === '')
335 334
 			{
336
-				unset($content['alarm'][1]);	// '' = no alarm on whole day --> delete it
335
+				unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it
337 336
 			}
338 337
 			else
339 338
 			{
@@ -347,7 +346,7 @@  discard block
 block discarded – undo
347 346
 		unset($event['alarm']['delete_alarm']);
348 347
 		unset($event['duration']);
349 348
 
350
-		if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series')))
349
+		if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series')))
351 350
 		{
352 351
 			// no conversation necessary, event is already in the right format
353 352
 		}
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
 			if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY;
368 367
 			if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data'])
369 368
 			{
370
-				$event['recur_data'] = 1 << (int)date('w',$event['start']);
369
+				$event['recur_data'] = 1 << (int)date('w', $event['start']);
371 370
 			}
372 371
 			if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate']))
373 372
 			{
@@ -379,9 +378,9 @@  discard block
 block discarded – undo
379 378
 
380 379
 				$event['participants'] = $event['participant_types'] = array();
381 380
 
382
-				foreach($content['participants'] as $key => $data)
381
+				foreach ($content['participants'] as $key => $data)
383 382
 				{
384
-					switch($key)
383
+					switch ($key)
385 384
 					{
386 385
 						case 'delete':		// handled in default
387 386
 						case 'quantity':	// handled in new_resource
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
 						case 'status_date':
391 390
 							break;
392 391
 						case 'participant':
393
-							foreach($data as $participant)
392
+							foreach ($data as $participant)
394 393
 							{
395 394
 								if (is_null($participant))
396 395
 								{
@@ -399,17 +398,17 @@  discard block
 block discarded – undo
399 398
 
400 399
 								// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>")
401 400
 								$email = array();
402
-								if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email))
401
+								if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email))
403 402
 								{
404
-									$status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']);
405
-									if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data))
403
+									$status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']);
404
+									if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data))
406 405
 									{
407 406
 										$event['participants'][$data] = $event['participant_types']['u'][$data] = $status;
408 407
 									}
409
-									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array(
408
+									elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array(
410 409
 										'email' => $email[2],
411 410
 										'email_home' => $email[2],
412
-									),true,'','','',false,'OR')))
411
+									), true, '', '', '', false, 'OR')))
413 412
 									{
414 413
 										$event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status;
415 414
 									}
@@ -420,7 +419,7 @@  discard block
 block discarded – undo
420 419
 								}
421 420
 								else
422 421
 								{
423
-									if(is_numeric($participant))
422
+									if (is_numeric($participant))
424 423
 									{
425 424
 										$uid = $participant;
426 425
 										$id = $participant;
@@ -429,12 +428,12 @@  discard block
 block discarded – undo
429 428
 									else
430 429
 									{
431 430
 										$uid = $participant;
432
-										$id = substr($participant,1);
431
+										$id = substr($participant, 1);
433 432
 										$resource = $this->bo->resources[$participant[0]];
434 433
 									}
435
-									if(!$this->bo->check_acl_invite($uid))
434
+									if (!$this->bo->check_acl_invite($uid))
436 435
 									{
437
-										if(!$msg_permission_denied_added)
436
+										if (!$msg_permission_denied_added)
438 437
 										{
439 438
 											$msg .= lang('Permission denied!');
440 439
 											$msg_permission_denied_added = true;
@@ -444,20 +443,19 @@  discard block
 block discarded – undo
444 443
 
445 444
 									$type = $resource['type'];
446 445
 									$status = isset($this->bo->resources[$type]['new_status']) ?
447
-										ExecMethod($this->bo->resources[$type]['new_status'],$id) :
448
-										($uid == $this->bo->user ? 'A' : 'U');
446
+										ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U');
449 447
 
450 448
 									// Expand mailing lists
451
-									if($type == 'l')
449
+									if ($type == 'l')
452 450
 									{
453 451
 										// Ignore ACL here, allow inviting anyone in the list
454
-										foreach($this->bo->enum_mailing_list($participant, true) as $contact)
452
+										foreach ($this->bo->enum_mailing_list($participant, true) as $contact)
455 453
 										{
456 454
 											// Mailing lists can contain users, so allow for that possibility
457 455
 											$_type = is_numeric($contact) ? '' : $contact[0];
458
-											$_uid = is_numeric($contact) ? $contact : substr($contact,1);
456
+											$_uid = is_numeric($contact) ? $contact : substr($contact, 1);
459 457
 											$event['participants'][$contact] = $event['participant_types'][$_type][$_uid] =
460
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
458
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
461 459
 										}
462 460
 										continue;
463 461
 									}
@@ -467,8 +465,8 @@  discard block
 block discarded – undo
467 465
 										// todo check real availability = maximum - already booked quantity
468 466
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
469 467
 										{
470
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
471
-											foreach(array('quantity','resource','role') as $n)
468
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
469
+											foreach (array('quantity', 'resource', 'role') as $n)
472 470
 											{
473 471
 												$event['participants'][$n] = $content['participants'][$n];
474 472
 											}
@@ -477,7 +475,7 @@  discard block
 block discarded – undo
477 475
 										else
478 476
 										{
479 477
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
480
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
478
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
481 479
 										}
482 480
 									}
483 481
 								}
@@ -491,14 +489,14 @@  discard block
 block discarded – undo
491 489
 							break;
492 490
 
493 491
 						default:		// existing participant row
494
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
495
-							foreach(array('uid','status','quantity','role') as $name)
492
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
493
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
496 494
 							{
497 495
 								$$name = $data[$name];
498 496
 							}
499 497
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
500 498
 							{
501
-								$uid = false;	// entry has been deleted
499
+								$uid = false; // entry has been deleted
502 500
 							}
503 501
 							elseif ($uid)
504 502
 							{
@@ -509,27 +507,27 @@  discard block
 block discarded – undo
509 507
 								}
510 508
 								else
511 509
 								{
512
-									$id = substr($uid,1);
510
+									$id = substr($uid, 1);
513 511
 									$type = $uid[0];
514 512
 								}
515 513
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
516 514
 								{
517 515
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
518 516
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
519
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
517
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
520 518
 									{
521 519
 										// Update main window
522 520
 										$d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone);
523 521
 										$client_updated = $this->update_client($event['id'], $d);
524 522
 
525 523
 										// refreshing the calendar-view with the changed participant-status
526
-										if($event['recur_type'] != MCAL_RECUR_NONE)
524
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
527 525
 										{
528 526
 											$msg = lang('Status for all future scheduled days changed');
529 527
 										}
530 528
 										else
531 529
 										{
532
-											if(isset($content['edit_single']))
530
+											if (isset($content['edit_single']))
533 531
 											{
534 532
 												$msg = lang('Status for this particular day changed');
535 533
 												// prevent accidentally creating a real exception afterwards
@@ -550,7 +548,7 @@  discard block
 block discarded – undo
550 548
 										if ($status == 'R' && $event['alarm'])
551 549
 										{
552 550
 											// remove from bo->set_status deleted alarms of rejected users from UI too
553
-											foreach($event['alarm'] as $alarm_id => $alarm)
551
+											foreach ($event['alarm'] as $alarm_id => $alarm)
554 552
 											{
555 553
 												if ((string)$alarm['owner'] === (string)$uid)
556 554
 												{
@@ -563,7 +561,7 @@  discard block
 block discarded – undo
563 561
 								if ($uid && $status != 'G')
564 562
 								{
565 563
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
566
-										calendar_so::combine_status($status,$quantity,$role);
564
+										calendar_so::combine_status($status, $quantity, $role);
567 565
 								}
568 566
 							}
569 567
 							break;
@@ -582,26 +580,26 @@  discard block
 block discarded – undo
582 580
 			'tabs'			=> $content['tabs'],
583 581
 			'template'      => $content['template'],
584 582
 		);
585
-		$noerror=true;
583
+		$noerror = true;
586 584
 
587 585
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
588 586
 
589 587
 		$ignore_conflicts = $status_reset_to_unknown = false;
590 588
 
591
-		switch((string)$button)
589
+		switch ((string)$button)
592 590
 		{
593 591
 			case 'ignore':
594 592
 				$ignore_conflicts = true;
595
-				$button = $event['button_was'];	// save or apply
593
+				$button = $event['button_was']; // save or apply
596 594
 				unset($event['button_was']);
597 595
 				break;
598 596
 
599 597
 		}
600 598
 
601
-		switch((string)$button)
599
+		switch ((string)$button)
602 600
 		{
603 601
 		case 'exception':	// create an exception in a recuring event
604
-			$msg = $this->_create_exception($event,$preserv);
602
+			$msg = $this->_create_exception($event, $preserv);
605 603
 			break;
606 604
 
607 605
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -612,29 +610,29 @@  discard block
 block discarded – undo
612 610
 			unset($event['recurrence']);
613 611
 			unset($preserv['recurrence']);
614 612
 			unset($event['recur_exception']);
615
-			unset($event['edit_single']);	// in case it has been set
613
+			unset($event['edit_single']); // in case it has been set
616 614
 			unset($event['modified']);
617 615
 			unset($event['modifier']);
618 616
 			unset($event['caldav_name']);
619
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
617
+			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner'];
620 618
 
621 619
 			// Clear participant stati
622
-			foreach($event['participant_types'] as $type => &$participants)
620
+			foreach ($event['participant_types'] as $type => &$participants)
623 621
 			{
624
-				foreach($participants as $id => &$p_response)
622
+				foreach ($participants as $id => &$p_response)
625 623
 				{
626
-					if($type == 'u' && $id == $event['owner']) continue;
624
+					if ($type == 'u' && $id == $event['owner']) continue;
627 625
 					calendar_so::split_status($p_response, $quantity, $role);
628 626
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
629
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
630
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
627
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
628
+					$p_response = calendar_so::combine_status($status, $quantity, $role);
631 629
 				}
632 630
 			}
633 631
 
634 632
 			// Copy alarms
635 633
 			if (is_array($event['alarm']))
636 634
 			{
637
-				foreach($event['alarm'] as $n => &$alarm)
635
+				foreach ($event['alarm'] as $n => &$alarm)
638 636
 				{
639 637
 					unset($alarm['id']);
640 638
 					unset($alarm['cal_id']);
@@ -644,7 +642,7 @@  discard block
 block discarded – undo
644 642
 			// Get links to be copied
645 643
 			// With no ID, $content['link_to']['to_id'] is used
646 644
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
647
-			foreach(Link::get_links('calendar', $content['id']) as $link)
645
+			foreach (Link::get_links('calendar', $content['id']) as $link)
648 646
 			{
649 647
 				if ($link['app'] != Link::VFS_APPNAME)
650 648
 				{
@@ -660,7 +658,7 @@  discard block
 block discarded – undo
660 658
 			}
661 659
 			unset($link);
662 660
 			$preserv['view'] = $preserv['edit_single'] = false;
663
-			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry')));
661
+			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry')));
664 662
 			$event['title'] = lang('Copy of:').' '.$event['title'];
665 663
 			break;
666 664
 
@@ -670,7 +668,7 @@  discard block
 block discarded – undo
670 668
 		case 'print':
671 669
 		case 'apply':
672 670
 		case 'infolog':
673
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
671
+			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event))
674 672
 			{
675 673
 				$msg = lang('Permission denied');
676 674
 				$button = '';
@@ -688,7 +686,7 @@  discard block
 block discarded – undo
688 686
 				$button = '';
689 687
 				break;
690 688
 			}
691
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
689
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
692 690
 			{
693 691
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
694 692
 				$button = '';
@@ -718,14 +716,14 @@  discard block
 block discarded – undo
718 716
 				$event['reference'] = $event['id'];
719 717
 				$event['recurrence'] = $content['edit_single'];
720 718
 				unset($event['id']);
721
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
719
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
722 720
 				if (!is_array($conflicts) && $conflicts)
723 721
 				{
724 722
 					// now we need to add the original start as recur-execption to the series
725 723
 					$recur_event = $this->bo->read($event['reference']);
726 724
 					$recur_event['recur_exception'][] = $content['edit_single'];
727 725
 					// check if we need to move the alarms, because they are next on that exception
728
-					foreach($recur_event['alarm'] as $id => $alarm)
726
+					foreach ($recur_event['alarm'] as $id => $alarm)
729 727
 					{
730 728
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
731 729
 						{
@@ -741,17 +739,17 @@  discard block
 block discarded – undo
741 739
 							}
742 740
 						}
743 741
 					}
744
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
745
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
746
-					$this->bo->update($recur_event,true);	// no conflict check here
742
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
743
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
744
+					$this->bo->update($recur_event, true); // no conflict check here
747 745
 
748 746
 					// Save links
749
-					if($content['links'])
747
+					if ($content['links'])
750 748
 					{
751 749
 						Link::link('calendar', $event['id'], $content['links']['to_id']);
752 750
 					}
753 751
 
754
-					if(Api\Json\Response::isJSONResponse())
752
+					if (Api\Json\Response::isJSONResponse())
755 753
 					{
756 754
 						// Sending null will trigger a removal of the original
757 755
 						// for that date
@@ -759,7 +757,7 @@  discard block
 block discarded – undo
759 757
 					}
760 758
 
761 759
 					unset($recur_event);
762
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
760
+					unset($event['edit_single']); // if we further edit it, it's just a single event
763 761
 					unset($preserv['edit_single']);
764 762
 				}
765 763
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -790,8 +788,8 @@  discard block
 block discarded – undo
790 788
 							{
791 789
 								$offset = $off2;
792 790
 							}
793
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
794
-							if($msg)
791
+							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']);
792
+							if ($msg)
795 793
 							{
796 794
 								$noerror = false;
797 795
 							}
@@ -804,10 +802,10 @@  discard block
 block discarded – undo
804 802
 							$event['whole_day'] != $old_event['whole_day'])
805 803
 						{
806 804
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
807
-							foreach((array)$event['participants'] as $uid => $status)
805
+							foreach ((array)$event['participants'] as $uid => $status)
808 806
 							{
809 807
 								$q = $r = null;
810
-								calendar_so::split_status($status,$q,$r);
808
+								calendar_so::split_status($status, $q, $r);
811 809
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
812 810
 								{
813 811
 									$preferences = new Api\Preferences($uid);
@@ -820,7 +818,7 @@  discard block
 block discarded – undo
820 818
 											if ($sameday) break;
821 819
 										default:
822 820
 											$status_reset_to_unknown = true;
823
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
821
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
824 822
 											// todo: report reset status to user
825 823
 									}
826 824
 								}
@@ -838,43 +836,43 @@  discard block
 block discarded – undo
838 836
 				}
839 837
 				// Adding participants needs to be done as an edit, in case we
840 838
 				// have participants visible in seperate calendars
841
-				if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
839
+				if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
842 840
 				{
843 841
 					$update_type = 'edit';
844 842
 				}
845 843
 				// Changing category may affect event filtering
846
-				if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
844
+				if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
847 845
 				{
848 846
 					$update_type = 'edit';
849 847
 				}
850
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
848
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
851 849
 				unset($event['ignore']);
852 850
 			}
853 851
 			if (is_array($conflicts))
854 852
 			{
855
-				$event['button_was'] = $button;	// remember for ignore
856
-				return $this->conflicts($event,$conflicts,$preserv);
853
+				$event['button_was'] = $button; // remember for ignore
854
+				return $this->conflicts($event, $conflicts, $preserv);
857 855
 			}
858 856
 
859 857
 			// Event spans multiple days, need an edit to make sure they all get updated
860 858
 			// We could check old date, as removing from days could still be an update
861
-			if(date('Ymd', $event['start']) != date('Ymd', $event['end']))
859
+			if (date('Ymd', $event['start']) != date('Ymd', $event['end']))
862 860
 			{
863 861
 				$update_type = 'edit';
864 862
 			}
865 863
 			// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
866 864
 			if ($messages)
867 865
 			{
868
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
866
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
869 867
 			}
870 868
 			if ($conflicts === 0)
871 869
 			{
872
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
873
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
874
-								htmlspecialchars(Egw::link('/index.php',array(
870
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
871
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
872
+								htmlspecialchars(Egw::link('/index.php', array(
875 873
 								'menuaction' => 'calendar.calendar_uiforms.edit',
876 874
 								'cal_id'    => $content['id'],
877
-							))).'">','</a>');
875
+							))).'">', '</a>');
878 876
 				$noerror = false;
879 877
 			}
880 878
 			elseif ($conflicts > 0)
@@ -896,19 +894,19 @@  discard block
 block discarded – undo
896 894
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
897 895
 						if ($alarm['time'] < $this->bo->now_su)
898 896
 						{
899
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
897
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
900 898
 							{
901
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
899
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
902 900
 							}
903 901
 							else
904 902
 							{
905
-								$alarm = false;	// no (further) recurence found --> ignore alarm
903
+								$alarm = false; // no (further) recurence found --> ignore alarm
906 904
 							}
907 905
 						}
908 906
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
909 907
 						elseif ($event_time < $event['start'])
910 908
 						{
911
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
909
+							$alarm['time'] = $event['start'] - $alarm['offset'];
912 910
 						}
913 911
 						if ($alarm)
914 912
 						{
@@ -917,9 +915,9 @@  discard block
 block discarded – undo
917 915
 						}
918 916
 					}
919 917
 					// attach all future exceptions to the new series
920
-					$events =& $this->bo->search(array(
918
+					$events = & $this->bo->search(array(
921 919
 						'query' => array('cal_uid' => $old_event['uid']),
922
-						'filter' => 'owner',  // return all possible entries
920
+						'filter' => 'owner', // return all possible entries
923 921
 						'daywise' => false,
924 922
 						'date_format' => 'ts',
925 923
 					));
@@ -930,7 +928,7 @@  discard block
 block discarded – undo
930 928
 							$exception['recurrence'] += $offset;
931 929
 							$exception['reference'] = $event['id'];
932 930
 							$exception['uid'] = $event['uid'];
933
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
931
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
934 932
 						}
935 933
 					}
936 934
 				}
@@ -938,12 +936,12 @@  discard block
 block discarded – undo
938 936
 				$message = lang('Event saved');
939 937
 				if ($status_reset_to_unknown)
940 938
 				{
941
-					foreach((array)$event['participants'] as $uid => $status)
939
+					foreach ((array)$event['participants'] as $uid => $status)
942 940
 					{
943 941
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
944 942
 						{
945
-							calendar_so::split_status($status,$q,$r);
946
-							$status = calendar_so::combine_status('U',$q,$r);
943
+							calendar_so::split_status($status, $q, $r);
944
+							$status = calendar_so::combine_status('U', $q, $r);
947 945
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
948 946
 						}
949 947
 					}
@@ -951,17 +949,17 @@  discard block
 block discarded – undo
951 949
 				}
952 950
 
953 951
 				$response = Api\Json\Response::get();
954
-				if($response && $update_type != 'delete')
952
+				if ($response && $update_type != 'delete')
955 953
 				{
956 954
 					$client_updated = $this->update_client($event['id']);
957 955
 				}
958 956
 
959
-				$msg = $message . ($msg ? ', ' . $msg : '');
957
+				$msg = $message.($msg ? ', '.$msg : '');
960 958
 				Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete');
961 959
 				// writing links for new entry, existing ones are handled by the widget itself
962 960
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
963 961
 				{
964
-					Link::link('calendar',$event['id'],$content['link_to']['to_id']);
962
+					Link::link('calendar', $event['id'], $content['link_to']['to_id']);
965 963
 				}
966 964
 			}
967 965
 			else
@@ -971,7 +969,7 @@  discard block
 block discarded – undo
971 969
 			break;
972 970
 
973 971
 		case 'cancel':
974
-			if($content['cancel_needs_refresh'])
972
+			if ($content['cancel_needs_refresh'])
975 973
 			{
976 974
 				Framework::refresh_opener($msg, 'calendar');
977 975
 			}
@@ -1009,7 +1007,7 @@  discard block
 block discarded – undo
1009 1007
 			{
1010 1008
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
1011 1009
 			}
1012
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
1010
+			if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
1013 1011
 			{
1014 1012
 				$alarm = array(
1015 1013
 					'offset' => $offset,
@@ -1023,13 +1021,13 @@  discard block
 block discarded – undo
1023 1021
 				}
1024 1022
 				elseif ($event['id'])	// save the alarm immediatly
1025 1023
 				{
1026
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1024
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
1027 1025
 					{
1028 1026
 						$alarm['id'] = $alarm_id;
1029 1027
 						$event['alarm'][$alarm_id] = $alarm;
1030 1028
 
1031 1029
 						$msg = lang('Alarm added');
1032
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1030
+						Framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
1033 1031
 					}
1034 1032
 					else
1035 1033
 					{
@@ -1038,7 +1036,7 @@  discard block
 block discarded – undo
1038 1036
 				}
1039 1037
 				else
1040 1038
 				{
1041
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1039
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1042 1040
 					$event['alarm'][$alarm['id']] = $alarm;
1043 1041
 				}
1044 1042
 			}
@@ -1055,31 +1053,31 @@  discard block
 block discarded – undo
1055 1053
 		}
1056 1054
 		// New event, send data before updating so it's there
1057 1055
 		$response = Api\Json\Response::get();
1058
-		if($response && !$content['id'] && $event['id'])
1056
+		if ($response && !$content['id'] && $event['id'])
1059 1057
 		{
1060 1058
 			$client_updated = $this->update_client($event['id']);
1061 1059
 		}
1062
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1060
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1063 1061
 		{
1064 1062
 			if ($content['lock_token'])	// remove an existing lock
1065 1063
 			{
1066
-				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1064
+				Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1067 1065
 			}
1068 1066
 			if ($content['no_popup'])
1069 1067
 			{
1070
-				Egw::redirect_link('/index.php',array(
1068
+				Egw::redirect_link('/index.php', array(
1071 1069
 					'menuaction' => 'calendar.calendar_uiviews.index',
1072 1070
 					'msg'        => $msg,
1073 1071
 				));
1074 1072
 			}
1075
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1073
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1076 1074
 			{
1077
-				Framework::refresh_opener($msg,'calendar');
1075
+				Framework::refresh_opener($msg, 'calendar');
1078 1076
 			}
1079 1077
 			else
1080 1078
 			{
1081 1079
 				Framework::refresh_opener($msg, 'calendar',
1082
-					$event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ),
1080
+					$event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''),
1083 1081
 					$button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete'
1084 1082
 				);
1085 1083
 			}
@@ -1087,7 +1085,7 @@  discard block
 block discarded – undo
1087 1085
 			exit();
1088 1086
 		}
1089 1087
 		unset($event['no_notifications']);
1090
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1088
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1091 1089
 	}
1092 1090
 
1093 1091
 	/**
@@ -1099,7 +1097,7 @@  discard block
 block discarded – undo
1099 1097
 	 * @param array &$preserv
1100 1098
 	 * @return string message that exception was created
1101 1099
 	 */
1102
-	function _create_exception(&$event,&$preserv)
1100
+	function _create_exception(&$event, &$preserv)
1103 1101
 	{
1104 1102
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1105 1103
 		$preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1109,25 +1107,25 @@  discard block
 block discarded – undo
1109 1107
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1110 1108
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1111 1109
 		$event['recur_type'] = MCAL_RECUR_NONE;
1112
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1110
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1113 1111
 		{
1114 1112
 			unset($event[$name]);
1115 1113
 		}
1116 1114
 		// add all alarms as new alarms to execption
1117 1115
 		$event['alarm'] = array_values((array)$event['alarm']);
1118
-		foreach($event['alarm'] as &$alarm)
1116
+		foreach ($event['alarm'] as &$alarm)
1119 1117
 		{
1120 1118
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1121 1119
 		}
1122 1120
 
1123 1121
 		// Copy links
1124
-		if(!is_array($event['link_to'])) $event['link_to'] = array();
1122
+		if (!is_array($event['link_to'])) $event['link_to'] = array();
1125 1123
 		$event['link_to']['to_app'] = 'calendar';
1126 1124
 		$event['link_to']['to_id'] = 0;
1127 1125
 
1128
-		foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1126
+		foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1129 1127
 		{
1130
-			if(!$link['id']) continue;
1128
+			if (!$link['id']) continue;
1131 1129
 			if ($link['app'] != Link::VFS_APPNAME)
1132 1130
 			{
1133 1131
 				Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
@@ -1143,7 +1141,7 @@  discard block
 block discarded – undo
1143 1141
 
1144 1142
 		$event['links'] = $event['link_to'];
1145 1143
 
1146
-		if($this->bo->check_perms(Acl::EDIT,$event))
1144
+		if ($this->bo->check_perms(Acl::EDIT, $event))
1147 1145
 		{
1148 1146
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1149 1147
 		}
@@ -1170,14 +1168,14 @@  discard block
 block discarded – undo
1170 1168
 	{
1171 1169
 		$msg = false;
1172 1170
 
1173
-		if(!$as_of_date )
1171
+		if (!$as_of_date)
1174 1172
 		{
1175 1173
 			$as_of_date = time();
1176 1174
 		}
1177 1175
 
1178 1176
 		//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
1179 1177
 
1180
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1178
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1181 1179
 		{
1182 1180
 			$msg = lang("Error: You can't shift a series from the past!");
1183 1181
 			return $msg;
@@ -1190,11 +1188,11 @@  discard block
 block discarded – undo
1190 1188
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1191 1189
 
1192 1190
 		// base start-date of new series on actual / clicked date
1193
-		$event['start'] = $as_of_date ;
1191
+		$event['start'] = $as_of_date;
1194 1192
 
1195
-		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1193
+		if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') ||
1196 1194
 			// Adjust for requested date in the past
1197
-			Api\DateTime::to($as_of_date,'ts') < time()
1195
+			Api\DateTime::to($as_of_date, 'ts') < time()
1198 1196
 		)
1199 1197
 		{
1200 1198
 
@@ -1214,17 +1212,17 @@  discard block
 block discarded – undo
1214 1212
 				$rriter->next_no_exception();
1215 1213
 				$occurrence = $rriter->current();
1216 1214
 			}
1217
-			while ($rriter->valid()  && (
1215
+			while ($rriter->valid() && (
1218 1216
 				Api\DateTime::to($occurrence, 'ts') <= time() ||
1219
-				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
1217
+				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd')
1220 1218
 			) && ($last = $occurrence));
1221 1219
 
1222 1220
 
1223 1221
 			// Make sure as_of_date is still valid, may have to move forward
1224
-			if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
1222
+			if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') ||
1225 1223
 				Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
1226 1224
 			{
1227
-				$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
1225
+				$event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset;
1228 1226
 			}
1229 1227
 
1230 1228
 			//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
@@ -1232,7 +1230,7 @@  discard block
 block discarded – undo
1232 1230
 			{
1233 1231
 				$event['end'] = $event['start'] + $duration;
1234 1232
 			}
1235
-			elseif($event['end'] < $event['start'])
1233
+			elseif ($event['end'] < $event['start'])
1236 1234
 			{
1237 1235
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1238 1236
 			}
@@ -1241,7 +1239,7 @@  discard block
 block discarded – undo
1241 1239
 			$event['participants'] = $old_event['participants'];
1242 1240
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1243 1241
 			{
1244
-				if ($exdate > Api\DateTime::to($last,'ts'))
1242
+				if ($exdate > Api\DateTime::to($last, 'ts'))
1245 1243
 				{
1246 1244
 					//error_log("Moved exception on " . Api\DateTime::to($exdate));
1247 1245
 					unset($old_event['recur_exception'][$key]);
@@ -1255,18 +1253,18 @@  discard block
 block discarded – undo
1255 1253
 			}
1256 1254
 			$last->setTime(0, 0, 0);
1257 1255
 			$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
1258
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1256
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1259 1257
 			{
1260
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1261
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1262
-						htmlspecialchars(Egw::link('/index.php',array(
1258
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1259
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1260
+						htmlspecialchars(Egw::link('/index.php', array(
1263 1261
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1264 1262
 							'cal_id'    => $event['id'],
1265
-						))).'">','</a>');
1263
+						))).'">', '</a>');
1266 1264
 				$event = $orig_event;
1267 1265
 			}
1268 1266
 		}
1269
-		$event['start'] = Api\DateTime::to($event['start'],'ts');
1267
+		$event['start'] = Api\DateTime::to($event['start'], 'ts');
1270 1268
 		return $msg;
1271 1269
 	}
1272 1270
 
@@ -1277,11 +1275,11 @@  discard block
 block discarded – undo
1277 1275
 	 * @param boolean $added
1278 1276
 	 * @return string javascript window.open command
1279 1277
 	 */
1280
-	function ajax_custom_mail($event,$added,$asrequest=false)
1278
+	function ajax_custom_mail($event, $added, $asrequest = false)
1281 1279
 	{
1282 1280
 		$to = array();
1283 1281
 
1284
-		foreach($event['participants'] as $uid => $status)
1282
+		foreach ($event['participants'] as $uid => $status)
1285 1283
 		{
1286 1284
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1287 1285
 			if (empty($status)) continue;
@@ -1290,32 +1288,32 @@  discard block
 block discarded – undo
1290 1288
 
1291 1289
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1292 1290
 			{
1293
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1291
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1294 1292
 
1295 1293
 				$toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '.
1296 1294
 					$GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>';
1297 1295
 
1298
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1296
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1299 1297
 			}
1300 1298
 			elseif ($uid < 0)
1301 1299
 			{
1302
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1300
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1303 1301
 				{
1304
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1302
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1305 1303
 
1306 1304
 					$toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1307 1305
 						$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>';
1308 1306
 
1309 1307
 					// dont add groupmembers if they already rejected the event, or are the current user
1310
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1308
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1311 1309
 				}
1312 1310
 			}
1313
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1311
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1314 1312
 			{
1315 1313
 				$to[] = $info['email'];
1316 1314
 				//error_log(__METHOD__.__LINE__.array2string($to));
1317 1315
 			}
1318
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1316
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1319 1317
 			{
1320 1318
 				$to[] = $info['email'];
1321 1319
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1324,7 +1322,7 @@  discard block
 block discarded – undo
1324 1322
 		// prefer event description over standard notification text
1325 1323
 		if (empty($event['description']))
1326 1324
 		{
1327
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1325
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1328 1326
 		}
1329 1327
 		else
1330 1328
 		{
@@ -1339,12 +1337,12 @@  discard block
 block discarded – undo
1339 1337
 		$boical = new calendar_ical();
1340 1338
 		// we need to pass $event[id] so iCal class reads event again,
1341 1339
 		// as event is in user TZ, but iCal class expects server TZ!
1342
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1340
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1343 1341
 
1344
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1345
-		if(($f = fopen($ics_file,'w')))
1342
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1343
+		if (($f = fopen($ics_file, 'w')))
1346 1344
 		{
1347
-			fwrite($f,$ics);
1345
+			fwrite($f, $ics);
1348 1346
 			fclose($f);
1349 1347
 		}
1350 1348
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1356,7 +1354,7 @@  discard block
 block discarded – undo
1356 1354
 			'preset[body]'    => $body,
1357 1355
 			'preset[name]'    => 'event.ics',
1358 1356
 			'preset[file]'    => $ics_file,
1359
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1357
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1360 1358
 			'preset[size]'    => filesize($ics_file),
1361 1359
 		);
1362 1360
 		if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.');
@@ -1412,7 +1410,7 @@  discard block
 block discarded – undo
1412 1410
 	 * @param mixed $link_to_id ='' from or for the link-widget
1413 1411
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1414 1412
 	 */
1415
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1413
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1416 1414
 	{
1417 1415
 		$sel_options = array(
1418 1416
 			'recur_type' => &$this->bo->recur_types,
@@ -1436,8 +1434,8 @@  discard block
 block discarded – undo
1436 1434
 				'no_popup' => isset($_GET['no_popup']),
1437 1435
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1438 1436
 			);
1439
-			$cal_id = (int) $_GET['cal_id'];
1440
-			if($_GET['action'])
1437
+			$cal_id = (int)$_GET['cal_id'];
1438
+			if ($_GET['action'])
1441 1439
 			{
1442 1440
 				$event = $this->bo->read($cal_id);
1443 1441
 				$event['action'] = $_GET['action'];
@@ -1455,14 +1453,14 @@  discard block
 block discarded – undo
1455 1453
 			{
1456 1454
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1457 1455
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1458
-				$event =& $this->default_add_event();
1456
+				$event = & $this->default_add_event();
1459 1457
 			}
1460 1458
 			if (!empty($_GET['ical_data']) &&
1461 1459
 				!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
1462 1460
 			{
1463 1461
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1464 1462
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1465
-				$event =& $this->default_add_event();
1463
+				$event = & $this->default_add_event();
1466 1464
 			}
1467 1465
 			if (!empty($_GET['ical']))
1468 1466
 			{
@@ -1471,14 +1469,14 @@  discard block
 block discarded – undo
1471 1469
 				{
1472 1470
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1473 1471
 					$msg = lang('Error: importing the iCal');
1474
-					$event =& $this->default_add_event();
1472
+					$event = & $this->default_add_event();
1475 1473
 				}
1476 1474
 				else
1477 1475
 				{
1478 1476
 					if (count($events) > 1)
1479 1477
 					{
1480 1478
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1481
-						$msg_type = 'notice';	// no not hide automatic
1479
+						$msg_type = 'notice'; // no not hide automatic
1482 1480
 					}
1483 1481
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1484 1482
 					$this->bo->db2data($events, 'ts');
@@ -1491,7 +1489,7 @@  discard block
 block discarded – undo
1491 1489
 					else
1492 1490
 					{
1493 1491
 						$event['participant_types'] = array();
1494
-						foreach($event['participants'] as $uid => $status)
1492
+						foreach ($event['participants'] as $uid => $status)
1495 1493
 						{
1496 1494
 							$user_type = $user_id = null;
1497 1495
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1512,15 +1510,15 @@  discard block
 block discarded – undo
1512 1510
 					}
1513 1511
 					else
1514 1512
 					{
1515
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1513
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1516 1514
 						exit();
1517 1515
 					}
1518 1516
 				}
1519
-				$event =& $this->default_add_event();
1517
+				$event = & $this->default_add_event();
1520 1518
 			}
1521 1519
 			else
1522 1520
 			{
1523
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1521
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1524 1522
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1525 1523
 				{
1526 1524
 					if (empty($event['whole_day']))
@@ -1533,10 +1531,10 @@  discard block
 block discarded – undo
1533 1531
 						$date->setUser();
1534 1532
 					}
1535 1533
 					$event = $this->bo->read($cal_id, $date, true);
1536
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1534
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1537 1535
 					if ($_GET['exception'])
1538 1536
 					{
1539
-						$msg = $this->_create_exception($event,$preserv);
1537
+						$msg = $this->_create_exception($event, $preserv);
1540 1538
 					}
1541 1539
 					else
1542 1540
 					{
@@ -1545,9 +1543,9 @@  discard block
 block discarded – undo
1545 1543
 				}
1546 1544
 			}
1547 1545
 			// set new start and end if given by $_GET
1548
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1549
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1550
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1546
+			if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); }
1547
+			if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); }
1548
+			if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1551 1549
 			// check if the event is the whole day
1552 1550
 			$start = $this->bo->date2array($event['start']);
1553 1551
 			$end = $this->bo->date2array($event['end']);
@@ -1557,30 +1555,30 @@  discard block
 block discarded – undo
1557 1555
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1558 1556
 			{
1559 1557
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1560
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1558
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1561 1559
 				{
1562 1560
 					$link_id = $link_ids[$n];
1563
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1561
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1564 1562
 					{
1565 1563
 						continue;
1566 1564
 					}
1567
-					if(!$n)
1565
+					if (!$n)
1568 1566
 					{
1569
-						$event['title'] = Link::title($link_app,$link_id);
1567
+						$event['title'] = Link::title($link_app, $link_id);
1570 1568
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1571
-						if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1569
+						if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1572 1570
 						{
1573
-							foreach((array)$set['link_app'] as $i => $l_app)
1571
+							foreach ((array)$set['link_app'] as $i => $l_app)
1574 1572
 							{
1575
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1573
+								if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1576 1574
 							}
1577 1575
 							unset($set['link_app']);
1578 1576
 							unset($set['link_id']);
1579 1577
 
1580
-							$event = array_merge($event,$set);
1578
+							$event = array_merge($event, $set);
1581 1579
 						}
1582 1580
 					}
1583
-					Link::link('calendar',$link_to_id,$link_app,$link_id);
1581
+					Link::link('calendar', $link_to_id, $link_app, $link_id);
1584 1582
 				}
1585 1583
 			}
1586 1584
 		}
@@ -1590,44 +1588,44 @@  discard block
 block discarded – undo
1590 1588
 		{
1591 1589
 			$etpl->read($preserv['template'] = 'calendar.edit');
1592 1590
 		}
1593
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
1591
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event);
1594 1592
 		//echo "view=$view, event="; _debug_array($event);
1595 1593
 		// shared locking of entries to edit
1596 1594
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1597 1595
 		{
1598
-			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1596
+			$lock_path = Vfs::app_entry_lock_path('calendar', $event['id']);
1599 1597
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1600 1598
 
1601 1599
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1602 1600
 			{
1603
-				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1601
+				Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1604 1602
 			}
1605 1603
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1606 1604
 			{
1607 1605
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1608
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1606
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1609 1607
 					Api\Accounts::username($lock_uid) : $lock['owner']));
1610 1608
 			}
1611
-			elseif($lock)
1609
+			elseif ($lock)
1612 1610
 			{
1613 1611
 				$preserv['lock_token'] = $lock['token'];
1614 1612
 			}
1615
-			elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1613
+			elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1616 1614
 			{
1617 1615
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1618 1616
 			}
1619 1617
 			else
1620 1618
 			{
1621
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1619
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1622 1620
 				$view = true;
1623 1621
 			}
1624 1622
 		}
1625
-		$content = array_merge($event,array(
1623
+		$content = array_merge($event, array(
1626 1624
 			'link_to' => array(
1627 1625
 				'to_id'  => $link_to_id,
1628 1626
 				'to_app' => 'calendar',
1629 1627
 			),
1630
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1628
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1631 1629
 			'tabs'   => $preserv['tabs'],
1632 1630
 			'view' => $view,
1633 1631
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1639,11 +1637,11 @@  discard block
 block discarded – undo
1639 1637
 		$row = 3;
1640 1638
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1641 1639
 		// preserve some ui elements, if set eg. under error-conditions
1642
-		foreach(array('quantity','resource','role') as $n)
1640
+		foreach (array('quantity', 'resource', 'role') as $n)
1643 1641
 		{
1644 1642
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1645 1643
 		}
1646
-		foreach($event['participant_types'] as $type => $participants)
1644
+		foreach ($event['participant_types'] as $type => $participants)
1647 1645
 		{
1648 1646
 			$name = 'accounts';
1649 1647
 			if (isset($this->bo->resources[$type]))
@@ -1652,17 +1650,17 @@  discard block
 block discarded – undo
1652 1650
 			}
1653 1651
 			// sort participants (in there group/app) by title
1654 1652
 			uksort($participants, array($this, 'uid_title_cmp'));
1655
-			foreach($participants as $id => $status)
1653
+			foreach ($participants as $id => $status)
1656 1654
 			{
1657 1655
 				$uid = $type == 'u' ? $id : $type.$id;
1658 1656
 				$quantity = $role = null;
1659
-				calendar_so::split_status($status,$quantity,$role);
1657
+				calendar_so::split_status($status, $quantity, $role);
1660 1658
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1661 1659
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1662 1660
 					'uid'      => $uid,
1663 1661
 					'status'   => $status,
1664 1662
 					'old_status' => $status,
1665
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1663
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1666 1664
 					'role'     => $role,
1667 1665
 				);
1668 1666
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1671,33 +1669,33 @@  discard block
 block discarded – undo
1671 1669
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1672 1670
 				}
1673 1671
 				// allow third party apps to use categories for roles
1674
-				elseif(substr($role,0,6) == 'X-CAT-')
1672
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1675 1673
 				{
1676
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1674
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1677 1675
 				}
1678 1676
 				else
1679 1677
 				{
1680
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1678
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1681 1679
 				}
1682
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1680
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1683 1681
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1684 1682
 
1685
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1683
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1686 1684
 					$readonlys['participants'][$row]['status'] = $no_status;
1687
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1685
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event))
1688 1686
 					$readonlys['participants']['delete'][$uid] = true;
1689 1687
 				// todo: make the participants available as links with email as title
1690 1688
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1691 1689
 				// enumerate group-invitations, so people can accept/reject them
1692 1690
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1693
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1691
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1694 1692
 				{
1695 1693
 					$sel_options['status']['G'] = lang('Select one');
1696 1694
 					// sort members by title
1697 1695
 					usort($members, array($this, 'uid_title_cmp'));
1698
-					foreach($members as $member)
1696
+					foreach ($members as $member)
1699 1697
 					{
1700
-						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
1698
+						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member))
1701 1699
 						{
1702 1700
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1703 1701
 								'app'      => 'Group invitation',
@@ -1706,7 +1704,7 @@  discard block
 block discarded – undo
1706 1704
 							);
1707 1705
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1708 1706
 							// read access is enough to invite participants, but you need edit rights to change status
1709
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
1707
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member);
1710 1708
 							$content['participants'][$row++]['title'] = Api\Accounts::username($member);
1711 1709
 						}
1712 1710
 					}
@@ -1714,43 +1712,43 @@  discard block
 block discarded – undo
1714 1712
 			}
1715 1713
 			// resouces / apps we shedule, atm. resources and addressbook
1716 1714
 			$content['participants']['cal_resources'] = '';
1717
-			foreach($this->bo->resources as $data)
1715
+			foreach ($this->bo->resources as $data)
1718 1716
 			{
1719
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1717
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1720 1718
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1721 1719
 			}
1722 1720
 		}
1723 1721
 		$content['participants']['status_date'] = $preserv['actual_date'];
1724
-		$preserved = array_merge($preserv,$content);
1722
+		$preserved = array_merge($preserv, $content);
1725 1723
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1726 1724
 		if ($event['alarm'])
1727 1725
 		{
1728 1726
 			// makes keys of the alarm-array starting with 1
1729 1727
 			$content['alarm'] = array(false);
1730
-			foreach(array_values($event['alarm']) as $id => $alarm)
1728
+			foreach (array_values($event['alarm']) as $id => $alarm)
1731 1729
 			{
1732
-				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
1730
+				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
1733 1731
 				{
1734
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1732
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1735 1733
 				}
1736
-				$alarm['all'] = (int) $alarm['all'];
1734
+				$alarm['all'] = (int)$alarm['all'];
1737 1735
 				$after = false;
1738
-				if($alarm['offset'] < 0)
1736
+				if ($alarm['offset'] < 0)
1739 1737
 				{
1740 1738
 					$after = true;
1741 1739
 					$alarm['offset'] = -1 * $alarm['offset'];
1742 1740
 				}
1743
-				$days = (int) ($alarm['offset'] / DAY_s);
1744
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1745
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1741
+				$days = (int)($alarm['offset'] / DAY_s);
1742
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1743
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1746 1744
 				$label = array();
1747 1745
 				if ($days) $label[] = $days.' '.lang('days');
1748 1746
 				if ($hours) $label[] = $hours.' '.lang('hours');
1749 1747
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1750
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1748
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1751 1749
 				$content['alarm'][] = $alarm;
1752 1750
 
1753
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1751
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1754 1752
 			}
1755 1753
 			if (count($content['alarm']) == 1)
1756 1754
 			{
@@ -1765,20 +1763,20 @@  discard block
 block discarded – undo
1765 1763
 
1766 1764
 		if ($view)
1767 1765
 		{
1768
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1766
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1769 1767
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1770 1768
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1771 1769
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1772 1770
 
1773 1771
 			$content['participants']['no_add'] = true;
1774 1772
 
1775
-			if(!$event['whole_day'])
1773
+			if (!$event['whole_day'])
1776 1774
 			{
1777 1775
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1778 1776
 			}
1779 1777
 
1780 1778
 			// respect category permissions
1781
-			if(!empty($event['category']))
1779
+			if (!empty($event['category']))
1782 1780
 			{
1783 1781
 				$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
1784 1782
 			}
@@ -1789,7 +1787,7 @@  discard block
 block discarded – undo
1789 1787
 
1790 1788
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1791 1789
 			{
1792
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1790
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1793 1791
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1794 1792
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1795 1793
 			}
@@ -1799,9 +1797,9 @@  discard block
 block discarded – undo
1799 1797
 				$readonlys['recur_interval'] = $readonlys['recur_data'] = true;
1800 1798
 			}
1801 1799
 		}
1802
-		if($content['category'] && !is_array($content['category']))
1800
+		if ($content['category'] && !is_array($content['category']))
1803 1801
 		{
1804
-			$content['category'] = explode(',',$event['category']);
1802
+			$content['category'] = explode(',', $event['category']);
1805 1803
 		}
1806 1804
 		// disabling the custom fields tab, if there are none
1807 1805
 		$readonlys['tabs'] = array(
@@ -1818,13 +1816,13 @@  discard block
 block discarded – undo
1818 1816
 		{
1819 1817
 			$readonlys['action'] = true;
1820 1818
 		}
1821
-		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate'])))
1819
+		if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT, $event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] && $event['start'] > $event['recur_enddate'])))
1822 1820
 		{
1823 1821
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1824 1822
 		}
1825
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1823
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event);
1826 1824
 
1827
-		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event))	// new event or edit rights to the event ==> allow to add alarm for all users
1825
+		if (!$event['id'] || $this->bo->check_perms(Acl::EDIT, $event))	// new event or edit rights to the event ==> allow to add alarm for all users
1828 1826
 		{
1829 1827
 			$sel_options['owner'][0] = lang('All participants');
1830 1828
 		}
@@ -1832,26 +1830,26 @@  discard block
 block discarded – undo
1832 1830
 		{
1833 1831
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1834 1832
 		}
1835
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1833
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1836 1834
 		{
1837
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
1835
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid))
1838 1836
 			{
1839 1837
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1840 1838
 			}
1841 1839
 		}
1842
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1840
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1843 1841
 		if (!$event['id'])
1844 1842
 		{
1845
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1843
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1846 1844
 		}
1847 1845
 		if ($preserved['no_popup'])
1848 1846
 		{
1849 1847
 			// If not a popup, load the normal calendar interface on cancel
1850
-			$etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')');
1848
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')');
1851 1849
 		}
1852 1850
 
1853 1851
 		// Allow admins to restore deleted events
1854
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1852
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1855 1853
 		{
1856 1854
 			$content['deleted'] = $preserved['deleted'] = null;
1857 1855
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1863,7 +1861,7 @@  discard block
 block discarded – undo
1863 1861
 		// Setup history tab
1864 1862
 		$this->setup_history($content, $sel_options);
1865 1863
 
1866
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1864
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1867 1865
 			. (!$event['id'] ? lang('Add')
1868 1866
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1869 1867
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1873,15 +1871,15 @@  discard block
 block discarded – undo
1873 1871
 		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1874 1872
 
1875 1873
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1876
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1874
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1877 1875
 		{
1878
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1876
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1879 1877
 			$content['button']['save'] = true;
1880
-			$this->process_edit(array_merge($content,$preserved));
1878
+			$this->process_edit(array_merge($content, $preserved));
1881 1879
 		}
1882 1880
 		else
1883 1881
 		{
1884
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1882
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1885 1883
 		}
1886 1884
 	}
1887 1885
 
@@ -1891,14 +1889,14 @@  discard block
 block discarded – undo
1891 1889
 	 * @param int $id
1892 1890
 	 * @param string $token
1893 1891
 	 */
1894
-	function ajax_unlock($id,$token)
1892
+	function ajax_unlock($id, $token)
1895 1893
 	{
1896
-		$lock_path = Vfs::app_entry_lock_path('calendar',$id);
1894
+		$lock_path = Vfs::app_entry_lock_path('calendar', $id);
1897 1895
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1898 1896
 
1899 1897
 		if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1900 1898
 		{
1901
-			Vfs::unlock($lock_path,$token,false);
1899
+			Vfs::unlock($lock_path, $token, false);
1902 1900
 		}
1903 1901
 	}
1904 1902
 
@@ -1910,17 +1908,17 @@  discard block
 block discarded – undo
1910 1908
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1911 1909
 	 * @param string $msg = null
1912 1910
 	 */
1913
-	function meeting(array $event=null, $msg=null)
1911
+	function meeting(array $event = null, $msg = null)
1914 1912
 	{
1915 1913
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1916 1914
 		$readonlys['button[apply]'] = true;
1917
-		$_usesession=!is_array($event);
1915
+		$_usesession = !is_array($event);
1918 1916
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1919 1917
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1920
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1918
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1921 1919
 		{
1922
-			$event=null; // set to null
1923
-			$_usesession=true; // trigger session read
1920
+			$event = null; // set to null
1921
+			$_usesession = true; // trigger session read
1924 1922
 		}
1925 1923
 		if (!is_array($event))
1926 1924
 		{
@@ -1949,7 +1947,7 @@  discard block
 block discarded – undo
1949 1947
 
1950 1948
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1951 1949
 			{
1952
-				switch(strtolower($ical_method))
1950
+				switch (strtolower($ical_method))
1953 1951
 				{
1954 1952
 					case 'reply':
1955 1953
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -2003,19 +2001,19 @@  discard block
 block discarded – undo
2003 2001
 			}
2004 2002
 			else	// event not in calendar
2005 2003
 			{
2006
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
2004
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
2007 2005
 			}
2008 2006
 			$event['participant_types'] = array();
2009
-			foreach($event['participants'] as $uid => $status)
2007
+			foreach ($event['participants'] as $uid => $status)
2010 2008
 			{
2011 2009
 				$user_type = $user_id = null;
2012 2010
 				calendar_so::split_user($uid, $user_type, $user_id);
2013 2011
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
2014
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
2012
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
2015 2013
 			}
2016 2014
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
2017 2015
 			$event['recure'] = $this->bo->recure2string($event);
2018
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
2016
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
2019 2017
 
2020 2018
 			// ignore events in the past (for recurring events check enddate!)
2021 2019
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -2035,23 +2033,23 @@  discard block
 block discarded – undo
2035 2033
 			// clear notification errors
2036 2034
 			notifications::errors(true);
2037 2035
 
2038
-			switch($button)
2036
+			switch ($button)
2039 2037
 			{
2040 2038
 				case 'reject':
2041 2039
 					if (!$event['id'])
2042 2040
 					{
2043 2041
 						// send reply to organizer
2044
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
2045
-						break;	// no need to store rejected event
2042
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
2043
+						break; // no need to store rejected event
2046 2044
 					}
2047 2045
 					// fall-through
2048 2046
 				case 'accept':
2049 2047
 				case 'tentativ':
2050
-					$status = strtoupper($button[0]);	// A, R or T
2048
+					$status = strtoupper($button[0]); // A, R or T
2051 2049
 					if (!$event['id'])
2052 2050
 					{
2053 2051
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
2054
-						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
2052
+						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner']))
2055 2053
 						{
2056 2054
 							// --> make organize a participant with role chair and current user the owner
2057 2055
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -2059,7 +2057,7 @@  discard block
 block discarded – undo
2059 2057
 							$event['owner'] = $this->user;
2060 2058
 						}
2061 2059
 						// store event without notifications!
2062
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
2060
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
2063 2061
 						{
2064 2062
 							$msg[] = lang('Event saved');
2065 2063
 						}
@@ -2097,7 +2095,7 @@  discard block
 block discarded – undo
2097 2095
 		Framework::message(implode("\n", (array)$msg));
2098 2096
 		$readonlys['button[edit]'] = !$event['id'];
2099 2097
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2100
-		switch(strtolower($ical_method))
2098
+		switch (strtolower($ical_method))
2101 2099
 		{
2102 2100
 			case 'reply':
2103 2101
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2121,37 +2119,37 @@  discard block
 block discarded – undo
2121 2119
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2122 2120
 	 * @param array $preserv data to preserv
2123 2121
 	 */
2124
-	function conflicts($event,$conflicts,$preserv)
2122
+	function conflicts($event, $conflicts, $preserv)
2125 2123
 	{
2126 2124
 		$etpl = new Etemplate('calendar.conflicts');
2127 2125
 		$allConflicts = array();
2128 2126
 
2129
-		foreach($conflicts as $k => $conflict)
2127
+		foreach ($conflicts as $k => $conflict)
2130 2128
 		{
2131
-			$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
2129
+			$is_readable = $this->bo->check_perms(Acl::READ, $conflict);
2132 2130
 
2133 2131
 			$conflicts[$k] += array(
2134 2132
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2135
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2136
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2137
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2138
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2139
-				),true,true)),	// show group invitations too
2133
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2134
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2135
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2136
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2137
+				), true, true)), // show group invitations too
2140 2138
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2141 2139
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2142 2140
 			);
2143
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2141
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2144 2142
 			}
2145 2143
 		$content = $event + array(
2146
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2144
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2147 2145
 		);
2148
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2146
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2149 2147
 		$resources_config = Api\Config::read('resources');
2150 2148
 		$readonlys = array();
2151 2149
 
2152 2150
 		foreach (array_keys($allConflicts) as $pId)
2153 2151
 		{
2154
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2152
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2155 2153
 			{
2156 2154
 
2157 2155
 				switch ($resources_config['ignoreconflicts'])
@@ -2171,7 +2169,7 @@  discard block
 block discarded – undo
2171 2169
 				}
2172 2170
 			}
2173 2171
 		}
2174
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2172
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2175 2173
 	}
2176 2174
 
2177 2175
 	/**
@@ -2189,7 +2187,7 @@  discard block
 block discarded – undo
2189 2187
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2190 2188
 
2191 2189
 		// convert start/end date-time values to timestamps
2192
-		foreach(array('start', 'end') as $name)
2190
+		foreach (array('start', 'end') as $name)
2193 2191
 		{
2194 2192
 			if (!empty($edit_content[$name]))
2195 2193
 			{
@@ -2219,7 +2217,7 @@  discard block
 block discarded – undo
2219 2217
 			'recur_type'   => $edit_content['recur_type'],
2220 2218
 			'participants' => array(),
2221 2219
 		);
2222
-		foreach($edit_content['participants'] as $key => $data)
2220
+		foreach ($edit_content['participants'] as $key => $data)
2223 2221
 		{
2224 2222
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2225 2223
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2234,21 +2232,21 @@  discard block
 block discarded – undo
2234 2232
 		// default search parameters
2235 2233
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2236 2234
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2237
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2235
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2238 2236
 		{
2239
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2237
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2240 2238
 		}
2241 2239
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2242 2240
 
2243 2241
 		$content['search_window'] = 7 * DAY_s;
2244 2242
 
2245 2243
 		// store content in session
2246
-		Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2244
+		Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2247 2245
 
2248 2246
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2249
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2247
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2250 2248
 
2251
-		$response->call('app.calendar.freetime_search_popup',$link);
2249
+		$response->call('app.calendar.freetime_search_popup', $link);
2252 2250
 
2253 2251
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2254 2252
 
@@ -2271,26 +2269,26 @@  discard block
 block discarded – undo
2271 2269
 	{
2272 2270
 		$etpl = new Etemplate('calendar.freetimesearch');
2273 2271
 		$sel_options['search_window'] = array(
2274
-			7*DAY_s		=> lang('one week'),
2275
-			14*DAY_s	=> lang('two weeks'),
2276
-			31*DAY_s	=> lang('one month'),
2277
-			92*DAY_s	=> lang('three month'),
2278
-			365*DAY_s	=> lang('one year'),
2272
+			7 * DAY_s		=> lang('one week'),
2273
+			14 * DAY_s	=> lang('two weeks'),
2274
+			31 * DAY_s	=> lang('one month'),
2275
+			92 * DAY_s	=> lang('three month'),
2276
+			365 * DAY_s	=> lang('one year'),
2279 2277
 		);
2280 2278
 		if (!is_array($content))
2281 2279
 		{
2282 2280
 			// get content from session (and delete it immediatly)
2283
-			$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2284
-			Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2281
+			$content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2282
+			Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2285 2283
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2286 2284
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2287 2285
 			$sTime = $content['start_time'];
2288 2286
 			$eTime = $content['end_time'];
2289
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2290
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2287
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2288
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2291 2289
 
2292 2290
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2293
-			foreach(array_keys($sel_options['search_window']) as $window)
2291
+			foreach (array_keys($sel_options['search_window']) as $window)
2294 2292
 			{
2295 2293
 				if ($window > $content['duration'])
2296 2294
 				{
@@ -2317,19 +2315,19 @@  discard block
 block discarded – undo
2317 2315
 		{
2318 2316
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2319 2317
 		}
2320
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2321
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2318
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2319
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2322 2320
 
2323
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2321
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2324 2322
 
2325 2323
 		$sel_options['duration'] = $this->durations;
2326 2324
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2327 2325
 
2328
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2326
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2329 2327
 				'participants'	=> $content['participants'],
2330 2328
 				'cal_id'		=> $content['cal_id'],
2331 2329
 				'recur_type'	=> $content['recur_type'],
2332
-			),2);
2330
+			), 2);
2333 2331
 	}
2334 2332
 
2335 2333
 	/**
@@ -2342,15 +2340,15 @@  discard block
 block discarded – undo
2342 2340
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2343 2341
 	 * @return array of free time-slots: array with start and end values
2344 2342
 	 */
2345
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2343
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2346 2344
 	{
2347
-		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id);
2345
+		if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)', true, $participants, $start, $end, $duration, $cal_id);
2348 2346
 
2349 2347
 		$busy = $this->bo->search(array(
2350 2348
 			'start' => $start,
2351 2349
 			'end'	=> $end,
2352 2350
 			'users'	=> $participants,
2353
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2351
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2354 2352
 		));
2355 2353
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2356 2354
 			'start'	=> $end,
@@ -2359,15 +2357,15 @@  discard block
 block discarded – undo
2359 2357
 		$ft_start = $start;
2360 2358
 		$freetime = array();
2361 2359
 		$n = 0;
2362
-		foreach($busy as $event)
2360
+		foreach ($busy as $event)
2363 2361
 		{
2364
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2362
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2365 2363
 
2366 2364
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2367 2365
 
2368 2366
 			// check if from all wanted participants at least one has a not rejected status in found event
2369 2367
 			$non_rejected_found = false;
2370
-			foreach($participants as $uid)
2368
+			foreach ($participants as $uid)
2371 2369
 			{
2372 2370
 				$status = $event['participants'][$uid];
2373 2371
 				$quantity = $role = null;
@@ -2386,10 +2384,10 @@  discard block
 block discarded – undo
2386 2384
 
2387 2385
 			if ($this->debug)
2388 2386
 			{
2389
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2387
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2390 2388
 				echo "event[title]=$event[title]<br>\n";
2391
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2392
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2389
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2390
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2393 2391
 			}
2394 2392
 			// $events ends before our actual position ==> ignore it
2395 2393
 			if ($event['end'] < $ft_start)
@@ -2413,11 +2411,11 @@  discard block
 block discarded – undo
2413 2411
 					'start'	=> $ft_start,
2414 2412
 					'end'	=> $ft_end,
2415 2413
 				);
2416
-				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n";
2414
+				if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i', $ft_start)." - ".date('D d.m.Y H:i', $ft_end)."</p>\n";
2417 2415
 			}
2418 2416
 			$ft_start = $event['end'];
2419 2417
 		}
2420
-		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime);
2418
+		if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6', true, $participants, $start, $end, $duration, $cal_id, $freetime);
2421 2419
 
2422 2420
 		return $freetime;
2423 2421
 	}
@@ -2437,46 +2435,46 @@  discard block
 block discarded – undo
2437 2435
 	 */
2438 2436
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2439 2437
 	{
2440
-		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time);
2438
+		if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)', true, $freetime, $duration, $_start_time, $_end_time);
2441 2439
 
2442 2440
 		$freetime_daywise = array();
2443 2441
 		if (!is_array($sel_options)) $sel_options = array();
2444 2442
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2445 2443
 
2446
-		$start_time = (int) $_start_time;	// ignore leading zeros
2447
-		$end_time   = (int) $_end_time;
2444
+		$start_time = (int)$_start_time; // ignore leading zeros
2445
+		$end_time   = (int)$_end_time;
2448 2446
 
2449 2447
 		// ignore the end_time, if duration would never fit
2450
-		if (($end_time - $start_time)*HOUR_s < $duration)
2448
+		if (($end_time - $start_time) * HOUR_s < $duration)
2451 2449
 		{
2452 2450
 			$end_time = 0;
2453
-			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time);
2451
+			if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise', true, $duration, $start_time);
2454 2452
 		}
2455 2453
 		$n = 0;
2456
-		foreach($freetime as $ft)
2454
+		foreach ($freetime as $ft)
2457 2455
 		{
2458 2456
 			$adaybegin = $this->bo->date2array($ft['start']);
2459 2457
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2460 2458
 			unset($adaybegin['raw']);
2461 2459
 			$daybegin = $this->bo->date2ts($adaybegin);
2462 2460
 
2463
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2461
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2464 2462
 			{
2465
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2466
-				$mcal_dow = pow(2,$dow);
2467
-				if (!($weekdays & $mcal_dow))
2463
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2464
+				$mcal_dow = pow(2, $dow);
2465
+				if (!($weekdays&$mcal_dow))
2468 2466
 				{
2469 2467
 					//echo "wrong day of week $dow<br>\n";
2470
-					continue;	// wrong day of week
2468
+					continue; // wrong day of week
2471 2469
 				}
2472 2470
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2473 2471
 
2474
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2472
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2475 2473
 				{
2476
-					$start = $daybegin + $start_time*HOUR_s;
2474
+					$start = $daybegin + $start_time * HOUR_s;
2477 2475
 				}
2478 2476
 				// if end_time given use it, else the original slot's end
2479
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2477
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2480 2478
 				if ($end > $ft['end']) $end = $ft['end'];
2481 2479
 
2482 2480
 				// slot to small for duration
@@ -2490,11 +2488,11 @@  discard block
 block discarded – undo
2490 2488
 					'end'	=> $end,
2491 2489
 				);
2492 2490
 				$times = array();
2493
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2491
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2494 2492
 				{
2495 2493
 					$e = $s + $duration;
2496
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2497
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2494
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2495
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2498 2496
 				}
2499 2497
 				$sel_options[$n.'start'] = $times;
2500 2498
 			}
@@ -2509,13 +2507,13 @@  discard block
 block discarded – undo
2509 2507
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2510 2508
      * @return string error-msg if $return_error
2511 2509
      */
2512
-    function export($content=0,$return_error=false)
2510
+    function export($content = 0, $return_error = false)
2513 2511
     {
2514 2512
 		$boical = new calendar_ical();
2515 2513
 		#error_log(__METHOD__.print_r($content,true));
2516 2514
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2517 2515
 		{
2518
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2516
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2519 2517
 			{
2520 2518
 				$msg = lang('Permission denied');
2521 2519
 
@@ -2523,20 +2521,20 @@  discard block
 block discarded – undo
2523 2521
 			}
2524 2522
 			else
2525 2523
 			{
2526
-				html::content_header('event.ics','text/calendar',bytes($ical));
2524
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2527 2525
 				echo $ical;
2528 2526
 				common::egw_exit();
2529 2527
 			}
2530 2528
 		}
2531 2529
 		if (is_array($content))
2532 2530
 		{
2533
-			$events =& $this->bo->search(array(
2531
+			$events = & $this->bo->search(array(
2534 2532
 				'start' => $content['start'],
2535 2533
 				'end'   => $content['end'],
2536 2534
 				'enum_recuring' => false,
2537 2535
 				'daywise'       => false,
2538 2536
 				'owner'         => $this->owner,
2539
-				'date_format'   => 'server',    // timestamp in server time for boical class
2537
+				'date_format'   => 'server', // timestamp in server time for boical class
2540 2538
 			));
2541 2539
 			if (!$events)
2542 2540
 			{
@@ -2544,8 +2542,8 @@  discard block
 block discarded – undo
2544 2542
 			}
2545 2543
 			else
2546 2544
 			{
2547
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2548
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2545
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2546
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2549 2547
 				echo $ical;
2550 2548
 				common::egw_exit();
2551 2549
 			}
@@ -2561,9 +2559,9 @@  discard block
 block discarded – undo
2561 2559
 		}
2562 2560
 		$content['msg'] = $msg;
2563 2561
 
2564
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2562
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2565 2563
 		$etpl = new etemplate_new('calendar.export');
2566
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2564
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2567 2565
     }
2568 2566
 
2569 2567
 	/**
@@ -2571,7 +2569,7 @@  discard block
 block discarded – undo
2571 2569
 	 *
2572 2570
 	 * @param array $_content
2573 2571
 	 */
2574
-	function cat_acl(array $_content=null)
2572
+	function cat_acl(array $_content = null)
2575 2573
 	{
2576 2574
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2577 2575
 		{
@@ -2583,15 +2581,15 @@  discard block
 block discarded – undo
2583 2581
 			unset($_content['button']);
2584 2582
 			if ($button != 'cancel')	// store changed Acl
2585 2583
 			{
2586
-				foreach($_content as $data)
2584
+				foreach ($_content as $data)
2587 2585
 				{
2588 2586
 					if (!($cat_id = $data['cat_id'])) continue;
2589
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2587
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2590 2588
 					{
2591 2589
 						$rights = 0;
2592
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2593
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2594
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2590
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2591
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2592
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2595 2593
 					}
2596 2594
 				}
2597 2595
 			}
@@ -2603,20 +2601,20 @@  discard block
 block discarded – undo
2603 2601
 				), 'admin');
2604 2602
 			}
2605 2603
 		}
2606
-		$content= $preserv = array();
2604
+		$content = $preserv = array();
2607 2605
 		$n = 1;
2608
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2606
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2609 2607
 		{
2610
-			$cat_id = substr($Lcat_id,1);
2608
+			$cat_id = substr($Lcat_id, 1);
2611 2609
 			$row = array(
2612 2610
 				'cat_id' => $cat_id,
2613 2611
 				'add' => array(),
2614 2612
 				'status' => array(),
2615 2613
 			);
2616
-			foreach($data as $account_id => $rights)
2614
+			foreach ($data as $account_id => $rights)
2617 2615
 			{
2618
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2619
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2616
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2617
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2620 2618
 			}
2621 2619
 			$content[$n] = $row;
2622 2620
 			$preserv[$n] = array(
@@ -2632,7 +2630,7 @@  discard block
 block discarded – undo
2632 2630
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2633 2631
 		$tmp = new Etemplate('calendar.cat_acl');
2634 2632
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2635
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2633
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2636 2634
 	}
2637 2635
 
2638 2636
 	/**
@@ -2682,18 +2680,18 @@  discard block
 block discarded – undo
2682 2680
 
2683 2681
 
2684 2682
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2685
-		if($content['recur_type'] || $content['recurrence'])
2683
+		if ($content['recur_type'] || $content['recurrence'])
2686 2684
 		{
2687 2685
 			$content['history']['filter'] = array(
2688 2686
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2689
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2690
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2687
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2688
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2691 2689
 			);
2692 2690
 		}
2693 2691
 
2694 2692
 		// Translate labels
2695 2693
 		$tracking = new calendar_tracking();
2696
-		foreach($tracking->field2label as $field => $label)
2694
+		foreach ($tracking->field2label as $field => $label)
2697 2695
 		{
2698 2696
 			$sel_options[$status][$field] = lang($label);
2699 2697
 		}
@@ -2712,44 +2710,44 @@  discard block
 block discarded – undo
2712 2710
 	 *	which particular instance was dragged
2713 2711
 	 * @return string XML response if no error occurs
2714 2712
 	 */
2715
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2713
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2716 2714
 	{
2717
-		list($eventId, $date) = explode(':', $_eventId,2);
2715
+		list($eventId, $date) = explode(':', $_eventId, 2);
2718 2716
 		$ignore_conflicts = false;
2719 2717
 
2720 2718
 		// we do not allow dragging into another users calendar ATM
2721
-		if($targetOwner < 0)
2719
+		if ($targetOwner < 0)
2722 2720
 		{
2723 2721
 			$targetOwner = array($targetOwner);
2724 2722
 		}
2725
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2723
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2726 2724
 		{
2727 2725
 			$targetOwner = $calendarOwner;
2728 2726
 		}
2729 2727
 		// But you may be viewing multiple users, or a group calendar and
2730 2728
 		// dragging your event - dragging across calendars does not change owner
2731
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2729
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2732 2730
 		{
2733 2731
 			$return = true;
2734
-			foreach($targetOwner as $owner)
2732
+			foreach ($targetOwner as $owner)
2735 2733
 			{
2736
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2734
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2737 2735
 				{
2738 2736
 					$return = false;
2739 2737
 					break;
2740 2738
 				}
2741
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2739
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2742 2740
 				{
2743 2741
 					$return = false;
2744 2742
 					break;
2745 2743
 				}
2746 2744
 			}
2747
-			if($return) return;
2745
+			if ($return) return;
2748 2746
 		}
2749
-		$old_event=$event=$this->bo->read($eventId);
2747
+		$old_event = $event = $this->bo->read($eventId);
2750 2748
 		if (!$durationT)
2751 2749
 		{
2752
-			$duration=$event['end']-$event['start'];
2750
+			$duration = $event['end'] - $event['start'];
2753 2751
 		}
2754 2752
 		// Drag a normal event to whole day non-blocking
2755 2753
 		else if ($durationT == 'whole_day')
@@ -2757,7 +2755,7 @@  discard block
 block discarded – undo
2757 2755
 			$event['whole_day'] = true;
2758 2756
 			$event['non_blocking'] = true;
2759 2757
 			// Make duration whole days, less 1 second
2760
-			$duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1;
2758
+			$duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1;
2761 2759
 		}
2762 2760
 		else
2763 2761
 		{
@@ -2770,19 +2768,19 @@  discard block
 block discarded – undo
2770 2768
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2771 2769
 			if (!empty($event['whole_day']))
2772 2770
 			{
2773
-				$d =& $this->bo->so->startOfDay($d);
2771
+				$d = & $this->bo->so->startOfDay($d);
2774 2772
 				$d->setUser();
2775 2773
 			}
2776 2774
 			$event = $this->bo->read($eventId, $d, true);
2777 2775
 
2778 2776
 			// For DnD, create an exception if they gave the date
2779 2777
 			$preserv = null;
2780
-			$this->_create_exception($event,$preserv);
2778
+			$this->_create_exception($event, $preserv);
2781 2779
 			unset($event['id']);
2782 2780
 			$links = $event['link_to']['to_id'];
2783 2781
 
2784 2782
 			$messages = null;
2785
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2783
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2786 2784
 			if (!is_array($conflicts) && $conflicts)
2787 2785
 			{
2788 2786
 				// now we need to add the original start as recur-execption to the series
@@ -2790,28 +2788,28 @@  discard block
 block discarded – undo
2790 2788
 				$recur_event['recur_exception'][] = $d->format('ts');
2791 2789
 				// check if we need to move the alarms, because they are next on that exception
2792 2790
 				$this->bo->check_move_alarms($recur_event, null, $d);
2793
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2794
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2795
-				$this->bo->update($recur_event,true);	// no conflict check here
2791
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2792
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2793
+				$this->bo->update($recur_event, true); // no conflict check here
2796 2794
 
2797 2795
 				// Sending null will trigger a removal of the original for that date
2798 2796
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2799 2797
 
2800 2798
 				unset($recur_event);
2801
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2799
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2802 2800
 				unset($preserv['edit_single']);
2803 2801
 			}
2804 2802
 		}
2805 2803
 
2806 2804
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2807 2805
 		$event['start'] = $d->format('ts');
2808
-		$event['end'] = $event['start']+$duration;
2806
+		$event['end'] = $event['start'] + $duration;
2809 2807
 
2810 2808
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2811 2809
 		{
2812 2810
 			// calculate offset against clicked recurrance,
2813 2811
 			// depending on which is smaller
2814
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2812
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2815 2813
 			$event['start'] = $old_event['start'] + $offset;
2816 2814
 			$event['duration'] = $duration;
2817 2815
 
@@ -2822,31 +2820,31 @@  discard block
 block discarded – undo
2822 2820
 			// Can't handle conflict.  Just ignore it.
2823 2821
 			$ignore_conflicts = true;
2824 2822
 		}
2825
-		if(!$event['recur_type'])
2823
+		if (!$event['recur_type'])
2826 2824
 		{
2827 2825
 			$this->bo->check_move_alarms($event, $old_event);
2828 2826
 		}
2829 2827
 
2830 2828
 		// Drag a whole day to a time
2831
-		if($durationT && $durationT != 'whole_day')
2829
+		if ($durationT && $durationT != 'whole_day')
2832 2830
 		{
2833 2831
 			$event['whole_day'] = ($duration == DAY_s);
2834 2832
 			$event['non_blocking'] = false;
2835 2833
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2836 2834
 			// so save the change now, and then let the conflict check happen.
2837 2835
 			$message = null;
2838
-			$this->bo->update($event,true, true, false, true, $message,true);
2836
+			$this->bo->update($event, true, true, false, true, $message, true);
2839 2837
 
2840 2838
 			// Whole day non blocking with DAY_s would add a day
2841
-			if($duration==DAY_s) $duration=0;
2839
+			if ($duration == DAY_s) $duration = 0;
2842 2840
 		}
2843 2841
 
2844 2842
 		$status_reset_to_unknown = false;
2845 2843
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2846
-		foreach((array)$event['participants'] as $uid => $status)
2844
+		foreach ((array)$event['participants'] as $uid => $status)
2847 2845
 		{
2848 2846
 			$q = $r = null;
2849
-			calendar_so::split_status($status,$q,$r);
2847
+			calendar_so::split_status($status, $q, $r);
2850 2848
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2851 2849
 			{
2852 2850
 				$preferences = new Api\Preferences($uid);
@@ -2859,29 +2857,29 @@  discard block
 block discarded – undo
2859 2857
 						if ($sameday) break;
2860 2858
 					default:
2861 2859
 						$status_reset_to_unknown = true;
2862
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2860
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2863 2861
 						// todo: report reset status to user
2864 2862
 				}
2865 2863
 			}
2866 2864
 		}
2867 2865
 
2868 2866
 		$message = false;
2869
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2867
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2870 2868
 
2871 2869
 		// Save links
2872
-		if($links)
2870
+		if ($links)
2873 2871
 		{
2874 2872
 			Link::link('calendar', $event['id'], $links);
2875 2873
 		}
2876 2874
 
2877
-		$this->update_client($event['id'],$d);
2875
+		$this->update_client($event['id'], $d);
2878 2876
 		$response = Api\Json\Response::get();
2879
-		if(!is_array($conflicts) && $conflicts)
2877
+		if (!is_array($conflicts) && $conflicts)
2880 2878
 		{
2881
-			if(is_int($conflicts))
2879
+			if (is_int($conflicts))
2882 2880
 			{
2883 2881
 				$event['id'] = $conflicts;
2884
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2882
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2885 2883
 			}
2886 2884
 		}
2887 2885
 		else if ($conflicts)
@@ -2894,21 +2892,21 @@  discard block
 block discarded – undo
2894 2892
 					.'&end='.$event['end']
2895 2893
 					.'&non_interactive=true'
2896 2894
 					.'&cancel_needs_refresh=true',
2897
-				'',750,410);
2895
+				'', 750, 410);
2898 2896
 		}
2899 2897
 		else if ($message)
2900 2898
 		{
2901
-			$response->call('egw.message',  implode('<br />', $message));
2899
+			$response->call('egw.message', implode('<br />', $message));
2902 2900
 		}
2903
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2901
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2904 2902
 		if ($status_reset_to_unknown)
2905 2903
 		{
2906
-			foreach((array)$event['participants'] as $uid => $status)
2904
+			foreach ((array)$event['participants'] as $uid => $status)
2907 2905
 			{
2908 2906
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2909 2907
 				{
2910
-					calendar_so::split_status($status,$q,$r);
2911
-					$status = calendar_so::combine_status('U',$q,$r);
2908
+					calendar_so::split_status($status, $q, $r);
2909
+					$status = calendar_so::combine_status('U', $q, $r);
2912 2910
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2913 2911
 				}
2914 2912
 			}
@@ -2925,7 +2923,7 @@  discard block
 block discarded – undo
2925 2923
 	{
2926 2924
 		list($eventId, $date) = explode(':', $_eventId);
2927 2925
 		$event = $this->bo->read($eventId);
2928
-		if($date)
2926
+		if ($date)
2929 2927
 		{
2930 2928
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2931 2929
 		}
@@ -2935,29 +2933,29 @@  discard block
 block discarded – undo
2935 2933
 		{
2936 2934
 			if (!empty($event['whole_day']))
2937 2935
 			{
2938
-				$d =& $this->bo->so->startOfDay($date);
2936
+				$d = & $this->bo->so->startOfDay($date);
2939 2937
 				$d->setUser();
2940 2938
 			}
2941 2939
 			$event = $this->bo->read($eventId, $d, true);
2942 2940
 			$date = $d->format('ts');
2943 2941
 		}
2944
-		if($event['participants'][$uid])
2942
+		if ($event['participants'][$uid])
2945 2943
 		{
2946 2944
 			$q = $r = null;
2947
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2948
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2949
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2945
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2946
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2947
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2950 2948
 		}
2951 2949
 		else
2952 2950
 		{
2953 2951
 			// Group membership
2954
-			foreach($event['participants'] as $id => $status)
2952
+			foreach ($event['participants'] as $id => $status)
2955 2953
 			{
2956
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2954
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2957 2955
 				{
2958
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2959
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2960
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2956
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2957
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2958
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2961 2959
 					break;
2962 2960
 				}
2963 2961
 			}
@@ -2965,7 +2963,7 @@  discard block
 block discarded – undo
2965 2963
 
2966 2964
 		// Directly update stored data.  If event is still visible, it will
2967 2965
 		// be notified & update itself.
2968
-		$this->update_client($eventId,$d);
2966
+		$this->update_client($eventId, $d);
2969 2967
 	}
2970 2968
 
2971 2969
 	/**
@@ -2973,8 +2971,8 @@  discard block
 block discarded – undo
2973 2971
 	 */
2974 2972
 	public function ajax_delete($eventId)
2975 2973
 	{
2976
-		list($id, $date) = explode(':',$eventId);
2977
-		$event=$this->bo->read($id);
2974
+		list($id, $date) = explode(':', $eventId);
2975
+		$event = $this->bo->read($id);
2978 2976
 		$response = Api\Json\Response::get();
2979 2977
 
2980 2978
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2987,11 +2985,11 @@  discard block
 block discarded – undo
2987 2985
 			{
2988 2986
 				$msg = lang('Event deleted');
2989 2987
 			}
2990
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2988
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2991 2989
 		}
2992 2990
 		else
2993 2991
 		{
2994
-			$response->apply('egw.message', Array(lang('Error')),'error');
2992
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2995 2993
 		}
2996 2994
 	}
2997 2995
 
@@ -3004,10 +3002,10 @@  discard block
 block discarded – undo
3004 3002
 	 */
3005 3003
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
3006 3004
 	{
3007
-		list($eventId, $date) = explode(':', $_eventId,2);
3005
+		list($eventId, $date) = explode(':', $_eventId, 2);
3008 3006
 
3009 3007
 		$event = $this->bo->read($eventId);
3010
-		if($date)
3008
+		if ($date)
3011 3009
 		{
3012 3010
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
3013 3011
 		}
@@ -3017,17 +3015,17 @@  discard block
 block discarded – undo
3017 3015
 		{
3018 3016
 			if (!empty($event['whole_day']))
3019 3017
 			{
3020
-				$d =& $this->bo->so->startOfDay($date);
3018
+				$d = & $this->bo->so->startOfDay($date);
3021 3019
 				$d->setUser();
3022 3020
 			}
3023 3021
 			$event = $this->bo->read($eventId, $d, true);
3024 3022
 			// For DnD, create an exception if they gave the date
3025 3023
 			$preserv = null;
3026
-			$this->_create_exception($event,$preserv);
3024
+			$this->_create_exception($event, $preserv);
3027 3025
 			unset($event['id']);
3028 3026
 
3029 3027
 			$messages = null;
3030
-			$conflicts = $this->bo->update($event,true,true,false,true,$messages);
3028
+			$conflicts = $this->bo->update($event, true, true, false, true, $messages);
3031 3029
 			if (!is_array($conflicts) && $conflicts)
3032 3030
 			{
3033 3031
 				// now we need to add the original start as recur-execption to the series
@@ -3035,28 +3033,28 @@  discard block
 block discarded – undo
3035 3033
 				$recur_event['recur_exception'][] = $d->format('ts');
3036 3034
 				// check if we need to move the alarms, because they are next on that exception
3037 3035
 				$this->bo->check_move_alarms($recur_event, null, $d);
3038
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
3039
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
3040
-				$this->bo->update($recur_event,true);	// no conflict check here
3036
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
3037
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
3038
+				$this->bo->update($recur_event, true); // no conflict check here
3041 3039
 
3042 3040
 				// Sending null will trigger a removal of the original for that date
3043 3041
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
3044 3042
 
3045 3043
 				unset($recur_event);
3046
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
3044
+				unset($event['edit_single']); // if we further edit it, it's just a single event
3047 3045
 				unset($preserv['edit_single']);
3048 3046
 			}
3049 3047
 		}
3050
-		foreach($remove as $participant)
3048
+		foreach ($remove as $participant)
3051 3049
 		{
3052 3050
 			unset($event['participants'][$participant]);
3053 3051
 		}
3054
-		foreach($invite as $participant)
3052
+		foreach ($invite as $participant)
3055 3053
 		{
3056 3054
 			$event['participants'][$participant] = 'U';
3057 3055
 		}
3058 3056
 		$message = null;
3059
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
3057
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
3060 3058
 
3061 3059
 		$response = Api\Json\Response::get();
3062 3060
 
@@ -3064,8 +3062,8 @@  discard block
 block discarded – undo
3064 3062
 		{
3065 3063
 			// Save it anyway, was done with explicit user interaction,
3066 3064
 			// and if we don't we lose the invite
3067
-			$this->bo->update($event,true);	// no conflict check here
3068
-			$this->update_client($event['id'],$d);
3065
+			$this->bo->update($event, true); // no conflict check here
3066
+			$this->update_client($event['id'], $d);
3069 3067
 			$response->call(
3070 3068
 				'egw_openWindowCentered2',
3071 3069
 				$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
@@ -3074,22 +3072,22 @@  discard block
 block discarded – undo
3074 3072
 					.'&end='.$event['end']
3075 3073
 					.'&non_interactive=true'
3076 3074
 					.'&cancel_needs_refresh=true',
3077
-				'',750,410);
3075
+				'', 750, 410);
3078 3076
 		}
3079 3077
 		else if ($message)
3080 3078
 		{
3081
-			$response->call('egw.message',  implode('<br />', $message));
3079
+			$response->call('egw.message', implode('<br />', $message));
3082 3080
 		}
3083
-		if($conflicts)
3081
+		if ($conflicts)
3084 3082
 		{
3085
-			$this->update_client($event['id'],$d);
3086
-			if(is_int($conflicts))
3083
+			$this->update_client($event['id'], $d);
3084
+			if (is_int($conflicts))
3087 3085
 			{
3088 3086
 				$event['id'] = $conflicts;
3089 3087
 			}
3090
-			if($event['id'])
3088
+			if ($event['id'])
3091 3089
 			{
3092
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
3090
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
3093 3091
 			}
3094 3092
 		}
3095 3093
 	}
@@ -3100,13 +3098,13 @@  discard block
 block discarded – undo
3100 3098
 	 * @param array $mailContent = null mail content
3101 3099
 	 * @return  array
3102 3100
 	 */
3103
-	function mail_import(array $mailContent=null)
3101
+	function mail_import(array $mailContent = null)
3104 3102
 	{
3105 3103
 		// It would get called from compose as a popup with egw_data
3106 3104
 		if (!is_array($mailContent) && ($_GET['egw_data']))
3107 3105
 		{
3108 3106
 			// get raw mail data
3109
-			Link::get_data ($_GET['egw_data']);
3107
+			Link::get_data($_GET['egw_data']);
3110 3108
 			return false;
3111 3109
 		}
3112 3110
 
@@ -3116,7 +3114,7 @@  discard block
 block discarded – undo
3116 3114
 			$AB = new Api\Contacts();
3117 3115
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
3118 3116
 
3119
-			$participants[0] = array (
3117
+			$participants[0] = array(
3120 3118
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
3121 3119
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
3122 3120
 				'status' => 'A',
@@ -3124,23 +3122,23 @@  discard block
 block discarded – undo
3124 3122
 				'app' => 'User',
3125 3123
 				'role' => 'REQ-PARTICIPANT'
3126 3124
 			);
3127
-			foreach($mailContent['addresses'] as $address)
3125
+			foreach ($mailContent['addresses'] as $address)
3128 3126
 			{
3129 3127
 				// Get available contacts from the email
3130 3128
 				$contacts = $AB->search(array(
3131 3129
 						'email' => $address['email'],
3132 3130
 						'email_home' => $address['email']
3133
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
3131
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
3134 3132
 				if (is_array($contacts))
3135 3133
 				{
3136
-					foreach($contacts as $account)
3134
+					foreach ($contacts as $account)
3137 3135
 					{
3138 3136
 						$accounts[] = $account['account_id'];
3139 3137
 					}
3140 3138
 				}
3141 3139
 				else
3142 3140
 				{
3143
-					$participants []= array (
3141
+					$participants [] = array(
3144 3142
 						'app' => 'email',
3145 3143
 						'uid' => 'e'.$address['email'],
3146 3144
 						'status' => 'U',
@@ -3148,7 +3146,7 @@  discard block
 block discarded – undo
3148 3146
 					);
3149 3147
 				}
3150 3148
 			}
3151
-			$participants = array_merge($participants , array(
3149
+			$participants = array_merge($participants, array(
3152 3150
 				"participant" => $accounts,
3153 3151
 				"role" => "REQ-PARTICIPANT",
3154 3152
 				"add" => "pressed"
@@ -3172,14 +3170,14 @@  discard block
 block discarded – undo
3172 3170
 			{
3173 3171
 				foreach ($mailContent['attachments'] as $attachment)
3174 3172
 				{
3175
-					if($attachment['egw_data'])
3173
+					if ($attachment['egw_data'])
3176 3174
 					{
3177
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3175
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3178 3176
 					}
3179
-					else if(is_readable($attachment['tmp_name']) ||
3177
+					else if (is_readable($attachment['tmp_name']) ||
3180 3178
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3181 3179
 					{
3182
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3180
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3183 3181
 					}
3184 3182
 				}
3185 3183
 			}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 1 patch
Braces   +325 added lines, -83 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)
@@ -2782,7 +2977,10 @@  discard block
 block discarded – undo
2782 2977
 					}
2783 2978
 					break;
2784 2979
 				case 'EXDATE':
2785
-					if (!$attributes['value']) break;
2980
+					if (!$attributes['value'])
2981
+					{
2982
+						break;
2983
+					}
2786 2984
 					if ((isset($attributes['params']['VALUE'])
2787 2985
 							&& $attributes['params']['VALUE'] == 'DATE') ||
2788 2986
 						(!isset($attributes['params']['VALUE']) && $isDate))
@@ -2862,13 +3060,16 @@  discard block
 block discarded – undo
2862 3060
 					// fall throught
2863 3061
 				case 'ATTENDEE':
2864 3062
 					if (isset($attributes['params']['PARTSTAT']))
2865
-				    {
3063
+					{
2866 3064
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2867 3065
 				    }
2868 3066
 				    if (isset($attributes['params']['STATUS']))
2869
-					{
3067
+				    {
2870 3068
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2871
-						if (empty($status)) $status = 'X';
3069
+						if (empty($status))
3070
+						{
3071
+							$status = 'X';
3072
+						}
2872 3073
 					}
2873 3074
 					else
2874 3075
 					{
@@ -2928,7 +3129,10 @@  discard block
 block discarded – undo
2928 3129
 							$uid = $this->user;
2929 3130
 					}
2930 3131
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2931
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3132
+					if (!$uid)
3133
+					{
3134
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
3135
+					}
2932 3136
 
2933 3137
 					// try to find an email address
2934 3138
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2996,7 +3200,10 @@  discard block
 block discarded – undo
2996 3200
 								}
2997 3201
 								$status = 'U'; // keep the group
2998 3202
 							}
2999
-							else continue; // can't find this group
3203
+							else {
3204
+								continue;
3205
+							}
3206
+							// can't find this group
3000 3207
 						}
3001 3208
 						elseif (empty($searcharray))
3002 3209
 						{
@@ -3055,7 +3262,9 @@  discard block
 block discarded – undo
3055 3262
 
3056 3263
 								try {
3057 3264
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
3058
-										$component->getAttribute('ORGANIZER');
3265
+									{
3266
+																			$component->getAttribute('ORGANIZER');
3267
+									}
3059 3268
 								}
3060 3269
 								catch(Horde_Icalendar_Exception $e)
3061 3270
 								{
@@ -3092,7 +3301,10 @@  discard block
 block discarded – undo
3092 3301
 					}
3093 3302
 					break;
3094 3303
 				case 'CREATED':		// will be written direct to the event
3095
-					if ($event['modified']) break;
3304
+					if ($event['modified'])
3305
+					{
3306
+						break;
3307
+					}
3096 3308
 					// fall through
3097 3309
 				case 'LAST-MODIFIED':	// will be written direct to the event
3098 3310
 					$event['modified'] = $attributes['value'];
@@ -3113,7 +3325,11 @@  discard block
 block discarded – undo
3113 3325
 					break;
3114 3326
 
3115 3327
 				case 'ATTACH':
3116
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3328
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3329
+					{
3330
+						break;
3331
+					}
3332
+					// handeled by managed attachment code
3117 3333
 					// fall throught to store external attachment url
3118 3334
 				default:	// X- attribute or other by EGroupware unsupported property
3119 3335
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3244,7 +3460,10 @@  discard block
 block discarded – undo
3244 3460
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3245 3461
 		}
3246 3462
 
3247
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3463
+		if ($this->calendarOwner)
3464
+		{
3465
+			$event['owner'] = $this->calendarOwner;
3466
+		}
3248 3467
 
3249 3468
 		// parsing ATTACH attributes for managed attachments
3250 3469
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3270,7 +3489,10 @@  discard block
 block discarded – undo
3270 3489
 				$filter = $relax ? 'relax' : 'check';
3271 3490
 				$event = array_shift($events);
3272 3491
 				$eventId = -1;
3273
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3492
+				if ($this->so->isWholeDay($event))
3493
+				{
3494
+					$event['whole_day'] = true;
3495
+				}
3274 3496
 				if ($contentID)
3275 3497
 				{
3276 3498
 					$parts = preg_split('/:/', $contentID);
@@ -3323,8 +3545,16 @@  discard block
 block discarded – undo
3323 3545
 	 */
3324 3546
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3325 3547
 	{
3326
-		if (!$start) $start = time();	// default now
3327
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3548
+		if (!$start)
3549
+		{
3550
+			$start = time();
3551
+		}
3552
+		// default now
3553
+		if (!$end)
3554
+		{
3555
+			$end = time() + 100*DAY_s;
3556
+		}
3557
+		// default next 100 days
3328 3558
 
3329 3559
 		$vcal = new Horde_Icalendar;
3330 3560
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3346,10 +3576,13 @@  discard block
 block discarded – undo
3346 3576
 				$attributes[$attr] = date('Ymd\THis', $value);
3347 3577
 			}
3348 3578
 		}
3349
-		if (is_null($extra)) $extra = array(
3579
+		if (is_null($extra))
3580
+		{
3581
+			$extra = array(
3350 3582
 			'URL' => $this->freebusy_url($user),
3351 3583
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3352 3584
 		);
3585
+		}
3353 3586
 		foreach($attributes+$extra as $attr => $value)
3354 3587
 		{
3355 3588
 			$vfreebusy->setAttribute($attr, $value);
@@ -3365,12 +3598,21 @@  discard block
 block discarded – undo
3365 3598
 		{
3366 3599
 			foreach ($fbdata as $event)
3367 3600
 			{
3368
-				if ($event['non_blocking']) continue;
3369
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3601
+				if ($event['non_blocking'])
3602
+				{
3603
+					continue;
3604
+				}
3605
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3606
+				{
3607
+					continue;
3608
+				}
3370 3609
 				$status = $event['participants'][$user];
3371 3610
 				$quantity = $role = null;
3372 3611
 				calendar_so::split_status($status, $quantity, $role);
3373
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
3612
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
3613
+				{
3614
+					continue;
3615
+				}
3374 3616
 
3375 3617
 				$fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3376 3618
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_boupdate.inc.php 2 patches
Spacing   +308 added lines, -310 removed lines patch added patch discarded remove patch
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 use EGroupware\Api\Acl;
17 17
 
18 18
 // types of messsages send by calendar_boupdate::send_update
19
-define('MSG_DELETED',0);
20
-define('MSG_MODIFIED',1);
21
-define('MSG_ADDED',2);
22
-define('MSG_REJECTED',3);
23
-define('MSG_TENTATIVE',4);
24
-define('MSG_ACCEPTED',5);
25
-define('MSG_ALARM',6);
26
-define('MSG_DISINVITE',7);
27
-define('MSG_DELEGATED',8);
19
+define('MSG_DELETED', 0);
20
+define('MSG_MODIFIED', 1);
21
+define('MSG_ADDED', 2);
22
+define('MSG_REJECTED', 3);
23
+define('MSG_TENTATIVE', 4);
24
+define('MSG_ACCEPTED', 5);
25
+define('MSG_ALARM', 6);
26
+define('MSG_DISINVITE', 7);
27
+define('MSG_DELEGATED', 8);
28 28
 
29 29
 /**
30 30
  * Class to access AND manipulate all calendar data (business object)
@@ -85,11 +85,11 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True);
89 89
 
90
-		parent::__construct();	// calling the parent constructor
90
+		parent::__construct(); // calling the parent constructor
91 91
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
92
+		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True);
93 93
 	}
94 94
 
95 95
 	/**
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 	 * +      + +  C   +	which is clearly wrong for everything with a maximum quantity > 1
117 117
 	 * ++++++++ ++++++++
118 118
 	 */
119
-	function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
119
+	function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
120 120
 	{
121
-		unset($updateTS);	// ignored, as updating timestamps is required for sync!
121
+		unset($updateTS); // ignored, as updating timestamps is required for sync!
122 122
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
123 123
 		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
124 124
 
125 125
 		if ($this->debug > 1 || $this->debug == 'update')
126 126
 		{
127 127
 			$this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)',
128
-				false,$event,$ignore_conflicts,$touch_modified,$ignore_acl);
128
+				false, $event, $ignore_conflicts, $touch_modified, $ignore_acl);
129 129
 		}
130 130
 		// check some minimum requirements:
131 131
 		// - new events need start, end and title
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
 		}
154 154
 
155 155
 		// check if user has the permission to update / create the event
156
-		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) ||
157
-			$new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) &&
158
-			!$this->check_perms(Acl::ADD,0,$event['owner']))
156
+		if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) ||
157
+			$new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) &&
158
+			!$this->check_perms(Acl::ADD, 0, $event['owner']))
159 159
 		{
160
-			$messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner']));
160
+			$messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner']));
161 161
 			return false;
162 162
 		}
163 163
 		if ($new_event)
@@ -166,24 +166,24 @@  discard block
 block discarded – undo
166 166
 		}
167 167
 		else
168 168
 		{
169
-			$old_event = $this->read((int)$event['id'],null,$ignore_acl);
169
+			$old_event = $this->read((int)$event['id'], null, $ignore_acl);
170 170
 		}
171 171
 
172 172
 		// do we need to check, if user is allowed to invite the invited participants
173
-		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event)))
173
+		if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event)))
174 174
 		{
175 175
 			// report removed participants back to user
176
-			foreach($removed as $key => $account_id)
176
+			foreach ($removed as $key => $account_id)
177 177
 			{
178 178
 				$removed[$key] = $this->participant_name($account_id);
179 179
 			}
180
-			$messages[] = lang('%1 participants removed because of missing invite grants',count($removed)).
181
-				': '.implode(', ',$removed);
180
+			$messages[] = lang('%1 participants removed because of missing invite grants', count($removed)).
181
+				': '.implode(', ', $removed);
182 182
 		}
183 183
 		// check category based ACL
184 184
 		if ($event['category'])
185 185
 		{
186
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
186
+			if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']);
187 187
 			if (!$old_event || !isset($old_event['category']))
188 188
 			{
189 189
 				$old_event['category'] = array();
@@ -192,38 +192,38 @@  discard block
 block discarded – undo
192 192
 			{
193 193
 				$old_event['category'] = explode(',', $old_event['category']);
194 194
 			}
195
-			foreach($event['category'] as $key => $cat_id)
195
+			foreach ($event['category'] as $key => $cat_id)
196 196
 			{
197 197
 				// check if user is allowed to update event categories
198
-				if ((!$old_event || !in_array($cat_id,$old_event['category'])) &&
199
-					self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false)
198
+				if ((!$old_event || !in_array($cat_id, $old_event['category'])) &&
199
+					self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false)
200 200
 				{
201 201
 					unset($event['category'][$key]);
202 202
 					// report removed category to user
203 203
 					$removed_cats[$cat_id] = $this->categories->id2name($cat_id);
204
-					continue;	// no further check, as cat was removed
204
+					continue; // no further check, as cat was removed
205 205
 				}
206 206
 				// for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown
207 207
 				if (!$status_reset_to_unknown &&
208
-					self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false &&
208
+					self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false &&
209 209
 					(!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end']))
210 210
 				{
211
-					foreach((array)$event['participants'] as $uid => $status)
211
+					foreach ((array)$event['participants'] as $uid => $status)
212 212
 					{
213 213
 						$q = $r = null;
214
-						calendar_so::split_status($status,$q,$r);
214
+						calendar_so::split_status($status, $q, $r);
215 215
 						if ($status != 'U')
216 216
 						{
217
-							$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
217
+							$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
218 218
 							// todo: report reset status to user
219 219
 						}
220 220
 					}
221
-					$status_reset_to_unknown = true;	// once is enough
221
+					$status_reset_to_unknown = true; // once is enough
222 222
 				}
223 223
 			}
224 224
 			if ($removed_cats)
225 225
 			{
226
-				$messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats));
226
+				$messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats));
227 227
 			}
228 228
 			if ($status_reset_to_unknown)
229 229
 			{
@@ -259,30 +259,30 @@  discard block
 block discarded – undo
259 259
 		$event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null);
260 260
 		//error_log("new $cal_id=". array2string($event));
261 261
 
262
-		if($old_event['deleted'] && $event['deleted'] == null)
262
+		if ($old_event['deleted'] && $event['deleted'] == null)
263 263
 		{
264 264
 			// Restored, bring back links
265 265
 			Link::restore('calendar', $cal_id);
266 266
 		}
267 267
 		if ($this->log_file)
268 268
 		{
269
-			$this->log2file($event2save,$event,$old_event);
269
+			$this->log2file($event2save, $event, $old_event);
270 270
 		}
271 271
 		// send notifications
272
-		if(!$skip_notification)
272
+		if (!$skip_notification)
273 273
 		{
274 274
 			if ($new_event)
275 275
 			{
276
-				$this->send_update(MSG_ADDED,$event['participants'],'',$event);
276
+				$this->send_update(MSG_ADDED, $event['participants'], '', $event);
277 277
 			}
278 278
 			else // update existing event
279 279
 			{
280
-				$this->check4update($event,$old_event);
280
+				$this->check4update($event, $old_event);
281 281
 			}
282 282
 		}
283 283
 
284 284
 		// notify the link-class about the update, as other apps may be subscribt to it
285
-		Link::notify_update('calendar',$cal_id,$event);
285
+		Link::notify_update('calendar', $cal_id, $event);
286 286
 
287 287
 		return $cal_id;
288 288
 	}
@@ -300,27 +300,27 @@  discard block
 block discarded – undo
300 300
 	 * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked
301 301
 	 * @return array or events
302 302
 	 */
303
-	function conflicts(array $event, &$checked_excluding=null)
303
+	function conflicts(array $event, &$checked_excluding = null)
304 304
 	{
305 305
 		$types_with_quantity = array();
306
-		foreach($this->resources as $type => $data)
306
+		foreach ($this->resources as $type => $data)
307 307
 		{
308 308
 			if ($data['max_quantity']) $types_with_quantity[] = $type;
309 309
 		}
310 310
 		// get all NOT rejected participants and evtl. their quantity
311 311
 		$quantity = $users = array();
312
-		foreach($event['participants'] as $uid => $status)
312
+		foreach ($event['participants'] as $uid => $status)
313 313
 		{
314 314
 			$q = $role = null;
315 315
 			calendar_so::split_status($status, $q, $role);
316
-			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;	// ignore rejected or non-participants
316
+			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue; // ignore rejected or non-participants
317 317
 
318 318
 			if ($uid < 0)	// group, check it's members too
319 319
 			{
320
-				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
320
+				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true)));
321 321
 			}
322 322
 			$users[] = $uid;
323
-			if (in_array($uid[0],$types_with_quantity))
323
+			if (in_array($uid[0], $types_with_quantity))
324 324
 			{
325 325
 				$quantity[$uid] = $q;
326 326
 			}
@@ -343,58 +343,58 @@  discard block
 block discarded – undo
343 343
 		}
344 344
 		$checked = 0;
345 345
 		$start = microtime(true);
346
-		$duration = $event['end']-$event['start'];
347
-		foreach($recurences as $date)
346
+		$duration = $event['end'] - $event['start'];
347
+		foreach ($recurences as $date)
348 348
 		{
349 349
 			$startts = $date->format('ts');
350 350
 
351 351
 			// skip past events or recurrences
352
-			if ($startts+$duration < $this->now_su) continue;
352
+			if ($startts + $duration < $this->now_su) continue;
353 353
 
354 354
 			// abort check if configured limits are exceeded
355 355
 			if ($event['recur_type'] &&
356 356
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
357
-				microtime(true) > $start+$max_check_time ||	// max check time exceeded
357
+				microtime(true) > $start + $max_check_time || // max check time exceeded
358 358
 				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
359 359
 			{
360 360
 				if ($this->debug > 2 || $this->debug == 'conflicts')
361 361
 				{
362 362
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
363
-						$checked, microtime(true)-$start, $date);
363
+						$checked, microtime(true) - $start, $date);
364 364
 				}
365 365
 				$checked_excluding = $date;
366 366
 				break;
367 367
 			}
368
-			$overlapping_events =& $this->search(array(
368
+			$overlapping_events = & $this->search(array(
369 369
 				'start' => $startts,
370
-				'end'   => $startts+$duration,
370
+				'end'   => $startts + $duration,
371 371
 				'users' => $users,
372
-				'ignore_acl' => true,	// otherwise we get only events readable by the user
373
-				'enum_groups' => true,	// otherwise group-events would not block time
372
+				'ignore_acl' => true, // otherwise we get only events readable by the user
373
+				'enum_groups' => true, // otherwise group-events would not block time
374 374
 				'query' => array(
375 375
 					'cal_non_blocking' => 0,
376 376
 				),
377
-				'no_integration' => true,	// do NOT use integration of other apps
377
+				'no_integration' => true, // do NOT use integration of other apps
378 378
 			));
379 379
 			if ($this->debug > 2 || $this->debug == 'conflicts')
380 380
 			{
381
-				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration);
381
+				$this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration);
382 382
 			}
383
-			foreach((array) $overlapping_events as $k => $overlap)
383
+			foreach ((array)$overlapping_events as $k => $overlap)
384 384
 			{
385
-				if ($overlap['id'] == $event['id'] ||	// that's the event itself
386
-					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
385
+				if ($overlap['id'] == $event['id'] || // that's the event itself
386
+					$overlap['id'] == $event['reference'] || // event is an exception of overlap
387 387
 					$overlap['non_blocking'])			// that's a non_blocking event
388 388
 				{
389 389
 					continue;
390 390
 				}
391 391
 				if ($this->debug > 3 || $this->debug == 'conflicts')
392 392
 				{
393
-					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
393
+					$this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap);
394 394
 				}
395 395
 				// check if the overlap is with a rejected participant or within the allowed quantity
396
-				$common_parts = array_intersect($users,array_keys($overlap['participants']));
397
-				foreach($common_parts as $n => $uid)
396
+				$common_parts = array_intersect($users, array_keys($overlap['participants']));
397
+				foreach ($common_parts as $n => $uid)
398 398
 				{
399 399
 					$status = $overlap['participants'][$uid];
400 400
 					calendar_so::split_status($status, $q, $role);
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 						unset($common_parts[$n]);
404 404
 						continue;
405 405
 					}
406
-					if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity))
406
+					if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity))
407 407
 					{
408
-						continue;	// no quantity check: quantity allways 1 ==> conflict
408
+						continue; // no quantity check: quantity allways 1 ==> conflict
409 409
 					}
410 410
 					if (!isset($max_quantity[$uid]))
411 411
 					{
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 					$quantity[$uid] += $q;
416 416
 					if ($quantity[$uid] <= $max_quantity[$uid])
417 417
 					{
418
-						$possible_quantity_conflicts[$uid][] =& $overlapping_events[$k];	// an other event can give the conflict
418
+						$possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict
419 419
 						unset($common_parts[$n]);
420 420
 						continue;
421 421
 					}
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 				{
426 426
 					if ($this->debug > 3 || $this->debug == 'conflicts')
427 427
 					{
428
-						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts);
428
+						$this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts);
429 429
 					}
430
-					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k];
430
+					$conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k];
431 431
 				}
432 432
 			}
433 433
 		}
434 434
 		//error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s');
435 435
 		// check if we are withing the allowed quantity and if not add all events using that resource
436 436
 		// seems this function is doing very strange things, it gives empty conflicts
437
-		foreach($max_quantity as $uid => $max)
437
+		foreach ($max_quantity as $uid => $max)
438 438
 		{
439 439
 			if ($quantity[$uid] > $max)
440 440
 			{
441
-				foreach((array)$possible_quantity_conflicts[$uid] as $conflict)
441
+				foreach ((array)$possible_quantity_conflicts[$uid] as $conflict)
442 442
 				{
443
-					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k];
443
+					$conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k];
444 444
 				}
445 445
 			}
446 446
 		}
@@ -448,10 +448,10 @@  discard block
 block discarded – undo
448 448
 
449 449
 		if (count($conflicts))
450 450
 		{
451
-			foreach($conflicts as $key => $conflict)
451
+			foreach ($conflicts as $key => $conflict)
452 452
 			{
453
-					$conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']);
454
-				if (!$this->check_perms(Acl::READ,$conflict))
453
+					$conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']);
454
+				if (!$this->check_perms(Acl::READ, $conflict))
455 455
 				{
456 456
 					$conflicts[$key] = array(
457 457
 						'id'    => $conflict['id'],
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 			}
465 465
 			if ($this->debug > 2 || $this->debug == 'conflicts')
466 466
 			{
467
-				$this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts);
467
+				$this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts);
468 468
 			}
469 469
 		}
470 470
 		return $conflicts;
@@ -476,22 +476,22 @@  discard block
 block discarded – undo
476 476
 	 * @param array $old_event =null old event with already invited participants
477 477
 	 * @return array removed participants because of missing invite grants
478 478
 	 */
479
-	public function remove_no_acl_invite(array &$event,array $old_event=null)
479
+	public function remove_no_acl_invite(array &$event, array $old_event = null)
480 480
 	{
481 481
 		if (!$this->require_acl_invite)
482 482
 		{
483
-			return array();	// nothing to check, everyone can invite everyone else
483
+			return array(); // nothing to check, everyone can invite everyone else
484 484
 		}
485 485
 		if ($event['id'] && is_null($old_event))
486 486
 		{
487 487
 			$old_event = $this->read($event['id']);
488 488
 		}
489 489
 		$removed = array();
490
-		foreach(array_keys((array)$event['participants']) as $uid)
490
+		foreach (array_keys((array)$event['participants']) as $uid)
491 491
 		{
492 492
 			if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid))
493 493
 			{
494
-				unset($event['participants'][$uid]);	// remove participant
494
+				unset($event['participants'][$uid]); // remove participant
495 495
 				$removed[] = $uid;
496 496
 			}
497 497
 		}
@@ -507,19 +507,19 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	public function check_acl_invite($uid)
509 509
 	{
510
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
510
+		if (!is_numeric($uid)) return true; // nothing implemented for resources so far
511 511
 
512 512
 		if (!$this->require_acl_invite)
513 513
 		{
514
-			$ret = true;	// no grant required
514
+			$ret = true; // no grant required
515 515
 		}
516 516
 		elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g')
517 517
 		{
518
-			$ret = true;	// grant only required for groups
518
+			$ret = true; // grant only required for groups
519 519
 		}
520 520
 		else
521 521
 		{
522
-			$ret = $this->check_perms(self::ACL_INVITE,0,$uid);
522
+			$ret = $this->check_perms(self::ACL_INVITE, 0, $uid);
523 523
 		}
524 524
 		//error_log(__METHOD__."($uid) = ".array2string($ret));
525 525
 		//echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n";
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 	 * @param array $old_event the event before the update
534 534
 	 * @todo check if there is a real change, not assume every save is a change
535 535
 	 */
536
-	function check4update($new_event,$old_event)
536
+	function check4update($new_event, $old_event)
537 537
 	{
538 538
 		//error_log(__METHOD__."($new_event[title])");
539 539
 		$modified = $added = $deleted = array();
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
 		//echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n";
542 542
 
543 543
 		// Find modified and deleted participants ...
544
-		foreach($old_event['participants'] as $old_userid => $old_status)
544
+		foreach ($old_event['participants'] as $old_userid => $old_status)
545 545
 		{
546
-			if(isset($new_event['participants'][$old_userid]))
546
+			if (isset($new_event['participants'][$old_userid]))
547 547
 			{
548 548
 				$modified[$old_userid] = $new_event['participants'][$old_userid];
549 549
 			}
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
 			}
554 554
 		}
555 555
 		// Find new participants ...
556
-		foreach(array_keys((array)$new_event['participants']) as $new_userid)
556
+		foreach (array_keys((array)$new_event['participants']) as $new_userid)
557 557
 		{
558
-			if(!isset($old_event['participants'][$new_userid]))
558
+			if (!isset($old_event['participants'][$new_userid]))
559 559
 			{
560 560
 				$added[$new_userid] = 'U';
561 561
 			}
562 562
 		}
563 563
 		//echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n";
564
-		if(count($added) || count($modified) || count($deleted))
564
+		if (count($added) || count($modified) || count($deleted))
565 565
 		{
566
-			if(count($added))
566
+			if (count($added))
567 567
 			{
568
-				$this->send_update(MSG_ADDED,$added,$old_event,$new_event);
568
+				$this->send_update(MSG_ADDED, $added, $old_event, $new_event);
569 569
 			}
570
-			if(count($modified))
570
+			if (count($modified))
571 571
 			{
572
-				$this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event);
572
+				$this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event);
573 573
 			}
574
-			if(count($deleted))
574
+			if (count($deleted))
575 575
 			{
576
-				$this->send_update(MSG_DISINVITE,$deleted,$new_event);
576
+				$this->send_update(MSG_DISINVITE, $deleted, $new_event);
577 577
 			}
578 578
 		}
579 579
 	}
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
 	 * @param string $status of current user
591 591
 	 * @return boolean true = update requested, false otherwise
592 592
 	 */
593
-	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null)
593
+	public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null)
594 594
 	{
595 595
 		if ($msg_type == MSG_ALARM)
596 596
 		{
597
-			return True;	// always True for now
597
+			return True; // always True for now
598 598
 		}
599 599
 		$want_update = 0;
600 600
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		//
603 603
 		$msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED;
604 604
 
605
-		switch($ru = $part_prefs['calendar']['receive_updates'])
605
+		switch ($ru = $part_prefs['calendar']['receive_updates'])
606 606
 		{
607 607
 			case 'responses':
608 608
 				++$want_update;
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
 			default:
617 617
 				if (is_array($new_event) && is_array($old_event))
618 618
 				{
619
-					$diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])),
620
-						abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end'])));
619
+					$diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])),
620
+						abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end'])));
621 621
 					$check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0;
622 622
 					if ($msg_type == MSG_MODIFIED && $diff > $check)
623 623
 					{
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 				if (!is_numeric($userid) && $role == 'CHAIR' &&
638 638
 					($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED))))
639 639
 				{
640
-					switch($msg_type)
640
+					switch ($msg_type)
641 641
 					{
642 642
 						case MSG_DELETED:	// treat deleting event as rejection to organizer
643 643
 							$msg_type = MSG_REJECTED;
644 644
 							break;
645 645
 						case MSG_ADDED:		// new events use added, but organizer needs status
646
-							switch($status[0])
646
+							switch ($status[0])
647 647
 							{
648 648
 								case 'A': $msg_type = MSG_ACCEPTED; break;
649 649
 								case 'R': $msg_type = MSG_REJECTED; break;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 	 * @param string $role ='REQ-PARTICIPANT'
669 669
 	 * @return boolean true if user requested to be notified, false if not
670 670
 	 */
671
-	static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT')
671
+	static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT')
672 672
 	{
673 673
 		// check if email is from a user
674 674
 		if (is_numeric($user_or_email))
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 				)
693 693
 			);
694 694
 		}
695
-		switch($ical_method)
695
+		switch ($ical_method)
696 696
 		{
697 697
 			default:
698 698
 			case 'REQUEST':
@@ -717,9 +717,9 @@  discard block
 block discarded – undo
717 717
 	 * @param string& $action=null on return verbose name
718 718
 	 * @param string& $msg=null on return notification message
719 719
 	 */
720
-	function msg_type2ical_method($msg_type, &$action=null, &$msg=null)
720
+	function msg_type2ical_method($msg_type, &$action = null, &$msg = null)
721 721
 	{
722
-		switch($msg_type)
722
+		switch ($msg_type)
723 723
 		{
724 724
 			case MSG_DELETED:
725 725
 				$action = 'Canceled';
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 		$msg = $this->cal_prefs['notify'.$pref];
772 772
 		if (empty($msg))
773 773
 		{
774
-			$msg = $this->cal_prefs['notifyAdded'];	// use a default
774
+			$msg = $this->cal_prefs['notifyAdded']; // use a default
775 775
 		}
776 776
 		//error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'");
777 777
 		return $method;
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 * @param int $user =0 User who started the notify, default current user
788 788
 	 * @return bool true/false
789 789
 	 */
790
-	function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0)
790
+	function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0)
791 791
 	{
792 792
 		//error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event));
793 793
 		if (!is_array($to_notify))
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 		$owner = $old_event ? $old_event['owner'] : $new_event['owner'];
800 800
 		if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM)
801 801
 		{
802
-			$to_notify[$owner] = 'OCHAIR';	// always include the event-owner
802
+			$to_notify[$owner] = 'OCHAIR'; // always include the event-owner
803 803
 		}
804 804
 
805 805
 		// ignore events in the past (give a tolerance of 10 seconds for the script)
806
-		if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
806
+		if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10))
807 807
 		{
808 808
 			return False;
809 809
 		}
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 			$restore_tz = $tz;
814 814
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
815 815
 		}
816
-		$temp_user = $GLOBALS['egw_info']['user'];	// save user-date of the enviroment to restore it after
816
+		$temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after
817 817
 
818 818
 		if (!$user)
819 819
 		{
@@ -829,16 +829,16 @@  discard block
 block discarded – undo
829 829
 		$event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event;
830 830
 
831 831
 		// add all group-members to the notification, unless they are already participants
832
-		foreach($to_notify as $userid => $statusid)
832
+		foreach ($to_notify as $userid => $statusid)
833 833
 		{
834 834
 			if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' &&
835 835
 				($members = $GLOBALS['egw']->accounts->members($userid, true)))
836 836
 			{
837
-				foreach($members as $member)
837
+				foreach ($members as $member)
838 838
 				{
839 839
 					if (!isset($to_notify[$member]))
840 840
 					{
841
-						$to_notify[$member] = 'G';	// Group-invitation
841
+						$to_notify[$member] = 'G'; // Group-invitation
842 842
 					}
843 843
 				}
844 844
 			}
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
851 851
 		//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() : ''));
852 852
 		$owner_prefs = $ics = null;
853
-		foreach($to_notify as $userid => $statusid)
853
+		foreach ($to_notify as $userid => $statusid)
854 854
 		{
855 855
 			$res_info = $quantity = $role = null;
856 856
 			calendar_so::split_status($statusid, $quantity, $role);
@@ -873,14 +873,14 @@  discard block
 block discarded – undo
873 873
 
874 874
 				if (!isset($userid))
875 875
 				{
876
-					if (empty($res_info['email'])) continue;	// no way to notify
876
+					if (empty($res_info['email'])) continue; // no way to notify
877 877
 					// check if event-owner wants non-EGroupware users notified
878 878
 					if (is_null($owner_prefs))
879 879
 					{
880 880
 						$preferences = new Api\Preferences($owner);
881 881
 						$owner_prefs = $preferences->read_repository();
882 882
 					}
883
-					if ($role != 'CHAIR' &&		// always notify externals CHAIRs
883
+					if ($role != 'CHAIR' && // always notify externals CHAIRs
884 884
 						(empty($owner_prefs['calendar']['notify_externals']) ||
885 885
 						$owner_prefs['calendar']['notify_externals'] == 'no'))
886 886
 					{
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
 
893 893
 			if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g')
894 894
 			{
895
-				continue;	// dont notify rejected participants or groups
895
+				continue; // dont notify rejected participants or groups
896 896
 			}
897 897
 
898
-			if($userid != $GLOBALS['egw_info']['user']['account_id'] ||
898
+			if ($userid != $GLOBALS['egw_info']['user']['account_id'] ||
899 899
 				($userid == $GLOBALS['egw_info']['user']['account_id'] &&
900
-					$user_prefs['calendar']['receive_own_updates']==1) ||
900
+					$user_prefs['calendar']['receive_own_updates'] == 1) ||
901 901
 				$msg_type == MSG_ALARM)
902 902
 			{
903 903
 				$tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop)
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 					$preferences = new Api\Preferences($userid);
907 907
 					$GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository();
908 908
 					$fullname = Api\Accounts::username($userid);
909
-					$tfn = Api\Accounts::id2name($userid,'account_firstname');
910
-					$tln = Api\Accounts::id2name($userid,'account_lastname');
909
+					$tfn = Api\Accounts::id2name($userid, 'account_firstname');
910
+					$tln = Api\Accounts::id2name($userid, 'account_lastname');
911 911
 				}
912 912
 				else	// external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification)
913 913
 				{
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
 					}
919 919
 					$part_prefs = $owner_prefs;
920 920
 					$part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals'];
921
-					$part_prefs['calendar']['update_format'] = 'ical';	// use ical format
921
+					$part_prefs['calendar']['update_format'] = 'ical'; // use ical format
922 922
 					$fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid;
923 923
 				}
924 924
 				$m_type = $msg_type;
@@ -943,14 +943,14 @@  discard block
 block discarded – undo
943 943
 				$details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event,
944 944
 					$action, $event_arr, $disinvited);
945 945
 				$details['to-fullname'] = $fullname;
946
-				$details['to-firstname'] = isset($tfn)? $tfn: '';
947
-				$details['to-lastname'] = isset($tln)? $tln: '';
946
+				$details['to-firstname'] = isset($tfn) ? $tfn : '';
947
+				$details['to-lastname'] = isset($tln) ? $tln : '';
948 948
 
949 949
 				// 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
950 950
 				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
951 951
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
952 952
 				$timeformat = $part_prefs['common']['timeformat'];
953
-				switch($timeformat)
953
+				switch ($timeformat)
954 954
 				{
955 955
 			  		case '24':
956 956
 						$timeformat = 'H:i';
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 						$timeformat = 'h:i a';
960 960
 						break;
961 961
 				}
962
-				$timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat;
962
+				$timeformat = $part_prefs['common']['dateformat'].', '.$timeformat;
963 963
 
964 964
 				$startdate->setTimezone($timezone);
965 965
 				$details['startdate'] = $startdate->format($timeformat);
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 				$details['enddate'] = $enddate->format($timeformat);
969 969
 
970 970
 				$modified->setTimezone($timezone);
971
-				$details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']);
971
+				$details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']);
972 972
 
973 973
 				if ($old_event != False)
974 974
 				{
@@ -977,15 +977,14 @@  discard block
 block discarded – undo
977 977
 				}
978 978
 				//error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]");
979 979
 
980
-				list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
980
+				list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
981 981
 				// alarm is NOT an iCal method, therefore we have to use extened (no iCal)
982
-				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
982
+				switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
983 983
 				{
984
-					case 'ical':
985
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
984
+					case 'ical' : if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
986 985
 						{
987 986
 							$calendar_ical = new calendar_ical();
988
-							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
987
+							$calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ
989 988
 							// we need to pass $event[id] so iCal class reads event again,
990 989
 							// as event is in user TZ, but iCal class expects server TZ!
991 990
 							$ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']),
@@ -1004,11 +1003,11 @@  discard block
 block discarded – undo
1004 1003
 					case 'extended':
1005 1004
 
1006 1005
 						$details_body = lang('Event Details follow').":\n";
1007
-						foreach($event_arr as $key => $val)
1006
+						foreach ($event_arr as $key => $val)
1008 1007
 						{
1009
-							if(!empty($details[$key]))
1008
+							if (!empty($details[$key]))
1010 1009
 							{
1011
-								switch($key)
1010
+								switch ($key)
1012 1011
 								{
1013 1012
 							 		case 'access':
1014 1013
 									case 'priority':
@@ -1017,7 +1016,7 @@  discard block
 block discarded – undo
1017 1016
 									case 'title':
1018 1017
 										break;
1019 1018
 									default:
1020
-										$details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]);
1019
+										$details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]);
1021 1020
 										break;
1022 1021
 							 	}
1023 1022
 							}
@@ -1025,7 +1024,7 @@  discard block
 block discarded – undo
1025 1024
 						break;
1026 1025
 				}
1027 1026
 				// send via notification_app
1028
-				if($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1027
+				if ($GLOBALS['egw_info']['apps']['notifications']['enabled'])
1029 1028
 				{
1030 1029
 					try {
1031 1030
 						//error_log(__METHOD__."() notifying $userid from $senderid: $subject");
@@ -1049,9 +1048,9 @@  discard block
 block discarded – undo
1049 1048
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1050 1049
 						$notification->set_popuplinks(array($details['link_arr']));
1051 1050
 
1052
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1051
+						if (is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1053 1052
 						$notification->send();
1054
-						foreach(notifications::errors(true) as $error)
1053
+						foreach (notifications::errors(true) as $error)
1055 1054
 						{
1056 1055
 							error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error");
1057 1056
 						}
@@ -1090,14 +1089,14 @@  discard block
 block discarded – undo
1090 1089
 		return true;
1091 1090
 	}
1092 1091
 
1093
-	function get_update_message($event,$added)
1092
+	function get_update_message($event, $added)
1094 1093
 	{
1095 1094
 		$nul = null;
1096
-		$details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul);
1095
+		$details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul);
1097 1096
 
1098 1097
 		$notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified'];
1099 1098
 
1100
-		return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2);
1099
+		return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2);
1101 1100
 	}
1102 1101
 
1103 1102
 	/**
@@ -1111,37 +1110,37 @@  discard block
 block discarded – undo
1111 1110
 		//echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n";
1112 1111
 		$GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner'];
1113 1112
 
1114
-		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']);	// alarm[time] is in server-time, read requires user-time
1115
-		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user)))
1113
+		$event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time
1114
+		if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user)))
1116 1115
 		{
1117
-			return False;	// event not found
1116
+			return False; // event not found
1118 1117
 		}
1119 1118
 		if ($alarm['all'])
1120 1119
 		{
1121 1120
 			$to_notify = $event['participants'];
1122 1121
 		}
1123
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1122
+		elseif ($this->check_perms(Acl::READ, $event))	// checks agains $this->owner set to $alarm[owner]
1124 1123
 		{
1125 1124
 			$to_notify[$alarm['owner']] = 'A';
1126 1125
 		}
1127 1126
 		else
1128 1127
 		{
1129
-			return False;	// no rights
1128
+			return False; // no rights
1130 1129
 		}
1131 1130
 		// need to load calendar translations and set currentapp, so calendar can reload a different lang
1132 1131
 		Api\Translation::add_app('calendar');
1133 1132
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
1134 1133
 
1135
-		$ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']);
1134
+		$ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']);
1136 1135
 
1137 1136
 		// create a new alarm for recuring events for the next event, if one exists
1138
-		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1)))
1137
+		if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1)))
1139 1138
 		{
1140 1139
 			$alarm['time'] = $this->date2ts($event['start']) - $alarm['offset'];
1141 1140
 			unset($alarm['times']);
1142 1141
 			unset($alarm['next']);
1143 1142
 			//error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm));
1144
-			$this->save_alarm($alarm['cal_id'], $alarm, false);	// false = do NOT update timestamp, as nothing changed for iCal clients
1143
+			$this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients
1145 1144
 		}
1146 1145
 		return $ret;
1147 1146
 	}
@@ -1157,14 +1156,14 @@  discard block
 block discarded – undo
1157 1156
 	 * Please note: you should ALLWAYS update timestamps, as they are required for sync!
1158 1157
 	 * @return int|boolean $cal_id > 0 or false on error (eg. permission denied)
1159 1158
 	 */
1160
-	function save($event,$ignore_acl=false,$updateTS=true)
1159
+	function save($event, $ignore_acl = false, $updateTS = true)
1161 1160
 	{
1162 1161
 		//error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)");
1163 1162
 
1164 1163
 		// check if user has the permission to update / create the event
1165
-		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) ||
1166
-			!$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) &&
1167
-			!$this->check_perms(Acl::ADD,0,$event['owner'])))
1164
+		if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) ||
1165
+			!$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) &&
1166
+			!$this->check_perms(Acl::ADD, 0, $event['owner'])))
1168 1167
 		{
1169 1168
 			return false;
1170 1169
 		}
@@ -1185,7 +1184,7 @@  discard block
 block discarded – undo
1185 1184
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'])
1186 1185
 		{
1187 1186
 			$event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1188
-			$event['recur_enddate']->setTime(23,59,59);
1187
+			$event['recur_enddate']->setTime(23, 59, 59);
1189 1188
 			$rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName());
1190 1189
 			$rrule->rewind();
1191 1190
 			$enddate = $rrule->current();
@@ -1244,19 +1243,19 @@  discard block
 block discarded – undo
1244 1243
 
1245 1244
 				$event['recur_enddate'] = $save_event['recur_enddate'] = $time;
1246 1245
 			}
1247
-			$timestamps = array('modified','created');
1246
+			$timestamps = array('modified', 'created');
1248 1247
 			// all-day events are handled in server time
1249 1248
 		//	$event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName();
1250 1249
 		}
1251 1250
 		else
1252 1251
 		{
1253
-			$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
1252
+			$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
1254 1253
 		}
1255 1254
 		// we run all dates through date2ts, to adjust to server-time and the possible date-formats
1256
-		foreach($timestamps as $ts)
1255
+		foreach ($timestamps as $ts)
1257 1256
 		{
1258 1257
 			// we convert here from user-time to timestamps in server-time!
1259
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1258
+			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0;
1260 1259
 		}
1261 1260
 		// convert tzid name to integer tz_id, of set user default
1262 1261
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
 		// same with the recur exceptions
1267 1266
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
1268 1267
 		{
1269
-			foreach($event['recur_exception'] as &$date)
1268
+			foreach ($event['recur_exception'] as &$date)
1270 1269
 			{
1271 1270
 				if ($event['whole_day'])
1272 1271
 				{
@@ -1275,7 +1274,7 @@  discard block
 block discarded – undo
1275 1274
 				}
1276 1275
 				else
1277 1276
 				{
1278
-					$date = $this->date2ts($date,true);
1277
+					$date = $this->date2ts($date, true);
1279 1278
 				}
1280 1279
 			}
1281 1280
 			unset($date);
@@ -1283,7 +1282,7 @@  discard block
 block discarded – undo
1283 1282
 		// same with the alarms
1284 1283
 		if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
1285 1284
 		{
1286
-			foreach($event['alarm'] as $id => &$alarm)
1285
+			foreach ($event['alarm'] as $id => &$alarm)
1287 1286
 			{
1288 1287
 				// remove alarms belonging to not longer existing or rejected participants
1289 1288
 				if ($alarm['owner'] && isset($event['participants']))
@@ -1301,15 +1300,14 @@  discard block
 block discarded – undo
1301 1300
 		// update all existing alarm times, in case alarm got moved and alarms are not include in $event
1302 1301
 		if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
1303 1302
 		{
1304
-			foreach($old_event['alarm'] as $id => &$alarm)
1303
+			foreach ($old_event['alarm'] as $id => &$alarm)
1305 1304
 			{
1306 1305
 				if (!isset($event['alarm'][$id]))
1307 1306
 				{
1308 1307
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1309 1308
 					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1310 1309
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1311
-					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1312
-						$old_event['participants'][$alarm['owner']];
1310
+					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']];
1313 1311
 					if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R')
1314 1312
 					{
1315 1313
 						$this->so->save_alarm($event['id'], $alarm);
@@ -1336,9 +1334,9 @@  discard block
 block discarded – undo
1336 1334
 			$event['created'] = $this->now;
1337 1335
 			$event['creator'] = $this->user;
1338 1336
 		}
1339
-		$set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate']+1 : false;
1337
+		$set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] + 1 : false;
1340 1338
 		$set_recurrences_start = 0;
1341
-		if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1339
+		if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE)
1342 1340
 		{
1343 1341
 			$save_event['id'] = $cal_id;
1344 1342
 			// unset participants to enforce the default stati for all added recurrences
@@ -1349,7 +1347,7 @@  discard block
 block discarded – undo
1349 1347
 		// create links for new participants from addressbook, if configured
1350 1348
 		if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants'])
1351 1349
 		{
1352
-			foreach($event['participants'] as $uid => $status)
1350
+			foreach ($event['participants'] as $uid => $status)
1353 1351
 			{
1354 1352
 				$user_type = $user_id = null;
1355 1353
 				calendar_so::split_user($uid, $user_type, $user_id);
@@ -1362,7 +1360,7 @@  discard block
 block discarded – undo
1362 1360
 
1363 1361
 		// Update history
1364 1362
 		$tracking = new calendar_tracking($this);
1365
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1363
+		if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id;
1366 1364
 		$tracking->track($event, $old_event);
1367 1365
 
1368 1366
 		return $cal_id;
@@ -1377,16 +1375,16 @@  discard block
 block discarded – undo
1377 1375
 	 * @param array|int $event event array or id of the event
1378 1376
 	 * @return boolean
1379 1377
 	 */
1380
-	function check_status_perms($uid,$event)
1378
+	function check_status_perms($uid, $event)
1381 1379
 	{
1382 1380
 		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1383 1381
 		{
1384 1382
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1385 1383
 
1386
-			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1384
+			return $this->check_perms(Acl::EDIT, 0, $event['owner']);
1387 1385
 		}
1388 1386
 		// check if we have a category Acl for the event or not (null)
1389
-		$access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event);
1387
+		$access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event);
1390 1388
 		if (!is_null($access))
1391 1389
 		{
1392 1390
 			return $access;
@@ -1396,17 +1394,17 @@  discard block
 block discarded – undo
1396 1394
 		{
1397 1395
 			$resource = $this->resource_info($uid);
1398 1396
 
1399
-			return Acl::EDIT & $resource['rights'];
1397
+			return Acl::EDIT&$resource['rights'];
1400 1398
 		}
1401 1399
 		if (!is_array($event) && !($event = $this->read($event))) return false;
1402 1400
 
1403 1401
 		// regular user and groups (need to check memberships too)
1404 1402
 		if (!isset($event['participants'][$uid]))
1405 1403
 		{
1406
-			$memberships = $GLOBALS['egw']->accounts->memberships($uid,true);
1404
+			$memberships = $GLOBALS['egw']->accounts->memberships($uid, true);
1407 1405
 		}
1408 1406
 		$memberships[] = $uid;
1409
-		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid);
1407
+		return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid);
1410 1408
 	}
1411 1409
 
1412 1410
 	/**
@@ -1420,16 +1418,16 @@  discard block
 block discarded – undo
1420 1418
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1421 1419
 	 * 	null = cat has no acl
1422 1420
 	 */
1423
-	function check_cat_acl($right,$event)
1421
+	function check_cat_acl($right, $event)
1424 1422
 	{
1425 1423
 		if (!is_array($event)) $event = $this->read($event);
1426 1424
 
1427 1425
 		$ret = null;
1428 1426
 		if ($event['category'])
1429 1427
 		{
1430
-			foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id)
1428
+			foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id)
1431 1429
 			{
1432
-				$access = self::has_cat_right($right,$cat_id,$this->user);
1430
+				$access = self::has_cat_right($right, $cat_id, $this->user);
1433 1431
 				if ($access === true)
1434 1432
 				{
1435 1433
 					$ret = true;
@@ -1437,7 +1435,7 @@  discard block
 block discarded – undo
1437 1435
 				}
1438 1436
 				if ($access === false)
1439 1437
 				{
1440
-					$ret = false;	// cat denies access --> check further cats
1438
+					$ret = false; // cat denies access --> check further cats
1441 1439
 				}
1442 1440
 			}
1443 1441
 		}
@@ -1458,12 +1456,12 @@  discard block
 block discarded – undo
1458 1456
 	 * @param int $cat_id =null null to return array with all cats
1459 1457
 	 * @return array with account_id => right pairs
1460 1458
 	 */
1461
-	public static function get_cat_rights($cat_id=null)
1459
+	public static function get_cat_rights($cat_id = null)
1462 1460
 	{
1463 1461
 		if (!isset(self::$cat_rights_cache))
1464 1462
 		{
1465
-			self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights',
1466
-				array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar'));
1463
+			self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights',
1464
+				array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar'));
1467 1465
 		}
1468 1466
 		//echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n";
1469 1467
 		return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache;
@@ -1476,7 +1474,7 @@  discard block
 block discarded – undo
1476 1474
 	 * @param int $user
1477 1475
 	 * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together
1478 1476
 	 */
1479
-	public static function set_cat_rights($cat_id,$user,$rights)
1477
+	public static function set_cat_rights($cat_id, $user, $rights)
1480 1478
 	{
1481 1479
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1482 1480
 		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
@@ -1486,15 +1484,15 @@  discard block
 block discarded – undo
1486 1484
 			if ($rights)
1487 1485
 			{
1488 1486
 				self::$cat_rights_cache['L'.$cat_id][$user] = $rights;
1489
-				$GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights);
1487
+				$GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights);
1490 1488
 			}
1491 1489
 			else
1492 1490
 			{
1493 1491
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1494 1492
 				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1495
-				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1493
+				$GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user);
1496 1494
 			}
1497
-			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
1495
+			Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache);
1498 1496
 		}
1499 1497
 	}
1500 1498
 
@@ -1505,9 +1503,9 @@  discard block
 block discarded – undo
1505 1503
 	 * @return boolean false=access denied because of cat acl, true access granted because of cat acl,
1506 1504
 	 * 	null = cat has no acl
1507 1505
 	 */
1508
-	public static function has_cat_right($right,$cat_id,$user)
1506
+	public static function has_cat_right($right, $cat_id, $user)
1509 1507
 	{
1510
-		static $cache=null;
1508
+		static $cache = null;
1511 1509
 
1512 1510
 		if (!isset($cache[$cat_id]))
1513 1511
 		{
@@ -1515,21 +1513,21 @@  discard block
 block discarded – undo
1515 1513
 			$cat_rights = self::get_cat_rights($cat_id);
1516 1514
 			if (!is_null($cat_rights))
1517 1515
 			{
1518
-				static $memberships=null;
1516
+				static $memberships = null;
1519 1517
 				if (is_null($memberships))
1520 1518
 				{
1521
-					$memberships = $GLOBALS['egw']->accounts->memberships($user,true);
1519
+					$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
1522 1520
 					$memberships[] = $user;
1523 1521
 				}
1524
-				foreach($cat_rights as $uid => $value)
1522
+				foreach ($cat_rights as $uid => $value)
1525 1523
 				{
1526 1524
 					$all |= $value;
1527
-					if (in_array($uid,$memberships)) $own |= $value;
1525
+					if (in_array($uid, $memberships)) $own |= $value;
1528 1526
 				}
1529 1527
 			}
1530
-			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
1528
+			foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask)
1531 1529
 			{
1532
-				$cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask);
1530
+				$cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask);
1533 1531
 			}
1534 1532
 		}
1535 1533
 		//echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n";
@@ -1549,13 +1547,13 @@  discard block
 block discarded – undo
1549 1547
 	 * @param boolean $skip_notification =false true: do not send notification messages
1550 1548
 	 * @return int number of changed recurrences
1551 1549
 	 */
1552
-	function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false)
1550
+	function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false)
1553 1551
 	{
1554 1552
 		unset($updateTS);
1555 1553
 
1556 1554
 		$cal_id = is_array($event) ? $event['id'] : $event;
1557 1555
 		//echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n";
1558
-		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event)))
1556
+		if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event)))
1559 1557
 		{
1560 1558
 			return false;
1561 1559
 		}
@@ -1564,16 +1562,16 @@  discard block
 block discarded – undo
1564 1562
 		if ($this->log)
1565 1563
 		{
1566 1564
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1567
-				"($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile);
1565
+				"($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile);
1568 1566
 		}
1569 1567
 		$old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server');
1570
-		if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0],
1571
-				is_numeric($uid)?$uid:substr($uid,1),$status,
1572
-				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1568
+		if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0],
1569
+				is_numeric($uid) ? $uid : substr($uid, 1), $status,
1570
+				$recur_date ? $this->date2ts($recur_date, true) : 0, $role)))
1573 1571
 		{
1574 1572
 			if ($status == 'R')	// remove alarms belonging to rejected participants
1575 1573
 			{
1576
-				foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1574
+				foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1577 1575
 				{
1578 1576
 					if ((string)$alarm['owner'] === (string)$uid)
1579 1577
 					{
@@ -1592,8 +1590,8 @@  discard block
 block discarded – undo
1592 1590
 			if (isset($status2msg[$status]) && !$skip_notification)
1593 1591
 			{
1594 1592
 				if (!is_array($event)) $event = $this->read($cal_id);
1595
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1596
-				$this->send_update($status2msg[$status],$event['participants'],$event);
1593
+				if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event
1594
+				$this->send_update($status2msg[$status], $event['participants'], $event);
1597 1595
 			}
1598 1596
 
1599 1597
 			// Update history
@@ -1613,14 +1611,14 @@  discard block
 block discarded – undo
1613 1611
 	 * @param int $recur_date =0 date to change, or 0 = all since now
1614 1612
 	 * @param boolean $skip_notification Do not send notifications.  Parameter passed on to set_status().
1615 1613
 	 */
1616
-	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1614
+	function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false)
1617 1615
 	{
1618 1616
 		if (!isset($new_event['participants'])) return;
1619 1617
 
1620 1618
 		// check the old list against the new list
1621 1619
 		foreach ($old_event['participants'] as $userid => $status)
1622 1620
   		{
1623
-            if (!isset($new_event['participants'][$userid])){
1621
+            if (!isset($new_event['participants'][$userid])) {
1624 1622
             	// Attendee will be deleted this way
1625 1623
             	$new_event['participants'][$userid] = 'G';
1626 1624
             }
@@ -1633,7 +1631,7 @@  discard block
 block discarded – undo
1633 1631
 		// write the changes
1634 1632
 		foreach ($new_event['participants'] as $userid => $status)
1635 1633
 		{
1636
-			$this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification);
1634
+			$this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification);
1637 1635
 		}
1638 1636
     }
1639 1637
 
@@ -1648,43 +1646,43 @@  discard block
 block discarded – undo
1648 1646
 	 * @param int &$exceptions_kept=null on return number of kept exceptions
1649 1647
 	 * @return boolean true on success, false on error (usually permission denied)
1650 1648
 	 */
1651
-	function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false,
1652
-		$delete_exceptions=true, &$exceptions_kept=null)
1649
+	function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false,
1650
+		$delete_exceptions = true, &$exceptions_kept = null)
1653 1651
 	{
1654 1652
 		//error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)");
1655
-		if (!($event = $this->read($cal_id,$recur_date)) ||
1656
-			!$ignore_acl && !$this->check_perms(Acl::DELETE,$event))
1653
+		if (!($event = $this->read($cal_id, $recur_date)) ||
1654
+			!$ignore_acl && !$this->check_perms(Acl::DELETE, $event))
1657 1655
 		{
1658 1656
 			return false;
1659 1657
 		}
1660 1658
 
1661 1659
 		// Don't send notification if the event has already been deleted
1662
-		if(!$event['deleted'] && !$skip_notification)
1660
+		if (!$event['deleted'] && !$skip_notification)
1663 1661
 		{
1664
-			$this->send_update(MSG_DELETED,$event['participants'],$event);
1662
+			$this->send_update(MSG_DELETED, $event['participants'], $event);
1665 1663
 		}
1666 1664
 
1667 1665
 		if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE)
1668 1666
 		{
1669 1667
 			$config = Api\Config::read('phpgwapi');
1670
-			if(!$config['calendar_delete_history'] || $event['deleted'])
1668
+			if (!$config['calendar_delete_history'] || $event['deleted'])
1671 1669
 			{
1672 1670
 				$this->so->delete($cal_id);
1673 1671
 
1674 1672
 				// delete all links to the event
1675
-				Link::unlink(0,'calendar',$cal_id);
1673
+				Link::unlink(0, 'calendar', $cal_id);
1676 1674
 			}
1677 1675
 			elseif ($config['calendar_delete_history'])
1678 1676
 			{
1679 1677
 				// mark all links to the event as deleted, but keep them
1680
-				Link::unlink(0,'calendar',$cal_id,'','','',true);
1678
+				Link::unlink(0, 'calendar', $cal_id, '', '', '', true);
1681 1679
 
1682 1680
 				$event['deleted'] = $this->now;
1683 1681
 				$this->save($event, $ignore_acl);
1684 1682
 				// Actually delete alarms
1685 1683
 				if (isset($event['alarm']) && is_array($event['alarm']))
1686 1684
 				{
1687
-					foreach($event['alarm'] as $id => $alarm)
1685
+					foreach ($event['alarm'] as $id => $alarm)
1688 1686
 					{
1689 1687
 						$this->delete_alarm($id);
1690 1688
 					}
@@ -1706,7 +1704,7 @@  discard block
 block discarded – undo
1706 1704
 						if (!($exception = $this->read($id))) continue;
1707 1705
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1708 1706
 						$exception['reference'] = $exception['recurrence'] = 0;
1709
-						$this->update($exception, true, true, false, true, $msg=null, true);
1707
+						$this->update($exception, true, true, false, true, $msg = null, true);
1710 1708
 						++$exceptions_kept;
1711 1709
 					}
1712 1710
 				}
@@ -1718,9 +1716,9 @@  discard block
 block discarded – undo
1718 1716
 			if ($event['alarm'])
1719 1717
 			{
1720 1718
 				$next_recurrance = null;
1721
-				foreach($event['alarm'] as &$alarm)
1719
+				foreach ($event['alarm'] as &$alarm)
1722 1720
 				{
1723
-					if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date))
1721
+					if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date))
1724 1722
 					{
1725 1723
 						//error_log(__METHOD__.__LINE__.'->'.array2string($recur_date));
1726 1724
 						//error_log(__METHOD__.__LINE__.array2string($event));
@@ -1728,12 +1726,12 @@  discard block
 block discarded – undo
1728 1726
 						{
1729 1727
 							$checkdate = $recur_date;
1730 1728
 							//if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset'];
1731
-							if (($e = $this->read($cal_id,$checkdate+1)))
1729
+							if (($e = $this->read($cal_id, $checkdate + 1)))
1732 1730
 							{
1733 1731
 								$next_recurrance = $this->date2ts($e['start']);
1734 1732
 							}
1735 1733
 						}
1736
-						$alarm['time'] = $this->date2ts($next_recurrance, true);	// user to server-time
1734
+						$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
1737 1735
 						$alarm['cal_id'] = $cal_id;
1738 1736
 						unset($alarm['times']);
1739 1737
 						unset($alarm['next']);
@@ -1747,7 +1745,7 @@  discard block
 block discarded – undo
1747 1745
 			$event = $this->read($cal_id);
1748 1746
 			//if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer;
1749 1747
 			$event['recur_exception'][] = $recur_date;
1750
-			$this->save($event);// updates the content-history
1748
+			$this->save($event); // updates the content-history
1751 1749
 		}
1752 1750
 		if ($event['reference'])
1753 1751
 		{
@@ -1765,19 +1763,19 @@  discard block
 block discarded – undo
1765 1763
 	 * @param array $disinvited
1766 1764
 	 * @return array
1767 1765
 	 */
1768
-	function _get_event_details($event,$action,&$event_arr,$disinvited=array())
1766
+	function _get_event_details($event, $action, &$event_arr, $disinvited = array())
1769 1767
 	{
1770 1768
 		$details = array(			// event-details for the notify-msg
1771 1769
 			'id'          => $event['id'],
1772 1770
 			'action'      => lang($action),
1773 1771
 		);
1774 1772
 		$event_arr = $this->event2array($event);
1775
-		foreach($event_arr as $key => $val)
1773
+		foreach ($event_arr as $key => $val)
1776 1774
 		{
1777 1775
 			if ($key == 'recur_type') $key = 'repetition';
1778 1776
 			$details[$key] = $val['data'];
1779 1777
 		}
1780
-		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
1778
+		$details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : '';
1781 1779
 
1782 1780
 		$event_arr['link']['field'] = lang('URL');
1783 1781
 		$eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state
@@ -1798,7 +1796,7 @@  discard block
 block discarded – undo
1798 1796
 		 */
1799 1797
 		$link_arr = array();
1800 1798
 		$link_arr['text'] = $event['title'];
1801
-		$link_arr['view'] = array(	'menuaction' => 'calendar.calendar_uiforms.edit',
1799
+		$link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit',
1802 1800
 									'cal_id' => $event['id'],
1803 1801
 									'date' => $eventStart_arr['full'],
1804 1802
 									);
@@ -1806,11 +1804,11 @@  discard block
 block discarded – undo
1806 1804
 		$details['link_arr'] = $link_arr;
1807 1805
 
1808 1806
 		$dis = array();
1809
-		foreach($disinvited as $uid)
1807
+		foreach ($disinvited as $uid)
1810 1808
 		{
1811 1809
 			$dis[] = $this->participant_name($uid);
1812 1810
 		}
1813
-		$details['disinvited'] = implode(', ',$dis);
1811
+		$details['disinvited'] = implode(', ', $dis);
1814 1812
 		return $details;
1815 1813
 	}
1816 1814
 
@@ -1834,13 +1832,13 @@  discard block
 block discarded – undo
1834 1832
 			'data'	=> $event['description']
1835 1833
 		);
1836 1834
 
1837
-		foreach(explode(',',$event['category']) as $cat_id)
1835
+		foreach (explode(',', $event['category']) as $cat_id)
1838 1836
 		{
1839 1837
 			$cat_string[] = stripslashes(Api\Categories::id2name($cat_id));
1840 1838
 		}
1841 1839
 		$var['category'] = Array(
1842 1840
 			'field'	=> lang('Category'),
1843
-			'data'	=> implode(', ',$cat_string)
1841
+			'data'	=> implode(', ', $cat_string)
1844 1842
 		);
1845 1843
 
1846 1844
 		$var['location'] = Array(
@@ -1886,7 +1884,7 @@  discard block
 block discarded – undo
1886 1884
 
1887 1885
 		if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants']))
1888 1886
 		{
1889
-			$participants = $this->participants($event,true);
1887
+			$participants = $this->participants($event, true);
1890 1888
 		}
1891 1889
 		$var['participants'] = Array(
1892 1890
 			'field'	=> lang('Participants'),
@@ -1909,26 +1907,26 @@  discard block
 block discarded – undo
1909 1907
 	 * @param array $old_event =null event-data in the DB before calling save
1910 1908
 	 * @param string $type ='update'
1911 1909
 	 */
1912
-	function log2file($event2save,$event_saved,$old_event=null,$type='update')
1910
+	function log2file($event2save, $event_saved, $old_event = null, $type = 'update')
1913 1911
 	{
1914
-		if (!($f = fopen($this->log_file,'a')))
1912
+		if (!($f = fopen($this->log_file, 'a')))
1915 1913
 		{
1916 1914
 			echo "<p>error opening '$this->log_file' !!!</p>\n";
1917 1915
 			return false;
1918 1916
 		}
1919
-		fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1920
-		fwrite($f,"Time: time to save / saved time read back / old time before save\n");
1921
-		foreach(array('start','end') as $name)
1917
+		fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n");
1918
+		fwrite($f, "Time: time to save / saved time read back / old time before save\n");
1919
+		foreach (array('start', 'end') as $name)
1922 1920
 		{
1923
-			fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1924
-				$this->format_date($event_saved[$name]) .' / '.
1921
+			fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '.
1922
+				$this->format_date($event_saved[$name]).' / '.
1925 1923
 				(is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n");
1926 1924
 		}
1927
-		foreach(array('event2save','event_saved','old_event') as $name)
1925
+		foreach (array('event2save', 'event_saved', 'old_event') as $name)
1928 1926
 		{
1929
-			fwrite($f,$name.' = '.print_r($$name,true));
1927
+			fwrite($f, $name.' = '.print_r($$name, true));
1930 1928
 		}
1931
-		fwrite($f,"\n");
1929
+		fwrite($f, "\n");
1932 1930
 		fclose($f);
1933 1931
 
1934 1932
 		return true;
@@ -1949,14 +1947,14 @@  discard block
 block discarded – undo
1949 1947
 		if ($old_event !== null && $event['start'] == $old_event['start']) return;
1950 1948
 
1951 1949
 		$time = new Api\DateTime($event['start']);
1952
-		if(!is_array($event['alarm']))
1950
+		if (!is_array($event['alarm']))
1953 1951
 		{
1954 1952
 			$event['alarm'] = $this->so->read_alarms($event['id']);
1955 1953
 		}
1956 1954
 
1957
-		foreach($event['alarm'] as &$alarm)
1955
+		foreach ($event['alarm'] as &$alarm)
1958 1956
 		{
1959
-			if($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date))
1957
+			if ($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date))
1960 1958
 			{
1961 1959
 				calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts'));
1962 1960
 			}
@@ -1976,14 +1974,14 @@  discard block
 block discarded – undo
1976 1974
 	 * @param boolean $update_modified =true call update modified, default true
1977 1975
 	 * @return string id of the alarm, or false on error (eg. no perms)
1978 1976
 	 */
1979
-	function save_alarm($cal_id, $alarm, $update_modified=true)
1977
+	function save_alarm($cal_id, $alarm, $update_modified = true)
1980 1978
 	{
1981
-		if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1979
+		if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
1982 1980
 		{
1983 1981
 			//echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>";
1984
-			return false;	// no rights to add the alarm
1982
+			return false; // no rights to add the alarm
1985 1983
 		}
1986
-		$alarm['time'] = $this->date2ts($alarm['time'],true);	// user to server-time
1984
+		$alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time
1987 1985
 
1988 1986
 		return $this->so->save_alarm($cal_id, $alarm, $update_modified);
1989 1987
 	}
@@ -1996,11 +1994,11 @@  discard block
 block discarded – undo
1996 1994
 	 */
1997 1995
 	function delete_alarm($id)
1998 1996
 	{
1999
-		list(,$cal_id) = explode(':',$id);
1997
+		list(,$cal_id) = explode(':', $id);
2000 1998
 
2001
-		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0))
1999
+		if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0))
2002 2000
 		{
2003
-			return false;	// no rights to delete the alarm
2001
+			return false; // no rights to delete the alarm
2004 2002
 		}
2005 2003
 
2006 2004
 		return $this->so->delete_alarm($id);
@@ -2015,13 +2013,13 @@  discard block
 block discarded – undo
2015 2013
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
2016 2014
 	 * @return array category ids (found, added and preserved categories)
2017 2015
 	 */
2018
-	function find_or_add_categories($catname_list, $old_event=null)
2016
+	function find_or_add_categories($catname_list, $old_event = null)
2019 2017
 	{
2020 2018
 		if (is_array($old_event) || $old_event > 0)
2021 2019
 		{
2022 2020
 			// preserve categories without users read access
2023 2021
 			if (!is_array($old_event)) $old_event = $this->read($old_event);
2024
-			$old_categories = explode(',',$old_event['category']);
2022
+			$old_categories = explode(',', $old_event['category']);
2025 2023
 			$old_cats_preserve = array();
2026 2024
 			if (is_array($old_categories) && count($old_categories) > 0)
2027 2025
 			{
@@ -2075,7 +2073,7 @@  discard block
 block discarded – undo
2075 2073
 	{
2076 2074
 		if (!is_array($cat_id_list))
2077 2075
 		{
2078
-			$cat_id_list = explode(',',$cat_id_list);
2076
+			$cat_id_list = explode(',', $cat_id_list);
2079 2077
 		}
2080 2078
 		$cat_list = array();
2081 2079
 		foreach ($cat_id_list as $cat_id)
@@ -2100,7 +2098,7 @@  discard block
 block discarded – undo
2100 2098
 	 *                              master	-> try to find a releated series master
2101 2099
 	 * @return array calendar_ids of matching entries
2102 2100
 	 */
2103
-	function find_event($event, $filter='exact')
2101
+	function find_event($event, $filter = 'exact')
2104 2102
 	{
2105 2103
 		$matchingEvents = array();
2106 2104
 		$query = array();
@@ -2108,14 +2106,14 @@  discard block
 block discarded – undo
2108 2106
 		if ($this->log)
2109 2107
 		{
2110 2108
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2111
-				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2109
+				"($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile);
2112 2110
 		}
2113 2111
 
2114 2112
 		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2115 2113
 
2116 2114
 		if ($filter == 'master')
2117 2115
 		{
2118
-			$query[] = 'recur_type!='. MCAL_RECUR_NONE;
2116
+			$query[] = 'recur_type!='.MCAL_RECUR_NONE;
2119 2117
 			$query['cal_recurrence'] = 0;
2120 2118
 		}
2121 2119
 		elseif ($filter == 'exact')
@@ -2136,14 +2134,14 @@  discard block
 block discarded – undo
2136 2134
 			if ($this->log)
2137 2135
 			{
2138 2136
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2139
-					'(' . $event['id'] . ")[EventID]\n",3,$this->logfile);
2137
+					'('.$event['id'].")[EventID]\n", 3, $this->logfile);
2140 2138
 			}
2141 2139
 			if (($egwEvent = $this->read($event['id'], 0, false, 'server')))
2142 2140
 			{
2143 2141
 				if ($this->log)
2144 2142
 				{
2145 2143
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2146
-						'()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile);
2144
+						'()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile);
2147 2145
 				}
2148 2146
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE &&
2149 2147
 					(empty($event['uid']) || $event['uid'] == $egwEvent['uid']))
@@ -2162,7 +2160,7 @@  discard block
 block discarded – undo
2162 2160
 						$exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']);
2163 2161
 						if (in_array($event['recurrence'], $exceptions))
2164 2162
 						{
2165
-							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2163
+							$matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence'];
2166 2164
 						}
2167 2165
 					}
2168 2166
 				} elseif ($filter != 'master' && ($filter == 'exact' ||
@@ -2181,19 +2179,19 @@  discard block
 block discarded – undo
2181 2179
 
2182 2180
 		// only query calendars of users, we have READ-grants from
2183 2181
 		$users = array();
2184
-		foreach(array_keys($this->grants) as $user)
2182
+		foreach (array_keys($this->grants) as $user)
2185 2183
 		{
2186 2184
 			$user = trim($user);
2187
-			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2185
+			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user))
2188 2186
 			{
2189
-				if ($user && !in_array($user,$users))	// already added?
2187
+				if ($user && !in_array($user, $users))	// already added?
2190 2188
 				{
2191 2189
 					$users[] = $user;
2192 2190
 				}
2193 2191
 			}
2194 2192
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2195 2193
 			{
2196
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2194
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
2197 2195
 			}
2198 2196
 			// the further code is only for real users
2199 2197
 			if (!is_numeric($user)) continue;
@@ -2204,7 +2202,7 @@  discard block
 block discarded – undo
2204 2202
 				$members = $GLOBALS['egw']->accounts->members($user, true);
2205 2203
 				if (is_array($members))
2206 2204
 				{
2207
-					foreach($members as $member)
2205
+					foreach ($members as $member)
2208 2206
 					{
2209 2207
 						// use only members which gave the user a read-grant
2210 2208
 						if (!in_array($member, $users) &&
@@ -2220,7 +2218,7 @@  discard block
 block discarded – undo
2220 2218
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
2221 2219
 				if (is_array($memberships))
2222 2220
 				{
2223
-					foreach($memberships as $group)
2221
+					foreach ($memberships as $group)
2224 2222
 					{
2225 2223
 						if (!in_array($group, $users))
2226 2224
 						{
@@ -2246,24 +2244,24 @@  discard block
 block discarded – undo
2246 2244
 
2247 2245
 				// check length with some tolerance
2248 2246
 				$length = $event['end'] - $event['start'] - $delta;
2249
-				$query[] = ('(cal_end-cal_start)>' . $length);
2247
+				$query[] = ('(cal_end-cal_start)>'.$length);
2250 2248
 				$length += 2 * $delta;
2251
-				$query[] = ('(cal_end-cal_start)<' . $length);
2252
-				$query[] = ('cal_start>' . ($event['start'] - 86400));
2253
-				$query[] = ('cal_start<' . ($event['start'] + 86400));
2249
+				$query[] = ('(cal_end-cal_start)<'.$length);
2250
+				$query[] = ('cal_start>'.($event['start'] - 86400));
2251
+				$query[] = ('cal_start<'.($event['start'] + 86400));
2254 2252
 			}
2255 2253
 			elseif (isset($event['start']))
2256 2254
 			{
2257 2255
 				if ($filter == 'relax')
2258 2256
 				{
2259
-					$query[] = ('cal_start>' . ($event['start'] - 3600));
2260
-					$query[] = ('cal_start<' . ($event['start'] + 3600));
2257
+					$query[] = ('cal_start>'.($event['start'] - 3600));
2258
+					$query[] = ('cal_start<'.($event['start'] + 3600));
2261 2259
 				}
2262 2260
 				else
2263 2261
 				{
2264 2262
 					// we accept a tiny tolerance
2265
-					$query[] = ('cal_start>' . ($event['start'] - 2));
2266
-					$query[] = ('cal_start<' . ($event['start'] + 2));
2263
+					$query[] = ('cal_start>'.($event['start'] - 2));
2264
+					$query[] = ('cal_start<'.($event['start'] + 2));
2267 2265
 				}
2268 2266
 			}
2269 2267
 			if ($filter == 'relax')
@@ -2286,14 +2284,14 @@  discard block
 block discarded – undo
2286 2284
 			if ($this->log)
2287 2285
 			{
2288 2286
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2289
-					'(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile);
2287
+					'('.$event['uid'].")[EventUID]\n", 3, $this->logfile);
2290 2288
 			}
2291 2289
 		}
2292 2290
 
2293 2291
 		if ($this->log)
2294 2292
 		{
2295 2293
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2296
-				'[QUERY]: ' . array2string($query)."\n",3,$this->logfile);
2294
+				'[QUERY]: '.array2string($query)."\n", 3, $this->logfile);
2297 2295
 		}
2298 2296
 		if (!count($users) || !($foundEvents =
2299 2297
 			$this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query))))
@@ -2301,19 +2299,19 @@  discard block
 block discarded – undo
2301 2299
 			if ($this->log)
2302 2300
 			{
2303 2301
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2304
-				"[NO MATCH]\n",3,$this->logfile);
2302
+				"[NO MATCH]\n", 3, $this->logfile);
2305 2303
 			}
2306 2304
 			return $matchingEvents;
2307 2305
 		}
2308 2306
 
2309 2307
 		$pseudos = array();
2310 2308
 
2311
-		foreach($foundEvents as $egwEvent)
2309
+		foreach ($foundEvents as $egwEvent)
2312 2310
 		{
2313 2311
 			if ($this->log)
2314 2312
 			{
2315 2313
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2316
-					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2314
+					'[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile);
2317 2315
 			}
2318 2316
 
2319 2317
 			if (in_array($egwEvent['id'], $matchingEvents)) continue;
@@ -2387,7 +2385,7 @@  discard block
 block discarded – undo
2387 2385
 						if (in_array($event['recurrence'], $exceptions))
2388 2386
 						{
2389 2387
 							// We found a pseudo exception
2390
-							$matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']);
2388
+							$matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']);
2391 2389
 							break;
2392 2390
 						}
2393 2391
 					}
@@ -2405,7 +2403,7 @@  discard block
 block discarded – undo
2405 2403
 						if ($this->log)
2406 2404
 						{
2407 2405
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2408
-							"() egwEvent length does not match!\n",3,$this->logfile);
2406
+							"() egwEvent length does not match!\n", 3, $this->logfile);
2409 2407
 						}
2410 2408
 						continue;
2411 2409
 					}
@@ -2417,7 +2415,7 @@  discard block
 block discarded – undo
2417 2415
 						if ($this->log)
2418 2416
 						{
2419 2417
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2420
-							"() egwEvent is not a whole-day event!\n",3,$this->logfile);
2418
+							"() egwEvent is not a whole-day event!\n", 3, $this->logfile);
2421 2419
 						}
2422 2420
 						continue;
2423 2421
 					}
@@ -2438,8 +2436,8 @@  discard block
 block discarded – undo
2438 2436
 					if ($this->log)
2439 2437
 					{
2440 2438
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2441
-							"() event[$key] differ: '" . $event[$key] .
2442
-							"' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile);
2439
+							"() event[$key] differ: '".$event[$key].
2440
+							"' <> '".$egwEvent[$key]."'\n", 3, $this->logfile);
2443 2441
 					}
2444 2442
 					continue 2; // next foundEvent
2445 2443
 				}
@@ -2457,7 +2455,7 @@  discard block
 block discarded – undo
2457 2455
 						if ($this->log)
2458 2456
 						{
2459 2457
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2460
-							"() egwEvent category $cat_id is missing!\n",3,$this->logfile);
2458
+							"() egwEvent category $cat_id is missing!\n", 3, $this->logfile);
2461 2459
 						}
2462 2460
 						continue 2;
2463 2461
 					}
@@ -2469,7 +2467,7 @@  discard block
 block discarded – undo
2469 2467
 					{
2470 2468
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2471 2469
 							'() event has additional categories:'
2472
-							. array2string($newCategories)."\n",3,$this->logfile);
2470
+							. array2string($newCategories)."\n", 3, $this->logfile);
2473 2471
 					}
2474 2472
 					continue;
2475 2473
 				}
@@ -2489,7 +2487,7 @@  discard block
 block discarded – undo
2489 2487
 							if ($this->log)
2490 2488
 							{
2491 2489
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2492
-								"() additional event['participants']: $attendee\n",3,$this->logfile);
2490
+								"() additional event['participants']: $attendee\n", 3, $this->logfile);
2493 2491
 							}
2494 2492
 							continue 2;
2495 2493
 						}
@@ -2512,8 +2510,8 @@  discard block
 block discarded – undo
2512 2510
 						if ($this->log)
2513 2511
 						{
2514 2512
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2515
-								'() missing event[participants]: ' .
2516
-								array2string($egwEvent['participants'])."\n",3,$this->logfile);
2513
+								'() missing event[participants]: '.
2514
+								array2string($egwEvent['participants'])."\n", 3, $this->logfile);
2517 2515
 						}
2518 2516
 						continue;
2519 2517
 					}
@@ -2525,7 +2523,7 @@  discard block
 block discarded – undo
2525 2523
 				if ($egwEvent['recur_type'] != MCAL_RECUR_NONE)
2526 2524
 				{
2527 2525
 					// We found a pseudo Exception
2528
-					$pseudos[] = $egwEvent['id'] . ':' . $event['start'];
2526
+					$pseudos[] = $egwEvent['id'].':'.$event['start'];
2529 2527
 					continue;
2530 2528
 				}
2531 2529
 			}
@@ -2547,7 +2545,7 @@  discard block
 block discarded – undo
2547 2545
 							if ($this->log)
2548 2546
 							{
2549 2547
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2550
-								"() additional event['recur_exception']: $day\n",3,$this->logfile);
2548
+								"() additional event['recur_exception']: $day\n", 3, $this->logfile);
2551 2549
 							}
2552 2550
 							continue 2;
2553 2551
 						}
@@ -2557,8 +2555,8 @@  discard block
 block discarded – undo
2557 2555
 						if ($this->log)
2558 2556
 						{
2559 2557
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2560
-								'() missing event[recur_exception]: ' .
2561
-								array2string($event['recur_exception'])."\n",3,$this->logfile);
2558
+								'() missing event[recur_exception]: '.
2559
+								array2string($event['recur_exception'])."\n", 3, $this->logfile);
2562 2560
 						}
2563 2561
 						continue;
2564 2562
 					}
@@ -2573,8 +2571,8 @@  discard block
 block discarded – undo
2573 2571
 						if ($this->log)
2574 2572
 						{
2575 2573
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2576
-								"() events[$key] differ: " . $event[$key] .
2577
-								' <> ' . $egwEvent[$key]."\n",3,$this->logfile);
2574
+								"() events[$key] differ: ".$event[$key].
2575
+								' <> '.$egwEvent[$key]."\n", 3, $this->logfile);
2578 2576
 						}
2579 2577
 						continue 2;
2580 2578
 					}
@@ -2590,7 +2588,7 @@  discard block
 block discarded – undo
2590 2588
 			if ($this->log)
2591 2589
 			{
2592 2590
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2593
-					"() new exception for series found.\n",3,$this->logfile);
2591
+					"() new exception for series found.\n", 3, $this->logfile);
2594 2592
 			}
2595 2593
 			$matchingEvents = array();
2596 2594
 		}
@@ -2601,7 +2599,7 @@  discard block
 block discarded – undo
2601 2599
 		if ($this->log)
2602 2600
 		{
2603 2601
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2604
-				'[MATCHES]:' . array2string($matches)."\n",3,$this->logfile);
2602
+				'[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile);
2605 2603
 		}
2606 2604
 		return $matches;
2607 2605
 	}
@@ -2674,7 +2672,7 @@  discard block
 block discarded – undo
2674 2672
 				if ($this->log)
2675 2673
 				{
2676 2674
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2677
-					"()[MASTER]: $eventID\n",3,$this->logfile);
2675
+					"()[MASTER]: $eventID\n", 3, $this->logfile);
2678 2676
 				}
2679 2677
 				$type = 'SERIES-EXCEPTION';
2680 2678
 				if (($master_event = $this->read($eventID, 0, false, 'server')))
@@ -2695,7 +2693,7 @@  discard block
 block discarded – undo
2695 2693
 					}
2696 2694
 					elseif (in_array($event['start'], $master_event['recur_exception']))
2697 2695
 					{
2698
-						$type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2696
+						$type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception?
2699 2697
 						$recurrence_event = $master_event;
2700 2698
 						$recurrence_event['start'] = $event['start'];
2701 2699
 						$recurrence_event['end'] -= $master_event['start'] - $event['start'];
@@ -2712,8 +2710,8 @@  discard block
 block discarded – undo
2712 2710
 							if ($this->log)
2713 2711
 							{
2714 2712
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2715
-									'() try occurrence ' . $egw_rrule->current()
2716
-									. " ($occurrence)\n",3,$this->logfile);
2713
+									'() try occurrence '.$egw_rrule->current()
2714
+									. " ($occurrence)\n", 3, $this->logfile);
2717 2715
 							}
2718 2716
 							if ($event['start'] == $occurrence)
2719 2717
 							{
@@ -2746,8 +2744,8 @@  discard block
 block discarded – undo
2746 2744
 			// default if we cannot find a proof for a fundamental change
2747 2745
 			// the recurrence_event is the master event with start and end adjusted to the recurrence
2748 2746
 			// check for changed data
2749
-			foreach (array('start','end','uid','title','location','description',
2750
-				'priority','public','special','non_blocking') as $key)
2747
+			foreach (array('start', 'end', 'uid', 'title', 'location', 'description',
2748
+				'priority', 'public', 'special', 'non_blocking') as $key)
2751 2749
 			{
2752 2750
 				if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key])
2753 2751
 				{
@@ -2805,10 +2803,10 @@  discard block
 block discarded – undo
2805 2803
      * @param &$event	the event we are working on
2806 2804
      *
2807 2805
      */
2808
-    function server2usertime (&$event)
2806
+    function server2usertime(&$event)
2809 2807
     {
2810 2808
 		// we run all dates through date2usertime, to adjust to user-time
2811
-		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2809
+		foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts)
2812 2810
 		{
2813 2811
 			// we convert here from server-time to timestamps in user-time!
2814 2812
 			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
@@ -2816,7 +2814,7 @@  discard block
 block discarded – undo
2816 2814
 		// same with the recur exceptions
2817 2815
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
2818 2816
 		{
2819
-			foreach($event['recur_exception'] as $n => $date)
2817
+			foreach ($event['recur_exception'] as $n => $date)
2820 2818
 			{
2821 2819
 				$event['recur_exception'][$n] = $this->date2usertime($date);
2822 2820
 			}
@@ -2824,7 +2822,7 @@  discard block
 block discarded – undo
2824 2822
 		// same with the alarms
2825 2823
 		if (isset($event['alarm']) && is_array($event['alarm']))
2826 2824
 		{
2827
-			foreach($event['alarm'] as $id => $alarm)
2825
+			foreach ($event['alarm'] as $id => $alarm)
2828 2826
 			{
2829 2827
 				$event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']);
2830 2828
 			}
@@ -2841,7 +2839,7 @@  discard block
 block discarded – undo
2841 2839
 	{
2842 2840
 		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
2843 2841
 		{
2844
-			$this->so->purge(time() - 365*24*3600*(float)$age);
2842
+			$this->so->purge(time() - 365 * 24 * 3600 * (float)$age);
2845 2843
 		}
2846 2844
 	}
2847 2845
 }
Please login to merge, or discard this patch.
Braces   +216 added lines, -55 removed lines patch added patch discarded remove patch
@@ -85,11 +85,17 @@  discard block
 block discarded – undo
85 85
 	 */
86 86
 	function __construct()
87 87
 	{
88
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True);
88
+		if ($this->debug > 0)
89
+		{
90
+			$this->debug_message('calendar_boupdate::__construct() started',True);
91
+		}
89 92
 
90 93
 		parent::__construct();	// calling the parent constructor
91 94
 
92
-		if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True);
95
+		if ($this->debug > 0)
96
+		{
97
+			$this->debug_message('calendar_boupdate::__construct() finished',True);
98
+		}
93 99
 	}
94 100
 
95 101
 	/**
@@ -120,7 +126,10 @@  discard block
 block discarded – undo
120 126
 	{
121 127
 		unset($updateTS);	// ignored, as updating timestamps is required for sync!
122 128
 		//error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)");
123
-		if (!is_array($messages)) $messages = $messages ? (array)$messages : array();
129
+		if (!is_array($messages))
130
+		{
131
+			$messages = $messages ? (array)$messages : array();
132
+		}
124 133
 
125 134
 		if ($this->debug > 1 || $this->debug == 'update')
126 135
 		{
@@ -140,10 +149,13 @@  discard block
 block discarded – undo
140 149
 
141 150
 		$status_reset_to_unknown = false;
142 151
 
143
-		if (($new_event = !$event['id']))	// some defaults for new entries
152
+		if (($new_event = !$event['id']))
153
+		{
154
+			// some defaults for new entries
144 155
 		{
145 156
 			// if no owner given, set user to owner
146 157
 			if (!$event['owner']) $event['owner'] = $this->user;
158
+		}
147 159
 			// set owner as participant if none is given
148 160
 			if (!is_array($event['participants']) || !count($event['participants']))
149 161
 			{
@@ -183,7 +195,10 @@  discard block
 block discarded – undo
183 195
 		// check category based ACL
184 196
 		if ($event['category'])
185 197
 		{
186
-			if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']);
198
+			if (!is_array($event['category']))
199
+			{
200
+				$event['category'] = explode(',',$event['category']);
201
+			}
187 202
 			if (!$old_event || !isset($old_event['category']))
188 203
 			{
189 204
 				$old_event['category'] = array();
@@ -235,13 +250,16 @@  discard block
 block discarded – undo
235 250
 		if (!$ignore_conflicts && !$event['non_blocking'] && isset($event['start']) && isset($event['end']) &&
236 251
 			(($conflicts = $this->conflicts($event, $checked_excluding)) || $checked_excluding))
237 252
 		{
238
-			if ($checked_excluding)	// warn user if not all recurrences have been checked
253
+			if ($checked_excluding)
254
+			{
255
+				// warn user if not all recurrences have been checked
239 256
 			{
240 257
 				$conflicts['warning'] = array(
241 258
 					'start' => $checked_excluding,
242 259
 					'title' => lang('Only recurrences until %1 (excluding) have been checked!', $checked_excluding->format(true)),
243 260
 				);
244 261
 			}
262
+			}
245 263
 			return $conflicts;
246 264
 		}
247 265
 
@@ -305,7 +323,10 @@  discard block
 block discarded – undo
305 323
 		$types_with_quantity = array();
306 324
 		foreach($this->resources as $type => $data)
307 325
 		{
308
-			if ($data['max_quantity']) $types_with_quantity[] = $type;
326
+			if ($data['max_quantity'])
327
+			{
328
+				$types_with_quantity[] = $type;
329
+			}
309 330
 		}
310 331
 		// get all NOT rejected participants and evtl. their quantity
311 332
 		$quantity = $users = array();
@@ -313,12 +334,19 @@  discard block
 block discarded – undo
313 334
 		{
314 335
 			$q = $role = null;
315 336
 			calendar_so::split_status($status, $q, $role);
316
-			if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;	// ignore rejected or non-participants
337
+			if ($status == 'R' || $role == 'NON-PARTICIPANT')
338
+			{
339
+				continue;
340
+			}
341
+			// ignore rejected or non-participants
317 342
 
318
-			if ($uid < 0)	// group, check it's members too
343
+			if ($uid < 0)
344
+			{
345
+				// group, check it's members too
319 346
 			{
320 347
 				$users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true)));
321 348
 			}
349
+			}
322 350
 			$users[] = $uid;
323 351
 			if (in_array($uid[0],$types_with_quantity))
324 352
 			{
@@ -349,18 +377,24 @@  discard block
 block discarded – undo
349 377
 			$startts = $date->format('ts');
350 378
 
351 379
 			// skip past events or recurrences
352
-			if ($startts+$duration < $this->now_su) continue;
380
+			if ($startts+$duration < $this->now_su)
381
+			{
382
+				continue;
383
+			}
353 384
 
354 385
 			// abort check if configured limits are exceeded
355 386
 			if ($event['recur_type'] &&
356 387
 				(++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded
357 388
 				microtime(true) > $start+$max_check_time ||	// max check time exceeded
358
-				$startts > $this->config['horizont']))	// we are behind horizon for which recurrences are rendered
389
+				$startts > $this->config['horizont']))
390
+			{
391
+				// we are behind horizon for which recurrences are rendered
359 392
 			{
360 393
 				if ($this->debug > 2 || $this->debug == 'conflicts')
361 394
 				{
362 395
 					$this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3',
363 396
 						$checked, microtime(true)-$start, $date);
397
+			}
364 398
 				}
365 399
 				$checked_excluding = $date;
366 400
 				break;
@@ -384,10 +418,13 @@  discard block
 block discarded – undo
384 418
 			{
385 419
 				if ($overlap['id'] == $event['id'] ||	// that's the event itself
386 420
 					$overlap['id'] == $event['reference'] ||	// event is an exception of overlap
387
-					$overlap['non_blocking'])			// that's a non_blocking event
421
+					$overlap['non_blocking'])
422
+				{
423
+					// that's a non_blocking event
388 424
 				{
389 425
 					continue;
390 426
 				}
427
+				}
391 428
 				if ($this->debug > 3 || $this->debug == 'conflicts')
392 429
 				{
393 430
 					$this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap);
@@ -507,7 +544,11 @@  discard block
 block discarded – undo
507 544
 	 */
508 545
 	public function check_acl_invite($uid)
509 546
 	{
510
-		if (!is_numeric($uid)) return true;	// nothing implemented for resources so far
547
+		if (!is_numeric($uid))
548
+		{
549
+			return true;
550
+		}
551
+		// nothing implemented for resources so far
511 552
 
512 553
 		if (!$this->require_acl_invite)
513 554
 		{
@@ -847,14 +888,20 @@  discard block
 block discarded – undo
847 888
 		$startdate = new Api\DateTime($event['start']);
848 889
 		$enddate = new Api\DateTime($event['end']);
849 890
 		$modified = new Api\DateTime($event['modified']);
850
-		if ($old_event) $olddate = new Api\DateTime($old_event['start']);
891
+		if ($old_event)
892
+		{
893
+			$olddate = new Api\DateTime($old_event['start']);
894
+		}
851 895
 		//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() : ''));
852 896
 		$owner_prefs = $ics = null;
853 897
 		foreach($to_notify as $userid => $statusid)
854 898
 		{
855 899
 			$res_info = $quantity = $role = null;
856 900
 			calendar_so::split_status($statusid, $quantity, $role);
857
-			if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
901
+			if ($this->debug > 0)
902
+			{
903
+				error_log(__METHOD__." trying to notify $userid, with $statusid ($role)");
904
+			}
858 905
 
859 906
 			if (!is_numeric($userid))
860 907
 			{
@@ -873,7 +920,11 @@  discard block
 block discarded – undo
873 920
 
874 921
 				if (!isset($userid))
875 922
 				{
876
-					if (empty($res_info['email'])) continue;	// no way to notify
923
+					if (empty($res_info['email']))
924
+					{
925
+						continue;
926
+					}
927
+					// no way to notify
877 928
 					// check if event-owner wants non-EGroupware users notified
878 929
 					if (is_null($owner_prefs))
879 930
 					{
@@ -947,7 +998,10 @@  discard block
 block discarded – undo
947 998
 				$details['to-lastname'] = isset($tln)? $tln: '';
948 999
 
949 1000
 				// 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
950
-				if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1001
+				if (!isset($part_prefs['common']['tz']))
1002
+				{
1003
+					$part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone'];
1004
+				}
951 1005
 				$timezone = new DateTimeZone($part_prefs['common']['tz']);
952 1006
 				$timeformat = $part_prefs['common']['timeformat'];
953 1007
 				switch($timeformat)
@@ -982,9 +1036,12 @@  discard block
 block discarded – undo
982 1036
 				switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format'])
983 1037
 				{
984 1038
 					case 'ical':
985
-						if (is_null($ics) || $m_type != $msg_type)	// need different ical for organizer notification
1039
+						if (is_null($ics) || $m_type != $msg_type)
1040
+						{
1041
+							// need different ical for organizer notification
986 1042
 						{
987 1043
 							$calendar_ical = new calendar_ical();
1044
+						}
988 1045
 							$calendar_ical->setSupportedFields('full');	// full iCal fields+event TZ
989 1046
 							// we need to pass $event[id] so iCal class reads event again,
990 1047
 							// as event is in user TZ, but iCal class expects server TZ!
@@ -998,7 +1055,10 @@  discard block
 block discarded – undo
998 1055
 							'encoding' => '8bit',
999 1056
 							'type' => 'text/calendar; method='.$method,
1000 1057
 						);
1001
-						if ($m_type != $msg_type) unset($ics);
1058
+						if ($m_type != $msg_type)
1059
+						{
1060
+							unset($ics);
1061
+						}
1002 1062
 						$subject = isset($cleared_event) ? $cleared_event['title'] : $event['title'];
1003 1063
 						// fall through
1004 1064
 					case 'extended':
@@ -1049,7 +1109,9 @@  discard block
 block discarded – undo
1049 1109
 						$notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body);
1050 1110
 						$notification->set_popuplinks(array($details['link_arr']));
1051 1111
 
1052
-						if(is_array($attachment)) { $notification->set_attachments(array($attachment)); }
1112
+						if(is_array($attachment))
1113
+						{
1114
+$notification->set_attachments(array($attachment)); }
1053 1115
 						$notification->send();
1054 1116
 						foreach(notifications::errors(true) as $error)
1055 1117
 						{
@@ -1085,7 +1147,10 @@  discard block
 block discarded – undo
1085 1147
 			Api\Translation::init();
1086 1148
 		}
1087 1149
 		// restore timezone, in case we had to reset it to server-timezone
1088
-		if ($restore_tz) date_default_timezone_set($restore_tz);
1150
+		if ($restore_tz)
1151
+		{
1152
+			date_default_timezone_set($restore_tz);
1153
+		}
1089 1154
 
1090 1155
 		return true;
1091 1156
 	}
@@ -1120,10 +1185,13 @@  discard block
 block discarded – undo
1120 1185
 		{
1121 1186
 			$to_notify = $event['participants'];
1122 1187
 		}
1123
-		elseif ($this->check_perms(Acl::READ,$event))	// checks agains $this->owner set to $alarm[owner]
1188
+		elseif ($this->check_perms(Acl::READ,$event))
1189
+		{
1190
+			// checks agains $this->owner set to $alarm[owner]
1124 1191
 		{
1125 1192
 			$to_notify[$alarm['owner']] = 'A';
1126 1193
 		}
1194
+		}
1127 1195
 		else
1128 1196
 		{
1129 1197
 			return False;	// no rights
@@ -1172,14 +1240,20 @@  discard block
 block discarded – undo
1172 1240
 		if ($event['id'])
1173 1241
 		{
1174 1242
 			// invalidate the read-cache if it contains the event we store now
1175
-			if ($event['id'] == self::$cached_event['id']) self::$cached_event = array();
1243
+			if ($event['id'] == self::$cached_event['id'])
1244
+			{
1245
+				self::$cached_event = array();
1246
+			}
1176 1247
 			$old_event = $this->read($event['id'], $event['recurrence'], false, 'server');
1177 1248
 		}
1178 1249
 		else
1179 1250
 		{
1180 1251
 			$old_event = null;
1181 1252
 		}
1182
-		if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event);
1253
+		if (!isset($event['whole_day']))
1254
+		{
1255
+			$event['whole_day'] = $this->isWholeDay($event);
1256
+		}
1183 1257
 
1184 1258
 		// set recur-enddate/range-end to real end-date of last recurrence
1185 1259
 		if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'])
@@ -1256,7 +1330,10 @@  discard block
 block discarded – undo
1256 1330
 		foreach($timestamps as $ts)
1257 1331
 		{
1258 1332
 			// we convert here from user-time to timestamps in server-time!
1259
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1333
+			if (isset($event[$ts]))
1334
+			{
1335
+				$event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0;
1336
+			}
1260 1337
 		}
1261 1338
 		// convert tzid name to integer tz_id, of set user default
1262 1339
 		if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid'])))
@@ -1306,7 +1383,10 @@  discard block
 block discarded – undo
1306 1383
 				if (!isset($event['alarm'][$id]))
1307 1384
 				{
1308 1385
 					$alarm['time'] = $event['start'] - $alarm['offset'];
1309
-					if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1386
+					if ($alarm['time'] < time())
1387
+					{
1388
+						calendar_so::shift_alarm($event, $alarm);
1389
+					}
1310 1390
 						// remove (not store) alarms belonging to not longer existing or rejected participants
1311 1391
 					$status = isset($event['participants']) ? $event['participants'][$alarm['owner']] :
1312 1392
 						$old_event['participants'][$alarm['owner']];
@@ -1362,7 +1442,10 @@  discard block
 block discarded – undo
1362 1442
 
1363 1443
 		// Update history
1364 1444
 		$tracking = new calendar_tracking($this);
1365
-		if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id;
1445
+		if (empty($event['id']) && !empty($cal_id))
1446
+		{
1447
+			$event['id']=$cal_id;
1448
+		}
1366 1449
 		$tracking->track($event, $old_event);
1367 1450
 
1368 1451
 		return $cal_id;
@@ -1379,9 +1462,12 @@  discard block
 block discarded – undo
1379 1462
 	 */
1380 1463
 	function check_status_perms($uid,$event)
1381 1464
 	{
1382
-		if ($uid[0] == 'c' || $uid[0] == 'e')	// for contact we use the owner of the event
1465
+		if ($uid[0] == 'c' || $uid[0] == 'e')
1466
+		{
1467
+			// for contact we use the owner of the event
1383 1468
 		{
1384 1469
 			if (!is_array($event) && !($event = $this->read($event))) return false;
1470
+		}
1385 1471
 
1386 1472
 			return $this->check_perms(Acl::EDIT,0,$event['owner']);
1387 1473
 		}
@@ -1392,13 +1478,19 @@  discard block
 block discarded – undo
1392 1478
 			return $access;
1393 1479
 		}
1394 1480
 		// no access or denied access because of category acl --> regular check
1395
-		if (!is_numeric($uid))	// this is eg. for resources (r123)
1481
+		if (!is_numeric($uid))
1482
+		{
1483
+			// this is eg. for resources (r123)
1396 1484
 		{
1397 1485
 			$resource = $this->resource_info($uid);
1486
+		}
1398 1487
 
1399 1488
 			return Acl::EDIT & $resource['rights'];
1400 1489
 		}
1401
-		if (!is_array($event) && !($event = $this->read($event))) return false;
1490
+		if (!is_array($event) && !($event = $this->read($event)))
1491
+		{
1492
+			return false;
1493
+		}
1402 1494
 
1403 1495
 		// regular user and groups (need to check memberships too)
1404 1496
 		if (!isset($event['participants'][$uid]))
@@ -1422,7 +1514,10 @@  discard block
 block discarded – undo
1422 1514
 	 */
1423 1515
 	function check_cat_acl($right,$event)
1424 1516
 	{
1425
-		if (!is_array($event)) $event = $this->read($event);
1517
+		if (!is_array($event))
1518
+		{
1519
+			$event = $this->read($event);
1520
+		}
1426 1521
 
1427 1522
 		$ret = null;
1428 1523
 		if ($event['category'])
@@ -1479,7 +1574,10 @@  discard block
 block discarded – undo
1479 1574
 	public static function set_cat_rights($cat_id,$user,$rights)
1480 1575
 	{
1481 1576
 		//echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n";
1482
-		if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id);
1577
+		if (!isset(self::$cat_rights_cache))
1578
+		{
1579
+			self::get_cat_rights($cat_id);
1580
+		}
1483 1581
 
1484 1582
 		if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user])
1485 1583
 		{
@@ -1491,7 +1589,10 @@  discard block
 block discarded – undo
1491 1589
 			else
1492 1590
 			{
1493 1591
 				unset(self::$cat_rights_cache['L'.$cat_id][$user]);
1494
-				if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]);
1592
+				if (!self::$cat_rights_cache['L'.$cat_id])
1593
+				{
1594
+					unset(self::$cat_rights_cache['L'.$cat_id]);
1595
+				}
1495 1596
 				$GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user);
1496 1597
 			}
1497 1598
 			Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache);
@@ -1524,7 +1625,10 @@  discard block
 block discarded – undo
1524 1625
 				foreach($cat_rights as $uid => $value)
1525 1626
 				{
1526 1627
 					$all |= $value;
1527
-					if (in_array($uid,$memberships)) $own |= $value;
1628
+					if (in_array($uid,$memberships))
1629
+					{
1630
+						$own |= $value;
1631
+					}
1528 1632
 				}
1529 1633
 			}
1530 1634
 			foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask)
@@ -1571,13 +1675,16 @@  discard block
 block discarded – undo
1571 1675
 				is_numeric($uid)?$uid:substr($uid,1),$status,
1572 1676
 				$recur_date?$this->date2ts($recur_date,true):0,$role)))
1573 1677
 		{
1574
-			if ($status == 'R')	// remove alarms belonging to rejected participants
1678
+			if ($status == 'R')
1679
+			{
1680
+				// remove alarms belonging to rejected participants
1575 1681
 			{
1576 1682
 				foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm)
1577 1683
 				{
1578 1684
 					if ((string)$alarm['owner'] === (string)$uid)
1579 1685
 					{
1580 1686
 						$this->so->delete_alarm($id);
1687
+			}
1581 1688
 						//error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm));
1582 1689
 					}
1583 1690
 				}
@@ -1591,8 +1698,15 @@  discard block
 block discarded – undo
1591 1698
 			);
1592 1699
 			if (isset($status2msg[$status]) && !$skip_notification)
1593 1700
 			{
1594
-				if (!is_array($event)) $event = $this->read($cal_id);
1595
-				if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event
1701
+				if (!is_array($event))
1702
+				{
1703
+					$event = $this->read($cal_id);
1704
+				}
1705
+				if (isset($recur_date))
1706
+				{
1707
+					$event = $this->read($event['id'],$recur_date);
1708
+				}
1709
+				//re-read the actually edited recurring event
1596 1710
 				$this->send_update($status2msg[$status],$event['participants'],$event);
1597 1711
 			}
1598 1712
 
@@ -1615,12 +1729,16 @@  discard block
 block discarded – undo
1615 1729
 	 */
1616 1730
 	function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false)
1617 1731
 	{
1618
-		if (!isset($new_event['participants'])) return;
1732
+		if (!isset($new_event['participants']))
1733
+		{
1734
+			return;
1735
+		}
1619 1736
 
1620 1737
 		// check the old list against the new list
1621 1738
 		foreach ($old_event['participants'] as $userid => $status)
1622
-  		{
1623
-            if (!isset($new_event['participants'][$userid])){
1739
+		{
1740
+            if (!isset($new_event['participants'][$userid]))
1741
+            {
1624 1742
             	// Attendee will be deleted this way
1625 1743
             	$new_event['participants'][$userid] = 'G';
1626 1744
             }
@@ -1703,7 +1821,10 @@  discard block
 block discarded – undo
1703 1821
 					}
1704 1822
 					else
1705 1823
 					{
1706
-						if (!($exception = $this->read($id))) continue;
1824
+						if (!($exception = $this->read($id)))
1825
+						{
1826
+							continue;
1827
+						}
1707 1828
 						$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1708 1829
 						$exception['reference'] = $exception['recurrence'] = 0;
1709 1830
 						$this->update($exception, true, true, false, true, $msg=null, true);
@@ -1774,7 +1895,10 @@  discard block
 block discarded – undo
1774 1895
 		$event_arr = $this->event2array($event);
1775 1896
 		foreach($event_arr as $key => $val)
1776 1897
 		{
1777
-			if ($key == 'recur_type') $key = 'repetition';
1898
+			if ($key == 'recur_type')
1899
+			{
1900
+				$key = 'repetition';
1901
+			}
1778 1902
 			$details[$key] = $val['data'];
1779 1903
 		}
1780 1904
 		$details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : '';
@@ -1946,7 +2070,10 @@  discard block
 block discarded – undo
1946 2070
 	 */
1947 2071
 	function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null)
1948 2072
 	{
1949
-		if ($old_event !== null && $event['start'] == $old_event['start']) return;
2073
+		if ($old_event !== null && $event['start'] == $old_event['start'])
2074
+		{
2075
+			return;
2076
+		}
1950 2077
 
1951 2078
 		$time = new Api\DateTime($event['start']);
1952 2079
 		if(!is_array($event['alarm']))
@@ -2020,7 +2147,10 @@  discard block
 block discarded – undo
2020 2147
 		if (is_array($old_event) || $old_event > 0)
2021 2148
 		{
2022 2149
 			// preserve categories without users read access
2023
-			if (!is_array($old_event)) $old_event = $this->read($old_event);
2150
+			if (!is_array($old_event))
2151
+			{
2152
+				$old_event = $this->read($old_event);
2153
+			}
2024 2154
 			$old_categories = explode(',',$old_event['category']);
2025 2155
 			$old_cats_preserve = array();
2026 2156
 			if (is_array($old_categories) && count($old_categories) > 0)
@@ -2111,7 +2241,10 @@  discard block
 block discarded – undo
2111 2241
 				"($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile);
2112 2242
 		}
2113 2243
 
2114
-		if (!isset($event['recurrence'])) $event['recurrence'] = 0;
2244
+		if (!isset($event['recurrence']))
2245
+		{
2246
+			$event['recurrence'] = 0;
2247
+		}
2115 2248
 
2116 2249
 		if ($filter == 'master')
2117 2250
 		{
@@ -2165,19 +2298,26 @@  discard block
 block discarded – undo
2165 2298
 							$matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence'];
2166 2299
 						}
2167 2300
 					}
2168
-				} elseif ($filter != 'master' && ($filter == 'exact' ||
2301
+				}
2302
+				elseif ($filter != 'master' && ($filter == 'exact' ||
2169 2303
 							$event['recur_type'] == $egwEvent['recur_type'] &&
2170 2304
 							strpos($egwEvent['title'], $event['title']) === 0))
2171 2305
 				{
2172 2306
 					$matchingEvents[] = $egwEvent['id']; // we found the event
2173 2307
 				}
2174 2308
 			}
2175
-			if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents;
2309
+			if (!empty($matchingEvents) || $filter == 'exact')
2310
+			{
2311
+				return $matchingEvents;
2312
+			}
2176 2313
 		}
2177 2314
 		unset($event['id']);
2178 2315
 
2179 2316
 		// No chance to find a master without [U]ID
2180
-		if ($filter == 'master' && empty($event['uid'])) return $matchingEvents;
2317
+		if ($filter == 'master' && empty($event['uid']))
2318
+		{
2319
+			return $matchingEvents;
2320
+		}
2181 2321
 
2182 2322
 		// only query calendars of users, we have READ-grants from
2183 2323
 		$users = array();
@@ -2186,17 +2326,23 @@  discard block
 block discarded – undo
2186 2326
 			$user = trim($user);
2187 2327
 			if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user))
2188 2328
 			{
2189
-				if ($user && !in_array($user,$users))	// already added?
2329
+				if ($user && !in_array($user,$users))
2330
+				{
2331
+					// already added?
2190 2332
 				{
2191 2333
 					$users[] = $user;
2192 2334
 				}
2335
+				}
2193 2336
 			}
2194 2337
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
2195 2338
 			{
2196 2339
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
2197 2340
 			}
2198 2341
 			// the further code is only for real users
2199
-			if (!is_numeric($user)) continue;
2342
+			if (!is_numeric($user))
2343
+			{
2344
+				continue;
2345
+			}
2200 2346
 
2201 2347
 			// for groups we have to include the members
2202 2348
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
@@ -2276,7 +2422,10 @@  discard block
 block discarded – undo
2276 2422
 			}
2277 2423
 			foreach ($matchFields as $key)
2278 2424
 			{
2279
-				if (isset($event[$key])) $query['cal_'.$key] = $event[$key];
2425
+				if (isset($event[$key]))
2426
+				{
2427
+					$query['cal_'.$key] = $event[$key];
2428
+				}
2280 2429
 			}
2281 2430
 		}
2282 2431
 
@@ -2316,7 +2465,10 @@  discard block
 block discarded – undo
2316 2465
 					'[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile);
2317 2466
 			}
2318 2467
 
2319
-			if (in_array($egwEvent['id'], $matchingEvents)) continue;
2468
+			if (in_array($egwEvent['id'], $matchingEvents))
2469
+			{
2470
+				continue;
2471
+			}
2320 2472
 
2321 2473
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
2322 2474
 			if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id'])))
@@ -2483,13 +2635,16 @@  discard block
 block discarded – undo
2483 2635
 					foreach ($event['participants'] as $attendee => $status)
2484 2636
 					{
2485 2637
 						if (!isset($egwEvent['participants'][$attendee]) &&
2486
-								$attendee != $egwEvent['owner']) // ||
2638
+								$attendee != $egwEvent['owner'])
2639
+						{
2640
+							// ||
2487 2641
 							//(!$relax && $egw_event['participants'][$attendee] != $status))
2488 2642
 						{
2489 2643
 							if ($this->log)
2490 2644
 							{
2491 2645
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2492 2646
 								"() additional event['participants']: $attendee\n",3,$this->logfile);
2647
+						}
2493 2648
 							}
2494 2649
 							continue 2;
2495 2650
 						}
@@ -2811,7 +2966,10 @@  discard block
 block discarded – undo
2811 2966
 		foreach(array('start','end','recur_enddate','recurrence') as $ts)
2812 2967
 		{
2813 2968
 			// we convert here from server-time to timestamps in user-time!
2814
-			if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2969
+			if (isset($event[$ts]))
2970
+			{
2971
+				$event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0;
2972
+			}
2815 2973
 		}
2816 2974
 		// same with the recur exceptions
2817 2975
 		if (isset($event['recur_exception']) && is_array($event['recur_exception']))
@@ -2839,9 +2997,12 @@  discard block
 block discarded – undo
2839 2997
 	 */
2840 2998
 	function purge($age)
2841 2999
 	{
2842
-		if (is_numeric($age) && $age > 0)	// just make sure bogus values dont delete everything
3000
+		if (is_numeric($age) && $age > 0)
3001
+		{
3002
+			// just make sure bogus values dont delete everything
2843 3003
 		{
2844 3004
 			$this->so->purge(time() - 365*24*3600*(float)$age);
2845 3005
 		}
3006
+		}
2846 3007
 	}
2847 3008
 }
Please login to merge, or discard this patch.