Completed
Push — 16.1 ( 3870d9...133628 )
by Nathan
25:03 queued 10:07
created
calendar/inc/class.calendar_uiforms.inc.php 1 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
 				if ($event['participants'][$uid] == 'R') continue;
2373 2371
 
@@ -2383,10 +2381,10 @@  discard block
 block discarded – undo
2383 2381
 
2384 2382
 			if ($this->debug)
2385 2383
 			{
2386
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2384
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2387 2385
 				echo "event[title]=$event[title]<br>\n";
2388
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2389
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2386
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2387
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2390 2388
 			}
2391 2389
 			// $events ends before our actual position ==> ignore it
2392 2390
 			if ($event['end'] < $ft_start)
@@ -2410,11 +2408,11 @@  discard block
 block discarded – undo
2410 2408
 					'start'	=> $ft_start,
2411 2409
 					'end'	=> $ft_end,
2412 2410
 				);
2413
-				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";
2411
+				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 2412
 			}
2415 2413
 			$ft_start = $event['end'];
2416 2414
 		}
2417
-		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);
2415
+		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 2416
 
2419 2417
 		return $freetime;
2420 2418
 	}
@@ -2434,46 +2432,46 @@  discard block
 block discarded – undo
2434 2432
 	 */
2435 2433
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2436 2434
 	{
2437
-		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);
2435
+		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 2436
 
2439 2437
 		$freetime_daywise = array();
2440 2438
 		if (!is_array($sel_options)) $sel_options = array();
2441 2439
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2442 2440
 
2443
-		$start_time = (int) $_start_time;	// ignore leading zeros
2444
-		$end_time   = (int) $_end_time;
2441
+		$start_time = (int)$_start_time; // ignore leading zeros
2442
+		$end_time   = (int)$_end_time;
2445 2443
 
2446 2444
 		// ignore the end_time, if duration would never fit
2447
-		if (($end_time - $start_time)*HOUR_s < $duration)
2445
+		if (($end_time - $start_time) * HOUR_s < $duration)
2448 2446
 		{
2449 2447
 			$end_time = 0;
2450
-			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);
2448
+			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 2449
 		}
2452 2450
 		$n = 0;
2453
-		foreach($freetime as $ft)
2451
+		foreach ($freetime as $ft)
2454 2452
 		{
2455 2453
 			$adaybegin = $this->bo->date2array($ft['start']);
2456 2454
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2457 2455
 			unset($adaybegin['raw']);
2458 2456
 			$daybegin = $this->bo->date2ts($adaybegin);
2459 2457
 
2460
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2458
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2461 2459
 			{
2462
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2463
-				$mcal_dow = pow(2,$dow);
2464
-				if (!($weekdays & $mcal_dow))
2460
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2461
+				$mcal_dow = pow(2, $dow);
2462
+				if (!($weekdays&$mcal_dow))
2465 2463
 				{
2466 2464
 					//echo "wrong day of week $dow<br>\n";
2467
-					continue;	// wrong day of week
2465
+					continue; // wrong day of week
2468 2466
 				}
2469 2467
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2470 2468
 
2471
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2469
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2472 2470
 				{
2473
-					$start = $daybegin + $start_time*HOUR_s;
2471
+					$start = $daybegin + $start_time * HOUR_s;
2474 2472
 				}
2475 2473
 				// if end_time given use it, else the original slot's end
2476
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2474
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2477 2475
 				if ($end > $ft['end']) $end = $ft['end'];
2478 2476
 
2479 2477
 				// slot to small for duration
@@ -2487,11 +2485,11 @@  discard block
 block discarded – undo
2487 2485
 					'end'	=> $end,
2488 2486
 				);
2489 2487
 				$times = array();
2490
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2488
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2491 2489
 				{
2492 2490
 					$e = $s + $duration;
2493
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2494
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2491
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2492
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2495 2493
 				}
2496 2494
 				$sel_options[$n.'start'] = $times;
2497 2495
 			}
@@ -2506,13 +2504,13 @@  discard block
 block discarded – undo
2506 2504
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2507 2505
      * @return string error-msg if $return_error
2508 2506
      */
