Completed
Push — master ( 471742...334697 )
by Ralf
15:03
created
calendar/inc/class.calendar_zpush.inc.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param int $cutoffdate =null
179 179
 	 * @param array $not_uids =null uids NOT to return for meeting requests
180 180
 	 * @return array
181
-  	 */
181
+	 */
182 182
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
183 183
 	{
184 184
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
@@ -1669,11 +1669,11 @@  discard block
 block discarded – undo
1669 1669
 	}
1670 1670
 }
1671 1671
 
1672
-    /**
1673
- * Testcode for active sync timezone stuff
1674
- *
1675
- * You need to comment implements activesync_plugin_write
1676
- */
1672
+	/**
1673
+	 * Testcode for active sync timezone stuff
1674
+	 *
1675
+	 * You need to comment implements activesync_plugin_write
1676
+	 */
1677 1677
 if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__)	// some tests
1678 1678
 {
1679 1679
 	$GLOBALS['egw_info'] = array(
Please login to merge, or discard this patch.
Spacing   +177 added lines, -178 removed lines patch added patch discarded remove patch
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
86 86
 
87 87
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
88
-		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
88
+		$cals = $cals_pref ? explode(',', $cals_pref) : array('P'); // implicit default of 'P'
89 89
 		$folderlist = array();
90 90
 
91 91
 		foreach ($this->calendar->list_cals() as $entry)
92 92
 		{
93 93
 			$account_id = $entry['grantor'];
94
-			if (in_array('A',$cals) || in_array($account_id,$cals) ||
95
-				$account_id == $GLOBALS['egw_info']['user']['account_id'] ||	// always incl. own calendar!
96
-				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals))
94
+			if (in_array('A', $cals) || in_array($account_id, $cals) ||
95
+				$account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar!
96
+				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals))
97 97
 			{
98 98
 				$folderlist[] = $f = array(
99
-					'id'	=>	$this->backend->createID('calendar',$account_id),
100
-					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'),
99
+					'id'	=>	$this->backend->createID('calendar', $account_id),
100
+					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'),
101 101
 					'parent'=>	'0',
102 102
 				);
103 103
 			}
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		$folderObj = new SyncFolder();
122 122
 		$folderObj->serverid = $id;
123 123
 		$folderObj->parentid = '0';
124
-		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname');
124
+		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname');
125 125
 		if ($owner == $GLOBALS['egw_info']['user']['account_id'])
126 126
 		{
127 127
 			$folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$stat = array(
157 157
 			'id'	 => $id,
158
-			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'),
158
+			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'),
159 159
 			'parent' => '0',
160 160
 		);
161 161
 		//error_log(__METHOD__."('$id') folderObj=".array2string($stat));
@@ -179,19 +179,19 @@  discard block
 block discarded – undo
179 179
 	 * @param array $not_uids =null uids NOT to return for meeting requests
180 180
 	 * @return array
181 181
   	 */
182
-	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182
+	function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null)
183 183
 	{
184 184
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
185 185
 
186 186
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
187 187
 		$type = $user = null;
188
-		$this->backend->splitID($id,$type,$user);
188
+		$this->backend->splitID($id, $type, $user);
189 189
 
190
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
190
+		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences
191 191
 
192 192
 		$filter = array(
193 193
 			'users' => $user,
194
-			'start' => $cutoffdate,	// default one month back -30 breaks all sync recurrences
194
+			'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences
195 195
 			'enum_recuring' => false,
196 196
 			'daywise' => false,
197 197
 			'date_format' => 'server',
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
 			//'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default',
203 203
 			// @todo return only etag relevant information (seems not to work ...)
204 204
 			//'cols'		=> array('egw_cal.cal_id', 'cal_start',	'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'),
205
-			'query' => array('cal_recurrence' => 0),	// do NOT return recurrence exceptions
205
+			'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions
206 206
 		);
207 207
 
208 208
 		$messagelist = array();
209 209
 		// reading events in chunks of 100, to keep memory down for huge calendars
210 210
 		$num_rows = 100;
211
-		for($start=0; ($events = $this->calendar->search($filter+array(
211
+		for ($start = 0; ($events = $this->calendar->search($filter + array(
212 212
 			'offset'   => $start,
213 213
 			'num_rows' => $num_rows,
214 214
 		))); $start += $num_rows)
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param int $cutoffdate =null
244 244
 	 * @return array
245 245
 	 */
246
-	function GetMeetingRequests(array $not_uids, $cutoffdate=NULL)
246
+	function GetMeetingRequests(array $not_uids, $cutoffdate = NULL)
247 247
 	{
248 248
 		unset($not_uids, $cutoffdate);
249 249
 		return array();
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 */
270 270
 	function StatMeetingRequest($id)
271 271
 	{
272
-		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']);	// users personal calendar
272
+		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar
273 273
 
274 274
 		$ret = $this->StatMessage($folderid, abs($id));
275 275
 		$ret['id'] = $id;
@@ -288,9 +288,9 @@  discard block
 block discarded – undo
288 288
 	 * @param bool $mimesupport
289 289
 	 * @return SyncMail
290 290
 	 */
291
-	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
291
+	function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
292 292
 	{
293
-		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
293
+		unset($truncsize, $optionbodypreference, $mimesupport); // not used, but required by function signature
294 294
 
295 295
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
296 296
 
@@ -303,13 +303,13 @@  discard block
 block discarded – undo
303 303
 			$message = new SyncMail();
304 304
 			$message->read = false;
305 305
 			$message->subject = $event['title'];
306
-			$message->importance = 1;	// 0=Low, 1=Normal, 2=High
306
+			$message->importance = 1; // 0=Low, 1=Normal, 2=High
307 307
 			$message->datereceived = $event['created'];
308 308
 			$message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email'];
309
-			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname').
310
-				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>';
309
+			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname').
310
+				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>';
311 311
 			$message->internetcpid = 65001;
312
-			$message->contentclass="urn:content-classes:message";
312
+			$message->contentclass = "urn:content-classes:message";
313 313
 
314 314
 			$message->meetingrequest = self::meetingRequest($event);
315 315
 			$message->messageclass = "IPM.Schedule.Meeting.Request";
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 			else
325 325
 			{
326 326
 				$message->airsyncbasebody = new SyncAirSyncBaseBody();
327
-				$message->airsyncbasenativebodytype=1;
327
+				$message->airsyncbasenativebodytype = 1;
328 328
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody);
329 329
 			}
330 330
 		}
@@ -359,12 +359,12 @@  discard block
 block discarded – undo
359 359
 			$as_tz = self::tz2as($event['tzid']);
360 360
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
361 361
 		}
362
-		catch(Exception $e) {
362
+		catch (Exception $e) {
363 363
 			unset($e);
364 364
 			// ignore exception, simply set no timezone, as it is optional
365 365
 		}
366 366
 		// copying timestamps (they are already read in servertime, so non tz conversation)
367
-		foreach(array(
367
+		foreach (array(
368 368
 			'start' => 'starttime',
369 369
 			'end'   => 'endtime',
370 370
 			'created' => 'dtstamp',
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 		}
375 375
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
376 376
 		{
377
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
377
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
378 378
 		}
379 379
 		// copying strings
380
-		foreach(array(
380
+		foreach (array(
381 381
 			'title' => 'subject',
382 382
 			'location' => 'location',
383 383
 		) as $key => $attr)
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 		}
387 387
 		$message->organizer = $event['organizer'];
388 388
 
389
-		$message->sensitivity = !isset($event['public']) || $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
389
+		$message->sensitivity = !isset($event['public']) || $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
390 390
 
391 391
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
392 392
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
393 393
 
394 394
 		// ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ...
395
-		$message->instancetype = 0;	// 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
395
+		$message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
396 396
 
397
-		$message->responserequested = 1;	//0=No, 1=Yes
398
-		$message->disallownewtimeproposal = 1;	//1=forbidden, 0=allowed
397
+		$message->responserequested = 1; //0=No, 1=Yes
398
+		$message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed
399 399
 		//$message->messagemeetingtype;	// email2
400 400
 
401 401
 		// ToDo: alarme: Reminder
@@ -441,14 +441,14 @@  discard block
 block discarded – undo
441 441
 			// check if event already exist (invitation of or already imported by other user)
442 442
 			if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server')))
443 443
 			{
444
-				$event = $parsed_event;	// create new event from external invitation
444
+				$event = $parsed_event; // create new event from external invitation
445 445
 			}
446
-			elseif(!isset($event['participants'][$uid]))
446
+			elseif (!isset($event['participants'][$uid]))
447 447
 			{
448 448
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event));
449 449
 				// maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ...
450 450
 			}
451
-			elseif($event['deleted'])
451
+			elseif ($event['deleted'])
452 452
 			{
453 453
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false");
454 454
 				return false;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		else
474 474
 		{
475 475
 			$event['participants'][$uid] = $status;
476
-			$ret = $this->calendar->update($event, true);	// true = ignore conflicts, as there seems no conflict handling in AS
476
+			$ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS
477 477
 			$msg = $ret ? "new event #$ret created" : "could NOT create event";
478 478
 			ZLog::Write(LOGLEVEL_DEBUG, __LINE__.': '.__METHOD__.'('.array2string($requestid).", '$folderid', $response) $msg, returning ".array2string($ret));
479 479
 		}
@@ -486,10 +486,10 @@  discard block
 block discarded – undo
486 486
 	 * @var array
487 487
 	 */
488 488
 	static $status2as = array(
489
-		'U' => 0,	// unknown
490
-		'T' => 2,	// tentative
491
-		'A' => 3,	// accepted
492
-		'R' => 4,	// decline
489
+		'U' => 0, // unknown
490
+		'T' => 2, // tentative
491
+		'A' => 3, // accepted
492
+		'R' => 4, // decline
493 493
 		// 5 = not responded
494 494
 	);
495 495
 	/**
@@ -498,9 +498,9 @@  discard block
 block discarded – undo
498 498
 	 * @var array
499 499
 	 */
500 500
 	static $role2as = array(
501
-		'REQ-PARTICIPANT' => 1,	// required
502
-		'CHAIR' => 1,			// required
503
-		'OPT-PARTICIPANT' => 2,	// optional
501
+		'REQ-PARTICIPANT' => 1, // required
502
+		'CHAIR' => 1, // required
503
+		'OPT-PARTICIPANT' => 2, // optional
504 504
 		'NON-PARTICIPANT' => 2,
505 505
 		// 3 = ressource
506 506
 	);
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
 	static $recur_type2as = array(
513 513
 		calendar_rrule::DAILY => 0,
514 514
 		calendar_rrule::WEEKLY => 1,
515
-		calendar_rrule::MONTHLY_MDAY => 2,	// monthly
516
-		calendar_rrule::MONTHLY_WDAY => 3,	// monthly on nth day
515
+		calendar_rrule::MONTHLY_MDAY => 2, // monthly
516
+		calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day
517 517
 		calendar_rrule::YEARLY => 5,
518 518
 		// 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears)
519 519
 	);
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	 */
541 541
 	public function ChangeMessage($folderid, $_id, $message, $contentParameters)
542 542
 	{
543
-		unset($contentParameters);	// unused, but required by function signature
543
+		unset($contentParameters); // unused, but required by function signature
544 544
 
545 545
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
546 546
 
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 
551 551
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $_id, ".array2string($message).") type='$type', account=$account");
552 552
 
553
-		list($id,$recur_date) = explode(':', $_id);
553
+		list($id, $recur_date) = explode(':', $_id);
554 554
 
555 555
 		if ($type != 'calendar' || $id && !($old_event = $this->calendar->read($id, $recur_date, false, 'server')))
556 556
 		{
@@ -563,21 +563,21 @@  discard block
 block discarded – undo
563 563
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
564 564
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
565 565
 		}
566
-		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
566
+		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0, $account))
567 567
 		{
568 568
 			// @todo: write in users calendar and make account only a participant
569 569
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) no rights to add/edit event!");
570 570
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
571 571
 			return false;
572 572
 		}
573
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
573
+		if (!$id) $old_event['owner'] = $account; // we do NOT allow to change the owner of existing events
574 574
 
575 575
 		$event = $this->message2event($message, $account, $old_event);
576 576
 
577 577
 		// store event, ignore conflicts and skip notifications, as AS clients do their own notifications
578 578
 		$skip_notification = false;
579 579
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']) &&
580
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations']=='send')
580
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['mail-allowSendingInvitations'] == 'send')
581 581
 		{
582 582
 			$skip_notification = true; // to avoid double notification from client AND Server
583 583
 		}
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 		// store non-delete exceptions
591 591
 		if ($message->exceptions)
592 592
 		{
593
-			foreach($message->exceptions as $exception)
593
+			foreach ($message->exceptions as $exception)
594 594
 			{
595 595
 				if (!$exception->deleted)
596 596
 				{
597 597
 					$ex_event = $event;
598 598
 					unset($ex_event['id']);
599 599
 					unset($ex_event['etag']);
600
-					foreach(array_keys($ex_event) as $name)
600
+					foreach (array_keys($ex_event) as $name)
601 601
 					{
602
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
602
+						if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]);
603 603
 					}
604 604
 					$ex_event['recur_type'] = calendar_rrule::NONE;
605 605
 
@@ -607,10 +607,10 @@  discard block
 block discarded – undo
607 607
 						'user' => $account,
608 608
 						'enum_recuring' => false,
609 609
 						'daywise' => false,
610
-						'filter' => 'owner',  // return all possible entries
610
+						'filter' => 'owner', // return all possible entries
611 611
 						'query' => array(
612 612
 							'cal_uid' => $event['uid'],
613
-							'cal_recurrence' => $exception->exceptionstarttime,	// in servertime
613
+							'cal_recurrence' => $exception->exceptionstarttime, // in servertime
614 614
 						),
615 615
 					))))
616 616
 					{
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 						$participants = $event['participants'];
623 623
 					}
624 624
 					$save_event = $this->message2event($exception, $account, $ex_event);
625
-					$save_event['participants'] = $participants;	// not contained in $exception
625
+					$save_event['participants'] = $participants; // not contained in $exception
626 626
 					$save_event['reference'] = $event['id'];
627 627
 					$save_event['recurrence'] = Api\DateTime::server2user($exception->exceptionstarttime);
628 628
 					$ex_ok = $this->calendar->save($save_event);
@@ -644,10 +644,10 @@  discard block
 block discarded – undo
644 644
 	 * @param array $event =array()
645 645
 	 * @return array
646 646
 	 */
647
-	private function message2event(SyncAppointment $message, $account, $event=array())
647
+	private function message2event(SyncAppointment $message, $account, $event = array())
648 648
 	{
649 649
 		// timestamps (created & modified are updated automatically)
650
-		foreach(array(
650
+		foreach (array(
651 651
 			'start' => 'starttime',
652 652
 			'end' => 'endtime',
653 653
 		) as $key => $attr)
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
656 656
 		}
657 657
 		// copying strings
658
-		foreach(array(
658
+		foreach (array(
659 659
 			'title' => 'subject',
660 660
 			'uid'   => 'uid',
661 661
 			'location' => 'location',
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 		{
671 671
 			$event['description'] = $description;
672 672
 		}
673
-		$event['public'] = (int)($message->sensitivity < 1);	// 0=normal, 1=personal, 2=private, 3=confidential
673
+		$event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential
674 674
 
675 675
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
676 676
 		if (isset($message->busystatus))
@@ -680,21 +680,21 @@  discard block
 block discarded – undo
680 680
 
681 681
 		if (($event['whole_day'] = $message->alldayevent))
682 682
 		{
683
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
684
-			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
683
+			if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day
684
+			$event['end']--; // otherwise our whole-day event code in save makes it one more day!
685 685
 		}
686 686
 
687 687
 		$participants = array();
688
-		foreach((array)$message->attendees as $attendee)
688
+		foreach ((array)$message->attendees as $attendee)
689 689
 		{
690
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
690
+			if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later
691 691
 
692 692
 			$matches = null;
693
-			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
693
+			if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches))
694 694
 			{
695 695
 				$uid = $matches[1];
696 696
 			}
697
-			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email')))
697
+			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email')))
698 698
 			{
699 699
 				$search = array(
700 700
 					'email' => $attendee->email,
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
 				// search addressbook for participant
705 705
 				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
706 706
 				if ((list($data) = $this->addressbook->search($search,
707
-					array('id','egw_addressbook.account_id as account_id','n_fn'),
707
+					array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
708 708
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
709
-					'','',false,'OR')))
709
+					'', '', false, 'OR')))
710 710
 				{
711 711
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
712 712
 				}
713
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
713
+				elseif ($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
714 714
 				{
715 715
 					$uid = 'e'.$attendee->email;
716 716
 				}
@@ -728,8 +728,8 @@  discard block
 block discarded – undo
728 728
 				//ZLog::Write(LOGLEVEL_DEBUG, "old status for $uid is status=$status, quantity=$quantitiy, role=$role");
729 729
 			}
730 730
 			// check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set
731
-			elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) ||
732
-				(isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>']))))
731
+			elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) ||
732
+				(isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>']))))
733 733
 			{
734 734
 				$status = $event['participants'][$u];
735 735
 				calendar_so::split_status($status, $quantity, $role);
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
 				$role = 'REQ-PARTICIPANT';
743 743
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
744 744
 			}
745
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
745
+			if ($role == 'CHAIR') $chair_set = true; // by role from existing participant
746 746
 
747
-			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
747
+			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as)))
748 748
 			{
749 749
 				$status = $s;
750 750
 			}
@@ -754,29 +754,29 @@  discard block
 block discarded – undo
754 754
 				$chair_set = true;
755 755
 			}
756 756
 			elseif (isset($attendee->attendeetype) &&
757
-				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
758
-				($r = array_search($attendee->attendeetype,self::$role2as)) &&
757
+				!($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER
758
+				($r = array_search($attendee->attendeetype, self::$role2as)) &&
759 759
 				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
760 760
 			{
761 761
 				$role = $r;
762 762
 			}
763 763
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
764
-			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
764
+			$participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role);
765 765
 		}
766 766
 		// if organizer is not already participant, add him as chair
767
-		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid]))
767
+		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid]))
768 768
 		{
769 769
 			$participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ?
770
-				'A' : 'U',1,'CHAIR');
770
+				'A' : 'U', 1, 'CHAIR');
771 771
 			$chair_set = true;
