Test Setup Failed
Push — master ( e99c33...1bbfb1 )
by Ralf
21:50
created
api/src/Session.php 1 patch
Braces   +184 added lines, -47 removed lines patch added patch discarded remove patch
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 
266 266
 		// set session_timeout from global php.ini and default to 14400=4h, if not set
267 267
 		if (!($GLOBALS['egw_info']['server']['sessions_timeout'] = ini_get('session.gc_maxlifetime')))
268
-      	{
268
+		{
269 269
       		ini_set('session.gc_maxlifetime', $GLOBALS['egw_info']['server']['sessions_timeout']=14400);
270 270
       	}
271 271
 	}
@@ -298,7 +298,10 @@  discard block
 block discarded – undo
298 298
 	 */
299 299
 	function commit_session()
300 300
 	{
301
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]).' '.function_backtrace());
301
+		if (self::ERROR_LOG_DEBUG)
302
+		{
303
+			error_log(__METHOD__."() sessionid=$this->sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]).' '.function_backtrace());
304
+		}
302 305
 		self::encrypt($this->kp3);
303 306
 
304 307
 		session_write_close();
@@ -360,7 +363,10 @@  discard block
 block discarded – undo
360 363
 	 */
361 364
 	static function log_session_usage(&$arr,$label,$recursion=true,$limit=1000)
362 365
 	{
363
-		if (!is_array($arr)) return;
366
+		if (!is_array($arr))
367
+		{
368
+			return;
369
+		}
364 370
 
365 371
 		$sizes = array();
366 372
 		foreach($arr as $key => &$data)
@@ -375,7 +381,10 @@  discard block
 block discarded – undo
375 381
 			if ($diff > $limit)
376 382
 			{
377 383
 				error_log("strlen({$label}[$key])=".Vfs::hsize($size).", diff=".Vfs::hsize($diff));
378
-				if ($recursion) self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit);
384
+				if ($recursion)
385
+				{
386
+					self::log_session_usage($arr[$key],$label.'['.$key.']',$recursion,$limit);
387
+				}
379 388
 			}
380 389
 		}
381 390
 	}
@@ -475,7 +484,10 @@  discard block
 block discarded – undo
475 484
 				$this->passwd      = $passwd;
476 485
 				$this->passwd_type = $passwd_type;
477 486
 			}
478
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ...");
487
+			if (self::ERROR_LOG_DEBUG)
488
+			{
489
+				error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) starting ...");
490
+			}
479 491
 
480 492
 			self::split_login_domain($login,$this->account_lid,$this->account_domain);
481 493
 			// add domain to the login, if not already there
@@ -525,7 +537,10 @@  discard block
 block discarded – undo
525 537
 				{
526 538
 					$this->log_access($this->reason,$login,$user_ip,0);	// log unsuccessfull login
527 539
 				}
528
-				if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
540
+				if (self::ERROR_LOG_DEBUG)
541
+				{
542
+					error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
543
+				}
529 544
 				return false;
530 545
 			}
531 546
 
@@ -550,10 +565,13 @@  discard block
 block discarded – undo
550 565
 			// --> allows this stateless protocolls which use basic auth to use sessions!
551 566
 			if (($this->sessionid = self::get_sessionid(true)))
552 567
 			{
553
-				if (session_status() !== PHP_SESSION_ACTIVE)	// gives warning including password
568
+				if (session_status() !== PHP_SESSION_ACTIVE)
569
+				{
570
+					// gives warning including password
554 571
 				{
555 572
 					session_id($this->sessionid);
556 573
 				}
574
+				}
557 575
 			}
558 576
 			else
559 577
 			{
@@ -574,7 +592,10 @@  discard block
 block discarded – undo
574 592
 				$this->reason = 'account is expired';
575 593
 				$this->cd_reason = self::CD_ACCOUNT_EXPIRED;
576 594
 
577
-				if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
595
+				if (self::ERROR_LOG_DEBUG)
596
+				{
597
+					error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
598
+				}
578 599
 				return false;
579 600
 			}
580 601
 
@@ -590,7 +611,10 @@  discard block
 block discarded – undo
590 611
 					$this->cd_reason = $e->getCode();
591 612
 					$this->reason = $e->getMessage();
592 613
 					$this->log_access($this->reason, $login, $user_ip, 0);	// log unsuccessfull login
593
-					if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check,$fail_on_forced_password_change,'$check_2fa') UNSUCCESSFULL ($this->reason)");
614
+					if (self::ERROR_LOG_DEBUG)
615
+					{
616
+						error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check,$fail_on_forced_password_change,'$check_2fa') UNSUCCESSFULL ($this->reason)");
617
+					}
594 618
 					return false;
595 619
 				}
596 620
 			}
@@ -619,24 +643,33 @@  discard block
 block discarded – undo
619 643
 				'passwd'         => $this->passwd,
620 644
 				'account_domain' => $this->account_domain,
621 645
 				'user_ip'        => $user_ip,
622
-			),'',true)))	// true = run hooks from all apps, not just the ones the current user has perms to run
646
+			),'',true)))
647
+			{
648
+				// true = run hooks from all apps, not just the ones the current user has perms to run
623 649
 			{
624 650
 				foreach($hook_result as $reason)
625 651
 				{
626 652
 					if ($reason)	// called hook requests to deny the session
627 653
 					{
628 654
 						$this->reason = $this->cd_reason = $reason;
655
+			}
629 656
 						$this->log_access($this->reason,$login,$user_ip,0);		// log unsuccessfull login
630
-						if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
657
+						if (self::ERROR_LOG_DEBUG)
658
+						{
659
+							error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) UNSUCCESSFULL ($this->reason)");
660
+						}
631 661
 						return false;
632 662
 					}
633 663
 				}
634 664
 			}
635 665
 			$GLOBALS['egw']->db->transaction_begin();
636 666
 			$this->register_session($this->login,$user_ip,$now,$this->session_flags);
637
-			if ($this->session_flags != 'A')		// dont log anonymous sessions
667
+			if ($this->session_flags != 'A')
668
+			{
669
+				// dont log anonymous sessions
638 670
 			{
639 671
 				$this->sessionid_access_log = $this->log_access($this->sessionid,$login,$user_ip,$this->account_id);
672
+			}
640 673
 				// We do NOT log anonymous sessions to not block website and also to cope with
641 674
 				// high rate anon endpoints might be called creating a bottleneck in the egw_accounts table.
642 675
 				Cache::setSession('phpgwapi', 'account_previous_login', $GLOBALS['egw']->auth->previous_login);
@@ -663,7 +696,10 @@  discard block
 block discarded – undo
663 696
 				self::egw_setcookie(self::REMEMBER_ME_COOKIE, $token, $expiration);
664 697
 			}
665 698
 
666
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid");
699
+			if (self::ERROR_LOG_DEBUG)
700
+			{
701
+				error_log(__METHOD__."($this->login,$this->passwd,$this->passwd_type,$no_session,$auth_check) successfull sessionid=$this->sessionid");
702
+			}
667 703
 
668 704
 			// hook called once session is created
669 705
 			Hooks::process(array(
@@ -1130,10 +1166,13 @@  discard block
 block discarded – undo
1130 1166
 		//error_log(__METHOD__."('$login', '$ip') false_ip=$false_ip, false_id=$false_id --> blocked=".array2string($blocked));
1131 1167
 
1132 1168
 		if ($blocked && $GLOBALS['egw_info']['server']['admin_mails'] &&
1133
-			$GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60)	// max. one mail every 5mins
1169
+			$GLOBALS['egw_info']['server']['login_blocked_mail_time'] < time()-5*60)
1170
+		{
1171
+			// max. one mail every 5mins
1134 1172
 		{
1135 1173
 			try {
1136 1174
 				$mailer = new Mailer();
1175
+		}
1137 1176
 				// notify admin(s) via email
1138 1177
 				$mailer->setFrom('eGroupWare@'.$GLOBALS['egw_info']['server']['mail_suffix']);
1139 1178
 				$mailer->addHeader('Subject', lang("eGroupWare: login blocked for user '%1', IP %2",$login,$ip));
@@ -1211,7 +1250,10 @@  discard block
 block discarded – undo
1211 1250
 		{
1212 1251
 			$sessionid = null;
1213 1252
 		}
1214
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true));
1253
+		if (self::ERROR_LOG_DEBUG)
1254
+		{
1255
+			error_log(__METHOD__."() _SERVER[REQUEST_URI]='$_SERVER[REQUEST_URI]' returning ".print_r($sessionid,true));
1256
+		}
1215 1257
 		return $sessionid;
1216 1258
 	}
1217 1259
 
@@ -1241,7 +1283,10 @@  discard block
 block discarded – undo
1241 1283
 	 */
1242 1284
 	function verify($sessionid=null,$kp3=null)
1243 1285
 	{
1244
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace());
1286
+		if (self::ERROR_LOG_DEBUG)
1287
+		{
1288
+			error_log(__METHOD__."('$sessionid','$kp3') ".function_backtrace());
1289
+		}
1245 1290
 
1246 1291
 		$fill_egw_info_and_repositories = !$GLOBALS['egw_info']['flags']['restored_from_session'];
1247 1292
 
@@ -1257,7 +1302,10 @@  discard block
 block discarded – undo
1257 1302
 
1258 1303
 		if (!$this->sessionid)
1259 1304
 		{
1260
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') get_sessionid()='".self::get_sessionid()."' No session ID");
1305
+			if (self::ERROR_LOG_DEBUG)
1306
+			{
1307
+				error_log(__METHOD__."('$sessionid') get_sessionid()='".self::get_sessionid()."' No session ID");
1308
+			}
1261 1309
 			return false;
1262 1310
 		}
1263 1311
 
@@ -1278,14 +1326,20 @@  discard block
 block discarded – undo
1278 1326
 		// check if we have a eGroupware session --> return false if not (but dont destroy it!)
1279 1327
 		if (is_null($_SESSION) || !isset($_SESSION[self::EGW_SESSION_VAR]))
1280 1328
 		{
1281
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session does NOT exist!");
1329
+			if (self::ERROR_LOG_DEBUG)
1330
+			{
1331
+				error_log(__METHOD__."('$sessionid') session does NOT exist!");
1332
+			}
1282 1333
 			return false;
1283 1334
 		}
1284 1335
 		$session =& $_SESSION[self::EGW_SESSION_VAR];
1285 1336
 
1286 1337
 		if ($session['session_dla'] <= time() - $GLOBALS['egw_info']['server']['sessions_timeout'])
1287 1338
 		{
1288
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$sessionid') session timed out!");
1339
+			if (self::ERROR_LOG_DEBUG)
1340
+			{
1341
+				error_log(__METHOD__."('$sessionid') session timed out!");
1342
+			}
1289 1343
 			$this->destroy($sessionid,$kp3);
1290 1344
 			return false;
1291 1345
 		}
@@ -1313,7 +1367,10 @@  discard block
 block discarded – undo
1313 1367
 		$this->account_id = $GLOBALS['egw']->accounts->name2id($this->account_lid,'account_lid','u');
1314 1368
 		if (!$this->account_id)
1315 1369
 		{
1316
-			if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')");
1370
+			if (self::ERROR_LOG_DEBUG)
1371
+			{
1372
+				error_log("*** Session::verify($sessionid) !accounts::name2id('$this->account_lid')");
1373
+			}
1317 1374
 			return false;
1318 1375
 		}
1319 1376
 
@@ -1340,7 +1397,10 @@  discard block
 block discarded – undo
1340 1397
 
1341 1398
 		if ($GLOBALS['egw']->accounts->is_expired($GLOBALS['egw_info']['user']))
1342 1399
 		{
1343
-			if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) accounts is expired");
1400
+			if (self::ERROR_LOG_DEBUG)
1401
+			{
1402
+				error_log("*** Session::verify($sessionid) accounts is expired");
1403
+			}
1344 1404
 			return false;
1345 1405
 		}
1346 1406
 		$this->passwd = base64_decode(Cache::getSession('phpgwapi', 'password'));
@@ -1351,7 +1411,10 @@  discard block
 block discarded – undo
1351 1411
 		}
1352 1412
 		if ($this->account_domain != $GLOBALS['egw_info']['user']['domain'])
1353 1413
 		{
1354
-			if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong domain");
1414
+			if (self::ERROR_LOG_DEBUG)
1415
+			{
1416
+				error_log("*** Session::verify($sessionid) wrong domain");
1417
+			}
1355 1418
 			return false;
1356 1419
 		}