2509
-    function export($content=0,$return_error=false)
2507
+    function export($content = 0, $return_error = false)
2510 2508
     {
2511 2509
 		$boical = new calendar_ical();
2512 2510
 		#error_log(__METHOD__.print_r($content,true));
2513 2511
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2514 2512
 		{
2515
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2513
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2516 2514
 			{
2517 2515
 				$msg = lang('Permission denied');
2518 2516
 
@@ -2520,20 +2518,20 @@  discard block
 block discarded – undo
2520 2518
 			}
2521 2519
 			else
2522 2520
 			{
2523
-				html::content_header('event.ics','text/calendar',bytes($ical));
2521
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2524 2522
 				echo $ical;
2525 2523
 				common::egw_exit();
2526 2524
 			}
2527 2525
 		}
2528 2526
 		if (is_array($content))
2529 2527
 		{
2530
-			$events =& $this->bo->search(array(
2528
+			$events = & $this->bo->search(array(
2531 2529
 				'start' => $content['start'],
2532 2530
 				'end'   => $content['end'],
2533 2531
 				'enum_recuring' => false,
2534 2532
 				'daywise'       => false,
2535 2533
 				'owner'         => $this->owner,
2536
-				'date_format'   => 'server',    // timestamp in server time for boical class
2534
+				'date_format'   => 'server', // timestamp in server time for boical class
2537 2535
 			));
2538 2536
 			if (!$events)
2539 2537
 			{
@@ -2541,8 +2539,8 @@  discard block
 block discarded – undo
2541 2539
 			}
2542 2540
 			else
2543 2541
 			{
2544
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2545
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2542
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2543
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2546 2544
 				echo $ical;
2547 2545
 				common::egw_exit();
2548 2546
 			}
@@ -2558,9 +2556,9 @@  discard block
 block discarded – undo
2558 2556
 		}
2559 2557
 		$content['msg'] = $msg;
2560 2558
 
2561
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2559
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2562 2560
 		$etpl = new etemplate_new('calendar.export');
2563
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2561
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2564 2562
     }
2565 2563
 
2566 2564
 	/**
@@ -2568,7 +2566,7 @@  discard block
 block discarded – undo
2568 2566
 	 *
2569 2567
 	 * @param array $_content
2570 2568
 	 */
2571
-	function cat_acl(array $_content=null)
2569
+	function cat_acl(array $_content = null)
2572 2570
 	{
2573 2571
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2574 2572
 		{
@@ -2580,15 +2578,15 @@  discard block
 block discarded – undo
2580 2578
 			unset($_content['button']);
2581 2579
 			if ($button != 'cancel')	// store changed Acl
2582 2580
 			{
2583
-				foreach($_content as $data)
2581
+				foreach ($_content as $data)
2584 2582
 				{
2585 2583
 					if (!($cat_id = $data['cat_id'])) continue;
2586
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2584
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2587 2585
 					{
2588 2586
 						$rights = 0;
2589
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2590
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2591
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2587
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2588
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2589
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2592 2590
 					}
2593 2591
 				}
2594 2592
 			}
@@ -2600,20 +2598,20 @@  discard block
 block discarded – undo
2600 2598
 				), 'admin');
2601 2599
 			}
2602 2600
 		}
2603
-		$content= $preserv = array();
2601
+		$content = $preserv = array();
2604 2602
 		$n = 1;