772 772
 		}
773 773
 		// preserve all resource types not account, contact or email (eg. resources) for existing events
774 774
 		// $account is also preserved, as AS does not add him as participant!
775
-		foreach((array)$event['participant_types'] as $type => $parts)
775
+		foreach ((array)$event['participant_types'] as $type => $parts)
776 776
 		{
777
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
777
+			if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS
778 778
 
779
-			foreach($parts as $id => $status)
779
+			foreach ($parts as $id => $status)
780 780
 			{
781 781
 				// accounts are represented correctly, but the event owner which is no participant in AS
782 782
 				if ($type == 'u' && $id != $account) continue;
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 		if (!$event['id'] || !$participants || !isset($participants[$account]))
793 793
 		{
794 794
 			$participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ?
795
-				'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
795
+				'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
796 796
 		}
797 797
 		$event['participants'] = $participants;
798 798
 
799 799
 		if (isset($message->categories))
800 800
 		{
801
-			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen'));
801
+			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen'));
802 802
 		}
803 803
 
804 804
 		// check if event is recurring and import recur information (incl. timezone)
@@ -808,8 +808,7 @@  discard block
 block discarded – undo
808 808
 			{
809 809
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
810 810
 			}
811
-			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
812
-				array_search($message->recurrence->type, self::$recur_type2as);
811
+			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as);
813 812
 			$event['recur_interval'] = $message->recurrence->interval;
814 813
 
815 814
 			switch ($event['recur_type'])
@@ -818,7 +817,7 @@  discard block
 block discarded – undo
818 817
 					// $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date
819 818
 					// fall throught
820 819
 				case calendar_rrule::WEEKLY:
821
-					$event['recur_data'] = $message->recurrence->dayofweek;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
820
+					$event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
822 821
 					break;
823 822
 				case calendar_rrule::MONTHLY_MDAY:
824 823
 					// $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date
@@ -834,7 +833,7 @@  discard block
 block discarded – undo
834 833
 			$event['recur_exception'] = array();
835 834
 			if ($message->exceptions)
836 835
 			{
837
-				foreach($message->exceptions as $exception)
836
+				foreach ($message->exceptions as $exception)
838 837
 				{
839 838
 					$event['recur_exception'][] = Api\DateTime::server2user($exception->exceptionstarttime);
840 839
 				}
@@ -844,7 +843,7 @@  discard block
 block discarded – undo
844 843
 			{
845 844
 				// calculate enddate from occurences count, as we only support enddate
846 845
 				$count = $message->recurrence->occurrences;
847
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
846
+				foreach (calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
848 847
 				{
849 848
 					if (--$count <= 0) break;
850 849
 				}
@@ -854,11 +853,11 @@  discard block
 block discarded – undo
854 853
 		// only import alarms in own calendar
855 854
 		if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id'])
856 855
 		{
857
-			foreach((array)$event['alarm'] as $alarm)
856
+			foreach ((array)$event['alarm'] as $alarm)
858 857
 			{
859
-				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder)
858
+				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder)
860 859
 				{
861
-					$alarm = true;	// alarm already exists --> do nothing
860
+					$alarm = true; // alarm already exists --> do nothing
862 861
 					break;
863 862
 				}
864 863
 			}
@@ -867,16 +866,16 @@  discard block
 block discarded – undo
867 866
 				// delete all earlier alarms of that user
868 867
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
869 868
 				// --> if a later alarm is returned, user probably modifed an existing alarm
870
-				foreach((array)$event['alarm'] as $key => $alarm)
869
+				foreach ((array)$event['alarm'] as $key => $alarm)
871 870
 				{
872
-					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
871
+					if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder)
873 872
 					{
874 873
 						unset($event['alarm'][$key]);
875 874
 					}
876 875
 				}
877 876
 				$event['alarm'][] = $alarm = array(
878 877
 					'owner' => $account,
879
-					'offset' => 60*$message->reminder,
878
+					'offset' => 60 * $message->reminder,
880 879
 				);
881 880
 			}
882 881
 		}
@@ -950,7 +949,7 @@  discard block
 block discarded – undo
950 949
 	 */
951 950
 	public function DeleteMessage($folderid, $id, $contentParameters)
952 951
 	{
953
-		unset($contentParameters);	// not used, but required by function signature
952
+		unset($contentParameters); // not used, but required by function signature
954 953
 
955 954
 		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
956 955
 
@@ -978,7 +977,7 @@  discard block
 block discarded – undo
978 977
 	 */
979 978
 	function SetReadFlag($folderid, $id, $flags, $contentParameters)
980 979
 	{
981
-		unset($contentParameters);	// not used, but required by function signature
980
+		unset($contentParameters); // not used, but required by function signature
982 981
 
983 982
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id, ".array2string($flags)." NOT supported!");
984 983
 		return false;
@@ -1012,7 +1011,7 @@  discard block
 block discarded – undo
1012 1011
 	 * @param string $class ='SyncAppointment' or 'SyncAppointmentException'
1013 1012
 	 * @return SyncAppointment|boolean false on error
1014 1013
 	 */
1015
-	public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment')
1014
+	public function GetMessage($folderid, $id, $contentparameters, $class = 'SyncAppointment')
1016 1015
 	{
1017 1016
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1018 1017
 		//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace());
@@ -1030,17 +1029,17 @@  discard block
 block discarded – undo
1030 1029
 		}
1031 1030
 		else
1032 1031
 		{
1033
-			list($id,$recur_date) = explode(':',$id);
1034
-			if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account)))
1032
+			list($id, $recur_date) = explode(':', $id);
1033
+			if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account)))
1035 1034
 			{
1036 1035
 				error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false");
1037 1036
 				return false;
1038 1037
 			}
1039 1038
 		}
1040
-		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence']));
1041
-		foreach((array)$event['recur_exception'] as $ex)
1039
+		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence']));
1040
+		foreach ((array)$event['recur_exception'] as $ex)
1042 1041
 		{
1043
-			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s',$ex));
1042
+			ZLog::Write(LOGLEVEL_DEBUG, "exception=$ex=".date('Y-m-d H:i:s', $ex));
1044 1043
 		}
1045 1044
 		$message = new $class();
1046 1045
 
@@ -1049,14 +1048,14 @@  discard block
 block discarded – undo
1049 1048
 			$as_tz = self::tz2as($event['tzid']);
1050 1049
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
1051 1050
 		}
1052
-		catch(Exception $e) {
1051
+		catch (Exception $e) {
1053 1052
 			unset($e);
1054 1053
 			// z-push (2.3 at least) requires a timezone for recurring events
1055 1054
 			if ($event['recur_type']) $message->timezone = self::UTC_BLOB;
1056 1055
 		}
1057 1056
 
1058 1057
 		// copying timestamps (they are already read in servertime, so non tz conversation)
1059
-		foreach(array(
1058
+		foreach (array(
1060 1059
 			'start' => 'starttime',
1061 1060
 			'end'   => 'endtime',
1062 1061
 			'created' => 'dtstamp',
@@ -1067,10 +1066,10 @@  discard block
 block discarded – undo
1067 1066
 		}
1068 1067
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1069 1068
 		{
1070
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
1069
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
1071 1070
 		}
1072 1071
 		// copying strings
1073
-		foreach(array(
1072
+		foreach (array(
1074 1073
 			'title' => 'subject',
1075 1074
 			'uid'   => 'uid',
1076 1075
 			'location' => 'location',
@@ -1092,21 +1091,21 @@  discard block
 block discarded – undo
1092 1091
 			{
1093 1092
 				ZLog::Write(LOGLEVEL_DEBUG, "airsyncbasebody!");
1094 1093
 				$message->asbody = new SyncBaseBody();
1095
-				$message->nativebodytype=1;
1094
+				$message->nativebodytype = 1;
1096 1095
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->asbody);
1097 1096
 			}
1098 1097
 		}
1099
-		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname');
1098
+		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname');
1100 1099
 		// at least iOS calendar crashes, if organizer has no email address (true = generate an email, if user has none)
1101 1100
 		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email', true);
1102 1101
 
1103
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
1102
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
1104 1103
 
1105 1104
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
1106 1105
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
1107 1106
 
1108 1107
 		$message->attendees = array();
1109
-		foreach($event['participants'] as $uid => $status)
1108
+		foreach ($event['participants'] as $uid => $status)
1110 1109
 		{
1111 1110
 			// we send all participants (incl. organizer), as this is what Exchange also does
1112 1111
 			$quantity = $role = null;
@@ -1117,13 +1116,13 @@  discard block
 block discarded – undo
1117 1116
 			$attendee->attendeetype = (int)self::$role2as[$role];
1118 1117
 			if (is_numeric($uid))
1119 1118
 			{
1120
-				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname');
1119
+				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname');
1121 1120
 				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email', true);
1122 1121
 			}
1123 1122
 			else
1124 1123
 			{
1125 1124
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1126
-					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1125
+					ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false);
1127 1126
 
1128 1127
 				if (!$info) continue;
1129 1128
 
@@ -1141,7 +1140,7 @@  discard block
 block discarded – undo
1141 1140
 					$message->organizeremail = $attendee->email;
1142 1141
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1143 1142
 				}
1144
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1143
+				if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource
1145 1144
 			}
1146 1145
 			// email must NOT be empty, but MAY be an arbitrary text
1147 1146
 			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
@@ -1149,7 +1148,7 @@  discard block
 block discarded – undo
1149 1148
 			$message->attendees[] = $attendee;
1150 1149
 		}
1151 1150
 		$message->categories = array();
1152
-		foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id)
1151
+		foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id)
1153 1152
 		{
1154 1153
 			$message->categories[] = Api\Categories::id2name($cat_id);
1155 1154
 		}
@@ -1158,25 +1157,25 @@  discard block
 block discarded – undo
1158 1157
 		if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date)
1159 1158
 		{
1160 1159
 			$message->recurrence = $recurrence = new SyncRecurrence();
1161
-			$rrule = calendar_rrule::event2rrule($event,false);	// false = timestamps in $event are servertime
1160
+			$rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime
1162 1161
 			$recurrence->type = (int)self::$recur_type2as[$rrule->type];
1163 1162
 			$recurrence->interval = $rrule->interval;
1164 1163
 			switch ($rrule->type)
1165 1164
 			{
1166 1165
 				case calendar_rrule::MONTHLY_WDAY:
1167 1166
 					$recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ?
1168
-						$rrule->monthly_byday_num : 5;	// 1..5=last week of month, not -1
1167
+						$rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1
1169 1168
 					// fall throught
1170 1169
 				case calendar_rrule::WEEKLY:
1171
-					$recurrence->dayofweek = $rrule->weekdays;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1170
+					$recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1172 1171
 					break;
1173 1172
 				case calendar_rrule::MONTHLY_MDAY:
1174
-					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ?	// 1..31
1175
-						$rrule->monthly_bymonthday : 31;	// not -1 for last day of month!
1173
+					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31
1174
+						$rrule->monthly_bymonthday : 31; // not -1 for last day of month!
1176 1175
 					break;
1177 1176
 				case calendar_rrule::YEARLY:
1178
-					$recurrence->dayofmonth = (int)$rrule->time->format('d');	// 1..31
1179
-					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1177
+					$recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31
1178
+					$recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12
1180 1179
 					break;
1181 1180
 			}
1182 1181
 			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
@@ -1192,9 +1191,9 @@  discard block
 block discarded – undo
1192 1191
 				// search real / non-virtual exceptions
1193 1192
 				if (!empty($event['uid']))
1194 1193
 				{
1195
-					$ex_events =& $this->calendar->search(array(
1194
+					$ex_events = & $this->calendar->search(array(
1196 1195
 						'query' => array('cal_uid' => $event['uid']),
1197
-						'filter' => 'owner',  // return all possible entries
1196
+						'filter' => 'owner', // return all possible entries
1198 1197
 						'daywise' => false,
1199 1198
 						'date_format' => 'server',
1200 1199
 					));
@@ -1203,36 +1202,36 @@  discard block
 block discarded – undo
1203 1202
 				{
1204 1203
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1205 1204
 				}
1206
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1205
+				if (count($ex_events) >= 1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1207 1206
 
1208 1207
 				$message->exceptions = array();
1209
-				foreach($ex_events as $ex_event)
1208
+				foreach ($ex_events as $ex_event)
1210 1209
 				{
1211
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1210
+					if ($ex_event['id'] == $event['id']) continue; // ignore series master
1212 1211
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException');
1213 1212
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1214
-					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
1213
+					foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported)
1215 1214
 					{
1216
-						$exception->$not_supported = null;	// not allowed in exceptions :-(
1215
+						$exception->$not_supported = null; // not allowed in exceptions :-(
1217 1216
 					}
1218 1217
 					$exception->deleted = 0;
1219
-					if (($key = array_search($exception_time,$event['recur_exception'])) !== false)
1218
+					if (($key = array_search($exception_time, $event['recur_exception'])) !== false)
1220 1219
 					{
1221 1220
 						unset($event['recur_exception'][$key]);
1222 1221
 					}
1223
-					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1222
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1224 1223
 					$message->exceptions[] = $exception;
1225 1224
 				}
1226 1225
 				// add rest of exceptions as deleted
1227
-				foreach($event['recur_exception'] as $exception_time)
1226
+				foreach ($event['recur_exception'] as $exception_time)
1228 1227
 				{
1229 1228
 					if (!empty($exception_time))
1230 1229
 					{
1231 1230
 						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1232
-						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1231
+						$exception = new SyncAppointmentException(); // exceptions seems to be full SyncAppointments, with only starttime required
1233 1232
 						$exception->deleted = 1;
1234 1233
 						$exception->exceptionstarttime = $exception_time;
1235
-						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1234
+						ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1236 1235
 						$message->exceptions[] = $exception;
1237 1236
 					}
1238 1237
 				}
@@ -1254,12 +1253,12 @@  discard block
 block discarded – undo
1254 1253
 		// only return alarms if in own calendar
1255 1254
 		if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm'])
1256 1255
 		{
1257
-			foreach($event['alarm'] as $alarm)
1256
+			foreach ($event['alarm'] as $alarm)
1258 1257
 			{
1259 1258
 				if ($alarm['all'] || $alarm['owner'] == $account)
1260 1259
 				{
1261
-					$message->reminder = $alarm['offset']/60;	// is in minutes, not seconds as in EGw
1262
-					break;	// AS supports only one alarm! (we use the next/earliest one)
1260
+					$message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw
1261
+					break; // AS supports only one alarm! (we use the next/earliest one)
1263 1262
 				}
1264 1263
 			}
1265 1264
 		}
@@ -1282,7 +1281,7 @@  discard block
 block discarded – undo
1282 1281
 	 */
1283 1282
 	public function StatMessage($folderid, $id)
1284 1283
 	{
1285
-		unset($folderid);	// not used ($id is unique), but required by function signature
1284
+		unset($folderid); // not used ($id is unique), but required by function signature
1286 1285
 
1287 1286
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1288 1287
 
@@ -1293,7 +1292,7 @@  discard block
 block discarded – undo
1293 1292
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1294 1293
 			$backup = $this->calendar->debug;
1295 1294
 			//$this->calendar->debug = 2;
1296
-			list($id) = explode(':',$id);
1295
+			list($id) = explode(':', $id);
1297 1296
 			$this->calendar->check_perms(calendar_bo::ACL_FREEBUSY, $id, 0, 'server');
1298 1297
 			$this->calendar->debug = $backup;
1299 1298
 		}
@@ -1327,7 +1326,7 @@  discard block
 block discarded – undo
1327 1326
 
1328 1327
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1329 1328
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1330
-		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1329
+		$syncstate = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too
1331 1330
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1332 1331
 		if ($syncstate == 0) $syncstate = 1;
1333 1332
 
@@ -1407,8 +1406,8 @@  discard block
 block discarded – undo
1407 1406
 
1408 1407
 		if ($tz === 'UTC') return $data;
1409 1408
 
1410
-		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1411
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1409
+		$name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz;
1410
+		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component');
1412 1411
 		// parse ical timezone defintion
1413 1412
 		$ical = self::ical2array($component);
1414 1413
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1417,11 +1416,11 @@  discard block
 block discarded – undo
1417 1416
 		if (!isset($standard))
1418 1417
 		{
1419 1418
 			$matches = null;
1420
-			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches))
1419
+			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches))
1421 1420
 			{
1422 1421
 				$standard = array(
1423
-					'TZOFFSETTO'   => sprintf('%s%02d00',$matches[1],$matches[2]),
1424
-					'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]),
1422
+					'TZOFFSETTO'   => sprintf('%s%02d00', $matches[1], $matches[2]),
1423
+					'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]),
1425 1424
 				);
1426 1425
 				unset($daylight);
1427 1426
 			}
@@ -1432,19 +1431,19 @@  discard block
 block discarded – undo
1432 1431
 		}
1433 1432
 		// get bias and dstbias from standard component, which is present in all tz's
1434 1433
 		// (dstbias is relative to bias and almost always 60 or 0)
1435
-		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2));
1436
-		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']);
1434
+		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2));
1435
+		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']);
1437 1436
 
