Completed
Push — 16.1 ( a3d010...d74fac )
by Nathan
30:20 queued 16:26
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,19 +443,18 @@  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
-										foreach($this->bo->enum_mailing_list($participant) as $contact)
451
+										foreach ($this->bo->enum_mailing_list($participant) as $contact)
454 452
 										{
455 453
 											// Mailing lists can contain users, so allow for that possibility
456 454
 											$_type = is_numeric($contact) ? '' : $contact[0];
457
-											$_uid = is_numeric($contact) ? $contact : substr($contact,1);
455
+											$_uid = is_numeric($contact) ? $contact : substr($contact, 1);
458 456
 											$event['participants'][$contact] = $event['participant_types'][$_type][$_uid] =
459
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
457
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
460 458
 										}
461 459
 										continue;
462 460
 									}
@@ -466,8 +464,8 @@  discard block
 block discarded – undo
466 464
 										// todo check real availability = maximum - already booked quantity
467 465
 										if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
468 466
 										{
469
-											$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
470
-											foreach(array('quantity','resource','role') as $n)
467
+											$msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']);
468
+											foreach (array('quantity', 'resource', 'role') as $n)
471 469
 											{
472 470
 												$event['participants'][$n] = $content['participants'][$n];
473 471
 											}
@@ -476,7 +474,7 @@  discard block
 block discarded – undo
476 474
 										else
477 475
 										{
478 476
 											$event['participants'][$uid] = $event['participant_types'][$type][$id] =
479
-												calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
477
+												calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']);
480 478
 										}
481 479
 									}
482 480
 								}
@@ -490,14 +488,14 @@  discard block
 block discarded – undo
490 488
 							break;
491 489
 
492 490
 						default:		// existing participant row
493
-							if (!is_array($data)) continue;	// widgets in participant tab, above participant list
494
-							foreach(array('uid','status','quantity','role') as $name)
491
+							if (!is_array($data)) continue; // widgets in participant tab, above participant list
492
+							foreach (array('uid', 'status', 'quantity', 'role') as $name)
495 493
 							{
496 494
 								$$name = $data[$name];
497 495
 							}
498 496
 							if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
499 497
 							{
500
-								$uid = false;	// entry has been deleted
498
+								$uid = false; // entry has been deleted
501 499
 							}
502 500
 							elseif ($uid)
503 501
 							{
@@ -508,27 +506,27 @@  discard block
 block discarded – undo
508 506
 								}
509 507
 								else
510 508
 								{
511
-									$id = substr($uid,1);
509
+									$id = substr($uid, 1);
512 510
 									$type = $uid[0];
513 511
 								}
514 512
 								if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
515 513
 								{
516 514
 									//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
517 515
 									$new_status = calendar_so::combine_status($status, $quantity, $role);
518
-									if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
516
+									if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications']))
519 517
 									{
520 518
 										// Update main window
521 519
 										$d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone);
522 520
 										$client_updated = $this->update_client($event['id'], $d);
523 521
 
524 522
 										// refreshing the calendar-view with the changed participant-status
525
-										if($event['recur_type'] != MCAL_RECUR_NONE)
523
+										if ($event['recur_type'] != MCAL_RECUR_NONE)
526 524
 										{
527 525
 											$msg = lang('Status for all future scheduled days changed');
528 526
 										}
529 527
 										else
530 528
 										{
531
-											if(isset($content['edit_single']))
529
+											if (isset($content['edit_single']))
532 530
 											{
533 531
 												$msg = lang('Status for this particular day changed');
534 532
 												// prevent accidentally creating a real exception afterwards
@@ -549,7 +547,7 @@  discard block
 block discarded – undo
549 547
 										if ($status == 'R' && $event['alarm'])
550 548
 										{
551 549
 											// remove from bo->set_status deleted alarms of rejected users from UI too
552
-											foreach($event['alarm'] as $alarm_id => $alarm)
550
+											foreach ($event['alarm'] as $alarm_id => $alarm)
553 551
 											{
554 552
 												if ((string)$alarm['owner'] === (string)$uid)
555 553
 												{
@@ -562,7 +560,7 @@  discard block
 block discarded – undo
562 560
 								if ($uid && $status != 'G')
563 561
 								{
564 562
 									$event['participants'][$uid] = $event['participant_types'][$type][$id] =
565
-										calendar_so::combine_status($status,$quantity,$role);
563
+										calendar_so::combine_status($status, $quantity, $role);
566 564
 								}
567 565
 							}
568 566
 							break;
@@ -581,26 +579,26 @@  discard block
 block discarded – undo
581 579
 			'tabs'			=> $content['tabs'],
582 580
 			'template'      => $content['template'],
583 581
 		);
584
-		$noerror=true;
582
+		$noerror = true;
585 583
 
586 584
 		//error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#');
587 585
 
588 586
 		$ignore_conflicts = $status_reset_to_unknown = false;
589 587
 
590
-		switch((string)$button)
588
+		switch ((string)$button)
591 589
 		{
592 590
 			case 'ignore':
593 591
 				$ignore_conflicts = true;
594
-				$button = $event['button_was'];	// save or apply
592
+				$button = $event['button_was']; // save or apply
595 593
 				unset($event['button_was']);
596 594
 				break;
597 595
 
598 596
 		}
599 597
 
600
-		switch((string)$button)
598
+		switch ((string)$button)
601 599
 		{
602 600
 		case 'exception':	// create an exception in a recuring event
603
-			$msg = $this->_create_exception($event,$preserv);
601
+			$msg = $this->_create_exception($event, $preserv);
604 602
 			break;
605 603
 
606 604
 		case 'copy':	// create new event with copied content, some content need to be unset to make a "new" event
@@ -611,29 +609,29 @@  discard block
 block discarded – undo
611 609
 			unset($event['recurrence']);
612 610
 			unset($preserv['recurrence']);
613 611
 			unset($event['recur_exception']);
614
-			unset($event['edit_single']);	// in case it has been set
612
+			unset($event['edit_single']); // in case it has been set
615 613
 			unset($event['modified']);
616 614
 			unset($event['modifier']);
617 615
 			unset($event['caldav_name']);
618
-			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner'];
616
+			$event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner'];
619 617
 
620 618
 			// Clear participant stati
621
-			foreach($event['participant_types'] as $type => &$participants)
619
+			foreach ($event['participant_types'] as $type => &$participants)
622 620
 			{
623
-				foreach($participants as $id => &$p_response)
621
+				foreach ($participants as $id => &$p_response)
624 622
 				{
625
-					if($type == 'u' && $id == $event['owner']) continue;
623
+					if ($type == 'u' && $id == $event['owner']) continue;
626 624
 					calendar_so::split_status($p_response, $quantity, $role);
627 625
 					// if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it
628
-					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
629
-					$p_response = calendar_so::combine_status($status,$quantity,$role);
626
+					$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U';
627
+					$p_response = calendar_so::combine_status($status, $quantity, $role);
630 628
 				}
631 629
 			}
632 630
 
633 631
 			// Copy alarms
634 632
 			if (is_array($event['alarm']))
635 633
 			{
636
-				foreach($event['alarm'] as $n => &$alarm)
634
+				foreach ($event['alarm'] as $n => &$alarm)
637 635
 				{
638 636
 					unset($alarm['id']);
639 637
 					unset($alarm['cal_id']);
@@ -643,7 +641,7 @@  discard block
 block discarded – undo
643 641
 			// Get links to be copied
644 642
 			// With no ID, $content['link_to']['to_id'] is used
645 643
 			$content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0);
646
-			foreach(Link::get_links('calendar', $content['id']) as $link)
644
+			foreach (Link::get_links('calendar', $content['id']) as $link)
647 645
 			{
648 646
 				if ($link['app'] != Link::VFS_APPNAME)
649 647
 				{
@@ -659,7 +657,7 @@  discard block
 block discarded – undo
659 657
 			}
660 658
 			unset($link);
661 659
 			$preserv['view'] = $preserv['edit_single'] = false;
662
-			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry')));
660
+			$msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry')));
663 661
 			$event['title'] = lang('Copy of:').' '.$event['title'];
664 662
 			break;
665 663
 
@@ -669,7 +667,7 @@  discard block
 block discarded – undo
669 667
 		case 'print':
670 668
 		case 'apply':
671 669
 		case 'infolog':
672
-			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event))
670
+			if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event))
673 671
 			{
674 672
 				$msg = lang('Permission denied');
675 673
 				$button = '';
@@ -687,7 +685,7 @@  discard block
 block discarded – undo
687 685
 				$button = '';
688 686
 				break;
689 687
 			}
690
-			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
688
+			if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval']))
691 689
 			{
692 690
 				$msg = lang('Error: Duration of event longer then recurrence interval!');
693 691
 				$button = '';
@@ -717,14 +715,14 @@  discard block
 block discarded – undo
717 715
 				$event['reference'] = $event['id'];
718 716
 				$event['recurrence'] = $content['edit_single'];
719 717
 				unset($event['id']);
720
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
718
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
721 719
 				if (!is_array($conflicts) && $conflicts)
722 720
 				{
723 721
 					// now we need to add the original start as recur-execption to the series
724 722
 					$recur_event = $this->bo->read($event['reference']);
725 723
 					$recur_event['recur_exception'][] = $content['edit_single'];
726 724
 					// check if we need to move the alarms, because they are next on that exception
727
-					foreach($recur_event['alarm'] as $id => $alarm)
725
+					foreach ($recur_event['alarm'] as $id => $alarm)
728 726
 					{
729 727
 						if ($alarm['time'] == $content['edit_single'] - $alarm['offset'])
730 728
 						{
@@ -740,17 +738,17 @@  discard block
 block discarded – undo
740 738
 							}
741 739
 						}
742 740
 					}
743
-					unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
744
-					unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
745
-					$this->bo->update($recur_event,true);	// no conflict check here
741
+					unset($recur_event['start']); unset($recur_event['end']); // no update necessary
742
+					unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
743
+					$this->bo->update($recur_event, true); // no conflict check here
746 744
 
747 745
 					// Save links
748
-					if($content['links'])
746
+					if ($content['links'])
749 747
 					{
750 748
 						Link::link('calendar', $event['id'], $content['links']['to_id']);
751 749
 					}
752 750
 
753
-					if(Api\Json\Response::isJSONResponse())
751
+					if (Api\Json\Response::isJSONResponse())
754 752
 					{
755 753
 						// Sending null will trigger a removal of the original
756 754
 						// for that date
@@ -758,7 +756,7 @@  discard block
 block discarded – undo
758 756
 					}
759 757
 
760 758
 					unset($recur_event);
761
-					unset($event['edit_single']);			// if we further edit it, it's just a single event
759
+					unset($event['edit_single']); // if we further edit it, it's just a single event
762 760
 					unset($preserv['edit_single']);
763 761
 				}
764 762
 				else	// conflict or error, we need to reset everything to the state befor we tried to save it
@@ -789,8 +787,8 @@  discard block
 block discarded – undo
789 787
 							{
790 788
 								$offset = $off2;
791 789
 							}
792
-							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']);
793
-							if($msg)
790
+							$msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']);
791
+							if ($msg)
794 792
 							{
795 793
 								$noerror = false;
796 794
 							}
@@ -803,10 +801,10 @@  discard block
 block discarded – undo
803 801
 							$event['whole_day'] != $old_event['whole_day'])
804 802
 						{
805 803
 							$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
806
-							foreach((array)$event['participants'] as $uid => $status)
804
+							foreach ((array)$event['participants'] as $uid => $status)
807 805
 							{
808 806
 								$q = $r = null;
809
-								calendar_so::split_status($status,$q,$r);
807
+								calendar_so::split_status($status, $q, $r);
810 808
 								if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
811 809
 								{
812 810
 									$preferences = new Api\Preferences($uid);
@@ -819,7 +817,7 @@  discard block
 block discarded – undo
819 817
 											if ($sameday) break;
820 818
 										default:
821 819
 											$status_reset_to_unknown = true;
822
-											$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
820
+											$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
823 821
 											// todo: report reset status to user
824 822
 									}
825 823
 								}
@@ -837,43 +835,43 @@  discard block
 block discarded – undo
837 835
 				}
838 836
 				// Adding participants needs to be done as an edit, in case we
839 837
 				// have participants visible in seperate calendars
840
-				if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
838
+				if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants'])))
841 839
 				{
842 840
 					$update_type = 'edit';
843 841
 				}
844 842
 				// Changing category may affect event filtering
845
-				if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
843
+				if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category'])
846 844
 				{
847 845
 					$update_type = 'edit';
848 846
 				}
849
-				$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
847
+				$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']);
850 848
 				unset($event['ignore']);
851 849
 			}
852 850
 			if (is_array($conflicts))
853 851
 			{
854
-				$event['button_was'] = $button;	// remember for ignore
855
-				return $this->conflicts($event,$conflicts,$preserv);
852
+				$event['button_was'] = $button; // remember for ignore
853
+				return $this->conflicts($event, $conflicts, $preserv);
856 854
 			}
857 855
 
858 856
 			// Event spans multiple days, need an edit to make sure they all get updated
859 857
 			// We could check old date, as removing from days could still be an update
860
-			if(date('Ymd', $event['start']) != date('Ymd', $event['end']))
858
+			if (date('Ymd', $event['start']) != date('Ymd', $event['end']))
861 859
 			{
862 860
 				$update_type = 'edit';
863 861
 			}
864 862
 			// check if there are messages from update, eg. removed participants or Api\Categories because of missing rights
865 863
 			if ($messages)
866 864
 			{
867
-				$msg  .= ($msg ? ', ' : '').implode(', ',$messages);
865
+				$msg .= ($msg ? ', ' : '').implode(', ', $messages);
868 866
 			}
869 867
 			if ($conflicts === 0)
870 868
 			{
871
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
872
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
873
-								htmlspecialchars(Egw::link('/index.php',array(
869
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
870
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
871
+								htmlspecialchars(Egw::link('/index.php', array(
874 872
 								'menuaction' => 'calendar.calendar_uiforms.edit',
875 873
 								'cal_id'    => $content['id'],
876
-							))).'">','</a>');
874
+							))).'">', '</a>');
877 875
 				$noerror = false;