2605
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2603
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2606 2604
 		{
2607
-			$cat_id = substr($Lcat_id,1);
2605
+			$cat_id = substr($Lcat_id, 1);
2608 2606
 			$row = array(
2609 2607
 				'cat_id' => $cat_id,
2610 2608
 				'add' => array(),
2611 2609
 				'status' => array(),
2612 2610
 			);
2613
-			foreach($data as $account_id => $rights)
2611
+			foreach ($data as $account_id => $rights)
2614 2612
 			{
2615
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2616
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2613
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2614
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2617 2615
 			}
2618 2616
 			$content[$n] = $row;
2619 2617
 			$preserv[$n] = array(
@@ -2629,7 +2627,7 @@  discard block
 block discarded – undo
2629 2627
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2630 2628
 		$tmp = new Etemplate('calendar.cat_acl');
2631 2629
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2632
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2630
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2633 2631
 	}
2634 2632
 
2635 2633
 	/**
@@ -2679,18 +2677,18 @@  discard block
 block discarded – undo
2679 2677
 
2680 2678
 
2681 2679
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2682
-		if($content['recur_type'] || $content['recurrence'])
2680
+		if ($content['recur_type'] || $content['recurrence'])
2683 2681
 		{
2684 2682
 			$content['history']['filter'] = array(
2685 2683
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2686
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2687
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2684
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2685
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2688 2686
 			);
2689 2687
 		}
2690 2688
 
2691 2689
 		// Translate labels
2692 2690
 		$tracking = new calendar_tracking();
2693
-		foreach($tracking->field2label as $field => $label)
2691
+		foreach ($tracking->field2label as $field => $label)
2694 2692
 		{
2695 2693
 			$sel_options[$status][$field] = lang($label);
2696 2694
 		}
@@ -2709,44 +2707,44 @@  discard block
 block discarded – undo
2709 2707
 	 *	which particular instance was dragged
2710 2708
 	 * @return string XML response if no error occurs
2711 2709
 	 */
2712
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2710
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2713 2711
 	{
2714
-		list($eventId, $date) = explode(':', $_eventId,2);
2712
+		list($eventId, $date) = explode(':', $_eventId, 2);
2715 2713
 		$ignore_conflicts = false;
2716 2714
 
2717 2715
 		// we do not allow dragging into another users calendar ATM
2718
-		if($targetOwner < 0)
2716
+		if ($targetOwner < 0)
2719 2717
 		{
2720 2718
 			$targetOwner = array($targetOwner);
2721 2719
 		}
2722
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2720
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2723 2721
 		{
2724 2722
 			$targetOwner = $calendarOwner;
2725 2723
 		}
2726 2724
 		// But you may be viewing multiple users, or a group calendar and
2727 2725
 		// dragging your event - dragging across calendars does not change owner
2728
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2726
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2729 2727
 		{
2730 2728
 			$return = true;
2731
-			foreach($targetOwner as $owner)
2729
+			foreach ($targetOwner as $owner)
2732 2730
 			{
2733
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2731
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2734 2732
 				{
2735 2733
 					$return = false;
2736 2734
 					break;
2737 2735
 				}
2738
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2736
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2739 2737
 				{
2740 2738
 					$return = false;
2741 2739
 					break;
2742 2740
 				}
2743 2741
 			}
2744
-			if($return) return;
2742
+			if ($return) return;
2745 2743
 		}
2746
-		$old_event=$event=$this->bo->read($eventId);
2744
+		$old_event = $event = $this->bo->read($eventId);
2747 2745
 		if (!$durationT)
2748 2746
 		{
2749
-			$duration=$event['end']-$event['start'];
2747
+			$duration = $event['end'] - $event['start'];
2750 2748
 		}
2751 2749
 		// Drag a normal event to whole day non-blocking
2752 2750
 		else if ($durationT == 'whole_day')
@@ -2754,7 +2752,7 @@  discard block
 block discarded – undo
2754 2752
 			$event['whole_day'] = true;
2755 2753
 			$event['non_blocking'] = true;
2756 2754
 			// Make duration whole days, less 1 second
2757
-			$duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1;
2755
+			$duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1;
2758 2756
 		}
2759 2757
 		else
2760 2758
 		{
@@ -2767,19 +2765,19 @@  discard block
 block discarded – undo
2767 2765
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2768 2766
 			if (!empty($event['whole_day']))
2769 2767
 			{
2770
-				$d =& $this->bo->so->startOfDay($d);
2768
+				$d = & $this->bo->so->startOfDay($d);
2771 2769
 				$d->setUser();
2772 2770
 			}
2773 2771
 			$event = $this->bo->read($eventId, $d, true);
2774 2772
 
2775 2773
 			// For DnD, create an exception if they gave the date
2776 2774
 			$preserv = null;
2777
-			$this->_create_exception($event,$preserv);
2775
+			$this->_create_exception($event, $preserv);
2778 2776
 			unset($event['id']);
2779 2777
 			$links = $event['link_to']['to_id'];
2780 2778
 
2781 2779
 			$messages = null;
2782
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2780
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2783 2781
 			if (!is_array($conflicts) && $conflicts)
2784 2782
 			{
2785 2783
 				// now we need to add the original start as recur-execption to the series
@@ -2787,28 +2785,28 @@  discard block
 block discarded – undo
2787 2785
 				$recur_event['recur_exception'][] = $d->format('ts');
2788 2786
 				// check if we need to move the alarms, because they are next on that exception
2789 2787
 				$this->bo->check_move_alarms($recur_event, null, $d);
2790
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2791
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2792
-				$this->bo->update($recur_event,true);	// no conflict check here
2788
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2789
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2790
+				$this->bo->update($recur_event, true); // no conflict check here
2793 2791
 
2794 2792
 				// Sending null will trigger a removal of the original for that date
2795 2793
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2796 2794
 
2797 2795
 				unset($recur_event);
2798
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2796
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2799 2797
 				unset($preserv['edit_single']);
2800 2798
 			}
2801 2799
 		}
2802 2800
 
2803 2801
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2804 2802
 		$event['start'] = $d->format('ts');
2805
-		$event['end'] = $event['start']+$duration;
2803
+		$event['end'] = $event['start'] + $duration;
2806 2804
 
2807 2805
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2808 2806
 		{
2809 2807
 			// calculate offset against clicked recurrance,
2810 2808
 			// depending on which is smaller
2811
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2809
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2812 2810
 			$event['start'] = $old_event['start'] + $offset;
2813 2811
 			$event['duration'] = $duration;
2814 2812
 
@@ -2819,31 +2817,31 @@  discard block
 block discarded – undo
2819 2817
 			// Can't handle conflict.  Just ignore it.
2820 2818
 			$ignore_conflicts = true;
2821 2819
 		}
2822
-		if(!$event['recur_type'])
2820
+		if (!$event['recur_type'])
2823 2821
 		{
2824 2822
 			$this->bo->check_move_alarms($event, $old_event);
2825 2823
 		}
2826 2824
 
2827 2825
 		// Drag a whole day to a time
2828
-		if($durationT && $durationT != 'whole_day')
2826
+		if ($durationT && $durationT != 'whole_day')
2829 2827
 		{
2830 2828
 			$event['whole_day'] = ($duration == DAY_s);
2831 2829
 			$event['non_blocking'] = false;
2832 2830
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2833 2831
 			// so save the change now, and then let the conflict check happen.
2834 2832
 			$message = null;
2835
-			$this->bo->update($event,true, true, false, true, $message,true);
2833
+			$this->bo->update($event, true, true, false, true, $message, true);
2836 2834
 
2837 2835
 			// Whole day non blocking with DAY_s would add a day
2838
-			if($duration==DAY_s) $duration=0;
2836
+			if ($duration == DAY_s) $duration = 0;
2839 2837
 		}
2840 2838
 
2841 2839
 		$status_reset_to_unknown = false;
2842 2840
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2843
-		foreach((array)$event['participants'] as $uid => $status)
2841
+		foreach ((array)$event['participants'] as $uid => $status)
2844 2842
 		{
2845 2843
 			$q = $r = null;
2846
-			calendar_so::split_status($status,$q,$r);
2844
+			calendar_so::split_status($status, $q, $r);
2847 2845
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2848 2846
 			{
2849 2847
 				$preferences = new Api\Preferences($uid);
@@ -2856,29 +2854,29 @@  discard block
 block discarded – undo
2856 2854
 						if ($sameday) break;
2857 2855
 					default:
2858 2856
 						$status_reset_to_unknown = true;
2859
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2857
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2860 2858
 						// todo: report reset status to user
2861 2859
 				}
2862 2860
 			}
2863 2861
 		}