1357 1420
 
@@ -1360,7 +1423,10 @@  discard block
 block discarded – undo
1360 1423
 			if (strtoupper(substr(PHP_OS,0,3)) != 'WIN' && (!$GLOBALS['egw_info']['user']['session_ip'] ||
1361 1424
 				$GLOBALS['egw_info']['user']['session_ip'] != $this->getuser_ip()))
1362 1425
 			{
1363
-				if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) wrong IP");
1426
+				if (self::ERROR_LOG_DEBUG)
1427
+				{
1428
+					error_log("*** Session::verify($sessionid) wrong IP");
1429
+				}
1364 1430
 				return false;
1365 1431
 			}
1366 1432
 		}
@@ -1373,7 +1439,10 @@  discard block
 block discarded – undo
1373 1439
 		}
1374 1440
 		if (!$this->account_lid)
1375 1441
 		{
1376
-			if (self::ERROR_LOG_DEBUG) error_log("*** Session::verify($sessionid) !account_lid");
1442
+			if (self::ERROR_LOG_DEBUG)
1443
+			{
1444
+				error_log("*** Session::verify($sessionid) !account_lid");
1445
+			}
1377 1446
 			return false;
1378 1447
 		}
1379 1448
 
@@ -1392,13 +1461,19 @@  discard block
 block discarded – undo
1392 1461
 			$_REQUEST[self::EGW_SESSION_NAME] === $this->sessionid &&
1393 1462
 			(!isset($_COOKIE[self::EGW_SESSION_NAME]) || $_COOKIE[self::EGW_SESSION_NAME] !== $_REQUEST[self::EGW_SESSION_NAME]))
1394 1463
 		{
1395
-			if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now");
1464
+			if (self::ERROR_LOG_DEBUG)
1465
+			{
1466
+				error_log("--> Session::verify($sessionid) SUCCESS, but NO required cookies set --> setting them now");
1467
+			}
1396 1468
 			self::egw_setcookie(self::EGW_SESSION_NAME,$this->sessionid);
1397 1469
 			self::egw_setcookie('kp3',$this->kp3);
1398 1470
 			self::egw_setcookie('domain',$this->account_domain);
1399 1471
 		}
1400 1472
 
1401
-		if (self::ERROR_LOG_DEBUG) error_log("--> Session::verify($sessionid) SUCCESS");
1473
+		if (self::ERROR_LOG_DEBUG)
1474
+		{
1475
+			error_log("--> Session::verify($sessionid) SUCCESS");
1476
+		}
1402 1477
 
1403 1478
 		return true;
1404 1479
 	}
@@ -1418,14 +1493,20 @@  discard block
 block discarded – undo
1418 1493
 		}
1419 1494
 		$this->log_access($sessionid);	// log logout-time
1420 1495
 
1421
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($sessionid,$kp3)");
1496
+		if (self::ERROR_LOG_DEBUG)
1497
+		{
1498
+			error_log(__METHOD__."($sessionid,$kp3)");
1499
+		}
1422 1500
 
1423
-		if (is_numeric($sessionid))	// do we have a access-log-id --> get PHP session id
1501
+		if (is_numeric($sessionid))
1502
+		{
1503
+			// do we have a access-log-id --> get PHP session id
1424 1504
 		{
1425 1505
 			$sessionid = $GLOBALS['egw']->db->select(self::ACCESS_LOG_TABLE,'session_php',array(
1426 1506
 					'sessionid' => $sessionid,
1427 1507
 				),__LINE__,__FILE__)->fetchColumn();
1428 1508
 		}
1509
+		}
1429 1510
 
1430 1511
 		Hooks::process(array(
1431 1512
 			'location'  => 'session_destroyed',
@@ -1435,7 +1516,10 @@  discard block
 block discarded – undo
1435 1516
 		// Only do the following, if where working with the current user
1436 1517
 		if (!$GLOBALS['egw_info']['user']['sessionid'] || $sessionid == $GLOBALS['egw_info']['user']['sessionid'])
1437 1518
 		{
1438
-			if (self::ERROR_LOG_DEBUG) error_log(__METHOD__." ********* about to call session_destroy!");
1519
+			if (self::ERROR_LOG_DEBUG)
1520
+			{
1521
+				error_log(__METHOD__." ********* about to call session_destroy!");
1522
+			}
1439 1523
 			session_unset();
1440 1524
 			@session_destroy();
1441 1525
 			// we need to (re-)load the eGW session-handler, as session_destroy unloads custom session-handlers
@@ -1530,7 +1614,10 @@  discard block
 block discarded – undo
1530 1614
 		}
1531 1615
 		else
1532 1616
 		{
1533
-			if ($othervars) $extravars .= ($extravars?'&':'').$othervars;
1617
+			if ($othervars)
1618
+			{
1619
+				$extravars .= ($extravars?'&':'').$othervars;
1620
+			}
1534 1621
 		}
1535 1622
 
1536 1623
 		// parse extravars string into the vars array
@@ -1539,7 +1626,11 @@  discard block
 block discarded – undo
1539 1626
 			foreach(explode('&',$extravars) as $expr)
1540 1627
 			{
1541 1628
 				list($var,$val) = explode('=', $expr,2);
1542
-				if (strpos($val,'%26') != false) $val = str_replace('%26','&',$val);	// make sure to not double encode &
1629
+				if (strpos($val,'%26') != false)
1630
+				{
1631
+					$val = str_replace('%26','&',$val);
1632
+				}
1633
+				// make sure to not double encode &
1543 1634
 				if (substr($var,-2) == '[]')
1544 1635
 				{
1545 1636
 					$vars[substr($var,0,-2)][] = $val;
@@ -1636,14 +1727,22 @@  discard block
 block discarded – undo
1636 1727
 		{
1637 1728
 			self::set_cookiedomain();
1638 1729
 		}
1639
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."($cookiename,$cookievalue,$cookietime,$cookiepath,".self::$cookie_domain.")");
1730
+		if (self::ERROR_LOG_DEBUG)
1731
+		{
1732
+			error_log(__METHOD__."($cookiename,$cookievalue,$cookietime,$cookiepath,".self::$cookie_domain.")");
1733
+		}
1640 1734
 
1641 1735
 		// if we are installed in iOS as web-app, we must not set a cookietime==0 (session-cookie),
1642 1736
 		// as every change between apps will cause the cookie to get lost
1643 1737
 		static $is_iOS = null;
1644
-		if (!$cookietime && !isset($is_iOS)) $is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile());
1738
+		if (!$cookietime && !isset($is_iOS))
1739
+		{
1740
+			$is_iOS = (bool)preg_match('/^(iPhone|iPad|iPod)/i', Header\UserAgent::mobile());
1741
+		}
1645 1742
 
1646
-		if(!headers_sent())	// gives only a warning, but can not send the cookie anyway
1743
+		if(!headers_sent())
1744
+		{
1745
+			// gives only a warning, but can not send the cookie anyway
1647 1746
 		{
1648 1747
 			setcookie($cookiename, $cookievalue,
1649 1748
 				!$cookietime && $is_iOS ? time()+self::IOS_SESSION_COOKIE_LIFETIME : $cookietime,
@@ -1651,6 +1750,7 @@  discard block
 block discarded – undo
1651 1750
 				// if called via HTTPS, only send cookie for https and only allow cookie access via HTTP (true)
1652 1751
 				empty($GLOBALS['egw_info']['server']['insecure_cookies']) && Header\Http::schema() === 'https', true);
1653 1752
 		}
1753
+		}
1654 1754
 	}
1655 1755
 
1656 1756
 	/**
@@ -1702,15 +1802,25 @@  discard block
 block discarded – undo
1702 1802
 	 */
1703 1803
 	public static function search_instance($login,$domain_requested,&$default_domain,$server_names,array $domains=null)
1704 1804
 	{
1705
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")");
1805
+		if (self::ERROR_LOG_DEBUG)
1806
+		{
1807
+			error_log(__METHOD__."('$login','$domain_requested',".array2string($default_domain).".".array2string($server_names).".".array2string($domains).")");
1808
+		}
1706 1809
 
1707
-		if (is_null($domains)) $domains = $GLOBALS['egw_domain'];
1810
+		if (is_null($domains))
1811
+		{
1812
+			$domains = $GLOBALS['egw_domain'];
1813
+		}
1708 1814
 
1709
-		if (!isset($default_domain) || !isset($domains[$default_domain]))	// allow to overwrite the default domain
1815
+		if (!isset($default_domain) || !isset($domains[$default_domain]))
1816
+		{
1817
+			// allow to overwrite the default domain
1710 1818
 		{
1711 1819
 			foreach((array)$server_names as $server_name)
1712 1820
 			{
1713
-				list($server_name) = explode(':', $server_name);	// remove port from HTTP_HOST
1821
+				list($server_name) = explode(':', $server_name);
1822
+		}
1823
+		// remove port from HTTP_HOST
1714 1824
 				if(isset($domains[$server_name]))
1715 1825
 				{
1716 1826
 					$default_domain = $server_name;
@@ -1735,11 +1845,14 @@  discard block
 block discarded – undo
1735 1845
 				}
1736 1846
 			}
1737 1847
 		}
1738
-		if (isset($login))	// on login
1848
+		if (isset($login))
1849
+		{
1850
+			// on login
1739 1851
 		{
1740 1852
 			if (strpos($login,'@') === false || count($domains) == 1)
1741 1853
 			{
1742 1854
 				$login .= '@' . (isset($_POST['logindomain']) ? $_POST['logindomain'] : $default_domain);
1855
+		}
1743 1856
 			}
1744 1857
 			$parts = explode('@',$login);
1745 1858
 			$domain = array_pop($parts);
@@ -1753,7 +1866,10 @@  discard block
 block discarded – undo
1753 1866
 		{
1754 1867
 			$domain = $default_domain;
1755 1868
 		}
1756
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() default_domain=".array2string($default_domain).', login='.array2string($login)." returning ".array2string($domain));
1869
+		if (self::ERROR_LOG_DEBUG)
1870
+		{
1871
+			error_log(__METHOD__."() default_domain=".array2string($default_domain).', login='.array2string($login)." returning ".array2string($domain));
1872
+		}
1757 1873
 
1758 1874
 		return $domain;
1759 1875
 	}
@@ -1792,14 +1908,20 @@  discard block
 block discarded – undo
1792 1908
 		{
1793 1909
 			list(, $action) = explode('.ajax_exec.template.', $_GET['menuaction']);
1794 1910
 
1795
-			if (empty($action)) $action = $_GET['menuaction'];
1911
+			if (empty($action))
1912
+			{
1913
+				$action = $_GET['menuaction'];
1914
+			}
1796 1915
 		}
1797 1916
 		else
1798 1917
 		{
1799 1918
 			$action = $_SERVER['PHP_SELF'];
1800 1919
 			// remove EGroupware path, if not installed in webroot
1801 1920
 			$egw_path = $GLOBALS['egw_info']['server']['webserver_url'];
1802
-			if ($egw_path[0] != '/') $egw_path = parse_url($egw_path,PHP_URL_PATH);
1921
+			if ($egw_path[0] != '/')
1922
+			{
1923
+				$egw_path = parse_url($egw_path,PHP_URL_PATH);
1924
+			}
1803 1925
 			if ($action == '/Microsoft-Server-ActiveSync')
1804 1926
 			{
1805 1927
 				$action .= '?Cmd='.$_GET['Cmd'].'&DeviceId='.$_GET['DeviceId'];
@@ -1832,7 +1954,10 @@  discard block
 block discarded – undo
1832 1954
 
1833 1955
 		$_SESSION[self::EGW_SESSION_VAR]['session_dla'] = time();
1834 1956
 		$_SESSION[self::EGW_SESSION_VAR]['session_action'] = $this->action;
1835
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__.'() _SESSION['.self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]));
1957
+		if (self::ERROR_LOG_DEBUG)
1958
+		{
1959
+			error_log(__METHOD__.'() _SESSION['.self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]));
1960
+		}
1836 1961
 
1837 1962
 		return $this->action;
1838 1963
 	}
@@ -1974,14 +2099,20 @@  discard block
 block discarded – undo
1974 2099
 					self::cache_control();
1975 2100
 					$ok = session_start();
1976 2101
 					self::decrypt();
1977
-					if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() sessionid=$sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]));
2102
+					if (self::ERROR_LOG_DEBUG)
2103
+					{
2104
+						error_log(__METHOD__."() sessionid=$sessionid, _SESSION[".self::EGW_SESSION_VAR.']='.array2string($_SESSION[self::EGW_SESSION_VAR]));
2105
+					}
1978 2106
 					return $ok;