878 876
 			}
879 877
 			elseif ($conflicts > 0)
@@ -895,19 +893,19 @@  discard block
 block discarded – undo
895 893
 						// if alarm would be in the past (eg. event moved back) --> move to next possible recurrence
896 894
 						if ($alarm['time'] < $this->bo->now_su)
897 895
 						{
898
-							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true)))
896
+							if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true)))
899 897
 							{
900
-								$alarm['time'] =  $next_occurrence['start'] - $alarm['offset'];
898
+								$alarm['time'] = $next_occurrence['start'] - $alarm['offset'];
901 899
 							}
902 900
 							else
903 901
 							{
904
-								$alarm = false;	// no (further) recurence found --> ignore alarm
902
+								$alarm = false; // no (further) recurence found --> ignore alarm
905 903
 							}
906 904
 						}
907 905
 						// alarm is currently on a previous recurrence --> set for first recurrence of new series
908 906
 						elseif ($event_time < $event['start'])
909 907
 						{
910
-							$alarm['time'] =  $event['start'] - $alarm['offset'];
908
+							$alarm['time'] = $event['start'] - $alarm['offset'];
911 909
 						}
912 910
 						if ($alarm)
913 911
 						{
@@ -916,9 +914,9 @@  discard block
 block discarded – undo
916 914
 						}
917 915
 					}
918 916
 					// attach all future exceptions to the new series
919
-					$events =& $this->bo->search(array(
917
+					$events = & $this->bo->search(array(
920 918
 						'query' => array('cal_uid' => $old_event['uid']),
921
-						'filter' => 'owner',  // return all possible entries
919
+						'filter' => 'owner', // return all possible entries
922 920
 						'daywise' => false,
923 921
 						'date_format' => 'ts',
924 922
 					));
@@ -929,7 +927,7 @@  discard block
 block discarded – undo
929 927
 							$exception['recurrence'] += $offset;
930 928
 							$exception['reference'] = $event['id'];
931 929
 							$exception['uid'] = $event['uid'];
932
-							$this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']);
930
+							$this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']);
933 931
 						}
934 932
 					}
935 933
 				}
@@ -937,12 +935,12 @@  discard block
 block discarded – undo
937 935
 				$message = lang('Event saved');
938 936
 				if ($status_reset_to_unknown)
939 937
 				{
940
-					foreach((array)$event['participants'] as $uid => $status)
938
+					foreach ((array)$event['participants'] as $uid => $status)
941 939
 					{
942 940
 						if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
943 941
 						{
944
-							calendar_so::split_status($status,$q,$r);
945
-							$status = calendar_so::combine_status('U',$q,$r);
942
+							calendar_so::split_status($status, $q, $r);
943
+							$status = calendar_so::combine_status('U', $q, $r);
946 944
 							$this->bo->set_status($event['id'], $uid, $status, 0, true);
947 945
 						}
948 946
 					}
@@ -950,17 +948,17 @@  discard block
 block discarded – undo
950 948
 				}
951 949
 
952 950
 				$response = Api\Json\Response::get();
953
-				if($response && $update_type != 'delete')
951
+				if ($response && $update_type != 'delete')
954 952
 				{
955 953
 					$client_updated = $this->update_client($event['id']);
956 954
 				}
957 955
 
958
-				$msg = $message . ($msg ? ', ' . $msg : '');
956
+				$msg = $message.($msg ? ', '.$msg : '');
959 957
 				Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete');
960 958
 				// writing links for new entry, existing ones are handled by the widget itself
961 959
 				if (!$content['id'] && is_array($content['link_to']['to_id']))
962 960
 				{
963
-					Link::link('calendar',$event['id'],$content['link_to']['to_id']);
961
+					Link::link('calendar', $event['id'], $content['link_to']['to_id']);
964 962
 				}
965 963
 			}
966 964
 			else
@@ -970,7 +968,7 @@  discard block
 block discarded – undo
970 968
 			break;
971 969
 
972 970
 		case 'cancel':
973
-			if($content['cancel_needs_refresh'])
971
+			if ($content['cancel_needs_refresh'])
974 972
 			{
975 973
 				Framework::refresh_opener($msg, 'calendar');
976 974
 			}
@@ -1008,7 +1006,7 @@  discard block
 block discarded – undo
1008 1006
 			{
1009 1007
 				$content['new_alarm']['date'] = $next_occurrence['start'] - $offset;
1010 1008
 			}
1011
-			if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner']))
1009
+			if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner']))
1012 1010
 			{
1013 1011
 				$alarm = array(
1014 1012
 					'offset' => $offset,
@@ -1022,13 +1020,13 @@  discard block
 block discarded – undo
1022 1020
 				}
1023 1021
 				elseif ($event['id'])	// save the alarm immediatly
1024 1022
 				{
1025
-					if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm)))
1023
+					if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm)))
1026 1024
 					{
1027 1025
 						$alarm['id'] = $alarm_id;
1028 1026
 						$event['alarm'][$alarm_id] = $alarm;
1029 1027
 
1030 1028
 						$msg = lang('Alarm added');
1031
-						Framework::refresh_opener($msg,'calendar', $event['id'], 'update');
1029
+						Framework::refresh_opener($msg, 'calendar', $event['id'], 'update');
1032 1030
 					}
1033 1031
 					else
1034 1032
 					{
@@ -1037,7 +1035,7 @@  discard block
 block discarded – undo
1037 1035
 				}
1038 1036
 				else
1039 1037
 				{
1040
-					for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1038
+					for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {}	// get a temporary non-conflicting, numeric id
1041 1039
 					$event['alarm'][$alarm['id']] = $alarm;
1042 1040
 				}
1043 1041
 			}
@@ -1054,31 +1052,31 @@  discard block
 block discarded – undo
1054 1052
 		}
1055 1053
 		// New event, send data before updating so it's there
1056 1054
 		$response = Api\Json\Response::get();
1057
-		if($response && !$content['id'] && $event['id'])
1055
+		if ($response && !$content['id'] && $event['id'])
1058 1056
 		{
1059 1057
 			$client_updated = $this->update_client($event['id']);
1060 1058
 		}
1061
-		if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror)
1059
+		if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror)
1062 1060
 		{
1063 1061
 			if ($content['lock_token'])	// remove an existing lock
1064 1062
 			{
1065
-				Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false);
1063
+				Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false);
1066 1064
 			}
1067 1065
 			if ($content['no_popup'])
1068 1066
 			{
1069
-				Egw::redirect_link('/index.php',array(
1067
+				Egw::redirect_link('/index.php', array(
1070 1068
 					'menuaction' => 'calendar.calendar_uiviews.index',
1071 1069
 					'msg'        => $msg,
1072 1070
 				));
1073 1071
 			}
1074
-			if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1072
+			if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete')
1075 1073
 			{
1076
-				Framework::refresh_opener($msg,'calendar');
1074
+				Framework::refresh_opener($msg, 'calendar');
1077 1075
 			}
1078 1076
 			else
1079 1077
 			{
1080 1078
 				Framework::refresh_opener($msg, 'calendar',
1081
-					$event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ),
1079
+					$event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''),
1082 1080
 					$button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete'
1083 1081
 				);
1084 1082
 			}
@@ -1086,7 +1084,7 @@  discard block
 block discarded – undo
1086 1084
 			exit();
1087 1085
 		}
1088 1086
 		unset($event['no_notifications']);
1089
-		return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']);
1087
+		return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']);
1090 1088
 	}
1091 1089
 
1092 1090
 	/**
@@ -1098,7 +1096,7 @@  discard block
 block discarded – undo
1098 1096
 	 * @param array &$preserv
1099 1097
 	 * @return string message that exception was created
1100 1098
 	 */
1101
-	function _create_exception(&$event,&$preserv)
1099
+	function _create_exception(&$event, &$preserv)
1102 1100
 	{
1103 1101
 		// In some cases where the user makes the first day an exception, actual_date may be missing
1104 1102
 		$preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start'];
@@ -1108,25 +1106,25 @@  discard block
 block discarded – undo
1108 1106
 		$event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date'];
1109 1107
 		$event['start'] = $preserv['edit_single'] = $preserv['actual_date'];
1110 1108
 		$event['recur_type'] = MCAL_RECUR_NONE;
1111
-		foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name)
1109
+		foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name)
1112 1110
 		{
1113 1111
 			unset($event[$name]);
1114 1112
 		}
1115 1113
 		// add all alarms as new alarms to execption
1116 1114
 		$event['alarm'] = array_values((array)$event['alarm']);
1117
-		foreach($event['alarm'] as &$alarm)
1115
+		foreach ($event['alarm'] as &$alarm)
1118 1116
 		{
1119 1117
 			unset($alarm['uid'], $alarm['id'], $alarm['time']);
1120 1118
 		}
1121 1119
 
1122 1120
 		// Copy links
1123
-		if(!is_array($event['link_to'])) $event['link_to'] = array();
1121
+		if (!is_array($event['link_to'])) $event['link_to'] = array();
1124 1122
 		$event['link_to']['to_app'] = 'calendar';
1125 1123
 		$event['link_to']['to_id'] = 0;
1126 1124
 
1127
-		foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1125
+		foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link)
1128 1126
 		{
1129
-			if(!$link['id']) continue;
1127
+			if (!$link['id']) continue;
1130 1128
 			if ($link['app'] != Link::VFS_APPNAME)
1131 1129
 			{
1132 1130
 				Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']);
@@ -1142,7 +1140,7 @@  discard block
 block discarded – undo
1142 1140
 
1143 1141
 		$event['links'] = $event['link_to'];
1144 1142
 
1145
-		if($this->bo->check_perms(Acl::EDIT,$event))
1143
+		if ($this->bo->check_perms(Acl::EDIT, $event))
1146 1144
 		{
1147 1145
 			return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day');
1148 1146
 		}
@@ -1169,14 +1167,14 @@  discard block
 block discarded – undo
1169 1167
 	{
1170 1168
 		$msg = false;
1171 1169
 
1172
-		if(!$as_of_date )
1170
+		if (!$as_of_date)
1173 1171
 		{
1174 1172
 			$as_of_date = time();
1175 1173
 		}
1176 1174
 
1177 1175
 		//error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date));
1178 1176
 
1179
-		if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1177
+		if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true)))
1180 1178
 		{
1181 1179
 			$msg = lang("Error: You can't shift a series from the past!");
1182 1180
 			return $msg;
@@ -1189,11 +1187,11 @@  discard block
 block discarded – undo
1189 1187
 		$duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start'];
1190 1188
 
1191 1189
 		// base start-date of new series on actual / clicked date
1192
-		$event['start'] = $as_of_date ;
1190
+		$event['start'] = $as_of_date;
1193 1191
 
1194
-		if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') ||
1192
+		if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') ||
1195 1193
 			// Adjust for requested date in the past
1196
-			Api\DateTime::to($as_of_date,'ts') < time()
1194
+			Api\DateTime::to($as_of_date, 'ts') < time()
1197 1195
 		)