2864 2862
 
2865 2863
 		$message = false;
2866
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2864
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2867 2865
 
2868 2866
 		// Save links
2869
-		if($links)
2867
+		if ($links)
2870 2868
 		{
2871 2869
 			Link::link('calendar', $event['id'], $links);
2872 2870
 		}
2873 2871
 
2874
-		$this->update_client($event['id'],$d);
2872
+		$this->update_client($event['id'], $d);
2875 2873
 		$response = Api\Json\Response::get();
2876
-		if(!is_array($conflicts) && $conflicts)
2874
+		if (!is_array($conflicts) && $conflicts)
2877 2875
 		{
2878
-			if(is_int($conflicts))
2876
+			if (is_int($conflicts))
2879 2877
 			{
2880 2878
 				$event['id'] = $conflicts;
2881
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2879
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2882 2880
 			}
2883 2881
 		}
2884 2882
 		else if ($conflicts)
@@ -2891,21 +2889,21 @@  discard block
 block discarded – undo
2891 2889
 					.'&end='.$event['end']
2892 2890
 					.'&non_interactive=true'
2893 2891
 					.'&cancel_needs_refresh=true',
2894
-				'',750,410);
2892
+				'', 750, 410);
2895 2893
 		}
2896 2894
 		else if ($message)
2897 2895
 		{
2898
-			$response->call('egw.message',  implode('<br />', $message));
2896
+			$response->call('egw.message', implode('<br />', $message));
2899 2897
 		}