1438 1437
 		// check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving
1439 1438
 		if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE']))
1440 1439
 		{
1441
-			foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp)
1440
+			foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp)
1442 1441
 			{
1443 1442
 				// fix RRULE order
1444 1443
 				$comp['RRULE'] = preg_replace('/FREQ=YEARLY;BYMONTH=(\d+);BYDAY=(.*)/',
1445 1444
 					'FREQ=YEARLY;BYDAY=$2;BYMONTH=$1', $comp['RRULE']);
1446 1445
 
1447
-				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches))
1446
+				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches))
1448 1447
 				{
1449 1448
 					$data[$prefix.'month'] = (int)$matches[2];
1450 1449
 					$data[$prefix.'week'] = (int)$matches[1];
@@ -1461,20 +1460,20 @@  discard block
 block discarded – undo
1461 1460
 						$data[$prefix.'week'] = 5;
1462 1461
 						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1463 1462
 					}
1464
-					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1465
-					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
1463
+					static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6);
1464
+					$data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)];
1466 1465
 				}
1467
-				if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches))
1466
+				if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches))
1468 1467
 				{
1469
-					$data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60;
1470
-					$data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60;
1471
-					$data[$prefix.'second'] = (int)substr($matches[1],4,2);
1468
+					$data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60;
1469
+					$data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60;
1470
+					$data[$prefix.'second'] = (int)substr($matches[1], 4, 2);
1472 1471
 				}
1473 1472
 			}
1474 1473
 			// for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute
1475 1474
 			if ($data['dststartmonth'] > $data['dstendmonth'])
1476 1475
 			{
1477
-				$start = $data['dststarthour'];   $data['dststarthour'] = $data['dstendhour'];     $data['dstendhour'] = $start;
1476
+				$start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start;
1478 1477
 				$end = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $end;
1479 1478
 			}
1480 1479
 		}
@@ -1532,20 +1531,20 @@  discard block
 block discarded – undo
1532 1531
 	 * @param string|array $ical lines of ical file
1533 1532
 	 * @return array with parsed ical components
1534 1533
 	 */
1535
-	static public function ical2array(&$ical,$section=null)
1534
+	static public function ical2array(&$ical, $section = null)
1536 1535
 	{
1537 1536
 		$arr = array();
1538 1537
 		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1539 1538
 		while (($line = array_shift($ical)))
1540 1539
 		{
1541
-			list($name,$value) = explode(':',$line,2);
1540
+			list($name, $value) = explode(':', $line, 2);
1542 1541
 			if ($name == 'BEGIN')
1543 1542
 			{
1544
-				$arr[$value] = self::ical2array($ical,$value);
1543
+				$arr[$value] = self::ical2array($ical, $value);
1545 1544
 			}
1546
-			elseif($name == 'END')
1545
+			elseif ($name == 'END')
1547 1546
 			{
1548
-				if ($section && $section==$value) return $arr;
1547
+				if ($section && $section == $value) return $arr;
1549 1548
 				break;
1550 1549
 			}
1551 1550
 			else
@@ -1568,13 +1567,13 @@  discard block
 block discarded – undo
1568 1567
 	 */
1569 1568
 	public static function as2tz(array $data)
1570 1569
 	{
1571
-		static $cache=null;	// some caching withing the request
1570
+		static $cache = null; // some caching withing the request
1572 1571
 
1573
-		unset($data['name']);	// not used, but can stall the match
1572
+		unset($data['name']); // not used, but can stall the match
1574 1573
 
1575 1574
 		$key = serialize($data);
1576 1575
 
1577
-		for($n = 0; !isset($cache[$key]); ++$n)
1576
+		for ($n = 0; !isset($cache[$key]); ++$n)
1578 1577
 		{
1579 1578
 			if (!$n)	// check users timezone first
1580 1579
 			{
@@ -1593,7 +1592,7 @@  discard block
 block discarded – undo
1593 1592
 					break;
1594 1593
 				}
1595 1594
 			}
1596
-			catch(Exception $e) {
1595
+			catch (Exception $e) {
1597 1596
 				unset($e);
1598 1597
 				// simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component
1599 1598
 			}
@@ -1608,8 +1607,8 @@  discard block
 block discarded – undo
1608 1607
 	 */
1609 1608
 	static public function _getTZFromSyncBlob($data)
1610 1609
 	{
1611
-		$tz = unpack(	"lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" .
1612
-						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" .
1610
+		$tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/".
1611
+						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/".
1613 1612
 						"ldstbias", $data);
1614 1613
 
1615 1614
 		return $tz;
@@ -1622,7 +1621,7 @@  discard block
 block discarded – undo
1622 1621
 	 */
1623 1622
 	static public function _getSyncBlobFromTZ($tz)
1624 1623
 	{
1625
-		$packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l",
1624
+		$packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l",
1626 1625
 				$tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"],
1627 1626
 				$tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"],
1628 1627
 				$tz["dstbias"]);
@@ -1646,7 +1645,7 @@  discard block
 block discarded – undo
1646 1645
 				$account_id = $entry['grantor'];
1647 1646
 				$cals[$account_id] = $entry['name'];
1648 1647
 			}
1649
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1648
+			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user
1650 1649
 		}
1651 1650
 		$cals['G'] = lang('Primary group');
1652 1651
 		$cals['A'] = lang('All');
@@ -1682,7 +1681,7 @@  discard block
 block discarded – undo
1682 1681
 		)
1683 1682
 	);
1684 1683
 	require_once('../../header.inc.php');
1685
-	ini_set('display_errors',1);
1684
+	ini_set('display_errors', 1);
1686 1685
 	error_reporting(E_ALL & ~E_NOTICE);
1687 1686
 
1688 1687
 	echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n";
@@ -1697,7 +1696,7 @@  discard block
 block discarded – undo
1697 1696
 	</script>\n";
1698 1697
 
1699 1698
 	// TZID => AS timezone blobs reported by various devices
1700
-	foreach(array(
1699
+	foreach (array(
1701 1700
 		// Exchange 2016 Europe/Berlin
1702 1701
 		'Europe/Berlin'    => 'xP///1cALgAgAEUAdQByAG8AcABlACAAUwB0AGEAbgBkAGEAcgBkACAAVABpAG0AZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAACgAVQBUAEMAKwAwADEAOgAwADAAKQAgAEEAbQBzAHQAZQByAGQAYQBtACwAIABCAGUAcgBsAGkAbgAsACAAQgAAAAMAAAAFAAIAAAAAAAAAxP///w==',
1703 1702
 		//'Europe/Berlin'    => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==',
@@ -1713,7 +1712,7 @@  discard block
 block discarded – undo
1713 1712
 	) as $tz => $sync_blob)
1714 1713
 	{
1715 1714
 		// get as timezone data for a given timezone
1716
-		$ical = calendar_timezones::tz2id($tz,'component');
1715
+		$ical = calendar_timezones::tz2id($tz, 'component');
1717 1716
 		//echo "<pre>".print_r($ical,true)."</pre>\n";
1718 1717
 		$ical_tz = $ical;
1719 1718
 		$ical_arr = calendar_zpush::ical2array($ical_tz);
@@ -1722,7 +1721,7 @@  discard block
 block discarded – undo
1722 1721
 		//echo "$tz=<pre>".print_r($as_tz,true)."</pre>\n";
1723 1722
 
1724 1723
 		$as_tz_org = calendar_zpush::_getTZFromSyncBlob(base64_decode($sync_blob));
1725
-		echo "sync_blob=<pre>".print_r($as_tz_org,true)."</pre>\n";
1724
+		echo "sync_blob=<pre>".print_r($as_tz_org, true)."</pre>\n";
1726 1725
 
1727 1726
 		// find matching timezone from as data
1728 1727
 		// this returns the FIRST match, which is in case of Pacific/Auckland eg. Antarctica/McMurdo ;-)
@@ -1730,24 +1729,24 @@  discard block
 block discarded – undo
1730 1729
 		//echo array2string($matched);
1731 1730
 
1732 1731
 		echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n";
1733
-		foreach(array('dststart','dstend') as $prefix)
1732
+		foreach (array('dststart', 'dstend') as $prefix)
1734 1733
 		{
1735 1734
 			echo "<td>\n";
1736
-			foreach(array($as_tz_org,$as_tz) as $n => $arr)
1735
+			foreach (array($as_tz_org, $as_tz) as $n => $arr)
1737 1736
 			{
1738 1737
 				$parts = array();
1739
-				foreach(array('year','month','day','week','hour','minute','second') as $postfix)
1738
+				foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix)
1740 1739
 				{
1741 1740
 					$failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix];
1742
-					$parts[] = ($failed?'<font color="red">':'').
1741
+					$parts[] = ($failed ? '<font color="red">' : '').
1743 1742
 						"<span title='$postfix'>".$arr[$prefix.$postfix].'</span>'.
1744
-						($failed?'</font>':'');
1743
+						($failed ? '</font>' : '');
1745 1744
 				}
1746
-				echo implode(' ', $parts).(!$n?'<br/>':'');
1745
+				echo implode(' ', $parts).(!$n ? '<br/>' : '');
1747 1746
 			}
1748 1747
 			echo "</td>\n";
1749 1748
 		}
1750
-		echo "<td>&nbsp;<br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n";
1749
+		echo "<td>&nbsp;<br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n";
1751 1750
 	}
1752 1751
 	echo "</tbody></table>\n";
1753 1752
 	echo "</body></html>\n";
Please login to merge, or discard this patch.
Braces   +236 added lines, -57 removed lines patch added patch discarded remove patch
@@ -20,9 +20,17 @@  discard block
 block discarded – undo
20 20
  */
21 21
 if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__)
22 22
 {
23
-	interface activesync_plugin_write {}
24
-	interface activesync_plugin_meeting_requests {}
25
-	class ZLog { static function Write($level, $msg) { unset($level, $msg); }}
23
+	interface activesync_plugin_write
24
+	{
25
+}
26
+	interface activesync_plugin_meeting_requests
27
+	{
28
+}
29
+	class ZLog
30
+	{
31
+static function Write($level, $msg)
32
+	{
33
+unset($level, $msg); }}
26 34
 }
27 35
 
28 36
 /**
@@ -82,7 +90,10 @@  discard block
 block discarded – undo
82 90
 	 */
83 91
 	public function GetFolderList()