1979 2107
 				}
1980 2108
 				break;
1981 2109
 			case PHP_SESSION_ACTIVE:
1982 2110
 				return true;	// session created by MServer
1983 2111
 		}
1984
-		if (self::ERROR_LOG_DEBUG) error_log(__METHOD__."() no active session!");
2112
+		if (self::ERROR_LOG_DEBUG)
2113
+		{
2114
+			error_log(__METHOD__."() no active session!");
2115
+		}
1985 2116
 
1986 2117
 		return false;
1987 2118
 	}
@@ -2039,9 +2170,12 @@  discard block
 block discarded – undo
2039 2170
 					error_log(__METHOD__."($expire) called, but header already sent in $file: $line");
2040 2171
 					return;
2041 2172
 				}
2042
-				if($expire === true)	// same behavior as session_cache_limiter('private_no_expire')
2173
+				if($expire === true)
2174
+				{
2175
+					// same behavior as session_cache_limiter('private_no_expire')
2043 2176
 				{
2044 2177
 					header('Cache-Control: private, max-age='.(60*session_cache_expire()));
2178
+				}
2045 2179
 					header_remove('Expires');
2046 2180
 				}
2047 2181
 				elseif ($private)
@@ -2055,10 +2189,13 @@  discard block
 block discarded – undo
2055 2189
 					header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expire) . ' GMT');
2056 2190
 				}
2057 2191
 				// remove Pragma header, might be set by old header
2058
-				if (function_exists('header_remove'))	// PHP 5.3+
2192
+				if (function_exists('header_remove'))
2193
+				{
2194
+					// PHP 5.3+
2059 2195
 				{
2060 2196
 					header_remove('Pragma');
2061 2197
 				}
2198
+				}
2062 2199
 				else
2063 2200
 				{
2064 2201
 					header('Pragma:');
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 3 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1014,12 +1014,12 @@  discard block
 block discarded – undo
1014 1014
 				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
1015 1015
 				{
1016 1016
 					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
1017
-	                $paramData = (array) Api\Translation::convert(is_array($value) ?
1018
-	                		$parameters[$key][$valueID] : $parameters[$key],
1019
-	                        Api\Translation::charset(),$charset);
1020
-	                $valuesData = (array) Api\Translation::convert($values[$key],
1021
-	                		Api\Translation::charset(),$charset);
1022
-	                $content = $valueData . implode(';', $valuesData);
1017
+					$paramData = (array) Api\Translation::convert(is_array($value) ?
1018
+							$parameters[$key][$valueID] : $parameters[$key],
1019
+							Api\Translation::charset(),$charset);
1020
+					$valuesData = (array) Api\Translation::convert($values[$key],
1021
+							Api\Translation::charset(),$charset);
1022
+					$content = $valueData . implode(';', $valuesData);
1023 1023
 
1024 1024
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1025 1025
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -3165,7 +3165,7 @@  discard block
 block discarded – undo
3165 3165
 				array2string($event)."\n",3,$this->logfile);
3166 3166
 		}
3167 3167
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3168
-	    //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3168
+		//    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3169 3169
 		return $event;
3170 3170
 	}
3171 3171
 
Please login to merge, or discard this patch.
Spacing   +257 added lines, -258 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;
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
684 684
 								foreach ($event['recur_exception'] as $id => $timestamp)
685 685
 								{
686
-									$time = new Api\DateTime($timestamp,Api\DateTime::$server_timezone);
686
+									$time = new Api\DateTime($timestamp, Api\DateTime::$server_timezone);
687 687
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
688
-									$arr = Api\DateTime::to($time,'array');
688
+									$arr = Api\DateTime::to($time, 'array');
689 689
 									$days[$id] = array(
690 690
 										'year'  => $arr['year'],
691 691
 										'month' => $arr['month'],
@@ -700,21 +700,21 @@  discard block
 block discarded – undo
700 700
 						break;
701 701
 
702 702
 					case 'PRIORITY':
703
-						if (!$event['priority']) continue 2;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
703
+						if (!$event['priority']) continue 2; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
704 704
 						if ($this->productManufacturer == 'funambol' &&
705 705
 							(strpos($this->productName, 'outlook') !== false
706 706
 								|| strpos($this->productName, 'pocket pc') !== false))
707 707
 						{
708
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
708
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
709 709
 						}
710 710
 						else
711 711
 						{
712
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
712
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
713 713
 						}
714 714
 						break;
715 715
 
716 716
 					case 'TRANSP':
717
-						if (!$event['non_blocking']) continue 2;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
717
+						if (!$event['non_blocking']) continue 2; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
718 718
 						if ($version == '1.0')
719 719
 						{
720 720
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -753,13 +753,13 @@  discard block
 block discarded – undo
753 753
 							// We handle a pseudo exception
754 754
 							if (empty($event['whole_day']))
755 755
 							{
756
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
756
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
757 757
 							}
758 758
 							else
759 759
 							{
760
-								$time = new Api\DateTime($recur_date,Api\DateTime::$server_timezone);
760
+								$time = new Api\DateTime($recur_date, Api\DateTime::$server_timezone);
761 761
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
762
-								$arr = Api\DateTime::to($time,'array');
762
+								$arr = Api\DateTime::to($time, 'array');
763 763
 								$vevent->setAttribute($icalFieldName, array(
764 764
 									'year' => $arr['year'],
765 765
 									'month' => $arr['month'],
@@ -771,17 +771,17 @@  discard block
 block discarded – undo
771 771
 						elseif ($event['recurrence'] && $event['reference'])
772 772
 						{
773 773
 							// $event['reference'] is a calendar_id, not a timestamp
774
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
774
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
775 775
 
776 776
 							if (empty($revent['whole_day']))
777 777
 							{
778
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
778
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
779 779
 							}
780 780
 							else
781 781
 							{
782
-								$time = new Api\DateTime($event['recurrence'],Api\DateTime::$server_timezone);
782
+								$time = new Api\DateTime($event['recurrence'], Api\DateTime::$server_timezone);
783 783
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
784
-								$arr = Api\DateTime::to($time,'array');
784
+								$arr = Api\DateTime::to($time, 'array');
785 785
 								$vevent->setAttribute($icalFieldName, array(
786 786
 									'year' => $arr['year'],
787 787
 									'month' => $arr['month'],
@@ -808,9 +808,9 @@  discard block
 block discarded – undo
808 808
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
809 809
 							if ($this->log && $size > 0)
810 810
 							{
811
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
812
-									"() $icalFieldName Size: $size, NoTruncate: " .
813
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
811
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
812
+									"() $icalFieldName Size: $size, NoTruncate: ".
813
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
814 814
 							}
815 815
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
816 816
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 							{
829 829
 								if ($this->log)
830 830
 								{
831
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
832
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
831
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
832
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
833 833
 								}
834 834
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
835 835
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 							$value = substr($value, 0, $size - 1);
840 840
 							if ($this->log)
841 841
 							{
842
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
843
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
842
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
843
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
844 844
 							}
845 845
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
846 846
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 			// for CalDAV add all X-Properties previously parsed
856 856
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
857 857
 			{
858
-				foreach($event as $name => $value)
858
+				foreach ($event as $name => $value)
859 859
 				{
860 860
 					if (substr($name, 0, 2) == '##')
861 861
 					{
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
 						$values['AALARM']['repeat count'] = '';
934 934
 						$values['AALARM']['display text'] = $description;
935 935
 					}
936
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
937
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
936
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
937
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
938 938
 					// lets take only the first alarm
939 939
 					break;
940 940
 				}
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
 						$alarmData['offset'] = false;
972 972
 					}
973 973
 
974
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
974
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
975 975
 					if ($alarmData['offset'] !== false)
976 976
 					{
977 977
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 					else
981 981
 					{
982 982
 						$params = array('VALUE' => 'DATE-TIME');
983
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
983
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
984 984
 						$valarm->setAttribute('TRIGGER', $value, $params);
985 985
 					}
986 986
 					if (!empty($alarmData['uid']))
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
992 992
 					if (isset($alarmData['attrs']))
993 993
 					{
994
-						foreach($alarmData['attrs'] as $attr => $data)
994
+						foreach ($alarmData['attrs'] as $attr => $data)
995 995
 						{
996 996
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
997 997
 						}
@@ -999,11 +999,11 @@  discard block
 block discarded – undo
999 999
 					// set default ACTION and DESCRIPTION, if not set by a client
1000 1000
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
1001 1001
 					{
1002
-						$valarm->setAttribute('ACTION','DISPLAY');
1002
+						$valarm->setAttribute('ACTION', 'DISPLAY');
1003 1003
 					}
1004 1004
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
1005 1005
 					{
1006
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
1006
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
1007 1007
 					}
1008 1008
 					$vevent->addComponent($valarm);
1009 1009
 				}
@@ -1011,15 +1011,15 @@  discard block
 block discarded – undo
1011 1011
 
1012 1012
 			foreach ($attributes as $key => $value)
1013 1013
 			{
1014
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
1014
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
1015 1015
 				{
1016
-					$valueData = Api\Translation::convert($valueData,Api\Translation::charset(),$charset);
1017
-	                $paramData = (array) Api\Translation::convert(is_array($value) ?
1016
+					$valueData = Api\Translation::convert($valueData, Api\Translation::charset(), $charset);
1017
+	                $paramData = (array)Api\Translation::convert(is_array($value) ?
1018 1018
 	                		$parameters[$key][$valueID] : $parameters[$key],
1019
-	                        Api\Translation::charset(),$charset);
1020
-	                $valuesData = (array) Api\Translation::convert($values[$key],
1021
-	                		Api\Translation::charset(),$charset);
1022
-	                $content = $valueData . implode(';', $valuesData);
1019
+	                        Api\Translation::charset(), $charset);
1020
+	                $valuesData = (array)Api\Translation::convert($values[$key],
1021
+	                		Api\Translation::charset(), $charset);
1022
+	                $content = $valueData.implode(';', $valuesData);
1023 1023
 
1024 1024
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1025 1025
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1070 1070
  		if ($this->log)
1071 1071
  		{
1072
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1073
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1074
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1075
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1072
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1073
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1074
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1075
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1076 1076
  		}
1077 1077
 
1078 1078
 		// hack to fix iCalendar exporting EXDATE always postfixed with a Z
@@ -1091,15 +1091,15 @@  discard block
 block discarded – undo
1091 1091
 	 * @param array &$params=null parameter array to set TZID
1092 1092
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1093 1093
 	 */
1094
-	static function getDateTime($time,$tzid,array &$params=null)
1094
+	static function getDateTime($time, $tzid, array &$params = null)
1095 1095
 	{
1096 1096
 		if (empty($tzid) || $tzid == 'UTC')
1097 1097
 		{
1098
-			return Api\DateTime::to($time,'ts');
1098
+			return Api\DateTime::to($time, 'ts');
1099 1099
 		}
1100
-		if (!is_a($time,'DateTime'))
1100
+		if (!is_a($time, 'DateTime'))
1101 1101
 		{
1102
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
1102
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
1103 1103
 		}
1104 1104
 		if (!isset(self::$tz_cache[$tzid]))
1105 1105
 		{
@@ -1134,11 +1134,11 @@  discard block
 block discarded – undo
1134 1134
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1135 1135
 	 * @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"
1136 1136
 	 */
1137
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1137
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1138 1138
 	{
1139 1139
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1140 1140
 		$this->events_imported = 0;
1141
-		$replace = $delete_exceptions= false;
1141
+		$replace = $delete_exceptions = false;
1142 1142
 
1143 1143
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1144 1144
 
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 		{
1147 1147
 			return false;
1148 1148
 		}
1149
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1149
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1150 1150
 
1151 1151
 		if ($cal_id > 0)
1152 1152
 		{
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 			{
1155 1155
 				$replace = $recur_date == 0;
1156 1156
 				$events[0]['id'] = $cal_id;
1157
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1157
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1158 1158
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1159 1159
 			}
1160 1160
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1196,9 +1196,9 @@  discard block
 block discarded – undo
1196 1196
 			if (!is_array($event)) continue; // the iterator may return false
1197 1197
 
1198 1198
 			// Run event through callback
1199
-			if($this->event_callback && is_callable($this->event_callback))
1199
+			if ($this->event_callback && is_callable($this->event_callback))
1200 1200
 			{
1201
-				if(!call_user_func_array($this->event_callback, array(&$event)))
1201
+				if (!call_user_func_array($this->event_callback, array(&$event)))
1202 1202
 				{
1203 1203
 					// Callback cancelled event
1204 1204
 					continue;
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 			{
1217 1217
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1218 1218
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1219
-					. array2string($event)."\n",3,$this->logfile);
1219
+					. array2string($event)."\n", 3, $this->logfile);
1220 1220
 			}
1221 1221
 
1222 1222
 			$updated_id = false;
@@ -1239,14 +1239,14 @@  discard block
 block discarded – undo
1239 1239
 					{
1240 1240
 						if ($delete_exceptions)
1241 1241
 						{
1242
-							$this->delete($id,0,false,$skip_notification);
1242
+							$this->delete($id, 0, false, $skip_notification);
1243 1243
 						}
1244 1244
 						else
1245 1245
 						{
1246 1246
 							if (!($exception = $this->read($id))) continue;
1247 1247
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1248 1248
 							$exception['reference'] = $exception['recurrence'] = 0;
1249
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1249
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1250 1250
 						}
1251 1251
 					}
1252 1252
 				}
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 				{
1264 1264
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1265 1265
 						. "(UPDATE Event)\n"
1266
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1266
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1267 1267
 				}
1268 1268
 				if (empty($event['uid']))
1269 1269
 				{
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 								if ($this->log)
1286 1286
 								{
1287 1287
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1288
-										"() Restore status for $uid\n",3,$this->logfile);
1288
+										"() Restore status for $uid\n", 3, $this->logfile);
1289 1289
 								}
1290 1290
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1291 1291
 							}
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 					if ($this->log)
1321 1321
 					{
1322 1322
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1323
-							"()[MERGE]\n",3,$this->logfile);
1323
+							"()[MERGE]\n", 3, $this->logfile);
1324 1324
 					}
1325 1325
 					// overwrite with server data for merge
1326 1326
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 						switch ($key)
1329 1329
 						{
1330 1330
 							case 'participants_types':
1331
-								continue 2;	// +1 for switch
1331
+								continue 2; // +1 for switch
1332 1332
 
1333 1333
 							case 'participants':
1334 1334
 								foreach ($event_info['stored_event']['participants'] as $uid => $status)
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 				else
1351 1351
 				{
1352 1352
 					// no merge
1353
-					if(!isset($this->supportedFields['category']))
1353
+					if (!isset($this->supportedFields['category']))
1354 1354
 					{
1355 1355
 						$event['category'] = $event_info['stored_event']['category'];
1356 1356
 					}
@@ -1362,7 +1362,7 @@  discard block
 block discarded – undo
1362 1362
 						if ($this->log)
1363 1363
 						{
1364 1364
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1365
-							"() No participants\n",3,$this->logfile);
1365
+							"() No participants\n", 3, $this->logfile);
1366 1366
 						}
1367 1367
 
1368 1368
 						// If this is an updated meeting, and the client doesn't support
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 								if ($this->log)
1382 1382
 								{
1383 1383
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1384
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1384
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1385 1385
 								}
1386 1386
 								// Add it back in
1387 1387
 								$event['participants'][$uid] = $status;
@@ -1469,8 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 						}
1470 1470
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1471 1471
 						$event['participants'][$user] = calendar_so::combine_status(
1472
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1473
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1472
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1474 1473
 					}
1475 1474
 				}
1476 1475
 				// check if an owner is set and the current user has add rights
@@ -1535,9 +1534,9 @@  discard block
 block discarded – undo
1535 1534
 
1536 1535
 			if ($this->log)
1537 1536
 			{
1538
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1539
-					. $event_info['type'] . ")\n"
1540
-					. array2string($event)."\n",3,$this->logfile);
1537
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1538
+					. $event_info['type'].")\n"
1539
+					. array2string($event)."\n", 3, $this->logfile);
1541 1540
 			}
1542 1541
 
1543 1542
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1545,10 +1544,10 @@  discard block
 block discarded – undo
1545 1544
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1546 1545
 				$event['status'] == 'CANCELLED')
1547 1546
 			{
1548
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1547
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1549 1548
 				{
1550 1549
 					// delete fails (because no rights), reject recurrence
1551
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1550
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1552 1551
 				}
1553 1552
 				continue;
1554 1553
 			}
@@ -1560,7 +1559,7 @@  discard block
 block discarded – undo
1560 1559
 					if ($this->log)
1561 1560
 					{
1562 1561
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1563
-							"(): event SINGLE\n",3,$this->logfile);
1562
+							"(): event SINGLE\n", 3, $this->logfile);
1564 1563
 					}
1565 1564
 
1566 1565
 					// update the event
@@ -1570,7 +1569,7 @@  discard block
 block discarded – undo
1570 1569
 						$event['reference'] = 0;
1571 1570
 						$event_to_store = $event; // prevent $event from being changed by the update method
1572 1571
 						$this->server2usertime($event_to_store);
1573
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1572
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1574 1573
 						unset($event_to_store);
1575 1574
 					}
1576 1575
 					break;
@@ -1579,7 +1578,7 @@  discard block
 block discarded – undo
1579 1578
 					if ($this->log)
1580 1579
 					{
1581 1580
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1582
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1581
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1583 1582
 					}
1584 1583
 
1585 1584
 					// remove all known pseudo exceptions and update the event
@@ -1589,8 +1588,8 @@  discard block
 block discarded – undo
1589 1588
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1590 1589
 						if ($this->log)
1591 1590
 						{
1592
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1593
-								array2string($days)."\n",3,$this->logfile);
1591
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1592
+								array2string($days)."\n", 3, $this->logfile);
1594 1593
 						}
1595 1594
 						if (is_array($days))
1596 1595
 						{
@@ -1608,7 +1607,7 @@  discard block
 block discarded – undo
1608 1607
 
1609 1608
 						$event_to_store = $event; // prevent $event from being changed by the update method
1610 1609
 						$this->server2usertime($event_to_store);
1611
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1610
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1612 1611
 						unset($event_to_store);
1613 1612
 					}
1614 1613
 					break;
@@ -1618,7 +1617,7 @@  discard block
 block discarded – undo
1618 1617
 					if ($this->log)
1619 1618
 					{
1620 1619
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1621
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1620
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1622 1621
 					}
1623 1622
 
1624 1623
 					// update event
@@ -1674,13 +1673,13 @@  discard block
 block discarded – undo
1674 1673
 							$event['owner'] = $event_info['master_event']['owner'];
1675 1674
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1676 1675
 							$this->server2usertime($event_to_store);
1677
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1676
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1678 1677
 							unset($event_to_store);
1679 1678
 						}
1680 1679
 
1681 1680
 						$event_to_store = $event; // prevent $event from being changed by update method
1682 1681
 						$this->server2usertime($event_to_store);
1683
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1682
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1684 1683
 						unset($event_to_store);
1685 1684
 					}
1686 1685
 					break;
@@ -1689,7 +1688,7 @@  discard block
 block discarded – undo
1689 1688
 					if ($this->log)
1690 1689
 					{
1691 1690
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1692
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1691
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1693 1692
 					}
1694 1693
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1695 1694
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1710,7 +1709,7 @@  discard block
 block discarded – undo
1710 1709
 						// save the series master with the adjusted exceptions
1711 1710
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1712 1711
 						$this->server2usertime($event_to_store);
1713
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1712
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1714 1713
 						unset($event_to_store);
1715 1714
 					}