1198 1196
 		{
1199 1197
 
@@ -1213,17 +1211,17 @@  discard block
 block discarded – undo
1213 1211
 				$rriter->next_no_exception();
1214 1212
 				$occurrence = $rriter->current();
1215 1213
 			}
1216
-			while ($rriter->valid()  && (
1214
+			while ($rriter->valid() && (
1217 1215
 				Api\DateTime::to($occurrence, 'ts') <= time() ||
1218
-				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd')
1216
+				Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd')
1219 1217
 			) && ($last = $occurrence));
1220 1218
 
1221 1219
 
1222 1220
 			// Make sure as_of_date is still valid, may have to move forward
1223
-			if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') ||
1221
+			if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') ||
1224 1222
 				Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd'))
1225 1223
 			{
1226
-				$event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset;
1224
+				$event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset;
1227 1225
 			}
1228 1226
 
1229 1227
 			//error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start']));
@@ -1231,7 +1229,7 @@  discard block
 block discarded – undo
1231 1229
 			{
1232 1230
 				$event['end'] = $event['start'] + $duration;
1233 1231
 			}
1234
-			elseif($event['end'] < $event['start'])
1232
+			elseif ($event['end'] < $event['start'])
1235 1233
 			{
1236 1234
 				$event['end'] = $old_event['end'] - $old_event['start'] + $event['start'];
1237 1235
 			}
@@ -1240,7 +1238,7 @@  discard block
 block discarded – undo
1240 1238
 			$event['participants'] = $old_event['participants'];
1241 1239
 			foreach ($old_event['recur_exception'] as $key => $exdate)
1242 1240
 			{
1243
-				if ($exdate > Api\DateTime::to($last,'ts'))
1241
+				if ($exdate > Api\DateTime::to($last, 'ts'))
1244 1242
 				{
1245 1243
 					//error_log("Moved exception on " . Api\DateTime::to($exdate));
1246 1244
 					unset($old_event['recur_exception'][$key]);
@@ -1254,18 +1252,18 @@  discard block
 block discarded – undo
1254 1252
 			}
1255 1253
 			$last->setTime(0, 0, 0);
1256 1254
 			$old_event['recur_enddate'] = Api\DateTime::to($last, 'ts');
1257
-			if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications))
1255
+			if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications))
1258 1256
 			{
1259
-				$msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1260
-					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1261
-						htmlspecialchars(Egw::link('/index.php',array(
1257
+				$msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1258
+					lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1259
+						htmlspecialchars(Egw::link('/index.php', array(
1262 1260
 							'menuaction' => 'calendar.calendar_uiforms.edit',
1263 1261
 							'cal_id'    => $event['id'],
1264
-						))).'">','</a>');
1262
+						))).'">', '</a>');
1265 1263
 				$event = $orig_event;
1266 1264
 			}
1267 1265
 		}
1268
-		$event['start'] = Api\DateTime::to($event['start'],'ts');
1266
+		$event['start'] = Api\DateTime::to($event['start'], 'ts');
1269 1267
 		return $msg;
1270 1268
 	}
1271 1269
 
@@ -1276,11 +1274,11 @@  discard block
 block discarded – undo
1276 1274
 	 * @param boolean $added
1277 1275
 	 * @return string javascript window.open command
1278 1276
 	 */
1279
-	function ajax_custom_mail($event,$added,$asrequest=false)
1277
+	function ajax_custom_mail($event, $added, $asrequest = false)
1280 1278
 	{
1281 1279
 		$to = array();
1282 1280
 
1283
-		foreach($event['participants'] as $uid => $status)
1281
+		foreach ($event['participants'] as $uid => $status)
1284 1282
 		{
1285 1283
 			//error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status));
1286 1284
 			if (empty($status)) continue;
@@ -1289,32 +1287,32 @@  discard block
 block discarded – undo
1289 1287
 
1290 1288
 			if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u')
1291 1289
 			{
1292
-				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue;
1290
+				if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue;
1293 1291
 
1294 1292
 				$toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '.
1295 1293
 					$GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>';
1296 1294
 
1297
-				if (!in_array($toadd,$to)) $to[] = $toadd;
1295
+				if (!in_array($toadd, $to)) $to[] = $toadd;
1298 1296
 			}
1299 1297
 			elseif ($uid < 0)
1300 1298
 			{
1301
-				foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid)
1299
+				foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid)
1302 1300
 				{
1303
-					if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue;
1301
+					if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue;
1304 1302
 
1305 1303
 					$toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1306 1304
 						$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>';
1307 1305
 
1308 1306
 					// dont add groupmembers if they already rejected the event, or are the current user
1309
-					if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1307
+					if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd;
1310 1308
 				}
1311 1309
 			}
1312
-			elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid'])))
1310
+			elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid'])))
1313 1311
 			{
1314 1312
 				$to[] = $info['email'];
1315 1313
 				//error_log(__METHOD__.__LINE__.array2string($to));
1316 1314
 			}
1317
-			elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid)))
1315
+			elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid)))
1318 1316
 			{
1319 1317
 				$to[] = $info['email'];
1320 1318
 				//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1323,7 +1321,7 @@  discard block
 block discarded – undo
1323 1321
 		// prefer event description over standard notification text
1324 1322
 		if (empty($event['description']))
1325 1323
 		{
1326
-			list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED);	// update-message is in TZ of the user
1324
+			list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user
1327 1325
 		}
1328 1326
 		else
1329 1327
 		{
@@ -1338,12 +1336,12 @@  discard block
 block discarded – undo
1338 1336
 		$boical = new calendar_ical();
1339 1337
 		// we need to pass $event[id] so iCal class reads event again,
1340 1338
 		// as event is in user TZ, but iCal class expects server TZ!
1341
-		$ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false);
1339
+		$ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false);
1342 1340
 
1343
-		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics');
1344
-		if(($f = fopen($ics_file,'w')))
1341
+		$ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics');
1342
+		if (($f = fopen($ics_file, 'w')))
1345 1343
 		{
1346
-			fwrite($f,$ics);
1344
+			fwrite($f, $ics);
1347 1345
 			fclose($f);
1348 1346
 		}
1349 1347
 		//error_log(__METHOD__.__LINE__.array2string($to));
@@ -1355,7 +1353,7 @@  discard block
 block discarded – undo
1355 1353
 			'preset[body]'    => $body,
1356 1354
 			'preset[name]'    => 'event.ics',
1357 1355
 			'preset[file]'    => $ics_file,
1358
-			'preset[type]'    => 'text/calendar'.($asrequest?'; method=REQUEST':''),
1356
+			'preset[type]'    => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''),
1359 1357
 			'preset[size]'    => filesize($ics_file),
1360 1358
 		);
1361 1359
 		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.');
@@ -1411,7 +1409,7 @@  discard block
 block discarded – undo
1411 1409
 	 * @param mixed $link_to_id ='' from or for the link-widget
1412 1410
 	 * @param string $msg_type =null default automatic detect, if it contains "error"
1413 1411
 	 */
1414
-	function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null)
1412
+	function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null)
1415 1413
 	{
1416 1414
 		$sel_options = array(
1417 1415
 			'recur_type' => &$this->bo->recur_types,
@@ -1435,8 +1433,8 @@  discard block
 block discarded – undo
1435 1433
 				'no_popup' => isset($_GET['no_popup']),
1436 1434
 				'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'),
1437 1435
 			);
1438
-			$cal_id = (int) $_GET['cal_id'];
1439
-			if($_GET['action'])
1436
+			$cal_id = (int)$_GET['cal_id'];
1437
+			if ($_GET['action'])
1440 1438
 			{
1441 1439
 				$event = $this->bo->read($cal_id);
1442 1440
 				$event['action'] = $_GET['action'];
@@ -1454,14 +1452,14 @@  discard block
 block discarded – undo
1454 1452
 			{
1455 1453
 				//error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!");
1456 1454
 				$msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs'];
1457
-				$event =& $this->default_add_event();
1455
+				$event = & $this->default_add_event();
1458 1456
 			}
1459 1457
 			if (!empty($_GET['ical_data']) &&
1460 1458
 				!($_GET['ical'] = Link::get_data($_GET['ical_data'])))
1461 1459
 			{
1462 1460
 				//error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!");
1463 1461
 				$msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data'];
1464
-				$event =& $this->default_add_event();
1462
+				$event = & $this->default_add_event();
1465 1463
 			}
1466 1464
 			if (!empty($_GET['ical']))
1467 1465
 			{
@@ -1470,14 +1468,14 @@  discard block
 block discarded – undo
1470 1468
 				{
1471 1469
 					error_log(__METHOD__."('$_GET[ical]') error parsing iCal!");
1472 1470
 					$msg = lang('Error: importing the iCal');
1473
-					$event =& $this->default_add_event();
1471
+					$event = & $this->default_add_event();
1474 1472
 				}
1475 1473
 				else
1476 1474
 				{
1477 1475
 					if (count($events) > 1)
1478 1476
 					{
1479 1477
 						$msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events));
1480
-						$msg_type = 'notice';	// no not hide automatic
1478
+						$msg_type = 'notice'; // no not hide automatic
1481 1479
 					}
1482 1480
 					// as icaltoegw returns timestamps in server-time, we have to convert them here to user-time
1483 1481
 					$this->bo->db2data($events, 'ts');
@@ -1490,7 +1488,7 @@  discard block
 block discarded – undo
1490 1488
 					else
1491 1489
 					{
1492 1490
 						$event['participant_types'] = array();
1493
-						foreach($event['participants'] as $uid => $status)
1491
+						foreach ($event['participants'] as $uid => $status)
1494 1492
 						{
1495 1493
 							$user_type = $user_id = null;
1496 1494
 							calendar_so::split_user($uid, $user_type, $user_id);
@@ -1511,15 +1509,15 @@  discard block
 block discarded – undo
1511 1509
 					}
1512 1510
 					else
1513 1511
 					{
1514
-						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true);
1512
+						$GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true);
1515 1513
 						exit();
1516 1514
 					}
1517 1515
 				}
1518
-				$event =& $this->default_add_event();
1516
+				$event = & $this->default_add_event();
1519 1517
 			}
1520 1518
 			else
1521 1519
 			{
1522
-				$preserv['actual_date'] = $event['start'];		// remember the date clicked
1520
+				$preserv['actual_date'] = $event['start']; // remember the date clicked
1523 1521
 				if ($event['recur_type'] != MCAL_RECUR_NONE)
1524 1522
 				{
1525 1523
 					if (empty($event['whole_day']))
@@ -1532,10 +1530,10 @@  discard block
 block discarded – undo
1532 1530
 						$date->setUser();
1533 1531
 					}
1534 1532
 					$event = $this->bo->read($cal_id, $date, true);
1535
-					$preserv['actual_date'] = $event['start'];		// remember the date clicked
1533
+					$preserv['actual_date'] = $event['start']; // remember the date clicked
1536 1534
 					if ($_GET['exception'])
1537 1535
 					{
1538
-						$msg = $this->_create_exception($event,$preserv);
1536
+						$msg = $this->_create_exception($event, $preserv);
1539 1537
 					}
1540 1538
 					else
1541 1539
 					{
@@ -1544,9 +1542,9 @@  discard block
 block discarded – undo
1544 1542
 				}
1545 1543
 			}
1546 1544
 			// set new start and end if given by $_GET
1547
-			if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); }
1548
-			if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); }
1549
-			if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1545
+			if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); }
1546
+			if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); }
1547
+			if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; }
1550 1548
 			// check if the event is the whole day
1551 1549
 			$start = $this->bo->date2array($event['start']);
1552 1550
 			$end = $this->bo->date2array($event['end']);
@@ -1556,30 +1554,30 @@  discard block
 block discarded – undo
1556 1554
 			if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']))
1557 1555
 			{
1558 1556
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
1559
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1557
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
1560 1558
 				{
1561 1559
 					$link_id = $link_ids[$n];
1562
-					if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// guard against XSS
1560
+					if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// guard against XSS
1563 1561
 					{
1564 1562
 						continue;
1565 1563
 					}
1566
-					if(!$n)
1564
+					if (!$n)
1567 1565
 					{
1568
-						$event['title'] = Link::title($link_app,$link_id);
1566
+						$event['title'] = Link::title($link_app, $link_id);
1569 1567
 						// ask first linked app via "calendar_set" hook, for further data to set, incl. links
1570
-						if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app)))
1568
+						if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app)))
1571 1569
 						{
1572
-							foreach((array)$set['link_app'] as $i => $l_app)
1570
+							foreach ((array)$set['link_app'] as $i => $l_app)
1573 1571
 							{
1574
-								if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id);
1572
+								if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id);
1575 1573
 							}