84 92
 	{
85
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
93
+		if (!isset($this->calendar))
94
+		{
95
+			$this->calendar = new calendar_boupdate();
96
+		}
86 97
 
87 98
 		$cals_pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
88 99
 		$cals = $cals_pref ? explode(',',$cals_pref) : array('P');	// implicit default of 'P'
@@ -181,13 +192,20 @@  discard block
 block discarded – undo
181 192
   	 */
182 193
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
183 194
 	{
184
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
195
+		if (!isset($this->calendar))
196
+		{
197
+			$this->calendar = new calendar_boupdate();
198
+		}
185 199
 
186 200
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$id',$cutoffdate)");
187 201
 		$type = $user = null;
188 202
 		$this->backend->splitID($id,$type,$user);
189 203
 
190
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
204
+		if (!$cutoffdate)
205
+		{
206
+			$cutoffdate = $this->bo->now - 100*24*3600;
207
+		}
208
+		// default three month back -30 breaks all sync recurrences
191 209
 
192 210
 		$filter = array(
193 211
 			'users' => $user,
@@ -215,7 +233,10 @@  discard block
 block discarded – undo
215 233
 		{
216 234
 			foreach ($events as $event)
217 235
 			{
218
-				if ($not_uids && in_array($event['uid'], $not_uids)) continue;
236
+				if ($not_uids && in_array($event['uid'], $not_uids))
237
+				{
238
+					continue;
239
+				}
219 240
 				$messagelist[] = $this->StatMessage($id, $event);
220 241
 
221 242
 				// add virtual exceptions for recuring events too
@@ -230,7 +251,10 @@  discard block
 block discarded – undo
230 251
 					}
231 252
 				}*/
232 253
 			}
233
-			if (count($events) < $num_rows) break;
254
+			if (count($events) < $num_rows)
255
+			{
256
+				break;
257
+			}
234 258
 		}
235 259
 		//error_log(__METHOD__."($id, $cutoffdate, ".array2string($not_uids).") type=$type, user=$user returning ".count($messagelist)." messages ".function_backtrace());
236 260
 		return $messagelist;
@@ -292,7 +316,10 @@  discard block
 block discarded – undo
292 316
 	{
293 317
 		unset($truncsize, $optionbodypreference, $mimesupport);	// not used, but required by function signature
294 318
 
295
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
319
+		if (!isset($this->calendar))
320
+		{
321
+			$this->calendar = new calendar_boupdate();
322
+		}
296 323
 
297 324
 		if (!($event = $this->calendar->read(abs($id), 0, false, 'server')))
298 325
 		{
@@ -370,7 +397,10 @@  discard block
 block discarded – undo
370 397
 			'created' => 'dtstamp',
371 398
 		) as $key => $attr)
372 399
 		{
373
-			if (!empty($event[$key])) $message->$attr = $event[$key];
400
+			if (!empty($event[$key]))
401
+			{
402
+				$message->$attr = $event[$key];
403
+			}
374 404
 		}
375 405
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
376 406
 		{
@@ -382,7 +412,10 @@  discard block
 block discarded – undo
382 412
 			'location' => 'location',
383 413
 		) as $key => $attr)
384 414
 		{
385
-			if (!empty($event[$key])) $message->$attr = $event[$key];
415
+			if (!empty($event[$key]))
416
+			{
417
+				$message->$attr = $event[$key];
418
+			}
386 419
 		}
387 420
 		$message->organizer = $event['organizer'];
388 421
 
@@ -417,7 +450,10 @@  discard block
 block discarded – undo
417 450
 	 */
418 451
 	function MeetingResponse($folderid, $requestid, $response)
419 452
 	{
420
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
453
+		if (!isset($this->calendar))
454
+		{
455
+			$this->calendar = new calendar_boupdate();
456
+		}
421 457
 
422 458
 		static $as2status = array(	// different from self::$status2as!
423 459
 			1 => 'A',
@@ -427,9 +463,12 @@  discard block
 block discarded – undo
427 463
 		$status_in = isset($as2status[$response]) ? $as2status[$response] : 'U';
428 464
 		$uid = $GLOBALS['egw_info']['user']['account_id'];
429 465
 
430
-		if (!is_numeric($requestid))	// iCal from fmail
466
+		if (!is_numeric($requestid))
467
+		{
468
+			// iCal from fmail
431 469
 		{
432 470
 			$ical = new calendar_ical();
471
+		}
433 472
 			if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1)
434 473
 			{
435 474
 				ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, '$requestid') error parsing iCal!");
@@ -542,7 +581,10 @@  discard block
 block discarded – undo
542 581
 	{
543 582
 		unset($contentParameters);	// unused, but required by function signature
544 583
 
545
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
584
+		if (!isset($this->calendar))
585
+		{
586
+			$this->calendar = new calendar_boupdate();
587
+		}
546 588
 
547 589
 		$old_event = array();
548 590
 		$type = $account = null;
@@ -557,10 +599,13 @@  discard block
 block discarded – undo
557 599
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id,...) Folder wrong or event does not existing");
558 600
 			return false;
559 601
 		}
560
-		if ($recur_date)	// virtual exception
602
+		if ($recur_date)
603
+		{
604
+			// virtual exception
561 605
 		{
562 606
 			// @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed
563 607
 			ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
608
+		}
564 609
 			//error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
565 610
 		}
566 611
 		if (!$this->calendar->check_perms($id ? Acl::EDIT : Acl::ADD, $old_event ? $old_event : 0,$account))
@@ -570,7 +615,11 @@  discard block
 block discarded – undo
570 615
 			//error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
571 616
 			return false;
572 617
 		}
573
-		if (!$id) $old_event['owner'] = $account;	// we do NOT allow to change the owner of existing events
618
+		if (!$id)
619
+		{
620
+			$old_event['owner'] = $account;
621
+		}
622
+		// we do NOT allow to change the owner of existing events
574 623
 
575 624
 		$event = $this->message2event($message, $account, $old_event);
576 625
 
@@ -599,7 +648,10 @@  discard block
 block discarded – undo
599 648
 					unset($ex_event['etag']);
600 649
 					foreach(array_keys($ex_event) as $name)
601 650
 					{
602
-						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
651
+						if (substr($name,0,6) == 'recur_')
652
+						{
653
+							unset($ex_event[$name]);
654
+						}
603 655
 					}
604 656
 					$ex_event['recur_type'] = calendar_rrule::NONE;
605 657
 
@@ -652,7 +704,10 @@  discard block
 block discarded – undo
652 704
 			'end' => 'endtime',
653 705
 		) as $key => $attr)
654 706
 		{
655
-			if (isset($message->$attr)) $event[$key] = Api\DateTime::server2user($message->$attr);
707
+			if (isset($message->$attr))
708
+			{
709
+				$event[$key] = Api\DateTime::server2user($message->$attr);
710
+			}
656 711
 		}
657 712
 		// copying strings
658 713
 		foreach(array(
@@ -661,7 +716,10 @@  discard block
 block discarded – undo
661 716
 			'location' => 'location',
662 717
 		) as $key => $attr)
663 718
 		{
664
-			if (isset($message->$attr)) $event[$key] = $message->$attr;
719
+			if (isset($message->$attr))
720
+			{
721
+				$event[$key] = $message->$attr;
722
+			}
665 723
 		}
666 724
 
667 725
 		// only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse
@@ -680,14 +738,22 @@  discard block
 block discarded – undo
680 738
 
681 739
 		if (($event['whole_day'] = $message->alldayevent))
682 740
 		{
683
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
741
+			if ($event['end'] == $event['start'])
742
+			{
743
+				$event['end'] += 24*3600;
744
+			}
745
+			// some clients send equal start&end for 1day
684 746
 			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
685 747
 		}
686 748
 
687 749
 		$participants = array();
688 750
 		foreach((array)$message->attendees as $attendee)
689 751
 		{
690
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
752
+			if ($attendee->type == 3)
753
+			{
754
+				continue;
755
+			}
756
+			// we can not identify resources and re-add them anyway later
691 757
 
692 758
 			$matches = null;
693 759
 			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
@@ -702,7 +768,10 @@  discard block
 block discarded – undo
702 768
 					//'n_fn' => $attendee->name,	// not sure if we want matches without email
703 769
 				);
704 770
 				// search addressbook for participant
705
-				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
771
+				if (!isset($this->addressbook))
772
+				{
773
+					$this->addressbook = new Api\Contacts();
774
+				}
706 775
 				if ((list($data) = $this->addressbook->search($search,
707 776
 					array('id','egw_addressbook.account_id as account_id','n_fn'),
708 777
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
@@ -710,10 +779,13 @@  discard block
 block discarded – undo
710 779
 				{
711 780
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
712 781
 				}
713
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
782
+				elseif($attendee->name === $attendee->email || empty($attendee->name))
783
+				{
784
+					// dont store empty or email as name
714 785
 				{
715 786
 					$uid = 'e'.$attendee->email;
716 787
 				}
788
+				}
717 789
 				else	// store just the email
718 790
 				{
719 791
 					$uid = 'e'.$attendee->name.' <'.$attendee->email.'>';
@@ -742,7 +814,11 @@  discard block
 block discarded – undo
742 814
 				$role = 'REQ-PARTICIPANT';
743 815
 				//ZLog::Write(LOGLEVEL_DEBUG, "default status for $uid is status=$status, quantity=$quantitiy, role=$role");
744 816
 			}
745
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
817
+			if ($role == 'CHAIR')
818
+			{
819
+				$chair_set = true;
820
+			}
821
+			// by role from existing participant
746 822
 
747 823
 			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
748 824
 			{
@@ -756,10 +832,13 @@  discard block
 block discarded – undo
756 832
 			elseif (isset($attendee->attendeetype) &&
757 833
 				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
758 834
 				($r = array_search($attendee->attendeetype,self::$role2as)) &&
759
-				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
835
+				(int)self::$role2as[$role] != $attendee->attendeetype)
836
+			{
837
+				// if old role gives same type, use old role, as we have a lot more roles then AS
760 838
 			{
761 839
 				$role = $r;
762 840
 			}
841
+			}
763 842
 			//ZLog::Write(LOGLEVEL_DEBUG, "-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
764 843
 			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
765 844
 		}
@@ -774,12 +853,19 @@  discard block
 block discarded – undo
774 853
 		// $account is also preserved, as AS does not add him as participant!
775 854
 		foreach((array)$event['participant_types'] as $type => $parts)
776 855
 		{
777
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
856
+			if (in_array($type,array('c','e')))
857
+			{
858
+				continue;
859
+			}
860
+			// they are correctly representable in AS
778 861
 
779 862
 			foreach($parts as $id => $status)
780 863
 			{
781 864
 				// accounts are represented correctly, but the event owner which is no participant in AS
782
-				if ($type == 'u' && $id != $account) continue;
865
+				if ($type == 'u' && $id != $account)
866
+				{
867
+					continue;
868
+				}
783 869
 
784 870
 				$uid = calendar_so::combine_user($type, $id);
785 871
 				if (!isset($participants[$uid]))
@@ -804,10 +890,13 @@  discard block
 block discarded – undo
804 890
 		// check if event is recurring and import recur information (incl. timezone)
805 891
 		if ($message->recurrence)
806 892
 		{
807
-			if ($message->timezone && !$event['id'])	// dont care for timezone, if no new and recurring event
893
+			if ($message->timezone && !$event['id'])
894
+			{
895
+				// dont care for timezone, if no new and recurring event
808 896
 			{
809 897
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
810 898
 			}
899
+			}
811 900
 			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
812 901
 				array_search($message->recurrence->type, self::$recur_type2as);
813 902
 			$event['recur_interval'] = $message->recurrence->interval;
@@ -844,10 +933,13 @@  discard block
 block discarded – undo
844 933
 			{
845 934
 				// calculate enddate from occurences count, as we only support enddate
846 935
 				$count = $message->recurrence->occurrences;
847
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
936
+				foreach(calendar_rrule::event2rrule($event, true) as $rtime)
937
+				{
938
+					// true = timestamps are user time here, because of save!
848 939
 				{
849 940
 					if (--$count <= 0) break;
850 941
 				}
942
+				}
851 943
 				$event['recur_enddate'] = $rtime->format('ts');
852 944
 			}
853 945
 		}
@@ -862,7 +954,9 @@  discard block
 block discarded – undo
862 954
 					break;
863 955
 				}
864 956
 			}
865
-			if ($alarm !== true)	// new alarm
957
+			if ($alarm !== true)
958
+			{
959
+				// new alarm
866 960
 			{
867 961
 				// delete all earlier alarms of that user
868 962
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
@@ -872,6 +966,7 @@  discard block
 block discarded – undo
872 966
 					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
873 967
 					{
874 968
 						unset($event['alarm'][$key]);
969
+			}
875 970
 					}
876 971
 				}
877 972
 				$event['alarm'][] = $alarm = array(
@@ -952,7 +1047,10 @@  discard block
 block discarded – undo
952 1047
 	{
953 1048
 		unset($contentParameters);	// not used, but required by function signature
954 1049
 
955
-		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
1050
+		if (!isset($this->caledar))
1051
+		{
1052
+			$this->calendar = new calendar_boupdate();
1053
+		}
956 1054
 
957 1055
 		$ret = $this->calendar->delete($id);
958 1056
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -1014,7 +1112,10 @@  discard block
 block discarded – undo
1014 1112
 	 */
1015 1113
 	public function GetMessage($folderid, $id, $contentparameters, $class='SyncAppointment')
1016 1114
 	{
1017
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1115
+		if (!isset($this->calendar))
1116
+		{
1117
+			$this->calendar = new calendar_boupdate();
1118
+		}
1018 1119
 		//error_log(__METHOD__.__LINE__.array2string($contentparameters).function_backtrace());
1019 1120
 		$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
1020 1121
 		$mimesupport = $contentparameters->GetMimeSupport();
@@ -1052,7 +1153,10 @@  discard block
 block discarded – undo
1052 1153
 		catch(Exception $e) {
1053 1154
 			unset($e);
1054 1155
 			// z-push (2.3 at least) requires a timezone for recurring events
1055
-			if ($event['recur_type']) $message->timezone = self::UTC_BLOB;
1156
+			if ($event['recur_type'])
1157
+			{
1158
+				$message->timezone = self::UTC_BLOB;
1159
+			}
1056 1160
 		}
1057 1161
 
1058 1162
 		// copying timestamps (they are already read in servertime, so non tz conversation)
@@ -1063,7 +1167,10 @@  discard block
 block discarded – undo
1063 1167
 			'modified' => 'dtstamp',
1064 1168
 		) as $key => $attr)
1065 1169
 		{
1066
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1170
+			if (!empty($event[$key]))
1171
+			{
1172
+				$message->$attr = $event[$key];
1173
+			}
1067 1174
 		}
1068 1175
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1069 1176
 		{
@@ -1076,7 +1183,10 @@  discard block
 block discarded – undo
1076 1183
 			'location' => 'location',
1077 1184
 		) as $key => $attr)
1078 1185
 		{
1079
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1186
+			if (!empty($event[$key]))
1187
+			{
1188
+				$message->$attr = $event[$key];
1189
+			}
1080 1190
 		}
1081 1191
 
1082 1192
 		// appoint description
@@ -1125,7 +1235,10 @@  discard block
 block discarded – undo
1125 1235
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1126 1236
 					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1127 1237
 
1128
-				if (!$info) continue;
1238
+				if (!$info)
1239
+				{
1240
+					continue;
1241
+				}
1129 1242
 
1130 1243
 				if (!$info['email'] && $info['responsible'])
1131 1244
 				{
@@ -1141,10 +1254,17 @@  discard block
 block discarded – undo
1141 1254
 					$message->organizeremail = $attendee->email;
1142 1255
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1143 1256
 				}
1144
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1257
+				if ($uid[0] == 'r')
1258
+				{
1259
+					$attendee->type = 3;
1260
+				}
1261
+				// 3 = resource
1145 1262
 			}
1146 1263
 			// email must NOT be empty, but MAY be an arbitrary text
1147
-			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
1264
+			if (empty($attendee->email))
1265
+			{
1266
+				$attendee->email = 'noreply-'.$uid.'[email protected]';
1267
+			}
1148 1268
 
1149 1269
 			$message->attendees[] = $attendee;
1150 1270
 		}
@@ -1179,9 +1299,12 @@  discard block
 block discarded – undo
1179 1299
 					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1180 1300
 					break;
1181 1301
 			}