1716 1715
 
@@ -1737,13 +1736,13 @@  discard block
 block discarded – undo
1737 1736
 							if ($event_info['acl_edit'])
1738 1737
 							{
1739 1738
 								// update all participants if we have the right to do that
1740
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1739
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1741 1740
 							}
1742 1741
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1743 1742
 							{
1744 1743
 								// update the users status only
1745 1744
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1746
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1745
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1747 1746
 							}
1748 1747
 						}
1749 1748
 						break;
@@ -1755,13 +1754,13 @@  discard block
 block discarded – undo
1755 1754
 							if ($event_info['acl_edit'])
1756 1755
 							{
1757 1756
 								// update all participants if we have the right to do that
1758
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1757
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1759 1758
 							}
1760 1759
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1761 1760
 							{
1762 1761
 								// update the users status only
1763 1762
 								$this->set_status($event_info['master_event']['id'], $this->user,
1764
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1763
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1765 1764
 							}
1766 1765
 						}
1767 1766
 						break;
@@ -1778,7 +1777,7 @@  discard block
 block discarded – undo
1778 1777
 					break;
1779 1778
 
1780 1779
 				case 'SERIES-PSEUDO-EXCEPTION':
1781
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1780
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1782 1781
 					break;
1783 1782
 
1784 1783
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1791,7 +1790,7 @@  discard block
 block discarded – undo
1791 1790
 					{
1792 1791
 						// we did not have sufficient rights to propagate the status only exception to a real one
1793 1792
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1794
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1793
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1795 1794
 					}
1796 1795
 					break;
1797 1796
 			}
@@ -1805,8 +1804,8 @@  discard block
 block discarded – undo
1805 1804
 			if ($this->log)
1806 1805
 			{
1807 1806
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1808
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1809
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1807
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1808
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1810 1809
 			}
1811 1810
 		}
1812 1811
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1828,19 +1827,19 @@  discard block
 block discarded – undo
1828 1827
 	 * @return mixed on success: int $cal_id > 0, on error or conflicts false.
1829 1828
 	 *	Conflicts are passed to $this->conflict_callback
1830 1829
 	 */
