@@ -15,10 +15,13 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Link; |
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | -if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
|
| 18 | +if (!defined('ACL_TYPE_IDENTIFER')) |
|
| 19 | +{ |
|
| 20 | + // used to mark ACL-values for the debug_message methode |
|
| 19 | 21 | { |
| 20 | 22 | define('ACL_TYPE_IDENTIFER','***ACL***'); |
| 21 | 23 | } |
| 24 | +} |
|
| 22 | 25 | |
| 23 | 26 | define('HOUR_s',60*60); |
| 24 | 27 | define('DAY_s',24*HOUR_s); |
@@ -219,7 +222,10 @@ discard block |
||
| 219 | 222 | */ |
| 220 | 223 | function __construct() |
| 221 | 224 | { |
| 222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
| 225 | + if ($this->debug > 0) |
|
| 226 | + { |
|
| 227 | + $this->debug_message('calendar_bo::bocal() started',True); |
|
| 228 | + } |
|
| 223 | 229 | |
| 224 | 230 | $this->so = new calendar_so(); |
| 225 | 231 | |
@@ -305,7 +311,10 @@ discard block |
||
| 305 | 311 | */ |
| 306 | 312 | static function email_info($ids) |
| 307 | 313 | { |
| 308 | - if (!$ids) return null; |
|
| 314 | + if (!$ids) |
|
| 315 | + { |
|
| 316 | + return null; |
|
| 317 | + } |
|
| 309 | 318 | |
| 310 | 319 | $data = array(); |
| 311 | 320 | foreach((array)$ids as $id) |
@@ -398,10 +407,13 @@ discard block |
||
| 398 | 407 | } |
| 399 | 408 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
| 400 | 409 | { |
| 401 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
| 410 | + if ($contact && !in_array($contact,$contact_list)) |
|
| 411 | + { |
|
| 412 | + // already added? |
|
| 402 | 413 | { |
| 403 | 414 | $contact_list[] = $contact; |
| 404 | 415 | } |
| 416 | + } |
|
| 405 | 417 | } |
| 406 | 418 | } |
| 407 | 419 | } |
@@ -461,21 +473,27 @@ discard block |
||
| 461 | 473 | { |
| 462 | 474 | foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
| 463 | 475 | { |
| 464 | - if ($contact && !in_array($contact,$users)) // already added? |
|
| 476 | + if ($contact && !in_array($contact,$users)) |
|
| 477 | + { |
|
| 478 | + // already added? |
|
| 465 | 479 | { |
| 466 | 480 | $users[] = $contact; |
| 467 | 481 | } |
| 482 | + } |
|
| 468 | 483 | } |
| 469 | 484 | continue; |
| 470 | 485 | } |
| 471 | 486 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
| 472 | 487 | { |
| 473 | - if ($user && !in_array($user,$users)) // already added? |
|
| 488 | + if ($user && !in_array($user,$users)) |
|
| 489 | + { |
|
| 490 | + // already added? |
|
| 474 | 491 | { |
| 475 | 492 | // General expansion check |
| 476 | 493 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
| 477 | 494 | { |
| 478 | 495 | $info = $this->resource_info($user); |
| 496 | + } |
|
| 479 | 497 | if($info && $info['resources']) |
| 480 | 498 | { |
| 481 | 499 | foreach($info['resources'] as $_user) |
@@ -496,12 +514,18 @@ discard block |
||
| 496 | 514 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 497 | 515 | } |
| 498 | 516 | // the further code is only for real users |
| 499 | - if (!is_numeric($user)) continue; |
|
| 517 | + if (!is_numeric($user)) |
|
| 518 | + { |
|
| 519 | + continue; |
|
| 520 | + } |
|
| 500 | 521 | |
| 501 | 522 | // for groups we have to include the members |
| 502 | 523 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
| 503 | 524 | { |
| 504 | - if ($no_enum_groups) continue; |
|
| 525 | + if ($no_enum_groups) |
|
| 526 | + { |
|
| 527 | + continue; |
|
| 528 | + } |
|
| 505 | 529 | |
| 506 | 530 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 507 | 531 | if (is_array($members)) |
@@ -581,11 +605,14 @@ discard block |
||
| 581 | 605 | } |
| 582 | 606 | |
| 583 | 607 | if (!isset($params['users']) || !$params['users'] || |
| 584 | - count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) // null or '' casted to an array |
|
| 608 | + count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) |
|
| 609 | + { |
|
| 610 | + // null or '' casted to an array |
|
| 585 | 611 | { |
| 586 | 612 | // for a search use all account you have read grants from |
| 587 | 613 | $params['users'] = $params['query'] ? array_keys($this->grants) : $this->user; |
| 588 | 614 | } |
| 615 | + } |
|
| 589 | 616 | // resolve users to add memberships for users and members for groups |
| 590 | 617 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
| 591 | 618 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
@@ -596,7 +623,10 @@ discard block |
||
| 596 | 623 | $params['private_grants'] = array(); |
| 597 | 624 | foreach($this->grants as $user => $rights) |
| 598 | 625 | { |
| 599 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 626 | + if ($rights & Acl::PRIVAT) |
|
| 627 | + { |
|
| 628 | + $params['private_grants'][] = $user; |
|
| 629 | + } |
|
| 600 | 630 | } |
| 601 | 631 | } |
| 602 | 632 | |
@@ -611,7 +641,10 @@ discard block |
||
| 611 | 641 | { |
| 612 | 642 | return false; |
| 613 | 643 | } |
| 614 | - if (isset($params['start'])) $start = $this->date2ts($params['start']); |
|
| 644 | + if (isset($params['start'])) |
|
| 645 | + { |
|
| 646 | + $start = $this->date2ts($params['start']); |
|
| 647 | + } |
|
| 615 | 648 | |
| 616 | 649 | if (isset($params['end'])) |
| 617 | 650 | { |
@@ -675,10 +708,13 @@ discard block |
||
| 675 | 708 | $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
| 676 | 709 | } |
| 677 | 710 | // create empty entries for each day in the reported time |
| 678 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 711 | + for($ts = $start; $ts <= $end; $ts += DAY_s) |
|
| 712 | + { |
|
| 713 | + // good enough for array creation, but see while loop below. |
|
| 679 | 714 | { |
| 680 | 715 | $daysEvents[$this->date2string($ts)] = array(); |
| 681 | 716 | } |
| 717 | + } |
|
| 682 | 718 | foreach($events as $k => $event) |
| 683 | 719 | { |
| 684 | 720 | $e_start = max($this->date2ts($event['start']),$start); |
@@ -730,7 +766,10 @@ discard block |
||
| 730 | 766 | $integration_data = calendar_so::get_integration_data(); |
| 731 | 767 | } |
| 732 | 768 | |
| 733 | - if (!isset($integration_data[$app])) return null; |
|
| 769 | + if (!isset($integration_data[$app])) |
|
| 770 | + { |
|
| 771 | + return null; |
|
| 772 | + } |
|
| 734 | 773 | |
| 735 | 774 | return $part ? $integration_data[$app][$part] : $integration_data[$app]; |
| 736 | 775 | } |
@@ -777,8 +816,14 @@ discard block |
||
| 777 | 816 | */ |
| 778 | 817 | function clear_private_infos(&$event,$allowed_participants = array()) |
| 779 | 818 | { |
| 780 | - if ($event == false) return; |
|
| 781 | - if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 819 | + if ($event == false) |
|
| 820 | + { |
|
| 821 | + return; |
|
| 822 | + } |
|
| 823 | + if (!is_array($event['participants'])) |
|
| 824 | + { |
|
| 825 | + error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 826 | + } |
|
| 782 | 827 | |
| 783 | 828 | $event = array( |
| 784 | 829 | 'id' => $event['id'], |
@@ -823,19 +868,29 @@ discard block |
||
| 823 | 868 | } |
| 824 | 869 | $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
| 825 | 870 | |
| 826 | - if ($new_horizont <= $this->config['horizont']) // no move necessary |
|
| 871 | + if ($new_horizont <= $this->config['horizont']) |
|
| 872 | + { |
|
| 873 | + // no move necessary |
|
| 827 | 874 | { |
| 828 | 875 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
| 876 | + } |
|
| 829 | 877 | return; |
| 830 | 878 | } |
| 831 | 879 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
| 832 | 880 | { |
| 833 | 881 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 834 | 882 | } |
| 835 | - if (empty($maxdays)) $maxdays = 1000; // old default |
|
| 836 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 883 | + if (empty($maxdays)) |
|
| 884 | + { |
|
| 885 | + $maxdays = 1000; |
|
| 886 | + } |
|
| 887 | + // old default |
|
| 888 | + if ($new_horizont > time()+$maxdays*DAY_s) |
|
| 889 | + { |
|
| 890 | + // some user tries to "look" more then the maximum number of days in the future |
|
| 837 | 891 | { |
| 838 | 892 | if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
| 893 | + } |
|
| 839 | 894 | $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
| 840 | 895 | return; |
| 841 | 896 | } |
@@ -863,7 +918,10 @@ discard block |
||
| 863 | 918 | // update the horizont |
| 864 | 919 | Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
| 865 | 920 | |
| 866 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 921 | + if ($this->debug == 'check_move_horizont') |
|
| 922 | + { |
|
| 923 | + $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 924 | + } |
|
| 867 | 925 | } |
| 868 | 926 | |
| 869 | 927 | /** |
@@ -894,7 +952,10 @@ discard block |
||
| 894 | 952 | $event['end'] = $this->date2usertime($event_read['end']); |
| 895 | 953 | } |
| 896 | 954 | } |
| 897 | - if (!$start) $start = $event['start']; |
|
| 955 | + if (!$start) |
|
| 956 | + { |
|
| 957 | + $start = $event['start']; |
|
| 958 | + } |
|
| 898 | 959 | $start_obj = new Api\DateTime($start); |
| 899 | 960 | $read_start = new Api\DateTime($event_read['start']); |
| 900 | 961 | |
@@ -936,7 +997,10 @@ discard block |
||
| 936 | 997 | */ |
| 937 | 998 | function db2data(&$events,$date_format='ts') |
| 938 | 999 | { |
| 939 | - if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1000 | + if (!is_array($events)) |
|
| 1001 | + { |
|
| 1002 | + echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 1003 | + } |
|
| 940 | 1004 | foreach ($events as &$event) |
| 941 | 1005 | { |
| 942 | 1006 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
@@ -1020,7 +1084,10 @@ discard block |
||
| 1020 | 1084 | */ |
| 1021 | 1085 | function date2usertime($ts,$date_format='ts') |
| 1022 | 1086 | { |
| 1023 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
| 1087 | + if (empty($ts) || $date_format == 'server') |
|
| 1088 | + { |
|
| 1089 | + return $ts; |
|
| 1090 | + } |
|
| 1024 | 1091 | |
| 1025 | 1092 | return Api\DateTime::server2user($ts,$date_format); |
| 1026 | 1093 | } |
@@ -1038,9 +1105,15 @@ discard block |
||
| 1038 | 1105 | */ |
| 1039 | 1106 | function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
| 1040 | 1107 | { |
| 1041 | - if (!$ids) return false; |
|
| 1108 | + if (!$ids) |
|
| 1109 | + { |
|
| 1110 | + return false; |
|
| 1111 | + } |
|
| 1042 | 1112 | |
| 1043 | - if ($date) $date = $this->date2ts($date); |
|
| 1113 | + if ($date) |
|
| 1114 | + { |
|
| 1115 | + $date = $this->date2ts($date); |
|
| 1116 | + } |
|
| 1044 | 1117 | |
| 1045 | 1118 | $return = null; |
| 1046 | 1119 | |
@@ -1205,7 +1278,10 @@ discard block |
||
| 1205 | 1278 | { |
| 1206 | 1279 | static $res_info_cache = array(); |
| 1207 | 1280 | |
| 1208 | - if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1281 | + if (!is_scalar($uid)) |
|
| 1282 | + { |
|
| 1283 | + throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1284 | + } |
|
| 1209 | 1285 | |
| 1210 | 1286 | if (!isset($res_info_cache[$uid])) |
| 1211 | 1287 | { |
@@ -1260,7 +1336,10 @@ discard block |
||
| 1260 | 1336 | */ |
| 1261 | 1337 | function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
| 1262 | 1338 | { |
| 1263 | - if (!$user) $user = $this->user; |
|
| 1339 | + if (!$user) |
|
| 1340 | + { |
|
| 1341 | + $user = $this->user; |
|
| 1342 | + } |
|
| 1264 | 1343 | if ($user == $this->user) |
| 1265 | 1344 | { |
| 1266 | 1345 | $grants = $this->grants; |
@@ -1299,7 +1378,10 @@ discard block |
||
| 1299 | 1378 | $grant = $grants[$owner]; |
| 1300 | 1379 | |
| 1301 | 1380 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1302 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1381 | + if ($grant & ~self::ACL_INVITE) |
|
| 1382 | + { |
|
| 1383 | + $grant |= self::ACL_FREEBUSY; |
|
| 1384 | + } |
|
| 1303 | 1385 | |
| 1304 | 1386 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1305 | 1387 | { |
@@ -1325,7 +1407,10 @@ discard block |
||
| 1325 | 1407 | elseif (!is_numeric($uid)) |
| 1326 | 1408 | { |
| 1327 | 1409 | // if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights |
| 1328 | - if ($grant == self::ACL_FREEBUSY) continue; |
|
| 1410 | + if ($grant == self::ACL_FREEBUSY) |
|
| 1411 | + { |
|
| 1412 | + continue; |
|
| 1413 | + } |
|
| 1329 | 1414 | // if we have a resource as participant |
| 1330 | 1415 | $resource = $this->resource_info($uid); |
| 1331 | 1416 | $grant |= $resource['rights']; |
@@ -1476,14 +1561,20 @@ discard block |
||
| 1476 | 1561 | $param = $param ? 'True' : 'False'; |
| 1477 | 1562 | break; |
| 1478 | 1563 | case 'integer': |
| 1479 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1564 | + if ($param >= mktime(0,0,0,1,1,2000)) |
|
| 1565 | + { |
|
| 1566 | + $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1567 | + } |
|
| 1480 | 1568 | break; |
| 1481 | 1569 | } |
| 1482 | 1570 | } |
| 1483 | 1571 | $msg = str_replace('%'.($i-1),$param,$msg); |
| 1484 | 1572 | } |
| 1485 | 1573 | error_log($msg); |
| 1486 | - if ($backtrace) error_log(function_backtrace(1)); |
|
| 1574 | + if ($backtrace) |
|
| 1575 | + { |
|
| 1576 | + error_log(function_backtrace(1)); |
|
| 1577 | + } |
|
| 1487 | 1578 | } |
| 1488 | 1579 | |
| 1489 | 1580 | /** |
@@ -1591,14 +1682,20 @@ discard block |
||
| 1591 | 1682 | function timespan($start_m,$end_m,$both=false) |
| 1592 | 1683 | { |
| 1593 | 1684 | $duration = $end_m - $start_m; |
| 1594 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1685 | + if ($end_m == 24*60-1) |
|
| 1686 | + { |
|
| 1687 | + ++$duration; |
|
| 1688 | + } |
|
| 1595 | 1689 | $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
| 1596 | 1690 | |
| 1597 | 1691 | $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
| 1598 | 1692 | |
| 1599 | - if ($both) // end-time too |
|
| 1693 | + if ($both) |
|
| 1694 | + { |
|
| 1695 | + // end-time too |
|
| 1600 | 1696 | { |
| 1601 | 1697 | $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
| 1698 | + } |
|
| 1602 | 1699 | // dont double am/pm if they are the same in both times |
| 1603 | 1700 | if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
| 1604 | 1701 | { |
@@ -1622,7 +1719,10 @@ discard block |
||
| 1622 | 1719 | static $id2lid = array(); |
| 1623 | 1720 | static $id2email = array(); |
| 1624 | 1721 | |
| 1625 | - if ($use_type && $use_type != 'u') $id = $use_type.$id; |
|
| 1722 | + if ($use_type && $use_type != 'u') |
|
| 1723 | + { |
|
| 1724 | + $id = $use_type.$id; |
|
| 1725 | + } |
|
| 1626 | 1726 | |
| 1627 | 1727 | if (!isset($id2lid[$id])) |
| 1628 | 1728 | { |
@@ -1632,7 +1732,10 @@ discard block |
||
| 1632 | 1732 | if (($info = $this->resource_info($id))) |
| 1633 | 1733 | { |
| 1634 | 1734 | $id2lid[$id] = $info['name'] ? $info['name'] : $info['email']; |
| 1635 | - if ($info['name']) $id2email[$id] = $info['email']; |
|
| 1735 | + if ($info['name']) |
|
| 1736 | + { |
|
| 1737 | + $id2email[$id] = $info['email']; |
|
| 1738 | + } |
|
| 1636 | 1739 | } |
| 1637 | 1740 | } |
| 1638 | 1741 | else |
@@ -1658,11 +1761,18 @@ discard block |
||
| 1658 | 1761 | $names = array(); |
| 1659 | 1762 | foreach((array)$event['participants'] as $id => $status) |
| 1660 | 1763 | { |
| 1661 | - if (!is_string($status)) continue; |
|
| 1764 | + if (!is_string($status)) |
|
| 1765 | + { |
|
| 1766 | + continue; |
|
| 1767 | + } |
|
| 1662 | 1768 | $quantity = $role = null; |
| 1663 | 1769 | calendar_so::split_status($status,$quantity,$role); |
| 1664 | 1770 | |
| 1665 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1771 | + if ($status == 'G' && !$show_group_invitation) |
|
| 1772 | + { |
|
| 1773 | + continue; |
|
| 1774 | + } |
|
| 1775 | + // dont show group-invitation |
|
| 1666 | 1776 | |
| 1667 | 1777 | $lang_status = lang($this->verbose_status[$status]); |
| 1668 | 1778 | if (!$long_status) |
@@ -1735,7 +1845,10 @@ discard block |
||
| 1735 | 1845 | |
| 1736 | 1846 | foreach(explode(',',$category) as $cat_id) |
| 1737 | 1847 | { |
| 1738 | - if (!$cat_id) continue; |
|
| 1848 | + if (!$cat_id) |
|
| 1849 | + { |
|
| 1850 | + continue; |
|
| 1851 | + } |
|
| 1739 | 1852 | |
| 1740 | 1853 | if (!isset($id2cat[$cat_id])) |
| 1741 | 1854 | { |
@@ -1801,7 +1914,10 @@ discard block |
||
| 1801 | 1914 | */ |
| 1802 | 1915 | public static function list_calendars($user, array $grants=null) |
| 1803 | 1916 | { |
| 1804 | - if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1917 | + if (is_null($grants)) |
|
| 1918 | + { |
|
| 1919 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1920 | + } |
|
| 1805 | 1921 | |
| 1806 | 1922 | $users = $groups = array(); |
| 1807 | 1923 | foreach(array_keys($grants) as $id) |
@@ -1849,7 +1965,10 @@ discard block |
||
| 1849 | 1965 | */ |
| 1850 | 1966 | function recure2string($event) |
| 1851 | 1967 | { |
| 1852 | - if (!is_array($event)) return false; |
|
| 1968 | + if (!is_array($event)) |
|
| 1969 | + { |
|
| 1970 | + return false; |
|
| 1971 | + } |
|
| 1853 | 1972 | return (string)calendar_rrule::event2rrule($event); |
| 1854 | 1973 | } |
| 1855 | 1974 | |
@@ -1868,7 +1987,10 @@ discard block |
||
| 1868 | 1987 | */ |
| 1869 | 1988 | function read_holidays($year=0) |
| 1870 | 1989 | { |
| 1871 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 1990 | + if (!$year) |
|
| 1991 | + { |
|
| 1992 | + $year = (int) date('Y',$this->now_su); |
|
| 1993 | + } |
|
| 1872 | 1994 | |
| 1873 | 1995 | $holidays = calendar_holidays::read( |
| 1874 | 1996 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
@@ -1963,7 +2085,10 @@ discard block |
||
| 1963 | 2085 | } |
| 1964 | 2086 | } |
| 1965 | 2087 | $str_fields = implode(', ',$extra_fields); |
| 1966 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2088 | + if (is_array($extra_fields)) |
|
| 2089 | + { |
|
| 2090 | + return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2091 | + } |
|
| 1967 | 2092 | } |
| 1968 | 2093 | return $this->format_date($event['start']) . ': ' . $event['title']; |
| 1969 | 2094 | } |
@@ -1984,7 +2109,8 @@ discard block |
||
| 1984 | 2109 | 'offset' => $options['start'], |
| 1985 | 2110 | 'order' => 'cal_start DESC', |
| 1986 | 2111 | ); |
| 1987 | - if($options['num_rows']) { |
|
| 2112 | + if($options['num_rows']) |
|
| 2113 | + { |
|
| 1988 | 2114 | $query['num_rows'] = $options['num_rows']; |
| 1989 | 2115 | } |
| 1990 | 2116 | foreach((array) $this->search($query) as $event) |
@@ -2045,7 +2171,10 @@ discard block |
||
| 2045 | 2171 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 2046 | 2172 | { |
| 2047 | 2173 | $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
| 2048 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2174 | + if ($type == 'forced') |
|
| 2175 | + { |
|
| 2176 | + $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2177 | + } |
|
| 2049 | 2178 | $this->cal_prefs[$var] = $default; |
| 2050 | 2179 | $need_save = True; |
| 2051 | 2180 | } |
@@ -2065,7 +2194,10 @@ discard block |
||
| 2065 | 2194 | */ |
| 2066 | 2195 | static function freebusy_url($user='',$pw=null) |
| 2067 | 2196 | { |
| 2068 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2197 | + if (is_numeric($user)) |
|
| 2198 | + { |
|
| 2199 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2200 | + } |
|
| 2069 | 2201 | |
| 2070 | 2202 | $credentials = ''; |
| 2071 | 2203 | |
@@ -2133,13 +2265,19 @@ discard block |
||
| 2133 | 2265 | */ |
| 2134 | 2266 | public function get_ctag($user, $filter='owner', $master_only=false) |
| 2135 | 2267 | { |
| 2136 | - if ($this->debug > 1) $startime = microtime(true); |
|
| 2268 | + if ($this->debug > 1) |
|
| 2269 | + { |
|
| 2270 | + $startime = microtime(true); |
|
| 2271 | + } |
|
| 2137 | 2272 | |
| 2138 | 2273 | // resolve users to add memberships for users and members for groups |
| 2139 | 2274 | $users = $this->resolve_users($user); |
| 2140 | 2275 | $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
| 2141 | 2276 | |
| 2142 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2277 | + if ($this->debug > 1) |
|
| 2278 | + { |
|
| 2279 | + error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2280 | + } |
|
| 2143 | 2281 | return $ctag; |
| 2144 | 2282 | } |
| 2145 | 2283 | |
@@ -2181,15 +2319,21 @@ discard block |
||
| 2181 | 2319 | $content['link_app'][] = $link['app']; |
| 2182 | 2320 | $content['link_id'][] = $link['id']; |
| 2183 | 2321 | } |
| 2184 | - if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above |
|
| 2322 | + if ($link['app'] == 'addressbook') |
|
| 2323 | + { |
|
| 2324 | + // prefering contact as primary contact over calendar entry set above |
|
| 2185 | 2325 | { |
| 2186 | 2326 | $content['info_contact'] = 'addressbook:'.$link['id']; |
| 2187 | 2327 | } |
| 2328 | + } |
|
| 2188 | 2329 | } |
| 2189 | 2330 | // Copy same custom fields |
| 2190 | 2331 | foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
| 2191 | 2332 | { |
| 2192 | - if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
|
| 2333 | + if ($this->customfields[$name]) |
|
| 2334 | + { |
|
| 2335 | + $content['#'.$name] = $calendar['#'.$name]; |
|
| 2336 | + } |
|
| 2193 | 2337 | } |
| 2194 | 2338 | //error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content)); |
| 2195 | 2339 | return $content; |
@@ -2212,7 +2356,11 @@ discard block |
||
| 2212 | 2356 | $set['ts_title'] = $this->link_title($event); |
| 2213 | 2357 | $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
| 2214 | 2358 | $set['ts_description'] = $event['description']; |
| 2215 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2359 | + if ($this->isWholeDay($event)) |
|
| 2360 | + { |
|
| 2361 | + $event['end']++; |
|
| 2362 | + } |
|
| 2363 | + // whole day events are 1sec short |
|
| 2216 | 2364 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2217 | 2365 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2218 | 2366 | $set['end_time'] = null; // unset end-time |
@@ -17,12 +17,12 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | if (!defined('ACL_TYPE_IDENTIFER')) // used to mark ACL-values for the debug_message methode |
| 19 | 19 | { |
| 20 | - define('ACL_TYPE_IDENTIFER','***ACL***'); |
|
| 20 | + define('ACL_TYPE_IDENTIFER', '***ACL***'); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -define('HOUR_s',60*60); |
|
| 24 | -define('DAY_s',24*HOUR_s); |
|
| 25 | -define('WEEK_s',7*DAY_s); |
|
| 23 | +define('HOUR_s', 60 * 60); |
|
| 24 | +define('DAY_s', 24 * HOUR_s); |
|
| 25 | +define('WEEK_s', 7 * DAY_s); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * 4 = function-calls to exported conversation-functions like date2ts, date2array, ... |
| 72 | 72 | * 5 = function-calls to private functions |
| 73 | 73 | */ |
| 74 | - var $debug=false; |
|
| 74 | + var $debug = false; |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @var int $now timestamp in server-time |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | /** |
| 102 | 102 | * @var int $user nummerical id of the current user-id |
| 103 | 103 | */ |
| 104 | - var $user=0; |
|
| 104 | + var $user = 0; |
|
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs |
| 108 | 108 | */ |
| 109 | - var $grants=array(); |
|
| 109 | + var $grants = array(); |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor |
@@ -219,15 +219,15 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | function __construct() |
| 221 | 221 | { |
| 222 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
| 222 | + if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True); |
|
| 223 | 223 | |
| 224 | 224 | $this->so = new calendar_so(); |
| 225 | 225 | |
| 226 | - $this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common']; |
|
| 227 | - $this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
| 226 | + $this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common']; |
|
| 227 | + $this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar']; |
|
| 228 | 228 | |
| 229 | 229 | $this->now = time(); |
| 230 | - $this->now_su = Api\DateTime::server2user($this->now,'ts'); |
|
| 230 | + $this->now_su = Api\DateTime::server2user($this->now, 'ts'); |
|
| 231 | 231 | |
| 232 | 232 | $this->user = $GLOBALS['egw_info']['user']['account_id']; |
| 233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources'))) |
| 237 | 237 | { |
| 238 | 238 | $this->resources = array(); |
| 239 | - foreach(Api\Hooks::process('calendar_resources') as $app => $data) |
|
| 239 | + foreach (Api\Hooks::process('calendar_resources') as $app => $data) |
|
| 240 | 240 | { |
| 241 | 241 | if ($data && $data['type']) |
| 242 | 242 | { |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | 'app' => 'email', |
| 250 | 250 | ); |
| 251 | 251 | $this->resources['l'] = array( |
| 252 | - 'type' => 'l',// one char type-identifier for this resources |
|
| 253 | - 'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id |
|
| 252 | + 'type' => 'l', // one char type-identifier for this resources |
|
| 253 | + 'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id |
|
| 254 | 254 | 'app' => 'Distribution list' |
| 255 | 255 | ); |
| 256 | 256 | $this->resources[''] = array( |
@@ -258,22 +258,22 @@ discard block |
||
| 258 | 258 | 'app' => 'api-accounts', |
| 259 | 259 | ); |
| 260 | 260 | $this->resources['l'] = array( |
| 261 | - 'type' => 'l',// one char type-identifier for this resources |
|
| 262 | - 'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id |
|
| 261 | + 'type' => 'l', // one char type-identifier for this resources |
|
| 262 | + 'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id |
|
| 263 | 263 | 'app' => 'Distribution list' |
| 264 | 264 | ); |
| 265 | 265 | Api\Cache::setSession('calendar', 'resources', $this->resources); |
| 266 | 266 | } |
| 267 | 267 | //error_log(__METHOD__ . " registered resources=". array2string($this->resources)); |
| 268 | 268 | |
| 269 | - $this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
| 269 | + $this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi |
|
| 270 | 270 | $this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite']; |
| 271 | 271 | |
| 272 | - $this->categories = new Api\Categories($this->user,'calendar'); |
|
| 272 | + $this->categories = new Api\Categories($this->user, 'calendar'); |
|
| 273 | 273 | |
| 274 | 274 | $this->customfields = Api\Storage\Customfields::get('calendar'); |
| 275 | 275 | |
| 276 | - foreach($this->alarms as $secs => &$label) |
|
| 276 | + foreach ($this->alarms as $secs => &$label) |
|
| 277 | 277 | { |
| 278 | 278 | $label = self::secs2label($secs); |
| 279 | 279 | } |
@@ -289,15 +289,15 @@ discard block |
||
| 289 | 289 | { |
| 290 | 290 | if ($secs <= 3600) |
| 291 | 291 | { |
| 292 | - $label = lang('%1 minutes', $secs/60); |
|
| 292 | + $label = lang('%1 minutes', $secs / 60); |
|
| 293 | 293 | } |
| 294 | - elseif($secs <= 86400) |
|
| 294 | + elseif ($secs <= 86400) |
|
| 295 | 295 | { |
| 296 | - $label = lang('%1 hours', $secs/3600); |
|
| 296 | + $label = lang('%1 hours', $secs / 3600); |
|
| 297 | 297 | } |
| 298 | 298 | else |
| 299 | 299 | { |
| 300 | - $label = lang('%1 days', $secs/86400); |
|
| 300 | + $label = lang('%1 days', $secs / 86400); |
|
| 301 | 301 | } |
| 302 | 302 | return $label; |
| 303 | 303 | } |
@@ -313,12 +313,12 @@ discard block |
||
| 313 | 313 | if (!$ids) return null; |
| 314 | 314 | |
| 315 | 315 | $data = array(); |
| 316 | - foreach((array)$ids as $id) |
|
| 316 | + foreach ((array)$ids as $id) |
|
| 317 | 317 | { |
| 318 | 318 | $email = $id; |
| 319 | 319 | $name = ''; |
| 320 | 320 | $matches = null; |
| 321 | - if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches)) |
|
| 321 | + if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches)) |
|
| 322 | 322 | { |
| 323 | 323 | $name = $matches[1]; |
| 324 | 324 | $email = $matches[2]; |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | static function mailing_lists($ids) |
| 344 | 344 | { |
| 345 | - if(!is_array($ids)) |
|
| 345 | + if (!is_array($ids)) |
|
| 346 | 346 | { |
| 347 | 347 | $ids = array($ids); |
| 348 | 348 | } |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | // Email list |
| 352 | 352 | $contacts_obj = new Api\Contacts(); |
| 353 | 353 | $bo = new calendar_bo(); |
| 354 | - foreach($ids as $id) |
|
| 354 | + foreach ($ids as $id) |
|
| 355 | 355 | { |
| 356 | 356 | $list = $contacts_obj->read_list((int)$id); |
| 357 | 357 | |
@@ -378,22 +378,22 @@ discard block |
||
| 378 | 378 | * |
| 379 | 379 | * @return array |
| 380 | 380 | */ |
| 381 | - public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true) |
|
| 381 | + public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true) |
|
| 382 | 382 | { |
| 383 | 383 | $contact_list = array(); |
| 384 | 384 | $contacts = new Api\Contacts(); |
| 385 | - if($contacts->check_list((int)substr($id,1), ACL::READ) || (int)substr($id,1) < 0) |
|
| 385 | + if ($contacts->check_list((int)substr($id, 1), ACL::READ) || (int)substr($id, 1) < 0) |
|
| 386 | 386 | { |
| 387 | - $options = array('list' => substr($id,1)); |
|
| 388 | - $lists = $contacts->search('',true,'','','',false,'AND',false,$options); |
|
| 389 | - if(!$lists) |
|
| 387 | + $options = array('list' => substr($id, 1)); |
|
| 388 | + $lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options); |
|
| 389 | + if (!$lists) |
|
| 390 | 390 | { |
| 391 | 391 | return $contact_list; |
| 392 | 392 | } |
| 393 | - foreach($lists as &$contact) |
|
| 393 | + foreach ($lists as &$contact) |
|
| 394 | 394 | { |
| 395 | 395 | // Check for user account |
| 396 | - if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'],'person_id'))) |
|
| 396 | + if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'], 'person_id'))) |
|
| 397 | 397 | { |
| 398 | 398 | $contact = ''.$account_id; |
| 399 | 399 | } |
@@ -401,9 +401,9 @@ discard block |
||
| 401 | 401 | { |
| 402 | 402 | $contact = 'c'.$contact['id']; |
| 403 | 403 | } |
| 404 | - if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact)) |
|
| 404 | + if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $contact)) |
|
| 405 | 405 | { |
| 406 | - if ($contact && !in_array($contact,$contact_list)) // already added? |
|
| 406 | + if ($contact && !in_array($contact, $contact_list)) // already added? |
|
| 407 | 407 | { |
| 408 | 408 | $contact_list[] = $contact; |
| 409 | 409 | } |
@@ -422,12 +422,12 @@ discard block |
||
| 422 | 422 | function enum_groups(&$event) |
| 423 | 423 | { |
| 424 | 424 | $added = 0; |
| 425 | - foreach(array_keys($event['participants']) as $uid) |
|
| 425 | + foreach (array_keys($event['participants']) as $uid) |
|
| 426 | 426 | { |
| 427 | 427 | if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' && |
| 428 | 428 | ($members = $GLOBALS['egw']->accounts->members($uid, true))) |
| 429 | 429 | { |
| 430 | - foreach($members as $member) |
|
| 430 | + foreach ($members as $member) |
|
| 431 | 431 | { |
| 432 | 432 | if (!isset($event['participants'][$member])) |
| 433 | 433 | { |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search |
| 450 | 450 | * @return array of user-ids |
| 451 | 451 | */ |
| 452 | - private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true) |
|
| 452 | + private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true) |
|
| 453 | 453 | { |
| 454 | 454 | if (!is_array($_users)) |
| 455 | 455 | { |
@@ -457,35 +457,35 @@ discard block |
||
| 457 | 457 | } |
| 458 | 458 | // only query calendars of users, we have READ-grants from |
| 459 | 459 | $users = array(); |
| 460 | - foreach($_users as $user) |
|
| 460 | + foreach ($_users as $user) |
|
| 461 | 461 | { |
| 462 | 462 | $user = trim($user); |
| 463 | 463 | |
| 464 | 464 | // Handle email lists |
| 465 | - if(!is_numeric($user) && $user[0] == 'l') |
|
| 465 | + if (!is_numeric($user) && $user[0] == 'l') |
|
| 466 | 466 | { |
| 467 | - foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
|
| 467 | + foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact) |
|
| 468 | 468 | { |
| 469 | - if ($contact && !in_array($contact,$users)) // already added? |
|
| 469 | + if ($contact && !in_array($contact, $users)) // already added? |
|
| 470 | 470 | { |
| 471 | 471 | $users[] = $contact; |
| 472 | 472 | } |
| 473 | 473 | } |
| 474 | 474 | continue; |
| 475 | 475 | } |
| 476 | - if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
|
| 476 | + if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $user)) |
|
| 477 | 477 | { |
| 478 | - if ($user && !in_array($user,$users)) // already added? |
|
| 478 | + if ($user && !in_array($user, $users)) // already added? |
|
| 479 | 479 | { |
| 480 | 480 | // General expansion check |
| 481 | 481 | if (!is_numeric($user) && $this->resources[$user[0]]['info']) |
| 482 | 482 | { |
| 483 | 483 | $info = $this->resource_info($user); |
| 484 | - if($info && $info['resources']) |
|
| 484 | + if ($info && $info['resources']) |
|
| 485 | 485 | { |
| 486 | - foreach($info['resources'] as $_user) |
|
| 486 | + foreach ($info['resources'] as $_user) |
|
| 487 | 487 | { |
| 488 | - if($_user && !in_array($_user, $users)) |
|
| 488 | + if ($_user && !in_array($_user, $users)) |
|
| 489 | 489 | { |
| 490 | 490 | $users[] = $_user; |
| 491 | 491 | } |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | } |
| 499 | 499 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 500 | 500 | { |
| 501 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 501 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 502 | 502 | } |
| 503 | 503 | // the further code is only for real users |
| 504 | 504 | if (!is_numeric($user)) continue; |
@@ -511,11 +511,11 @@ discard block |
||
| 511 | 511 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 512 | 512 | if (is_array($members)) |
| 513 | 513 | { |
| 514 | - foreach($members as $member) |
|
| 514 | + foreach ($members as $member) |
|
| 515 | 515 | { |
| 516 | 516 | // use only members which gave the user a read-grant |
| 517 | 517 | if (!in_array($member, $users) && |
| 518 | - ($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member))) |
|
| 518 | + ($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $member))) |
|
| 519 | 519 | { |
| 520 | 520 | $users[] = $member; |
| 521 | 521 | } |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 528 | 528 | if (is_array($memberships)) |
| 529 | 529 | { |
| 530 | - foreach($memberships as $group) |
|
| 530 | + foreach ($memberships as $group) |
|
| 531 | 531 | { |
| 532 | - if (!in_array($group,$users)) |
|
| 532 | + if (!in_array($group, $users)) |
|
| 533 | 533 | { |
| 534 | 534 | $users[] = $group; |
| 535 | 535 | } |
@@ -570,18 +570,18 @@ discard block |
||
| 570 | 570 | * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param) |
| 571 | 571 | * or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given |
| 572 | 572 | */ |
| 573 | - function &search($params,$sql_filter=null) |
|
| 573 | + function &search($params, $sql_filter = null) |
|
| 574 | 574 | { |
| 575 | 575 | $params_in = $params; |
| 576 | 576 | |
| 577 | - $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
| 577 | + $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
| 578 | 578 | |
| 579 | 579 | // check if any resource wants to hook into |
| 580 | - foreach($this->resources as $data) |
|
| 580 | + foreach ($this->resources as $data) |
|
| 581 | 581 | { |
| 582 | 582 | if (isset($data['search_filter'])) |
| 583 | 583 | { |
| 584 | - $params = ExecMethod($data['search_filter'],$params); |
|
| 584 | + $params = ExecMethod($data['search_filter'], $params); |
|
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
@@ -599,9 +599,9 @@ discard block |
||
| 599 | 599 | if (!empty($params['query'])) |
| 600 | 600 | { |
| 601 | 601 | $params['private_grants'] = array(); |
| 602 | - foreach($this->grants as $user => $rights) |
|
| 602 | + foreach ($this->grants as $user => $rights) |
|
| 603 | 603 | { |
| 604 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 604 | + if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 605 | 605 | } |
| 606 | 606 | } |
| 607 | 607 | |
@@ -627,49 +627,49 @@ discard block |
||
| 627 | 627 | $params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring']; |
| 628 | 628 | $cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0; |
| 629 | 629 | $filter = isset($params['filter']) ? $params['filter'] : 'all'; |
| 630 | - $offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false; |
|
| 630 | + $offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false; |
|
| 631 | 631 | // socal::search() returns rejected group-invitations, as only the user not also the group is rejected |
| 632 | 632 | // as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed |
| 633 | 633 | $users_in = (array)$params_in['users']; |
| 634 | - $remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) && |
|
| 634 | + $remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) && |
|
| 635 | 635 | count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null; |
| 636 | 636 | //error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user)); |
| 637 | 637 | |
| 638 | 638 | if ($this->debug && ($this->debug > 1 || $this->debug == 'search')) |
| 639 | 639 | { |
| 640 | 640 | $this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)', |
| 641 | - True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']); |
|
| 641 | + True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']); |
|
| 642 | 642 | } |
| 643 | 643 | // date2ts(,true) converts to server time, db2data converts again to user-time |
| 644 | - $events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null, |
|
| 645 | - $users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user); |
|
| 644 | + $events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null, |
|
| 645 | + $users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user); |
|
| 646 | 646 | |
| 647 | 647 | if (isset($params['cols'])) |
| 648 | 648 | { |
| 649 | 649 | return $events; |
| 650 | 650 | } |
| 651 | 651 | $this->total = $this->so->total; |
| 652 | - $this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
| 652 | + $this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
| 653 | 653 | |
| 654 | 654 | //echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n"; |
| 655 | - foreach($events as $id => $event) |
|
| 655 | + foreach ($events as $id => $event) |
|
| 656 | 656 | { |
| 657 | 657 | if ($params['enum_groups'] && $this->enum_groups($event)) |
| 658 | 658 | { |
| 659 | 659 | $events[$id] = $event; |
| 660 | 660 | } |
| 661 | 661 | $matches = null; |
| 662 | - if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches)) |
|
| 662 | + if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches)) |
|
| 663 | 663 | { |
| 664 | - $is_private = self::integration_get_private($matches[1],$matches[2],$event); |
|
| 664 | + $is_private = self::integration_get_private($matches[1], $matches[2], $event); |
|
| 665 | 665 | } |
| 666 | 666 | else |
| 667 | 667 | { |
| 668 | - $is_private = !$this->check_perms(Acl::READ,$event); |
|
| 668 | + $is_private = !$this->check_perms(Acl::READ, $event); |
|
| 669 | 669 | } |
| 670 | 670 | if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate'))) |
| 671 | 671 | { |
| 672 | - $this->clear_private_infos($events[$id],$users); |
|
| 672 | + $this->clear_private_infos($events[$id], $users); |
|
| 673 | 673 | } |
| 674 | 674 | } |
| 675 | 675 | |
@@ -677,18 +677,18 @@ discard block |
||
| 677 | 677 | { |
| 678 | 678 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
| 679 | 679 | { |
| 680 | - $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
|
| 680 | + $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events); |
|
| 681 | 681 | } |
| 682 | 682 | // create empty entries for each day in the reported time |
| 683 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 683 | + for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 684 | 684 | { |
| 685 | 685 | $daysEvents[$this->date2string($ts)] = array(); |
| 686 | 686 | } |
| 687 | - foreach($events as $k => $event) |
|
| 687 | + foreach ($events as $k => $event) |
|
| 688 | 688 | { |
| 689 | - $e_start = max($this->date2ts($event['start']),$start); |
|
| 689 | + $e_start = max($this->date2ts($event['start']), $start); |
|
| 690 | 690 | // $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59 |
| 691 | - $e_end = min($this->date2ts($event['end'])-1,$end); |
|
| 691 | + $e_end = min($this->date2ts($event['end']) - 1, $end); |
|
| 692 | 692 | |
| 693 | 693 | // add event to each day in the reported time |
| 694 | 694 | $ts = $e_start; |
@@ -697,23 +697,23 @@ discard block |
||
| 697 | 697 | $ymd = null; |
| 698 | 698 | while ($ts <= $e_end) |
| 699 | 699 | { |
| 700 | - $daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k]; |
|
| 701 | - $ts = strtotime("+1 day",$ts); |
|
| 700 | + $daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k]; |
|
| 701 | + $ts = strtotime("+1 day", $ts); |
|
| 702 | 702 | } |
| 703 | 703 | if ($ymd != ($last = $this->date2string($e_end))) |
| 704 | 704 | { |
| 705 | - $daysEvents[$last][] =& $events[$k]; |
|
| 705 | + $daysEvents[$last][] = & $events[$k]; |
|
| 706 | 706 | } |
| 707 | 707 | } |
| 708 | - $events =& $daysEvents; |
|
| 708 | + $events = & $daysEvents; |
|
| 709 | 709 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
| 710 | 710 | { |
| 711 | - $this->debug_message('socalendar::search daywise events=%1',False,$events); |
|
| 711 | + $this->debug_message('socalendar::search daywise events=%1', False, $events); |
|
| 712 | 712 | } |
| 713 | 713 | } |
| 714 | 714 | if ($this->debug && ($this->debug > 0 || $this->debug == 'search')) |
| 715 | 715 | { |
| 716 | - $this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events); |
|
| 716 | + $this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events); |
|
| 717 | 717 | } |
| 718 | 718 | //error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace()); |
| 719 | 719 | return $events; |
@@ -726,9 +726,9 @@ discard block |
||
| 726 | 726 | * @param string $part |
| 727 | 727 | * @return array |
| 728 | 728 | */ |
| 729 | - static function integration_get_data($app,$part=null) |
|
| 729 | + static function integration_get_data($app, $part = null) |
|
| 730 | 730 | { |
| 731 | - static $integration_data=null; |
|
| 731 | + static $integration_data = null; |
|
| 732 | 732 | |
| 733 | 733 | if (!isset($integration_data)) |
| 734 | 734 | { |
@@ -750,14 +750,14 @@ discard block |
||
| 750 | 750 | * @param int|string $id |
| 751 | 751 | * @return string |
| 752 | 752 | */ |
| 753 | - static function integration_get_private($app,$id,$event) |
|
| 753 | + static function integration_get_private($app, $id, $event) |
|
| 754 | 754 | { |
| 755 | - $app_data = self::integration_get_data($app,'is_private'); |
|
| 755 | + $app_data = self::integration_get_data($app, 'is_private'); |
|
| 756 | 756 | |
| 757 | 757 | // no method, fall back to link title |
| 758 | 758 | if (is_null($app_data)) |
| 759 | 759 | { |
| 760 | - $is_private = !Link::title($app,$id); |
|
| 760 | + $is_private = !Link::title($app, $id); |
|
| 761 | 761 | } |
| 762 | 762 | // boolean value to make all events of $app public (false) or private (true) |
| 763 | 763 | elseif (is_bool($app_data)) |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | } |
| 767 | 767 | else |
| 768 | 768 | { |
| 769 | - $is_private = (bool)ExecMethod2($app_data,$id,$event); |
|
| 769 | + $is_private = (bool)ExecMethod2($app_data, $id, $event); |
|
| 770 | 770 | } |
| 771 | 771 | //echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n"; |
| 772 | 772 | return $is_private; |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * @param array &$event |
| 781 | 781 | * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar |
| 782 | 782 | */ |
| 783 | - function clear_private_infos(&$event,$allowed_participants = array()) |
|
| 783 | + function clear_private_infos(&$event, $allowed_participants = array()) |
|
| 784 | 784 | { |
| 785 | 785 | if ($event == false) return; |
| 786 | 786 | if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
@@ -796,19 +796,19 @@ discard block |
||
| 796 | 796 | 'owner' => $event['owner'], |
| 797 | 797 | 'uid' => $event['uid'], |
| 798 | 798 | 'etag' => $event['etag'], |
| 799 | - 'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)), |
|
| 799 | + 'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)), |
|
| 800 | 800 | 'public'=> 0, |
| 801 | - 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
| 801 | + 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
| 802 | 802 | 'non_blocking' => $event['non_blocking'], |
| 803 | 803 | 'caldav_name' => $event['caldav_name'], |
| 804 | 804 | // we need full recurrence information, as they are relevant free/busy information |
| 805 | - )+($event['recur_type'] ? array( |
|
| 805 | + ) + ($event['recur_type'] ? array( |
|
| 806 | 806 | 'recur_type' => $event['recur_type'], |
| 807 | 807 | 'recur_interval' => $event['recur_interval'], |
| 808 | 808 | 'recur_data' => $event['recur_data'], |
| 809 | 809 | 'recur_enddate' => $event['recur_enddate'], |
| 810 | 810 | 'recur_exception'=> $event['recur_exception'], |
| 811 | - ):array( |
|
| 811 | + ) : array( |
|
| 812 | 812 | 'reference' => $event['reference'], |
| 813 | 813 | 'recurrence' => $event['recurrence'], |
| 814 | 814 | )); |
@@ -822,15 +822,15 @@ discard block |
||
| 822 | 822 | */ |
| 823 | 823 | function check_move_horizont($_new_horizont) |
| 824 | 824 | { |
| 825 | - if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
| 825 | + if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
| 826 | 826 | { |
| 827 | - $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']); |
|
| 827 | + $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']); |
|
| 828 | 828 | } |
| 829 | - $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
|
| 829 | + $new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates |
|
| 830 | 830 | |
| 831 | 831 | if ($new_horizont <= $this->config['horizont']) // no move necessary |
| 832 | 832 | { |
| 833 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']); |
|
| 833 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']); |
|
| 834 | 834 | return; |
| 835 | 835 | } |
| 836 | 836 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
@@ -838,15 +838,15 @@ discard block |
||
| 838 | 838 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 839 | 839 | } |
| 840 | 840 | if (empty($maxdays)) $maxdays = 1000; // old default |
| 841 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 841 | + if ($new_horizont > time() + $maxdays * DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 842 | 842 | { |
| 843 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays); |
|
| 844 | - $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
|
| 843 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays); |
|
| 844 | + $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays); |
|
| 845 | 845 | return; |
| 846 | 846 | } |
| 847 | - if ($new_horizont < time()+31*DAY_s) |
|
| 847 | + if ($new_horizont < time() + 31 * DAY_s) |
|
| 848 | 848 | { |
| 849 | - $new_horizont = time()+31*DAY_s; |
|
| 849 | + $new_horizont = time() + 31 * DAY_s; |
|
| 850 | 850 | } |
| 851 | 851 | $old_horizont = $this->config['horizont']; |
| 852 | 852 | $this->config['horizont'] = $new_horizont; |
@@ -854,21 +854,21 @@ discard block |
||
| 854 | 854 | // create further recurrences for all recurring and not yet (at the old horizont) ended events |
| 855 | 855 | if (($recuring = $this->so->unfinished_recuring($old_horizont))) |
| 856 | 856 | { |
| 857 | - @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
| 858 | - foreach($this->read(array_keys($recuring)) as $cal_id => $event) |
|
| 857 | + @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
| 858 | + foreach ($this->read(array_keys($recuring)) as $cal_id => $event) |
|
| 859 | 859 | { |
| 860 | 860 | if ($this->debug == 'check_move_horizont') |
| 861 | 861 | { |
| 862 | - $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont); |
|
| 862 | + $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont); |
|
| 863 | 863 | } |
| 864 | 864 | // insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past |
| 865 | - $this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time! |
|
| 865 | + $this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time! |
|
| 866 | 866 | } |
| 867 | 867 | } |
| 868 | 868 | // update the horizont |
| 869 | - Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
|
| 869 | + Api\Config::save_value('horizont', $this->config['horizont'], 'calendar'); |
|
| 870 | 870 | |
| 871 | - if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 871 | + if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']); |
|
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | /** |
@@ -879,11 +879,11 @@ discard block |
||
| 879 | 879 | * @param array $event |
| 880 | 880 | * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
| 881 | 881 | */ |
| 882 | - function set_recurrences($event,$start=0) |
|
| 882 | + function set_recurrences($event, $start = 0) |
|
| 883 | 883 | { |
| 884 | - if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
| 884 | + if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
| 885 | 885 | { |
| 886 | - $this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start); |
|
| 886 | + $this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start); |
|
| 887 | 887 | } |
| 888 | 888 | // check if the caller gave us enough information and if not read it from the DB |
| 889 | 889 | if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end'])) |
@@ -904,29 +904,29 @@ discard block |
||
| 904 | 904 | $read_start = new Api\DateTime($event_read['start']); |
| 905 | 905 | |
| 906 | 906 | $events = array(); |
| 907 | - $this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events); |
|
| 907 | + $this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events); |
|
| 908 | 908 | |
| 909 | 909 | $exceptions = array(); |
| 910 | - foreach((array)$event['recur_exception'] as $exception) |
|
| 910 | + foreach ((array)$event['recur_exception'] as $exception) |
|
| 911 | 911 | { |
| 912 | - $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
| 912 | + $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
| 913 | 913 | } |
| 914 | - foreach($events as $event) |
|
| 914 | + foreach ($events as $event) |
|
| 915 | 915 | { |
| 916 | 916 | $is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions); |
| 917 | - $start = $this->date2ts($event['start'],true); |
|
| 917 | + $start = $this->date2ts($event['start'], true); |
|
| 918 | 918 | if ($event['whole_day']) |
| 919 | 919 | { |
| 920 | 920 | $start = new Api\DateTime($event['start'], Api\DateTime::$server_timezone); |
| 921 | - $start->setTime(0,0,0); |
|
| 921 | + $start->setTime(0, 0, 0); |
|
| 922 | 922 | $start = $start->format('ts'); |
| 923 | 923 | $time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone)); |
| 924 | 924 | $time->setTime(23, 59, 59); |
| 925 | - $end = $this->date2ts($time,true); |
|
| 925 | + $end = $this->date2ts($time, true); |
|
| 926 | 926 | } |
| 927 | 927 | else |
| 928 | 928 | { |
| 929 | - $end = $this->date2ts($event['end'],true); |
|
| 929 | + $end = $this->date2ts($event['end'], true); |
|
| 930 | 930 | } |
| 931 | 931 | //error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception)); |
| 932 | 932 | $this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception); |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | * @param array &$events array of event-arrays (reference) |
| 943 | 943 | * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
| 944 | 944 | */ |
| 945 | - function db2data(&$events,$date_format='ts') |
|
| 945 | + function db2data(&$events, $date_format = 'ts') |
|
| 946 | 946 | { |
| 947 | 947 | if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
| 948 | 948 | foreach ($events as &$event) |
@@ -955,65 +955,65 @@ discard block |
||
| 955 | 955 | // database returns timestamps as string, convert them to integer |
| 956 | 956 | // to avoid misinterpretation by Api\DateTime as Ymd string |
| 957 | 957 | // (this will fail on 32bit systems for times > 2038!) |
| 958 | - $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
| 958 | + $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
| 959 | 959 | $event['end'] = (int)$event['end']; |
| 960 | 960 | $event['whole_day'] = self::isWholeDay($event); |
| 961 | 961 | if ($event['whole_day'] && $date_format != 'server') |
| 962 | 962 | { |
| 963 | 963 | // Adjust dates to user TZ |
| 964 | - $stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 964 | + $stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 965 | 965 | $event['start'] = Api\DateTime::to($stime, $date_format); |
| 966 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 966 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 967 | 967 | $time->setTime(23, 59, 59); |
| 968 | 968 | $event['end'] = Api\DateTime::to($time, $date_format); |
| 969 | 969 | if (!empty($event['recurrence'])) |
| 970 | 970 | { |
| 971 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 971 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 972 | 972 | $event['recurrence'] = Api\DateTime::to($time, $date_format); |
| 973 | 973 | } |
| 974 | 974 | if (!empty($event['recur_enddate'])) |
| 975 | 975 | { |
| 976 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 976 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 977 | 977 | $time->setTime(23, 59, 59); |
| 978 | 978 | $event['recur_enddate'] = Api\DateTime::to($time, $date_format); |
| 979 | 979 | } |
| 980 | - $timestamps = array('modified','created','deleted'); |
|
| 980 | + $timestamps = array('modified', 'created', 'deleted'); |
|
| 981 | 981 | } |
| 982 | 982 | else |
| 983 | 983 | { |
| 984 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date','deleted'); |
|
| 984 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date', 'deleted'); |
|
| 985 | 985 | } |
| 986 | 986 | // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! |
| 987 | 987 | foreach ($timestamps as $ts) |
| 988 | 988 | { |
| 989 | 989 | if (!empty($event[$ts])) |
| 990 | 990 | { |
| 991 | - $event[$ts] = $this->date2usertime((int)$event[$ts],$date_format); |
|
| 991 | + $event[$ts] = $this->date2usertime((int)$event[$ts], $date_format); |
|
| 992 | 992 | } |
| 993 | 993 | } |
| 994 | 994 | // same with the recur exceptions |
| 995 | 995 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 996 | 996 | { |
| 997 | - foreach($event['recur_exception'] as &$date) |
|
| 997 | + foreach ($event['recur_exception'] as &$date) |
|
| 998 | 998 | { |
| 999 | 999 | if ($event['whole_day'] && $date_format != 'server') |
| 1000 | 1000 | { |
| 1001 | 1001 | // Adjust dates to user TZ |
| 1002 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
| 1002 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
| 1003 | 1003 | $date = Api\DateTime::to($time, $date_format); |
| 1004 | 1004 | } |
| 1005 | 1005 | else |
| 1006 | 1006 | { |
| 1007 | - $date = $this->date2usertime((int)$date,$date_format); |
|
| 1007 | + $date = $this->date2usertime((int)$date, $date_format); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | } |
| 1010 | 1010 | } |
| 1011 | 1011 | // same with the alarms |
| 1012 | 1012 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1013 | 1013 | { |
| 1014 | - foreach($event['alarm'] as &$alarm) |
|
| 1014 | + foreach ($event['alarm'] as &$alarm) |
|
| 1015 | 1015 | { |
| 1016 | - $alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format); |
|
| 1016 | + $alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | } |
| 1019 | 1019 | } |
@@ -1026,11 +1026,11 @@ discard block |
||
| 1026 | 1026 | * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
| 1027 | 1027 | * @return mixed depending of $date_format |
| 1028 | 1028 | */ |
| 1029 | - function date2usertime($ts,$date_format='ts') |
|
| 1029 | + function date2usertime($ts, $date_format = 'ts') |
|
| 1030 | 1030 | { |
| 1031 | 1031 | if (empty($ts) || $date_format == 'server') return $ts; |
| 1032 | 1032 | |
| 1033 | - return Api\DateTime::server2user($ts,$date_format); |
|
| 1033 | + return Api\DateTime::server2user($ts, $date_format); |
|
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | /** |
@@ -1044,7 +1044,7 @@ discard block |
||
| 1044 | 1044 | * but call clear_private_infos() with the given users |
| 1045 | 1045 | * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found |
| 1046 | 1046 | */ |
| 1047 | - function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
|
| 1047 | + function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null) |
|
| 1048 | 1048 | { |
| 1049 | 1049 | if (!$ids) return false; |
| 1050 | 1050 | |
@@ -1053,21 +1053,21 @@ discard block |
||
| 1053 | 1053 | $return = null; |
| 1054 | 1054 | |
| 1055 | 1055 | $check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ; |
| 1056 | - if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date))) |
|
| 1056 | + if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date))) |
|
| 1057 | 1057 | { |
| 1058 | 1058 | if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids || |
| 1059 | 1059 | self::$cached_event_date_format != $date_format || |
| 1060 | 1060 | self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date) |
| 1061 | 1061 | { |
| 1062 | - $events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0); |
|
| 1062 | + $events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0); |
|
| 1063 | 1063 | |
| 1064 | 1064 | if ($events) |
| 1065 | 1065 | { |
| 1066 | - $this->db2data($events,$date_format); |
|
| 1066 | + $this->db2data($events, $date_format); |
|
| 1067 | 1067 | |
| 1068 | 1068 | if (is_array($ids)) |
| 1069 | 1069 | { |
| 1070 | - $return =& $events; |
|
| 1070 | + $return = & $events; |
|
| 1071 | 1071 | } |
| 1072 | 1072 | else |
| 1073 | 1073 | { |
@@ -1083,13 +1083,13 @@ discard block |
||
| 1083 | 1083 | $return = self::$cached_event; |
| 1084 | 1084 | } |
| 1085 | 1085 | } |
| 1086 | - if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return)) |
|
| 1086 | + if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return)) |
|
| 1087 | 1087 | { |
| 1088 | 1088 | $this->clear_private_infos($return, (array)$clear_private_infos_users); |
| 1089 | 1089 | } |
| 1090 | 1090 | if ($this->debug && ($this->debug > 1 || $this->debug == 'read')) |
| 1091 | 1091 | { |
| 1092 | - $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return); |
|
| 1092 | + $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | return $return; |
| 1095 | 1095 | } |
@@ -1107,17 +1107,17 @@ discard block |
||
| 1107 | 1107 | * @param array $events where the repetions get inserted |
| 1108 | 1108 | * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
| 1109 | 1109 | */ |
| 1110 | - function insert_all_recurrences($event,$_start,$end,&$events) |
|
| 1110 | + function insert_all_recurrences($event, $_start, $end, &$events) |
|
| 1111 | 1111 | { |
| 1112 | - if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
| 1112 | + if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
| 1113 | 1113 | { |
| 1114 | - $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end); |
|
| 1114 | + $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end); |
|
| 1115 | 1115 | } |
| 1116 | 1116 | $end_in = $end; |
| 1117 | 1117 | |
| 1118 | 1118 | $start = $this->date2ts($_start); |
| 1119 | 1119 | $event_start_ts = $this->date2ts($event['start']); |
| 1120 | - $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
| 1120 | + $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
| 1121 | 1121 | |
| 1122 | 1122 | // if $end is before recur_enddate, use it instead |
| 1123 | 1123 | if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end)) |
@@ -1126,39 +1126,38 @@ discard block |
||
| 1126 | 1126 | // insert at least the event itself, if it's behind the horizont |
| 1127 | 1127 | $event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end; |
| 1128 | 1128 | } |
| 1129 | - $event['recur_enddate'] = is_a($event['recur_enddate'],'DateTime') ? |
|
| 1130 | - $event['recur_enddate'] : |
|
| 1131 | - new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
| 1129 | + $event['recur_enddate'] = is_a($event['recur_enddate'], 'DateTime') ? |
|
| 1130 | + $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
| 1132 | 1131 | // unset exceptions, as we need to add them as recurrence too, but marked as exception |
| 1133 | 1132 | unset($event['recur_exception']); |
| 1134 | 1133 | // loop over all recurrences and insert them, if they are after $start |
| 1135 | - $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
| 1136 | - foreach($rrule as $time) |
|
| 1134 | + $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
| 1135 | + foreach ($rrule as $time) |
|
| 1137 | 1136 | { |
| 1138 | - $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
| 1139 | - if($event['whole_day']) |
|
| 1137 | + $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
| 1138 | + if ($event['whole_day']) |
|
| 1140 | 1139 | { |
| 1141 | 1140 | // All day events are processed in server timezone |
| 1142 | 1141 | $time->setServer(); |
| 1143 | - $time->setTime(0,0,0); |
|
| 1142 | + $time->setTime(0, 0, 0); |
|
| 1144 | 1143 | } |
| 1145 | - if (($ts = $this->date2ts($time)) < $start-$event_length) |
|
| 1144 | + if (($ts = $this->date2ts($time)) < $start - $event_length) |
|
| 1146 | 1145 | { |
| 1147 | 1146 | //echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n"; |
| 1148 | - continue; // to early or original event (returned by interator too) |
|
| 1147 | + continue; // to early or original event (returned by interator too) |
|
| 1149 | 1148 | } |
| 1150 | 1149 | |
| 1151 | 1150 | $ts_end = $ts + $event_length; |
| 1152 | 1151 | // adjust ts_end for whole day events in case it does not fit due to |
| 1153 | 1152 | // spans over summer/wintertime adjusted days |
| 1154 | - if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
| 1153 | + if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
| 1155 | 1154 | !($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59)) |
| 1156 | 1155 | { |
| 1157 | 1156 | $arr_end['hour'] = 23; |
| 1158 | 1157 | $arr_end['minute'] = 59; |
| 1159 | 1158 | $arr_end['second'] = 59; |
| 1160 | 1159 | $ts_end_guess = $this->date2ts($arr_end); |
| 1161 | - if($ts_end_guess - $ts_end > DAY_s/2) |
|
| 1160 | + if ($ts_end_guess - $ts_end > DAY_s / 2) |
|
| 1162 | 1161 | { |
| 1163 | 1162 | $ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future |
| 1164 | 1163 | } |
@@ -1172,11 +1171,11 @@ discard block |
||
| 1172 | 1171 | $event['end'] = $ts_end; |
| 1173 | 1172 | $events[] = $event; |
| 1174 | 1173 | } |
| 1175 | - if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
| 1174 | + if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
| 1176 | 1175 | { |
| 1177 | 1176 | $event['start'] = $event_start_ts; |
| 1178 | 1177 | $event['end'] = $event_start_ts + $event_length; |
| 1179 | - $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events); |
|
| 1178 | + $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events); |
|
| 1180 | 1179 | } |
| 1181 | 1180 | } |
| 1182 | 1181 | |
@@ -1187,18 +1186,18 @@ discard block |
||
| 1187 | 1186 | * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd |
| 1188 | 1187 | * @param int|string $date_ymd of the date of the event |
| 1189 | 1188 | */ |
| 1190 | - function add_adjusted_event(&$events,$event,$date_ymd) |
|
| 1189 | + function add_adjusted_event(&$events, $event, $date_ymd) |
|
| 1191 | 1190 | { |
| 1192 | 1191 | $event_in = $event; |
| 1193 | 1192 | // calculate the new start- and end-time |
| 1194 | 1193 | $length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']); |
| 1195 | 1194 | $event_start_arr = $this->date2array($event['start']); |
| 1196 | 1195 | |
| 1197 | - $date_arr = $this->date2array((string) $date_ymd); |
|
| 1196 | + $date_arr = $this->date2array((string)$date_ymd); |
|
| 1198 | 1197 | $date_arr['hour'] = $event_start_arr['hour']; |
| 1199 | 1198 | $date_arr['minute'] = $event_start_arr['minute']; |
| 1200 | 1199 | $date_arr['second'] = $event_start_arr['second']; |
| 1201 | - unset($date_arr['raw']); // else date2ts would use it |
|
| 1200 | + unset($date_arr['raw']); // else date2ts would use it |
|
| 1202 | 1201 | $event['start'] = $this->date2ts($date_arr); |
| 1203 | 1202 | $event['end'] = $event['start'] + $length_s; |
| 1204 | 1203 | |
@@ -1206,7 +1205,7 @@ discard block |
||
| 1206 | 1205 | |
| 1207 | 1206 | if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event')) |
| 1208 | 1207 | { |
| 1209 | - $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event); |
|
| 1208 | + $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event); |
|
| 1210 | 1209 | } |
| 1211 | 1210 | } |
| 1212 | 1211 | |
@@ -1230,22 +1229,22 @@ discard block |
||
| 1230 | 1229 | { |
| 1231 | 1230 | $info = array( |
| 1232 | 1231 | 'res_id' => $uid, |
| 1233 | - 'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'), |
|
| 1234 | - 'name' => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' . |
|
| 1235 | - $GLOBALS['egw']->accounts->id2name($uid,'account_lastname')), |
|
| 1232 | + 'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'), |
|
| 1233 | + 'name' => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
|
| 1234 | + $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')), |
|
| 1236 | 1235 | 'type' => $GLOBALS['egw']->accounts->get_type($uid), |
| 1237 | 1236 | 'app' => 'accounts', |
| 1238 | 1237 | ); |
| 1239 | 1238 | } |
| 1240 | 1239 | else |
| 1241 | 1240 | { |
| 1242 | - list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false; |
|
| 1241 | + list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false; |
|
| 1243 | 1242 | if ($info) |
| 1244 | 1243 | { |
| 1245 | 1244 | $info['type'] = $uid[0]; |
| 1246 | 1245 | if (!$info['email'] && $info['responsible']) |
| 1247 | 1246 | { |
| 1248 | - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); |
|
| 1247 | + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email'); |
|
| 1249 | 1248 | } |
| 1250 | 1249 | $info['app'] = $this->resources[$uid[0]]['app']; |
| 1251 | 1250 | } |
@@ -1254,7 +1253,7 @@ discard block |
||
| 1254 | 1253 | } |
| 1255 | 1254 | if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info')) |
| 1256 | 1255 | { |
| 1257 | - $this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]); |
|
| 1256 | + $this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]); |
|
| 1258 | 1257 | } |
| 1259 | 1258 | return $res_info_cache[$uid]; |
| 1260 | 1259 | } |
@@ -1275,7 +1274,7 @@ discard block |
||
| 1275 | 1274 | * @param int $user =null for which user to check, default current user |
| 1276 | 1275 | * @return boolean true permission granted, false for permission denied or null if event not found |
| 1277 | 1276 | */ |
| 1278 | - function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
|
| 1277 | + function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null) |
|
| 1279 | 1278 | { |
| 1280 | 1279 | if (!$user) $user = $this->user; |
| 1281 | 1280 | if ($user == $this->user) |
@@ -1284,13 +1283,13 @@ discard block |
||
| 1284 | 1283 | } |
| 1285 | 1284 | else |
| 1286 | 1285 | { |
| 1287 | - $grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user); |
|
| 1286 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1288 | 1287 | } |
| 1289 | 1288 | |
| 1290 | 1289 | if ($other && !is_numeric($other)) |
| 1291 | 1290 | { |
| 1292 | 1291 | $resource = $this->resource_info($other); |
| 1293 | - return $needed & $resource['rights']; |
|
| 1292 | + return $needed&$resource['rights']; |
|
| 1294 | 1293 | } |
| 1295 | 1294 | if (is_int($event) && $event == 0) |
| 1296 | 1295 | { |
@@ -1300,15 +1299,15 @@ discard block |
||
| 1300 | 1299 | { |
| 1301 | 1300 | if (!is_array($event)) |
| 1302 | 1301 | { |
| 1303 | - $event = $this->read($event,$date_to_read,true,$date_format); // = no ACL check !!! |
|
| 1302 | + $event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!! |
|
| 1304 | 1303 | } |
| 1305 | 1304 | if (!is_array($event)) |
| 1306 | 1305 | { |
| 1307 | 1306 | if ($this->xmlrpc) |
| 1308 | 1307 | { |
| 1309 | - $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']); |
|
| 1308 | + $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']); |
|
| 1310 | 1309 | } |
| 1311 | - return null; // event not found |
|
| 1310 | + return null; // event not found |
|
| 1312 | 1311 | } |
| 1313 | 1312 | $owner = $event['owner']; |
| 1314 | 1313 | $private = !$event['public']; |
@@ -1316,7 +1315,7 @@ discard block |
||
| 1316 | 1315 | $grant = $grants[$owner]; |
| 1317 | 1316 | |
| 1318 | 1317 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1319 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1318 | + if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1320 | 1319 | |
| 1321 | 1320 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1322 | 1321 | { |
@@ -1325,15 +1324,15 @@ discard block |
||
| 1325 | 1324 | // |
| 1326 | 1325 | if ($event['participants'] && is_array($event['participants'])) |
| 1327 | 1326 | { |
| 1328 | - foreach(array_keys($event['participants']) as $uid) |
|
| 1327 | + foreach (array_keys($event['participants']) as $uid) |
|
| 1329 | 1328 | { |
| 1330 | - if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true))) |
|
| 1329 | + if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true))) |
|
| 1331 | 1330 | { |
| 1332 | 1331 | // if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant |
| 1333 | - $grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT; |
|
| 1332 | + $grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT; |
|
| 1334 | 1333 | break; |
| 1335 | 1334 | } |
| 1336 | - elseif ($grants[$uid] & Acl::READ) |
|
| 1335 | + elseif ($grants[$uid]&Acl::READ) |
|
| 1337 | 1336 | { |
| 1338 | 1337 | // if we have a READ grant from a participant, we dont give an implicit privat grant too |
| 1339 | 1338 | $grant |= Acl::READ; |
@@ -1352,12 +1351,12 @@ discard block |
||
| 1352 | 1351 | } |
| 1353 | 1352 | if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD) |
| 1354 | 1353 | { |
| 1355 | - $access = False; // a group can't be the owner of an event |
|
| 1354 | + $access = False; // a group can't be the owner of an event |
|
| 1356 | 1355 | } |
| 1357 | 1356 | else |
| 1358 | 1357 | { |
| 1359 | - $access = $user == $owner || $grant & $needed |
|
| 1360 | - && ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT); |
|
| 1358 | + $access = $user == $owner || $grant&$needed |
|
| 1359 | + && ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT); |
|
| 1361 | 1360 | } |
| 1362 | 1361 | // do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled |
| 1363 | 1362 | if ($access && $needed == Acl::DELETE && $event['deleted'] && |
@@ -1368,7 +1367,7 @@ discard block |
||
| 1368 | 1367 | } |
| 1369 | 1368 | if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms')) |
| 1370 | 1369 | { |
| 1371 | - $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access); |
|
| 1370 | + $this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access); |
|
| 1372 | 1371 | } |
| 1373 | 1372 | //error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access)); |
| 1374 | 1373 | return $access; |
@@ -1383,9 +1382,9 @@ discard block |
||
| 1383 | 1382 | * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' |
| 1384 | 1383 | * @param boolean $user2server =False conversion between user- and server-time; default False == Off |
| 1385 | 1384 | */ |
| 1386 | - static function date2ts($date,$user2server=False) |
|
| 1385 | + static function date2ts($date, $user2server = False) |
|
| 1387 | 1386 | { |
| 1388 | - return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts'); |
|
| 1387 | + return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts'); |
|
| 1389 | 1388 | } |
| 1390 | 1389 | |
| 1391 | 1390 | /** |
@@ -1395,9 +1394,9 @@ discard block |
||
| 1395 | 1394 | * @param boolean $server2user conversation between user- and server-time default False == Off |
| 1396 | 1395 | * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string) |
| 1397 | 1396 | */ |
| 1398 | - static function date2array($date,$server2user=False) |
|
| 1397 | + static function date2array($date, $server2user = False) |
|
| 1399 | 1398 | { |
| 1400 | - return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array'); |
|
| 1399 | + return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array'); |
|
| 1401 | 1400 | } |
| 1402 | 1401 | |
| 1403 | 1402 | /** |
@@ -1408,9 +1407,9 @@ discard block |
||
| 1408 | 1407 | * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100) |
| 1409 | 1408 | * @return string date formatted according to $format |
| 1410 | 1409 | */ |
| 1411 | - static function date2string($date,$server2user=False,$format='Ymd') |
|
| 1410 | + static function date2string($date, $server2user = False, $format = 'Ymd') |
|
| 1412 | 1411 | { |
| 1413 | - return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format); |
|
| 1412 | + return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format); |
|
| 1414 | 1413 | } |
| 1415 | 1414 | |
| 1416 | 1415 | /** |
@@ -1420,9 +1419,9 @@ discard block |
||
| 1420 | 1419 | * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only |
| 1421 | 1420 | * @return string the formated date (incl. time) |
| 1422 | 1421 | */ |
| 1423 | - static function format_date($date,$format='') |
|
| 1422 | + static function format_date($date, $format = '') |
|
| 1424 | 1423 | { |
| 1425 | - return Api\DateTime::to($date,$format); |
|
| 1424 | + return Api\DateTime::to($date, $format); |
|
| 1426 | 1425 | } |
| 1427 | 1426 | |
| 1428 | 1427 | /** |
@@ -1444,7 +1443,7 @@ discard block |
||
| 1444 | 1443 | * @param mixed $param a variable number of parameters, to be inserted in $msg |
| 1445 | 1444 | * arrays get serialized with print_r() ! |
| 1446 | 1445 | */ |
| 1447 | - static function debug_message($msg,$backtrace=True) |
|
| 1446 | + static function debug_message($msg, $backtrace = True) |
|
| 1448 | 1447 | { |
| 1449 | 1448 | static $acl2string = array( |
| 1450 | 1449 | 0 => 'ACL-UNKNOWN', |
@@ -1455,22 +1454,22 @@ discard block |
||
| 1455 | 1454 | Acl::PRIVAT => 'ACL_PRIVATE', |
| 1456 | 1455 | self::ACL_FREEBUSY => 'ACL_FREEBUSY', |
| 1457 | 1456 | ); |
| 1458 | - for($i = 2; $i < func_num_args(); ++$i) |
|
| 1457 | + for ($i = 2; $i < func_num_args(); ++$i) |
|
| 1459 | 1458 | { |
| 1460 | 1459 | $param = func_get_arg($i); |
| 1461 | 1460 | |
| 1462 | 1461 | if (is_null($param)) |
| 1463 | 1462 | { |
| 1464 | - $param='NULL'; |
|
| 1463 | + $param = 'NULL'; |
|
| 1465 | 1464 | } |
| 1466 | 1465 | else |
| 1467 | 1466 | { |
| 1468 | - switch(gettype($param)) |
|
| 1467 | + switch (gettype($param)) |
|
| 1469 | 1468 | { |
| 1470 | 1469 | case 'string': |
| 1471 | - if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER) |
|
| 1470 | + if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER) |
|
| 1472 | 1471 | { |
| 1473 | - $param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER)); |
|
| 1472 | + $param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER)); |
|
| 1474 | 1473 | $param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)"; |
| 1475 | 1474 | } |
| 1476 | 1475 | else |
@@ -1493,11 +1492,11 @@ discard block |
||
| 1493 | 1492 | $param = $param ? 'True' : 'False'; |
| 1494 | 1493 | break; |
| 1495 | 1494 | case 'integer': |
| 1496 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1495 | + if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)"; |
|
| 1497 | 1496 | break; |
| 1498 | 1497 | } |
| 1499 | 1498 | } |
| 1500 | - $msg = str_replace('%'.($i-1),$param,$msg); |
|
| 1499 | + $msg = str_replace('%'.($i - 1), $param, $msg); |
|
| 1501 | 1500 | } |
| 1502 | 1501 | error_log($msg); |
| 1503 | 1502 | if ($backtrace) error_log(function_backtrace(1)); |
@@ -1512,7 +1511,7 @@ discard block |
||
| 1512 | 1511 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
| 1513 | 1512 | * @return string with formated date |
| 1514 | 1513 | */ |
| 1515 | - function long_date($_first,$last=0,$display_time=false,$display_day=false) |
|
| 1514 | + function long_date($_first, $last = 0, $display_time = false, $display_day = false) |
|
| 1516 | 1515 | { |
| 1517 | 1516 | $first = $this->date2array($_first); |
| 1518 | 1517 | if ($last) |
@@ -1527,27 +1526,27 @@ discard block |
||
| 1527 | 1526 | |
| 1528 | 1527 | if ($display_day) |
| 1529 | 1528 | { |
| 1530 | - $range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
| 1529 | + $range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
| 1531 | 1530 | } |
| 1532 | 1531 | for ($i = 0; $i < 5; $i += 2) |
| 1533 | 1532 | { |
| 1534 | - switch($datefmt[$i]) |
|
| 1533 | + switch ($datefmt[$i]) |
|
| 1535 | 1534 | { |
| 1536 | 1535 | case 'd': |
| 1537 | - $range .= $first['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
| 1536 | + $range .= $first['day'].($datefmt[1] == '.' ? '.' : ''); |
|
| 1538 | 1537 | if ($first['month'] != $last['month'] || $first['year'] != $last['year']) |
| 1539 | 1538 | { |
| 1540 | 1539 | if (!$month_before_day) |
| 1541 | 1540 | { |
| 1542 | - $range .= ' '.lang(strftime('%B',$first['raw'])); |
|
| 1541 | + $range .= ' '.lang(strftime('%B', $first['raw'])); |
|
| 1543 | 1542 | } |
| 1544 | 1543 | if ($first['year'] != $last['year'] && $datefmt[0] != 'Y') |
| 1545 | 1544 | { |
| 1546 | - $range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year']; |
|
| 1545 | + $range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year']; |
|
| 1547 | 1546 | } |
| 1548 | 1547 | if ($display_time) |
| 1549 | 1548 | { |
| 1550 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
| 1549 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
| 1551 | 1550 | } |
| 1552 | 1551 | if (!$last) |
| 1553 | 1552 | { |
@@ -1557,43 +1556,43 @@ discard block |
||
| 1557 | 1556 | |
| 1558 | 1557 | if ($first['year'] != $last['year'] && $datefmt[0] == 'Y') |
| 1559 | 1558 | { |
| 1560 | - $range .= $last['year'] . ', '; |
|
| 1559 | + $range .= $last['year'].', '; |
|
| 1561 | 1560 | } |
| 1562 | 1561 | |
| 1563 | 1562 | if ($month_before_day) |
| 1564 | 1563 | { |
| 1565 | - $range .= lang(strftime('%B',$last['raw'])); |
|
| 1564 | + $range .= lang(strftime('%B', $last['raw'])); |
|
| 1566 | 1565 | } |
| 1567 | 1566 | } |
| 1568 | 1567 | else |
| 1569 | 1568 | { |
| 1570 | 1569 | if ($display_time) |
| 1571 | 1570 | { |
| 1572 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
| 1571 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
| 1573 | 1572 | } |
| 1574 | 1573 | $range .= ' - '; |
| 1575 | 1574 | } |
| 1576 | - $range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
| 1575 | + $range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : ''); |
|
| 1577 | 1576 | break; |
| 1578 | 1577 | case 'm': |
| 1579 | 1578 | case 'M': |
| 1580 | - $range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' '; |
|
| 1579 | + $range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' '; |
|
| 1581 | 1580 | break; |
| 1582 | 1581 | case 'Y': |
| 1583 | 1582 | if ($datefmt[0] != 'm') |
| 1584 | 1583 | { |
| 1585 | - $range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
| 1584 | + $range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
| 1586 | 1585 | } |
| 1587 | 1586 | break; |
| 1588 | 1587 | } |
| 1589 | 1588 | } |
| 1590 | 1589 | if ($display_time && $last) |
| 1591 | 1590 | { |
| 1592 | - $range .= ' '.adodb_date($timefmt,$last['raw']); |
|
| 1591 | + $range .= ' '.adodb_date($timefmt, $last['raw']); |
|
| 1593 | 1592 | } |
| 1594 | 1593 | if ($datefmt[4] == 'Y' && $datefmt[0] == 'm') |
| 1595 | 1594 | { |
| 1596 | - $range .= ', ' . $last['year']; |
|
| 1595 | + $range .= ', '.$last['year']; |
|
| 1597 | 1596 | } |
| 1598 | 1597 | return $range; |
| 1599 | 1598 | } |
@@ -1605,25 +1604,25 @@ discard block |
||
| 1605 | 1604 | * @param int $end_m end time in minutes since 0h |
| 1606 | 1605 | * @param boolean $both =false display the end-time too, duration is always displayed |
| 1607 | 1606 | */ |
| 1608 | - function timespan($start_m,$end_m,$both=false) |
|
| 1607 | + function timespan($start_m, $end_m, $both = false) |
|
| 1609 | 1608 | { |
| 1610 | 1609 | $duration = $end_m - $start_m; |
| 1611 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1612 | - $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
| 1610 | + if ($end_m == 24 * 60 - 1) ++$duration; |
|
| 1611 | + $duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
| 1613 | 1612 | |
| 1614 | - $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
|
| 1613 | + $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false); |
|
| 1615 | 1614 | |
| 1616 | 1615 | if ($both) // end-time too |
| 1617 | 1616 | { |
| 1618 | - $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
|
| 1617 | + $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false); |
|
| 1619 | 1618 | // dont double am/pm if they are the same in both times |
| 1620 | - if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
|
| 1619 | + if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2)) |
|
| 1621 | 1620 | { |
| 1622 | - $timespan = str_replace($t,substr($t,0,-3),$timespan); |
|
| 1621 | + $timespan = str_replace($t, substr($t, 0, -3), $timespan); |
|
| 1623 | 1622 | } |
| 1624 | 1623 | $timespan .= ':'; |
| 1625 | 1624 | } |
| 1626 | - return $timespan . ' ' . $duration; |
|
| 1625 | + return $timespan.' '.$duration; |
|
| 1627 | 1626 | } |
| 1628 | 1627 | |
| 1629 | 1628 | /** |
@@ -1634,7 +1633,7 @@ discard block |
||
| 1634 | 1633 | * @param boolean $append_email =false append email (Name <email>) |
| 1635 | 1634 | * @return string with name |
| 1636 | 1635 | */ |
| 1637 | - function participant_name($id,$use_type=false, $append_email=false) |
|
| 1636 | + function participant_name($id, $use_type = false, $append_email = false) |
|
| 1638 | 1637 | { |
| 1639 | 1638 | static $id2lid = array(); |
| 1640 | 1639 | static $id2email = array(); |
@@ -1655,7 +1654,7 @@ discard block |
||
| 1655 | 1654 | else |
| 1656 | 1655 | { |
| 1657 | 1656 | $id2lid[$id] = Api\Accounts::username($id); |
| 1658 | - $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email'); |
|
| 1657 | + $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email'); |
|
| 1659 | 1658 | } |
| 1660 | 1659 | } |
| 1661 | 1660 | return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : ''); |
@@ -1669,37 +1668,37 @@ discard block |
||
| 1669 | 1668 | * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
| 1670 | 1669 | * @return array with id / names with status pairs |
| 1671 | 1670 | */ |
| 1672 | - function participants($event,$long_status=false,$show_group_invitation=false) |
|
| 1671 | + function participants($event, $long_status = false, $show_group_invitation = false) |
|
| 1673 | 1672 | { |
| 1674 | 1673 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
| 1675 | 1674 | $names = array(); |
| 1676 | - foreach((array)$event['participants'] as $id => $status) |
|
| 1675 | + foreach ((array)$event['participants'] as $id => $status) |
|
| 1677 | 1676 | { |
| 1678 | 1677 | if (!is_string($status)) continue; |
| 1679 | 1678 | $quantity = $role = null; |
| 1680 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1679 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1681 | 1680 | |
| 1682 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1681 | + if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1683 | 1682 | |
| 1684 | 1683 | $lang_status = lang($this->verbose_status[$status]); |
| 1685 | 1684 | if (!$long_status) |
| 1686 | 1685 | { |
| 1687 | - switch($status[0]) |
|
| 1686 | + switch ($status[0]) |
|
| 1688 | 1687 | { |
| 1689 | 1688 | case 'A': // accepted |
| 1690 | - $status = Api\Html::image('calendar','accepted',$lang_status); |
|
| 1689 | + $status = Api\Html::image('calendar', 'accepted', $lang_status); |
|
| 1691 | 1690 | break; |
| 1692 | 1691 | case 'R': // rejected |
| 1693 | - $status = Api\Html::image('calendar','rejected',$lang_status); |
|
| 1692 | + $status = Api\Html::image('calendar', 'rejected', $lang_status); |
|
| 1694 | 1693 | break; |
| 1695 | 1694 | case 'T': // tentative |
| 1696 | - $status = Api\Html::image('calendar','tentative',$lang_status); |
|
| 1695 | + $status = Api\Html::image('calendar', 'tentative', $lang_status); |
|
| 1697 | 1696 | break; |
| 1698 | 1697 | case 'U': // no response = unknown |
| 1699 | - $status = Api\Html::image('calendar','needs-action',$lang_status); |
|
| 1698 | + $status = Api\Html::image('calendar', 'needs-action', $lang_status); |
|
| 1700 | 1699 | break; |
| 1701 | 1700 | case 'D': // delegated |
| 1702 | - $status = Api\Html::image('calendar','forward',$lang_status); |
|
| 1701 | + $status = Api\Html::image('calendar', 'forward', $lang_status); |
|
| 1703 | 1702 | break; |
| 1704 | 1703 | case 'G': // group invitation |
| 1705 | 1704 | // Todo: Image, seems not to be used |
@@ -1721,13 +1720,13 @@ discard block |
||
| 1721 | 1720 | $role = lang($this->roles[$role]); |
| 1722 | 1721 | } |
| 1723 | 1722 | // allow to use cats as roles (beside regular iCal ones) |
| 1724 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
| 1723 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
| 1725 | 1724 | { |
| 1726 | 1725 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
| 1727 | 1726 | } |
| 1728 | 1727 | else |
| 1729 | 1728 | { |
| 1730 | - $role = lang(str_replace('X-','',$role)); |
|
| 1729 | + $role = lang(str_replace('X-', '', $role)); |
|
| 1731 | 1730 | } |
| 1732 | 1731 | $names[$id] .= ' '.$role; |
| 1733 | 1732 | } |
@@ -1744,13 +1743,13 @@ discard block |
||
| 1744 | 1743 | * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
| 1745 | 1744 | * @return array with id / names |
| 1746 | 1745 | */ |
| 1747 | - function categories($category,&$color) |
|
| 1746 | + function categories($category, &$color) |
|
| 1748 | 1747 | { |
| 1749 | 1748 | static $id2cat = array(); |
| 1750 | 1749 | $cats = array(); |
| 1751 | 1750 | $color = 0; |
| 1752 | 1751 | |
| 1753 | - foreach(explode(',',$category) as $cat_id) |
|
| 1752 | + foreach (explode(',', $category) as $cat_id) |
|
| 1754 | 1753 | { |
| 1755 | 1754 | if (!$cat_id) continue; |
| 1756 | 1755 | |
@@ -1765,7 +1764,7 @@ discard block |
||
| 1765 | 1764 | { |
| 1766 | 1765 | $color = $cat['data']['color']; |
| 1767 | 1766 | } |
| 1768 | - elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
| 1767 | + elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
| 1769 | 1768 | { |
| 1770 | 1769 | $color = $parts[1]; |
| 1771 | 1770 | } |
@@ -1777,12 +1776,12 @@ discard block |
||
| 1777 | 1776 | /** |
| 1778 | 1777 | * This is called only by list_cals(). It was moved here to remove fatal error in php5 beta4 |
| 1779 | 1778 | */ |
| 1780 | - private static function _list_cals_add($id,&$users,&$groups) |
|
| 1779 | + private static function _list_cals_add($id, &$users, &$groups) |
|
| 1781 | 1780 | { |
| 1782 | 1781 | $name = Api\Accounts::username($id); |
| 1783 | 1782 | if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id))) |
| 1784 | 1783 | { |
| 1785 | - return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
| 1784 | + return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
| 1786 | 1785 | } |
| 1787 | 1786 | if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g') |
| 1788 | 1787 | { |
@@ -1794,7 +1793,7 @@ discard block |
||
| 1794 | 1793 | } |
| 1795 | 1794 | $arr[$id] = array( |
| 1796 | 1795 | 'grantor' => $id, |
| 1797 | - 'value' => ($type == 'g' ? 'g_' : '') . $id, |
|
| 1796 | + 'value' => ($type == 'g' ? 'g_' : '').$id, |
|
| 1798 | 1797 | 'name' => $name, |
| 1799 | 1798 | 'sname' => $egw_name |
| 1800 | 1799 | ); |
@@ -1816,26 +1815,26 @@ discard block |
||
| 1816 | 1815 | * @param int $user account_id of user to generate list for |
| 1817 | 1816 | * @param array $grants =null calendar grants from user, or null to query them from acl class |
| 1818 | 1817 | */ |
| 1819 | - public static function list_calendars($user, array $grants=null) |
|
| 1818 | + public static function list_calendars($user, array $grants = null) |
|
| 1820 | 1819 | { |
| 1821 | 1820 | if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
| 1822 | 1821 | |
| 1823 | 1822 | $users = $groups = array(); |
| 1824 | - foreach(array_keys($grants) as $id) |
|
| 1823 | + foreach (array_keys($grants) as $id) |
|
| 1825 | 1824 | { |
| 1826 | - self::_list_cals_add($id,$users,$groups); |
|
| 1825 | + self::_list_cals_add($id, $users, $groups); |
|
| 1827 | 1826 | } |
| 1828 | 1827 | if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true))) |
| 1829 | 1828 | { |
| 1830 | - foreach($memberships as $group) |
|
| 1829 | + foreach ($memberships as $group) |
|
| 1831 | 1830 | { |
| 1832 | - self::_list_cals_add($group,$users,$groups); |
|
| 1831 | + self::_list_cals_add($group, $users, $groups); |
|
| 1833 | 1832 | |
| 1834 | - if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar'))) |
|
| 1833 | + if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar'))) |
|
| 1835 | 1834 | { |
| 1836 | - foreach($account_perms as $id) |
|
| 1835 | + foreach ($account_perms as $id) |
|
| 1837 | 1836 | { |
| 1838 | - self::_list_cals_add($id,$users,$groups); |
|
| 1837 | + self::_list_cals_add($id, $users, $groups); |
|
| 1839 | 1838 | } |
| 1840 | 1839 | } |
| 1841 | 1840 | } |
@@ -1843,7 +1842,7 @@ discard block |
||
| 1843 | 1842 | usort($users, array(__CLASS__, 'name_cmp')); |
| 1844 | 1843 | usort($groups, array(__CLASS__, 'name_cmp')); |
| 1845 | 1844 | |
| 1846 | - return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
| 1845 | + return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
| 1847 | 1846 | } |
| 1848 | 1847 | |
| 1849 | 1848 | /** |
@@ -1883,28 +1882,27 @@ discard block |
||
| 1883 | 1882 | * month: numerical month |
| 1884 | 1883 | * occurence: numerical year or 0 for every year |
| 1885 | 1884 | */ |
| 1886 | - function read_holidays($year=0) |
|
| 1885 | + function read_holidays($year = 0) |
|
| 1887 | 1886 | { |
| 1888 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 1887 | + if (!$year) $year = (int)date('Y', $this->now_su); |
|
| 1889 | 1888 | |
| 1890 | 1889 | $holidays = calendar_holidays::read( |
| 1891 | 1890 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
| 1892 | - $GLOBALS['egw_info']['server']['ical_holiday_url'] : |
|
| 1893 | - $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
| 1891 | + $GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
| 1894 | 1892 | |
| 1895 | 1893 | // search for birthdays |
| 1896 | 1894 | if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') |
| 1897 | 1895 | { |
| 1898 | 1896 | $contacts = new Api\Contacts(); |
| 1899 | - foreach($contacts->get_addressbooks() as $owner => $name) |
|
| 1897 | + foreach ($contacts->get_addressbooks() as $owner => $name) |
|
| 1900 | 1898 | { |
| 1901 | 1899 | $holidays += $contacts->read_birthdays($owner, $year); |
| 1902 | 1900 | } |
| 1903 | 1901 | } |
| 1904 | 1902 | |
| 1905 | - if ((int) $this->debug >= 2 || $this->debug == 'read_holidays') |
|
| 1903 | + if ((int)$this->debug >= 2 || $this->debug == 'read_holidays') |
|
| 1906 | 1904 | { |
| 1907 | - $this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$holidays); |
|
| 1905 | + $this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $holidays); |
|
| 1908 | 1906 | } |
| 1909 | 1907 | return $holidays; |
| 1910 | 1908 | } |
@@ -1915,10 +1913,10 @@ discard block |
||
| 1915 | 1913 | * @param type $event |
| 1916 | 1914 | * @return array array of selected calendar fields |
| 1917 | 1915 | */ |
| 1918 | - public static function get_link_options ($event = array()) |
|
| 1916 | + public static function get_link_options($event = array()) |
|
| 1919 | 1917 | { |
| 1920 | - unset($event); // not used, but required by function signature |
|
| 1921 | - $options = array ( |
|
| 1918 | + unset($event); // not used, but required by function signature |
|
| 1919 | + $options = array( |
|
| 1922 | 1920 | 'end' => lang('End date'), |
| 1923 | 1921 | 'id' => lang('ID'), |
| 1924 | 1922 | 'owner' => lang('Event owner'), |
@@ -1945,7 +1943,7 @@ discard block |
||
| 1945 | 1943 | list($id, $recur) = explode('-', $event, 2); |
| 1946 | 1944 | $event = $this->read($id, $recur); |
| 1947 | 1945 | } |
| 1948 | - else if (!is_array($event) && (int) $event > 0) |
|
| 1946 | + else if (!is_array($event) && (int)$event > 0) |
|
| 1949 | 1947 | { |
| 1950 | 1948 | $event = $this->read($event); |
| 1951 | 1949 | } |
@@ -1953,7 +1951,7 @@ discard block |
||
| 1953 | 1951 | { |
| 1954 | 1952 | return $event; |
| 1955 | 1953 | } |
| 1956 | - $type = explode(',',$this->cal_prefs['link_title']); |
|
| 1954 | + $type = explode(',', $this->cal_prefs['link_title']); |
|
| 1957 | 1955 | if (is_array($type)) |
| 1958 | 1956 | { |
| 1959 | 1957 | foreach ($type as &$val) |
@@ -1979,10 +1977,10 @@ discard block |
||
| 1979 | 1977 | $extra_fields [] = $event[$val]; |
| 1980 | 1978 | } |
| 1981 | 1979 | } |
| 1982 | - $str_fields = implode(', ',$extra_fields); |
|
| 1983 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 1980 | + $str_fields = implode(', ', $extra_fields); |
|
| 1981 | + if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : ''); |
|
| 1984 | 1982 | } |
| 1985 | - return $this->format_date($event['start']) . ': ' . $event['title']; |
|
| 1983 | + return $this->format_date($event['start']).': '.$event['title']; |
|
| 1986 | 1984 | } |
| 1987 | 1985 | |
| 1988 | 1986 | /** |
@@ -2001,10 +1999,10 @@ discard block |
||
| 2001 | 1999 | 'offset' => $options['start'], |
| 2002 | 2000 | 'order' => 'cal_start DESC', |
| 2003 | 2001 | ); |
| 2004 | - if($options['num_rows']) { |
|
| 2002 | + if ($options['num_rows']) { |
|
| 2005 | 2003 | $query['num_rows'] = $options['num_rows']; |
| 2006 | 2004 | } |
| 2007 | - foreach((array) $this->search($query) as $event) |
|
| 2005 | + foreach ((array)$this->search($query) as $event) |
|
| 2008 | 2006 | { |
| 2009 | 2007 | $result[$event['id']] = $this->link_title($event); |
| 2010 | 2008 | } |
@@ -2021,11 +2019,11 @@ discard block |
||
| 2021 | 2019 | * @param int $user =null for which user to check, default current user |
| 2022 | 2020 | * @return boolean true if access is granted or false otherwise |
| 2023 | 2021 | */ |
| 2024 | - function file_access($id,$check,$rel_path,$user=null) |
|
| 2022 | + function file_access($id, $check, $rel_path, $user = null) |
|
| 2025 | 2023 | { |
| 2026 | - unset($rel_path); // not used, but required by function signature |
|
| 2024 | + unset($rel_path); // not used, but required by function signature |
|
| 2027 | 2025 | |
| 2028 | - return $this->check_perms($check,$id,0,'ts',null,$user); |
|
| 2026 | + return $this->check_perms($check, $id, 0, 'ts', null, $user); |
|
| 2029 | 2027 | } |
| 2030 | 2028 | |
| 2031 | 2029 | /** |
@@ -2041,36 +2039,36 @@ discard block |
||
| 2041 | 2039 | } |
| 2042 | 2040 | Api\Cache::setSession('calendar', 'default_prefs_set', 'set'); |
| 2043 | 2041 | |
| 2044 | - $default_prefs =& $GLOBALS['egw']->preferences->default['calendar']; |
|
| 2045 | - $forced_prefs =& $GLOBALS['egw']->preferences->forced['calendar']; |
|
| 2042 | + $default_prefs = & $GLOBALS['egw']->preferences->default['calendar']; |
|
| 2043 | + $forced_prefs = & $GLOBALS['egw']->preferences->forced['calendar']; |
|
| 2046 | 2044 | |
| 2047 | - $subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
| 2045 | + $subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
| 2048 | 2046 | $values = array( |
| 2049 | - 'notifyAdded' => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'), |
|
| 2050 | - 'notifyCanceled' => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'), |
|
| 2051 | - 'notifyModified' => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'), |
|
| 2052 | - 'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'), |
|
| 2053 | - 'notifyResponse' => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'), |
|
| 2054 | - 'notifyAlarm' => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'), |
|
| 2047 | + 'notifyAdded' => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'), |
|
| 2048 | + 'notifyCanceled' => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'), |
|
| 2049 | + 'notifyModified' => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'), |
|
| 2050 | + 'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'), |
|
| 2051 | + 'notifyResponse' => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'), |
|
| 2052 | + 'notifyAlarm' => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'), |
|
| 2055 | 2053 | 'interval' => 30, |
| 2056 | 2054 | ); |
| 2057 | - foreach($values as $var => $default) |
|
| 2055 | + foreach ($values as $var => $default) |
|
| 2058 | 2056 | { |
| 2059 | - $type = substr($var,0,6) == 'notify' ? 'forced' : 'default'; |
|
| 2057 | + $type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default'; |
|
| 2060 | 2058 | |
| 2061 | 2059 | // only set, if neither default nor forced pref exists |
| 2062 | 2060 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 2063 | 2061 | { |
| 2064 | - $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
|
| 2065 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2062 | + $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too |
|
| 2063 | + if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced'); |
|
| 2066 | 2064 | $this->cal_prefs[$var] = $default; |
| 2067 | 2065 | $need_save = True; |
| 2068 | 2066 | } |
| 2069 | 2067 | } |
| 2070 | 2068 | if ($need_save) |
| 2071 | 2069 | { |
| 2072 | - $GLOBALS['egw']->preferences->save_repository(False,'default'); |
|
| 2073 | - $GLOBALS['egw']->preferences->save_repository(False,'forced'); |
|
| 2070 | + $GLOBALS['egw']->preferences->save_repository(False, 'default'); |
|
| 2071 | + $GLOBALS['egw']->preferences->save_repository(False, 'forced'); |
|
| 2074 | 2072 | } |
| 2075 | 2073 | } |
| 2076 | 2074 | |
@@ -2080,7 +2078,7 @@ discard block |
||
| 2080 | 2078 | * @param int|string $user account_id or account_lid |
| 2081 | 2079 | * @param string $pw =null password |
| 2082 | 2080 | */ |
| 2083 | - static function freebusy_url($user='',$pw=null) |
|
| 2081 | + static function freebusy_url($user = '', $pw = null) |
|
| 2084 | 2082 | { |
| 2085 | 2083 | if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
| 2086 | 2084 | |
@@ -2093,8 +2091,8 @@ discard block |
||
| 2093 | 2091 | elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2) |
| 2094 | 2092 | { |
| 2095 | 2093 | $credentials = $GLOBALS['egw_info']['user']['account_lid'] |
| 2096 | - . ':' . $GLOBALS['egw_info']['user']['passwd']; |
|
| 2097 | - $credentials = '&cred=' . base64_encode($credentials); |
|
| 2094 | + . ':'.$GLOBALS['egw_info']['user']['passwd']; |
|
| 2095 | + $credentials = '&cred='.base64_encode($credentials); |
|
| 2098 | 2096 | } |
| 2099 | 2097 | return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ? |
| 2100 | 2098 | ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : ''). |
@@ -2126,11 +2124,11 @@ discard block |
||
| 2126 | 2124 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
| 2127 | 2125 | * @return string|boolean string with etag or false |
| 2128 | 2126 | */ |
| 2129 | - function get_etag($entry, &$schedule_tag=null) |
|
| 2127 | + function get_etag($entry, &$schedule_tag = null) |
|
| 2130 | 2128 | { |
| 2131 | 2129 | if (!is_array($entry)) |
| 2132 | 2130 | { |
| 2133 | - list($id,$recur_date) = explode(':',$entry); |
|
| 2131 | + list($id, $recur_date) = explode(':', $entry); |
|
| 2134 | 2132 | $entry = $this->read($id, $recur_date, true, 'server'); |
| 2135 | 2133 | } |
| 2136 | 2134 | $etag = $schedule_tag = $entry['id'].':'.$entry['etag']; |
@@ -2148,15 +2146,15 @@ discard block |
||
| 2148 | 2146 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
| 2149 | 2147 | * @return integer |
| 2150 | 2148 | */ |
| 2151 | - public function get_ctag($user, $filter='owner', $master_only=false) |
|
| 2149 | + public function get_ctag($user, $filter = 'owner', $master_only = false) |
|
| 2152 | 2150 | { |
| 2153 | 2151 | if ($this->debug > 1) $startime = microtime(true); |
| 2154 | 2152 | |
| 2155 | 2153 | // resolve users to add memberships for users and members for groups |
| 2156 | 2154 | $users = $this->resolve_users($user); |
| 2157 | - $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
| 2155 | + $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
| 2158 | 2156 | |
| 2159 | - if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2157 | + if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs"); |
|
| 2160 | 2158 | return $ctag; |
| 2161 | 2159 | } |
| 2162 | 2160 | |
@@ -2176,7 +2174,7 @@ discard block |
||
| 2176 | 2174 | |
| 2177 | 2175 | $content = array( |
| 2178 | 2176 | 'info_cat' => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']), |
| 2179 | - 'info_priority' => $calendar['priority'] , |
|
| 2177 | + 'info_priority' => $calendar['priority'], |
|
| 2180 | 2178 | 'info_public' => $calendar['public'] != 'private', |
| 2181 | 2179 | 'info_subject' => $calendar['title'], |
| 2182 | 2180 | 'info_des' => $calendar['description'], |
@@ -2191,7 +2189,7 @@ discard block |
||
| 2191 | 2189 | $content['link_app'][] = $calendar['info_link']['app']; |
| 2192 | 2190 | $content['link_id'][] = $calendar['info_link']['id']; |
| 2193 | 2191 | // Copy claendar's links |
| 2194 | - foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link) |
|
| 2192 | + foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link) |
|
| 2195 | 2193 | { |
| 2196 | 2194 | if ($link['app'] != Link::VFS_APPNAME) |
| 2197 | 2195 | { |
@@ -2204,7 +2202,7 @@ discard block |
||
| 2204 | 2202 | } |
| 2205 | 2203 | } |
| 2206 | 2204 | // Copy same custom fields |
| 2207 | - foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
| 2205 | + foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
| 2208 | 2206 | { |
| 2209 | 2207 | if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
| 2210 | 2208 | } |
@@ -2222,20 +2220,20 @@ discard block |
||
| 2222 | 2220 | function timesheet_set($data) |
| 2223 | 2221 | { |
| 2224 | 2222 | $set = array(); |
| 2225 | - list($id,$recurrence) = explode(':',$data['id']); |
|
| 2226 | - if ((int)$id && ($event = $this->read($id,$recurrence))) |
|
| 2223 | + list($id, $recurrence) = explode(':', $data['id']); |
|
| 2224 | + if ((int)$id && ($event = $this->read($id, $recurrence))) |
|
| 2227 | 2225 | { |
| 2228 | 2226 | $set['ts_start'] = $event['start']; |
| 2229 | 2227 | $set['ts_title'] = $this->link_title($event); |
| 2230 | - $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
|
| 2228 | + $set['start_time'] = Api\DateTime::to($event['start'], 'H:i'); |
|
| 2231 | 2229 | $set['ts_description'] = $event['description']; |
| 2232 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2230 | + if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2233 | 2231 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2234 | 2232 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2235 | - $set['end_time'] = null; // unset end-time |
|
| 2233 | + $set['end_time'] = null; // unset end-time |
|
| 2236 | 2234 | $set['cat_id'] = (int)$event['category']; |
| 2237 | 2235 | |
| 2238 | - foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link) |
|
| 2236 | + foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link) |
|
| 2239 | 2237 | { |
| 2240 | 2238 | if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME) |
| 2241 | 2239 | { |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | use EGroupware\Api\Acl; |
| 17 | 17 | |
| 18 | 18 | // types of messsages send by calendar_boupdate::send_update |
| 19 | -define('MSG_DELETED',0); |
|
| 20 | -define('MSG_MODIFIED',1); |
|
| 21 | -define('MSG_ADDED',2); |
|
| 22 | -define('MSG_REJECTED',3); |
|
| 23 | -define('MSG_TENTATIVE',4); |
|
| 24 | -define('MSG_ACCEPTED',5); |
|
| 25 | -define('MSG_ALARM',6); |
|
| 26 | -define('MSG_DISINVITE',7); |
|
| 27 | -define('MSG_DELEGATED',8); |
|
| 19 | +define('MSG_DELETED', 0); |
|
| 20 | +define('MSG_MODIFIED', 1); |
|
| 21 | +define('MSG_ADDED', 2); |
|
| 22 | +define('MSG_REJECTED', 3); |
|
| 23 | +define('MSG_TENTATIVE', 4); |
|
| 24 | +define('MSG_ACCEPTED', 5); |
|
| 25 | +define('MSG_ALARM', 6); |
|
| 26 | +define('MSG_DISINVITE', 7); |
|
| 27 | +define('MSG_DELEGATED', 8); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Class to access AND manipulate all calendar data (business object) |
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started', True); |
|
| 89 | 89 | |
| 90 | - parent::__construct(); // calling the parent constructor |
|
| 90 | + parent::__construct(); // calling the parent constructor |
|
| 91 | 91 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 92 | + if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished', True); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * + + + C + which is clearly wrong for everything with a maximum quantity > 1 |
| 117 | 117 | * ++++++++ ++++++++ |
| 118 | 118 | */ |
| 119 | - function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
|
| 119 | + function update(&$event, $ignore_conflicts = false, $touch_modified = true, $ignore_acl = false, $updateTS = true, &$messages = null, $skip_notification = false) |
|
| 120 | 120 | { |
| 121 | 121 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 122 | 122 | if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if ($this->debug > 1 || $this->debug == 'update') |
| 125 | 125 | { |
| 126 | 126 | $this->debug_message('calendar_boupdate::update(%1,ignore_conflict=%2,touch_modified=%3,ignore_acl=%4)', |
| 127 | - false,$event,$ignore_conflicts,$touch_modified,$ignore_acl); |
|
| 127 | + false, $event, $ignore_conflicts, $touch_modified, $ignore_acl); |
|
| 128 | 128 | } |
| 129 | 129 | // check some minimum requirements: |
| 130 | 130 | // - new events need start, end and title |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // check if user has the permission to update / create the event |
| 155 | - if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 156 | - $new_event && !$this->check_perms(Acl::EDIT,0,$event['owner'])) && |
|
| 157 | - !$this->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 155 | + if (!$ignore_acl && (!$new_event && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 156 | + $new_event && !$this->check_perms(Acl::EDIT, 0, $event['owner'])) && |
|
| 157 | + !$this->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 158 | 158 | { |
| 159 | - $messages[] = lang('Access to calendar of %1 denied!',Api\Accounts::username($event['owner'])); |
|
| 159 | + $messages[] = lang('Access to calendar of %1 denied!', Api\Accounts::username($event['owner'])); |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | if ($new_event) |
@@ -165,24 +165,24 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | else |
| 167 | 167 | { |
| 168 | - $old_event = $this->read((int)$event['id'],null,$ignore_acl); |
|
| 168 | + $old_event = $this->read((int)$event['id'], null, $ignore_acl); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | // do we need to check, if user is allowed to invite the invited participants |
| 172 | - if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event,$old_event))) |
|
| 172 | + if ($this->require_acl_invite && ($removed = $this->remove_no_acl_invite($event, $old_event))) |
|
| 173 | 173 | { |
| 174 | 174 | // report removed participants back to user |
| 175 | - foreach($removed as $key => $account_id) |
|
| 175 | + foreach ($removed as $key => $account_id) |
|
| 176 | 176 | { |
| 177 | 177 | $removed[$key] = $this->participant_name($account_id); |
| 178 | 178 | } |
| 179 | - $messages[] = lang('%1 participants removed because of missing invite grants',count($removed)). |
|
| 180 | - ': '.implode(', ',$removed); |
|
| 179 | + $messages[] = lang('%1 participants removed because of missing invite grants', count($removed)). |
|
| 180 | + ': '.implode(', ', $removed); |
|
| 181 | 181 | } |
| 182 | 182 | // check category based ACL |
| 183 | 183 | if ($event['category']) |
| 184 | 184 | { |
| 185 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 185 | + if (!is_array($event['category'])) $event['category'] = explode(',', $event['category']); |
|
| 186 | 186 | if (!$old_event || !isset($old_event['category'])) |
| 187 | 187 | { |
| 188 | 188 | $old_event['category'] = array(); |
@@ -191,38 +191,38 @@ discard block |
||
| 191 | 191 | { |
| 192 | 192 | $old_event['category'] = explode(',', $old_event['category']); |
| 193 | 193 | } |
| 194 | - foreach($event['category'] as $key => $cat_id) |
|
| 194 | + foreach ($event['category'] as $key => $cat_id) |
|
| 195 | 195 | { |
| 196 | 196 | // check if user is allowed to update event categories |
| 197 | - if ((!$old_event || !in_array($cat_id,$old_event['category'])) && |
|
| 198 | - self::has_cat_right(self::CAT_ACL_ADD,$cat_id,$this->user) === false) |
|
| 197 | + if ((!$old_event || !in_array($cat_id, $old_event['category'])) && |
|
| 198 | + self::has_cat_right(self::CAT_ACL_ADD, $cat_id, $this->user) === false) |
|
| 199 | 199 | { |
| 200 | 200 | unset($event['category'][$key]); |
| 201 | 201 | // report removed category to user |
| 202 | 202 | $removed_cats[$cat_id] = $this->categories->id2name($cat_id); |
| 203 | - continue; // no further check, as cat was removed |
|
| 203 | + continue; // no further check, as cat was removed |
|
| 204 | 204 | } |
| 205 | 205 | // for new or moved events check status of participants, if no category status right --> set all status to 'U' = unknown |
| 206 | 206 | if (!$status_reset_to_unknown && |
| 207 | - self::has_cat_right(self::CAT_ACL_STATUS,$cat_id,$this->user) === false && |
|
| 207 | + self::has_cat_right(self::CAT_ACL_STATUS, $cat_id, $this->user) === false && |
|
| 208 | 208 | (!$old_event || $old_event['start'] != $event['start'] || $old_event['end'] != $event['end'])) |
| 209 | 209 | { |
| 210 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 210 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 211 | 211 | { |
| 212 | 212 | $q = $r = null; |
| 213 | - calendar_so::split_status($status,$q,$r); |
|
| 213 | + calendar_so::split_status($status, $q, $r); |
|
| 214 | 214 | if ($status != 'U') |
| 215 | 215 | { |
| 216 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 216 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 217 | 217 | // todo: report reset status to user |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | - $status_reset_to_unknown = true; // once is enough |
|
| 220 | + $status_reset_to_unknown = true; // once is enough |
|
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | 223 | if ($removed_cats) |
| 224 | 224 | { |
| 225 | - $messages[] = lang('Category %1 removed because of missing rights',implode(', ',$removed_cats)); |
|
| 225 | + $messages[] = lang('Category %1 removed because of missing rights', implode(', ', $removed_cats)); |
|
| 226 | 226 | } |
| 227 | 227 | if ($status_reset_to_unknown) |
| 228 | 228 | { |
@@ -258,30 +258,30 @@ discard block |
||
| 258 | 258 | $event = $this->read($cal_id, null, $ignore_acl, 'ts', $new_event && !$event['public'] ? $this->user : null); |
| 259 | 259 | //error_log("new $cal_id=". array2string($event)); |
| 260 | 260 | |
| 261 | - if($old_event['deleted'] && $event['deleted'] == null) |
|
| 261 | + if ($old_event['deleted'] && $event['deleted'] == null) |
|
| 262 | 262 | { |
| 263 | 263 | // Restored, bring back links |
| 264 | 264 | Link::restore('calendar', $cal_id); |
| 265 | 265 | } |
| 266 | 266 | if ($this->log_file) |
| 267 | 267 | { |
| 268 | - $this->log2file($event2save,$event,$old_event); |
|
| 268 | + $this->log2file($event2save, $event, $old_event); |
|
| 269 | 269 | } |
| 270 | 270 | // send notifications |
| 271 | - if(!$skip_notification) |
|
| 271 | + if (!$skip_notification) |
|
| 272 | 272 | { |
| 273 | 273 | if ($new_event) |
| 274 | 274 | { |
| 275 | - $this->send_update(MSG_ADDED,$event['participants'],'',$event); |
|
| 275 | + $this->send_update(MSG_ADDED, $event['participants'], '', $event); |
|
| 276 | 276 | } |
| 277 | 277 | else // update existing event |
| 278 | 278 | { |
| 279 | - $this->check4update($event,$old_event); |
|
| 279 | + $this->check4update($event, $old_event); |
|
| 280 | 280 | } |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | // notify the link-class about the update, as other apps may be subscribt to it |
| 284 | - Link::notify_update('calendar',$cal_id,$event); |
|
| 284 | + Link::notify_update('calendar', $cal_id, $event); |
|
| 285 | 285 | |
| 286 | 286 | return $cal_id; |
| 287 | 287 | } |
@@ -299,27 +299,27 @@ discard block |
||
| 299 | 299 | * @param Api\DateTime& $checked_excluding =null time until which (excluding) recurrences have been checked |
| 300 | 300 | * @return array or events |
| 301 | 301 | */ |
| 302 | - function conflicts(array $event, &$checked_excluding=null) |
|
| 302 | + function conflicts(array $event, &$checked_excluding = null) |
|
| 303 | 303 | { |
| 304 | 304 | $types_with_quantity = array(); |
| 305 | - foreach($this->resources as $type => $data) |
|
| 305 | + foreach ($this->resources as $type => $data) |
|
| 306 | 306 | { |
| 307 | 307 | if ($data['max_quantity']) $types_with_quantity[] = $type; |
| 308 | 308 | } |
| 309 | 309 | // get all NOT rejected participants and evtl. their quantity |
| 310 | 310 | $quantity = $users = array(); |
| 311 | - foreach($event['participants'] as $uid => $status) |
|
| 311 | + foreach ($event['participants'] as $uid => $status) |
|
| 312 | 312 | { |
| 313 | 313 | $q = $r = null; |
| 314 | - calendar_so::split_status($status,$q,$r); |
|
| 315 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 314 | + calendar_so::split_status($status, $q, $r); |
|
| 315 | + if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 316 | 316 | |
| 317 | 317 | if ($uid < 0) // group, check it's members too |
| 318 | 318 | { |
| 319 | - $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid,true))); |
|
| 319 | + $users = array_unique(array_merge($users, (array)$GLOBALS['egw']->accounts->members($uid, true))); |
|
| 320 | 320 | } |
| 321 | 321 | $users[] = $uid; |
| 322 | - if (in_array($uid[0],$types_with_quantity)) |
|
| 322 | + if (in_array($uid[0], $types_with_quantity)) |
|
| 323 | 323 | { |
| 324 | 324 | $quantity[$uid] = $q; |
| 325 | 325 | } |
@@ -342,58 +342,58 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | $checked = 0; |
| 344 | 344 | $start = microtime(true); |
| 345 | - $duration = $event['end']-$event['start']; |
|
| 346 | - foreach($recurences as $date) |
|
| 345 | + $duration = $event['end'] - $event['start']; |
|
| 346 | + foreach ($recurences as $date) |
|
| 347 | 347 | { |
| 348 | 348 | $startts = $date->format('ts'); |
| 349 | 349 | |
| 350 | 350 | // skip past events or recurrences |
| 351 | - if ($startts+$duration < $this->now_su) continue; |
|
| 351 | + if ($startts + $duration < $this->now_su) continue; |
|
| 352 | 352 | |
| 353 | 353 | // abort check if configured limits are exceeded |
| 354 | 354 | if ($event['recur_type'] && |
| 355 | 355 | (++$checked > $max_checked && $max_checked > 0 || // maximum number of checked recurrences exceeded |
| 356 | - microtime(true) > $start+$max_check_time || // max check time exceeded |
|
| 356 | + microtime(true) > $start + $max_check_time || // max check time exceeded |
|
| 357 | 357 | $startts > $this->config['horizont'])) // we are behind horizon for which recurrences are rendered |
| 358 | 358 | { |
| 359 | 359 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 360 | 360 | { |
| 361 | 361 | $this->debug_message(__METHOD__.'() conflict check limited to %1 recurrences, %2 seconds, until (excluding) %3', |
| 362 | - $checked, microtime(true)-$start, $date); |
|
| 362 | + $checked, microtime(true) - $start, $date); |
|
| 363 | 363 | } |
| 364 | 364 | $checked_excluding = $date; |
| 365 | 365 | break; |
| 366 | 366 | } |
| 367 | - $overlapping_events =& $this->search(array( |
|
| 367 | + $overlapping_events = & $this->search(array( |
|
| 368 | 368 | 'start' => $startts, |
| 369 | - 'end' => $startts+$duration, |
|
| 369 | + 'end' => $startts + $duration, |
|
| 370 | 370 | 'users' => $users, |
| 371 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 372 | - 'enum_groups' => true, // otherwise group-events would not block time |
|
| 371 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 372 | + 'enum_groups' => true, // otherwise group-events would not block time |
|
| 373 | 373 | 'query' => array( |
| 374 | 374 | 'cal_non_blocking' => 0, |
| 375 | 375 | ), |
| 376 | - 'no_integration' => true, // do NOT use integration of other apps |
|
| 376 | + 'no_integration' => true, // do NOT use integration of other apps |
|
| 377 | 377 | )); |
| 378 | 378 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 379 | 379 | { |
| 380 | - $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3',false,$users,$startts,$startts+$duration); |
|
| 380 | + $this->debug_message(__METHOD__.'() checking for potential overlapping events for users %1 from %2 to %3', false, $users, $startts, $startts + $duration); |
|
| 381 | 381 | } |
| 382 | - foreach((array) $overlapping_events as $k => $overlap) |
|
| 382 | + foreach ((array)$overlapping_events as $k => $overlap) |
|
| 383 | 383 | { |
| 384 | - if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 385 | - $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 384 | + if ($overlap['id'] == $event['id'] || // that's the event itself |
|
| 385 | + $overlap['id'] == $event['reference'] || // event is an exception of overlap |
|
| 386 | 386 | $overlap['non_blocking']) // that's a non_blocking event |
| 387 | 387 | { |
| 388 | 388 | continue; |
| 389 | 389 | } |
| 390 | 390 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 391 | 391 | { |
| 392 | - $this->debug_message(__METHOD__.'() checking overlapping event %1',false,$overlap); |
|
| 392 | + $this->debug_message(__METHOD__.'() checking overlapping event %1', false, $overlap); |
|
| 393 | 393 | } |
| 394 | 394 | // check if the overlap is with a rejected participant or within the allowed quantity |
| 395 | - $common_parts = array_intersect($users,array_keys($overlap['participants'])); |
|
| 396 | - foreach($common_parts as $n => $uid) |
|
| 395 | + $common_parts = array_intersect($users, array_keys($overlap['participants'])); |
|
| 396 | + foreach ($common_parts as $n => $uid) |
|
| 397 | 397 | { |
| 398 | 398 | $status = $overlap['participants'][$uid]; |
| 399 | 399 | calendar_so::split_status($status, $q, $r); |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | unset($common_parts[$n]); |
| 403 | 403 | continue; |
| 404 | 404 | } |
| 405 | - if (is_numeric($uid) || !in_array($uid[0],$types_with_quantity)) |
|
| 405 | + if (is_numeric($uid) || !in_array($uid[0], $types_with_quantity)) |
|
| 406 | 406 | { |
| 407 | - continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 407 | + continue; // no quantity check: quantity allways 1 ==> conflict |
|
| 408 | 408 | } |
| 409 | 409 | if (!isset($max_quantity[$uid])) |
| 410 | 410 | { |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | $quantity[$uid] += $q; |
| 415 | 415 | if ($quantity[$uid] <= $max_quantity[$uid]) |
| 416 | 416 | { |
| 417 | - $possible_quantity_conflicts[$uid][] =& $overlapping_events[$k]; // an other event can give the conflict |
|
| 417 | + $possible_quantity_conflicts[$uid][] = & $overlapping_events[$k]; // an other event can give the conflict |
|
| 418 | 418 | unset($common_parts[$n]); |
| 419 | 419 | continue; |
| 420 | 420 | } |
@@ -424,22 +424,22 @@ discard block |
||
| 424 | 424 | { |
| 425 | 425 | if ($this->debug > 3 || $this->debug == 'conflicts') |
| 426 | 426 | { |
| 427 | - $this->debug_message(__METHOD__.'() conflicts with the following participants found %1',false,$common_parts); |
|
| 427 | + $this->debug_message(__METHOD__.'() conflicts with the following participants found %1', false, $common_parts); |
|
| 428 | 428 | } |
| 429 | - $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] =& $overlapping_events[$k]; |
|
| 429 | + $conflicts[$overlap['id'].'-'.$this->date2ts($overlap['start'])] = & $overlapping_events[$k]; |
|
| 430 | 430 | } |
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | //error_log(__METHOD__."() conflict check took ".number_format(microtime(true)-$start, 3).'s'); |
| 434 | 434 | // check if we are withing the allowed quantity and if not add all events using that resource |
| 435 | 435 | // seems this function is doing very strange things, it gives empty conflicts |
| 436 | - foreach($max_quantity as $uid => $max) |
|
| 436 | + foreach ($max_quantity as $uid => $max) |
|
| 437 | 437 | { |
| 438 | 438 | if ($quantity[$uid] > $max) |
| 439 | 439 | { |
| 440 | - foreach((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 440 | + foreach ((array)$possible_quantity_conflicts[$uid] as $conflict) |
|
| 441 | 441 | { |
| 442 | - $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] =& $possible_quantity_conflicts[$k]; |
|
| 442 | + $conflicts[$conflict['id'].'-'.$this->date2ts($conflict['start'])] = & $possible_quantity_conflicts[$k]; |
|
| 443 | 443 | } |
| 444 | 444 | } |
| 445 | 445 | } |
@@ -447,10 +447,10 @@ discard block |
||
| 447 | 447 | |
| 448 | 448 | if (count($conflicts)) |
| 449 | 449 | { |
| 450 | - foreach($conflicts as $key => $conflict) |
|
| 450 | + foreach ($conflicts as $key => $conflict) |
|
| 451 | 451 | { |
| 452 | - $conflict['participants'] = array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 453 | - if (!$this->check_perms(Acl::READ,$conflict)) |
|
| 452 | + $conflict['participants'] = array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 453 | + if (!$this->check_perms(Acl::READ, $conflict)) |
|
| 454 | 454 | { |
| 455 | 455 | $conflicts[$key] = array( |
| 456 | 456 | 'id' => $conflict['id'], |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | if ($this->debug > 2 || $this->debug == 'conflicts') |
| 465 | 465 | { |
| 466 | - $this->debug_message(__METHOD__.'() %1 conflicts found %2',false,count($conflicts),$conflicts); |
|
| 466 | + $this->debug_message(__METHOD__.'() %1 conflicts found %2', false, count($conflicts), $conflicts); |
|
| 467 | 467 | } |
| 468 | 468 | } |
| 469 | 469 | return $conflicts; |
@@ -475,22 +475,22 @@ discard block |
||
| 475 | 475 | * @param array $old_event =null old event with already invited participants |
| 476 | 476 | * @return array removed participants because of missing invite grants |
| 477 | 477 | */ |
| 478 | - public function remove_no_acl_invite(array &$event,array $old_event=null) |
|
| 478 | + public function remove_no_acl_invite(array &$event, array $old_event = null) |
|
| 479 | 479 | { |
| 480 | 480 | if (!$this->require_acl_invite) |
| 481 | 481 | { |
| 482 | - return array(); // nothing to check, everyone can invite everyone else |
|
| 482 | + return array(); // nothing to check, everyone can invite everyone else |
|
| 483 | 483 | } |
| 484 | 484 | if ($event['id'] && is_null($old_event)) |
| 485 | 485 | { |
| 486 | 486 | $old_event = $this->read($event['id']); |
| 487 | 487 | } |
| 488 | 488 | $removed = array(); |
| 489 | - foreach(array_keys((array)$event['participants']) as $uid) |
|
| 489 | + foreach (array_keys((array)$event['participants']) as $uid) |
|
| 490 | 490 | { |
| 491 | 491 | if ((is_null($old_event) || !isset($old_event['participants'][$uid])) && !$this->check_acl_invite($uid)) |
| 492 | 492 | { |
| 493 | - unset($event['participants'][$uid]); // remove participant |
|
| 493 | + unset($event['participants'][$uid]); // remove participant |
|
| 494 | 494 | $removed[] = $uid; |
| 495 | 495 | } |
| 496 | 496 | } |
@@ -506,19 +506,19 @@ discard block |
||
| 506 | 506 | */ |
| 507 | 507 | public function check_acl_invite($uid) |
| 508 | 508 | { |
| 509 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 509 | + if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 510 | 510 | |
| 511 | 511 | if (!$this->require_acl_invite) |
| 512 | 512 | { |
| 513 | - $ret = true; // no grant required |
|
| 513 | + $ret = true; // no grant required |
|
| 514 | 514 | } |
| 515 | 515 | elseif ($this->require_acl_invite == 'groups' && $GLOBALS['egw']->accounts->get_type($uid) != 'g') |
| 516 | 516 | { |
| 517 | - $ret = true; // grant only required for groups |
|
| 517 | + $ret = true; // grant only required for groups |
|
| 518 | 518 | } |
| 519 | 519 | else |
| 520 | 520 | { |
| 521 | - $ret = $this->check_perms(self::ACL_INVITE,0,$uid); |
|
| 521 | + $ret = $this->check_perms(self::ACL_INVITE, 0, $uid); |
|
| 522 | 522 | } |
| 523 | 523 | //error_log(__METHOD__."($uid) = ".array2string($ret)); |
| 524 | 524 | //echo "<p>".__METHOD__."($uid) require_acl_invite=$this->require_acl_invite returning ".array2string($ret)."</p>\n"; |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | * @param array $old_event the event before the update |
| 533 | 533 | * @todo check if there is a real change, not assume every save is a change |
| 534 | 534 | */ |
| 535 | - function check4update($new_event,$old_event) |
|
| 535 | + function check4update($new_event, $old_event) |
|
| 536 | 536 | { |
| 537 | 537 | //error_log(__METHOD__."($new_event[title])"); |
| 538 | 538 | $modified = $added = $deleted = array(); |
@@ -540,9 +540,9 @@ discard block |
||
| 540 | 540 | //echo "<p>calendar_boupdate::check4update() new participants = ".print_r($new_event['participants'],true).", old participants =".print_r($old_event['participants'],true)."</p>\n"; |
| 541 | 541 | |
| 542 | 542 | // Find modified and deleted participants ... |
| 543 | - foreach($old_event['participants'] as $old_userid => $old_status) |
|
| 543 | + foreach ($old_event['participants'] as $old_userid => $old_status) |
|
| 544 | 544 | { |
| 545 | - if(isset($new_event['participants'][$old_userid])) |
|
| 545 | + if (isset($new_event['participants'][$old_userid])) |
|
| 546 | 546 | { |
| 547 | 547 | $modified[$old_userid] = $new_event['participants'][$old_userid]; |
| 548 | 548 | } |
@@ -552,27 +552,27 @@ discard block |
||
| 552 | 552 | } |
| 553 | 553 | } |
| 554 | 554 | // Find new participants ... |
| 555 | - foreach(array_keys((array)$new_event['participants']) as $new_userid) |
|
| 555 | + foreach (array_keys((array)$new_event['participants']) as $new_userid) |
|
| 556 | 556 | { |
| 557 | - if(!isset($old_event['participants'][$new_userid])) |
|
| 557 | + if (!isset($old_event['participants'][$new_userid])) |
|
| 558 | 558 | { |
| 559 | 559 | $added[$new_userid] = 'U'; |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | //echo "<p>calendar_boupdate::check4update() added=".print_r($added,true).", modified=".print_r($modified,true).", deleted=".print_r($deleted,true)."</p>\n"; |
| 563 | - if(count($added) || count($modified) || count($deleted)) |
|
| 563 | + if (count($added) || count($modified) || count($deleted)) |
|
| 564 | 564 | { |
| 565 | - if(count($added)) |
|
| 565 | + if (count($added)) |
|
| 566 | 566 | { |
| 567 | - $this->send_update(MSG_ADDED,$added,$old_event,$new_event); |
|
| 567 | + $this->send_update(MSG_ADDED, $added, $old_event, $new_event); |
|
| 568 | 568 | } |
| 569 | - if(count($modified)) |
|
| 569 | + if (count($modified)) |
|
| 570 | 570 | { |
| 571 | - $this->send_update(MSG_MODIFIED,$modified,$old_event,$new_event); |
|
| 571 | + $this->send_update(MSG_MODIFIED, $modified, $old_event, $new_event); |
|
| 572 | 572 | } |
| 573 | - if(count($deleted)) |
|
| 573 | + if (count($deleted)) |
|
| 574 | 574 | { |
| 575 | - $this->send_update(MSG_DISINVITE,$deleted,$new_event); |
|
| 575 | + $this->send_update(MSG_DISINVITE, $deleted, $new_event); |
|
| 576 | 576 | } |
| 577 | 577 | } |
| 578 | 578 | } |
@@ -589,11 +589,11 @@ discard block |
||
| 589 | 589 | * @param string $status of current user |
| 590 | 590 | * @return boolean true = update requested, false otherwise |
| 591 | 591 | */ |
| 592 | - public static function update_requested($userid, $part_prefs, &$msg_type, $old_event ,$new_event, $role, $status=null) |
|
| 592 | + public static function update_requested($userid, $part_prefs, &$msg_type, $old_event, $new_event, $role, $status = null) |
|
| 593 | 593 | { |
| 594 | 594 | if ($msg_type == MSG_ALARM) |
| 595 | 595 | { |
| 596 | - return True; // always True for now |
|
| 596 | + return True; // always True for now |
|
| 597 | 597 | } |
| 598 | 598 | $want_update = 0; |
| 599 | 599 | |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | // |
| 602 | 602 | $msg_is_response = $msg_type == MSG_REJECTED || $msg_type == MSG_ACCEPTED || $msg_type == MSG_TENTATIVE || $msg_type == MSG_DELEGATED; |
| 603 | 603 | |
| 604 | - switch($ru = $part_prefs['calendar']['receive_updates']) |
|
| 604 | + switch ($ru = $part_prefs['calendar']['receive_updates']) |
|
| 605 | 605 | { |
| 606 | 606 | case 'responses': |
| 607 | 607 | ++$want_update; |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | default: |
| 616 | 616 | if (is_array($new_event) && is_array($old_event)) |
| 617 | 617 | { |
| 618 | - $diff = max(abs(self::date2ts($old_event['start'])-self::date2ts($new_event['start'])), |
|
| 619 | - abs(self::date2ts($old_event['end'])-self::date2ts($new_event['end']))); |
|
| 618 | + $diff = max(abs(self::date2ts($old_event['start']) - self::date2ts($new_event['start'])), |
|
| 619 | + abs(self::date2ts($old_event['end']) - self::date2ts($new_event['end']))); |
|
| 620 | 620 | $check = $ru == 'time_change_4h' ? 4 * 60 * 60 - 1 : 0; |
| 621 | 621 | if ($msg_type == MSG_MODIFIED && $diff > $check) |
| 622 | 622 | { |
@@ -636,13 +636,13 @@ discard block |
||
| 636 | 636 | if (!is_numeric($userid) && $role == 'CHAIR' && |
| 637 | 637 | ($msg_is_response || in_array($msg_type, array(MSG_ADDED, MSG_DELETED)))) |
| 638 | 638 | { |
| 639 | - switch($msg_type) |
|
| 639 | + switch ($msg_type) |
|
| 640 | 640 | { |
| 641 | 641 | case MSG_DELETED: // treat deleting event as rejection to organizer |
| 642 | 642 | $msg_type = MSG_REJECTED; |
| 643 | 643 | break; |
| 644 | 644 | case MSG_ADDED: // new events use added, but organizer needs status |
| 645 | - switch($status[0]) |
|
| 645 | + switch ($status[0]) |
|
| 646 | 646 | { |
| 647 | 647 | case 'A': $msg_type = MSG_ACCEPTED; break; |
| 648 | 648 | case 'R': $msg_type = MSG_REJECTED; break; |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * @param string $role ='REQ-PARTICIPANT' |
| 668 | 668 | * @return boolean true if user requested to be notified, false if not |
| 669 | 669 | */ |
| 670 | - static public function email_update_requested($user_or_email, $ical_method='REQUEST', $role='REQ-PARTICIPANT') |
|
| 670 | + static public function email_update_requested($user_or_email, $ical_method = 'REQUEST', $role = 'REQ-PARTICIPANT') |
|
| 671 | 671 | { |
| 672 | 672 | // check if email is from a user |
| 673 | 673 | if (is_numeric($user_or_email)) |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | ) |
| 692 | 692 | ); |
| 693 | 693 | } |
| 694 | - switch($ical_method) |
|
| 694 | + switch ($ical_method) |
|
| 695 | 695 | { |
| 696 | 696 | default: |
| 697 | 697 | case 'REQUEST': |
@@ -716,9 +716,9 @@ discard block |
||
| 716 | 716 | * @param string& $action=null on return verbose name |
| 717 | 717 | * @param string& $msg=null on return notification message |
| 718 | 718 | */ |
| 719 | - function msg_type2ical_method($msg_type, &$action=null, &$msg=null) |
|
| 719 | + function msg_type2ical_method($msg_type, &$action = null, &$msg = null) |
|
| 720 | 720 | { |
| 721 | - switch($msg_type) |
|
| 721 | + switch ($msg_type) |
|
| 722 | 722 | { |
| 723 | 723 | case MSG_DELETED: |
| 724 | 724 | $action = 'Canceled'; |
@@ -770,7 +770,7 @@ discard block |
||
| 770 | 770 | $msg = $this->cal_prefs['notify'.$pref]; |
| 771 | 771 | if (empty($msg)) |
| 772 | 772 | { |
| 773 | - $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 773 | + $msg = $this->cal_prefs['notifyAdded']; // use a default |
|
| 774 | 774 | } |
| 775 | 775 | //error_log(__METHOD__."($msg_type) action='$action', $msg='$msg' returning '$method'"); |
| 776 | 776 | return $method; |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | * @param int $user =0 User who started the notify, default current user |
| 787 | 787 | * @return bool true/false |
| 788 | 788 | */ |
| 789 | - function send_update($msg_type,$to_notify,$old_event,$new_event=null,$user=0) |
|
| 789 | + function send_update($msg_type, $to_notify, $old_event, $new_event = null, $user = 0) |
|
| 790 | 790 | { |
| 791 | 791 | //error_log(__METHOD__."($msg_type,".array2string($to_notify).",...) ".array2string($new_event)); |
| 792 | 792 | if (!is_array($to_notify)) |
@@ -798,11 +798,11 @@ discard block |
||
| 798 | 798 | $owner = $old_event ? $old_event['owner'] : $new_event['owner']; |
| 799 | 799 | if ($owner && !isset($to_notify[$owner]) && $msg_type != MSG_ALARM) |
| 800 | 800 | { |
| 801 | - $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 801 | + $to_notify[$owner] = 'OCHAIR'; // always include the event-owner |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | // ignore events in the past (give a tolerance of 10 seconds for the script) |
| 805 | - if($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 805 | + if ($old_event && $this->date2ts($old_event['start']) < ($this->now_su - 10)) |
|
| 806 | 806 | { |
| 807 | 807 | return False; |
| 808 | 808 | } |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | $restore_tz = $tz; |
| 813 | 813 | date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']); |
| 814 | 814 | } |
| 815 | - $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 815 | + $temp_user = $GLOBALS['egw_info']['user']; // save user-date of the enviroment to restore it after |
|
| 816 | 816 | |
| 817 | 817 | if (!$user) |
| 818 | 818 | { |
@@ -828,16 +828,16 @@ discard block |
||
| 828 | 828 | $event = $msg_type == MSG_ADDED || $msg_type == MSG_MODIFIED ? $new_event : $old_event; |
| 829 | 829 | |
| 830 | 830 | // add all group-members to the notification, unless they are already participants |
| 831 | - foreach($to_notify as $userid => $statusid) |
|
| 831 | + foreach ($to_notify as $userid => $statusid) |
|
| 832 | 832 | { |
| 833 | 833 | if (is_numeric($userid) && $GLOBALS['egw']->accounts->get_type($userid) == 'g' && |
| 834 | 834 | ($members = $GLOBALS['egw']->accounts->members($userid, true))) |
| 835 | 835 | { |
| 836 | - foreach($members as $member) |
|
| 836 | + foreach ($members as $member) |
|
| 837 | 837 | { |
| 838 | 838 | if (!isset($to_notify[$member])) |
| 839 | 839 | { |
| 840 | - $to_notify[$member] = 'G'; // Group-invitation |
|
| 840 | + $to_notify[$member] = 'G'; // Group-invitation |
|
| 841 | 841 | } |
| 842 | 842 | } |
| 843 | 843 | } |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
| 850 | 850 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 851 | 851 | $owner_prefs = $ics = null; |
| 852 | - foreach($to_notify as $userid => $statusid) |
|
| 852 | + foreach ($to_notify as $userid => $statusid) |
|
| 853 | 853 | { |
| 854 | 854 | $res_info = $quantity = $role = null; |
| 855 | 855 | calendar_so::split_status($statusid, $quantity, $role); |
@@ -872,14 +872,14 @@ discard block |
||
| 872 | 872 | |
| 873 | 873 | if (!isset($userid)) |
| 874 | 874 | { |
| 875 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 875 | + if (empty($res_info['email'])) continue; // no way to notify |
|
| 876 | 876 | // check if event-owner wants non-EGroupware users notified |
| 877 | 877 | if (is_null($owner_prefs)) |
| 878 | 878 | { |
| 879 | 879 | $preferences = new Api\Preferences($owner); |
| 880 | 880 | $owner_prefs = $preferences->read_repository(); |
| 881 | 881 | } |
| 882 | - if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 882 | + if ($role != 'CHAIR' && // always notify externals CHAIRs |
|
| 883 | 883 | (empty($owner_prefs['calendar']['notify_externals']) || |
| 884 | 884 | $owner_prefs['calendar']['notify_externals'] == 'no')) |
| 885 | 885 | { |
@@ -891,12 +891,12 @@ discard block |
||
| 891 | 891 | |
| 892 | 892 | if ($statusid == 'R' || $GLOBALS['egw']->accounts->get_type($userid) == 'g') |
| 893 | 893 | { |
| 894 | - continue; // dont notify rejected participants or groups |
|
| 894 | + continue; // dont notify rejected participants or groups |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - if($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 897 | + if ($userid != $GLOBALS['egw_info']['user']['account_id'] || |
|
| 898 | 898 | ($userid == $GLOBALS['egw_info']['user']['account_id'] && |
| 899 | - $user_prefs['calendar']['receive_own_updates']==1) || |
|
| 899 | + $user_prefs['calendar']['receive_own_updates'] == 1) || |
|
| 900 | 900 | $msg_type == MSG_ALARM) |
| 901 | 901 | { |
| 902 | 902 | $tfn = $tln = $lid = null; //cleanup of lastname and fullname (in case they are set in a previous loop) |
@@ -905,8 +905,8 @@ discard block |
||
| 905 | 905 | $preferences = new Api\Preferences($userid); |
| 906 | 906 | $GLOBALS['egw_info']['user']['preferences'] = $part_prefs = $preferences->read_repository(); |
| 907 | 907 | $fullname = Api\Accounts::username($userid); |
| 908 | - $tfn = Api\Accounts::id2name($userid,'account_firstname'); |
|
| 909 | - $tln = Api\Accounts::id2name($userid,'account_lastname'); |
|
| 908 | + $tfn = Api\Accounts::id2name($userid, 'account_firstname'); |
|
| 909 | + $tln = Api\Accounts::id2name($userid, 'account_lastname'); |
|
| 910 | 910 | } |
| 911 | 911 | else // external email address: use Api\Preferences of event-owner, plus some hardcoded settings (eg. ical notification) |
| 912 | 912 | { |
@@ -917,7 +917,7 @@ discard block |
||
| 917 | 917 | } |
| 918 | 918 | $part_prefs = $owner_prefs; |
| 919 | 919 | $part_prefs['calendar']['receive_updates'] = $owner_prefs['calendar']['notify_externals']; |
| 920 | - $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 920 | + $part_prefs['calendar']['update_format'] = 'ical'; // use ical format |
|
| 921 | 921 | $fullname = $res_info && !empty($res_info['name']) ? $res_info['name'] : $userid; |
| 922 | 922 | } |
| 923 | 923 | $m_type = $msg_type; |
@@ -942,14 +942,14 @@ discard block |
||
| 942 | 942 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 943 | 943 | $action, $event_arr, $disinvited); |
| 944 | 944 | $details['to-fullname'] = $fullname; |
| 945 | - $details['to-firstname'] = isset($tfn)? $tfn: ''; |
|
| 946 | - $details['to-lastname'] = isset($tln)? $tln: ''; |
|
| 945 | + $details['to-firstname'] = isset($tfn) ? $tfn : ''; |
|
| 946 | + $details['to-lastname'] = isset($tln) ? $tln : ''; |
|
| 947 | 947 | |
| 948 | 948 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 949 | 949 | if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
| 950 | 950 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 951 | 951 | $timeformat = $part_prefs['common']['timeformat']; |
| 952 | - switch($timeformat) |
|
| 952 | + switch ($timeformat) |
|
| 953 | 953 | { |
| 954 | 954 | case '24': |
| 955 | 955 | $timeformat = 'H:i'; |
@@ -958,7 +958,7 @@ discard block |
||
| 958 | 958 | $timeformat = 'h:i a'; |
| 959 | 959 | break; |
| 960 | 960 | } |
| 961 | - $timeformat = $part_prefs['common']['dateformat'] . ', ' . $timeformat; |
|
| 961 | + $timeformat = $part_prefs['common']['dateformat'].', '.$timeformat; |
|
| 962 | 962 | |
| 963 | 963 | $startdate->setTimezone($timezone); |
| 964 | 964 | $details['startdate'] = $startdate->format($timeformat); |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | $details['enddate'] = $enddate->format($timeformat); |
| 968 | 968 | |
| 969 | 969 | $modified->setTimezone($timezone); |
| 970 | - $details['updated'] = $modified->format($timeformat) . ', ' . Api\Accounts::username($event['modifier']); |
|
| 970 | + $details['updated'] = $modified->format($timeformat).', '.Api\Accounts::username($event['modifier']); |
|
| 971 | 971 | |
| 972 | 972 | if ($old_event != False) |
| 973 | 973 | { |
@@ -976,15 +976,14 @@ discard block |
||
| 976 | 976 | } |
| 977 | 977 | //error_log(__METHOD__."() userid=$userid, timezone=".$timezone->getName().", startdate=$details[startdate], enddate=$details[enddate], updated=$details[updated], olddate=$details[olddate]"); |
| 978 | 978 | |
| 979 | - list($subject,$notify_body) = explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 979 | + list($subject, $notify_body) = explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 980 | 980 | // alarm is NOT an iCal method, therefore we have to use extened (no iCal) |
| 981 | - switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 981 | + switch ($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
|
| 982 | 982 | { |
| 983 | - case 'ical': |
|
| 984 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 983 | + case 'ical' : if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 985 | 984 | { |
| 986 | 985 | $calendar_ical = new calendar_ical(); |
| 987 | - $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 986 | + $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
|
| 988 | 987 | // we need to pass $event[id] so iCal class reads event again, |
| 989 | 988 | // as event is in user TZ, but iCal class expects server TZ! |
| 990 | 989 | $ics = $calendar_ical->exportVCal(array(isset($cleared_event) ? $cleared_event : $event['id']), |
@@ -1003,11 +1002,11 @@ discard block |
||
| 1003 | 1002 | case 'extended': |
| 1004 | 1003 | |
| 1005 | 1004 | $details_body = lang('Event Details follow').":\n"; |
| 1006 | - foreach($event_arr as $key => $val) |
|
| 1005 | + foreach ($event_arr as $key => $val) |
|
| 1007 | 1006 | { |
| 1008 | - if(!empty($details[$key])) |
|
| 1007 | + if (!empty($details[$key])) |
|
| 1009 | 1008 | { |
| 1010 | - switch($key) |
|
| 1009 | + switch ($key) |
|
| 1011 | 1010 | { |
| 1012 | 1011 | case 'access': |
| 1013 | 1012 | case 'priority': |
@@ -1016,7 +1015,7 @@ discard block |
||
| 1016 | 1015 | case 'title': |
| 1017 | 1016 | break; |
| 1018 | 1017 | default: |
| 1019 | - $details_body .= sprintf("%-20s %s\n",$val['field'].':',$details[$key]); |
|
| 1018 | + $details_body .= sprintf("%-20s %s\n", $val['field'].':', $details[$key]); |
|
| 1020 | 1019 | break; |
| 1021 | 1020 | } |
| 1022 | 1021 | } |
@@ -1024,7 +1023,7 @@ discard block |
||
| 1024 | 1023 | break; |
| 1025 | 1024 | } |
| 1026 | 1025 | // send via notification_app |
| 1027 | - if($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1026 | + if ($GLOBALS['egw_info']['apps']['notifications']['enabled']) |
|
| 1028 | 1027 | { |
| 1029 | 1028 | try { |
| 1030 | 1029 | //error_log(__METHOD__."() notifying $userid from $senderid: $subject"); |
@@ -1048,9 +1047,9 @@ discard block |
||
| 1048 | 1047 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 1049 | 1048 | $notification->set_popuplinks(array($details['link_arr'])); |
| 1050 | 1049 | |
| 1051 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1050 | + if (is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1052 | 1051 | $notification->send(); |
| 1053 | - foreach(notifications::errors(true) as $error) |
|
| 1052 | + foreach (notifications::errors(true) as $error) |
|
| 1054 | 1053 | { |
| 1055 | 1054 | error_log(__METHOD__."() Error notifying $userid from $senderid: $subject: $error"); |
| 1056 | 1055 | } |
@@ -1089,14 +1088,14 @@ discard block |
||
| 1089 | 1088 | return true; |
| 1090 | 1089 | } |
| 1091 | 1090 | |
| 1092 | - function get_update_message($event,$added) |
|
| 1091 | + function get_update_message($event, $added) |
|
| 1093 | 1092 | { |
| 1094 | 1093 | $nul = null; |
| 1095 | - $details = $this->_get_event_details($event,$added ? lang('Added') : lang('Modified'),$nul); |
|
| 1094 | + $details = $this->_get_event_details($event, $added ? lang('Added') : lang('Modified'), $nul); |
|
| 1096 | 1095 | |
| 1097 | 1096 | $notify_msg = $this->cal_prefs[$added || empty($this->cal_prefs['notifyModified']) ? 'notifyAdded' : 'notifyModified']; |
| 1098 | 1097 | |
| 1099 | - return explode("\n",$GLOBALS['egw']->preferences->parse_notify($notify_msg,$details),2); |
|
| 1098 | + return explode("\n", $GLOBALS['egw']->preferences->parse_notify($notify_msg, $details), 2); |
|
| 1100 | 1099 | } |
| 1101 | 1100 | |
| 1102 | 1101 | /** |
@@ -1110,37 +1109,37 @@ discard block |
||
| 1110 | 1109 | //echo "<p>bocalendar::send_alarm("; print_r($alarm); echo ")</p>\n"; |
| 1111 | 1110 | $GLOBALS['egw_info']['user']['account_id'] = $this->owner = $alarm['owner']; |
| 1112 | 1111 | |
| 1113 | - $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1114 | - if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'],$event_time_user))) |
|
| 1112 | + $event_time_user = Api\DateTime::server2user($alarm['time'] + $alarm['offset']); // alarm[time] is in server-time, read requires user-time |
|
| 1113 | + if (!$alarm['owner'] || !$alarm['cal_id'] || !($event = $this->read($alarm['cal_id'], $event_time_user))) |
|
| 1115 | 1114 | { |
| 1116 | - return False; // event not found |
|
| 1115 | + return False; // event not found |
|
| 1117 | 1116 | } |
| 1118 | 1117 | if ($alarm['all']) |
| 1119 | 1118 | { |
| 1120 | 1119 | $to_notify = $event['participants']; |
| 1121 | 1120 | } |
| 1122 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1121 | + elseif ($this->check_perms(Acl::READ, $event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1123 | 1122 | { |
| 1124 | 1123 | $to_notify[$alarm['owner']] = 'A'; |
| 1125 | 1124 | } |
| 1126 | 1125 | else |
| 1127 | 1126 | { |
| 1128 | - return False; // no rights |
|
| 1127 | + return False; // no rights |
|
| 1129 | 1128 | } |
| 1130 | 1129 | // need to load calendar translations and set currentapp, so calendar can reload a different lang |
| 1131 | 1130 | Api\Translation::add_app('calendar'); |
| 1132 | 1131 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
| 1133 | 1132 | |
| 1134 | - $ret = $this->send_update(MSG_ALARM,$to_notify,$event,False,$alarm['owner']); |
|
| 1133 | + $ret = $this->send_update(MSG_ALARM, $to_notify, $event, False, $alarm['owner']); |
|
| 1135 | 1134 | |
| 1136 | 1135 | // create a new alarm for recuring events for the next event, if one exists |
| 1137 | - if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'],$event_time_user+1))) |
|
| 1136 | + if ($event['recur_type'] != MCAL_RECUR_NONE && ($event = $this->read($alarm['cal_id'], $event_time_user + 1))) |
|
| 1138 | 1137 | { |
| 1139 | 1138 | $alarm['time'] = $this->date2ts($event['start']) - $alarm['offset']; |
| 1140 | 1139 | unset($alarm['times']); |
| 1141 | 1140 | unset($alarm['next']); |
| 1142 | 1141 | //error_log(__METHOD__."() moving alarm to next recurrence ".array2string($alarm)); |
| 1143 | - $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1142 | + $this->save_alarm($alarm['cal_id'], $alarm, false); // false = do NOT update timestamp, as nothing changed for iCal clients |
|
| 1144 | 1143 | } |
| 1145 | 1144 | return $ret; |
| 1146 | 1145 | } |
@@ -1156,14 +1155,14 @@ discard block |
||
| 1156 | 1155 | * Please note: you should ALLWAYS update timestamps, as they are required for sync! |
| 1157 | 1156 | * @return int|boolean $cal_id > 0 or false on error (eg. permission denied) |
| 1158 | 1157 | */ |
| 1159 | - function save($event,$ignore_acl=false,$updateTS=true) |
|
| 1158 | + function save($event, $ignore_acl = false, $updateTS = true) |
|
| 1160 | 1159 | { |
| 1161 | 1160 | //error_log(__METHOD__.'('.array2string($event).", $ignore_acl, $updateTS)"); |
| 1162 | 1161 | |
| 1163 | 1162 | // check if user has the permission to update / create the event |
| 1164 | - if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT,$event['id']) || |
|
| 1165 | - !$event['id'] && !$this->check_perms(Acl::EDIT,0,$event['owner']) && |
|
| 1166 | - !$this->check_perms(Acl::ADD,0,$event['owner']))) |
|
| 1163 | + if (!$ignore_acl && ($event['id'] && !$this->check_perms(Acl::EDIT, $event['id']) || |
|
| 1164 | + !$event['id'] && !$this->check_perms(Acl::EDIT, 0, $event['owner']) && |
|
| 1165 | + !$this->check_perms(Acl::ADD, 0, $event['owner']))) |
|
| 1167 | 1166 | { |
| 1168 | 1167 | return false; |
| 1169 | 1168 | } |
@@ -1184,7 +1183,7 @@ discard block |
||
| 1184 | 1183 | if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start']) |
| 1185 | 1184 | { |
| 1186 | 1185 | $event['recur_enddate'] = new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
| 1187 | - $event['recur_enddate']->setTime(23,59,59); |
|
| 1186 | + $event['recur_enddate']->setTime(23, 59, 59); |
|
| 1188 | 1187 | $rrule = calendar_rrule::event2rrule($event, true, Api\DateTime::$user_timezone->getName()); |
| 1189 | 1188 | $rrule->rewind(); |
| 1190 | 1189 | $enddate = $rrule->current(); |
@@ -1243,19 +1242,19 @@ discard block |
||
| 1243 | 1242 | |
| 1244 | 1243 | $event['recur_enddate'] = $save_event['recur_enddate'] = $time; |
| 1245 | 1244 | } |
| 1246 | - $timestamps = array('modified','created'); |
|
| 1245 | + $timestamps = array('modified', 'created'); |
|
| 1247 | 1246 | // all-day events are handled in server time |
| 1248 | 1247 | // $event['tzid'] = $save_event['tzid'] = Api\DateTime::$server_timezone->getName(); |
| 1249 | 1248 | } |
| 1250 | 1249 | else |
| 1251 | 1250 | { |
| 1252 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence'); |
|
| 1251 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence'); |
|
| 1253 | 1252 | } |
| 1254 | 1253 | // we run all dates through date2ts, to adjust to server-time and the possible date-formats |
| 1255 | - foreach($timestamps as $ts) |
|
| 1254 | + foreach ($timestamps as $ts) |
|
| 1256 | 1255 | { |
| 1257 | 1256 | // we convert here from user-time to timestamps in server-time! |
| 1258 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1257 | + if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts], true) : 0; |
|
| 1259 | 1258 | } |
| 1260 | 1259 | // convert tzid name to integer tz_id, of set user default |
| 1261 | 1260 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1265,7 +1264,7 @@ discard block |
||
| 1265 | 1264 | // same with the recur exceptions |
| 1266 | 1265 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 1267 | 1266 | { |
| 1268 | - foreach($event['recur_exception'] as &$date) |
|
| 1267 | + foreach ($event['recur_exception'] as &$date) |
|
| 1269 | 1268 | { |
| 1270 | 1269 | if ($event['whole_day']) |
| 1271 | 1270 | { |
@@ -1274,7 +1273,7 @@ discard block |
||
| 1274 | 1273 | } |
| 1275 | 1274 | else |
| 1276 | 1275 | { |
| 1277 | - $date = $this->date2ts($date,true); |
|
| 1276 | + $date = $this->date2ts($date, true); |
|
| 1278 | 1277 | } |
| 1279 | 1278 | } |
| 1280 | 1279 | unset($date); |
@@ -1282,7 +1281,7 @@ discard block |
||
| 1282 | 1281 | // same with the alarms |
| 1283 | 1282 | if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start'])) |
| 1284 | 1283 | { |
| 1285 | - foreach($event['alarm'] as $id => &$alarm) |
|
| 1284 | + foreach ($event['alarm'] as $id => &$alarm) |
|
| 1286 | 1285 | { |
| 1287 | 1286 | // remove alarms belonging to not longer existing or rejected participants |
| 1288 | 1287 | if ($alarm['owner'] && isset($event['participants'])) |
@@ -1300,15 +1299,14 @@ discard block |
||
| 1300 | 1299 | // update all existing alarm times, in case alarm got moved and alarms are not include in $event |
| 1301 | 1300 | if ($old_event && is_array($old_event['alarm']) && isset($event['start'])) |
| 1302 | 1301 | { |
| 1303 | - foreach($old_event['alarm'] as $id => &$alarm) |
|
| 1302 | + foreach ($old_event['alarm'] as $id => &$alarm) |
|
| 1304 | 1303 | { |
| 1305 | 1304 | if (!isset($event['alarm'][$id])) |
| 1306 | 1305 | { |
| 1307 | 1306 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1308 | 1307 | if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
| 1309 | 1308 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1310 | - $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
|
| 1311 | - $old_event['participants'][$alarm['owner']]; |
|
| 1309 | + $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : $old_event['participants'][$alarm['owner']]; |
|
| 1312 | 1310 | if (!$alarm['owner'] || isset($status) && calendar_so::split_status($status) !== 'R') |
| 1313 | 1311 | { |
| 1314 | 1312 | $this->so->save_alarm($event['id'], $alarm); |
@@ -1335,9 +1333,9 @@ discard block |
||
| 1335 | 1333 | $event['created'] = $this->now; |
| 1336 | 1334 | $event['creator'] = $this->user; |
| 1337 | 1335 | } |
| 1338 | - $set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate']+1 : false; |
|
| 1336 | + $set_recurrences = $old_event ? $event['recur_enddate'] != $old_event['recur_enddate'] + 1 : false; |
|
| 1339 | 1337 | $set_recurrences_start = 0; |
| 1340 | - if (($cal_id = $this->so->save($event,$set_recurrences,$set_recurrences_start,0,$event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1338 | + if (($cal_id = $this->so->save($event, $set_recurrences, $set_recurrences_start, 0, $event['etag'])) && $set_recurrences && $event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1341 | 1339 | { |
| 1342 | 1340 | $save_event['id'] = $cal_id; |
| 1343 | 1341 | // unset participants to enforce the default stati for all added recurrences |
@@ -1348,7 +1346,7 @@ discard block |
||
| 1348 | 1346 | // create links for new participants from addressbook, if configured |
| 1349 | 1347 | if ($cal_id && $GLOBALS['egw_info']['server']['link_contacts'] && $event['participants']) |
| 1350 | 1348 | { |
| 1351 | - foreach($event['participants'] as $uid => $status) |
|
| 1349 | + foreach ($event['participants'] as $uid => $status) |
|
| 1352 | 1350 | { |
| 1353 | 1351 | $user_type = $user_id = null; |
| 1354 | 1352 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1361,7 +1359,7 @@ discard block |
||
| 1361 | 1359 | |
| 1362 | 1360 | // Update history |
| 1363 | 1361 | $tracking = new calendar_tracking($this); |
| 1364 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1362 | + if (empty($event['id']) && !empty($cal_id)) $event['id'] = $cal_id; |
|
| 1365 | 1363 | $tracking->track($event, $old_event); |
| 1366 | 1364 | |
| 1367 | 1365 | return $cal_id; |
@@ -1376,16 +1374,16 @@ discard block |
||
| 1376 | 1374 | * @param array|int $event event array or id of the event |
| 1377 | 1375 | * @return boolean |
| 1378 | 1376 | */ |
| 1379 | - function check_status_perms($uid,$event) |
|
| 1377 | + function check_status_perms($uid, $event) |
|
| 1380 | 1378 | { |
| 1381 | 1379 | if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
| 1382 | 1380 | { |
| 1383 | 1381 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1384 | 1382 | |
| 1385 | - return $this->check_perms(Acl::EDIT,0,$event['owner']); |
|
| 1383 | + return $this->check_perms(Acl::EDIT, 0, $event['owner']); |
|
| 1386 | 1384 | } |
| 1387 | 1385 | // check if we have a category Acl for the event or not (null) |
| 1388 | - $access = $this->check_cat_acl(self::CAT_ACL_STATUS,$event); |
|
| 1386 | + $access = $this->check_cat_acl(self::CAT_ACL_STATUS, $event); |
|
| 1389 | 1387 | if (!is_null($access)) |
| 1390 | 1388 | { |
| 1391 | 1389 | return $access; |
@@ -1395,17 +1393,17 @@ discard block |
||
| 1395 | 1393 | { |
| 1396 | 1394 | $resource = $this->resource_info($uid); |
| 1397 | 1395 | |
| 1398 | - return Acl::EDIT & $resource['rights']; |
|
| 1396 | + return Acl::EDIT&$resource['rights']; |
|
| 1399 | 1397 | } |
| 1400 | 1398 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1401 | 1399 | |
| 1402 | 1400 | // regular user and groups (need to check memberships too) |
| 1403 | 1401 | if (!isset($event['participants'][$uid])) |
| 1404 | 1402 | { |
| 1405 | - $memberships = $GLOBALS['egw']->accounts->memberships($uid,true); |
|
| 1403 | + $memberships = $GLOBALS['egw']->accounts->memberships($uid, true); |
|
| 1406 | 1404 | } |
| 1407 | 1405 | $memberships[] = $uid; |
| 1408 | - return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT,0,$uid); |
|
| 1406 | + return array_intersect($memberships, array_keys($event['participants'])) && $this->check_perms(Acl::EDIT, 0, $uid); |
|
| 1409 | 1407 | } |
| 1410 | 1408 | |
| 1411 | 1409 | /** |
@@ -1419,16 +1417,16 @@ discard block |
||
| 1419 | 1417 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1420 | 1418 | * null = cat has no acl |
| 1421 | 1419 | */ |
| 1422 | - function check_cat_acl($right,$event) |
|
| 1420 | + function check_cat_acl($right, $event) |
|
| 1423 | 1421 | { |
| 1424 | 1422 | if (!is_array($event)) $event = $this->read($event); |
| 1425 | 1423 | |
| 1426 | 1424 | $ret = null; |
| 1427 | 1425 | if ($event['category']) |
| 1428 | 1426 | { |
| 1429 | - foreach(is_array($event['category']) ? $event['category'] : explode(',',$event['category']) as $cat_id) |
|
| 1427 | + foreach (is_array($event['category']) ? $event['category'] : explode(',', $event['category']) as $cat_id) |
|
| 1430 | 1428 | { |
| 1431 | - $access = self::has_cat_right($right,$cat_id,$this->user); |
|
| 1429 | + $access = self::has_cat_right($right, $cat_id, $this->user); |
|
| 1432 | 1430 | if ($access === true) |
| 1433 | 1431 | { |
| 1434 | 1432 | $ret = true; |
@@ -1436,7 +1434,7 @@ discard block |
||
| 1436 | 1434 | } |
| 1437 | 1435 | if ($access === false) |
| 1438 | 1436 | { |
| 1439 | - $ret = false; // cat denies access --> check further cats |
|
| 1437 | + $ret = false; // cat denies access --> check further cats |
|
| 1440 | 1438 | } |
| 1441 | 1439 | } |
| 1442 | 1440 | } |
@@ -1457,12 +1455,12 @@ discard block |
||
| 1457 | 1455 | * @param int $cat_id =null null to return array with all cats |
| 1458 | 1456 | * @return array with account_id => right pairs |
| 1459 | 1457 | */ |
| 1460 | - public static function get_cat_rights($cat_id=null) |
|
| 1458 | + public static function get_cat_rights($cat_id = null) |
|
| 1461 | 1459 | { |
| 1462 | 1460 | if (!isset(self::$cat_rights_cache)) |
| 1463 | 1461 | { |
| 1464 | - self::$cat_rights_cache = Api\Cache::getSession('calendar','cat_rights', |
|
| 1465 | - array($GLOBALS['egw']->acl,'get_location_grants'),array('L%','calendar')); |
|
| 1462 | + self::$cat_rights_cache = Api\Cache::getSession('calendar', 'cat_rights', |
|
| 1463 | + array($GLOBALS['egw']->acl, 'get_location_grants'), array('L%', 'calendar')); |
|
| 1466 | 1464 | } |
| 1467 | 1465 | //echo "<p>".__METHOD__."($cat_id) = ".array2string($cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache)."</p>\n"; |
| 1468 | 1466 | return $cat_id ? self::$cat_rights_cache['L'.$cat_id] : self::$cat_rights_cache; |
@@ -1475,7 +1473,7 @@ discard block |
||
| 1475 | 1473 | * @param int $user |
| 1476 | 1474 | * @param int $rights self::CAT_ACL_{ADD|STATUS} or'ed together |
| 1477 | 1475 | */ |
| 1478 | - public static function set_cat_rights($cat_id,$user,$rights) |
|
| 1476 | + public static function set_cat_rights($cat_id, $user, $rights) |
|
| 1479 | 1477 | { |
| 1480 | 1478 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1481 | 1479 | if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
@@ -1485,15 +1483,15 @@ discard block |
||
| 1485 | 1483 | if ($rights) |
| 1486 | 1484 | { |
| 1487 | 1485 | self::$cat_rights_cache['L'.$cat_id][$user] = $rights; |
| 1488 | - $GLOBALS['egw']->acl->add_repository('calendar','L'.$cat_id,$user,$rights); |
|
| 1486 | + $GLOBALS['egw']->acl->add_repository('calendar', 'L'.$cat_id, $user, $rights); |
|
| 1489 | 1487 | } |
| 1490 | 1488 | else |
| 1491 | 1489 | { |
| 1492 | 1490 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1493 | 1491 | if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
| 1494 | - $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
|
| 1492 | + $GLOBALS['egw']->acl->delete_repository('calendar', 'L'.$cat_id, $user); |
|
| 1495 | 1493 | } |
| 1496 | - Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
|
| 1494 | + Api\Cache::setSession('calendar', 'cat_rights', self::$cat_rights_cache); |
|
| 1497 | 1495 | } |
| 1498 | 1496 | } |
| 1499 | 1497 | |
@@ -1504,9 +1502,9 @@ discard block |
||
| 1504 | 1502 | * @return boolean false=access denied because of cat acl, true access granted because of cat acl, |
| 1505 | 1503 | * null = cat has no acl |
| 1506 | 1504 | */ |
| 1507 | - public static function has_cat_right($right,$cat_id,$user) |
|
| 1505 | + public static function has_cat_right($right, $cat_id, $user) |
|
| 1508 | 1506 | { |
| 1509 | - static $cache=null; |
|
| 1507 | + static $cache = null; |
|
| 1510 | 1508 | |
| 1511 | 1509 | if (!isset($cache[$cat_id])) |
| 1512 | 1510 | { |
@@ -1514,21 +1512,21 @@ discard block |
||
| 1514 | 1512 | $cat_rights = self::get_cat_rights($cat_id); |
| 1515 | 1513 | if (!is_null($cat_rights)) |
| 1516 | 1514 | { |
| 1517 | - static $memberships=null; |
|
| 1515 | + static $memberships = null; |
|
| 1518 | 1516 | if (is_null($memberships)) |
| 1519 | 1517 | { |
| 1520 | - $memberships = $GLOBALS['egw']->accounts->memberships($user,true); |
|
| 1518 | + $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
|
| 1521 | 1519 | $memberships[] = $user; |
| 1522 | 1520 | } |
| 1523 | - foreach($cat_rights as $uid => $value) |
|
| 1521 | + foreach ($cat_rights as $uid => $value) |
|
| 1524 | 1522 | { |
| 1525 | 1523 | $all |= $value; |
| 1526 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1524 | + if (in_array($uid, $memberships)) $own |= $value; |
|
| 1527 | 1525 | } |
| 1528 | 1526 | } |
| 1529 | - foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
|
| 1527 | + foreach (array(self::CAT_ACL_ADD, self::CAT_ACL_STATUS) as $mask) |
|
| 1530 | 1528 | { |
| 1531 | - $cache[$cat_id][$mask] = !($all & $mask) ? null : !!($own & $mask); |
|
| 1529 | + $cache[$cat_id][$mask] = !($all&$mask) ? null : !!($own&$mask); |
|
| 1532 | 1530 | } |
| 1533 | 1531 | } |
| 1534 | 1532 | //echo "<p>".__METHOD__."($right,$cat_id) all=$all, own=$own returning ".array2string($cache[$cat_id][$right])."</p>\n"; |
@@ -1548,13 +1546,13 @@ discard block |
||
| 1548 | 1546 | * @param boolean $skip_notification =false true: do not send notification messages |
| 1549 | 1547 | * @return int number of changed recurrences |
| 1550 | 1548 | */ |
| 1551 | - function set_status($event,$uid,$status,$recur_date=0,$ignore_acl=false,$updateTS=true,$skip_notification=false) |
|
| 1549 | + function set_status($event, $uid, $status, $recur_date = 0, $ignore_acl = false, $updateTS = true, $skip_notification = false) |
|
| 1552 | 1550 | { |
| 1553 | 1551 | unset($updateTS); |
| 1554 | 1552 | |
| 1555 | 1553 | $cal_id = is_array($event) ? $event['id'] : $event; |
| 1556 | 1554 | //echo "<p>calendar_boupdate::set_status($cal_id,$uid,$status,$recur_date)</p>\n"; |
| 1557 | - if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid,$event))) |
|
| 1555 | + if (!$cal_id || (!$ignore_acl && !$this->check_status_perms($uid, $event))) |
|
| 1558 | 1556 | { |
| 1559 | 1557 | return false; |
| 1560 | 1558 | } |
@@ -1563,16 +1561,16 @@ discard block |
||
| 1563 | 1561 | if ($this->log) |
| 1564 | 1562 | { |
| 1565 | 1563 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 1566 | - "($cal_id, $uid, $status, $recur_date)\n",3,$this->logfile); |
|
| 1564 | + "($cal_id, $uid, $status, $recur_date)\n", 3, $this->logfile); |
|
| 1567 | 1565 | } |
| 1568 | 1566 | $old_event = $this->read($cal_id, $recur_date, $ignore_acl, 'server'); |
| 1569 | - if (($Ok = $this->so->set_status($cal_id,is_numeric($uid)?'u':$uid[0], |
|
| 1570 | - is_numeric($uid)?$uid:substr($uid,1),$status, |
|
| 1571 | - $recur_date?$this->date2ts($recur_date,true):0,$role))) |
|
| 1567 | + if (($Ok = $this->so->set_status($cal_id, is_numeric($uid) ? 'u' : $uid[0], |
|
| 1568 | + is_numeric($uid) ? $uid : substr($uid, 1), $status, |
|
| 1569 | + $recur_date ? $this->date2ts($recur_date, true) : 0, $role))) |
|
| 1572 | 1570 | { |
| 1573 | 1571 | if ($status == 'R') // remove alarms belonging to rejected participants |
| 1574 | 1572 | { |
| 1575 | - foreach(is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1573 | + foreach (is_array($event) && isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
|
| 1576 | 1574 | { |
| 1577 | 1575 | if ((string)$alarm['owner'] === (string)$uid) |
| 1578 | 1576 | { |
@@ -1591,8 +1589,8 @@ discard block |
||
| 1591 | 1589 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1592 | 1590 | { |
| 1593 | 1591 | if (!is_array($event)) $event = $this->read($cal_id); |
| 1594 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1595 | - $this->send_update($status2msg[$status],$event['participants'],$event); |
|
| 1592 | + if (isset($recur_date)) $event = $this->read($event['id'], $recur_date); //re-read the actually edited recurring event |
|
| 1593 | + $this->send_update($status2msg[$status], $event['participants'], $event); |
|
| 1596 | 1594 | } |
| 1597 | 1595 | |
| 1598 | 1596 | // Update history |
@@ -1612,14 +1610,14 @@ discard block |
||
| 1612 | 1610 | * @param int $recur_date =0 date to change, or 0 = all since now |
| 1613 | 1611 | * @param boolean $skip_notification Do not send notifications. Parameter passed on to set_status(). |
| 1614 | 1612 | */ |
| 1615 | - function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
|
| 1613 | + function update_status($new_event, $old_event, $recur_date = 0, $skip_notification = false) |
|
| 1616 | 1614 | { |
| 1617 | 1615 | if (!isset($new_event['participants'])) return; |
| 1618 | 1616 | |
| 1619 | 1617 | // check the old list against the new list |
| 1620 | 1618 | foreach ($old_event['participants'] as $userid => $status) |
| 1621 | 1619 | { |
| 1622 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1620 | + if (!isset($new_event['participants'][$userid])) { |
|
| 1623 | 1621 | // Attendee will be deleted this way |
| 1624 | 1622 | $new_event['participants'][$userid] = 'G'; |
| 1625 | 1623 | } |
@@ -1632,7 +1630,7 @@ discard block |
||
| 1632 | 1630 | // write the changes |
| 1633 | 1631 | foreach ($new_event['participants'] as $userid => $status) |
| 1634 | 1632 | { |
| 1635 | - $this->set_status($old_event, $userid, $status, $recur_date, true, false,$skip_notification); |
|
| 1633 | + $this->set_status($old_event, $userid, $status, $recur_date, true, false, $skip_notification); |
|
| 1636 | 1634 | } |
| 1637 | 1635 | } |
| 1638 | 1636 | |
@@ -1647,43 +1645,43 @@ discard block |
||
| 1647 | 1645 | * @param int &$exceptions_kept=null on return number of kept exceptions |
| 1648 | 1646 | * @return boolean true on success, false on error (usually permission denied) |
| 1649 | 1647 | */ |
| 1650 | - function delete($cal_id, $recur_date=0, $ignore_acl=false, $skip_notification=false, |
|
| 1651 | - $delete_exceptions=true, &$exceptions_kept=null) |
|
| 1648 | + function delete($cal_id, $recur_date = 0, $ignore_acl = false, $skip_notification = false, |
|
| 1649 | + $delete_exceptions = true, &$exceptions_kept = null) |
|
| 1652 | 1650 | { |
| 1653 | 1651 | //error_log(__METHOD__."(cal_id=$cal_id, recur_date=$recur_date, ignore_acl=$ignore_acl, skip_notifications=$skip_notification)"); |
| 1654 | - if (!($event = $this->read($cal_id,$recur_date)) || |
|
| 1655 | - !$ignore_acl && !$this->check_perms(Acl::DELETE,$event)) |
|
| 1652 | + if (!($event = $this->read($cal_id, $recur_date)) || |
|
| 1653 | + !$ignore_acl && !$this->check_perms(Acl::DELETE, $event)) |
|
| 1656 | 1654 | { |
| 1657 | 1655 | return false; |
| 1658 | 1656 | } |
| 1659 | 1657 | |
| 1660 | 1658 | // Don't send notification if the event has already been deleted |
| 1661 | - if(!$event['deleted'] && !$skip_notification) |
|
| 1659 | + if (!$event['deleted'] && !$skip_notification) |
|
| 1662 | 1660 | { |
| 1663 | - $this->send_update(MSG_DELETED,$event['participants'],$event); |
|
| 1661 | + $this->send_update(MSG_DELETED, $event['participants'], $event); |
|
| 1664 | 1662 | } |
| 1665 | 1663 | |
| 1666 | 1664 | if (!$recur_date || $event['recur_type'] == MCAL_RECUR_NONE) |
| 1667 | 1665 | { |
| 1668 | 1666 | $config = Api\Config::read('phpgwapi'); |
| 1669 | - if(!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1667 | + if (!$config['calendar_delete_history'] || $event['deleted']) |
|
| 1670 | 1668 | { |
| 1671 | 1669 | $this->so->delete($cal_id); |
| 1672 | 1670 | |
| 1673 | 1671 | // delete all links to the event |
| 1674 | - Link::unlink(0,'calendar',$cal_id); |
|
| 1672 | + Link::unlink(0, 'calendar', $cal_id); |
|
| 1675 | 1673 | } |
| 1676 | 1674 | elseif ($config['calendar_delete_history']) |
| 1677 | 1675 | { |
| 1678 | 1676 | // mark all links to the event as deleted, but keep them |
| 1679 | - Link::unlink(0,'calendar',$cal_id,'','','',true); |
|
| 1677 | + Link::unlink(0, 'calendar', $cal_id, '', '', '', true); |
|
| 1680 | 1678 | |
| 1681 | 1679 | $event['deleted'] = $this->now; |
| 1682 | 1680 | $this->save($event, $ignore_acl); |
| 1683 | 1681 | // Actually delete alarms |
| 1684 | 1682 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1685 | 1683 | { |
| 1686 | - foreach($event['alarm'] as $id => $alarm) |
|
| 1684 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 1687 | 1685 | { |
| 1688 | 1686 | $this->delete_alarm($id); |
| 1689 | 1687 | } |
@@ -1705,7 +1703,7 @@ discard block |
||
| 1705 | 1703 | if (!($exception = $this->read($id))) continue; |
| 1706 | 1704 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1707 | 1705 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1708 | - $this->update($exception, true, true, false, true, $msg=null, true); |
|
| 1706 | + $this->update($exception, true, true, false, true, $msg = null, true); |
|
| 1709 | 1707 | ++$exceptions_kept; |
| 1710 | 1708 | } |
| 1711 | 1709 | } |
@@ -1717,9 +1715,9 @@ discard block |
||
| 1717 | 1715 | if ($event['alarm']) |
| 1718 | 1716 | { |
| 1719 | 1717 | $next_recurrance = null; |
| 1720 | - foreach($event['alarm'] as &$alarm) |
|
| 1718 | + foreach ($event['alarm'] as &$alarm) |
|
| 1721 | 1719 | { |
| 1722 | - if (($alarm['time'] == $recur_date) || ($alarm['time']+$alarm['offset'] == $recur_date)) |
|
| 1720 | + if (($alarm['time'] == $recur_date) || ($alarm['time'] + $alarm['offset'] == $recur_date)) |
|
| 1723 | 1721 | { |
| 1724 | 1722 | //error_log(__METHOD__.__LINE__.'->'.array2string($recur_date)); |
| 1725 | 1723 | //error_log(__METHOD__.__LINE__.array2string($event)); |
@@ -1727,12 +1725,12 @@ discard block |
||
| 1727 | 1725 | { |
| 1728 | 1726 | $checkdate = $recur_date; |
| 1729 | 1727 | //if ($alarm['time']+$alarm['offset'] == $recur_date) $checkdate = $recur_date + $alarm['offset']; |
| 1730 | - if (($e = $this->read($cal_id,$checkdate+1))) |
|
| 1728 | + if (($e = $this->read($cal_id, $checkdate + 1))) |
|
| 1731 | 1729 | { |
| 1732 | 1730 | $next_recurrance = $this->date2ts($e['start']); |
| 1733 | 1731 | } |
| 1734 | 1732 | } |
| 1735 | - $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1733 | + $alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time |
|
| 1736 | 1734 | $alarm['cal_id'] = $cal_id; |
| 1737 | 1735 | unset($alarm['times']); |
| 1738 | 1736 | unset($alarm['next']); |
@@ -1746,7 +1744,7 @@ discard block |
||
| 1746 | 1744 | $event = $this->read($cal_id); |
| 1747 | 1745 | //if (isset($alarmbuffer)) $event['alarm'] = $alarmbuffer; |
| 1748 | 1746 | $event['recur_exception'][] = $recur_date; |
| 1749 | - $this->save($event);// updates the content-history |
|
| 1747 | + $this->save($event); // updates the content-history |
|
| 1750 | 1748 | } |
| 1751 | 1749 | if ($event['reference']) |
| 1752 | 1750 | { |
@@ -1764,19 +1762,19 @@ discard block |
||
| 1764 | 1762 | * @param array $disinvited |
| 1765 | 1763 | * @return array |
| 1766 | 1764 | */ |
| 1767 | - function _get_event_details($event,$action,&$event_arr,$disinvited=array()) |
|
| 1765 | + function _get_event_details($event, $action, &$event_arr, $disinvited = array()) |
|
| 1768 | 1766 | { |
| 1769 | 1767 | $details = array( // event-details for the notify-msg |
| 1770 | 1768 | 'id' => $event['id'], |
| 1771 | 1769 | 'action' => lang($action), |
| 1772 | 1770 | ); |
| 1773 | 1771 | $event_arr = $this->event2array($event); |
| 1774 | - foreach($event_arr as $key => $val) |
|
| 1772 | + foreach ($event_arr as $key => $val) |
|
| 1775 | 1773 | { |
| 1776 | 1774 | if ($key == 'recur_type') $key = 'repetition'; |
| 1777 | 1775 | $details[$key] = $val['data']; |
| 1778 | 1776 | } |
| 1779 | - $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
|
| 1777 | + $details['participants'] = $details['participants'] ? implode("\n", $details['participants']) : ''; |
|
| 1780 | 1778 | |
| 1781 | 1779 | $event_arr['link']['field'] = lang('URL'); |
| 1782 | 1780 | $eventStart_arr = $this->date2array($event['start']); // give this as 'date' to the link to pick the right recurrence for the participants state |
@@ -1797,7 +1795,7 @@ discard block |
||
| 1797 | 1795 | */ |
| 1798 | 1796 | $link_arr = array(); |
| 1799 | 1797 | $link_arr['text'] = $event['title']; |
| 1800 | - $link_arr['view'] = array( 'menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1798 | + $link_arr['view'] = array('menuaction' => 'calendar.calendar_uiforms.edit', |
|
| 1801 | 1799 | 'cal_id' => $event['id'], |
| 1802 | 1800 | 'date' => $eventStart_arr['full'], |
| 1803 | 1801 | ); |
@@ -1805,11 +1803,11 @@ discard block |
||
| 1805 | 1803 | $details['link_arr'] = $link_arr; |
| 1806 | 1804 | |
| 1807 | 1805 | $dis = array(); |
| 1808 | - foreach($disinvited as $uid) |
|
| 1806 | + foreach ($disinvited as $uid) |
|
| 1809 | 1807 | { |
| 1810 | 1808 | $dis[] = $this->participant_name($uid); |
| 1811 | 1809 | } |
| 1812 | - $details['disinvited'] = implode(', ',$dis); |
|
| 1810 | + $details['disinvited'] = implode(', ', $dis); |
|
| 1813 | 1811 | return $details; |
| 1814 | 1812 | } |
| 1815 | 1813 | |
@@ -1833,13 +1831,13 @@ discard block |
||
| 1833 | 1831 | 'data' => $event['description'] |
| 1834 | 1832 | ); |
| 1835 | 1833 | |
| 1836 | - foreach(explode(',',$event['category']) as $cat_id) |
|
| 1834 | + foreach (explode(',', $event['category']) as $cat_id) |
|
| 1837 | 1835 | { |
| 1838 | 1836 | $cat_string[] = stripslashes(Api\Categories::id2name($cat_id)); |
| 1839 | 1837 | } |
| 1840 | 1838 | $var['category'] = Array( |
| 1841 | 1839 | 'field' => lang('Category'), |
| 1842 | - 'data' => implode(', ',$cat_string) |
|
| 1840 | + 'data' => implode(', ', $cat_string) |
|
| 1843 | 1841 | ); |
| 1844 | 1842 | |
| 1845 | 1843 | $var['location'] = Array( |
@@ -1885,7 +1883,7 @@ discard block |
||
| 1885 | 1883 | |
| 1886 | 1884 | if (isset($event['participants']) && is_array($event['participants']) && !empty($event['participants'])) |
| 1887 | 1885 | { |
| 1888 | - $participants = $this->participants($event,true); |
|
| 1886 | + $participants = $this->participants($event, true); |
|
| 1889 | 1887 | } |
| 1890 | 1888 | $var['participants'] = Array( |
| 1891 | 1889 | 'field' => lang('Participants'), |
@@ -1908,26 +1906,26 @@ discard block |
||
| 1908 | 1906 | * @param array $old_event =null event-data in the DB before calling save |
| 1909 | 1907 | * @param string $type ='update' |
| 1910 | 1908 | */ |
| 1911 | - function log2file($event2save,$event_saved,$old_event=null,$type='update') |
|
| 1909 | + function log2file($event2save, $event_saved, $old_event = null, $type = 'update') |
|
| 1912 | 1910 | { |
| 1913 | - if (!($f = fopen($this->log_file,'a'))) |
|
| 1911 | + if (!($f = fopen($this->log_file, 'a'))) |
|
| 1914 | 1912 | { |
| 1915 | 1913 | echo "<p>error opening '$this->log_file' !!!</p>\n"; |
| 1916 | 1914 | return false; |
| 1917 | 1915 | } |
| 1918 | - fwrite($f,$type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1919 | - fwrite($f,"Time: time to save / saved time read back / old time before save\n"); |
|
| 1920 | - foreach(array('start','end') as $name) |
|
| 1916 | + fwrite($f, $type.': '.Api\Accounts::username($this->user).': '.date('r')."\n"); |
|
| 1917 | + fwrite($f, "Time: time to save / saved time read back / old time before save\n"); |
|
| 1918 | + foreach (array('start', 'end') as $name) |
|
| 1921 | 1919 | { |
| 1922 | - fwrite($f,$name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1923 | - $this->format_date($event_saved[$name]) .' / '. |
|
| 1920 | + fwrite($f, $name.': '.(isset($event2save[$name]) ? $this->format_date($event2save[$name]) : 'not set').' / '. |
|
| 1921 | + $this->format_date($event_saved[$name]).' / '. |
|
| 1924 | 1922 | (is_null($old_event) ? 'no old event' : $this->format_date($old_event[$name]))."\n"); |
| 1925 | 1923 | } |
| 1926 | - foreach(array('event2save','event_saved','old_event') as $name) |
|
| 1924 | + foreach (array('event2save', 'event_saved', 'old_event') as $name) |
|
| 1927 | 1925 | { |
| 1928 | - fwrite($f,$name.' = '.print_r($$name,true)); |
|
| 1926 | + fwrite($f, $name.' = '.print_r($$name, true)); |
|
| 1929 | 1927 | } |
| 1930 | - fwrite($f,"\n"); |
|
| 1928 | + fwrite($f, "\n"); |
|
| 1931 | 1929 | fclose($f); |
| 1932 | 1930 | |
| 1933 | 1931 | return true; |
@@ -1948,14 +1946,14 @@ discard block |
||
| 1948 | 1946 | if ($old_event !== null && $event['start'] == $old_event['start']) return; |
| 1949 | 1947 | |
| 1950 | 1948 | $time = new Api\DateTime($event['start']); |
| 1951 | - if(!is_array($event['alarm'])) |
|
| 1949 | + if (!is_array($event['alarm'])) |
|
| 1952 | 1950 | { |
| 1953 | 1951 | $event['alarm'] = $this->so->read_alarms($event['id']); |
| 1954 | 1952 | } |
| 1955 | 1953 | |
| 1956 | - foreach($event['alarm'] as &$alarm) |
|
| 1954 | + foreach ($event['alarm'] as &$alarm) |
|
| 1957 | 1955 | { |
| 1958 | - if($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1956 | + if ($event['recur_type'] != MCAL_RECUR_NONE && is_object($instance_date)) |
|
| 1959 | 1957 | { |
| 1960 | 1958 | calendar_so::shift_alarm($event, $alarm, $instance_date->format('ts')); |
| 1961 | 1959 | } |
@@ -1975,14 +1973,14 @@ discard block |
||
| 1975 | 1973 | * @param boolean $update_modified =true call update modified, default true |
| 1976 | 1974 | * @return string id of the alarm, or false on error (eg. no perms) |
| 1977 | 1975 | */ |
| 1978 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 1976 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 1979 | 1977 | { |
| 1980 | - if (!$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1978 | + if (!$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1981 | 1979 | { |
| 1982 | 1980 | //echo "<p>no rights to save the alarm=".print_r($alarm,true)." to event($cal_id)</p>"; |
| 1983 | - return false; // no rights to add the alarm |
|
| 1981 | + return false; // no rights to add the alarm |
|
| 1984 | 1982 | } |
| 1985 | - $alarm['time'] = $this->date2ts($alarm['time'],true); // user to server-time |
|
| 1983 | + $alarm['time'] = $this->date2ts($alarm['time'], true); // user to server-time |
|
| 1986 | 1984 | |
| 1987 | 1985 | return $this->so->save_alarm($cal_id, $alarm, $update_modified); |
| 1988 | 1986 | } |
@@ -1995,11 +1993,11 @@ discard block |
||
| 1995 | 1993 | */ |
| 1996 | 1994 | function delete_alarm($id) |
| 1997 | 1995 | { |
| 1998 | - list(,$cal_id) = explode(':',$id); |
|
| 1996 | + list(,$cal_id) = explode(':', $id); |
|
| 1999 | 1997 | |
| 2000 | - if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT,$alarm['all'] ? $cal_id : 0,!$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 1998 | + if (!($alarm = $this->so->read_alarm($id)) || !$cal_id || !$this->check_perms(Acl::EDIT, $alarm['all'] ? $cal_id : 0, !$alarm['all'] ? $alarm['owner'] : 0)) |
|
| 2001 | 1999 | { |
| 2002 | - return false; // no rights to delete the alarm |
|
| 2000 | + return false; // no rights to delete the alarm |
|
| 2003 | 2001 | } |
| 2004 | 2002 | |
| 2005 | 2003 | return $this->so->delete_alarm($id); |
@@ -2014,13 +2012,13 @@ discard block |
||
| 2014 | 2012 | * by the ones the user normally does not see due to category permissions - used to preserve categories |
| 2015 | 2013 | * @return array category ids (found, added and preserved categories) |
| 2016 | 2014 | */ |
| 2017 | - function find_or_add_categories($catname_list, $old_event=null) |
|
| 2015 | + function find_or_add_categories($catname_list, $old_event = null) |
|
| 2018 | 2016 | { |
| 2019 | 2017 | if (is_array($old_event) || $old_event > 0) |
| 2020 | 2018 | { |
| 2021 | 2019 | // preserve categories without users read access |
| 2022 | 2020 | if (!is_array($old_event)) $old_event = $this->read($old_event); |
| 2023 | - $old_categories = explode(',',$old_event['category']); |
|
| 2021 | + $old_categories = explode(',', $old_event['category']); |
|
| 2024 | 2022 | $old_cats_preserve = array(); |
| 2025 | 2023 | if (is_array($old_categories) && count($old_categories) > 0) |
| 2026 | 2024 | { |
@@ -2074,7 +2072,7 @@ discard block |
||
| 2074 | 2072 | { |
| 2075 | 2073 | if (!is_array($cat_id_list)) |
| 2076 | 2074 | { |
| 2077 | - $cat_id_list = explode(',',$cat_id_list); |
|
| 2075 | + $cat_id_list = explode(',', $cat_id_list); |
|
| 2078 | 2076 | } |
| 2079 | 2077 | $cat_list = array(); |
| 2080 | 2078 | foreach ($cat_id_list as $cat_id) |
@@ -2099,7 +2097,7 @@ discard block |
||
| 2099 | 2097 | * master -> try to find a releated series master |
| 2100 | 2098 | * @return array calendar_ids of matching entries |
| 2101 | 2099 | */ |
| 2102 | - function find_event($event, $filter='exact') |
|
| 2100 | + function find_event($event, $filter = 'exact') |
|
| 2103 | 2101 | { |
| 2104 | 2102 | $matchingEvents = array(); |
| 2105 | 2103 | $query = array(); |
@@ -2107,14 +2105,14 @@ discard block |
||
| 2107 | 2105 | if ($this->log) |
| 2108 | 2106 | { |
| 2109 | 2107 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2110 | - "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
|
| 2108 | + "($filter)[EVENT]:".array2string($event)."\n", 3, $this->logfile); |
|
| 2111 | 2109 | } |
| 2112 | 2110 | |
| 2113 | 2111 | if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
| 2114 | 2112 | |
| 2115 | 2113 | if ($filter == 'master') |
| 2116 | 2114 | { |
| 2117 | - $query[] = 'recur_type!='. MCAL_RECUR_NONE; |
|
| 2115 | + $query[] = 'recur_type!='.MCAL_RECUR_NONE; |
|
| 2118 | 2116 | $query['cal_recurrence'] = 0; |
| 2119 | 2117 | } |
| 2120 | 2118 | elseif ($filter == 'exact') |
@@ -2135,14 +2133,14 @@ discard block |
||
| 2135 | 2133 | if ($this->log) |
| 2136 | 2134 | { |
| 2137 | 2135 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2138 | - '(' . $event['id'] . ")[EventID]\n",3,$this->logfile); |
|
| 2136 | + '('.$event['id'].")[EventID]\n", 3, $this->logfile); |
|
| 2139 | 2137 | } |
| 2140 | 2138 | if (($egwEvent = $this->read($event['id'], 0, false, 'server'))) |
| 2141 | 2139 | { |
| 2142 | 2140 | if ($this->log) |
| 2143 | 2141 | { |
| 2144 | 2142 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2145 | - '()[FOUND]:' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2143 | + '()[FOUND]:'.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2146 | 2144 | } |
| 2147 | 2145 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE && |
| 2148 | 2146 | (empty($event['uid']) || $event['uid'] == $egwEvent['uid'])) |
@@ -2161,7 +2159,7 @@ discard block |
||
| 2161 | 2159 | $exceptions = $this->so->get_recurrence_exceptions($egwEvent, $event['tzid']); |
| 2162 | 2160 | if (in_array($event['recurrence'], $exceptions)) |
| 2163 | 2161 | { |
| 2164 | - $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
|
| 2162 | + $matchingEvents[] = $egwEvent['id'].':'.(int)$event['recurrence']; |
|
| 2165 | 2163 | } |
| 2166 | 2164 | } |
| 2167 | 2165 | } elseif ($filter != 'master' && ($filter == 'exact' || |
@@ -2180,19 +2178,19 @@ discard block |
||
| 2180 | 2178 | |
| 2181 | 2179 | // only query calendars of users, we have READ-grants from |
| 2182 | 2180 | $users = array(); |
| 2183 | - foreach(array_keys($this->grants) as $user) |
|
| 2181 | + foreach (array_keys($this->grants) as $user) |
|
| 2184 | 2182 | { |
| 2185 | 2183 | $user = trim($user); |
| 2186 | - if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
|
| 2184 | + if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY, 0, $user)) |
|
| 2187 | 2185 | { |
| 2188 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2186 | + if ($user && !in_array($user, $users)) // already added? |
|
| 2189 | 2187 | { |
| 2190 | 2188 | $users[] = $user; |
| 2191 | 2189 | } |
| 2192 | 2190 | } |
| 2193 | 2191 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2194 | 2192 | { |
| 2195 | - continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2193 | + continue; // for non-groups (eg. users), we stop here if we have no read-rights |
|
| 2196 | 2194 | } |
| 2197 | 2195 | // the further code is only for real users |
| 2198 | 2196 | if (!is_numeric($user)) continue; |
@@ -2203,7 +2201,7 @@ discard block |
||
| 2203 | 2201 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 2204 | 2202 | if (is_array($members)) |
| 2205 | 2203 | { |
| 2206 | - foreach($members as $member) |
|
| 2204 | + foreach ($members as $member) |
|
| 2207 | 2205 | { |
| 2208 | 2206 | // use only members which gave the user a read-grant |
| 2209 | 2207 | if (!in_array($member, $users) && |
@@ -2219,7 +2217,7 @@ discard block |
||
| 2219 | 2217 | $memberships = $GLOBALS['egw']->accounts->memberships($user, true); |
| 2220 | 2218 | if (is_array($memberships)) |
| 2221 | 2219 | { |
| 2222 | - foreach($memberships as $group) |
|
| 2220 | + foreach ($memberships as $group) |
|
| 2223 | 2221 | { |
| 2224 | 2222 | if (!in_array($group, $users)) |
| 2225 | 2223 | { |
@@ -2245,24 +2243,24 @@ discard block |
||
| 2245 | 2243 | |
| 2246 | 2244 | // check length with some tolerance |
| 2247 | 2245 | $length = $event['end'] - $event['start'] - $delta; |
| 2248 | - $query[] = ('(cal_end-cal_start)>' . $length); |
|
| 2246 | + $query[] = ('(cal_end-cal_start)>'.$length); |
|
| 2249 | 2247 | $length += 2 * $delta; |
| 2250 | - $query[] = ('(cal_end-cal_start)<' . $length); |
|
| 2251 | - $query[] = ('cal_start>' . ($event['start'] - 86400)); |
|
| 2252 | - $query[] = ('cal_start<' . ($event['start'] + 86400)); |
|
| 2248 | + $query[] = ('(cal_end-cal_start)<'.$length); |
|
| 2249 | + $query[] = ('cal_start>'.($event['start'] - 86400)); |
|
| 2250 | + $query[] = ('cal_start<'.($event['start'] + 86400)); |
|
| 2253 | 2251 | } |
| 2254 | 2252 | elseif (isset($event['start'])) |
| 2255 | 2253 | { |
| 2256 | 2254 | if ($filter == 'relax') |
| 2257 | 2255 | { |
| 2258 | - $query[] = ('cal_start>' . ($event['start'] - 3600)); |
|
| 2259 | - $query[] = ('cal_start<' . ($event['start'] + 3600)); |
|
| 2256 | + $query[] = ('cal_start>'.($event['start'] - 3600)); |
|
| 2257 | + $query[] = ('cal_start<'.($event['start'] + 3600)); |
|
| 2260 | 2258 | } |
| 2261 | 2259 | else |
| 2262 | 2260 | { |
| 2263 | 2261 | // we accept a tiny tolerance |
| 2264 | - $query[] = ('cal_start>' . ($event['start'] - 2)); |
|
| 2265 | - $query[] = ('cal_start<' . ($event['start'] + 2)); |
|
| 2262 | + $query[] = ('cal_start>'.($event['start'] - 2)); |
|
| 2263 | + $query[] = ('cal_start<'.($event['start'] + 2)); |
|
| 2266 | 2264 | } |
| 2267 | 2265 | } |
| 2268 | 2266 | if ($filter == 'relax') |
@@ -2285,14 +2283,14 @@ discard block |
||
| 2285 | 2283 | if ($this->log) |
| 2286 | 2284 | { |
| 2287 | 2285 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2288 | - '(' . $event['uid'] . ")[EventUID]\n",3,$this->logfile); |
|
| 2286 | + '('.$event['uid'].")[EventUID]\n", 3, $this->logfile); |
|
| 2289 | 2287 | } |
| 2290 | 2288 | } |
| 2291 | 2289 | |
| 2292 | 2290 | if ($this->log) |
| 2293 | 2291 | { |
| 2294 | 2292 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2295 | - '[QUERY]: ' . array2string($query)."\n",3,$this->logfile); |
|
| 2293 | + '[QUERY]: '.array2string($query)."\n", 3, $this->logfile); |
|
| 2296 | 2294 | } |
| 2297 | 2295 | if (!count($users) || !($foundEvents = |
| 2298 | 2296 | $this->so->search(null, null, $users, 0, 'owner', false, 0, array('query' => $query)))) |
@@ -2300,19 +2298,19 @@ discard block |
||
| 2300 | 2298 | if ($this->log) |
| 2301 | 2299 | { |
| 2302 | 2300 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2303 | - "[NO MATCH]\n",3,$this->logfile); |
|
| 2301 | + "[NO MATCH]\n", 3, $this->logfile); |
|
| 2304 | 2302 | } |
| 2305 | 2303 | return $matchingEvents; |
| 2306 | 2304 | } |
| 2307 | 2305 | |
| 2308 | 2306 | $pseudos = array(); |
| 2309 | 2307 | |
| 2310 | - foreach($foundEvents as $egwEvent) |
|
| 2308 | + foreach ($foundEvents as $egwEvent) |
|
| 2311 | 2309 | { |
| 2312 | 2310 | if ($this->log) |
| 2313 | 2311 | { |
| 2314 | 2312 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2315 | - '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
|
| 2313 | + '[FOUND]: '.array2string($egwEvent)."\n", 3, $this->logfile); |
|
| 2316 | 2314 | } |
| 2317 | 2315 | |
| 2318 | 2316 | if (in_array($egwEvent['id'], $matchingEvents)) continue; |
@@ -2386,7 +2384,7 @@ discard block |
||
| 2386 | 2384 | if (in_array($event['recurrence'], $exceptions)) |
| 2387 | 2385 | { |
| 2388 | 2386 | // We found a pseudo exception |
| 2389 | - $matchingEvents = array($egwEvent['id'] . ':' . (int)$event['recurrence']); |
|
| 2387 | + $matchingEvents = array($egwEvent['id'].':'.(int)$event['recurrence']); |
|
| 2390 | 2388 | break; |
| 2391 | 2389 | } |
| 2392 | 2390 | } |
@@ -2404,7 +2402,7 @@ discard block |
||
| 2404 | 2402 | if ($this->log) |
| 2405 | 2403 | { |
| 2406 | 2404 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2407 | - "() egwEvent length does not match!\n",3,$this->logfile); |
|
| 2405 | + "() egwEvent length does not match!\n", 3, $this->logfile); |
|
| 2408 | 2406 | } |
| 2409 | 2407 | continue; |
| 2410 | 2408 | } |
@@ -2416,7 +2414,7 @@ discard block |
||
| 2416 | 2414 | if ($this->log) |
| 2417 | 2415 | { |
| 2418 | 2416 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2419 | - "() egwEvent is not a whole-day event!\n",3,$this->logfile); |
|
| 2417 | + "() egwEvent is not a whole-day event!\n", 3, $this->logfile); |
|
| 2420 | 2418 | } |
| 2421 | 2419 | continue; |
| 2422 | 2420 | } |
@@ -2437,8 +2435,8 @@ discard block |
||
| 2437 | 2435 | if ($this->log) |
| 2438 | 2436 | { |
| 2439 | 2437 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2440 | - "() event[$key] differ: '" . $event[$key] . |
|
| 2441 | - "' <> '" . $egwEvent[$key] . "'\n",3,$this->logfile); |
|
| 2438 | + "() event[$key] differ: '".$event[$key]. |
|
| 2439 | + "' <> '".$egwEvent[$key]."'\n", 3, $this->logfile); |
|
| 2442 | 2440 | } |
| 2443 | 2441 | continue 2; // next foundEvent |
| 2444 | 2442 | } |
@@ -2456,7 +2454,7 @@ discard block |
||
| 2456 | 2454 | if ($this->log) |
| 2457 | 2455 | { |
| 2458 | 2456 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2459 | - "() egwEvent category $cat_id is missing!\n",3,$this->logfile); |
|
| 2457 | + "() egwEvent category $cat_id is missing!\n", 3, $this->logfile); |
|
| 2460 | 2458 | } |
| 2461 | 2459 | continue 2; |
| 2462 | 2460 | } |
@@ -2468,7 +2466,7 @@ discard block |
||
| 2468 | 2466 | { |
| 2469 | 2467 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2470 | 2468 | '() event has additional categories:' |
| 2471 | - . array2string($newCategories)."\n",3,$this->logfile); |
|
| 2469 | + . array2string($newCategories)."\n", 3, $this->logfile); |
|
| 2472 | 2470 | } |
| 2473 | 2471 | continue; |
| 2474 | 2472 | } |
@@ -2488,7 +2486,7 @@ discard block |
||
| 2488 | 2486 | if ($this->log) |
| 2489 | 2487 | { |
| 2490 | 2488 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2491 | - "() additional event['participants']: $attendee\n",3,$this->logfile); |
|
| 2489 | + "() additional event['participants']: $attendee\n", 3, $this->logfile); |
|
| 2492 | 2490 | } |
| 2493 | 2491 | continue 2; |
| 2494 | 2492 | } |
@@ -2511,8 +2509,8 @@ discard block |
||
| 2511 | 2509 | if ($this->log) |
| 2512 | 2510 | { |
| 2513 | 2511 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2514 | - '() missing event[participants]: ' . |
|
| 2515 | - array2string($egwEvent['participants'])."\n",3,$this->logfile); |
|
| 2512 | + '() missing event[participants]: '. |
|
| 2513 | + array2string($egwEvent['participants'])."\n", 3, $this->logfile); |
|
| 2516 | 2514 | } |
| 2517 | 2515 | continue; |
| 2518 | 2516 | } |
@@ -2524,7 +2522,7 @@ discard block |
||
| 2524 | 2522 | if ($egwEvent['recur_type'] != MCAL_RECUR_NONE) |
| 2525 | 2523 | { |
| 2526 | 2524 | // We found a pseudo Exception |
| 2527 | - $pseudos[] = $egwEvent['id'] . ':' . $event['start']; |
|
| 2525 | + $pseudos[] = $egwEvent['id'].':'.$event['start']; |
|
| 2528 | 2526 | continue; |
| 2529 | 2527 | } |
| 2530 | 2528 | } |
@@ -2546,7 +2544,7 @@ discard block |
||
| 2546 | 2544 | if ($this->log) |
| 2547 | 2545 | { |
| 2548 | 2546 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2549 | - "() additional event['recur_exception']: $day\n",3,$this->logfile); |
|
| 2547 | + "() additional event['recur_exception']: $day\n", 3, $this->logfile); |
|
| 2550 | 2548 | } |
| 2551 | 2549 | continue 2; |
| 2552 | 2550 | } |
@@ -2556,8 +2554,8 @@ discard block |
||
| 2556 | 2554 | if ($this->log) |
| 2557 | 2555 | { |
| 2558 | 2556 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2559 | - '() missing event[recur_exception]: ' . |
|
| 2560 | - array2string($event['recur_exception'])."\n",3,$this->logfile); |
|
| 2557 | + '() missing event[recur_exception]: '. |
|
| 2558 | + array2string($event['recur_exception'])."\n", 3, $this->logfile); |
|
| 2561 | 2559 | } |
| 2562 | 2560 | continue; |
| 2563 | 2561 | } |
@@ -2572,8 +2570,8 @@ discard block |
||
| 2572 | 2570 | if ($this->log) |
| 2573 | 2571 | { |
| 2574 | 2572 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2575 | - "() events[$key] differ: " . $event[$key] . |
|
| 2576 | - ' <> ' . $egwEvent[$key]."\n",3,$this->logfile); |
|
| 2573 | + "() events[$key] differ: ".$event[$key]. |
|
| 2574 | + ' <> '.$egwEvent[$key]."\n", 3, $this->logfile); |
|
| 2577 | 2575 | } |
| 2578 | 2576 | continue 2; |
| 2579 | 2577 | } |
@@ -2589,7 +2587,7 @@ discard block |
||
| 2589 | 2587 | if ($this->log) |
| 2590 | 2588 | { |
| 2591 | 2589 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2592 | - "() new exception for series found.\n",3,$this->logfile); |
|
| 2590 | + "() new exception for series found.\n", 3, $this->logfile); |
|
| 2593 | 2591 | } |
| 2594 | 2592 | $matchingEvents = array(); |
| 2595 | 2593 | } |
@@ -2600,7 +2598,7 @@ discard block |
||
| 2600 | 2598 | if ($this->log) |
| 2601 | 2599 | { |
| 2602 | 2600 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2603 | - '[MATCHES]:' . array2string($matches)."\n",3,$this->logfile); |
|
| 2601 | + '[MATCHES]:'.array2string($matches)."\n", 3, $this->logfile); |
|
| 2604 | 2602 | } |
| 2605 | 2603 | return $matches; |
| 2606 | 2604 | } |
@@ -2673,7 +2671,7 @@ discard block |
||
| 2673 | 2671 | if ($this->log) |
| 2674 | 2672 | { |
| 2675 | 2673 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2676 | - "()[MASTER]: $eventID\n",3,$this->logfile); |
|
| 2674 | + "()[MASTER]: $eventID\n", 3, $this->logfile); |
|
| 2677 | 2675 | } |
| 2678 | 2676 | $type = 'SERIES-EXCEPTION'; |
| 2679 | 2677 | if (($master_event = $this->read($eventID, 0, false, 'server'))) |
@@ -2694,7 +2692,7 @@ discard block |
||
| 2694 | 2692 | } |
| 2695 | 2693 | elseif (in_array($event['start'], $master_event['recur_exception'])) |
| 2696 | 2694 | { |
| 2697 | - $type='SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2695 | + $type = 'SERIES-PSEUDO-EXCEPTION'; // new pseudo exception? |
|
| 2698 | 2696 | $recurrence_event = $master_event; |
| 2699 | 2697 | $recurrence_event['start'] = $event['start']; |
| 2700 | 2698 | $recurrence_event['end'] -= $master_event['start'] - $event['start']; |
@@ -2711,8 +2709,8 @@ discard block |
||
| 2711 | 2709 | if ($this->log) |
| 2712 | 2710 | { |
| 2713 | 2711 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2714 | - '() try occurrence ' . $egw_rrule->current() |
|
| 2715 | - . " ($occurrence)\n",3,$this->logfile); |
|
| 2712 | + '() try occurrence '.$egw_rrule->current() |
|
| 2713 | + . " ($occurrence)\n", 3, $this->logfile); |
|
| 2716 | 2714 | } |
| 2717 | 2715 | if ($event['start'] == $occurrence) |
| 2718 | 2716 | { |
@@ -2745,8 +2743,8 @@ discard block |
||
| 2745 | 2743 | // default if we cannot find a proof for a fundamental change |
| 2746 | 2744 | // the recurrence_event is the master event with start and end adjusted to the recurrence |
| 2747 | 2745 | // check for changed data |
| 2748 | - foreach (array('start','end','uid','title','location','description', |
|
| 2749 | - 'priority','public','special','non_blocking') as $key) |
|
| 2746 | + foreach (array('start', 'end', 'uid', 'title', 'location', 'description', |
|
| 2747 | + 'priority', 'public', 'special', 'non_blocking') as $key) |
|
| 2750 | 2748 | { |
| 2751 | 2749 | if (!empty($event[$key]) && $recurrence_event[$key] != $event[$key]) |
| 2752 | 2750 | { |
@@ -2804,10 +2802,10 @@ discard block |
||
| 2804 | 2802 | * @param &$event the event we are working on |
| 2805 | 2803 | * |
| 2806 | 2804 | */ |
| 2807 | - function server2usertime (&$event) |
|
| 2805 | + function server2usertime(&$event) |
|
| 2808 | 2806 | { |
| 2809 | 2807 | // we run all dates through date2usertime, to adjust to user-time |
| 2810 | - foreach(array('start','end','recur_enddate','recurrence') as $ts) |
|
| 2808 | + foreach (array('start', 'end', 'recur_enddate', 'recurrence') as $ts) |
|
| 2811 | 2809 | { |
| 2812 | 2810 | // we convert here from server-time to timestamps in user-time! |
| 2813 | 2811 | if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
@@ -2815,7 +2813,7 @@ discard block |
||
| 2815 | 2813 | // same with the recur exceptions |
| 2816 | 2814 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 2817 | 2815 | { |
| 2818 | - foreach($event['recur_exception'] as $n => $date) |
|
| 2816 | + foreach ($event['recur_exception'] as $n => $date) |
|
| 2819 | 2817 | { |
| 2820 | 2818 | $event['recur_exception'][$n] = $this->date2usertime($date); |
| 2821 | 2819 | } |
@@ -2823,7 +2821,7 @@ discard block |
||
| 2823 | 2821 | // same with the alarms |
| 2824 | 2822 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 2825 | 2823 | { |
| 2826 | - foreach($event['alarm'] as $id => $alarm) |
|
| 2824 | + foreach ($event['alarm'] as $id => $alarm) |
|
| 2827 | 2825 | { |
| 2828 | 2826 | $event['alarm'][$id]['time'] = $this->date2usertime($alarm['time']); |
| 2829 | 2827 | } |
@@ -2840,7 +2838,7 @@ discard block |
||
| 2840 | 2838 | { |
| 2841 | 2839 | if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
| 2842 | 2840 | { |
| 2843 | - $this->so->purge(time() - 365*24*3600*(float)$age); |
|
| 2841 | + $this->so->purge(time() - 365 * 24 * 3600 * (float)$age); |
|
| 2844 | 2842 | } |
| 2845 | 2843 | } |
| 2846 | 2844 | } |