1182
-			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
1302
+			if ($rrule->enddate)
1303
+			{
1304
+				// enddate is only a date, but AS needs a time incl. correct starttime!
1183 1305
 			{
1184 1306
 				$enddate = clone $rrule->time;
1307
+			}
1185 1308
 				$enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'),
1186 1309
 					$rrule->enddate->format('d'));
1187 1310
 				$recurrence->until = $enddate->format('server');
@@ -1203,12 +1326,19 @@  discard block
 block discarded – undo
1203 1326
 				{
1204 1327
 					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1205 1328
 				}
1206
-				if (count($ex_events)>=1) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1329
+				if (count($ex_events)>=1)
1330
+				{
1331
+					ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1332
+				}
1207 1333
 
1208 1334
 				$message->exceptions = array();
1209 1335
 				foreach($ex_events as $ex_event)
1210 1336
 				{
1211
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1337
+					if ($ex_event['id'] == $event['id'])
1338
+					{
1339
+						continue;
1340
+					}
1341
+					// ignore series master
1212 1342
 					$exception = $this->GetMessage($folderid, $ex_event, $contentparameters, 'SyncAppointmentException');
1213 1343
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1214 1344
 					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
@@ -1228,7 +1358,10 @@  discard block
 block discarded – undo
1228 1358
 				{
1229 1359
 					if (!empty($exception_time))
1230 1360
 					{
1231
-						if (empty($event['uid'])) ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1361
+						if (empty($event['uid']))
1362
+						{
1363
+							ZLog::Write(LOGLEVEL_DEBUG, __METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1364
+						}
1232 1365
 						$exception = new SyncAppointmentException();	// exceptions seems to be full SyncAppointments, with only starttime required
1233 1366
 						$exception->deleted = 1;
1234 1367
 						$exception->exceptionstarttime = $exception_time;
@@ -1284,12 +1417,18 @@  discard block
 block discarded – undo
1284 1417
 	{
1285 1418
 		unset($folderid);	// not used ($id is unique), but required by function signature
1286 1419
 
1287
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1420
+		if (!isset($this->calendar))
1421
+		{
1422
+			$this->calendar = new calendar_boupdate();
1423
+		}
1288 1424
 
1289 1425
 		$nul = null;
1290
-		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))	// last true: $only_master=true
1426
+		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))
1427
+		{
1428
+			// last true: $only_master=true
1291 1429
 		{
1292 1430
 			$stat = false;
1431
+		}
1293 1432
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1294 1433
 			$backup = $this->calendar->debug;
1295 1434
 			//$this->calendar->debug = 2;
@@ -1323,13 +1462,22 @@  discard block
 block discarded – undo
1323 1462
 		$type = $owner = null;
1324 1463
 		$this->backend->splitID($folderid, $type, $owner);
1325 1464
 
1326
-		if ($type != 'calendar') return false;
1465
+		if ($type != 'calendar')
1466
+		{
1467
+			return false;
1468
+		}
1327 1469
 
1328
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1470
+		if (!isset($this->calendar))
1471
+		{
1472
+			$this->calendar = new calendar_boupdate();
1473
+		}
1329 1474
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1330 1475
 		$syncstate = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1331 1476
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1332
-		if ($syncstate == 0) $syncstate = 1;
1477
+		if ($syncstate == 0)
1478
+		{
1479
+			$syncstate = 1;
1480
+		}
1333 1481
 
1334 1482
 		ZLog::Write(LOGLEVEL_DEBUG, __METHOD__."('$folderid', ...) type='$type', owner=$owner --> syncstate='$syncstate'");
1335 1483
 	}
@@ -1405,10 +1553,16 @@  discard block
 block discarded – undo
1405 1553
 			'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0,
1406 1554
 		);
1407 1555
 
1408
-		if ($tz === 'UTC') return $data;
1556
+		if ($tz === 'UTC')
1557
+		{
1558
+			return $data;
1559
+		}
1409 1560
 
1410 1561
 		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1411
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1562
+		if (strpos($component, 'VTIMEZONE') === false)
1563
+		{
1564
+			$component = calendar_timezones::tz2id($name,'component');
1565
+		}
1412 1566
 		// parse ical timezone defintion
1413 1567
 		$ical = self::ical2array($component);
1414 1568
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1455,11 +1609,17 @@  discard block
 block discarded – undo
1455 1609
 						$data[$prefix.'week'] = 5;
1456 1610
 					}
1457 1611
 					// if both start and end use 1SU use week=5 and decrement month
1458
-					if ($prefix == 'dststart') $start_byday = $matches[1];
1612
+					if ($prefix == 'dststart')
1613
+					{
1614
+						$start_byday = $matches[1];
1615
+					}
1459 1616
 					if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU')
1460 1617
 					{
1461 1618
 						$data[$prefix.'week'] = 5;
1462
-						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1619
+						if ($prefix == 'dstend')
1620
+						{
1621
+							$data[$prefix.'month'] -= 1;
1622
+						}
1463 1623
 					}
1464 1624
 					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1465 1625
 					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
@@ -1535,7 +1695,10 @@  discard block
 block discarded – undo
1535 1695
 	static public function ical2array(&$ical,$section=null)
1536 1696
 	{
1537 1697
 		$arr = array();
1538
-		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1698
+		if (!is_array($ical))
1699
+		{
1700
+			$ical = preg_split("/[\r\n]+/m", $ical);
1701
+		}
1539 1702
 		while (($line = array_shift($ical)))
1540 1703
 		{
1541 1704
 			list($name,$value) = explode(':',$line,2);
@@ -1545,7 +1708,10 @@  discard block
 block discarded – undo
1545 1708
 			}
1546 1709
 			elseif($name == 'END')
1547 1710
 			{
1548
-				if ($section && $section==$value) return $arr;
1711
+				if ($section && $section==$value)
1712
+				{
1713
+					return $arr;
1714
+				}
1549 1715
 				break;
1550 1716
 			}
1551 1717
 			else
@@ -1576,13 +1742,19 @@  discard block
 block discarded – undo
1576 1742
 
1577 1743
 		for($n = 0; !isset($cache[$key]); ++$n)
1578 1744
 		{
1579
-			if (!$n)	// check users timezone first
1745
+			if (!$n)
1746
+			{
1747
+				// check users timezone first
1580 1748
 			{
1581 1749
 				$tz = Api\DateTime::$user_timezone->getName();
1582 1750
 			}
1583
-			elseif (!($tz = calendar_timezones::id2tz($n)))	// no further timezones to check
1751
+			}
1752
+			elseif (!($tz = calendar_timezones::id2tz($n)))
1753
+			{
1754
+				// no further timezones to check
1584 1755
 			{
1585 1756
 				$cache[$key] = 'UTC';
1757
+			}
1586 1758
 				error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!');
1587 1759
 				break;
1588 1760
 			}
@@ -1646,7 +1818,11 @@  discard block
 block discarded – undo
1646 1818
 				$account_id = $entry['grantor'];
1647 1819
 				$cals[$account_id] = $entry['name'];
1648 1820
 			}
1649
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1821
+			if ($hook_data['account_id'] > 0)
1822
+			{
1823
+				unset($cals[$hook_data['account_id']]);
1824
+			}
1825
+			// skip current user
1650 1826
 		}
1651 1827
 		$cals['G'] = lang('Primary group');
1652 1828
 		$cals['A'] = lang('All');
@@ -1674,13 +1850,16 @@  discard block
 block discarded – undo
1674 1850
  *
1675 1851
  * You need to comment implements activesync_plugin_write
1676 1852
  */
1677
-if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__)	// some tests
1853
+if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__)
1854
+{
1855
+	// some tests
1678 1856
 {
1679 1857
 	$GLOBALS['egw_info'] = array(
1680 1858
 		'flags' => array(
1681 1859
 			'currentapp' => 'login'
1682 1860
 		)
1683 1861
 	);
1862
+}
1684 1863
 	require_once('../../header.inc.php');
1685 1864
 	ini_set('display_errors',1);
1686 1865
 	error_reporting(E_ALL & ~E_NOTICE);
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 1 patch
Spacing   +258 added lines, -259 removed lines patch added patch discarded remove patch
@@ -54,39 +54,39 @@  discard block
 block discarded – undo
54 54
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
55 55
 	 */
56 56
 	var $priority_egw2ical = array(
57
-		0 => 0,		// undefined
58
-		1 => 9,		// low
59
-		2 => 5,		// normal
60
-		3 => 1,		// high
57
+		0 => 0, // undefined
58
+		1 => 9, // low
59
+		2 => 5, // normal
60
+		3 => 1, // high
61 61
 	);
62 62
 
63 63
 	/**
64 64
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
65 65
 	 */
66 66
 	var $priority_ical2egw = array(
67
-		0 => 0,		// undefined
68
-		9 => 1,	8 => 1, 7 => 1, 6 => 1,	// low
69
-		5 => 2,		// normal
70
-		4 => 3, 3 => 3, 2 => 3, 1 => 3,	// high
67
+		0 => 0, // undefined
68
+		9 => 1, 8 => 1, 7 => 1, 6 => 1, // low
69
+		5 => 2, // normal
70
+		4 => 3, 3 => 3, 2 => 3, 1 => 3, // high
71 71
 	);
72 72
 
73 73
 	/**
74 74
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
75 75
 	 */
76 76
 	var $priority_egw2funambol = array(
77
-		0 => 1,		// undefined (mapped to normal since undefined does not exist)
78
-		1 => 0,		// low
79
-		2 => 1,		// normal
80
-		3 => 2,		// high
77
+		0 => 1, // undefined (mapped to normal since undefined does not exist)
78
+		1 => 0, // low
79
+		2 => 1, // normal
80
+		3 => 2, // high
81 81
 	);
82 82
 
83 83
 	/**
84 84
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
85 85
 	 */
86 86
 	var $priority_funambol2egw = array(
87
-		0 => 1,		// low
88
-		1 => 2,		// normal
89
-		2 => 3,		// high
87
+		0 => 1, // low
88
+		1 => 2, // normal
89
+		2 => 3, // high
90 90
 	);
91 91
 
92 92
 	/**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @var boolean
157 157
 	 */
158 158
 	var $log = false;
159
-	var $logfile="/tmp/log-vcal";
159
+	var $logfile = "/tmp/log-vcal";
160 160
 
161 161
 	/**
162 162
 	 * Event callback
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
204 204
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
205 205
 	 */
206
-	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
206
+	function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0)
207 207
 	{
208 208
 		if ($this->log)
209 209
 		{
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 
235 235
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
236 236
 
237
-		if ($this->productManufacturer == '' )
237
+		if ($this->productManufacturer == '')
238 238
 		{	// syncevolution is broken
239 239
 			$version = '2.0';
240 240
 		}
241 241
 
242 242
 		$vcal = new Horde_Icalendar;
243
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
243
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
244 244
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
245 245
 		$vcal->setAttribute('VERSION', $version);
246 246
 		if ($method) $vcal->setAttribute('METHOD', $method);
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 						if ($this->log)
271 271
 						{
272 272
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
273
-								'() User does not have the permission to read event ' . $event['id']. "\n",
274
-								3,$this->logfile);
273
+								'() User does not have the permission to read event '.$event['id']."\n",
274
+								3, $this->logfile);
275 275
 						}
276 276
 						return -1; // Permission denied
277 277
 					}
278 278
 				}
279 279
 				else
280 280
 				{
281
-					$retval = false;  // Entry does not exist
281
+					$retval = false; // Entry does not exist
282 282
 					if ($this->log)
283 283
 					{
284 284
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 			if ($this->log)
293 293
 			{
294 294
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
295
-					'() export event UID: ' . $event['uid'] . ".\n",
295
+					'() export event UID: '.$event['uid'].".\n",
296 296
 					3, $this->logfile);
297 297
 			}
298 298
 
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 			if ($this->log)
326 326
 			{
327 327
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
328
-					'(' . $event['id']. ',' . $recurrence . ")\n" .
329
-					array2string($event)."\n",3,$this->logfile);
328
+					'('.$event['id'].','.$recurrence.")\n".
329
+					array2string($event)."\n", 3, $this->logfile);
330 330
 			}
331 331
 
332 332
 			if ($recurrence)
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 						{
348 348
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
349 349
 								"(, $recurrence) Gratuitous pseudo exception, skipped ...\n",
350
-								3,$this->logfile);
350
+								3, $this->logfile);
351 351
 						}
352 352
 						continue; // unsupported status only exception
353 353
 					}
@@ -357,13 +357,13 @@  discard block
 block discarded – undo
357 357
 					$days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule');
358 358
 					if ($this->log)
359 359
 					{
360
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
361
-							array2string($days)."\n",3,$this->logfile);
360
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
361
+							array2string($days)."\n", 3, $this->logfile);
362 362
 					}
363 363
 					$recurrence = $days[$recurrence]; // use remote representation
364 364
 				}
365 365
 				// force single event
366
-				foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name)
366
+				foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name)
367 367
 				{
368 368
 					unset($event[$name]);
369 369
 				}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 			}
372 372
 
373 373
 			// check if tzid of event (not only recuring ones) is already added to export
374
-			if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
374
+			if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added))
375 375
 			{
376 376
 				// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
377 377
 				if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 			{
390 390
 				// Append UID to DESCRIPTION
391 391
 				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
392
-					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
392
+					$event['description'] .= "\n[UID:".$event['uid']."]";
393 393
 				}
394 394
 			}
395 395
 
@@ -410,14 +410,14 @@  discard block
 block discarded – undo
410 410
 				$exceptions = array();
411 411
 
412 412
 				// dont use "virtual" exceptions created by participant status for GroupDAV or file export
413
-				if (!in_array($this->productManufacturer,array('file','groupdav')))
413
+				if (!in_array($this->productManufacturer, array('file', 'groupdav')))
414 414
 				{
415 415
 					$filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule';
416 416
 					$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter);
417 417
 					if ($this->log)
418 418
 					{
419
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
420
-							array2string($exceptions)."\n",3,$this->logfile);
419
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
420
+							array2string($exceptions)."\n", 3, $this->logfile);
421 421
 					}
422 422
 				}
423 423
 				elseif (is_array($event['recur_exception']))
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 					if ($this->log)
435 435
 					{
436 436
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
437
-							'(' . $event['id'] . ") [$icalFieldName] not supported\n",
438
-							3,$this->logfile);
437
+							'('.$event['id'].") [$icalFieldName] not supported\n",
438
+							3, $this->logfile);
439 439
 					}
440 440
 					continue;
441 441
 				}
@@ -452,23 +452,23 @@  discard block
 block discarded – undo
452 452
 
453 453
 							if (!($info = $this->resource_info($uid))) continue;
454 454
 
455
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
455
+							if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants
456 456
 
457 457
 							if ($this->log)
458 458
 							{
459
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
460
-									'()attendee:' . array2string($info) ."\n",3,$this->logfile);
459
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
460
+									'()attendee:'.array2string($info)."\n", 3, $this->logfile);
461 461
 							}
462 462
 							$participantCN = str_replace(array('\\', ',', ';', ':'),
463 463
 												array('\\\\', '\\,', '\\;', '\\:'),
464 464
 												trim(empty($info['cn']) ? $info['name'] : $info['cn']));
465 465
 							if ($version == '1.0')
466 466
 							{
467
-								$participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>'));
467
+								$participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>'));
468 468
 							}