2900
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2898
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2901 2899
 		if ($status_reset_to_unknown)
2902 2900
 		{
2903
-			foreach((array)$event['participants'] as $uid => $status)
2901
+			foreach ((array)$event['participants'] as $uid => $status)
2904 2902
 			{
2905 2903
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2906 2904
 				{
2907
-					calendar_so::split_status($status,$q,$r);
2908
-					$status = calendar_so::combine_status('U',$q,$r);
2905
+					calendar_so::split_status($status, $q, $r);
2906
+					$status = calendar_so::combine_status('U', $q, $r);
2909 2907
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2910 2908
 				}
2911 2909
 			}
@@ -2922,7 +2920,7 @@  discard block
 block discarded – undo
2922 2920
 	{
2923 2921
 		list($eventId, $date) = explode(':', $_eventId);
2924 2922
 		$event = $this->bo->read($eventId);
2925
-		if($date)
2923
+		if ($date)
2926 2924
 		{
2927 2925
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2928 2926
 		}
@@ -2932,29 +2930,29 @@  discard block
 block discarded – undo
2932 2930
 		{
2933 2931
 			if (!empty($event['whole_day']))
2934 2932
 			{
2935
-				$d =& $this->bo->so->startOfDay($date);
2933
+				$d = & $this->bo->so->startOfDay($date);
2936 2934
 				$d->setUser();
2937 2935
 			}
2938 2936
 			$event = $this->bo->read($eventId, $d, true);
2939 2937
 			$date = $d->format('ts');
2940 2938
 		}
2941
-		if($event['participants'][$uid])
2939
+		if ($event['participants'][$uid])
2942 2940
 		{
2943 2941
 			$q = $r = null;
2944
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2945
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2946
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2942
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2943
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2944
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2947 2945
 		}
2948 2946
 		else
2949 2947
 		{
2950 2948
 			// Group membership
2951
-			foreach($event['participants'] as $id => $status)
2949
+			foreach ($event['participants'] as $id => $status)
2952 2950
 			{
2953
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2951
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2954 2952
 				{
2955
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2956
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2957
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2953
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2954
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2955
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2958 2956
 					break;
2959 2957
 				}
2960 2958
 			}
@@ -2962,7 +2960,7 @@  discard block
 block discarded – undo
2962 2960
 
2963 2961
 		// Directly update stored data.  If event is still visible, it will
2964 2962
 		// be notified & update itself.
2965
-		$this->update_client($eventId,$d);
2963
+		$this->update_client($eventId, $d);
2966 2964
 	}
2967 2965
 
2968 2966
 	/**
@@ -2970,8 +2968,8 @@  discard block
 block discarded – undo
2970 2968
 	 */
2971 2969
 	public function ajax_delete($eventId)
2972 2970
 	{
2973
-		list($id, $date) = explode(':',$eventId);
2974
-		$event=$this->bo->read($id);
2971
+		list($id, $date) = explode(':', $eventId);
2972
+		$event = $this->bo->read($id);
2975 2973
 		$response = Api\Json\Response::get();
2976 2974
 
2977 2975
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2984,11 +2982,11 @@  discard block
 block discarded – undo
2984 2982
 			{
2985 2983
 				$msg = lang('Event deleted');
2986 2984
 			}
2987
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2985
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2988 2986
 		}
2989 2987
 		else
2990 2988
 		{
2991
-			$response->apply('egw.message', Array(lang('Error')),'error');
2989
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2992 2990
 		}
2993 2991
 	}
2994 2992
 
@@ -3001,10 +2999,10 @@  discard block
 block discarded – undo
3001 2999
 	 */
3002 3000
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
3003 3001
 	{
3004
-		list($eventId, $date) = explode(':', $_eventId,2);
3002
+		list($eventId, $date) = explode(':', $_eventId, 2);
3005 3003
 
3006 3004
 		$event = $this->bo->read($eventId);
3007
-		if($date)
3005
+		if ($date)
3008 3006
 		{
3009 3007
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
3010 3008
 		}
@@ -3014,17 +3012,17 @@  discard block
 block discarded – undo
3014 3012
 		{
3015 3013
 			if (!empty($event['whole_day']))
3016 3014
 			{
3017
-				$d =& $this->bo->so->startOfDay($date);
3015
+				$d = & $this->bo->so->startOfDay($date);
3018 3016
 				$d->setUser();
3019 3017
 			}
3020 3018
 			$event = $this->bo->read($eventId, $d, true);
3021 3019
 			// For DnD, create an exception if they gave the date
3022 3020
 			$preserv = null;
3023
-			$this->_create_exception($event,$preserv);
3021
+			$this->_create_exception($event, $preserv);
3024 3022
 			unset($event['id']);
3025 3023
 
3026 3024
 			$messages = null;
3027
-			$conflicts = $this->bo->update($event,true,true,false,true,$messages);
3025
+			$conflicts = $this->bo->update($event, true, true, false, true, $messages);
3028 3026
 			if (!is_array($conflicts) && $conflicts)
3029 3027
 			{
3030 3028
 				// now we need to add the original start as recur-execption to the series
@@ -3032,28 +3030,28 @@  discard block
 block discarded – undo
3032 3030
 				$recur_event['recur_exception'][] = $d->format('ts');
3033 3031
 				// check if we need to move the alarms, because they are next on that exception
3034 3032
 				$this->bo->check_move_alarms($recur_event, null, $d);
3035
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
3036
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
3037
-				$this->bo->update($recur_event,true);	// no conflict check here
3033
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
3034
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
3035
+				$this->bo->update($recur_event, true); // no conflict check here
3038 3036
 
3039 3037
 				// Sending null will trigger a removal of the original for that date
3040 3038
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
3041 3039
 
3042 3040
 				unset($recur_event);
3043
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
3041
+				unset($event['edit_single']); // if we further edit it, it's just a single event
3044 3042
 				unset($preserv['edit_single']);
3045 3043
 			}
3046 3044
 		}
3047
-		foreach($remove as $participant)
3045
+		foreach ($remove as $participant)
3048 3046
 		{
3049 3047
 			unset($event['participants'][$participant]);
3050 3048
 		}
3051
-		foreach($invite as $participant)
3049
+		foreach ($invite as $participant)
3052 3050
 		{
3053 3051
 			$event['participants'][$participant] = 'U';
3054 3052
 		}
3055 3053
 		$message = null;
3056
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
3054
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
3057 3055
 
3058 3056
 		$response = Api\Json\Response::get();
3059 3057
 
@@ -3061,8 +3059,8 @@  discard block
 block discarded – undo
3061 3059
 		{
3062 3060
 			// Save it anyway, was done with explicit user interaction,
3063 3061
 			// and if we don't we lose the invite
3064
-			$this->bo->update($event,true);	// no conflict check here
3065
-			$this->update_client($event['id'],$d);
3062
+			$this->bo->update($event, true); // no conflict check here
3063
+			$this->update_client($event['id'], $d);
3066 3064
 			$response->call(
3067 3065
 				'egw_openWindowCentered2',
3068 3066
 				$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
@@ -3071,22 +3069,22 @@  discard block
 block discarded – undo
3071 3069
 					.'&end='.$event['end']
3072 3070
 					.'&non_interactive=true'
3073 3071
 					.'&cancel_needs_refresh=true',
3074
-				'',750,410);
3072
+				'', 750, 410);
3075 3073
 		}
3076 3074
 		else if ($message)
3077 3075
 		{
3078
-			$response->call('egw.message',  implode('<br />', $message));
3076
+			$response->call('egw.message', implode('<br />', $message));
3079 3077
 		}
3080
-		if($conflicts)
3078
+		if ($conflicts)
3081 3079
 		{
3082
-			$this->update_client($event['id'],$d);
3083
-			if(is_int($conflicts))
3080
+			$this->update_client($event['id'], $d);
3081
+			if (is_int($conflicts))
3084 3082
 			{
3085 3083
 				$event['id'] = $conflicts;
3086 3084
 			}
3087
-			if($event['id'])
3085
+			if ($event['id'])
3088 3086
 			{
3089
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
3087
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
3090 3088
 			}
3091 3089
 		}
3092 3090
 	}
