@@ -265,7 +265,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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:'); |
@@ -183,7 +183,10 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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; |