469 469
 							else
470 470
 							{
471
-								$participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email'];
471
+								$participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email'];
472 472
 							}
473 473
 							// RSVP={TRUE|FALSE}	// resonse expected, not set in eGW => status=U
474 474
 							$rsvp = $status == 'U' ? 'TRUE' : 'FALSE';
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 										($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members))
497 497
 									{
498 498
 										$user = $this->resource_info($this->user);
499
-										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
499
+										$attributes['ATTENDEE'][] = 'mailto:'.$user['email'];
500 500
 			    						$parameters['ATTENDEE'][] = array(
501 501
 			    							'CN'		=>	$user['name'],
502 502
 			    							'ROLE'		=> 'REQ-PARTICIPANT',
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
 							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
539 539
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
540 540
 							{
541
-								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
541
+								$options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
542 542
 							}
543 543
 							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
544 544
 							if ($quantity > 1)
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 						break;
553 553
 
554 554
 					case 'CLASS':
555
-						if ($event['public']) continue 2;	// public is default, no need to export, fails CalDAVTester if added as default
555
+						if ($event['public']) continue 2; // public is default, no need to export, fails CalDAVTester if added as default
556 556
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
557 557
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
558 558
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -564,16 +564,16 @@  discard block
 block discarded – undo
564 564
     				case 'ORGANIZER':
565 565
 	    				if (!$organizerURL)
566 566
 	    				{
567
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
568
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
569
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
567
+	    					$organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname')
568
+			    				. ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"';
569
+			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
570 570
 			    			if ($version == '1.0')
571 571
 			    			{
572
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
572
+		    					$organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>'));
573 573
 			    			}
574 574
 			    			else
575 575
 			    			{
576
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
576
+		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail;
577 577
 			    			}
578 578
 			    			$organizerUID = $event['owner'];
579 579
 	    				}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 					case 'DTSTART':
593 593
 						if (empty($event['whole_day']))
594 594
 						{
595
-							$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
595
+							$attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']);
596 596
 						}
597 597
 						break;
598 598
 
@@ -603,27 +603,27 @@  discard block
 block discarded – undo
603 603
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
604 604
 								$attributes['duration'] = $event['end'] - $event['start'];
605 605
 							else
606
-								$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
606
+								$attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']);
607 607
 						}
608 608
 						else
609 609
 						{
610 610
 							// write start + end of whole day events as dates
611
-							$event['end-nextday'] = $event['end'] + 12*3600;	// we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
612
-							foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
611
+							$event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
612
+							foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t)
613 613
 							{
614
-								$time = new Api\DateTime($event[$f],Api\DateTime::$server_timezone);
615
-								$arr = Api\DateTime::to($time,'array');
616
-								$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
614
+								$time = new Api\DateTime($event[$f], Api\DateTime::$server_timezone);
615
+								$arr = Api\DateTime::to($time, 'array');
616
+								$vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']),
617 617
 									array('VALUE' => 'DATE'));
618 618
 							}
619 619
 							unset($attributes['DTSTART']);
620 620
 							// Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event
621
-							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE');
621
+							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
622 622
 						}
623 623
 						break;
624 624
 
625 625
 					case 'RRULE':
626
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
626
+						if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
627 627
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
628 628
 						$rrule = $rriter->generate_rrule($version);
629 629
 						if ($event['recur_enddate'])
@@ -650,16 +650,16 @@  discard block
 block discarded – undo
650 650
 						{
651 651
 							if ($event['recur_enddate'] && $tzid)
652 652
 							{
653
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
653
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
654 654
 							}
655 655
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
656 656
 						}
657 657
 						else // $version == '2.0'
658 658
 						{
659 659
 							$attributes['RRULE'] = '';
660
-							foreach($rrule as $n => $v)
660
+							foreach ($rrule as $n => $v)
661 661
 							{
662
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
662
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
663 663
 							}
664 664
 						}
665 665
 						break;
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
 								{
675 675
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
676 676
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
677
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
677
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
678 678
 								}
679 679
 							}
680 680
 							else
@@ -682,9 +682,9 @@  discard block
 block discarded – undo
682 682
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
683 683
 								foreach ($event['recur_exception'] as $id => $timestamp)
684 684
 								{
685
-									$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
685
+									$time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone);
686 686
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
687
-									$arr = Api\DateTime::to($time,'array');
687
+									$arr = Api\DateTime::to($time, 'array');
688 688
 									$days[$id] = array(
689 689
 										'year'  => $arr['year'],
690 690
 										'month' => $arr['month'],
@@ -699,21 +699,21 @@  discard block
 block discarded – undo
699 699
 						break;
700 700
 
701 701
 					case 'PRIORITY':
702
-						if (!$event['priority']) continue 2;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
702
+						if (!$event['priority']) continue 2; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
703 703
 						if ($this->productManufacturer == 'funambol' &&
704 704
 							(strpos($this->productName, 'outlook') !== false
705 705
 								|| strpos($this->productName, 'pocket pc') !== false))
706 706
 						{
707
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
707
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
708 708
 						}
709 709
 						else
710 710
 						{
711
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
711
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
712 712
 						}
713 713
 						break;
714 714
 
715 715
 					case 'TRANSP':
716
-						if (!$event['non_blocking']) continue 2;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
716
+						if (!$event['non_blocking']) continue 2; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
717 717
 						if ($version == '1.0')
718 718
 						{
719 719
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -752,13 +752,13 @@  discard block
 block discarded – undo
752 752
 							// We handle a pseudo exception
753 753
 							if (empty($event['whole_day']))
754 754
 							{
755
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
755
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
756 756
 							}
757 757
 							else
758 758
 							{
759
-								$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
759
+								$time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone);
760 760
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
761
-								$arr = Api\DateTime::to($time,'array');
761
+								$arr = Api\DateTime::to($time, 'array');
762 762
 								$vevent->setAttribute($icalFieldName, array(
763 763
 									'year' => $arr['year'],
764 764
 									'month' => $arr['month'],
@@ -770,17 +770,17 @@  discard block
 block discarded – undo
770 770
 						elseif ($event['recurrence'] && $event['reference'])
771 771
 						{
772 772
 							// $event['reference'] is a calendar_id, not a timestamp
773
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
773
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
774 774
 
775 775
 							if (empty($revent['whole_day']))
776 776
 							{
777
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
777
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
778 778
 							}
779 779
 							else
780 780
 							{
781
-								$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
781
+								$time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone);
782 782
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
783
-								$arr = Api\DateTime::to($time,'array');
783
+								$arr = Api\DateTime::to($time, 'array');
784 784
 								$vevent->setAttribute($icalFieldName, array(
785 785
 									'year' => $arr['year'],
786 786
 									'month' => $arr['month'],
@@ -807,9 +807,9 @@  discard block
 block discarded – undo
807 807
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
808 808
 							if ($this->log && $size > 0)
809 809
 							{
810
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
811
-									"() $icalFieldName Size: $size, NoTruncate: " .
812
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
810
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
811
+									"() $icalFieldName Size: $size, NoTruncate: ".
812
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
813 813
 							}
814 814
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
815 815
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 							{
828 828
 								if ($this->log)
829 829
 								{
830
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
831
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
830
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
831
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
832 832
 								}
833 833
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
834 834
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 							$value = substr($value, 0, $size - 1);
839 839
 							if ($this->log)
840 840
 							{
841
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
842
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
841
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
842
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
843 843
 							}
844 844
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
845 845
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 			// for CalDAV add all X-Properties previously parsed
855 855
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
856 856
 			{
857
-				foreach($event as $name => $value)
857
+				foreach ($event as $name => $value)
858 858
 				{
859 859
 					if (substr($name, 0, 2) == '##')
860 860
 					{
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 						$values['AALARM']['repeat count'] = '';
933 933
 						$values['AALARM']['display text'] = $description;
934 934
 					}
935
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
936
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
935
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
936
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
937 937
 					// lets take only the first alarm
938 938
 					break;
939 939
 				}
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
 						$alarmData['offset'] = false;
971 971
 					}
972 972
 
973
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
973
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
974 974
 					if ($alarmData['offset'] !== false)
975 975
 					{
976 976
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 					else
980 980
 					{
981 981
 						$params = array('VALUE' => 'DATE-TIME');
982
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
982
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
983 983
 						$valarm->setAttribute('TRIGGER', $value, $params);
984 984
 					}
985 985
 					if (!empty($alarmData['uid']))
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
991 991
 					if (isset($alarmData['attrs']))
992 992
 					{
993
-						foreach($alarmData['attrs'] as $attr => $data)
993
+						foreach ($alarmData['attrs'] as $attr => $data)
994 994
 						{
995 995
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
996 996
 						}
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 					// set default ACTION and DESCRIPTION, if not set by a client
999 999
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
1000 1000
 					{
1001
-						$valarm->setAttribute('ACTION','DISPLAY');
1001
+						$valarm->setAttribute('ACTION', 'DISPLAY');
1002 1002
 					}
1003 1003
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
1004 1004
 					{
1005
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
1005
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
1006 1006
 					}
1007 1007
 					$vevent->addComponent($valarm);
1008 1008
 				}
@@ -1010,15 +1010,15 @@  discard block
 block discarded – undo
1010 1010
 
1011 1011
 			foreach ($attributes as $key => $value)
1012 1012
 			{
1013
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
1013
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
1014 1014
 				{
1015
-					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
1016
-                    $paramData = (array) Api\Translation::convert(is_array($value) ?
1015
+					$valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset);
1016
+                    $paramData = (array)Api\Translation::convert(is_array($value) ?
1017 1017
                     		$parameters[$key][$valueID] : $parameters[$key],
1018
-                            Api\Translation::charset(),$charset);
1019
-                    $valuesData = (array) Api\Translation::convert($values[$key],
1020
-                    		Api\Translation::charset(),$charset);
1021
-                    $content = $valueData . implode(';', $valuesData);
1018
+                            Api\Translation::charset(), $charset);
1019
+                    $valuesData = (array)Api\Translation::convert($values[$key],
1020
+                    		Api\Translation::charset(), $charset);
1021
+                    $content = $valueData.implode(';', $valuesData);
1022 1022
 
1023 1023
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1024 1024
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1068,10 +1068,10 @@  discard block
 block discarded – undo
1068 1068
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1069 1069
  		if ($this->log)
1070 1070
  		{
1071
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1072
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1073
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1074
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1071
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1072
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1073
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1074
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1075 1075
  		}
1076 1076
 		return $retval;
1077 1077
 	}
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
 	 * @param array &$params=null parameter array to set TZID
1085 1085
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1086 1086
 	 */
1087
-	static function getDateTime($time,$tzid,array &$params=null)
1087
+	static function getDateTime($time, $tzid, array &$params = null)
1088 1088
 	{
1089 1089
 		if (empty($tzid) || $tzid == 'UTC')
1090 1090
 		{
1091
-			return Api\DateTime::to($time,'ts');
1091
+			return Api\DateTime::to($time, 'ts');
1092 1092
 		}
1093
-		if (!is_a($time,'DateTime'))
1093
+		if (!is_a($time, 'DateTime'))
1094 1094
 		{
1095
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
1095
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
1096 1096
 		}
1097 1097
 		if (!isset(self::$tz_cache[$tzid]))
1098 1098
 		{
@@ -1127,11 +1127,11 @@  discard block
 block discarded – undo
1127 1127
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1128 1128
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1129 1129
 	 */
1130
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1130
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1131 1131
 	{
1132 1132
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1133 1133
 		$this->events_imported = 0;
1134
-		$replace = $delete_exceptions= false;
1134
+		$replace = $delete_exceptions = false;
1135 1135
 
1136 1136
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1137 1137
 
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 		{
1140 1140
 			return false;
1141 1141
 		}
1142
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1142
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1143 1143
 
1144 1144
 		if ($cal_id > 0)
1145 1145
 		{
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 			{
1148 1148
 				$replace = $recur_date == 0;
1149 1149
 				$events[0]['id'] = $cal_id;
1150
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1150
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1151 1151
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1152 1152
 			}
1153 1153
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1189,9 +1189,9 @@  discard block
 block discarded – undo
1189 1189
 			if (!is_array($event)) continue; // the iterator may return false
1190 1190
 
1191 1191
 			// Run event through callback
1192
-			if($this->event_callback && is_callable($this->event_callback))
1192
+			if ($this->event_callback && is_callable($this->event_callback))
1193 1193
 			{
1194
-				if(!call_user_func_array($this->event_callback, array(&$event)))
1194
+				if (!call_user_func_array($this->event_callback, array(&$event)))
1195 1195
 				{
1196 1196
 					// Callback cancelled event
1197 1197
 					continue;
@@ -1209,7 +1209,7 @@  discard block
 block discarded – undo
1209 1209
 			{
1210 1210
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1211 1211
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1212
-					. array2string($event)."\n",3,$this->logfile);
1212
+					. array2string($event)."\n", 3, $this->logfile);
1213 1213
 			}
1214 1214
 
1215 1215
 			$updated_id = false;
@@ -1232,14 +1232,14 @@  discard block
 block discarded – undo
1232 1232
 					{
1233 1233
 						if ($delete_exceptions)
1234 1234
 						{
1235
-							$this->delete($id,0,false,$skip_notification);
1235
+							$this->delete($id, 0, false, $skip_notification);
1236 1236
 						}
1237 1237
 						else
1238 1238
 						{
1239 1239
 							if (!($exception = $this->read($id))) continue;
1240 1240
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1241 1241
 							$exception['reference'] = $exception['recurrence'] = 0;
1242
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1242
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1243 1243
 						}
1244 1244
 					}
1245 1245
 				}
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 				{
1257 1257
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1258 1258
 						. "(UPDATE Event)\n"
1259
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1259
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1260 1260
 				}
1261 1261
 				if (empty($event['uid']))
1262 1262
 				{
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 								if ($this->log)
1279 1279
 								{
1280 1280
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1281
-										"() Restore status for $uid\n",3,$this->logfile);
1281
+										"() Restore status for $uid\n", 3, $this->logfile);
1282 1282
 								}
1283 1283
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1284 1284
 							}
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 					if ($this->log)
1314 1314
 					{
1315 1315
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1316
-							"()[MERGE]\n",3,$this->logfile);
1316
+							"()[MERGE]\n", 3, $this->logfile);
1317 1317
 					}
1318 1318
 					// overwrite with server data for merge
1319 1319
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 						switch ($key)
1322 1322
 						{
1323 1323
 							case 'participants_types':
1324
-								continue 2;	// +1 for switch
1324
+								continue 2; // +1 for switch
1325 1325
 
1326 1326
 							case 'participants':
1327 1327
 								foreach ($event_info['stored_event']['participants'] as $uid => $status)
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 				else
1344 1344
 				{
1345 1345
 					// no merge
1346
-					if(!isset($this->supportedFields['category']))
1346
+					if (!isset($this->supportedFields['category']))
1347 1347
 					{
1348 1348
 						$event['category'] = $event_info['stored_event']['category'];
1349 1349
 					}
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 						if ($this->log)
1356 1356
 						{
1357 1357
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1358
-							"() No participants\n",3,$this->logfile);
1358
+							"() No participants\n", 3, $this->logfile);
1359 1359
 						}
1360 1360
 
1361 1361
 						// If this is an updated meeting, and the client doesn't support
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 								if ($this->log)
1375 1375
 								{
1376 1376
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1377
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1377
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1378 1378
 								}
1379 1379
 								// Add it back in
1380 1380
 								$event['participants'][$uid] = $status;
@@ -1462,8 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 						}
1463 1463
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1464 1464
 						$event['participants'][$user] = calendar_so::combine_status(
1465
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1466
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1465
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1467 1466
 					}
1468 1467
 				}
1469 1468
 				// check if an owner is set and the current user has add rights
@@ -1528,9 +1527,9 @@  discard block
 block discarded – undo
1528 1527
 
1529 1528
 			if ($this->log)
1530 1529
 			{
1531
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1532
-					. $event_info['type'] . ")\n"
1533
-					. array2string($event)."\n",3,$this->logfile);
1530
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1531
+					. $event_info['type'].")\n"
1532
+					. array2string($event)."\n", 3, $this->logfile);
1534 1533
 			}
1535 1534
 
1536 1535
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1538,10 +1537,10 @@  discard block
 block discarded – undo
1538 1537
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1539 1538
 				$event['status'] == 'CANCELLED')
1540 1539
 			{
1541
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1540
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1542 1541
 				{
1543 1542
 					// delete fails (because no rights), reject recurrence
1544
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1543
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1545 1544
 				}
1546 1545
 				continue;
1547 1546
 			}
@@ -1553,7 +1552,7 @@  discard block
 block discarded – undo
1553 1552
 					if ($this->log)
1554 1553
 					{
1555 1554
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1556
-							"(): event SINGLE\n",3,$this->logfile);
1555
+							"(): event SINGLE\n", 3, $this->logfile);
1557 1556
 					}
1558 1557
 
1559 1558
 					// update the event
@@ -1563,7 +1562,7 @@  discard block
 block discarded – undo
1563 1562
 						$event['reference'] = 0;
1564 1563
 						$event_to_store = $event; // prevent $event from being changed by the update method
1565 1564
 						$this->server2usertime($event_to_store);
1566
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1565
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1567 1566
 						unset($event_to_store);
1568 1567
 					}