1576 1574
 							unset($set['link_app']);
1577 1575
 							unset($set['link_id']);
1578 1576
 
1579
-							$event = array_merge($event,$set);
1577
+							$event = array_merge($event, $set);
1580 1578
 						}
1581 1579
 					}
1582
-					Link::link('calendar',$link_to_id,$link_app,$link_id);
1580
+					Link::link('calendar', $link_to_id, $link_app, $link_id);
1583 1581
 				}
1584 1582
 			}
1585 1583
 		}
@@ -1589,44 +1587,44 @@  discard block
 block discarded – undo
1589 1587
 		{
1590 1588
 			$etpl->read($preserv['template'] = 'calendar.edit');
1591 1589
 		}
1592
-		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event);
1590
+		$view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event);
1593 1591
 		//echo "view=$view, event="; _debug_array($event);
1594 1592
 		// shared locking of entries to edit
1595 1593
 		if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id'])
1596 1594
 		{
1597
-			$lock_path = Vfs::app_entry_lock_path('calendar',$event['id']);
1595
+			$lock_path = Vfs::app_entry_lock_path('calendar', $event['id']);
1598 1596
 			$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1599 1597
 
1600 1598
 			if (($preserv['lock_token'] = $event['lock_token']))		// already locked --> refresh the lock
1601 1599
 			{
1602
-				Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false);
1600
+				Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false);
1603 1601
 			}
1604 1602
 			if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner)
1605 1603
 			{
1606 1604
 				$msg .= ' '.lang('This entry is currently opened by %1!',
1607
-					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ?
1605
+					(($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ?
1608 1606
 					Api\Accounts::username($lock_uid) : $lock['owner']));
1609 1607
 			}
1610
-			elseif($lock)
1608
+			elseif ($lock)
1611 1609
 			{
1612 1610
 				$preserv['lock_token'] = $lock['token'];
1613 1611
 			}
1614
-			elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false))
1612
+			elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false))
1615 1613
 			{
1616 1614
 				//We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button
1617 1615
 			}
1618 1616
 			else
1619 1617
 			{
1620
-				$msg .= ' '.lang("Can't aquire lock!");		// eg. an exclusive lock via CalDAV ...
1618
+				$msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ...
1621 1619
 				$view = true;
1622 1620
 			}
1623 1621
 		}
1624
-		$content = array_merge($event,array(
1622
+		$content = array_merge($event, array(
1625 1623
 			'link_to' => array(
1626 1624
 				'to_id'  => $link_to_id,
1627 1625
 				'to_app' => 'calendar',
1628 1626
 			),
1629
-			'edit_single' => $preserv['edit_single'],	// need to be in content too, as it is used in the template
1627
+			'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template
1630 1628
 			'tabs'   => $preserv['tabs'],
1631 1629
 			'view' => $view,
1632 1630
 			'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']),
@@ -1638,11 +1636,11 @@  discard block
 block discarded – undo
1638 1636
 		$row = 3;
1639 1637
 		$readonlys = $content['participants'] = $preserv['participants'] = array();
1640 1638
 		// preserve some ui elements, if set eg. under error-conditions
1641
-		foreach(array('quantity','resource','role') as $n)
1639
+		foreach (array('quantity', 'resource', 'role') as $n)
1642 1640
 		{
1643 1641
 			if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
1644 1642
 		}
1645
-		foreach($event['participant_types'] as $type => $participants)
1643
+		foreach ($event['participant_types'] as $type => $participants)
1646 1644
 		{
1647 1645
 			$name = 'accounts';
1648 1646
 			if (isset($this->bo->resources[$type]))
@@ -1651,17 +1649,17 @@  discard block
 block discarded – undo
1651 1649
 			}
1652 1650
 			// sort participants (in there group/app) by title
1653 1651
 			uksort($participants, array($this, 'uid_title_cmp'));
1654
-			foreach($participants as $id => $status)
1652
+			foreach ($participants as $id => $status)
1655 1653
 			{
1656 1654
 				$uid = $type == 'u' ? $id : $type.$id;
1657 1655
 				$quantity = $role = null;
1658
-				calendar_so::split_status($status,$quantity,$role);
1656
+				calendar_so::split_status($status, $quantity, $role);
1659 1657
 				$preserv['participants'][$row] = $content['participants'][$row] = array(
1660 1658
 					'app'      => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name,
1661 1659
 					'uid'      => $uid,
1662 1660
 					'status'   => $status,
1663 1661
 					'old_status' => $status,
1664
-					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '',	// only display quantity for resources or if > 1
1662
+					'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1
1665 1663
 					'role'     => $role,
1666 1664
 				);
1667 1665
 				// replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT
@@ -1670,33 +1668,33 @@  discard block
 block discarded – undo
1670 1668
 					$content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]);
1671 1669
 				}
1672 1670
 				// allow third party apps to use categories for roles
1673
-				elseif(substr($role,0,6) == 'X-CAT-')
1671
+				elseif (substr($role, 0, 6) == 'X-CAT-')
1674 1672
 				{
1675
-					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6));
1673
+					$content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6));
1676 1674
 				}
1677 1675
 				else
1678 1676
 				{
1679
-					$content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role));
1677
+					$content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role));
1680 1678
 				}
1681
-				$content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid;
1679
+				$content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid;
1682 1680
 				//echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n";
1683 1681
 
1684
-				if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view)
1682
+				if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view)
1685 1683
 					$readonlys['participants'][$row]['status'] = $no_status;
1686
-				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event))
1684
+				if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event))
1687 1685
 					$readonlys['participants']['delete'][$uid] = true;
1688 1686
 				// todo: make the participants available as links with email as title
1689 1687
 				$content['participants'][$row++]['title'] = $this->get_title($uid);
1690 1688
 				// enumerate group-invitations, so people can accept/reject them
1691 1689
 				if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' &&
1692
-					($members = $GLOBALS['egw']->accounts->members($id,true)))
1690
+					($members = $GLOBALS['egw']->accounts->members($id, true)))
1693 1691
 				{
1694 1692
 					$sel_options['status']['G'] = lang('Select one');
1695 1693
 					// sort members by title
1696 1694
 					usort($members, array($this, 'uid_title_cmp'));
1697
-					foreach($members as $member)
1695
+					foreach ($members as $member)
1698 1696
 					{
1699
-						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member))
1697
+						if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member))
1700 1698
 						{
1701 1699
 							$preserv['participants'][$row] = $content['participants'][$row] = array(
1702 1700
 								'app'      => 'Group invitation',
@@ -1705,7 +1703,7 @@  discard block
 block discarded – undo
1705 1703
 							);
1706 1704
 							$readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true;
1707 1705
 							// read access is enough to invite participants, but you need edit rights to change status
1708
-							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member);
1706
+							$readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member);
1709 1707
 							$content['participants'][$row++]['title'] = Api\Accounts::username($member);
1710 1708
 						}
1711 1709
 					}
@@ -1713,43 +1711,43 @@  discard block
 block discarded – undo
1713 1711
 			}
1714 1712
 			// resouces / apps we shedule, atm. resources and addressbook
1715 1713
 			$content['participants']['cal_resources'] = '';
1716
-			foreach($this->bo->resources as $data)
1714
+			foreach ($this->bo->resources as $data)
1717 1715
 			{
1718
-				if ($data['app'] == 'email') continue;	// make no sense, as we cant search for email
1716
+				if ($data['app'] == 'email') continue; // make no sense, as we cant search for email
1719 1717
 				$content['participants']['cal_resources'] .= ','.$data['app'];
1720 1718
 			}
1721 1719
 		}
1722 1720
 		$content['participants']['status_date'] = $preserv['actual_date'];
1723
-		$preserved = array_merge($preserv,$content);
1721
+		$preserved = array_merge($preserv, $content);
1724 1722
 		$event['new_alarm']['options'] = $content['new_alarm']['options'];
1725 1723
 		if ($event['alarm'])
1726 1724
 		{
1727 1725
 			// makes keys of the alarm-array starting with 1
1728 1726
 			$content['alarm'] = array(false);
1729
-			foreach(array_values($event['alarm']) as $id => $alarm)
1727
+			foreach (array_values($event['alarm']) as $id => $alarm)
1730 1728
 			{
1731
-				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner']))
1729
+				if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner']))
1732 1730
 				{
1733
-					continue;	// no read rights to the calendar of the alarm-owner, dont show the alarm
1731
+					continue; // no read rights to the calendar of the alarm-owner, dont show the alarm
1734 1732
 				}
1735
-				$alarm['all'] = (int) $alarm['all'];
1733
+				$alarm['all'] = (int)$alarm['all'];
1736 1734
 				$after = false;
1737
-				if($alarm['offset'] < 0)
1735
+				if ($alarm['offset'] < 0)
1738 1736
 				{
1739 1737
 					$after = true;
1740 1738
 					$alarm['offset'] = -1 * $alarm['offset'];
1741 1739
 				}
1742
-				$days = (int) ($alarm['offset'] / DAY_s);
1743
-				$hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s);
1744
-				$minutes = (int) (($alarm['offset'] % HOUR_s) / 60);
1740
+				$days = (int)($alarm['offset'] / DAY_s);
1741
+				$hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s);
1742
+				$minutes = (int)(($alarm['offset'] % HOUR_s) / 60);
1745 1743
 				$label = array();
1746 1744
 				if ($days) $label[] = $days.' '.lang('days');
1747 1745
 				if ($hours) $label[] = $hours.' '.lang('hours');
1748 1746
 				if ($minutes) $label[] = $minutes.' '.lang('Minutes');
1749
-				$alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before'));
1747
+				$alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before'));
1750 1748
 				$content['alarm'][] = $alarm;
1751 1749
 
1752
-				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']);
1750
+				$readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']);
1753 1751
 			}
1754 1752
 			if (count($content['alarm']) == 1)
1755 1753
 			{
@@ -1764,20 +1762,20 @@  discard block
 block discarded – undo
1764 1762
 
1765 1763
 		if ($view)
1766 1764
 		{
1767
-			$readonlys['__ALL__'] = true;	// making everything readonly, but widgets set explicitly to false
1765
+			$readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false
1768 1766
 			$readonlys['button[cancel]'] = $readonlys['action'] =
1769 1767
 				$readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] =
1770 1768
 				$readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false;
1771 1769
 
1772 1770
 			$content['participants']['no_add'] = true;
1773 1771
 
1774
-			if(!$event['whole_day'])
1772
+			if (!$event['whole_day'])
1775 1773
 			{
1776 1774
 				$etpl->setElementAttribute('whole_day', 'disabled', true);
1777 1775
 			}
1778 1776
 
1779 1777
 			// respect category permissions
1780
-			if(!empty($event['category']))
1778
+			if (!empty($event['category']))
1781 1779
 			{
1782 1780
 				$content['category'] = $this->categories->check_list(Acl::READ, $event['category']);
1783 1781
 			}
@@ -1788,7 +1786,7 @@  discard block
 block discarded – undo
1788 1786
 
1789 1787
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1790 1788
 			{
1791
-				$readonlys['recur_exception'] = !count($content['recur_exception']);	// otherwise we get a delete button
1789
+				$readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button
1792 1790
 				//$onclick =& $etpl->get_cell_attribute('button[delete]','onclick');
1793 1791
 				//$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick);
1794 1792
 			}
@@ -1798,9 +1796,9 @@  discard block
 block discarded – undo
1798 1796
 				$readonlys['recur_interval'] = $readonlys['recur_data'] = true;
1799 1797
 			}
1800 1798
 		}
1801
-		if($content['category'] && !is_array($content['category']))
1799
+		if ($content['category'] && !is_array($content['category']))
1802 1800
 		{
1803
-			$content['category'] = explode(',',$event['category']);
1801
+			$content['category'] = explode(',', $event['category']);
1804 1802
 		}
1805 1803
 		// disabling the custom fields tab, if there are none
1806 1804
 		$readonlys['tabs'] = array(
@@ -1817,13 +1815,13 @@  discard block
 block discarded – undo
1817 1815
 		{
1818 1816
 			$readonlys['action'] = true;
1819 1817
 		}
1820
-		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'])))
1818
+		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'])))
1821 1819
 		{
1822 1820
 			$content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start']));
1823 1821
 		}
1824
-		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event);
1822
+		$readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event);
1825 1823
 
1826
-		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
1824
+		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
1827 1825
 		{
1828 1826
 			$sel_options['owner'][0] = lang('All participants');
1829 1827
 		}