1831
-	public function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false)
1830
+	public function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false)
1832 1831
 	{
1833
-		if($this->conflict_callback !== null)
1832
+		if ($this->conflict_callback !== null)
1834 1833
 		{
1835 1834
 			// calendar_ical overrides search(), which breaks conflict checking
1836 1835
 			// so we make sure to use the original from parent
1837 1836
 			static $bo = null;
1838
-			if(!$bo)
1837
+			if (!$bo)
1839 1838
 			{
1840 1839
 				$bo = new calendar_boupdate();
1841 1840
 			}
1842 1841
 			$conflicts = $bo->conflicts($event);
1843
-			if(is_array($conflicts) && count($conflicts) > 0)
1842
+			if (is_array($conflicts) && count($conflicts) > 0)
1844 1843
 			{
1845 1844
 				call_user_func_array($this->conflict_callback, array(&$event, &$conflicts));
1846 1845
 				return false;
@@ -1861,11 +1860,11 @@  discard block
 block discarded – undo
1861 1860
 	{
1862 1861
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1863 1862
 		$modified = 0;
1864
-		foreach($event['alarm'] as &$alarm)
1863
+		foreach ($event['alarm'] as &$alarm)
1865 1864
 		{
1866 1865
 			// check if alarm is already stored or from other users
1867 1866
 			$found = false;
1868
-			foreach($old_alarms as $id => $old_alarm)
1867
+			foreach ($old_alarms as $id => $old_alarm)
1869 1868
 			{
1870 1869
 				// not current users alarm --> ignore
1871 1870
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1881,7 +1880,7 @@  discard block
 block discarded – undo
1881 1880
 					break;
1882 1881
 				}
1883 1882
 			}
1884
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
1883
+			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found ? 'existing' : 'new')." alarm ".array2string($alarm));
1885 1884
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1886 1885
 			{
1887 1886
 				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
@@ -1909,7 +1908,7 @@  discard block
 block discarded – undo
1909 1908
 			}
1910 1909
 		}
1911 1910
 		// remove all old alarms left from current user
1912
-		foreach($old_alarms as $id => $old_alarm)
1911
+		foreach ($old_alarms as $id => $old_alarm)
1913 1912
 		{
1914 1913
 			// not current users alarm --> ignore
1915 1914
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1932,7 +1931,7 @@  discard block
 block discarded – undo
1932 1931
 	 * @param string $what ='value'
1933 1932
 	 * @return mixed
1934 1933
 	 */
1935
-	static function _get_attribute($components,$name,$what='value')
1934
+	static function _get_attribute($components, $name, $what = 'value')
1936 1935
 	{
1937 1936
 		foreach ($components as $attribute)
1938 1937
 		{
@@ -1967,7 +1966,7 @@  discard block
 block discarded – undo
1967 1966
 						case 'DURATION':
1968 1967
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1969 1968
 							{
1970
-								$alarm['offset'] = $duration -$vattr['value'];
1969
+								$alarm['offset'] = $duration - $vattr['value'];
1971 1970
 							}
1972 1971
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1973 1972
 							{
@@ -1983,7 +1982,7 @@  discard block
 block discarded – undo
1983 1982
 							$alarm['time'] = $vattr['value'];
1984 1983
 							break;
1985 1984
 						default:
1986
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1985
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1987 1986
 					}
1988 1987
 					break;
1989 1988
 
@@ -2008,9 +2007,9 @@  discard block
 block discarded – undo
2008 2007
 		return 0;
2009 2008
 	}
2010 2009
 
2011
-	function setSupportedFields($_productManufacturer='', $_productName='')
2010
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
2012 2011
 	{
2013
-		$state =& $_SESSION['SyncML.state'];
2012
+		$state = & $_SESSION['SyncML.state'];
2014 2013
 		if (isset($state))
2015 2014
 		{
2016 2015
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2307,10 +2306,10 @@  discard block
 block discarded – undo
2307 2306
 		if ($this->log)
2308 2307
 		{
2309 2308
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2310
-				'(' . $this->productManufacturer .
2311
-				', '. $this->productName .', ' .
2312
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
2313
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2309
+				'('.$this->productManufacturer.
2310
+				', '.$this->productName.', '.
2311
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
2312
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2314 2313
 		}
2315 2314
 
2316 2315
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2328,12 +2327,12 @@  discard block
 block discarded – undo
2328 2327
 	 *                         utf-8 for new format, iso-8859-1 for old format.
2329 2328
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2330 2329
 	 */
2331
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2330
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2332 2331
 	{
2333 2332
 		if ($this->log)
2334 2333
 		{
2335
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2336
-				array2string($_vcalData)."\n",3,$this->logfile);
2334
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2335
+				array2string($_vcalData)."\n", 3, $this->logfile);
2337 2336
 		}
2338 2337
 
2339 2338
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2368,14 +2367,14 @@  discard block
 block discarded – undo
2368 2367
 			if ($this->log)
2369 2368
 			{
2370 2369
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2371
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2370
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2372 2371
 			}
2373 2372
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2374 2373
 			return false;
2375 2374
 		}
2376 2375
 		foreach ($vcal->getComponents() as $component)
2377 2376
 		{
2378
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2377
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2379 2378
 			{
2380 2379
 				$events[] = $event;
2381 2380
 			}
@@ -2420,13 +2419,13 @@  discard block
 block discarded – undo
2420 2419
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2421 2420
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2422 2421
 	 */
2423
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2422
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2424 2423
 	{
2425 2424
 		//unset($component->_container); _debug_array($component);
2426 2425
 
2427 2426
 		if ($this->log)
2428 2427
 		{
2429
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2428
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2430 2429
 		}
2431 2430
 
2432 2431
 		// eg. Mozilla holiday calendars contain only a X-WR-TIMEZONE on vCalendar component
@@ -2486,16 +2485,16 @@  discard block
 block discarded – undo
2486 2485
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2487 2486
 	 * @return array|boolean			event on success, false on failure
2488 2487
 	 */
2489
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2488
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2490 2489
 	{
2491
-		unset($principalURL);	// not longer used, but required in function signature
2490
+		unset($principalURL); // not longer used, but required in function signature
2492 2491
 
2493 2492
 		if ($check_component && !is_a($component, $check_component))
2494 2493
 		{
2495 2494
 			if ($this->log)
2496 2495
 			{
2497
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2498
-					get_class($component)." found\n",3,$this->logfile);
2496
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2497
+					get_class($component)." found\n", 3, $this->logfile);
2499 2498
 			}
2500 2499
 			return false;
2501 2500
 		}
@@ -2511,12 +2510,12 @@  discard block
 block discarded – undo
2511 2510
 
2512 2511
 		$isDate = false;
2513 2512
 		$event		= array();
2514
-		$alarms		= array();
2513
+		$alarms = array();
2515 2514
 		$organizer_status = $organizer_uid = null;
2516
-		$vcardData	= array(
2515
+		$vcardData = array(
2517 2516
 			'recur_type'		=> MCAL_RECUR_NONE,
2518 2517
 			'recur_exception'	=> array(),
2519
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2518
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2520 2519
 			'public'            => 1,
2521 2520
 		);
2522 2521
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
@@ -2535,7 +2534,7 @@  discard block
 block discarded – undo
2535 2534
 						$isDate = true;
2536 2535
 					}
2537 2536
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2538
-					$vcardData['start']	= $dtstart_ts;
2537
+					$vcardData['start'] = $dtstart_ts;
2539 2538
 
2540 2539
 					// set event timezone from dtstart, if specified there
2541 2540
 					if (!empty($attributes['params']['TZID']))
@@ -2553,18 +2552,18 @@  discard block
 block discarded – undo
2553 2552
 							}
2554 2553
 							else
2555 2554
 							{
2556
-								error_log(__METHOD__ . '() unknown TZID='
2557
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2558
-									. date_default_timezone_get() . '".'.array2string($tz));
2559
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2555
+								error_log(__METHOD__.'() unknown TZID='
2556
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2557
+									. date_default_timezone_get().'".'.array2string($tz));
2558
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2560 2559
 							}
2561 2560
 						}
2562
-						catch(Exception $e)
2561
+						catch (Exception $e)
2563 2562
 						{
2564
-							error_log(__METHOD__ . '() unknown TZID='
2565
-								. $attributes['params']['TZID'] . ', defaulting to timezone "'
2566
-								. date_default_timezone_get() . '".'.$e->getMessage());
2567
-							$event['tzid'] = date_default_timezone_get();	// default to current timezone
2563
+							error_log(__METHOD__.'() unknown TZID='
2564
+								. $attributes['params']['TZID'].', defaulting to timezone "'
2565
+								. date_default_timezone_get().'".'.$e->getMessage());
2566
+							$event['tzid'] = date_default_timezone_get(); // default to current timezone
2568 2567
 						}
2569 2568
 					}
2570 2569
 					// if no timezone given and one is specified in class (never the case for CalDAV)
@@ -2588,11 +2587,11 @@  discard block
 block discarded – undo
2588 2587
 
2589 2588
 				case 'DTEND':
2590 2589
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2591
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2590
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2592 2591
 					{
2593 2592
 						$dtend_ts -= 1;
2594 2593
 					}
2595
-					$vcardData['end']	= $dtend_ts;
2594
+					$vcardData['end'] = $dtend_ts;
2596 2595
 					break;
2597 2596
 
2598 2597
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2612,7 +2611,7 @@  discard block
 block discarded – undo
2612 2611
 			if ($this->log)
2613 2612
 			{
2614 2613
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2615
-					. "() DTSTART missing!\n",3,$this->logfile);
2614
+					. "() DTSTART missing!\n", 3, $this->logfile);
2616 2615
 			}
2617 2616
 			return false; // not a valid entry
2618 2617
 		}
@@ -2631,7 +2630,7 @@  discard block
 block discarded – undo
2631 2630
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2632 2631
 					if (isset($supportedFields['whole_day']))
2633 2632
 					{
2634
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2633
+						$event['whole_day'] = (isset($attributes['value']) ?strtoupper($attributes['value']) == 'TRUE' : true);
2635 2634
 					}
2636 2635
 					break;
2637 2636
 				case 'AALARM':
@@ -2661,12 +2660,12 @@  discard block
 block discarded – undo
2661 2660
 					$vcardData['recurrence'] = $attributes['value'];
2662 2661
 					break;
2663 2662
 				case 'LOCATION':
2664
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2663
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2665 2664
 					break;
2666 2665
 				case 'RRULE':
2667
-					unset($vcardData['recur_type']);	// it wont be set by +=
2666
+					unset($vcardData['recur_type']); // it wont be set by +=
2668 2667
 					$vcardData += calendar_rrule::parseRrule($attributes['value']);
2669
-					if (!empty($vcardData['recur_enddate'])) self::check_fix_endate ($vcardData);
2668
+					if (!empty($vcardData['recur_enddate'])) self::check_fix_endate($vcardData);
2670 2669
 					break;
2671 2670
 				case 'EXDATE':	// current Horde_Icalendar returns dates, no timestamps
2672 2671
 					if ($attributes['values'])
@@ -2712,11 +2711,11 @@  discard block
 block discarded – undo
2712 2711
 						(strpos($this->productName, 'outlook') !== false
2713 2712
 							|| strpos($this->productName, 'pocket pc') !== false))
2714 2713
 					{
2715
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2714
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2716 2715
 					}
2717 2716
 					else
2718 2717
 					{
2719
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2718
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2720 2719
 					}
2721 2720
 					break;
2722 2721
 				case 'CATEGORIES':
@@ -2730,10 +2729,10 @@  discard block
 block discarded – undo
2730 2729
 					}
2731 2730
 					break;
2732 2731
 				case 'ORGANIZER':
2733
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2734
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2732
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2733
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2735 2734
 					{
2736
-						$event['organizer'] = substr($event['organizer'],7);
2735
+						$event['organizer'] = substr($event['organizer'], 7);
2737 2736
 					}
2738 2737
 					if (!empty($attributes['params']['CN']))
2739 2738
 					{
@@ -2772,19 +2771,19 @@  discard block
 block discarded – undo
2772 2771
 					}
2773 2772
 					// try parsing email and cn from attendee
2774 2773
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2775
-						$attributes['value'],$matches))
2774
+						$attributes['value'], $matches))
2776 2775
 					{
2777 2776
 						$email = $matches[1] ? $matches[1] : $matches[3];
2778
-						$cn = isset($matches[2]) ? $matches[2]: '';
2777
+						$cn = isset($matches[2]) ? $matches[2] : '';
2779 2778
 					}
2780 2779
 					elseif (!empty($attributes['value']) &&
2781 2780
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2782
-						$attributes['value'],$matches))
2781
+						$attributes['value'], $matches))
2783 2782
 					{
2784 2783
 						$cn = $matches[1];
2785 2784
 						$email = $matches[2];
2786 2785
 					}
2787
-					elseif (strpos($attributes['value'],'@') !== false)
2786
+					elseif (strpos($attributes['value'], '@') !== false)
2788 2787
 					{
2789 2788
 						$email = $attributes['value'];
2790 2789
 					}
@@ -2801,7 +2800,7 @@  discard block
 block discarded – undo
2801 2800
 						if ($this->log)
2802 2801
 						{
2803 2802
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2804
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2803
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2805 2804
 						}
2806 2805
 					}
2807 2806
 					elseif ($attributes['value'] == 'Unknown')
@@ -2819,7 +2818,7 @@  discard block
 block discarded – undo
2819 2818
 						if ($this->log)
2820 2819
 						{
2821 2820
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2822
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2821
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2823 2822
 						}
2824 2823
 					}
2825 2824
 					if (!$uid)
@@ -2836,9 +2835,9 @@  discard block
 block discarded – undo
2836 2835
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2837 2836
 										array(',', ';', ':', '\\'),
2838 2837
 										$attributes['params']['CN']);
2839
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2838
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2840 2839
 							{
2841
-								$cn = substr($cn,1,-1);
2840
+								$cn = substr($cn, 1, -1);
2842 2841
 							}
2843 2842
 							// not searching for $cn, as match can be not unique or without an email address
2844 2843
 							// --> notification will fail, better store just as email
@@ -2847,19 +2846,19 @@  discard block
 block discarded – undo
2847 2846
 						if ($this->log)
2848 2847
 						{
2849 2848
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2850
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2849
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2851 2850
 						}
2852 2851
 
2853 2852
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2854
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2853
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2855 2854
 						{
2856 2855
 							// we found a group
2857 2856
 							if ($this->log)
2858 2857
 							{
2859 2858
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2860
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2859
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2861 2860
 							}
2862
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2861
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2863 2862
 							{
2864 2863
 								//Horde::logMessage("vevent2egw: group participant $uid",
2865 2864
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2873,7 +2872,7 @@  discard block
 block discarded – undo
2873 2872
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2874 2873
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2875 2874
 										$vcardData['participants'][$this->user] =
2876
-											calendar_so::combine_status($status,$quantity,$role);
2875
+											calendar_so::combine_status($status, $quantity, $role);
2877 2876
 									}
2878 2877
 								}
2879 2878
 								$status = 'U'; // keep the group
@@ -2882,36 +2881,36 @@  discard block
 block discarded – undo
2882 2881
 						}
2883 2882
 						elseif (empty($searcharray))
2884 2883
 						{
2885
-							continue 2;	// participants without email AND CN --> ignore it
2884
+							continue 2; // participants without email AND CN --> ignore it
2886 2885
 						}