@@ -3097,13 +3095,13 @@  discard block
 block discarded – undo
3097 3095
 	 * @param array $mailContent = null mail content
3098 3096
 	 * @return  array
3099 3097
 	 */
3100
-	function mail_import(array $mailContent=null)
3098
+	function mail_import(array $mailContent = null)
3101 3099
 	{
3102 3100
 		// It would get called from compose as a popup with egw_data
3103 3101
 		if (!is_array($mailContent) && ($_GET['egw_data']))
3104 3102
 		{
3105 3103
 			// get raw mail data
3106
-			Link::get_data ($_GET['egw_data']);
3104
+			Link::get_data($_GET['egw_data']);
3107 3105
 			return false;
3108 3106
 		}
3109 3107
 
@@ -3113,7 +3111,7 @@  discard block
 block discarded – undo
3113 3111
 			$AB = new Api\Contacts();
3114 3112
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
3115 3113
 
3116
-			$participants[0] = array (
3114
+			$participants[0] = array(
3117 3115
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
3118 3116
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
3119 3117
 				'status' => 'A',
@@ -3121,23 +3119,23 @@  discard block
 block discarded – undo
3121 3119
 				'app' => 'User',
3122 3120
 				'role' => 'REQ-PARTICIPANT'
3123 3121
 			);
3124
-			foreach($mailContent['addresses'] as $address)
3122
+			foreach ($mailContent['addresses'] as $address)
3125 3123
 			{
3126 3124
 				// Get available contacts from the email
3127 3125
 				$contacts = $AB->search(array(
3128 3126
 						'email' => $address['email'],
3129 3127
 						'email_home' => $address['email']
3130
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
3128
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
3131 3129
 				if (is_array($contacts))
3132 3130
 				{
3133
-					foreach($contacts as $account)
3131
+					foreach ($contacts as $account)
3134 3132
 					{
3135 3133
 						$accounts[] = $account['account_id'];
3136 3134
 					}
3137 3135
 				}
3138 3136
 				else
3139 3137
 				{
3140
-					$participants []= array (
3138
+					$participants [] = array(
3141 3139
 						'app' => 'email',
3142 3140
 						'uid' => 'e'.$address['email'],
3143 3141
 						'status' => 'U',
@@ -3145,7 +3143,7 @@  discard block
 block discarded – undo
3145 3143
 					);
3146 3144
 				}
3147 3145
 			}
3148
-			$participants = array_merge($participants , array(
3146
+			$participants = array_merge($participants, array(
3149 3147
 				"participant" => $accounts,
3150 3148
 				"role" => "REQ-PARTICIPANT",
3151 3149
 				"add" => "pressed"
@@ -3169,14 +3167,14 @@  discard block
 block discarded – undo
3169 3167
 			{
3170 3168
 				foreach ($mailContent['attachments'] as $attachment)
3171 3169
 				{
3172
-					if($attachment['egw_data'])
3170
+					if ($attachment['egw_data'])
3173 3171
 					{
3174
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3172
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3175 3173
 					}
3176
-					else if(is_readable($attachment['tmp_name']) ||
3174
+					else if (is_readable($attachment['tmp_name']) ||
3177 3175
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3178 3176
 					{
3179
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3177
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3180 3178
 					}
3181 3179
 				}
3182 3180
 			}
Please login to merge, or discard this patch.