@@ -1831,26 +1829,26 @@  discard block
 block discarded – undo
1831 1829
 		{
1832 1830
 			$sel_options['owner'][$this->user] = $this->bo->participant_name($this->user);
1833 1831
 		}
1834
-		foreach((array) $event['participant_types']['u'] as $uid => $status)
1832
+		foreach ((array)$event['participant_types']['u'] as $uid => $status)
1835 1833
 		{
1836
-			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid))
1834
+			if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid))
1837 1835
 			{
1838 1836
 				$sel_options['owner'][$uid] = $this->bo->participant_name($uid);
1839 1837
 			}
1840 1838
 		}
1841
-		$content['no_add_alarm'] = !count($sel_options['owner']);	// no rights to set any alarm
1839
+		$content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm
1842 1840
 		if (!$event['id'])
1843 1841
 		{
1844
-			$etpl->set_cell_attribute('button[new_alarm]','type','checkbox');
1842
+			$etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox');
1845 1843
 		}
1846 1844
 		if ($preserved['no_popup'])
1847 1845
 		{
1848 1846
 			// If not a popup, load the normal calendar interface on cancel
1849
-			$etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')');
1847
+			$etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')');
1850 1848
 		}
1851 1849
 
1852 1850
 		// Allow admins to restore deleted events
1853
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] )
1851
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'])
1854 1852
 		{
1855 1853
 			$content['deleted'] = $preserved['deleted'] = null;
1856 1854
 			$etpl->set_cell_attribute('button[save]', 'label', 'Recover');
@@ -1862,7 +1860,7 @@  discard block
 block discarded – undo
1862 1860
 		// Setup history tab
1863 1861
 		$this->setup_history($content, $sel_options);
1864 1862
 
1865
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - '
1863
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '
1866 1864
 			. (!$event['id'] ? lang('Add')
1867 1865
 				: ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View')))
1868 1866
 					: ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit')))));
@@ -1872,15 +1870,15 @@  discard block
 block discarded – undo
1872 1870
 		if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token'];
1873 1871
 
1874 1872
 		// non_interactive==true from $_GET calls immediate save action without displaying the edit form
1875
-		if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1873
+		if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true)
1876 1874
 		{
1877
-			unset($_GET['non_interactive']);	// prevent process_exec <--> edit loops
1875
+			unset($_GET['non_interactive']); // prevent process_exec <--> edit loops
1878 1876
 			$content['button']['save'] = true;
1879
-			$this->process_edit(array_merge($content,$preserved));
1877
+			$this->process_edit(array_merge($content, $preserved));
1880 1878
 		}
1881 1879
 		else
1882 1880
 		{
1883
-			$etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2);
1881
+			$etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2);
1884 1882
 		}
1885 1883
 	}
1886 1884
 
@@ -1890,14 +1888,14 @@  discard block
 block discarded – undo
1890 1888
 	 * @param int $id
1891 1889
 	 * @param string $token
1892 1890
 	 */
1893
-	function ajax_unlock($id,$token)
1891
+	function ajax_unlock($id, $token)
1894 1892
 	{
1895
-		$lock_path = Vfs::app_entry_lock_path('calendar',$id);
1893
+		$lock_path = Vfs::app_entry_lock_path('calendar', $id);
1896 1894
 		$lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
1897 1895
 
1898 1896
 		if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token)
1899 1897
 		{
1900
-			Vfs::unlock($lock_path,$token,false);
1898
+			Vfs::unlock($lock_path, $token, false);
1901 1899
 		}
1902 1900
 	}
1903 1901
 
@@ -1909,17 +1907,17 @@  discard block
 block discarded – undo
1909 1907
 	 * 		are called by new mail-app; and we intend to use the stuff passed on by session
1910 1908
 	 * @param string $msg = null
1911 1909
 	 */
1912
-	function meeting(array $event=null, $msg=null)
1910
+	function meeting(array $event = null, $msg = null)
1913 1911
 	{
1914 1912
 		$user = $GLOBALS['egw_info']['user']['account_id'];
1915 1913
 		$readonlys['button[apply]'] = true;
1916
-		$_usesession=!is_array($event);
1914
+		$_usesession = !is_array($event);
1917 1915
 		//special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we
1918 1916
 		//are called by new mail-app; and we intend to use the stuff passed on by session
1919
-		if ($event == array('event'=>null,'msg'=>'','useSession'=>true))
1917
+		if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true))
1920 1918
 		{
1921
-			$event=null; // set to null
1922
-			$_usesession=true; // trigger session read
1919
+			$event = null; // set to null
1920
+			$_usesession = true; // trigger session read
1923 1921
 		}
1924 1922
 		if (!is_array($event))
1925 1923
 		{
@@ -1948,7 +1946,7 @@  discard block
 block discarded – undo
1948 1946
 
1949 1947
 			if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted'])
1950 1948
 			{
1951
-				switch(strtolower($ical_method))
1949
+				switch (strtolower($ical_method))
1952 1950
 				{
1953 1951
 					case 'reply':
1954 1952
 						// first participant is the one replying (our iCal parser adds owner first!)
@@ -2002,19 +2000,19 @@  discard block
 block discarded – undo
2002 2000
 			}
2003 2001
 			else	// event not in calendar
2004 2002
 			{
2005
-				$readonlys['button[cancel]'] = true;	// no way to remove a canceled event not in calendar
2003
+				$readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar
2006 2004
 			}
2007 2005
 			$event['participant_types'] = array();
2008
-			foreach($event['participants'] as $uid => $status)
2006
+			foreach ($event['participants'] as $uid => $status)
2009 2007
 			{
2010 2008
 				$user_type = $user_id = null;
2011 2009
 				calendar_so::split_user($uid, $user_type, $user_id);
2012 2010
 				$event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] =
2013
-					$status && $status !== 'X' ? $status : 'U';	// X --> no status given --> U = unknown
2011
+					$status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown
2014 2012
 			}
2015 2013
 			//error_log(__METHOD__."(...) parsed as ".array2string($event));
2016 2014
 			$event['recure'] = $this->bo->recure2string($event);
2017
-			$event['all_participants'] = implode(",\n",$this->bo->participants($event, true));
2015
+			$event['all_participants'] = implode(",\n", $this->bo->participants($event, true));
2018 2016
 
2019 2017
 			// ignore events in the past (for recurring events check enddate!)
2020 2018
 			if ($this->bo->date2ts($event['start']) < $this->bo->now_su &&
@@ -2034,23 +2032,23 @@  discard block
 block discarded – undo
2034 2032
 			// clear notification errors
2035 2033
 			notifications::errors(true);
2036 2034
 
2037
-			switch($button)
2035
+			switch ($button)
2038 2036
 			{
2039 2037
 				case 'reject':
2040 2038
 					if (!$event['id'])
2041 2039
 					{
2042 2040
 						// send reply to organizer
2043
-						$this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event);
2044
-						break;	// no need to store rejected event
2041
+						$this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event);
2042
+						break; // no need to store rejected event
2045 2043
 					}
2046 2044
 					// fall-through
2047 2045
 				case 'accept':
2048 2046
 				case 'tentativ':
2049
-					$status = strtoupper($button[0]);	// A, R or T
2047
+					$status = strtoupper($button[0]); // A, R or T
2050 2048
 					if (!$event['id'])
2051 2049
 					{
2052 2050
 						// if organizer is a EGroupware user, but we have no rights to organizers calendar
2053
-						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner']))
2051
+						if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner']))
2054 2052
 						{
2055 2053
 							// --> make organize a participant with role chair and current user the owner
2056 2054
 							$event['participant_types']['u'] = $event['participants'][$event['owner']] =
@@ -2058,7 +2056,7 @@  discard block
 block discarded – undo
2058 2056
 							$event['owner'] = $this->user;
2059 2057
 						}
2060 2058
 						// store event without notifications!
2061
-						if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true)))
2059
+						if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true)))
2062 2060
 						{
2063 2061
 							$msg[] = lang('Event saved');
2064 2062
 						}
@@ -2096,7 +2094,7 @@  discard block
 block discarded – undo
2096 2094
 		Framework::message(implode("\n", (array)$msg));
2097 2095
 		$readonlys['button[edit]'] = !$event['id'];
2098 2096
 		$event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method);
2099
-		switch(strtolower($ical_method))
2097
+		switch (strtolower($ical_method))
2100 2098
 		{
2101 2099
 			case 'reply':
2102 2100
 				$event['ics_method_label'] = lang('Reply to meeting request');
@@ -2120,37 +2118,37 @@  discard block
 block discarded – undo
2120 2118
 	 * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user!
2121 2119
 	 * @param array $preserv data to preserv
2122 2120
 	 */
2123
-	function conflicts($event,$conflicts,$preserv)
2121
+	function conflicts($event, $conflicts, $preserv)
2124 2122
 	{
2125 2123
 		$etpl = new Etemplate('calendar.conflicts');
2126 2124
 		$allConflicts = array();
2127 2125
 
2128
-		foreach($conflicts as $k => $conflict)
2126
+		foreach ($conflicts as $k => $conflict)
2129 2127
 		{
2130
-			$is_readable = $this->bo->check_perms(Acl::READ,$conflict);
2128
+			$is_readable = $this->bo->check_perms(Acl::READ, $conflict);
2131 2129
 
2132 2130
 			$conflicts[$k] += array(
2133 2131
 				'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private',
2134
-				'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '',
2135
-				'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true),
2136
-				'conflicting_participants' => implode(",\n",$this->bo->participants(array(
2137
-					'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']),
2138
-				),true,true)),	// show group invitations too
2132
+				'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '',
2133
+				'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true),
2134
+				'conflicting_participants' => implode(",\n", $this->bo->participants(array(
2135
+					'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']),
2136
+				), true, true)), // show group invitations too
2139 2137
 				'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '',
2140 2138
 				'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ',
2141 2139
 			);
2142
-				$allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']);
2140
+				$allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']);
2143 2141
 			}
2144 2142
 		$content = $event + array(
2145
-			'conflicts' => array_values($conflicts),	// conflicts have id-start as key
2143
+			'conflicts' => array_values($conflicts), // conflicts have id-start as key
2146 2144
 		);
2147
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict');
2145
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict');
2148 2146
 		$resources_config = Api\Config::read('resources');
2149 2147
 		$readonlys = array();
2150 2148
 
2151 2149
 		foreach (array_keys($allConflicts) as $pId)
2152 2150
 		{
2153
-			if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts
2151
+			if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts
2154 2152
 			{
2155 2153
 
2156 2154
 				switch ($resources_config['ignoreconflicts'])
@@ -2170,7 +2168,7 @@  discard block
 block discarded – undo
2170 2168
 				}
2171 2169
 			}
2172 2170
 		}
2173
-		$etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2);
2171
+		$etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2);
2174 2172
 	}
2175 2173
 