2887 2886
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2888
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2887
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2889 2888
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2890
-							'','',false,'OR')))
2889
+							'', '', false, 'OR')))
2891 2890
 						{
2892 2891
 							// found an addressbook entry
2893 2892
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2894 2893
 							if ($this->log)
2895 2894
 							{
2896 2895
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2897
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2896
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2898 2897
 							}
2899 2898
 						}
2900 2899
 						else
2901 2900
 						{
2902 2901
 							if (!$email)
2903 2902
 							{
2904
-								$email = '[email protected]';	// set dummy email to store the CN
2903
+								$email = '[email protected]'; // set dummy email to store the CN
2905 2904
 							}
2906
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2905
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2907 2906
 							if ($this->log)
2908 2907
 							{
2909 2908
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2910
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2909
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2911 2910
 							}
2912 2911
 						}
2913 2912
 					}
2914
-					switch($attributes['name'])
2913
+					switch ($attributes['name'])
2915 2914
 					{
2916 2915
 						case 'ATTENDEE':
2917 2916
 							if (!isset($attributes['params']['ROLE']) &&
@@ -2925,7 +2924,7 @@  discard block
 block discarded – undo
2925 2924
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
2926 2925
 								// as this is currently the only way to store an external organizer and send him iMip responses
2927 2926
 								$q = $r = null;
2928
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
2927
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
2929 2928
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
2930 2929
 								{
2931 2930
 									$role = 'CHAIR';
@@ -2943,7 +2942,7 @@  discard block
 block discarded – undo
2943 2942
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2944 2943
 										$component->getAttribute('ORGANIZER');
2945 2944
 								}
2946
-								catch(Horde_Icalendar_Exception $e)
2945
+								catch (Horde_Icalendar_Exception $e)
2947 2946
 								{
2948 2947
 									// we can store the ORGANIZER as event owner
2949 2948
 									$event['owner'] = $uid;
@@ -3002,7 +3001,7 @@  discard block
 block discarded – undo
3002 3001
 					break;
3003 3002
 
3004 3003
 				case 'ATTACH':
3005
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3004
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3006 3005
 					// fall throught to store external attachment url
3007 3006
 				default:	// X- attribute or other by EGroupware unsupported property
3008 3007
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3080,7 +3079,7 @@  discard block
 block discarded – undo
3080 3079
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3081 3080
 					{
3082 3081
 						$event['reference'] = 0;
3083
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3082
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3084 3083
 						{
3085 3084
 							if (isset($vcardData[$r]))
3086 3085
 							{
@@ -3103,12 +3102,12 @@  discard block
 block discarded – undo
3103 3102
 			// reset recure_enddate to 00:00:00 on the last day
3104 3103
 			$rriter = calendar_rrule::event2rrule($event, false);
3105 3104
 			$last = $rriter->normalize_enddate();
3106
-			if(!is_object($last))
3105
+			if (!is_object($last))
3107 3106
 			{
3108
-				if($this->log)
3107
+				if ($this->log)
3109 3108
 				{
3110
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3111
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3109
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3110
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3112 3111
 				}
3113 3112
 				return false;
3114 3113
 			}
@@ -3117,16 +3116,16 @@  discard block
 block discarded – undo
3117 3116
 			$event['recur_enddate'] = Api\DateTime::to($last, 'server');
3118 3117
 		}
3119 3118
 		// translate COUNT into an enddate, as we only store enddates
3120
-		elseif($event['recur_count'])
3119
+		elseif ($event['recur_count'])
3121 3120
 		{
3122 3121
 			$rriter = calendar_rrule::event2rrule($event, false);
3123 3122
 			$last = $rriter->count2date($event['recur_count']);
3124
-			if(!is_object($last))
3123
+			if (!is_object($last))
3125 3124
 			{
3126
-				if($this->log)
3125
+				if ($this->log)
3127 3126
 				{
3128 3127
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3129
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3128
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3130 3129
 				}
3131 3130
 				return false;
3132 3131
 			}
@@ -3140,7 +3139,7 @@  discard block
 block discarded – undo
3140 3139
 			if ($this->productManufacturer == 'groupdav' && $container &&
3141 3140
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3142 3141
 			{
3143
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3142
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3144 3143
 			}
3145 3144
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3146 3145
 		}
@@ -3161,15 +3160,15 @@  discard block
 block discarded – undo
3161 3160
 
3162 3161
 		if ($this->log)
3163 3162
 		{
3164
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3165
-				array2string($event)."\n",3,$this->logfile);
3163
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3164
+				array2string($event)."\n", 3, $this->logfile);
3166 3165
 		}
3167 3166
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3168 3167
 	    //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3169 3168
 		return $event;
3170 3169
 	}
3171 3170
 
3172
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3171
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3173 3172
 	{
3174 3173
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3175 3174
 		{
@@ -3190,8 +3189,8 @@  discard block
 block discarded – undo
3190 3189
 			}
3191 3190
 			if ($this->log)
3192 3191
 			{
3193
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3194
-					array2string($events)."\n",3,$this->logfile);
3192
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3193
+					array2string($events)."\n", 3, $this->logfile);
3195 3194
 			}
3196 3195
 		}
3197 3196
 		return array();
@@ -3230,23 +3229,23 @@  discard block
 block discarded – undo
3230 3229
 	 * @param array $extra =null extra attributes to add
3231 3230
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3232 3231
 	 */
3233
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3232
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3234 3233
 	{
3235
-		if (!$start) $start = time();	// default now
3236
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3234
+		if (!$start) $start = time(); // default now
3235
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3237 3236
 
3238 3237
 		$vcal = new Horde_Icalendar;
3239
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3238
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3240 3239
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3241
-		$vcal->setAttribute('VERSION','2.0');
3242
-		$vcal->setAttribute('METHOD',$method);
3240
+		$vcal->setAttribute('VERSION', '2.0');
3241
+		$vcal->setAttribute('METHOD', $method);
3243 3242
 
3244
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3243
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3245 3244
 
3246 3245
 		$attributes = array(
3247 3246
 			'DTSTAMP' => time(),
3248
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3249
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3247
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3248
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3250 3249
 		);
3251 3250
 		if (!$utc)
3252 3251
 		{
@@ -3257,9 +3256,9 @@  discard block
 block discarded – undo
3257 3256
 		}
3258 3257
 		if (is_null($extra)) $extra = array(
3259 3258
 			'URL' => $this->freebusy_url($user),
3260
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3259
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3261 3260
 		);
3262
-		foreach($attributes+$extra as $attr => $value)
3261
+		foreach ($attributes + $extra as $attr => $value)
3263 3262
 		{
3264 3263
 			$vfreebusy->setAttribute($attr, $value);
3265 3264
 		}
@@ -3291,22 +3290,22 @@  discard block
 block discarded – undo
3291 3290
 
3292 3291
 				$fbdata[$fbtype][] = $event;
3293 3292
 			}
3294
-			foreach($fbdata as $fbtype => $events)
3293
+			foreach ($fbdata as $fbtype => $events)
3295 3294
 			{
3296
-				foreach($this->aggregate_periods($events, $start, $end) as $event)
3295
+				foreach ($this->aggregate_periods($events, $start, $end) as $event)
3297 3296
 				{
3298 3297
 					if ($utc)
3299 3298
 					{
3300
-						$vfreebusy->setAttribute('FREEBUSY',array(array(
3299
+						$vfreebusy->setAttribute('FREEBUSY', array(array(
3301 3300
 							'start' => $event['start'],
3302 3301
 							'end' => $event['end'],
3303 3302
 						)), array('FBTYPE' => $fbtype));
3304 3303
 					}
3305 3304
 					else
3306 3305
 					{
3307
-						$vfreebusy->setAttribute('FREEBUSY',array(array(
3308
-							'start' => date('Ymd\THis',$event['start']),
3309
-							'end' => date('Ymd\THis',$event['end']),
3306
+						$vfreebusy->setAttribute('FREEBUSY', array(array(
3307
+							'start' => date('Ymd\THis', $event['start']),
3308
+							'end' => date('Ymd\THis', $event['end']),
3310 3309
 						)), array('FBTYPE' => $fbtype));
3311 3310
 					}
3312 3311
 				}
@@ -3336,7 +3335,7 @@  discard block
 block discarded – undo
3336 3335
 		});
3337 3336
 
3338 3337
 		$fbdata = array();
3339
-		foreach($events as $event)
3338
+		foreach ($events as $event)
3340 3339
 		{
3341 3340
 			error_log(__METHOD__."(..., $start, $end) event[start]=$event[start], event[end]=$event[end], fbdata=".array2string($fbdata));
3342 3341
 			if ($event['end'] <= $start || $event['start'] >= $end) continue;
@@ -3349,7 +3348,7 @@  discard block
 block discarded – undo
3349 3348
 				);
3350 3349
 				continue;
3351 3350
 			}
3352
-			$last =& $fbdata[count($fbdata)-1];
3351
+			$last = & $fbdata[count($fbdata) - 1];
3353 3352
 
3354 3353
 			if ($last['end'] >= $event['start'])
3355 3354
 			{
@@ -3366,7 +3365,7 @@  discard block
 block discarded – undo
3366 3365
 				);
3367 3366
 			}
3368 3367
 		}
3369
-		$last =& $fbdata[count($fbdata)-1];
3368
+		$last = & $fbdata[count($fbdata) - 1];
3370 3369
 
3371 3370
 		if ($last['end'] > $end) $last['end'] = $end;
3372 3371
 
Please login to merge, or discard this patch.
Braces   +305 added lines, -77 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 	function __construct(&$_clientProperties = array())
184 184
 	{
185 185
 		parent::__construct();
186
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
186
+		if ($this->log)
187
+		{
188
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
189
+		}
187 190
 		$this->clientProperties = $_clientProperties;
188 191
 		$this->vCalendar = new Horde_Icalendar;
189 192
 		$this->addressbook = new Api\Contacts;
@@ -232,10 +235,14 @@  discard block
 block discarded – undo
232 235
 			'ATTACH'        => 'attachments',
233 236
 		);
234 237
 
235
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
238
+		if (!is_array($this->supportedFields))
239
+		{
240
+			$this->setSupportedFields();
241
+		}
236 242
 
237 243
 		if ($this->productManufacturer == '' )
238
-		{	// syncevolution is broken
244
+		{
245
+// syncevolution is broken
239 246
 			$version = '2.0';
240 247
 		}
241 248
 
@@ -243,10 +250,16 @@  discard block
 block discarded – undo
243 250
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
244 251
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
245 252
 		$vcal->setAttribute('VERSION', $version);
246
-		if ($method) $vcal->setAttribute('METHOD', $method);
253
+		if ($method)
254
+		{
255
+			$vcal->setAttribute('METHOD', $method);
256
+		}
247 257
 		$events_exported = false;
248 258
 
249
-		if (!is_array($events)) $events = array($events);
259
+		if (!is_array($events))
260
+		{
261
+			$events = array($events);
262
+		}
250 263
 
251 264
 		$vtimezones_added = array();
252 265
 		foreach ($events as $event)
@@ -314,13 +327,19 @@  discard block
 block discarded – undo
314 327
 				}
315 328
 				catch (Exception $e) {
316 329
 					// log unknown timezones
317
-					if (!empty($event['tzid'])) _egw_log_exception($e);
330
+					if (!empty($event['tzid']))
331
+					{
332
+						_egw_log_exception($e);
333
+					}
318 334
 					// default for no timezone and unkown to user timezone
319 335
 					self::$tz_cache[$event['tzid']] = Api\DateTime::$user_timezone;
320 336
 				}
321 337
 			}
322 338
 
323
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
339
+			if ($this->so->isWholeDay($event))
340
+			{
341
+				$event['whole_day'] = true;
342
+			}
324 343
 
325 344
 			if ($this->log)
326 345
 			{
@@ -331,7 +350,10 @@  discard block
 block discarded – undo
331 350
 
332 351
 			if ($recurrence)
333 352
 			{
334
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
353
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
354
+				{
355
+					continue;
356
+				}
335 357
 
336 358
 				if (!isset($this->supportedFields['participants']))
337 359
 				{
@@ -388,7 +410,8 @@  discard block
 block discarded – undo
388 410
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
389 411
 			{
390 412
 				// Append UID to DESCRIPTION
391
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
413
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
414
+				{
392 415
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
393 416
 				}
394 417
 			}
@@ -448,11 +471,21 @@  discard block
 block discarded – undo
448 471
 							$quantity = $role = null;
449 472
 							calendar_so::split_status($status, $quantity, $role);
450 473
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
451
-							if (count($event['participants']) == 1 && $event['owner'] == $uid && $uid == $this->user) continue;
474
+							if (count($event['participants']) == 1 && $event['owner'] == $uid && $uid == $this->user)
475
+							{
476
+								continue;
477
+							}
452 478
 
453
-							if (!($info = $this->resource_info($uid))) continue;
479
+							if (!($info = $this->resource_info($uid)))
480
+							{
481
+								continue;
482
+							}
454 483
 
455
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
484
+							if (in_array($status, array('X','E')))
485
+							{
486
+								continue;
487
+							}
488
+							// dont include deleted participants
456 489
 
457 490
 							if ($this->log)
458 491
 							{
@@ -531,16 +564,34 @@  discard block
 block discarded – undo
531 564
 							}
532 565
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
533 566
 							$options = array();
534
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
535
-							if (!empty($role)) $options['ROLE'] = $role;
536
-							if (!empty($status)) $options['PARTSTAT'] = $status;
537
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
538
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
567
+							if (!empty($participantCN))
568
+							{
569
+								$options['CN'] = $participantCN;
570
+							}
571
+							if (!empty($role))
572
+							{
573
+								$options['ROLE'] = $role;
574
+							}
575
+							if (!empty($status))
576
+							{
577
+								$options['PARTSTAT'] = $status;
578
+							}
579
+							if (!empty($cutype))
580
+							{
581
+								$options['CUTYPE'] = $cutype;
582
+							}
583
+							if (!empty($rsvp))
584
+							{
585
+								$options['RSVP'] = $rsvp;
586
+							}
539 587
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
540 588
 							{
541 589
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
542 590
 							}
543
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
591
+							if ($info['type'] != 'e')
592
+							{
593
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
594
+							}
544 595
 							if ($quantity > 1)
545 596
 							{
546 597
 								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
@@ -552,7 +603,11 @@  discard block
 block discarded – undo
552 603
 						break;
553 604
 
554 605
 					case 'CLASS':
555
-						if ($event['public']) continue 2;	// public is default, no need to export, fails CalDAVTester if added as default
606
+						if ($event['public'])
607
+						{
608
+							continue 2;
609
+						}
610
+						// public is default, no need to export, fails CalDAVTester if added as default
556 611
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
557 612
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
558 613
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -601,9 +656,12 @@  discard block
 block discarded – undo
601 656
 						{
602 657
 							// Hack for CalDAVTester to export duration instead of endtime
603 658
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
604
-								$attributes['duration'] = $event['end'] - $event['start'];
605
-							else
606
-								$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
659
+							{
660
+															$attributes['duration'] = $event['end'] - $event['start'];
661
+							}
662
+							else {
663
+															$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
664
+							}
607 665
 						}
608 666
 						else
609 667
 						{
@@ -623,7 +681,11 @@  discard block
 block discarded – undo
623 681
 						break;
624 682
 
625 683
 					case 'RRULE':
626
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
684
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
685
+						{
686
+							break;
687
+						}
688
+						// no recuring event
627 689
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
628 690
 						$rrule = $rriter->generate_rrule($version);
629 691
 						if ($event['recur_enddate'])
@@ -665,7 +727,10 @@  discard block
 block discarded – undo
665 727
 						break;
666 728
 
667 729
 					case 'EXDATE':
668
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
730
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
731
+						{
732
+							break;
733
+						}
669 734
 						if (!empty($event['recur_exception']))
670 735
 						{
671 736
 							if (empty($event['whole_day']))
@@ -693,14 +758,21 @@  discard block
 block discarded – undo
693 758
 									);
694 759
 								}
695 760
 								$event['recur_exception'] = $days;
696
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
761
+								if ($version != '1.0')
762
+								{
763
+									$parameters['EXDATE']['VALUE'] = 'DATE';
764
+								}
697 765
 							}
698 766
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
699 767
 						}
700 768
 						break;
701 769
 
702 770
 					case 'PRIORITY':
703
-						if (!$event['priority']) continue 2;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
771
+						if (!$event['priority'])
772
+						{
773
+							continue 2;
774
+						}
775
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
704 776
 						if ($this->productManufacturer == 'funambol' &&
705 777
 							(strpos($this->productName, 'outlook') !== false
706 778
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -714,7 +786,11 @@  discard block
 block discarded – undo
714 786
 						break;
715 787
 
716 788
 					case 'TRANSP':
717
-						if (!$event['non_blocking']) continue 2;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
789
+						if (!$event['non_blocking'])
790
+						{
791
+							continue 2;
792
+						}
793
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
718 794
 						if ($version == '1.0')
719 795
 						{
720 796
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -771,7 +847,11 @@  discard block
 block discarded – undo
771 847
 						elseif ($event['recurrence'] && $event['reference'])
772 848
 						{
773 849
 							// $event['reference'] is a calendar_id, not a timestamp
774
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
850
+							if (!($revent = $this->read($event['reference'])))
851
+							{
852
+								break;
853
+							}
854
+							// referenced event does not exist
775 855
 
776 856
 							if (empty($revent['whole_day']))
777 857
 							{
@@ -865,7 +945,10 @@  discard block
 block discarded – undo
865 945
 							if (count($attr) === 1 && !empty($attr['gzcompress']))
866 946
 							{
867 947
 								$attr = json_decode(gzuncompress(base64_decode($attr['gzcompress'])), true);
868
-								if (!is_array($attr)) continue;
948
+								if (!is_array($attr))
949
+								{
950
+									continue;
951
+								}
869 952
 							}
870 953
 							$vevent->setAttribute(substr($name, 2), $attr['value'], $attr['params'], true, $attr['values']);
871 954
 						}
@@ -906,7 +989,10 @@  discard block
 block discarded – undo
906 989
 			foreach ((array)$event['alarm'] as $alarmData)
907 990
 			{
908 991
 				// skip over alarms that don't have the minimum required info
909
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
992
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
993
+				{
994
+					continue;
995
+				}
910 996
 
911 997
 				// skip alarms not being set for all users and alarms owned by other users
912 998
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -923,7 +1009,10 @@  discard block
 block discarded – undo
923 1009
 
924 1010
 				if ($version == '1.0')
925 1011
 				{
926
-					if ($event['title']) $description = $event['title'];
1012
+					if ($event['title'])
1013
+					{
1014
+						$description = $event['title'];
1015
+					}
927 1016
 					if ($description)
928 1017
 					{
929 1018
 						$values['DALARM']['snooze_time'] = '';
@@ -943,7 +1032,10 @@  discard block
 block discarded – undo
943 1032
 					// VCalendar 2.0 / RFC 2445
944 1033
 
945 1034
 					// RFC requires DESCRIPTION for DISPLAY
946
-					if (!$event['title'] && !$description) $description = 'Alarm';
1035
+					if (!$event['title'] && !$description)
1036
+					{
1037
+						$description = 'Alarm';
1038
+					}
947 1039
 
948 1040
 					/* Disabling for now
949 1041
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1078,7 +1170,7 @@  discard block
 block discarded – undo
1078 1170
 		// hack to fix iCalendar exporting EXDATE always postfixed with a Z
1079 1171
 		// EXDATE can have multiple values and therefore be folded into multiple lines
1080 1172
 		return preg_replace_callback("/\nEXDATE;TZID=[^:]+:[0-9TZ \n,]+/", function($matches)
1081
-			{
1173
+		{
1082 1174
 				return preg_replace('/([0-9 ])Z/', '$1', $matches[0]);
1083 1175
 			}, $retval);
1084 1176
 	}
@@ -1140,13 +1232,20 @@  discard block
 block discarded – undo
1140 1232
 		$this->events_imported = 0;
1141 1233
 		$replace = $delete_exceptions= false;
1142 1234
 
1143
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1235
+		if (!is_array($this->supportedFields))
1236
+		{
1237
+			$this->setSupportedFields();
1238
+		}
1144 1239
 
1145 1240
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1146 1241
 		{
1147 1242
 			return false;
1148 1243
 		}
1149
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1244
+		if (!is_array($events))
1245
+		{
1246
+			$cal_id = -1;
1247
+		}
1248
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1150 1249
 
1151 1250
 		if ($cal_id > 0)
1152 1251
 		{
@@ -1154,8 +1253,14 @@  discard block
 block discarded – undo
1154 1253
 			{
1155 1254
 				$replace = $recur_date == 0;
1156 1255
 				$events[0]['id'] = $cal_id;
1157
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1158
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1256
+				if (!is_null($etag))
1257
+				{
1258
+					$events[0]['etag'] = (int) $etag;
1259
+				}
1260
+				if ($recur_date)
1261
+				{
1262
+					$events[0]['recurrence'] = $recur_date;
1263
+				}
1159 1264
 			}
1160 1265
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1161 1266
 					($eventId = array_shift($foundEvent)) &&
@@ -1163,7 +1268,10 @@  discard block
 block discarded – undo
1163 1268
 			{
1164 1269
 				foreach ($events as $k => $event)
1165 1270
 				{
1166
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1271
+					if (!isset($event['uid']))
1272
+					{
1273
+						$events[$k]['uid'] = $egwEvent['uid'];
1274
+					}
1167 1275
 				}
1168 1276
 			}
1169 1277
 		}
@@ -1193,7 +1301,11 @@  discard block
 block discarded – undo
1193 1301
 		$msg = null;
1194 1302
 		foreach ($events as $event)
1195 1303
 		{
1196
-			if (!is_array($event)) continue; // the iterator may return false
1304
+			if (!is_array($event))
1305
+			{
1306
+				continue;
1307
+			}
1308
+			// the iterator may return false
1197 1309
 
1198 1310
 			// Run event through callback
1199 1311
 			if($this->event_callback && is_callable($this->event_callback))
@@ -1206,7 +1318,10 @@  discard block
 block discarded – undo
1206 1318
 			}
1207 1319
 			++$this->events_imported;
1208 1320
 
1209
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1321
+			if ($this->so->isWholeDay($event))
1322
+			{
1323
+				$event['whole_day'] = true;
1324
+			}
1210 1325
 			if (is_array($event['category']))
1211 1326
 			{
1212 1327
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1243,7 +1358,10 @@  discard block
 block discarded – undo
1243 1358
 						}
1244 1359
 						else
1245 1360
 						{
1246
-							if (!($exception = $this->read($id))) continue;
1361
+							if (!($exception = $this->read($id)))
1362
+							{
1363
+								continue;
1364
+							}
1247 1365
 							$exception['uid'] = Api\CalDAV::generate_uid('calendar', $id);
1248 1366
 							$exception['reference'] = $exception['recurrence'] = 0;
1249 1367
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1343,7 +1461,10 @@  discard block
 block discarded – undo
1343 1461
 								break;
1344 1462
 
1345 1463
 							default:
1346
-								if (!empty($value)) $event[$key] = $value;
1464
+								if (!empty($value))
1465
+								{
1466
+									$event[$key] = $value;
1467
+								}
1347 1468
 						}
1348 1469
 					}
1349 1470
 				}
@@ -1441,7 +1562,10 @@  discard block
 block discarded – undo
1441 1562
 			else // common adjustments for new events
1442 1563
 			{
1443 1564
 				unset($event['id']);
1444
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1565
+				if ($caldav_name)
1566
+				{
1567
+					$event['caldav_name'] = $caldav_name;
1568
+				}
1445 1569
 				// set non blocking all day depending on the user setting
1446 1570
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1447 1571
 				{
@@ -1489,7 +1613,10 @@  discard block
 block discarded – undo
1489 1613
 					|| !isset($event['participants'][$event['owner']]))
1490 1614
 				{
1491 1615
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1492
-					if (!is_array($event['participants'])) $event['participants'] = array();
1616
+					if (!is_array($event['participants']))
1617
+					{
1618
+						$event['participants'] = array();
1619
+					}
1493 1620
 					$event['participants'][$event['owner']] = $status;
1494 1621
 				}
1495 1622
 				else
@@ -1642,7 +1769,10 @@  discard block
 block discarded – undo
1642 1769
 								$occurence = $exception = false;
1643 1770
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1644 1771
 								{
1645
-									if ($exception > $event['start']) break;
1772
+									if ($exception > $event['start'])
1773
+									{
1774
+										break;
1775
+									}
1646 1776
 									$occurence = $exception;
1647 1777
 								}
1648 1778
 								if (!$occurence)
@@ -1732,12 +1862,15 @@  discard block
 block discarded – undo
1732 1862
 					case 'SERIES-MASTER':
1733 1863
 					case 'SERIES-EXCEPTION':
1734 1864
 					case 'SERIES-EXCEPTION-PROPAGATE':
1735
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1865
+						if (is_array($event_info['stored_event']))
1866
+						{
1867
+							// status update requires a stored event
1736 1868
 						{
1737 1869
 							if ($event_info['acl_edit'])
1738 1870
 							{
1739 1871
 								// update all participants if we have the right to do that
1740 1872
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1873
+						}
1741 1874
 							}
1742 1875
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1743 1876
 							{
@@ -1749,9 +1882,12 @@  discard block
 block discarded – undo
1749 1882
 						break;
1750 1883
 
1751 1884
 					case 'SERIES-PSEUDO-EXCEPTION':
1752
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1885
+						if (is_array($event_info['master_event']))
1886
+						{
1887
+							// status update requires a stored master event
1753 1888
 						{
1754 1889
 							$recurrence = $this->date2usertime($event['recurrence']);
1890
+						}
1755 1891
 							if ($event_info['acl_edit'])
1756 1892
 							{
1757 1893
 								// update all participants if we have the right to do that
@@ -1859,7 +1995,10 @@  discard block
 block discarded – undo
1859 1995
 	 */
1860 1996
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1861 1997
 	{
1862
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1998
+		if ($this->debug)
1999
+		{
2000
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
2001
+		}
1863 2002
 		$modified = 0;
1864 2003
 		foreach($event['alarm'] as &$alarm)
1865 2004
 		{
@@ -1881,29 +2020,56 @@  discard block
 block discarded – undo
1881 2020
 					break;
1882 2021
 				}
1883 2022
 			}
1884
-			if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2023
+			if ($this->debug)
2024
+			{
2025
+				error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) processing ".($found?'existing':'new')." alarm ".array2string($alarm));
2026
+			}
1885 2027
 			if (!empty($alarm['attrs']['X-LIC-ERROR']))
1886 2028
 			{
1887
-				if ($this->debug) error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2029
+				if ($this->debug)
2030
+				{
2031
+					error_log(__METHOD__."($event[title] (#$event[id]), ..., $user) ignored X-LIC-ERROR=".array2string($alarm['X-LIC-ERROR']));
2032
+				}
1888 2033
 				unset($alarm['attrs']['X-LIC-ERROR']);
1889 2034
 			}
1890 2035
 			// alarm not found --> add it
1891 2036
 			if (!$found)
1892 2037
 			{
1893 2038
 				$alarm['owner'] = $user;
1894
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1895
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1896
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1897
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
2039
+				if (!isset($alarm['time']))
2040
+				{
2041
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2042
+				}
2043
+				if ($alarm['time'] < time())
2044
+				{
2045
+					calendar_so::shift_alarm($event, $alarm);
2046
+				}
2047
+				if ($this->debug)
2048
+				{
2049
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
2050
+				}
2051
+				if ($event['id'])
2052
+				{
2053
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
2054
+				}
1898 2055
 				++$modified;
1899 2056
 			}
1900 2057
 			// existing alarm --> update it
1901 2058
 			else
1902 2059
 			{
1903
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1904
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
2060
+				if (!isset($alarm['time']))
2061
+				{
2062
+					$alarm['time'] = $event['start'] - $alarm['offset'];
2063
+				}
2064
+				if ($alarm['time'] < time())
2065
+				{
2066
+					calendar_so::shift_alarm($event, $alarm);
2067
+				}
1905 2068
 				$alarm = array_merge($old_alarm, $alarm);
1906
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2069
+				if ($this->debug)
2070
+				{
2071
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
2072
+				}
1907 2073
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1908 2074
 				++$modified;
1909 2075
 			}
@@ -1917,7 +2083,10 @@  discard block
 block discarded – undo
1917 2083
 				unset($old_alarm[$id]);
1918 2084
 				continue;
1919 2085
 			}
1920
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2086
+			if ($this->debug)
2087
+			{
2088
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
2089
+			}
1921 2090
 			$this->delete_alarm($id);
1922 2091
 			++$modified;
1923 2092
 		}
@@ -2336,7 +2505,10 @@  discard block
 block discarded – undo
2336 2505
 				array2string($_vcalData)."\n",3,$this->logfile);
2337 2506
 		}
2338 2507
 
2339
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2508
+		if (!is_array($this->supportedFields))
2509
+		{
2510
+			$this->setSupportedFields();
2511
+		}
2340 2512
 
2341 2513
 		// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2342 2514
 		if (is_resource($_vcalData))
@@ -2666,7 +2838,10 @@  discard block
 block discarded – undo
2666 2838
 				case 'RRULE':
2667 2839
 					unset($vcardData['recur_type']);	// it wont be set by +=
2668 2840
 					$vcardData += calendar_rrule::parseRrule($attributes['value']);
2669
-					if (!empty($vcardData['recur_enddate'])) self::check_fix_endate ($vcardData);
2841
+					if (!empty($vcardData['recur_enddate']))
2842
+					{
2843
+						self::check_fix_endate ($vcardData);
2844
+					}
2670 2845
 					break;
2671 2846
 				case 'EXDATE':	// current Horde_Icalendar returns dates, no timestamps
2672 2847
 					if ($attributes['values'])
@@ -2750,7 +2925,10 @@  discard block
 block discarded – undo
2750 2925
 					if (isset($attributes['params']['STATUS']))
2751 2926
 					{
2752 2927
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2753
-						if (empty($status)) $status = 'X';
2928
+						if (empty($status))
2929
+						{
2930
+							$status = 'X';
2931
+						}
2754 2932
 					}
2755 2933
 					else
2756 2934
 					{
@@ -2810,7 +2988,10 @@  discard block
 block discarded – undo
2810 2988
 							$uid = $this->user;
2811 2989
 					}
2812 2990
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2813
-					if (!$uid) $uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
2991
+					if (!$uid)
2992
+					{
2993
+						$uid = Api\CalDAV\Principals::url2uid($attributes['value'], null, $cn);
2994
+					}
2814 2995
 
2815 2996
 					// try to find an email address
2816 2997
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2878,7 +3059,10 @@  discard block
 block discarded – undo
2878 3059
 								}
2879 3060
 								$status = 'U'; // keep the group
2880 3061
 							}
2881
-							else continue 2; // can't find this group
3062
+							else {
3063
+								continue 2;
3064
+							}
3065
+							// can't find this group
2882 3066
 						}
2883 3067
 						elseif (empty($searcharray))
2884 3068
 						{
@@ -2941,7 +3125,9 @@  discard block
 block discarded – undo
2941 3125
 
2942 3126
 								try {
2943 3127
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2944
-										$component->getAttribute('ORGANIZER');
3128
+									{
3129
+																			$component->getAttribute('ORGANIZER');
3130
+									}
2945 3131
 								}
2946 3132
 								catch(Horde_Icalendar_Exception $e)
2947 3133
 								{
@@ -2981,7 +3167,10 @@  discard block
 block discarded – undo
2981 3167
 					}
2982 3168
 					break;
2983 3169
 				case 'CREATED':		// will be written direct to the event
2984
-					if ($event['modified']) break;
3170
+					if ($event['modified'])
3171
+					{
3172
+						break;
3173
+					}
2985 3174
 					// fall through
2986 3175
 				case 'LAST-MODIFIED':	// will be written direct to the event
2987 3176
 					$event['modified'] = $attributes['value'];
@@ -3002,7 +3191,11 @@  discard block
 block discarded – undo
3002 3191
 					break;
3003 3192
 
3004 3193
 				case 'ATTACH':
3005
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3194
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3195
+					{
3196
+						break;
3197
+					}
3198
+					// handeled by managed attachment code
3006 3199
 					// fall throught to store external attachment url
3007 3200
 				default:	// X- attribute or other by EGroupware unsupported property
3008 3201
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3153,7 +3346,10 @@  discard block
 block discarded – undo
3153 3346
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3154 3347
 		}
3155 3348
 
3156
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3349
+		if ($this->calendarOwner)
3350
+		{
3351
+			$event['owner'] = $this->calendarOwner;
3352
+		}
3157 3353
 
3158 3354
 		// parsing ATTACH attributes for managed attachments
3159 3355
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3179,7 +3375,10 @@  discard block
 block discarded – undo
3179 3375
 				$filter = $relax ? 'relax' : 'check';
3180 3376
 				$event = array_shift($events);
3181 3377
 				$eventId = -1;
3182
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3378
+				if ($this->so->isWholeDay($event))
3379
+				{
3380
+					$event['whole_day'] = true;
3381
+				}
3183 3382
 				if ($contentID)
3184 3383
 				{
3185 3384
 					$parts = preg_split('/:/', $contentID);
@@ -3232,8 +3431,16 @@  discard block
 block discarded – undo
3232 3431
 	 */
3233 3432
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3234 3433
 	{
3235
-		if (!$start) $start = time();	// default now
3236
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3434
+		if (!$start)
3435
+		{
3436
+			$start = time();
3437
+		}
3438
+		// default now
3439
+		if (!$end)
3440
+		{
3441
+			$end = time() + 100*DAY_s;
3442
+		}
3443
+		// default next 100 days
3237 3444
 
3238 3445
 		$vcal = new Horde_Icalendar;
3239 3446
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3255,10 +3462,13 @@  discard block
 block discarded – undo
3255 3462
 				$attributes[$attr] = date('Ymd\THis', $value);
3256 3463
 			}
3257 3464
 		}
3258
-		if (is_null($extra)) $extra = array(
3465
+		if (is_null($extra))
3466
+		{
3467
+			$extra = array(
3259 3468
 			'URL' => $this->freebusy_url($user),
3260 3469
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3261 3470
 		);
3471
+		}
3262 3472
 		foreach($attributes+$extra as $attr => $value)
3263 3473
 		{
3264 3474
 			$vfreebusy->setAttribute($attr, $value);
@@ -3276,18 +3486,30 @@  discard block
 block discarded – undo
3276 3486
 
3277 3487
 			foreach ($events as $event)
3278 3488
 			{
3279
-				if ($event['non_blocking']) continue;
3280
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3489
+				if ($event['non_blocking'])
3490
+				{
3491
+					continue;
3492
+				}
3493
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3494
+				{
3495
+					continue;
3496
+				}
3281 3497
 				$status = $event['participants'][$user];
3282 3498
 				$quantity = $role = null;
3283 3499
 				calendar_so::split_status($status, $quantity, $role);
3284
-				if ($status == 'R' || $role == 'NON-PARTICIPANT') continue;
3500
+				if ($status == 'R' || $role == 'NON-PARTICIPANT')
3501
+				{
3502
+					continue;
3503
+				}
3285 3504
 
3286 3505
 				$fbtype = $status == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3287 3506
 
3288 3507
 				// hack to fix end-time to be non-inclusive
3289 3508
 				// all-day events end in our data-model at 23:59:59 (of given TZ)
3290
-				if (date('is', $event['end']) == '5959') ++$event['end'];
3509
+				if (date('is', $event['end']) == '5959')
3510
+				{
3511
+					++$event['end'];
3512
+				}
3291 3513
 
3292 3514
 				$fbdata[$fbtype][] = $event;
3293 3515
 			}
@@ -3339,7 +3561,10 @@  discard block
 block discarded – undo
3339 3561
 		foreach($events as $event)
3340 3562
 		{
3341 3563
 			error_log(__METHOD__."(..., $start, $end) event[start]=$event[start], event[end]=$event[end], fbdata=".array2string($fbdata));
3342
-			if ($event['end'] <= $start || $event['start'] >= $end) continue;
3564
+			if ($event['end'] <= $start || $event['start'] >= $end)
3565
+			{
3566
+				continue;
3567
+			}
3343 3568
 
3344 3569
 			if (!$fbdata)
3345 3570
 			{
@@ -3368,7 +3593,10 @@  discard block
 block discarded – undo
3368 3593
 		}
3369 3594
 		$last =& $fbdata[count($fbdata)-1];
3370 3595
 
3371
-		if ($last['end'] > $end) $last['end'] = $end;
3596
+		if ($last['end'] > $end)
3597
+		{
3598
+			$last['end'] = $end;
3599
+		}
3372 3600
 
3373 3601
 		error_log(__METHOD__."(..., $start, $end) returning ".array2string($fbdata));
3374 3602
 		return $fbdata;
Please login to merge, or discard this patch.