1569 1568
 					break;
@@ -1572,7 +1571,7 @@  discard block
 block discarded – undo
1572 1571
 					if ($this->log)
1573 1572
 					{
1574 1573
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1575
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1574
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1576 1575
 					}
1577 1576
 
1578 1577
 					// remove all known pseudo exceptions and update the event
@@ -1582,8 +1581,8 @@  discard block
 block discarded – undo
1582 1581
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1583 1582
 						if ($this->log)
1584 1583
 						{
1585
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1586
-								array2string($days)."\n",3,$this->logfile);
1584
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1585
+								array2string($days)."\n", 3, $this->logfile);
1587 1586
 						}
1588 1587
 						if (is_array($days))
1589 1588
 						{
@@ -1601,7 +1600,7 @@  discard block
 block discarded – undo
1601 1600
 
1602 1601
 						$event_to_store = $event; // prevent $event from being changed by the update method
1603 1602
 						$this->server2usertime($event_to_store);
1604
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1603
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1605 1604
 						unset($event_to_store);
1606 1605
 					}
1607 1606
 					break;
@@ -1611,7 +1610,7 @@  discard block
 block discarded – undo
1611 1610
 					if ($this->log)
1612 1611
 					{
1613 1612
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1614
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1613
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1615 1614
 					}
1616 1615
 
1617 1616
 					// update event
@@ -1667,13 +1666,13 @@  discard block
 block discarded – undo
1667 1666
 							$event['owner'] = $event_info['master_event']['owner'];
1668 1667
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1669 1668
 							$this->server2usertime($event_to_store);
1670
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1669
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1671 1670
 							unset($event_to_store);
1672 1671
 						}
1673 1672
 
1674 1673
 						$event_to_store = $event; // prevent $event from being changed by update method
1675 1674
 						$this->server2usertime($event_to_store);
1676
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1675
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1677 1676
 						unset($event_to_store);
1678 1677
 					}
1679 1678
 					break;
@@ -1682,7 +1681,7 @@  discard block
 block discarded – undo
1682 1681
 					if ($this->log)
1683 1682
 					{
1684 1683
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1685
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1684
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1686 1685
 					}
1687 1686
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1688 1687
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1703,7 +1702,7 @@  discard block
 block discarded – undo
1703 1702
 						// save the series master with the adjusted exceptions
1704 1703
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1705 1704
 						$this->server2usertime($event_to_store);
1706
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1705
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1707 1706
 						unset($event_to_store);
1708 1707
 					}
1709 1708
 
@@ -1730,13 +1729,13 @@  discard block
 block discarded – undo
1730 1729
 							if ($event_info['acl_edit'])
1731 1730
 							{
1732 1731
 								// update all participants if we have the right to do that
1733
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1732
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1734 1733
 							}
1735 1734
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1736 1735
 							{
1737 1736
 								// update the users status only
1738 1737
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1739
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1738
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1740 1739
 							}
1741 1740
 						}
1742 1741
 						break;
@@ -1748,13 +1747,13 @@  discard block
 block discarded – undo
1748 1747
 							if ($event_info['acl_edit'])
1749 1748
 							{
1750 1749
 								// update all participants if we have the right to do that
1751
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1750
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1752 1751
 							}
1753 1752
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1754 1753
 							{
1755 1754
 								// update the users status only
1756 1755
 								$this->set_status($event_info['master_event']['id'], $this->user,
1757
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1756
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1758 1757
 							}
1759 1758
 						}
1760 1759
 						break;
@@ -1771,7 +1770,7 @@  discard block
 block discarded – undo
1771 1770
 					break;
1772 1771
 
1773 1772
 				case 'SERIES-PSEUDO-EXCEPTION':
1774
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1773
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1775 1774
 					break;
1776 1775
 
1777 1776
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1784,7 +1783,7 @@  discard block
 block discarded – undo
1784 1783
 					{
1785 1784
 						// we did not have sufficient rights to propagate the status only exception to a real one
1786 1785
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1787
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1786
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1788 1787
 					}
1789 1788
 					break;
1790 1789
 			}
@@ -1798,8 +1797,8 @@  discard block
 block discarded – undo
1798 1797
 			if ($this->log)
1799 1798
 			{
1800 1799
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1801
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1802
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1800
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1801
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1803 1802
 			}
1804 1803
 		}
1805 1804
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1821,19 +1820,19 @@  discard block
 block discarded – undo
1821 1820
 	 * @return mixed on success: int $cal_id > 0, on error or conflicts false.
1822 1821
 	 *	Conflicts are passed to $this->conflict_callback
1823 1822
 	 */
1824
-	public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
1823
+	public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
1825 1824
 	{
1826
-		if($this->conflict_callback !== null)
1825
+		if ($this->conflict_callback !== null)
1827 1826
 		{
1828 1827
 			// calendar_ical overrides search(), which breaks conflict checking
1829 1828
 			// so we make sure to use the original from parent
1830 1829
 			static $bo = null;
1831
-			if(!$bo)
1830
+			if (!$bo)
1832 1831
 			{
1833 1832
 				$bo = new calendar_boupdate();
1834 1833
 			}
1835 1834
 			$conflicts = $bo->conflicts($event);
1836
-			if(is_array($conflicts) && count($conflicts) > 0)
1835
+			if (is_array($conflicts) && count($conflicts) > 0)
1837 1836
 			{
1838 1837
 				call_user_func_array($this->conflict_callback, array(&$event, &$conflicts));
1839 1838
 				return false;
@@ -1854,11 +1853,11 @@  discard block
 block discarded – undo
1854 1853
 	{
1855 1854
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1856 1855
 		$modified = 0;
1857
-		foreach($event['alarm'] as &$alarm)
1856
+		foreach ($event['alarm'] as &$alarm)
1858 1857
 		{
1859 1858
 			// check if alarm is already stored or from other users
1860 1859
 			$found = false;
1861
-			foreach($old_alarms as $id => $old_alarm)
1860
+			foreach ($old_alarms as $id => $old_alarm)
1862 1861
 			{
1863 1862
 				// not current users alarm --> ignore
1864 1863
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1874,7 +1873,7 @@  discard block
 block discarded – undo
1874 1873
 					break;
1875 1874
 				}
1876 1875
 			}
1877
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
1876
+			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found ? 'existing' : 'new')." alarm ".array2string($alarm));
1878 1877
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1879 1878
 			{
1880 1879
 				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
@@ -1902,7 +1901,7 @@  discard block
 block discarded – undo
1902 1901
 			}
1903 1902
 		}
1904 1903
 		// remove all old alarms left from current user
1905
-		foreach($old_alarms as $id => $old_alarm)
1904
+		foreach ($old_alarms as $id => $old_alarm)
1906 1905
 		{
1907 1906
 			// not current users alarm --> ignore
1908 1907
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1925,7 +1924,7 @@  discard block
 block discarded – undo
1925 1924
 	 * @param string $what ='value'
1926 1925
 	 * @return mixed
1927 1926
 	 */
1928
-	static function _get_attribute($components,$name,$what='value')
1927
+	static function _get_attribute($components, $name, $what = 'value')
1929 1928
 	{
1930 1929
 		foreach ($components as $attribute)
1931 1930
 		{
@@ -1960,7 +1959,7 @@  discard block
 block discarded – undo
1960 1959
 						case 'DURATION':
1961 1960
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1962 1961
 							{
1963
-								$alarm['offset'] = $duration -$vattr['value'];
1962
+								$alarm['offset'] = $duration - $vattr['value'];
1964 1963
 							}
1965 1964
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1966 1965
 							{
@@ -1976,7 +1975,7 @@  discard block
 block discarded – undo
1976 1975
 							$alarm['time'] = $vattr['value'];
1977 1976
 							break;
1978 1977
 						default:
1979
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1978
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1980 1979
 					}
1981 1980
 					break;
1982 1981
 
@@ -2001,9 +2000,9 @@  discard block
 block discarded – undo
2001 2000
 		return 0;
2002 2001
 	}
2003 2002
 
2004
-	function setSupportedFields($_productManufacturer='', $_productName='')
2003
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
2005 2004
 	{
2006
-		$state =& $_SESSION['SyncML.state'];
2005
+		$state = & $_SESSION['SyncML.state'];
2007 2006
 		if (isset($state))
2008 2007
 		{
2009 2008
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2300,10 +2299,10 @@  discard block
 block discarded – undo
2300 2299
 		if ($this->log)
2301 2300
 		{
2302 2301
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2303
-				'(' . $this->productManufacturer .
2304
-				', '. $this->productName .', ' .
2305
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
2306
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2302
+				'('.$this->productManufacturer.
2303
+				', '.$this->productName.', '.
2304
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
2305
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2307 2306
 		}
2308 2307
 
2309 2308
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2321,12 +2320,12 @@  discard block
 block discarded – undo
2321 2320
      *                         utf-8 for new format, iso-8859-1 for old format.
2322 2321
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2323 2322
 	 */
2324
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2323
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2325 2324
 	{
2326 2325
 		if ($this->log)
2327 2326
 		{
2328
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2329
-				array2string($_vcalData)."\n",3,$this->logfile);
2327
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2328
+				array2string($_vcalData)."\n", 3, $this->logfile);
2330 2329
 		}
2331 2330
 
2332 2331
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2361,14 +2360,14 @@  discard block
 block discarded – undo
2361 2360
 			if ($this->log)
2362 2361
 			{
2363 2362
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2364
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2363
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2365 2364
 			}
2366 2365
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2367 2366
 			return false;
2368 2367
 		}
2369 2368
 		foreach ($vcal->getComponents() as $component)
2370 2369
 		{
2371
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2370
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2372 2371
 			{
2373 2372
 				$events[] = $event;
2374 2373
 			}
@@ -2413,13 +2412,13 @@  discard block
 block discarded – undo
2413 2412
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2414 2413
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2415 2414
 	 */
2416
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2415
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2417 2416
 	{
2418 2417
 		//unset($component->_container); _debug_array($component);
2419 2418
 
2420 2419
 		if ($this->log)
2421 2420
 		{
2422
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2421
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2423 2422
 		}
2424 2423
 
2425 2424
 		// eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component
@@ -2479,16 +2478,16 @@  discard block
 block discarded – undo
2479 2478
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2480 2479
 	 * @return array|boolean			event on success, false on failure
2481 2480
 	 */
2482
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2481
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2483 2482
 	{
2484
-		unset($principalURL);	// not longer used, but required in function signature
2483
+		unset($principalURL); // not longer used, but required in function signature
2485 2484
 
2486 2485
 		if ($check_component && !is_a($component, $check_component))
2487 2486
 		{
2488 2487
 			if ($this->log)
2489 2488
 			{
2490
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2491
-					get_class($component)." found\n",3,$this->logfile);
2489
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2490
+					get_class($component)." found\n", 3, $this->logfile);
2492 2491
 			}
2493 2492
 			return false;
2494 2493
 		}
@@ -2504,12 +2503,12 @@  discard block
 block discarded – undo
2504 2503
 
2505 2504
 		$isDate = false;
2506 2505
 		$event		= array();
2507
-		$alarms		= array();
2506
+		$alarms = array();
2508 2507
 		$organizer_status = $organizer_uid = null;
2509
-		$vcardData	= array(
2508
+		$vcardData = array(
2510 2509
 			'recur_type'		=> MCAL_RECUR_NONE,
2511 2510
 			'recur_exception'	=> array(),
2512
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2511
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2513 2512
 			'public'            => 1,
2514 2513
 		);
2515 2514
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
@@ -2528,7 +2527,7 @@  discard block
 block discarded – undo
2528 2527
 						$isDate = true;
2529 2528
 					}
2530 2529
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2531
-					$vcardData['start']	= $dtstart_ts;
2530
+					$vcardData['start'] = $dtstart_ts;
2532 2531
 
2533 2532
 					// set event timezone from dtstart, if specified there
2534 2533
 					if (!empty($attributes['params']['TZID']))
@@ -2546,18 +2545,18 @@  discard block
 block discarded – undo
2546 2545
 							}
2547 2546
 							else
2548 2547
 							{
2549
-								error_log(__METHOD__ . '() unknown TZID='
2550
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2551
-									. date_default_timezone_get() . '".'.array2string($tz));
2552
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2548
+								error_log(__METHOD__.'() unknown TZID='
2549
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2550
+									. date_default_timezone_get().'".'.array2string($tz));
2551
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2553 2552
 							}
2554 2553
 						}
2555
-						catch(Exception $e)
2554
+						catch (Exception $e)
2556 2555
 						{
2557
-							error_log(__METHOD__ . '() unknown TZID='
2558
-								. $attributes['params']['TZID'] . ', defaulting to timezone "'
2559
-								. date_default_timezone_get() . '".'.$e->getMessage());
2560
-							$event['tzid'] = date_default_timezone_get();	// default to current timezone
2556
+							error_log(__METHOD__.'() unknown TZID='
2557
+								. $attributes['params']['TZID'].', defaulting to timezone "'
2558
+								. date_default_timezone_get().'".'.$e->getMessage());
2559
+							$event['tzid'] = date_default_timezone_get(); // default to current timezone
2561 2560
 						}
2562 2561
 					}
2563 2562
 					// if no timezone given and one is specified in class (never the case for CalDAV)
@@ -2581,11 +2580,11 @@  discard block
 block discarded – undo
2581 2580
 
2582 2581
 				case 'DTEND':
2583 2582
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2584
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2583
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2585 2584
 					{
2586 2585
 						$dtend_ts -= 1;
2587 2586
 					}
2588
-					$vcardData['end']	= $dtend_ts;
2587
+					$vcardData['end'] = $dtend_ts;
2589 2588
 					break;
2590 2589
 
2591 2590
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2605,7 +2604,7 @@  discard block
 block discarded – undo
2605 2604
 			if ($this->log)
2606 2605
 			{
2607 2606
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2608
-					. "() DTSTART missing!\n",3,$this->logfile);
2607
+					. "() DTSTART missing!\n", 3, $this->logfile);
2609 2608
 			}