2176 2174
 	/**
@@ -2188,7 +2186,7 @@  discard block
 block discarded – undo
2188 2186
 		//$response->addAlert(__METHOD__.'('.array2string($edit_content).')');
2189 2187
 
2190 2188
 		// convert start/end date-time values to timestamps
2191
-		foreach(array('start', 'end') as $name)
2189
+		foreach (array('start', 'end') as $name)
2192 2190
 		{
2193 2191
 			if (!empty($edit_content[$name]))
2194 2192
 			{
@@ -2218,7 +2216,7 @@  discard block
 block discarded – undo
2218 2216
 			'recur_type'   => $edit_content['recur_type'],
2219 2217
 			'participants' => array(),
2220 2218
 		);
2221
-		foreach($edit_content['participants'] as $key => $data)
2219
+		foreach ($edit_content['participants'] as $key => $data)
2222 2220
 		{
2223 2221
 			if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] &&
2224 2222
 				!$edit_content['participants']['delete'][md5($data['uid'])])
@@ -2233,21 +2231,21 @@  discard block
 block discarded – undo
2233 2231
 		// default search parameters
2234 2232
 		$content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts'];
2235 2233
 		$content['end_time'] = $this->cal_prefs['workdayends'];
2236
-		if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration'])
2234
+		if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration'])
2237 2235
 		{
2238
-			$content['end_time'] = 0;	// no end-time limit, as duration would never fit
2236
+			$content['end_time'] = 0; // no end-time limit, as duration would never fit
2239 2237
 		}
2240 2238
 		$content['weekdays'] = MCAL_M_WEEKDAYS;
2241 2239
 
2242 2240
 		$content['search_window'] = 7 * DAY_s;
2243 2241
 
2244 2242
 		// store content in session
2245
-		Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content);
2243
+		Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content);
2246 2244
 
2247 2245
 		//menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500
2248
-		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id'];
2246
+		$link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id'];
2249 2247
 
2250
-		$response->call('app.calendar.freetime_search_popup',$link);
2248
+		$response->call('app.calendar.freetime_search_popup', $link);
2251 2249
 
2252 2250
 		//$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500);
2253 2251
 
@@ -2270,26 +2268,26 @@  discard block
 block discarded – undo
2270 2268
 	{
2271 2269
 		$etpl = new Etemplate('calendar.freetimesearch');
2272 2270
 		$sel_options['search_window'] = array(
2273
-			7*DAY_s		=> lang('one week'),
2274
-			14*DAY_s	=> lang('two weeks'),
2275
-			31*DAY_s	=> lang('one month'),
2276
-			92*DAY_s	=> lang('three month'),
2277
-			365*DAY_s	=> lang('one year'),
2271
+			7 * DAY_s		=> lang('one week'),
2272
+			14 * DAY_s	=> lang('two weeks'),
2273
+			31 * DAY_s	=> lang('one month'),
2274
+			92 * DAY_s	=> lang('three month'),
2275
+			365 * DAY_s	=> lang('one year'),
2278 2276
 		);
2279 2277
 		if (!is_array($content))
2280 2278
 		{
2281 2279
 			// get content from session (and delete it immediatly)
2282
-			$content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2283
-			Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']);
2280
+			$content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2281
+			Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']);
2284 2282
 			//Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly
2285 2283
 			//widget we need to convert them from numbers to timestamps, only for the first time when we have template without content
2286 2284
 			$sTime = $content['start_time'];
2287 2285
 			$eTime = $content['end_time'];
2288
-			$content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00");
2289
-			$content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00");
2286
+			$content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00");
2287
+			$content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00");
2290 2288
 
2291 2289
 			// pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds)
2292
-			foreach(array_keys($sel_options['search_window']) as $window)
2290
+			foreach (array_keys($sel_options['search_window']) as $window)
2293 2291
 			{
2294 2292
 				if ($window > $content['duration'])
2295 2293
 				{
@@ -2316,19 +2314,19 @@  discard block
 block discarded – undo
2316 2314
 		{
2317 2315
 			$content['msg'] .= lang('Only the initial date of that recuring event is checked!');
2318 2316
 		}
2319
-		$content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']);
2320
-		$content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options);
2317
+		$content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']);
2318
+		$content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options);
2321 2319
 
2322
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search');
2320
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search');
2323 2321
 
2324 2322
 		$sel_options['duration'] = $this->durations;
2325 2323
 		if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = '';
2326 2324
 
2327
-		$etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array(
2325
+		$etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array(
2328 2326
 				'participants'	=> $content['participants'],
2329 2327
 				'cal_id'		=> $content['cal_id'],
2330 2328
 				'recur_type'	=> $content['recur_type'],
2331
-			),2);
2329
+			), 2);
2332 2330
 	}
2333 2331
 
2334 2332
 	/**
@@ -2341,15 +2339,15 @@  discard block
 block discarded – undo
2341 2339
 	 * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0
2342 2340
 	 * @return array of free time-slots: array with start and end values
2343 2341
 	 */
2344
-	function freetime($participants,$start,$end,$duration=1,$cal_id=0)
2342
+	function freetime($participants, $start, $end, $duration = 1, $cal_id = 0)
2345 2343
 	{
2346
-		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);
2344
+		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);
2347 2345
 
2348 2346
 		$busy = $this->bo->search(array(
2349 2347
 			'start' => $start,
2350 2348
 			'end'	=> $end,
2351 2349
 			'users'	=> $participants,
2352
-			'ignore_acl' => true,	// otherwise we get only events readable by the user
2350
+			'ignore_acl' => true, // otherwise we get only events readable by the user
2353 2351
 		));
2354 2352
 		$busy[] = array(	// add end-of-search-date as event, to cope with empty search and get freetime til that date
2355 2353
 			'start'	=> $end,
@@ -2358,15 +2356,15 @@  discard block
 block discarded – undo
2358 2356
 		$ft_start = $start;
2359 2357
 		$freetime = array();
2360 2358
 		$n = 0;
2361
-		foreach($busy as $event)
2359
+		foreach ($busy as $event)
2362 2360
 		{
2363
-			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue;	// ignore our own event
2361
+			if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event
2364 2362
 
2365 2363
  			if ($event['non_blocking']) continue; // ignore non_blocking events
2366 2364
 
2367 2365
 			// check if from all wanted participants at least one has a not rejected status in found event
2368 2366
 			$non_rejected_found = false;
2369
-			foreach($participants as $uid)
2367
+			foreach ($participants as $uid)
2370 2368
 			{
2371 2369
 				if ($event['participants'][$uid] == 'R') continue;
2372 2370
 
@@ -2382,10 +2380,10 @@  discard block
 block discarded – undo
2382 2380
 
2383 2381
 			if ($this->debug)
2384 2382
 			{
2385
-				echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n";
2383
+				echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n";
2386 2384
 				echo "event[title]=$event[title]<br>\n";
2387
-				echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n";
2388
-				echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n";
2385
+				echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n";
2386
+				echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n";
2389 2387
 			}
2390 2388
 			// $events ends before our actual position ==> ignore it
2391 2389
 			if ($event['end'] < $ft_start)
@@ -2409,11 +2407,11 @@  discard block
 block discarded – undo
2409 2407
 					'start'	=> $ft_start,
2410 2408
 					'end'	=> $ft_end,
2411 2409
 				);
2412
-				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";
2410
+				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";
2413 2411
 			}
2414 2412
 			$ft_start = $event['end'];
2415 2413
 		}
2416
-		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);
2414
+		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);
2417 2415
 
2418 2416
 		return $freetime;
2419 2417
 	}
@@ -2433,46 +2431,46 @@  discard block
 block discarded – undo
2433 2431
 	 */
2434 2432
 	function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options)
2435 2433
 	{
2436
-		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);
2434
+		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);
2437 2435
 
2438 2436
 		$freetime_daywise = array();
2439 2437
 		if (!is_array($sel_options)) $sel_options = array();
2440 2438
 		$time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i';
2441 2439
 
2442
-		$start_time = (int) $_start_time;	// ignore leading zeros
2443
-		$end_time   = (int) $_end_time;
2440
+		$start_time = (int)$_start_time; // ignore leading zeros
2441
+		$end_time   = (int)$_end_time;
2444 2442
 
2445 2443
 		// ignore the end_time, if duration would never fit
2446
-		if (($end_time - $start_time)*HOUR_s < $duration)
2444
+		if (($end_time - $start_time) * HOUR_s < $duration)
2447 2445
 		{
2448 2446
 			$end_time = 0;
2449
-			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);
2447
+			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);
2450 2448
 		}
2451 2449
 		$n = 0;
2452
-		foreach($freetime as $ft)
2450
+		foreach ($freetime as $ft)
2453 2451
 		{
2454 2452
 			$adaybegin = $this->bo->date2array($ft['start']);
2455 2453
 			$adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0;
2456 2454
 			unset($adaybegin['raw']);
2457 2455
 			$daybegin = $this->bo->date2ts($adaybegin);
2458 2456
 
2459
-			for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s)
2457
+			for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s)
2460 2458
 			{
2461
-				$dow = date('w',$daybegin+DAY_s/2);	// 0=Sun, .., 6=Sat
2462
-				$mcal_dow = pow(2,$dow);
2463
-				if (!($weekdays & $mcal_dow))
2459
+				$dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat
2460
+				$mcal_dow = pow(2, $dow);
2461
+				if (!($weekdays&$mcal_dow))
2464 2462
 				{
2465 2463
 					//echo "wrong day of week $dow<br>\n";
2466
-					continue;	// wrong day of week
2464
+					continue; // wrong day of week
2467 2465
 				}
2468 2466
 				$start = $t < $ft['start'] ? $ft['start'] : $t;
2469 2467
 
2470
-				if ($start-$daybegin < $start_time*HOUR_s)	// start earlier then start_time
2468
+				if ($start - $daybegin < $start_time * HOUR_s)	// start earlier then start_time
2471 2469
 				{
2472
-					$start = $daybegin + $start_time*HOUR_s;
2470
+					$start = $daybegin + $start_time * HOUR_s;
2473 2471
 				}
2474 2472
 				// if end_time given use it, else the original slot's end
2475
-				$end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end'];
2473
+				$end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end'];
2476 2474
 				if ($end > $ft['end']) $end = $ft['end'];
2477 2475
 
2478 2476
 				// slot to small for duration
@@ -2486,11 +2484,11 @@  discard block
 block discarded – undo
2486 2484
 					'end'	=> $end,
2487 2485
 				);
2488 2486
 				$times = array();
2489
-				for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval'])
2487
+				for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval'])
2490 2488
 				{
2491 2489
 					$e = $s + $duration;
2492
-					$end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : '';
2493
-					$times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e);
2490
+					$end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : '';
2491
+					$times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e);
2494 2492
 				}
2495 2493
 				$sel_options[$n.'start'] = $times;
2496 2494
 			}
@@ -2505,13 +2503,13 @@  discard block
 block discarded – undo
2505 2503
      * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default)
2506 2504
      * @return string error-msg if $return_error
2507 2505
      */
2508
-    function export($content=0,$return_error=false)
2506
+    function export($content = 0, $return_error = false)
2509 2507
     {
2510 2508
 		$boical = new calendar_ical();
2511 2509
 		#error_log(__METHOD__.print_r($content,true));
2512 2510
 		if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id']))
2513 2511
 		{
2514
-			if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false)))
2512
+			if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false)))
2515 2513
 			{
2516 2514
 				$msg = lang('Permission denied');
2517 2515
 
@@ -2519,20 +2517,20 @@  discard block
 block discarded – undo
2519 2517
 			}
2520 2518
 			else
2521 2519
 			{
2522
-				html::content_header('event.ics','text/calendar',bytes($ical));
2520
+				html::content_header('event.ics', 'text/calendar', bytes($ical));
2523 2521
 				echo $ical;
2524 2522
 				common::egw_exit();
2525 2523
 			}
2526 2524
 		}
2527 2525
 		if (is_array($content))
2528 2526
 		{
2529
-			$events =& $this->bo->search(array(
2527
+			$events = & $this->bo->search(array(
2530 2528
 				'start' => $content['start'],
2531 2529
 				'end'   => $content['end'],
2532 2530
 				'enum_recuring' => false,
2533 2531
 				'daywise'       => false,
2534 2532
 				'owner'         => $this->owner,
2535
-				'date_format'   => 'server',    // timestamp in server time for boical class
2533
+				'date_format'   => 'server', // timestamp in server time for boical class
2536 2534
 			));
2537 2535
 			if (!$events)
2538 2536
 			{
@@ -2540,8 +2538,8 @@  discard block
 block discarded – undo
2540 2538
 			}
2541 2539
 			else
2542 2540
 			{
2543
-				$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false);
2544
-				html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical));
2541
+				$ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false);
2542
+				html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical));
2545 2543
 				echo $ical;
2546 2544
 				common::egw_exit();
2547 2545
 			}
@@ -2557,9 +2555,9 @@  discard block
 block discarded – undo
2557 2555
 		}
2558 2556
 		$content['msg'] = $msg;
2559 2557
 
2560
-		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export');
2558
+		$GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export');
2561 2559
 		$etpl = new etemplate_new('calendar.export');
2562
-		$etpl->exec('calendar.calendar_uiforms.export',$content);
2560
+		$etpl->exec('calendar.calendar_uiforms.export', $content);
2563 2561
     }
2564 2562
 
2565 2563
 	/**
@@ -2567,7 +2565,7 @@  discard block
 block discarded – undo
2567 2565
 	 *
2568 2566
 	 * @param array $_content
2569 2567
 	 */
2570
-	function cat_acl(array $_content=null)
2568
+	function cat_acl(array $_content = null)
2571 2569
 	{
2572 2570
 		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
2573 2571
 		{
@@ -2579,15 +2577,15 @@  discard block
 block discarded – undo
2579 2577
 			unset($_content['button']);
2580 2578
 			if ($button != 'cancel')	// store changed Acl
2581 2579
 			{
2582
-				foreach($_content as $data)
2580
+				foreach ($_content as $data)
2583 2581
 				{
2584 2582
 					if (!($cat_id = $data['cat_id'])) continue;
2585
-					foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id)
2583
+					foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id)
2586 2584
 					{
2587 2585
 						$rights = 0;
2588
-						if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2589
-						if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2590
-						if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights);
2586
+						if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD;
2587
+						if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS;
2588
+						if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights);
2591 2589
 					}
2592 2590
 				}
2593 2591
 			}
@@ -2599,20 +2597,20 @@  discard block
 block discarded – undo
2599 2597
 				), 'admin');
2600 2598
 			}
2601 2599
 		}
2602
-		$content= $preserv = array();
2600
+		$content = $preserv = array();
2603 2601
 		$n = 1;
2604
-		foreach($this->bo->get_cat_rights() as $Lcat_id => $data)
2602
+		foreach ($this->bo->get_cat_rights() as $Lcat_id => $data)
2605 2603
 		{
2606
-			$cat_id = substr($Lcat_id,1);
2604
+			$cat_id = substr($Lcat_id, 1);
2607 2605
 			$row = array(
2608 2606
 				'cat_id' => $cat_id,
2609 2607
 				'add' => array(),
2610 2608
 				'status' => array(),
2611 2609
 			);
2612
-			foreach($data as $account_id => $rights)
2610
+			foreach ($data as $account_id => $rights)
2613 2611
 			{
2614
-				if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2615
-				if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2612
+				if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id;
2613
+				if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id;
2616 2614
 			}
2617 2615
 			$content[$n] = $row;
2618 2616
 			$preserv[$n] = array(
@@ -2628,7 +2626,7 @@  discard block
 block discarded – undo
2628 2626
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL');
2629 2627
 		$tmp = new Etemplate('calendar.cat_acl');
2630 2628
 		$GLOBALS['egw_info']['flags']['nonavbar'] = 1;
2631
-		$tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv);
2629
+		$tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv);
2632 2630
 	}
2633 2631
 
2634 2632
 	/**
@@ -2678,18 +2676,18 @@  discard block
 block discarded – undo
2678 2676
 
2679 2677
 
2680 2678
 		// Get participants for only this one, if it's recurring.  The date is on the end of the value.
2681
-		if($content['recur_type'] || $content['recurrence'])
2679
+		if ($content['recur_type'] || $content['recurrence'])
2682 2680
 		{
2683 2681
 			$content['history']['filter'] = array(
2684 2682
 				'(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND (
2685
-					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR
2686
-					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))'
2683
+					history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR
2684
+					history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))'
2687 2685
 			);
2688 2686
 		}
2689 2687
 
2690 2688
 		// Translate labels
2691 2689
 		$tracking = new calendar_tracking();
2692
-		foreach($tracking->field2label as $field => $label)
2690
+		foreach ($tracking->field2label as $field => $label)
2693 2691
 		{
2694 2692
 			$sel_options[$status][$field] = lang($label);
2695 2693
 		}
@@ -2708,44 +2706,44 @@  discard block
 block discarded – undo
2708 2706
 	 *	which particular instance was dragged
2709 2707
 	 * @return string XML response if no error occurs
2710 2708
 	 */
2711
-	function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null)
2709
+	function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null)
2712 2710
 	{
2713
-		list($eventId, $date) = explode(':', $_eventId,2);
2711
+		list($eventId, $date) = explode(':', $_eventId, 2);
2714 2712
 		$ignore_conflicts = false;
2715 2713
 
2716 2714
 		// we do not allow dragging into another users calendar ATM
2717
-		if($targetOwner < 0)
2715
+		if ($targetOwner < 0)
2718 2716
 		{
2719 2717
 			$targetOwner = array($targetOwner);
2720 2718
 		}
2721
-		if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2719
+		if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0)
2722 2720
 		{
2723 2721
 			$targetOwner = $calendarOwner;
2724 2722
 		}
2725 2723
 		// But you may be viewing multiple users, or a group calendar and
2726 2724
 		// dragging your event - dragging across calendars does not change owner
2727
-		if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2725
+		if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner))
2728 2726
 		{
2729 2727
 			$return = true;
2730
-			foreach($targetOwner as $owner)
2728
+			foreach ($targetOwner as $owner)
2731 2729
 			{
2732
-				if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true)))
2730
+				if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true)))
2733 2731
 				{
2734 2732
 					$return = false;
2735 2733
 					break;
2736 2734
 				}
2737
-				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date))
2735
+				else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date))
2738 2736
 				{
2739 2737
 					$return = false;
2740 2738
 					break;
2741 2739
 				}
2742 2740
 			}
2743
-			if($return) return;
2741
+			if ($return) return;
2744 2742
 		}
2745
-		$old_event=$event=$this->bo->read($eventId);
2743
+		$old_event = $event = $this->bo->read($eventId);
2746 2744
 		if (!$durationT)
2747 2745
 		{
2748
-			$duration=$event['end']-$event['start'];
2746
+			$duration = $event['end'] - $event['start'];
2749 2747
 		}
2750 2748
 		// Drag a normal event to whole day non-blocking
2751 2749
 		else if ($durationT == 'whole_day')
@@ -2753,7 +2751,7 @@  discard block
 block discarded – undo
2753 2751
 			$event['whole_day'] = true;
2754 2752
 			$event['non_blocking'] = true;
2755 2753
 			// Make duration whole days, less 1 second
2756
-			$duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1;
2754
+			$duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1;
2757 2755
 		}
2758 2756
 		else
2759 2757
 		{
@@ -2766,19 +2764,19 @@  discard block
 block discarded – undo
2766 2764
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2767 2765
 			if (!empty($event['whole_day']))
2768 2766
 			{
2769
-				$d =& $this->bo->so->startOfDay($d);
2767
+				$d = & $this->bo->so->startOfDay($d);
2770 2768
 				$d->setUser();
2771 2769
 			}
2772 2770
 			$event = $this->bo->read($eventId, $d, true);
2773 2771
 
2774 2772
 			// For DnD, create an exception if they gave the date
2775 2773
 			$preserv = null;
2776
-			$this->_create_exception($event,$preserv);
2774
+			$this->_create_exception($event, $preserv);
2777 2775
 			unset($event['id']);
2778 2776
 			$links = $event['link_to']['to_id'];
2779 2777
 
2780 2778
 			$messages = null;
2781
-			$conflicts = $this->bo->update($event,false,true,false,true,$messages);
2779
+			$conflicts = $this->bo->update($event, false, true, false, true, $messages);
2782 2780
 			if (!is_array($conflicts) && $conflicts)
2783 2781
 			{
2784 2782
 				// now we need to add the original start as recur-execption to the series
@@ -2786,28 +2784,28 @@  discard block
 block discarded – undo
2786 2784
 				$recur_event['recur_exception'][] = $d->format('ts');
2787 2785
 				// check if we need to move the alarms, because they are next on that exception
2788 2786
 				$this->bo->check_move_alarms($recur_event, null, $d);
2789
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
2790
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
2791
-				$this->bo->update($recur_event,true);	// no conflict check here
2787
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
2788
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
2789
+				$this->bo->update($recur_event, true); // no conflict check here
2792 2790
 
2793 2791
 				// Sending null will trigger a removal of the original for that date
2794 2792
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
2795 2793
 
2796 2794
 				unset($recur_event);
2797
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
2795
+				unset($event['edit_single']); // if we further edit it, it's just a single event
2798 2796
 				unset($preserv['edit_single']);
2799 2797
 			}
2800 2798
 		}
2801 2799
 
2802 2800
 		$d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone);
2803 2801
 		$event['start'] = $d->format('ts');
2804
-		$event['end'] = $event['start']+$duration;
2802
+		$event['end'] = $event['start'] + $duration;
2805 2803
 
2806 2804
 		if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance)
2807 2805
 		{
2808 2806
 			// calculate offset against clicked recurrance,
2809 2807
 			// depending on which is smaller
2810
-			$offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts');
2808
+			$offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts');
2811 2809
 			$event['start'] = $old_event['start'] + $offset;
2812 2810
 			$event['duration'] = $duration;
2813 2811
 
@@ -2818,31 +2816,31 @@  discard block
 block discarded – undo
2818 2816
 			// Can't handle conflict.  Just ignore it.
2819 2817
 			$ignore_conflicts = true;
2820 2818
 		}
2821
-		if(!$event['recur_type'])
2819
+		if (!$event['recur_type'])
2822 2820
 		{
2823 2821
 			$this->bo->check_move_alarms($event, $old_event);
2824 2822
 		}
2825 2823
 
2826 2824
 		// Drag a whole day to a time
2827
-		if($durationT && $durationT != 'whole_day')
2825
+		if ($durationT && $durationT != 'whole_day')
2828 2826
 		{
2829 2827
 			$event['whole_day'] = ($duration == DAY_s);
2830 2828
 			$event['non_blocking'] = false;
2831 2829
 			// If there's a conflict, it won't save the change and the conflict popup will be blank
2832 2830
 			// so save the change now, and then let the conflict check happen.
2833 2831
 			$message = null;
2834
-			$this->bo->update($event,true, true, false, true, $message,true);
2832
+			$this->bo->update($event, true, true, false, true, $message, true);
2835 2833
 
2836 2834
 			// Whole day non blocking with DAY_s would add a day
2837
-			if($duration==DAY_s) $duration=0;
2835
+			if ($duration == DAY_s) $duration = 0;
2838 2836
 		}
2839 2837
 
2840 2838
 		$status_reset_to_unknown = false;
2841 2839
 		$sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start']));
2842
-		foreach((array)$event['participants'] as $uid => $status)
2840
+		foreach ((array)$event['participants'] as $uid => $status)
2843 2841
 		{
2844 2842
 			$q = $r = null;
2845
-			calendar_so::split_status($status,$q,$r);
2843
+			calendar_so::split_status($status, $q, $r);
2846 2844
 			if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U')
2847 2845
 			{
2848 2846
 				$preferences = new Api\Preferences($uid);
@@ -2855,29 +2853,29 @@  discard block
 block discarded – undo
2855 2853
 						if ($sameday) break;
2856 2854
 					default:
2857 2855
 						$status_reset_to_unknown = true;
2858
-						$event['participants'][$uid] = calendar_so::combine_status('U',$q,$r);
2856
+						$event['participants'][$uid] = calendar_so::combine_status('U', $q, $r);
2859 2857
 						// todo: report reset status to user
2860 2858
 				}
2861 2859
 			}
2862 2860
 		}
2863 2861
 
2864 2862
 		$message = false;
2865
-		$conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message);
2863
+		$conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message);
2866 2864
 
2867 2865
 		// Save links
2868
-		if($links)
2866
+		if ($links)
2869 2867
 		{
2870 2868
 			Link::link('calendar', $event['id'], $links);
2871 2869
 		}
2872 2870
 
2873
-		$this->update_client($event['id'],$d);
2871
+		$this->update_client($event['id'], $d);
2874 2872
 		$response = Api\Json\Response::get();
2875
-		if(!is_array($conflicts) && $conflicts)
2873
+		if (!is_array($conflicts) && $conflicts)
2876 2874
 		{
2877
-			if(is_int($conflicts))
2875
+			if (is_int($conflicts))
2878 2876
 			{
2879 2877
 				$event['id'] = $conflicts;
2880
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
2878
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
2881 2879
 			}
2882 2880
 		}
2883 2881
 		else if ($conflicts)
@@ -2890,21 +2888,21 @@  discard block
 block discarded – undo
2890 2888
 					.'&end='.$event['end']
2891 2889
 					.'&non_interactive=true'
2892 2890
 					.'&cancel_needs_refresh=true',
2893
-				'',750,410);
2891
+				'', 750, 410);
2894 2892
 		}
2895 2893
 		else if ($message)
2896 2894
 		{
2897
-			$response->call('egw.message',  implode('<br />', $message));
2895
+			$response->call('egw.message', implode('<br />', $message));
2898 2896
 		}
2899
-		if($event['id'] != $eventId ) $this->update_client($_eventId);
2897
+		if ($event['id'] != $eventId) $this->update_client($_eventId);
2900 2898
 		if ($status_reset_to_unknown)
2901 2899
 		{
2902
-			foreach((array)$event['participants'] as $uid => $status)
2900
+			foreach ((array)$event['participants'] as $uid => $status)
2903 2901
 			{
2904 2902
 				if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user)
2905 2903
 				{
2906
-					calendar_so::split_status($status,$q,$r);
2907
-					$status = calendar_so::combine_status('U',$q,$r);
2904
+					calendar_so::split_status($status, $q, $r);
2905
+					$status = calendar_so::combine_status('U', $q, $r);
2908 2906
 					$this->bo->set_status($event['id'], $uid, $status, 0, true);
2909 2907
 				}
2910 2908
 			}