2610 2609
 			return false; // not a valid entry
2611 2610
 		}
@@ -2624,7 +2623,7 @@  discard block
 block discarded – undo
2624 2623
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2625 2624
 					if (isset($supportedFields['whole_day']))
2626 2625
 					{
2627
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2626
+						$event['whole_day'] = (isset($attributes['value']) ?strtoupper($attributes['value']) == 'TRUE' : true);
2628 2627
 					}
2629 2628
 					break;
2630 2629
 				case 'AALARM':
@@ -2654,12 +2653,12 @@  discard block
 block discarded – undo
2654 2653
 					$vcardData['recurrence'] = $attributes['value'];
2655 2654
 					break;
2656 2655
 				case 'LOCATION':
2657
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2656
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2658 2657
 					break;
2659 2658
 				case 'RRULE':
2660
-					unset($vcardData['recur_type']);	// it wont be set by +=
2659
+					unset($vcardData['recur_type']); // it wont be set by +=
2661 2660
 					$vcardData += calendar_rrule::parseRrule($attributes['value']);
2662
-					if (!empty($vcardData['recur_enddate'])) self::check_fix_endate ($vcardData);
2661
+					if (!empty($vcardData['recur_enddate'])) self::check_fix_endate($vcardData);
2663 2662
 					break;
2664 2663
 				case 'EXDATE':	// current Horde_Icalendar returns dates, no timestamps
2665 2664
 					if ($attributes['values'])
@@ -2705,11 +2704,11 @@  discard block
 block discarded – undo
2705 2704
 						(strpos($this->productName, 'outlook') !== false
2706 2705
 							|| strpos($this->productName, 'pocket pc') !== false))
2707 2706
 					{
2708
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2707
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2709 2708
 					}
2710 2709
 					else
2711 2710
 					{
2712
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2711
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2713 2712
 					}
2714 2713
 					break;
2715 2714
 				case 'CATEGORIES':
@@ -2723,10 +2722,10 @@  discard block
 block discarded – undo
2723 2722
 					}
2724 2723
 					break;
2725 2724
 				case 'ORGANIZER':
2726
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2727
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2725
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2726
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2728 2727
 					{
2729
-						$event['organizer'] = substr($event['organizer'],7);
2728
+						$event['organizer'] = substr($event['organizer'], 7);
2730 2729
 					}
2731 2730
 					if (!empty($attributes['params']['CN']))
2732 2731
 					{
@@ -2765,19 +2764,19 @@  discard block
 block discarded – undo
2765 2764
 					}
2766 2765
 					// try parsing email and cn from attendee
2767 2766
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2768
-						$attributes['value'],$matches))
2767
+						$attributes['value'], $matches))
2769 2768
 					{
2770 2769
 						$email = $matches[1] ? $matches[1] : $matches[3];
2771
-						$cn = isset($matches[2]) ? $matches[2]: '';
2770
+						$cn = isset($matches[2]) ? $matches[2] : '';
2772 2771
 					}
2773 2772
 					elseif (!empty($attributes['value']) &&
2774 2773
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2775
-						$attributes['value'],$matches))
2774
+						$attributes['value'], $matches))
2776 2775
 					{
2777 2776
 						$cn = $matches[1];
2778 2777
 						$email = $matches[2];
2779 2778
 					}
2780
-					elseif (strpos($attributes['value'],'@') !== false)
2779
+					elseif (strpos($attributes['value'], '@') !== false)
2781 2780
 					{
2782 2781
 						$email = $attributes['value'];
2783 2782
 					}
@@ -2794,7 +2793,7 @@  discard block
 block discarded – undo
2794 2793
 						if ($this->log)
2795 2794
 						{
2796 2795
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2797
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2796
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2798 2797
 						}
2799 2798
 					}
2800 2799
 					elseif ($attributes['value'] == 'Unknown')
@@ -2812,7 +2811,7 @@  discard block
 block discarded – undo
2812 2811
 						if ($this->log)
2813 2812
 						{
2814 2813
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2815
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2814
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2816 2815
 						}
2817 2816
 					}
2818 2817
 					if (!$uid)
@@ -2829,9 +2828,9 @@  discard block
 block discarded – undo
2829 2828
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2830 2829
 										array(',', ';', ':', '\\'),
2831 2830
 										$attributes['params']['CN']);
2832
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2831
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2833 2832
 							{
2834
-								$cn = substr($cn,1,-1);
2833
+								$cn = substr($cn, 1, -1);
2835 2834
 							}
2836 2835
 							// not searching for $cn, as match can be not unique or without an email address
2837 2836
 							// --> notification will fail, better store just as email
@@ -2840,19 +2839,19 @@  discard block
 block discarded – undo
2840 2839
 						if ($this->log)
2841 2840
 						{
2842 2841
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2843
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2842
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2844 2843
 						}
2845 2844
 
2846 2845
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2847
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2846
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2848 2847
 						{
2849 2848
 							// we found a group
2850 2849
 							if ($this->log)
2851 2850
 							{
2852 2851
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2853
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2852
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2854 2853
 							}
2855
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2854
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2856 2855
 							{
2857 2856
 								//Horde::logMessage("vevent2egw: group participant $uid",
2858 2857
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2866,7 +2865,7 @@  discard block
 block discarded – undo
2866 2865
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2867 2866
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2868 2867
 										$vcardData['participants'][$this->user] =
2869
-											calendar_so::combine_status($status,$quantity,$role);
2868
+											calendar_so::combine_status($status, $quantity, $role);
2870 2869
 									}
2871 2870
 								}
2872 2871
 								$status = 'U'; // keep the group
@@ -2875,36 +2874,36 @@  discard block
 block discarded – undo
2875 2874
 						}
2876 2875
 						elseif (empty($searcharray))
2877 2876
 						{
2878
-							continue 2;	// participants without email AND CN --> ignore it
2877
+							continue 2; // participants without email AND CN --> ignore it
2879 2878
 						}
2880 2879
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2881
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2880
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2882 2881
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2883
-							'','',false,'OR')))
2882
+							'', '', false, 'OR')))
2884 2883
 						{
2885 2884
 							// found an addressbook entry
2886 2885
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2887 2886
 							if ($this->log)
2888 2887
 							{
2889 2888
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2890
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2889
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2891 2890
 							}
2892 2891
 						}
2893 2892
 						else
2894 2893
 						{
2895 2894
 							if (!$email)
2896 2895
 							{
2897
-								$email = '[email protected]';	// set dummy email to store the CN
2896
+								$email = '[email protected]'; // set dummy email to store the CN
2898 2897
 							}
2899
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2898
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2900 2899
 							if ($this->log)
2901 2900
 							{
2902 2901
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2903
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2902
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2904 2903
 							}
2905 2904
 						}
2906 2905
 					}
2907
-					switch($attributes['name'])
2906
+					switch ($attributes['name'])
2908 2907
 					{
2909 2908
 						case 'ATTENDEE':
2910 2909
 							if (!isset($attributes['params']['ROLE']) &&
@@ -2918,7 +2917,7 @@  discard block
 block discarded – undo
2918 2917
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
2919 2918
 								// as this is currently the only way to store an external organizer and send him iMip responses
2920 2919
 								$q = $r = null;
2921
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
2920
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
2922 2921
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
2923 2922
 								{
2924 2923
 									$role = 'CHAIR';
@@ -2936,7 +2935,7 @@  discard block
 block discarded – undo
2936 2935
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2937 2936
 										$component->getAttribute('ORGANIZER');
2938 2937
 								}
2939
-								catch(Horde_Icalendar_Exception $e)
2938
+								catch (Horde_Icalendar_Exception $e)
2940 2939
 								{
2941 2940
 									// we can store the ORGANIZER as event owner
2942 2941
 									$event['owner'] = $uid;
@@ -2995,7 +2994,7 @@  discard block
 block discarded – undo
2995 2994
 					break;
2996 2995
 
2997 2996
 				case 'ATTACH':
2998
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
2997
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
2999 2998
 					// fall throught to store external attachment url
3000 2999
 				default:	// X- attribute or other by EGroupware unsupported property
3001 3000
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3073,7 +3072,7 @@  discard block
 block discarded – undo
3073 3072
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3074 3073
 					{
3075 3074
 						$event['reference'] = 0;
3076
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3075
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3077 3076
 						{
3078 3077
 							if (isset($vcardData[$r]))
3079 3078
 							{
@@ -3096,12 +3095,12 @@  discard block
 block discarded – undo
3096 3095
 			// reset recure_enddate to 00:00:00 on the last day
3097 3096
 			$rriter = calendar_rrule::event2rrule($event, false);
3098 3097
 			$last = $rriter->normalize_enddate();
3099
-			if(!is_object($last))
3098
+			if (!is_object($last))
3100 3099
 			{
3101
-				if($this->log)
3100
+				if ($this->log)
3102 3101
 				{
3103
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3104
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3102
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3103
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3105 3104
 				}
3106 3105
 				return false;
3107 3106
 			}
@@ -3110,16 +3109,16 @@  discard block
 block discarded – undo
3110 3109
 			$event['recur_enddate'] = Api\DateTime::to($last, 'server');
3111 3110
 		}
3112 3111
 		// translate COUNT into an enddate, as we only store enddates
3113
-		elseif($event['recur_count'])
3112
+		elseif ($event['recur_count'])
3114 3113
 		{
3115 3114
 			$rriter = calendar_rrule::event2rrule($event, false);
3116 3115
 			$last = $rriter->count2date($event['recur_count']);
3117
-			if(!is_object($last))
3116
+			if (!is_object($last))
3118 3117
 			{
3119
-				if($this->log)
3118
+				if ($this->log)
3120 3119
 				{
3121 3120
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3122
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3121
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3123 3122
 				}
3124 3123
 				return false;
3125 3124
 			}
@@ -3133,7 +3132,7 @@  discard block
 block discarded – undo
3133 3132
 			if ($this->productManufacturer == 'groupdav' && $container &&
3134 3133
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3135 3134
 			{
3136
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3135
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3137 3136
 			}
3138 3137
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3139 3138
 		}
@@ -3154,15 +3153,15 @@  discard block
 block discarded – undo
3154 3153
 
3155 3154
 		if ($this->log)
3156 3155
 		{
3157
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3158
-				array2string($event)."\n",3,$this->logfile);
3156
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3157
+				array2string($event)."\n", 3, $this->logfile);
3159 3158
 		}
3160 3159
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3161 3160
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3162 3161
 		return $event;
3163 3162
 	}
3164 3163
 
3165
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3164
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3166 3165
 	{
3167 3166
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3168 3167
 		{
@@ -3183,8 +3182,8 @@  discard block
 block discarded – undo
3183 3182
 			}
3184 3183
 			if ($this->log)
3185 3184
 			{
3186
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3187
-					array2string($events)."\n",3,$this->logfile);
3185
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3186
+					array2string($events)."\n", 3, $this->logfile);
3188 3187
 			}
3189 3188
 		}
3190 3189
 		return array();
@@ -3223,23 +3222,23 @@  discard block
 block discarded – undo
3223 3222
 	 * @param array $extra =null extra attributes to add
3224 3223
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3225 3224
 	 */
3226
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3225
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3227 3226
 	{
3228
-		if (!$start) $start = time();	// default now
3229
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3227
+		if (!$start) $start = time(); // default now
3228
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3230 3229
 
3231 3230
 		$vcal = new Horde_Icalendar;
3232
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3231
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3233 3232
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3234
-		$vcal->setAttribute('VERSION','2.0');
3235
-		$vcal->setAttribute('METHOD',$method);
3233
+		$vcal->setAttribute('VERSION', '2.0');
3234
+		$vcal->setAttribute('METHOD', $method);
3236 3235
 
3237
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3236
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3238 3237
 
3239 3238
 		$attributes = array(
3240 3239
 			'DTSTAMP' => time(),
3241
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3242
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3240
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3241
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3243 3242
 		);
3244 3243
 		if (!$utc)
3245 3244
 		{
@@ -3250,9 +3249,9 @@  discard block
 block discarded – undo
3250 3249
 		}
3251 3250
 		if (is_null($extra)) $extra = array(
3252 3251
 			'URL' => $this->freebusy_url($user),
3253
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3252
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3254 3253
 		);
3255
-		foreach($attributes+$extra as $attr => $value)
3254
+		foreach ($attributes + $extra as $attr => $value)
3256 3255
 		{
3257 3256
 			$vfreebusy->setAttribute($attr, $value);
3258 3257
 		}
@@ -3284,22 +3283,22 @@  discard block
 block discarded – undo
3284 3283
 
3285 3284
 				$fbdata[$fbtype][] = $event;
3286 3285
 			}
3287
-			foreach($fbdata as $fbtype => $events)
3286
+			foreach ($fbdata as $fbtype => $events)
3288 3287
 			{
3289
-				foreach($this->aggregate_periods($events, $start, $end) as $event)
3288
+				foreach ($this->aggregate_periods($events, $start, $end) as $event)
3290 3289
 				{
3291 3290
 					if ($utc)
3292 3291
 					{
3293
-						$vfreebusy->setAttribute('FREEBUSY',array(array(
3292
+						$vfreebusy->setAttribute('FREEBUSY', array(array(
3294 3293
 							'start' => $event['start'],
3295 3294
 							'end' => $event['end'],
3296 3295
 						)), array('FBTYPE' => $fbtype));
3297 3296
 					}
3298 3297
 					else
3299 3298
 					{
3300
-						$vfreebusy->setAttribute('FREEBUSY',array(array(
3301
-							'start' => date('Ymd\THis',$event['start']),
3302
-							'end' => date('Ymd\THis',$event['end']),
3299
+						$vfreebusy->setAttribute('FREEBUSY', array(array(
3300
+							'start' => date('Ymd\THis', $event['start']),
3301
+							'end' => date('Ymd\THis', $event['end']),
3303 3302
 						)), array('FBTYPE' => $fbtype));
3304 3303
 					}
3305 3304
 				}
@@ -3329,7 +3328,7 @@  discard block
 block discarded – undo
3329 3328
 		});
3330 3329
 
3331 3330
 		$fbdata = array();
3332
-		foreach($events as $event)
3331
+		foreach ($events as $event)
3333 3332
 		{
3334 3333
 			error_log(__METHOD__."(..., $start, $end) event[start]=$event[start], event[end]=$event[end], fbdata=".array2string($fbdata));
3335 3334
 			if ($event['end'] <= $start || $event['start'] >= $end) continue;
@@ -3342,7 +3341,7 @@  discard block
 block discarded – undo
3342 3341
 				);
3343 3342
 				continue;
3344 3343
 			}
3345
-			$last =& $fbdata[count($fbdata)-1];
3344
+			$last = & $fbdata[count($fbdata) - 1];
3346 3345
 
3347 3346
 			if ($last['end'] >= $event['start'])
3348 3347
 			{
@@ -3359,7 +3358,7 @@  discard block
 block discarded – undo
3359 3358
 				);
3360 3359
 			}
3361 3360
 		}
3362
-		$last =& $fbdata[count($fbdata)-1];
3361
+		$last = & $fbdata[count($fbdata) - 1];
3363 3362
 
3364 3363
 		if ($last['end'] > $end) $last['end'] = $end;
3365 3364
 
Please login to merge, or discard this patch.