@@ -2921,7 +2919,7 @@  discard block
 block discarded – undo
2921 2919
 	{
2922 2920
 		list($eventId, $date) = explode(':', $_eventId);
2923 2921
 		$event = $this->bo->read($eventId);
2924
-		if($date)
2922
+		if ($date)
2925 2923
 		{
2926 2924
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
2927 2925
 		}
@@ -2931,29 +2929,29 @@  discard block
 block discarded – undo
2931 2929
 		{
2932 2930
 			if (!empty($event['whole_day']))
2933 2931
 			{
2934
-				$d =& $this->bo->so->startOfDay($date);
2932
+				$d = & $this->bo->so->startOfDay($date);
2935 2933
 				$d->setUser();
2936 2934
 			}
2937 2935
 			$event = $this->bo->read($eventId, $d, true);
2938 2936
 			$date = $d->format('ts');
2939 2937
 		}
2940
-		if($event['participants'][$uid])
2938
+		if ($event['participants'][$uid])
2941 2939
 		{
2942 2940
 			$q = $r = null;
2943
-			calendar_so::split_status($event['participants'][$uid],$q,$r);
2944
-			$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2945
-			$this->bo->set_status($event['id'],$uid,$status,$date,true);
2941
+			calendar_so::split_status($event['participants'][$uid], $q, $r);
2942
+			$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2943
+			$this->bo->set_status($event['id'], $uid, $status, $date, true);
2946 2944
 		}
2947 2945
 		else
2948 2946
 		{
2949 2947
 			// Group membership
2950
-			foreach($event['participants'] as $id => $status)
2948
+			foreach ($event['participants'] as $id => $status)
2951 2949
 			{
2952
-				if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true)))
2950
+				if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true)))
2953 2951
 				{
2954
-					calendar_so::split_status($event['participants'][$uid],$q,$r);
2955
-					$event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r);
2956
-					$this->bo->set_status($event['id'],$uid,$status,$date,true);
2952
+					calendar_so::split_status($event['participants'][$uid], $q, $r);
2953
+					$event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r);
2954
+					$this->bo->set_status($event['id'], $uid, $status, $date, true);
2957 2955
 					break;
2958 2956
 				}
2959 2957
 			}
@@ -2961,7 +2959,7 @@  discard block
 block discarded – undo
2961 2959
 
2962 2960
 		// Directly update stored data.  If event is still visible, it will
2963 2961
 		// be notified & update itself.
2964
-		$this->update_client($eventId,$d);
2962
+		$this->update_client($eventId, $d);
2965 2963
 	}
2966 2964
 
2967 2965
 	/**
@@ -2969,8 +2967,8 @@  discard block
 block discarded – undo
2969 2967
 	 */
2970 2968
 	public function ajax_delete($eventId)
2971 2969
 	{
2972
-		list($id, $date) = explode(':',$eventId);
2973
-		$event=$this->bo->read($id);
2970
+		list($id, $date) = explode(':', $eventId);
2971
+		$event = $this->bo->read($id);
2974 2972
 		$response = Api\Json\Response::get();
2975 2973
 
2976 2974
 		if ($this->bo->delete($event['id'], (int)$date))
@@ -2983,11 +2981,11 @@  discard block
 block discarded – undo
2983 2981
 			{
2984 2982
 				$msg = lang('Event deleted');
2985 2983
 			}
2986
-			$response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete'));
2984
+			$response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete'));
2987 2985
 		}
2988 2986
 		else
2989 2987
 		{
2990
-			$response->apply('egw.message', Array(lang('Error')),'error');
2988
+			$response->apply('egw.message', Array(lang('Error')), 'error');
2991 2989
 		}
2992 2990
 	}
2993 2991
 
@@ -3000,10 +2998,10 @@  discard block
 block discarded – undo
3000 2998
 	 */
3001 2999
 	public function ajax_invite($_eventId, $invite = array(), $remove = array())
3002 3000
 	{
3003
-		list($eventId, $date) = explode(':', $_eventId,2);
3001
+		list($eventId, $date) = explode(':', $_eventId, 2);
3004 3002
 
3005 3003
 		$event = $this->bo->read($eventId);
3006
-		if($date)
3004
+		if ($date)
3007 3005
 		{
3008 3006
 			$d = new Api\DateTime($date, Api\DateTime::$user_timezone);
3009 3007
 		}
@@ -3013,17 +3011,17 @@  discard block
 block discarded – undo
3013 3011
 		{
3014 3012
 			if (!empty($event['whole_day']))
3015 3013
 			{
3016
-				$d =& $this->bo->so->startOfDay($date);
3014
+				$d = & $this->bo->so->startOfDay($date);
3017 3015
 				$d->setUser();
3018 3016
 			}
3019 3017
 			$event = $this->bo->read($eventId, $d, true);
3020 3018
 			// For DnD, create an exception if they gave the date
3021 3019
 			$preserv = null;
3022
-			$this->_create_exception($event,$preserv);
3020
+			$this->_create_exception($event, $preserv);
3023 3021
 			unset($event['id']);
3024 3022
 
3025 3023
 			$messages = null;
3026
-			$conflicts = $this->bo->update($event,true,true,false,true,$messages);
3024
+			$conflicts = $this->bo->update($event, true, true, false, true, $messages);
3027 3025
 			if (!is_array($conflicts) && $conflicts)
3028 3026
 			{
3029 3027
 				// now we need to add the original start as recur-execption to the series
@@ -3031,28 +3029,28 @@  discard block
 block discarded – undo
3031 3029
 				$recur_event['recur_exception'][] = $d->format('ts');
3032 3030
 				// check if we need to move the alarms, because they are next on that exception
3033 3031
 				$this->bo->check_move_alarms($recur_event, null, $d);
3034
-				unset($recur_event['start']); unset($recur_event['end']);	// no update necessary
3035
-				unset($recur_event['alarm']);	// unsetting alarms too, as they cant be updated without start!
3036
-				$this->bo->update($recur_event,true);	// no conflict check here
3032
+				unset($recur_event['start']); unset($recur_event['end']); // no update necessary
3033
+				unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
3034
+				$this->bo->update($recur_event, true); // no conflict check here
3037 3035
 
3038 3036
 				// Sending null will trigger a removal of the original for that date
3039 3037
 				Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null));
3040 3038
 
3041 3039
 				unset($recur_event);
3042
-				unset($event['edit_single']);			// if we further edit it, it's just a single event
3040
+				unset($event['edit_single']); // if we further edit it, it's just a single event
3043 3041
 				unset($preserv['edit_single']);
3044 3042
 			}
3045 3043
 		}
3046
-		foreach($remove as $participant)
3044
+		foreach ($remove as $participant)
3047 3045
 		{
3048 3046
 			unset($event['participants'][$participant]);
3049 3047
 		}
3050
-		foreach($invite as $participant)
3048
+		foreach ($invite as $participant)
3051 3049
 		{
3052 3050
 			$event['participants'][$participant] = 'U';
3053 3051
 		}
3054 3052
 		$message = null;
3055
-		$conflicts=$this->bo->update($event,false, true, false, true, $message);
3053
+		$conflicts = $this->bo->update($event, false, true, false, true, $message);
3056 3054
 
3057 3055
 		$response = Api\Json\Response::get();
3058 3056
 
@@ -3060,8 +3058,8 @@  discard block
 block discarded – undo
3060 3058
 		{
3061 3059
 			// Save it anyway, was done with explicit user interaction,
3062 3060
 			// and if we don't we lose the invite
3063
-			$this->bo->update($event,true);	// no conflict check here
3064
-			$this->update_client($event['id'],$d);
3061
+			$this->bo->update($event, true); // no conflict check here
3062
+			$this->update_client($event['id'], $d);
3065 3063
 			$response->call(
3066 3064
 				'egw_openWindowCentered2',
3067 3065
 				$GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit
@@ -3070,22 +3068,22 @@  discard block
 block discarded – undo
3070 3068
 					.'&end='.$event['end']
3071 3069
 					.'&non_interactive=true'
3072 3070
 					.'&cancel_needs_refresh=true',
3073
-				'',750,410);
3071
+				'', 750, 410);
3074 3072
 		}
3075 3073
 		else if ($message)
3076 3074
 		{
3077
-			$response->call('egw.message',  implode('<br />', $message));
3075
+			$response->call('egw.message', implode('<br />', $message));
3078 3076
 		}
3079
-		if($conflicts)
3077
+		if ($conflicts)
3080 3078
 		{
3081
-			$this->update_client($event['id'],$d);
3082
-			if(is_int($conflicts))
3079
+			$this->update_client($event['id'], $d);
3080
+			if (is_int($conflicts))
3083 3081
 			{
3084 3082
 				$event['id'] = $conflicts;
3085 3083
 			}
3086
-			if($event['id'])
3084
+			if ($event['id'])
3087 3085
 			{
3088
-				$response->call('egw.refresh', '','calendar',$event['id'],'edit');
3086
+				$response->call('egw.refresh', '', 'calendar', $event['id'], 'edit');
3089 3087
 			}
3090 3088
 		}
3091 3089
 	}
@@ -3096,13 +3094,13 @@  discard block
 block discarded – undo
3096 3094
 	 * @param array $mailContent = null mail content
3097 3095
 	 * @return  array
3098 3096
 	 */
3099
-	function mail_import(array $mailContent=null)
3097
+	function mail_import(array $mailContent = null)
3100 3098
 	{
3101 3099
 		// It would get called from compose as a popup with egw_data
3102 3100
 		if (!is_array($mailContent) && ($_GET['egw_data']))
3103 3101
 		{
3104 3102
 			// get raw mail data
3105
-			Link::get_data ($_GET['egw_data']);
3103
+			Link::get_data($_GET['egw_data']);
3106 3104
 			return false;
3107 3105
 		}
3108 3106
 
@@ -3112,7 +3110,7 @@  discard block
 block discarded – undo
3112 3110
 			$AB = new Api\Contacts();
3113 3111
 			$accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']);
3114 3112
 
3115
-			$participants[0] = array (
3113
+			$participants[0] = array(
3116 3114
 				'uid' => $GLOBALS['egw_info']['user']['account_id'],
3117 3115
 				'delete_id' => $GLOBALS['egw_info']['user']['account_id'],
3118 3116
 				'status' => 'A',
@@ -3120,23 +3118,23 @@  discard block
 block discarded – undo
3120 3118
 				'app' => 'User',
3121 3119
 				'role' => 'REQ-PARTICIPANT'
3122 3120
 			);
3123
-			foreach($mailContent['addresses'] as $address)
3121
+			foreach ($mailContent['addresses'] as $address)
3124 3122
 			{
3125 3123
 				// Get available contacts from the email
3126 3124
 				$contacts = $AB->search(array(
3127 3125
 						'email' => $address['email'],
3128 3126
 						'email_home' => $address['email']
3129
-					),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false);
3127
+					), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false);
3130 3128
 				if (is_array($contacts))
3131 3129
 				{
3132
-					foreach($contacts as $account)
3130
+					foreach ($contacts as $account)
3133 3131
 					{
3134 3132
 						$accounts[] = $account['account_id'];
3135 3133
 					}
3136 3134
 				}
3137 3135
 				else
3138 3136
 				{
3139
-					$participants []= array (
3137
+					$participants [] = array(
3140 3138
 						'app' => 'email',
3141 3139
 						'uid' => 'e'.$address['email'],
3142 3140
 						'status' => 'U',
@@ -3144,7 +3142,7 @@  discard block
 block discarded – undo
3144 3142
 					);
3145 3143
 				}
3146 3144
 			}
3147
-			$participants = array_merge($participants , array(
3145
+			$participants = array_merge($participants, array(
3148 3146
 				"participant" => $accounts,
3149 3147
 				"role" => "REQ-PARTICIPANT",
3150 3148
 				"add" => "pressed"
@@ -3168,14 +3166,14 @@  discard block
 block discarded – undo
3168 3166
 			{
3169 3167
 				foreach ($mailContent['attachments'] as $attachment)
3170 3168
 				{
3171
-					if($attachment['egw_data'])
3169
+					if ($attachment['egw_data'])
3172 3170
 					{
3173
-						Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
3171
+						Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
3174 3172
 					}
3175
-					else if(is_readable($attachment['tmp_name']) ||
3173
+					else if (is_readable($attachment['tmp_name']) ||
3176 3174
 						(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
3177 3175
 					{
3178
-						Link::link('calendar',$event['link_to']['to_id'],'file',  $attachment);
3176
+						Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment);
3179 3177
 					}
3180 3178
 				}
3181 3179
 			}
Please login to merge, or discard this patch.