@@ -1490,13 +1490,13 @@ discard block |
||
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | /** |
| 1493 | - * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | - * |
|
| 1495 | - * @param string|int $id id of user or resource |
|
| 1496 | - * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | - * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | - * @return string with name |
|
| 1499 | - */ |
|
| 1493 | + * Converts a participant into a (readable) user- or resource-name |
|
| 1494 | + * |
|
| 1495 | + * @param string|int $id id of user or resource |
|
| 1496 | + * @param string|boolean $use_type =false type-letter or false |
|
| 1497 | + * @param boolean $append_email =false append email (Name <email>) |
|
| 1498 | + * @return string with name |
|
| 1499 | + */ |
|
| 1500 | 1500 | function participant_name($id,$use_type=false, $append_email=false) |
| 1501 | 1501 | { |
| 1502 | 1502 | static $id2lid = array(); |
@@ -1525,13 +1525,13 @@ discard block |
||
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | /** |
| 1528 | - * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | - * |
|
| 1530 | - * @param array $event event-data |
|
| 1531 | - * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | - * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | - * @return array with id / names with status pairs |
|
| 1534 | - */ |
|
| 1528 | + * Converts participants array of an event into array of (readable) participant-names with status |
|
| 1529 | + * |
|
| 1530 | + * @param array $event event-data |
|
| 1531 | + * @param boolean $long_status =false should the long/verbose status or an icon be use |
|
| 1532 | + * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
|
| 1533 | + * @return array with id / names with status pairs |
|
| 1534 | + */ |
|
| 1535 | 1535 | function participants($event,$long_status=false,$show_group_invitation=false) |
| 1536 | 1536 | { |
| 1537 | 1537 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
@@ -1601,12 +1601,12 @@ discard block |
||
| 1601 | 1601 | } |
| 1602 | 1602 | |
| 1603 | 1603 | /** |
| 1604 | - * Converts category string of an event into array of (readable) category-names |
|
| 1605 | - * |
|
| 1606 | - * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | - * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | - * @return array with id / names |
|
| 1609 | - */ |
|
| 1604 | + * Converts category string of an event into array of (readable) category-names |
|
| 1605 | + * |
|
| 1606 | + * @param string $category cat-id (multiple id's commaseparated) |
|
| 1607 | + * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
|
| 1608 | + * @return array with id / names |
|
| 1609 | + */ |
|
| 1610 | 1610 | function categories($category,&$color) |
| 1611 | 1611 | { |
| 1612 | 1612 | static $id2cat = array(); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | /** |
| 123 | 123 | * @var array recur_types translates MCAL recur-types to verbose labels |
| 124 | 124 | */ |
| 125 | - var $recur_types = Array( |
|
| 125 | + var $recur_types = array( |
|
| 126 | 126 | MCAL_RECUR_NONE => 'No recurrence', |
| 127 | 127 | MCAL_RECUR_DAILY => 'Daily', |
| 128 | 128 | MCAL_RECUR_WEEKLY => 'Weekly', |
@@ -1897,7 +1897,7 @@ discard block |
||
| 1897 | 1897 | * @param string $pattern pattern to search |
| 1898 | 1898 | * @return array with cal_id - title pairs of the matching entries |
| 1899 | 1899 | */ |
| 1900 | - function link_query($pattern, Array &$options = array()) |
|
| 1900 | + function link_query($pattern, array &$options = array()) |
|
| 1901 | 1901 | { |
| 1902 | 1902 | $result = array(); |
| 1903 | 1903 | $query = array( |
@@ -632,8 +632,8 @@ discard block |
||
| 632 | 632 | * or an ExecMethod callback with parameters $id,$event |
| 633 | 633 | * |
| 634 | 634 | * @param string $app |
| 635 | - * @param int|string $id |
|
| 636 | - * @return string |
|
| 635 | + * @param string $id |
|
| 636 | + * @return boolean |
|
| 637 | 637 | */ |
| 638 | 638 | static function integration_get_private($app,$id,$event) |
| 639 | 639 | { |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | * This methods operates in usertime, while $this->config['horizont'] is in servertime! |
| 763 | 763 | * |
| 764 | 764 | * @param array $event |
| 765 | - * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
|
| 765 | + * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
|
| 766 | 766 | */ |
| 767 | 767 | function set_recurrences($event,$start=0) |
| 768 | 768 | { |
@@ -982,10 +982,9 @@ discard block |
||
| 982 | 982 | * Recurrences get calculated by rrule iterator implemented in calendar_rrule class. |
| 983 | 983 | * |
| 984 | 984 | * @param array $event repeating event whos repetions should be inserted |
| 985 | - * @param mixed $start start-date |
|
| 985 | + * @param mixed $_start start-date |
|
| 986 | 986 | * @param mixed $end end-date |
| 987 | 987 | * @param array $events where the repetions get inserted |
| 988 | - * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
|
| 989 | 988 | */ |
| 990 | 989 | function insert_all_recurrences($event,$_start,$end,&$events) |
| 991 | 990 | { |
@@ -1139,7 +1138,7 @@ discard block |
||
| 1139 | 1138 | * even if you have no general read-grant from that user. |
| 1140 | 1139 | * |
| 1141 | 1140 | * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE} |
| 1142 | - * @param mixed $event event as array or the event-id or 0 for a general check |
|
| 1141 | + * @param integer $event event as array or the event-id or 0 for a general check |
|
| 1143 | 1142 | * @param int $other uid to check (if event==0) or 0 to check against $this->user |
| 1144 | 1143 | * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc |
| 1145 | 1144 | * @param mixed $date_to_read =null date used for reading, internal param for the caching |
@@ -1312,8 +1311,6 @@ discard block |
||
| 1312 | 1311 | * @param string $msg message with parameters/variables like lang(), eg. '%1' |
| 1313 | 1312 | * @param boolean $backtrace =True include a function-backtrace, default True=On |
| 1314 | 1313 | * should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!! |
| 1315 | - * @param mixed $param a variable number of parameters, to be inserted in $msg |
|
| 1316 | - * arrays get serialized with print_r() ! |
|
| 1317 | 1314 | */ |
| 1318 | 1315 | static function debug_message($msg,$backtrace=True) |
| 1319 | 1316 | { |
@@ -1378,7 +1375,7 @@ discard block |
||
| 1378 | 1375 | * Formats one or two dates (range) as long date (full monthname), optionaly with a time |
| 1379 | 1376 | * |
| 1380 | 1377 | * @param mixed $_first first date |
| 1381 | - * @param mixed $last =0 last date if != 0 (default) |
|
| 1378 | + * @param integer $last =0 last date if != 0 (default) |
|
| 1382 | 1379 | * @param boolean $display_time =false should a time be displayed too |
| 1383 | 1380 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
| 1384 | 1381 | * @return string with formated date |
@@ -1847,7 +1844,6 @@ discard block |
||
| 1847 | 1844 | * |
| 1848 | 1845 | * Is called as hook to participate in the linking |
| 1849 | 1846 | * |
| 1850 | - * @param int|array $entry int cal_id or array with event |
|
| 1851 | 1847 | * @param string|boolean string with title, null if not found or false if not read perms |
| 1852 | 1848 | */ |
| 1853 | 1849 | function link_title($event) |
@@ -2036,6 +2032,7 @@ discard block |
||
| 2036 | 2032 | * |
| 2037 | 2033 | * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions |
| 2038 | 2034 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
| 2035 | + * @param string $schedule_tag |
|
| 2039 | 2036 | * @return string|boolean string with etag or false |
| 2040 | 2037 | */ |
| 2041 | 2038 | function get_etag($entry, &$schedule_tag=null) |
@@ -2076,7 +2073,6 @@ discard block |
||
| 2076 | 2073 | * Hook for infolog to set some extra data and links |
| 2077 | 2074 | * |
| 2078 | 2075 | * @param array $data event-array preset by infolog plus |
| 2079 | - * @param int $data[id] cal_id |
|
| 2080 | 2076 | * @return array with key => value pairs to set in new event and link_app/link_id arrays |
| 2081 | 2077 | */ |
| 2082 | 2078 | function infolog_set($data) |
@@ -2128,7 +2124,6 @@ discard block |
||
| 2128 | 2124 | * Hook for timesheet to set some extra data and links |
| 2129 | 2125 | * |
| 2130 | 2126 | * @param array $data |
| 2131 | - * @param int $data[id] cal_id:recurrence |
|
| 2132 | 2127 | * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays |
| 2133 | 2128 | */ |
| 2134 | 2129 | function timesheet_set($data) |
@@ -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 | } |
@@ -572,18 +572,18 @@ discard block |
||
| 572 | 572 | * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param) |
| 573 | 573 | * or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given |
| 574 | 574 | */ |
| 575 | - function &search($params,$sql_filter=null) |
|
| 575 | + function &search($params, $sql_filter = null) |
|
| 576 | 576 | { |
| 577 | 577 | $params_in = $params; |
| 578 | 578 | |
| 579 | - $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
| 579 | + $params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc |
|
| 580 | 580 | |
| 581 | 581 | // check if any resource wants to hook into |
| 582 | - foreach($this->resources as $data) |
|
| 582 | + foreach ($this->resources as $data) |
|
| 583 | 583 | { |
| 584 | 584 | if (isset($data['search_filter'])) |
| 585 | 585 | { |
| 586 | - $params = ExecMethod($data['search_filter'],$params); |
|
| 586 | + $params = ExecMethod($data['search_filter'], $params); |
|
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | |
@@ -601,9 +601,9 @@ discard block |
||
| 601 | 601 | if (!empty($params['query'])) |
| 602 | 602 | { |
| 603 | 603 | $params['private_grants'] = array(); |
| 604 | - foreach($this->grants as $user => $rights) |
|
| 604 | + foreach ($this->grants as $user => $rights) |
|
| 605 | 605 | { |
| 606 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 606 | + if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 607 | 607 | } |
| 608 | 608 | } |
| 609 | 609 | |
@@ -629,49 +629,49 @@ discard block |
||
| 629 | 629 | $params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring']; |
| 630 | 630 | $cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0; |
| 631 | 631 | $filter = isset($params['filter']) ? $params['filter'] : 'all'; |
| 632 | - $offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false; |
|
| 632 | + $offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false; |
|
| 633 | 633 | // socal::search() returns rejected group-invitations, as only the user not also the group is rejected |
| 634 | 634 | // as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed |
| 635 | 635 | $users_in = (array)$params_in['users']; |
| 636 | - $remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) && |
|
| 636 | + $remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) && |
|
| 637 | 637 | count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null; |
| 638 | 638 | //error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user)); |
| 639 | 639 | |
| 640 | 640 | if ($this->debug && ($this->debug > 1 || $this->debug == 'search')) |
| 641 | 641 | { |
| 642 | 642 | $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)', |
| 643 | - True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']); |
|
| 643 | + True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']); |
|
| 644 | 644 | } |
| 645 | 645 | // date2ts(,true) converts to server time, db2data converts again to user-time |
| 646 | - $events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null, |
|
| 647 | - $users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user); |
|
| 646 | + $events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null, |
|
| 647 | + $users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user); |
|
| 648 | 648 | |
| 649 | 649 | if (isset($params['cols'])) |
| 650 | 650 | { |
| 651 | 651 | return $events; |
| 652 | 652 | } |
| 653 | 653 | $this->total = $this->so->total; |
| 654 | - $this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
| 654 | + $this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts'); |
|
| 655 | 655 | |
| 656 | 656 | //echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n"; |
| 657 | - foreach($events as $id => $event) |
|
| 657 | + foreach ($events as $id => $event) |
|
| 658 | 658 | { |
| 659 | 659 | if ($params['enum_groups'] && $this->enum_groups($event)) |
| 660 | 660 | { |
| 661 | 661 | $events[$id] = $event; |
| 662 | 662 | } |
| 663 | 663 | $matches = null; |
| 664 | - if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches)) |
|
| 664 | + if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches)) |
|
| 665 | 665 | { |
| 666 | - $is_private = self::integration_get_private($matches[1],$matches[2],$event); |
|
| 666 | + $is_private = self::integration_get_private($matches[1], $matches[2], $event); |
|
| 667 | 667 | } |
| 668 | 668 | else |
| 669 | 669 | { |
| 670 | - $is_private = !$this->check_perms(Acl::READ,$event); |
|
| 670 | + $is_private = !$this->check_perms(Acl::READ, $event); |
|
| 671 | 671 | } |
| 672 | 672 | if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate'))) |
| 673 | 673 | { |
| 674 | - $this->clear_private_infos($events[$id],$params['private_allowed'] ? $params['private_allowed'] : $users); |
|
| 674 | + $this->clear_private_infos($events[$id], $params['private_allowed'] ? $params['private_allowed'] : $users); |
|
| 675 | 675 | } |
| 676 | 676 | } |
| 677 | 677 | |
@@ -679,18 +679,18 @@ discard block |
||
| 679 | 679 | { |
| 680 | 680 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
| 681 | 681 | { |
| 682 | - $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
|
| 682 | + $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events); |
|
| 683 | 683 | } |
| 684 | 684 | // create empty entries for each day in the reported time |
| 685 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 685 | + for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 686 | 686 | { |
| 687 | 687 | $daysEvents[$this->date2string($ts)] = array(); |
| 688 | 688 | } |
| 689 | - foreach($events as $k => $event) |
|
| 689 | + foreach ($events as $k => $event) |
|
| 690 | 690 | { |
| 691 | - $e_start = max($this->date2ts($event['start']),$start); |
|
| 691 | + $e_start = max($this->date2ts($event['start']), $start); |
|
| 692 | 692 | // $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59 |
| 693 | - $e_end = min($this->date2ts($event['end'])-1,$end); |
|
| 693 | + $e_end = min($this->date2ts($event['end']) - 1, $end); |
|
| 694 | 694 | |
| 695 | 695 | // add event to each day in the reported time |
| 696 | 696 | $ts = $e_start; |
@@ -699,23 +699,23 @@ discard block |
||
| 699 | 699 | $ymd = null; |
| 700 | 700 | while ($ts <= $e_end) |
| 701 | 701 | { |
| 702 | - $daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k]; |
|
| 703 | - $ts = strtotime("+1 day",$ts); |
|
| 702 | + $daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k]; |
|
| 703 | + $ts = strtotime("+1 day", $ts); |
|
| 704 | 704 | } |
| 705 | 705 | if ($ymd != ($last = $this->date2string($e_end))) |
| 706 | 706 | { |
| 707 | - $daysEvents[$last][] =& $events[$k]; |
|
| 707 | + $daysEvents[$last][] = & $events[$k]; |
|
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | - $events =& $daysEvents; |
|
| 710 | + $events = & $daysEvents; |
|
| 711 | 711 | if ($this->debug && ($this->debug > 2 || $this->debug == 'search')) |
| 712 | 712 | { |
| 713 | - $this->debug_message('socalendar::search daywise events=%1',False,$events); |
|
| 713 | + $this->debug_message('socalendar::search daywise events=%1', False, $events); |
|
| 714 | 714 | } |
| 715 | 715 | } |
| 716 | 716 | if ($this->debug && ($this->debug > 0 || $this->debug == 'search')) |
| 717 | 717 | { |
| 718 | - $this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events); |
|
| 718 | + $this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events); |
|
| 719 | 719 | } |
| 720 | 720 | //error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace()); |
| 721 | 721 | return $events; |
@@ -728,9 +728,9 @@ discard block |
||
| 728 | 728 | * @param string $part |
| 729 | 729 | * @return array |
| 730 | 730 | */ |
| 731 | - static function integration_get_data($app,$part=null) |
|
| 731 | + static function integration_get_data($app, $part = null) |
|
| 732 | 732 | { |
| 733 | - static $integration_data=null; |
|
| 733 | + static $integration_data = null; |
|
| 734 | 734 | |
| 735 | 735 | if (!isset($integration_data)) |
| 736 | 736 | { |
@@ -752,14 +752,14 @@ discard block |
||
| 752 | 752 | * @param int|string $id |
| 753 | 753 | * @return string |
| 754 | 754 | */ |
| 755 | - static function integration_get_private($app,$id,$event) |
|
| 755 | + static function integration_get_private($app, $id, $event) |
|
| 756 | 756 | { |
| 757 | - $app_data = self::integration_get_data($app,'is_private'); |
|
| 757 | + $app_data = self::integration_get_data($app, 'is_private'); |
|
| 758 | 758 | |
| 759 | 759 | // no method, fall back to link title |
| 760 | 760 | if (is_null($app_data)) |
| 761 | 761 | { |
| 762 | - $is_private = !Link::title($app,$id); |
|
| 762 | + $is_private = !Link::title($app, $id); |
|
| 763 | 763 | } |
| 764 | 764 | // boolean value to make all events of $app public (false) or private (true) |
| 765 | 765 | elseif (is_bool($app_data)) |
@@ -768,7 +768,7 @@ discard block |
||
| 768 | 768 | } |
| 769 | 769 | else |
| 770 | 770 | { |
| 771 | - $is_private = (bool)ExecMethod2($app_data,$id,$event); |
|
| 771 | + $is_private = (bool)ExecMethod2($app_data, $id, $event); |
|
| 772 | 772 | } |
| 773 | 773 | //echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n"; |
| 774 | 774 | return $is_private; |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | * @param array &$event |
| 783 | 783 | * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar |
| 784 | 784 | */ |
| 785 | - function clear_private_infos(&$event,$allowed_participants = array()) |
|
| 785 | + function clear_private_infos(&$event, $allowed_participants = array()) |
|
| 786 | 786 | { |
| 787 | 787 | if ($event == false) return; |
| 788 | 788 | if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
@@ -798,19 +798,19 @@ discard block |
||
| 798 | 798 | 'owner' => $event['owner'], |
| 799 | 799 | 'uid' => $event['uid'], |
| 800 | 800 | 'etag' => $event['etag'], |
| 801 | - 'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)), |
|
| 801 | + 'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)), |
|
| 802 | 802 | 'public'=> 0, |
| 803 | - 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
| 803 | + 'category' => $event['category'], // category is visible anyway, eg. by using planner by cat |
|
| 804 | 804 | 'non_blocking' => $event['non_blocking'], |
| 805 | 805 | 'caldav_name' => $event['caldav_name'], |
| 806 | 806 | // we need full recurrence information, as they are relevant free/busy information |
| 807 | - )+($event['recur_type'] ? array( |
|
| 807 | + ) + ($event['recur_type'] ? array( |
|
| 808 | 808 | 'recur_type' => $event['recur_type'], |
| 809 | 809 | 'recur_interval' => $event['recur_interval'], |
| 810 | 810 | 'recur_data' => $event['recur_data'], |
| 811 | 811 | 'recur_enddate' => $event['recur_enddate'], |
| 812 | 812 | 'recur_exception'=> $event['recur_exception'], |
| 813 | - ):array( |
|
| 813 | + ) : array( |
|
| 814 | 814 | 'reference' => $event['reference'], |
| 815 | 815 | 'recurrence' => $event['recurrence'], |
| 816 | 816 | )); |
@@ -824,15 +824,15 @@ discard block |
||
| 824 | 824 | */ |
| 825 | 825 | function check_move_horizont($_new_horizont) |
| 826 | 826 | { |
| 827 | - if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
| 827 | + if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont') |
|
| 828 | 828 | { |
| 829 | - $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']); |
|
| 829 | + $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']); |
|
| 830 | 830 | } |
| 831 | - $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
|
| 831 | + $new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates |
|
| 832 | 832 | |
| 833 | 833 | if ($new_horizont <= $this->config['horizont']) // no move necessary |
| 834 | 834 | { |
| 835 | - 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']); |
|
| 835 | + 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']); |
|
| 836 | 836 | return; |
| 837 | 837 | } |
| 838 | 838 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
@@ -840,15 +840,15 @@ discard block |
||
| 840 | 840 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 841 | 841 | } |
| 842 | 842 | if (empty($maxdays)) $maxdays = 1000; // old default |
| 843 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 843 | + if ($new_horizont > time() + $maxdays * DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 844 | 844 | { |
| 845 | - 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); |
|
| 846 | - $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
|
| 845 | + 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); |
|
| 846 | + $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays); |
|
| 847 | 847 | return; |
| 848 | 848 | } |
| 849 | - if ($new_horizont < time()+31*DAY_s) |
|
| 849 | + if ($new_horizont < time() + 31 * DAY_s) |
|
| 850 | 850 | { |
| 851 | - $new_horizont = time()+31*DAY_s; |
|
| 851 | + $new_horizont = time() + 31 * DAY_s; |
|
| 852 | 852 | } |
| 853 | 853 | $old_horizont = $this->config['horizont']; |
| 854 | 854 | $this->config['horizont'] = $new_horizont; |
@@ -856,21 +856,21 @@ discard block |
||
| 856 | 856 | // create further recurrences for all recurring and not yet (at the old horizont) ended events |
| 857 | 857 | if (($recuring = $this->so->unfinished_recuring($old_horizont))) |
| 858 | 858 | { |
| 859 | - @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
| 860 | - foreach($this->read(array_keys($recuring)) as $cal_id => $event) |
|
| 859 | + @set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences |
|
| 860 | + foreach ($this->read(array_keys($recuring)) as $cal_id => $event) |
|
| 861 | 861 | { |
| 862 | 862 | if ($this->debug == 'check_move_horizont') |
| 863 | 863 | { |
| 864 | - $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont); |
|
| 864 | + $this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont); |
|
| 865 | 865 | } |
| 866 | 866 | // insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past |
| 867 | - $this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1)); // set_recurences operates in user-time! |
|
| 867 | + $this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time! |
|
| 868 | 868 | } |
| 869 | 869 | } |
| 870 | 870 | // update the horizont |
| 871 | - Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
|
| 871 | + Api\Config::save_value('horizont', $this->config['horizont'], 'calendar'); |
|
| 872 | 872 | |
| 873 | - 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']); |
|
| 873 | + 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']); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |
@@ -881,11 +881,11 @@ discard block |
||
| 881 | 881 | * @param array $event |
| 882 | 882 | * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event |
| 883 | 883 | */ |
| 884 | - function set_recurrences($event,$start=0) |
|
| 884 | + function set_recurrences($event, $start = 0) |
|
| 885 | 885 | { |
| 886 | - if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
| 886 | + if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont')) |
|
| 887 | 887 | { |
| 888 | - $this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start); |
|
| 888 | + $this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start); |
|
| 889 | 889 | } |
| 890 | 890 | // check if the caller gave us enough information and if not read it from the DB |
| 891 | 891 | if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end'])) |
@@ -906,29 +906,29 @@ discard block |
||
| 906 | 906 | $read_start = new Api\DateTime($event_read['start']); |
| 907 | 907 | |
| 908 | 908 | $events = array(); |
| 909 | - $this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events); |
|
| 909 | + $this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events); |
|
| 910 | 910 | |
| 911 | 911 | $exceptions = array(); |
| 912 | - foreach((array)$event['recur_exception'] as $exception) |
|
| 912 | + foreach ((array)$event['recur_exception'] as $exception) |
|
| 913 | 913 | { |
| 914 | - $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
| 914 | + $exceptions[] = Api\DateTime::to($exception, true); // true = date |
|
| 915 | 915 | } |
| 916 | - foreach($events as $event) |
|
| 916 | + foreach ($events as $event) |
|
| 917 | 917 | { |
| 918 | 918 | $is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions); |
| 919 | - $start = $this->date2ts($event['start'],true); |
|
| 919 | + $start = $this->date2ts($event['start'], true); |
|
| 920 | 920 | if ($event['whole_day']) |
| 921 | 921 | { |
| 922 | 922 | $start = new Api\DateTime($event['start'], Api\DateTime::$server_timezone); |
| 923 | - $start->setTime(0,0,0); |
|
| 923 | + $start->setTime(0, 0, 0); |
|
| 924 | 924 | $start = $start->format('ts'); |
| 925 | 925 | $time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone)); |
| 926 | 926 | $time->setTime(23, 59, 59); |
| 927 | - $end = $this->date2ts($time,true); |
|
| 927 | + $end = $this->date2ts($time, true); |
|
| 928 | 928 | } |
| 929 | 929 | else |
| 930 | 930 | { |
| 931 | - $end = $this->date2ts($event['end'],true); |
|
| 931 | + $end = $this->date2ts($event['end'], true); |
|
| 932 | 932 | } |
| 933 | 933 | //error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception)); |
| 934 | 934 | $this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception); |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | * @param array &$events array of event-arrays (reference) |
| 945 | 945 | * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
| 946 | 946 | */ |
| 947 | - function db2data(&$events,$date_format='ts') |
|
| 947 | + function db2data(&$events, $date_format = 'ts') |
|
| 948 | 948 | { |
| 949 | 949 | if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
| 950 | 950 | foreach ($events as &$event) |
@@ -957,65 +957,65 @@ discard block |
||
| 957 | 957 | // database returns timestamps as string, convert them to integer |
| 958 | 958 | // to avoid misinterpretation by Api\DateTime as Ymd string |
| 959 | 959 | // (this will fail on 32bit systems for times > 2038!) |
| 960 | - $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
| 960 | + $event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime |
|
| 961 | 961 | $event['end'] = (int)$event['end']; |
| 962 | 962 | $event['whole_day'] = self::isWholeDay($event); |
| 963 | 963 | if ($event['whole_day'] && $date_format != 'server') |
| 964 | 964 | { |
| 965 | 965 | // Adjust dates to user TZ |
| 966 | - $stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 966 | + $stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 967 | 967 | $event['start'] = Api\DateTime::to($stime, $date_format); |
| 968 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 968 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 969 | 969 | $time->setTime(23, 59, 59); |
| 970 | 970 | $event['end'] = Api\DateTime::to($time, $date_format); |
| 971 | 971 | if (!empty($event['recurrence'])) |
| 972 | 972 | { |
| 973 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 973 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 974 | 974 | $event['recurrence'] = Api\DateTime::to($time, $date_format); |
| 975 | 975 | } |
| 976 | 976 | if (!empty($event['recur_enddate'])) |
| 977 | 977 | { |
| 978 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 978 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']); |
|
| 979 | 979 | $time->setTime(23, 59, 59); |
| 980 | 980 | $event['recur_enddate'] = Api\DateTime::to($time, $date_format); |
| 981 | 981 | } |
| 982 | - $timestamps = array('modified','created','deleted'); |
|
| 982 | + $timestamps = array('modified', 'created', 'deleted'); |
|
| 983 | 983 | } |
| 984 | 984 | else |
| 985 | 985 | { |
| 986 | - $timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date','deleted'); |
|
| 986 | + $timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date', 'deleted'); |
|
| 987 | 987 | } |
| 988 | 988 | // we convert here from the server-time timestamps to user-time and (optional) to a different date-format! |
| 989 | 989 | foreach ($timestamps as $ts) |
| 990 | 990 | { |
| 991 | 991 | if (!empty($event[$ts])) |
| 992 | 992 | { |
| 993 | - $event[$ts] = $this->date2usertime((int)$event[$ts],$date_format); |
|
| 993 | + $event[$ts] = $this->date2usertime((int)$event[$ts], $date_format); |
|
| 994 | 994 | } |
| 995 | 995 | } |
| 996 | 996 | // same with the recur exceptions |
| 997 | 997 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
| 998 | 998 | { |
| 999 | - foreach($event['recur_exception'] as &$date) |
|
| 999 | + foreach ($event['recur_exception'] as &$date) |
|
| 1000 | 1000 | { |
| 1001 | 1001 | if ($event['whole_day'] && $date_format != 'server') |
| 1002 | 1002 | { |
| 1003 | 1003 | // Adjust dates to user TZ |
| 1004 | - $time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
| 1004 | + $time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']); |
|
| 1005 | 1005 | $date = Api\DateTime::to($time, $date_format); |
| 1006 | 1006 | } |
| 1007 | 1007 | else |
| 1008 | 1008 | { |
| 1009 | - $date = $this->date2usertime((int)$date,$date_format); |
|
| 1009 | + $date = $this->date2usertime((int)$date, $date_format); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | // same with the alarms |
| 1014 | 1014 | if (isset($event['alarm']) && is_array($event['alarm'])) |
| 1015 | 1015 | { |
| 1016 | - foreach($event['alarm'] as &$alarm) |
|
| 1016 | + foreach ($event['alarm'] as &$alarm) |
|
| 1017 | 1017 | { |
| 1018 | - $alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format); |
|
| 1018 | + $alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format); |
|
| 1019 | 1019 | } |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format |
| 1029 | 1029 | * @return mixed depending of $date_format |
| 1030 | 1030 | */ |
| 1031 | - function date2usertime($ts,$date_format='ts') |
|
| 1031 | + function date2usertime($ts, $date_format = 'ts') |
|
| 1032 | 1032 | { |
| 1033 | 1033 | if (empty($ts) || $date_format == 'server') return $ts; |
| 1034 | 1034 | |
| 1035 | - return Api\DateTime::server2user($ts,$date_format); |
|
| 1035 | + return Api\DateTime::server2user($ts, $date_format); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | /** |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * but call clear_private_infos() with the given users |
| 1047 | 1047 | * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found |
| 1048 | 1048 | */ |
| 1049 | - function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
|
| 1049 | + function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null) |
|
| 1050 | 1050 | { |
| 1051 | 1051 | if (!$ids) return false; |
| 1052 | 1052 | |
@@ -1055,21 +1055,21 @@ discard block |
||
| 1055 | 1055 | $return = null; |
| 1056 | 1056 | |
| 1057 | 1057 | $check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ; |
| 1058 | - if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date))) |
|
| 1058 | + if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date))) |
|
| 1059 | 1059 | { |
| 1060 | 1060 | if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids || |
| 1061 | 1061 | self::$cached_event_date_format != $date_format || |
| 1062 | 1062 | self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date) |
| 1063 | 1063 | { |
| 1064 | - $events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0); |
|
| 1064 | + $events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0); |
|
| 1065 | 1065 | |
| 1066 | 1066 | if ($events) |
| 1067 | 1067 | { |
| 1068 | - $this->db2data($events,$date_format); |
|
| 1068 | + $this->db2data($events, $date_format); |
|
| 1069 | 1069 | |
| 1070 | 1070 | if (is_array($ids)) |
| 1071 | 1071 | { |
| 1072 | - $return =& $events; |
|
| 1072 | + $return = & $events; |
|
| 1073 | 1073 | } |
| 1074 | 1074 | else |
| 1075 | 1075 | { |
@@ -1085,13 +1085,13 @@ discard block |
||
| 1085 | 1085 | $return = self::$cached_event; |
| 1086 | 1086 | } |
| 1087 | 1087 | } |
| 1088 | - if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return)) |
|
| 1088 | + if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return)) |
|
| 1089 | 1089 | { |
| 1090 | 1090 | $this->clear_private_infos($return, (array)$clear_private_infos_users); |
| 1091 | 1091 | } |
| 1092 | 1092 | if ($this->debug && ($this->debug > 1 || $this->debug == 'read')) |
| 1093 | 1093 | { |
| 1094 | - $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return); |
|
| 1094 | + $this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return); |
|
| 1095 | 1095 | } |
| 1096 | 1096 | return $return; |
| 1097 | 1097 | } |
@@ -1109,17 +1109,17 @@ discard block |
||
| 1109 | 1109 | * @param array $events where the repetions get inserted |
| 1110 | 1110 | * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore |
| 1111 | 1111 | */ |
| 1112 | - function insert_all_recurrences($event,$_start,$end,&$events) |
|
| 1112 | + function insert_all_recurrences($event, $_start, $end, &$events) |
|
| 1113 | 1113 | { |
| 1114 | - if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
| 1114 | + if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences') |
|
| 1115 | 1115 | { |
| 1116 | - $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end); |
|
| 1116 | + $this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | $end_in = $end; |
| 1119 | 1119 | |
| 1120 | 1120 | $start = $this->date2ts($_start); |
| 1121 | 1121 | $event_start_ts = $this->date2ts($event['start']); |
| 1122 | - $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
| 1122 | + $event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time! |
|
| 1123 | 1123 | |
| 1124 | 1124 | // if $end is before recur_enddate, use it instead |
| 1125 | 1125 | if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end)) |
@@ -1128,39 +1128,38 @@ discard block |
||
| 1128 | 1128 | // insert at least the event itself, if it's behind the horizont |
| 1129 | 1129 | $event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end; |
| 1130 | 1130 | } |
| 1131 | - $event['recur_enddate'] = is_a($event['recur_enddate'],'DateTime') ? |
|
| 1132 | - $event['recur_enddate'] : |
|
| 1133 | - new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
| 1131 | + $event['recur_enddate'] = is_a($event['recur_enddate'], 'DateTime') ? |
|
| 1132 | + $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid'])); |
|
| 1134 | 1133 | // unset exceptions, as we need to add them as recurrence too, but marked as exception |
| 1135 | 1134 | unset($event['recur_exception']); |
| 1136 | 1135 | // loop over all recurrences and insert them, if they are after $start |
| 1137 | - $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
| 1138 | - foreach($rrule as $time) |
|
| 1136 | + $rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo |
|
| 1137 | + foreach ($rrule as $time) |
|
| 1139 | 1138 | { |
| 1140 | - $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
| 1141 | - if($event['whole_day']) |
|
| 1139 | + $time->setUser(); // $time is in timezone of event, convert it to usertime used here |
|
| 1140 | + if ($event['whole_day']) |
|
| 1142 | 1141 | { |
| 1143 | 1142 | // All day events are processed in server timezone |
| 1144 | 1143 | $time->setServer(); |
| 1145 | - $time->setTime(0,0,0); |
|
| 1144 | + $time->setTime(0, 0, 0); |
|
| 1146 | 1145 | } |
| 1147 | - if (($ts = $this->date2ts($time)) < $start-$event_length) |
|
| 1146 | + if (($ts = $this->date2ts($time)) < $start - $event_length) |
|
| 1148 | 1147 | { |
| 1149 | 1148 | //echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n"; |
| 1150 | - continue; // to early or original event (returned by interator too) |
|
| 1149 | + continue; // to early or original event (returned by interator too) |
|
| 1151 | 1150 | } |
| 1152 | 1151 | |
| 1153 | 1152 | $ts_end = $ts + $event_length; |
| 1154 | 1153 | // adjust ts_end for whole day events in case it does not fit due to |
| 1155 | 1154 | // spans over summer/wintertime adjusted days |
| 1156 | - if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
| 1155 | + if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) && |
|
| 1157 | 1156 | !($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59)) |
| 1158 | 1157 | { |
| 1159 | 1158 | $arr_end['hour'] = 23; |
| 1160 | 1159 | $arr_end['minute'] = 59; |
| 1161 | 1160 | $arr_end['second'] = 59; |
| 1162 | 1161 | $ts_end_guess = $this->date2ts($arr_end); |
| 1163 | - if($ts_end_guess - $ts_end > DAY_s/2) |
|
| 1162 | + if ($ts_end_guess - $ts_end > DAY_s / 2) |
|
| 1164 | 1163 | { |
| 1165 | 1164 | $ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future |
| 1166 | 1165 | } |
@@ -1174,11 +1173,11 @@ discard block |
||
| 1174 | 1173 | $event['end'] = $ts_end; |
| 1175 | 1174 | $events[] = $event; |
| 1176 | 1175 | } |
| 1177 | - if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
| 1176 | + if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')) |
|
| 1178 | 1177 | { |
| 1179 | 1178 | $event['start'] = $event_start_ts; |
| 1180 | 1179 | $event['end'] = $event_start_ts + $event_length; |
| 1181 | - $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events); |
|
| 1180 | + $this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events); |
|
| 1182 | 1181 | } |
| 1183 | 1182 | } |
| 1184 | 1183 | |
@@ -1189,18 +1188,18 @@ discard block |
||
| 1189 | 1188 | * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd |
| 1190 | 1189 | * @param int|string $date_ymd of the date of the event |
| 1191 | 1190 | */ |
| 1192 | - function add_adjusted_event(&$events,$event,$date_ymd) |
|
| 1191 | + function add_adjusted_event(&$events, $event, $date_ymd) |
|
| 1193 | 1192 | { |
| 1194 | 1193 | $event_in = $event; |
| 1195 | 1194 | // calculate the new start- and end-time |
| 1196 | 1195 | $length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']); |
| 1197 | 1196 | $event_start_arr = $this->date2array($event['start']); |
| 1198 | 1197 | |
| 1199 | - $date_arr = $this->date2array((string) $date_ymd); |
|
| 1198 | + $date_arr = $this->date2array((string)$date_ymd); |
|
| 1200 | 1199 | $date_arr['hour'] = $event_start_arr['hour']; |
| 1201 | 1200 | $date_arr['minute'] = $event_start_arr['minute']; |
| 1202 | 1201 | $date_arr['second'] = $event_start_arr['second']; |
| 1203 | - unset($date_arr['raw']); // else date2ts would use it |
|
| 1202 | + unset($date_arr['raw']); // else date2ts would use it |
|
| 1204 | 1203 | $event['start'] = $this->date2ts($date_arr); |
| 1205 | 1204 | $event['end'] = $event['start'] + $length_s; |
| 1206 | 1205 | |
@@ -1208,7 +1207,7 @@ discard block |
||
| 1208 | 1207 | |
| 1209 | 1208 | if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event')) |
| 1210 | 1209 | { |
| 1211 | - $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event); |
|
| 1210 | + $this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event); |
|
| 1212 | 1211 | } |
| 1213 | 1212 | } |
| 1214 | 1213 | |
@@ -1232,22 +1231,22 @@ discard block |
||
| 1232 | 1231 | { |
| 1233 | 1232 | $info = array( |
| 1234 | 1233 | 'res_id' => $uid, |
| 1235 | - 'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'), |
|
| 1236 | - 'name' => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' . |
|
| 1237 | - $GLOBALS['egw']->accounts->id2name($uid,'account_lastname')), |
|
| 1234 | + 'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'), |
|
| 1235 | + 'name' => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
|
| 1236 | + $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')), |
|
| 1238 | 1237 | 'type' => $GLOBALS['egw']->accounts->get_type($uid), |
| 1239 | 1238 | 'app' => 'accounts', |
| 1240 | 1239 | ); |
| 1241 | 1240 | } |
| 1242 | 1241 | else |
| 1243 | 1242 | { |
| 1244 | - list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false; |
|
| 1243 | + list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false; |
|
| 1245 | 1244 | if ($info) |
| 1246 | 1245 | { |
| 1247 | 1246 | $info['type'] = $uid[0]; |
| 1248 | 1247 | if (!$info['email'] && $info['responsible']) |
| 1249 | 1248 | { |
| 1250 | - $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email'); |
|
| 1249 | + $info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email'); |
|
| 1251 | 1250 | } |
| 1252 | 1251 | $info['app'] = $this->resources[$uid[0]]['app']; |
| 1253 | 1252 | } |
@@ -1256,7 +1255,7 @@ discard block |
||
| 1256 | 1255 | } |
| 1257 | 1256 | if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info')) |
| 1258 | 1257 | { |
| 1259 | - $this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]); |
|
| 1258 | + $this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]); |
|
| 1260 | 1259 | } |
| 1261 | 1260 | return $res_info_cache[$uid]; |
| 1262 | 1261 | } |
@@ -1277,7 +1276,7 @@ discard block |
||
| 1277 | 1276 | * @param int $user =null for which user to check, default current user |
| 1278 | 1277 | * @return boolean true permission granted, false for permission denied or null if event not found |
| 1279 | 1278 | */ |
| 1280 | - function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
|
| 1279 | + function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null) |
|
| 1281 | 1280 | { |
| 1282 | 1281 | if (!$user) $user = $this->user; |
| 1283 | 1282 | if ($user == $this->user) |
@@ -1286,13 +1285,13 @@ discard block |
||
| 1286 | 1285 | } |
| 1287 | 1286 | else |
| 1288 | 1287 | { |
| 1289 | - $grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user); |
|
| 1288 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1290 | 1289 | } |
| 1291 | 1290 | |
| 1292 | 1291 | if ($other && !is_numeric($other)) |
| 1293 | 1292 | { |
| 1294 | 1293 | $resource = $this->resource_info($other); |
| 1295 | - return $needed & $resource['rights']; |
|
| 1294 | + return $needed&$resource['rights']; |
|
| 1296 | 1295 | } |
| 1297 | 1296 | if (is_int($event) && $event == 0) |
| 1298 | 1297 | { |
@@ -1302,15 +1301,15 @@ discard block |
||
| 1302 | 1301 | { |
| 1303 | 1302 | if (!is_array($event)) |
| 1304 | 1303 | { |
| 1305 | - $event = $this->read($event,$date_to_read,true,$date_format); // = no ACL check !!! |
|
| 1304 | + $event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!! |
|
| 1306 | 1305 | } |
| 1307 | 1306 | if (!is_array($event)) |
| 1308 | 1307 | { |
| 1309 | 1308 | if ($this->xmlrpc) |
| 1310 | 1309 | { |
| 1311 | - $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']); |
|
| 1310 | + $GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']); |
|
| 1312 | 1311 | } |
| 1313 | - return null; // event not found |
|
| 1312 | + return null; // event not found |
|
| 1314 | 1313 | } |
| 1315 | 1314 | $owner = $event['owner']; |
| 1316 | 1315 | $private = !$event['public']; |
@@ -1318,7 +1317,7 @@ discard block |
||
| 1318 | 1317 | $grant = $grants[$owner]; |
| 1319 | 1318 | |
| 1320 | 1319 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1321 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1320 | + if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1322 | 1321 | |
| 1323 | 1322 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1324 | 1323 | { |
@@ -1327,15 +1326,15 @@ discard block |
||
| 1327 | 1326 | // |
| 1328 | 1327 | if ($event['participants'] && is_array($event['participants'])) |
| 1329 | 1328 | { |
| 1330 | - foreach(array_keys($event['participants']) as $uid) |
|
| 1329 | + foreach (array_keys($event['participants']) as $uid) |
|
| 1331 | 1330 | { |
| 1332 | - if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true))) |
|
| 1331 | + if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true))) |
|
| 1333 | 1332 | { |
| 1334 | 1333 | // if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant |
| 1335 | - $grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT; |
|
| 1334 | + $grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT; |
|
| 1336 | 1335 | break; |
| 1337 | 1336 | } |
| 1338 | - elseif ($grants[$uid] & Acl::READ) |
|
| 1337 | + elseif ($grants[$uid]&Acl::READ) |
|
| 1339 | 1338 | { |
| 1340 | 1339 | // if we have a READ grant from a participant, we dont give an implicit privat grant too |
| 1341 | 1340 | $grant |= Acl::READ; |
@@ -1354,12 +1353,12 @@ discard block |
||
| 1354 | 1353 | } |
| 1355 | 1354 | if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD) |
| 1356 | 1355 | { |
| 1357 | - $access = False; // a group can't be the owner of an event |
|
| 1356 | + $access = False; // a group can't be the owner of an event |
|
| 1358 | 1357 | } |
| 1359 | 1358 | else |
| 1360 | 1359 | { |
| 1361 | - $access = $user == $owner || $grant & $needed |
|
| 1362 | - && ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT); |
|
| 1360 | + $access = $user == $owner || $grant&$needed |
|
| 1361 | + && ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT); |
|
| 1363 | 1362 | } |
| 1364 | 1363 | // do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled |
| 1365 | 1364 | if ($access && $needed == Acl::DELETE && $event['deleted'] && |
@@ -1370,7 +1369,7 @@ discard block |
||
| 1370 | 1369 | } |
| 1371 | 1370 | if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms')) |
| 1372 | 1371 | { |
| 1373 | - $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 | + $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); |
|
| 1374 | 1373 | } |
| 1375 | 1374 | //error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access)); |
| 1376 | 1375 | return $access; |
@@ -1385,9 +1384,9 @@ discard block |
||
| 1385 | 1384 | * array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year' |
| 1386 | 1385 | * @param boolean $user2server =False conversion between user- and server-time; default False == Off |
| 1387 | 1386 | */ |
| 1388 | - static function date2ts($date,$user2server=False) |
|
| 1387 | + static function date2ts($date, $user2server = False) |
|
| 1389 | 1388 | { |
| 1390 | - return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts'); |
|
| 1389 | + return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts'); |
|
| 1391 | 1390 | } |
| 1392 | 1391 | |
| 1393 | 1392 | /** |
@@ -1397,9 +1396,9 @@ discard block |
||
| 1397 | 1396 | * @param boolean $server2user conversation between user- and server-time default False == Off |
| 1398 | 1397 | * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string) |
| 1399 | 1398 | */ |
| 1400 | - static function date2array($date,$server2user=False) |
|
| 1399 | + static function date2array($date, $server2user = False) |
|
| 1401 | 1400 | { |
| 1402 | - return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array'); |
|
| 1401 | + return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array'); |
|
| 1403 | 1402 | } |
| 1404 | 1403 | |
| 1405 | 1404 | /** |
@@ -1410,9 +1409,9 @@ discard block |
||
| 1410 | 1409 | * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100) |
| 1411 | 1410 | * @return string date formatted according to $format |
| 1412 | 1411 | */ |
| 1413 | - static function date2string($date,$server2user=False,$format='Ymd') |
|
| 1412 | + static function date2string($date, $server2user = False, $format = 'Ymd') |
|
| 1414 | 1413 | { |
| 1415 | - return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format); |
|
| 1414 | + return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format); |
|
| 1416 | 1415 | } |
| 1417 | 1416 | |
| 1418 | 1417 | /** |
@@ -1422,9 +1421,9 @@ discard block |
||
| 1422 | 1421 | * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only |
| 1423 | 1422 | * @return string the formated date (incl. time) |
| 1424 | 1423 | */ |
| 1425 | - static function format_date($date,$format='') |
|
| 1424 | + static function format_date($date, $format = '') |
|
| 1426 | 1425 | { |
| 1427 | - return Api\DateTime::to($date,$format); |
|
| 1426 | + return Api\DateTime::to($date, $format); |
|
| 1428 | 1427 | } |
| 1429 | 1428 | |
| 1430 | 1429 | /** |
@@ -1446,7 +1445,7 @@ discard block |
||
| 1446 | 1445 | * @param mixed $param a variable number of parameters, to be inserted in $msg |
| 1447 | 1446 | * arrays get serialized with print_r() ! |
| 1448 | 1447 | */ |
| 1449 | - static function debug_message($msg,$backtrace=True) |
|
| 1448 | + static function debug_message($msg, $backtrace = True) |
|
| 1450 | 1449 | { |
| 1451 | 1450 | static $acl2string = array( |
| 1452 | 1451 | 0 => 'ACL-UNKNOWN', |
@@ -1457,22 +1456,22 @@ discard block |
||
| 1457 | 1456 | Acl::PRIVAT => 'ACL_PRIVATE', |
| 1458 | 1457 | self::ACL_FREEBUSY => 'ACL_FREEBUSY', |
| 1459 | 1458 | ); |
| 1460 | - for($i = 2; $i < func_num_args(); ++$i) |
|
| 1459 | + for ($i = 2; $i < func_num_args(); ++$i) |
|
| 1461 | 1460 | { |
| 1462 | 1461 | $param = func_get_arg($i); |
| 1463 | 1462 | |
| 1464 | 1463 | if (is_null($param)) |
| 1465 | 1464 | { |
| 1466 | - $param='NULL'; |
|
| 1465 | + $param = 'NULL'; |
|
| 1467 | 1466 | } |
| 1468 | 1467 | else |
| 1469 | 1468 | { |
| 1470 | - switch(gettype($param)) |
|
| 1469 | + switch (gettype($param)) |
|
| 1471 | 1470 | { |
| 1472 | 1471 | case 'string': |
| 1473 | - if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER) |
|
| 1472 | + if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER) |
|
| 1474 | 1473 | { |
| 1475 | - $param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER)); |
|
| 1474 | + $param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER)); |
|
| 1476 | 1475 | $param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)"; |
| 1477 | 1476 | } |
| 1478 | 1477 | else |
@@ -1495,11 +1494,11 @@ discard block |
||
| 1495 | 1494 | $param = $param ? 'True' : 'False'; |
| 1496 | 1495 | break; |
| 1497 | 1496 | case 'integer': |
| 1498 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1497 | + if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)"; |
|
| 1499 | 1498 | break; |
| 1500 | 1499 | } |
| 1501 | 1500 | } |
| 1502 | - $msg = str_replace('%'.($i-1),$param,$msg); |
|
| 1501 | + $msg = str_replace('%'.($i - 1), $param, $msg); |
|
| 1503 | 1502 | } |
| 1504 | 1503 | error_log($msg); |
| 1505 | 1504 | if ($backtrace) error_log(function_backtrace(1)); |
@@ -1514,7 +1513,7 @@ discard block |
||
| 1514 | 1513 | * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006 |
| 1515 | 1514 | * @return string with formated date |
| 1516 | 1515 | */ |
| 1517 | - function long_date($_first,$last=0,$display_time=false,$display_day=false) |
|
| 1516 | + function long_date($_first, $last = 0, $display_time = false, $display_day = false) |
|
| 1518 | 1517 | { |
| 1519 | 1518 | $first = $this->date2array($_first); |
| 1520 | 1519 | if ($last) |
@@ -1529,27 +1528,27 @@ discard block |
||
| 1529 | 1528 | |
| 1530 | 1529 | if ($display_day) |
| 1531 | 1530 | { |
| 1532 | - $range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
| 1531 | + $range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', '); |
|
| 1533 | 1532 | } |
| 1534 | 1533 | for ($i = 0; $i < 5; $i += 2) |
| 1535 | 1534 | { |
| 1536 | - switch($datefmt[$i]) |
|
| 1535 | + switch ($datefmt[$i]) |
|
| 1537 | 1536 | { |
| 1538 | 1537 | case 'd': |
| 1539 | - $range .= $first['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
| 1538 | + $range .= $first['day'].($datefmt[1] == '.' ? '.' : ''); |
|
| 1540 | 1539 | if ($first['month'] != $last['month'] || $first['year'] != $last['year']) |
| 1541 | 1540 | { |
| 1542 | 1541 | if (!$month_before_day) |
| 1543 | 1542 | { |
| 1544 | - $range .= ' '.lang(strftime('%B',$first['raw'])); |
|
| 1543 | + $range .= ' '.lang(strftime('%B', $first['raw'])); |
|
| 1545 | 1544 | } |
| 1546 | 1545 | if ($first['year'] != $last['year'] && $datefmt[0] != 'Y') |
| 1547 | 1546 | { |
| 1548 | - $range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year']; |
|
| 1547 | + $range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year']; |
|
| 1549 | 1548 | } |
| 1550 | 1549 | if ($display_time) |
| 1551 | 1550 | { |
| 1552 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
| 1551 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
| 1553 | 1552 | } |
| 1554 | 1553 | if (!$last) |
| 1555 | 1554 | { |
@@ -1559,43 +1558,43 @@ discard block |
||
| 1559 | 1558 | |
| 1560 | 1559 | if ($first['year'] != $last['year'] && $datefmt[0] == 'Y') |
| 1561 | 1560 | { |
| 1562 | - $range .= $last['year'] . ', '; |
|
| 1561 | + $range .= $last['year'].', '; |
|
| 1563 | 1562 | } |
| 1564 | 1563 | |
| 1565 | 1564 | if ($month_before_day) |
| 1566 | 1565 | { |
| 1567 | - $range .= lang(strftime('%B',$last['raw'])); |
|
| 1566 | + $range .= lang(strftime('%B', $last['raw'])); |
|
| 1568 | 1567 | } |
| 1569 | 1568 | } |
| 1570 | 1569 | else |
| 1571 | 1570 | { |
| 1572 | 1571 | if ($display_time) |
| 1573 | 1572 | { |
| 1574 | - $range .= ' '.adodb_date($timefmt,$first['raw']); |
|
| 1573 | + $range .= ' '.adodb_date($timefmt, $first['raw']); |
|
| 1575 | 1574 | } |
| 1576 | 1575 | $range .= ' - '; |
| 1577 | 1576 | } |
| 1578 | - $range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : ''); |
|
| 1577 | + $range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : ''); |
|
| 1579 | 1578 | break; |
| 1580 | 1579 | case 'm': |
| 1581 | 1580 | case 'M': |
| 1582 | - $range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' '; |
|
| 1581 | + $range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' '; |
|
| 1583 | 1582 | break; |
| 1584 | 1583 | case 'Y': |
| 1585 | 1584 | if ($datefmt[0] != 'm') |
| 1586 | 1585 | { |
| 1587 | - $range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
| 1586 | + $range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' '); |
|
| 1588 | 1587 | } |
| 1589 | 1588 | break; |
| 1590 | 1589 | } |
| 1591 | 1590 | } |
| 1592 | 1591 | if ($display_time && $last) |
| 1593 | 1592 | { |
| 1594 | - $range .= ' '.adodb_date($timefmt,$last['raw']); |
|
| 1593 | + $range .= ' '.adodb_date($timefmt, $last['raw']); |
|
| 1595 | 1594 | } |
| 1596 | 1595 | if ($datefmt[4] == 'Y' && $datefmt[0] == 'm') |
| 1597 | 1596 | { |
| 1598 | - $range .= ', ' . $last['year']; |
|
| 1597 | + $range .= ', '.$last['year']; |
|
| 1599 | 1598 | } |
| 1600 | 1599 | return $range; |
| 1601 | 1600 | } |
@@ -1607,25 +1606,25 @@ discard block |
||
| 1607 | 1606 | * @param int $end_m end time in minutes since 0h |
| 1608 | 1607 | * @param boolean $both =false display the end-time too, duration is always displayed |
| 1609 | 1608 | */ |
| 1610 | - function timespan($start_m,$end_m,$both=false) |
|
| 1609 | + function timespan($start_m, $end_m, $both = false) |
|
| 1611 | 1610 | { |
| 1612 | 1611 | $duration = $end_m - $start_m; |
| 1613 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1614 | - $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
|
| 1612 | + if ($end_m == 24 * 60 - 1) ++$duration; |
|
| 1613 | + $duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : ''); |
|
| 1615 | 1614 | |
| 1616 | - $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
|
| 1615 | + $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false); |
|
| 1617 | 1616 | |
| 1618 | 1617 | if ($both) // end-time too |
| 1619 | 1618 | { |
| 1620 | - $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
|
| 1619 | + $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false); |
|
| 1621 | 1620 | // dont double am/pm if they are the same in both times |
| 1622 | - if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
|
| 1621 | + if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2)) |
|
| 1623 | 1622 | { |
| 1624 | - $timespan = str_replace($t,substr($t,0,-3),$timespan); |
|
| 1623 | + $timespan = str_replace($t, substr($t, 0, -3), $timespan); |
|
| 1625 | 1624 | } |
| 1626 | 1625 | $timespan .= ':'; |
| 1627 | 1626 | } |
| 1628 | - return $timespan . ' ' . $duration; |
|
| 1627 | + return $timespan.' '.$duration; |
|
| 1629 | 1628 | } |
| 1630 | 1629 | |
| 1631 | 1630 | /** |
@@ -1636,7 +1635,7 @@ discard block |
||
| 1636 | 1635 | * @param boolean $append_email =false append email (Name <email>) |
| 1637 | 1636 | * @return string with name |
| 1638 | 1637 | */ |
| 1639 | - function participant_name($id,$use_type=false, $append_email=false) |
|
| 1638 | + function participant_name($id, $use_type = false, $append_email = false) |
|
| 1640 | 1639 | { |
| 1641 | 1640 | static $id2lid = array(); |
| 1642 | 1641 | static $id2email = array(); |
@@ -1657,7 +1656,7 @@ discard block |
||
| 1657 | 1656 | else |
| 1658 | 1657 | { |
| 1659 | 1658 | $id2lid[$id] = Api\Accounts::username($id); |
| 1660 | - $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email'); |
|
| 1659 | + $id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email'); |
|
| 1661 | 1660 | } |
| 1662 | 1661 | } |
| 1663 | 1662 | return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : ''); |
@@ -1671,37 +1670,37 @@ discard block |
||
| 1671 | 1670 | * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default) |
| 1672 | 1671 | * @return array with id / names with status pairs |
| 1673 | 1672 | */ |
| 1674 | - function participants($event,$long_status=false,$show_group_invitation=false) |
|
| 1673 | + function participants($event, $long_status = false, $show_group_invitation = false) |
|
| 1675 | 1674 | { |
| 1676 | 1675 | //error_log(__METHOD__.__LINE__.array2string($event['participants'])); |
| 1677 | 1676 | $names = array(); |
| 1678 | - foreach((array)$event['participants'] as $id => $status) |
|
| 1677 | + foreach ((array)$event['participants'] as $id => $status) |
|
| 1679 | 1678 | { |
| 1680 | 1679 | if (!is_string($status)) continue; |
| 1681 | 1680 | $quantity = $role = null; |
| 1682 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1681 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1683 | 1682 | |
| 1684 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1683 | + if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1685 | 1684 | |
| 1686 | 1685 | $lang_status = lang($this->verbose_status[$status]); |
| 1687 | 1686 | if (!$long_status) |
| 1688 | 1687 | { |
| 1689 | - switch($status[0]) |
|
| 1688 | + switch ($status[0]) |
|
| 1690 | 1689 | { |
| 1691 | 1690 | case 'A': // accepted |
| 1692 | - $status = Api\Html::image('calendar','accepted',$lang_status); |
|
| 1691 | + $status = Api\Html::image('calendar', 'accepted', $lang_status); |
|
| 1693 | 1692 | break; |
| 1694 | 1693 | case 'R': // rejected |
| 1695 | - $status = Api\Html::image('calendar','rejected',$lang_status); |
|
| 1694 | + $status = Api\Html::image('calendar', 'rejected', $lang_status); |
|
| 1696 | 1695 | break; |
| 1697 | 1696 | case 'T': // tentative |
| 1698 | - $status = Api\Html::image('calendar','tentative',$lang_status); |
|
| 1697 | + $status = Api\Html::image('calendar', 'tentative', $lang_status); |
|
| 1699 | 1698 | break; |
| 1700 | 1699 | case 'U': // no response = unknown |
| 1701 | - $status = Api\Html::image('calendar','needs-action',$lang_status); |
|
| 1700 | + $status = Api\Html::image('calendar', 'needs-action', $lang_status); |
|
| 1702 | 1701 | break; |
| 1703 | 1702 | case 'D': // delegated |
| 1704 | - $status = Api\Html::image('calendar','forward',$lang_status); |
|
| 1703 | + $status = Api\Html::image('calendar', 'forward', $lang_status); |
|
| 1705 | 1704 | break; |
| 1706 | 1705 | case 'G': // group invitation |
| 1707 | 1706 | // Todo: Image, seems not to be used |
@@ -1723,13 +1722,13 @@ discard block |
||
| 1723 | 1722 | $role = lang($this->roles[$role]); |
| 1724 | 1723 | } |
| 1725 | 1724 | // allow to use cats as roles (beside regular iCal ones) |
| 1726 | - elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0) |
|
| 1725 | + elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0) |
|
| 1727 | 1726 | { |
| 1728 | 1727 | $role = $GLOBALS['egw']->categories->id2name($cat_id); |
| 1729 | 1728 | } |
| 1730 | 1729 | else |
| 1731 | 1730 | { |
| 1732 | - $role = lang(str_replace('X-','',$role)); |
|
| 1731 | + $role = lang(str_replace('X-', '', $role)); |
|
| 1733 | 1732 | } |
| 1734 | 1733 | $names[$id] .= ' '.$role; |
| 1735 | 1734 | } |
@@ -1746,13 +1745,13 @@ discard block |
||
| 1746 | 1745 | * @param int $color color of the category, if multiple cats, the color of the last one with color is returned |
| 1747 | 1746 | * @return array with id / names |
| 1748 | 1747 | */ |
| 1749 | - function categories($category,&$color) |
|
| 1748 | + function categories($category, &$color) |
|
| 1750 | 1749 | { |
| 1751 | 1750 | static $id2cat = array(); |
| 1752 | 1751 | $cats = array(); |
| 1753 | 1752 | $color = 0; |
| 1754 | 1753 | |
| 1755 | - foreach(explode(',',$category) as $cat_id) |
|
| 1754 | + foreach (explode(',', $category) as $cat_id) |
|
| 1756 | 1755 | { |
| 1757 | 1756 | if (!$cat_id) continue; |
| 1758 | 1757 | |
@@ -1767,7 +1766,7 @@ discard block |
||
| 1767 | 1766 | { |
| 1768 | 1767 | $color = $cat['data']['color']; |
| 1769 | 1768 | } |
| 1770 | - elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
| 1769 | + elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts)) |
|
| 1771 | 1770 | { |
| 1772 | 1771 | $color = $parts[1]; |
| 1773 | 1772 | } |
@@ -1779,12 +1778,12 @@ discard block |
||
| 1779 | 1778 | /** |
| 1780 | 1779 | * This is called only by list_cals(). It was moved here to remove fatal error in php5 beta4 |
| 1781 | 1780 | */ |
| 1782 | - private static function _list_cals_add($id,&$users,&$groups) |
|
| 1781 | + private static function _list_cals_add($id, &$users, &$groups) |
|
| 1783 | 1782 | { |
| 1784 | 1783 | $name = Api\Accounts::username($id); |
| 1785 | 1784 | if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id))) |
| 1786 | 1785 | { |
| 1787 | - return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
| 1786 | + return; // do not return no longer existing accounts which eg. still mentioned in acl |
|
| 1788 | 1787 | } |
| 1789 | 1788 | if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g') |
| 1790 | 1789 | { |
@@ -1796,7 +1795,7 @@ discard block |
||
| 1796 | 1795 | } |
| 1797 | 1796 | $arr[$id] = array( |
| 1798 | 1797 | 'grantor' => $id, |
| 1799 | - 'value' => ($type == 'g' ? 'g_' : '') . $id, |
|
| 1798 | + 'value' => ($type == 'g' ? 'g_' : '').$id, |
|
| 1800 | 1799 | 'name' => $name, |
| 1801 | 1800 | 'sname' => $egw_name |
| 1802 | 1801 | ); |
@@ -1818,26 +1817,26 @@ discard block |
||
| 1818 | 1817 | * @param int $user account_id of user to generate list for |
| 1819 | 1818 | * @param array $grants =null calendar grants from user, or null to query them from acl class |
| 1820 | 1819 | */ |
| 1821 | - public static function list_calendars($user, array $grants=null) |
|
| 1820 | + public static function list_calendars($user, array $grants = null) |
|
| 1822 | 1821 | { |
| 1823 | 1822 | if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
| 1824 | 1823 | |
| 1825 | 1824 | $users = $groups = array(); |
| 1826 | - foreach(array_keys($grants) as $id) |
|
| 1825 | + foreach (array_keys($grants) as $id) |
|
| 1827 | 1826 | { |
| 1828 | - self::_list_cals_add($id,$users,$groups); |
|
| 1827 | + self::_list_cals_add($id, $users, $groups); |
|
| 1829 | 1828 | } |
| 1830 | 1829 | if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true))) |
| 1831 | 1830 | { |
| 1832 | - foreach($memberships as $group) |
|
| 1831 | + foreach ($memberships as $group) |
|
| 1833 | 1832 | { |
| 1834 | - self::_list_cals_add($group,$users,$groups); |
|
| 1833 | + self::_list_cals_add($group, $users, $groups); |
|
| 1835 | 1834 | |
| 1836 | - if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar'))) |
|
| 1835 | + if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar'))) |
|
| 1837 | 1836 | { |
| 1838 | - foreach($account_perms as $id) |
|
| 1837 | + foreach ($account_perms as $id) |
|
| 1839 | 1838 | { |
| 1840 | - self::_list_cals_add($id,$users,$groups); |
|
| 1839 | + self::_list_cals_add($id, $users, $groups); |
|
| 1841 | 1840 | } |
| 1842 | 1841 | } |
| 1843 | 1842 | } |
@@ -1845,7 +1844,7 @@ discard block |
||
| 1845 | 1844 | usort($users, array(__CLASS__, 'name_cmp')); |
| 1846 | 1845 | usort($groups, array(__CLASS__, 'name_cmp')); |
| 1847 | 1846 | |
| 1848 | - return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
| 1847 | + return array_merge($users, $groups); // users first and then groups, both alphabeticaly |
|
| 1849 | 1848 | } |
| 1850 | 1849 | |
| 1851 | 1850 | /** |
@@ -1885,28 +1884,27 @@ discard block |
||
| 1885 | 1884 | * month: numerical month |
| 1886 | 1885 | * occurence: numerical year or 0 for every year |
| 1887 | 1886 | */ |
| 1888 | - function read_holidays($year=0) |
|
| 1887 | + function read_holidays($year = 0) |
|
| 1889 | 1888 | { |
| 1890 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 1889 | + if (!$year) $year = (int)date('Y', $this->now_su); |
|
| 1891 | 1890 | |
| 1892 | 1891 | $holidays = calendar_holidays::read( |
| 1893 | 1892 | !empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ? |
| 1894 | - $GLOBALS['egw_info']['server']['ical_holiday_url'] : |
|
| 1895 | - $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
| 1893 | + $GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year); |
|
| 1896 | 1894 | |
| 1897 | 1895 | // search for birthdays |
| 1898 | 1896 | if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes') |
| 1899 | 1897 | { |
| 1900 | 1898 | $contacts = new Api\Contacts(); |
| 1901 | - foreach($contacts->get_addressbooks() as $owner => $name) |
|
| 1899 | + foreach ($contacts->get_addressbooks() as $owner => $name) |
|
| 1902 | 1900 | { |
| 1903 | 1901 | $holidays += $contacts->read_birthdays($owner, $year); |
| 1904 | 1902 | } |
| 1905 | 1903 | } |
| 1906 | 1904 | |
| 1907 | - if ((int) $this->debug >= 2 || $this->debug == 'read_holidays') |
|
| 1905 | + if ((int)$this->debug >= 2 || $this->debug == 'read_holidays') |
|
| 1908 | 1906 | { |
| 1909 | - $this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$holidays); |
|
| 1907 | + $this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $holidays); |
|
| 1910 | 1908 | } |
| 1911 | 1909 | return $holidays; |
| 1912 | 1910 | } |
@@ -1917,10 +1915,10 @@ discard block |
||
| 1917 | 1915 | * @param type $event |
| 1918 | 1916 | * @return array array of selected calendar fields |
| 1919 | 1917 | */ |
| 1920 | - public static function get_link_options ($event = array()) |
|
| 1918 | + public static function get_link_options($event = array()) |
|
| 1921 | 1919 | { |
| 1922 | - unset($event); // not used, but required by function signature |
|
| 1923 | - $options = array ( |
|
| 1920 | + unset($event); // not used, but required by function signature |
|
| 1921 | + $options = array( |
|
| 1924 | 1922 | 'end' => lang('End date'), |
| 1925 | 1923 | 'id' => lang('ID'), |
| 1926 | 1924 | 'owner' => lang('Event owner'), |
@@ -1947,7 +1945,7 @@ discard block |
||
| 1947 | 1945 | list($id, $recur) = explode('-', $event, 2); |
| 1948 | 1946 | $event = $this->read($id, $recur); |
| 1949 | 1947 | } |
| 1950 | - else if (!is_array($event) && (int) $event > 0) |
|
| 1948 | + else if (!is_array($event) && (int)$event > 0) |
|
| 1951 | 1949 | { |
| 1952 | 1950 | $event = $this->read($event); |
| 1953 | 1951 | } |
@@ -1955,7 +1953,7 @@ discard block |
||
| 1955 | 1953 | { |
| 1956 | 1954 | return $event; |
| 1957 | 1955 | } |
| 1958 | - $type = explode(',',$this->cal_prefs['link_title']); |
|
| 1956 | + $type = explode(',', $this->cal_prefs['link_title']); |
|
| 1959 | 1957 | if (is_array($type)) |
| 1960 | 1958 | { |
| 1961 | 1959 | foreach ($type as &$val) |
@@ -1981,10 +1979,10 @@ discard block |
||
| 1981 | 1979 | $extra_fields [] = $event[$val]; |
| 1982 | 1980 | } |
| 1983 | 1981 | } |
| 1984 | - $str_fields = implode(', ',$extra_fields); |
|
| 1985 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 1982 | + $str_fields = implode(', ', $extra_fields); |
|
| 1983 | + if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : ''); |
|
| 1986 | 1984 | } |
| 1987 | - return $this->format_date($event['start']) . ': ' . $event['title']; |
|
| 1985 | + return $this->format_date($event['start']).': '.$event['title']; |
|
| 1988 | 1986 | } |
| 1989 | 1987 | |
| 1990 | 1988 | /** |
@@ -2003,10 +2001,10 @@ discard block |
||
| 2003 | 2001 | 'offset' => $options['start'], |
| 2004 | 2002 | 'order' => 'cal_start DESC', |
| 2005 | 2003 | ); |
| 2006 | - if($options['num_rows']) { |
|
| 2004 | + if ($options['num_rows']) { |
|
| 2007 | 2005 | $query['num_rows'] = $options['num_rows']; |
| 2008 | 2006 | } |
| 2009 | - foreach((array) $this->search($query) as $event) |
|
| 2007 | + foreach ((array)$this->search($query) as $event) |
|
| 2010 | 2008 | { |
| 2011 | 2009 | $result[$event['id']] = $this->link_title($event); |
| 2012 | 2010 | } |
@@ -2023,11 +2021,11 @@ discard block |
||
| 2023 | 2021 | * @param int $user =null for which user to check, default current user |
| 2024 | 2022 | * @return boolean true if access is granted or false otherwise |
| 2025 | 2023 | */ |
| 2026 | - function file_access($id,$check,$rel_path,$user=null) |
|
| 2024 | + function file_access($id, $check, $rel_path, $user = null) |
|
| 2027 | 2025 | { |
| 2028 | - unset($rel_path); // not used, but required by function signature |
|
| 2026 | + unset($rel_path); // not used, but required by function signature |
|
| 2029 | 2027 | |
| 2030 | - return $this->check_perms($check,$id,0,'ts',null,$user); |
|
| 2028 | + return $this->check_perms($check, $id, 0, 'ts', null, $user); |
|
| 2031 | 2029 | } |
| 2032 | 2030 | |
| 2033 | 2031 | /** |
@@ -2043,36 +2041,36 @@ discard block |
||
| 2043 | 2041 | } |
| 2044 | 2042 | Api\Cache::setSession('calendar', 'default_prefs_set', 'set'); |
| 2045 | 2043 | |
| 2046 | - $default_prefs =& $GLOBALS['egw']->preferences->default['calendar']; |
|
| 2047 | - $forced_prefs =& $GLOBALS['egw']->preferences->forced['calendar']; |
|
| 2044 | + $default_prefs = & $GLOBALS['egw']->preferences->default['calendar']; |
|
| 2045 | + $forced_prefs = & $GLOBALS['egw']->preferences->forced['calendar']; |
|
| 2048 | 2046 | |
| 2049 | - $subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
| 2047 | + $subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n"; |
|
| 2050 | 2048 | $values = array( |
| 2051 | - 'notifyAdded' => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'), |
|
| 2052 | - 'notifyCanceled' => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'), |
|
| 2053 | - 'notifyModified' => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'), |
|
| 2054 | - 'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'), |
|
| 2055 | - 'notifyResponse' => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'), |
|
| 2056 | - 'notifyAlarm' => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'), |
|
| 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.'), |
|
| 2057 | 2055 | 'interval' => 30, |
| 2058 | 2056 | ); |
| 2059 | - foreach($values as $var => $default) |
|
| 2057 | + foreach ($values as $var => $default) |
|
| 2060 | 2058 | { |
| 2061 | - $type = substr($var,0,6) == 'notify' ? 'forced' : 'default'; |
|
| 2059 | + $type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default'; |
|
| 2062 | 2060 | |
| 2063 | 2061 | // only set, if neither default nor forced pref exists |
| 2064 | 2062 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 2065 | 2063 | { |
| 2066 | - $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
|
| 2067 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 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'); |
|
| 2068 | 2066 | $this->cal_prefs[$var] = $default; |
| 2069 | 2067 | $need_save = True; |
| 2070 | 2068 | } |
| 2071 | 2069 | } |
| 2072 | 2070 | if ($need_save) |
| 2073 | 2071 | { |
| 2074 | - $GLOBALS['egw']->preferences->save_repository(False,'default'); |
|
| 2075 | - $GLOBALS['egw']->preferences->save_repository(False,'forced'); |
|
| 2072 | + $GLOBALS['egw']->preferences->save_repository(False, 'default'); |
|
| 2073 | + $GLOBALS['egw']->preferences->save_repository(False, 'forced'); |
|
| 2076 | 2074 | } |
| 2077 | 2075 | } |
| 2078 | 2076 | |
@@ -2082,7 +2080,7 @@ discard block |
||
| 2082 | 2080 | * @param int|string $user account_id or account_lid |
| 2083 | 2081 | * @param string $pw =null password |
| 2084 | 2082 | */ |
| 2085 | - static function freebusy_url($user='',$pw=null) |
|
| 2083 | + static function freebusy_url($user = '', $pw = null) |
|
| 2086 | 2084 | { |
| 2087 | 2085 | if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
| 2088 | 2086 | |
@@ -2095,8 +2093,8 @@ discard block |
||
| 2095 | 2093 | elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2) |
| 2096 | 2094 | { |
| 2097 | 2095 | $credentials = $GLOBALS['egw_info']['user']['account_lid'] |
| 2098 | - . ':' . $GLOBALS['egw_info']['user']['passwd']; |
|
| 2099 | - $credentials = '&cred=' . base64_encode($credentials); |
|
| 2096 | + . ':'.$GLOBALS['egw_info']['user']['passwd']; |
|
| 2097 | + $credentials = '&cred='.base64_encode($credentials); |
|
| 2100 | 2098 | } |
| 2101 | 2099 | return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ? |
| 2102 | 2100 | ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : ''). |
@@ -2128,11 +2126,11 @@ discard block |
||
| 2128 | 2126 | * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!) |
| 2129 | 2127 | * @return string|boolean string with etag or false |
| 2130 | 2128 | */ |
| 2131 | - function get_etag($entry, &$schedule_tag=null) |
|
| 2129 | + function get_etag($entry, &$schedule_tag = null) |
|
| 2132 | 2130 | { |
| 2133 | 2131 | if (!is_array($entry)) |
| 2134 | 2132 | { |
| 2135 | - list($id,$recur_date) = explode(':',$entry); |
|
| 2133 | + list($id, $recur_date) = explode(':', $entry); |
|
| 2136 | 2134 | $entry = $this->read($id, $recur_date, true, 'server'); |
| 2137 | 2135 | } |
| 2138 | 2136 | $etag = $schedule_tag = $entry['id'].':'.$entry['etag']; |
@@ -2150,15 +2148,15 @@ discard block |
||
| 2150 | 2148 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
| 2151 | 2149 | * @return integer |
| 2152 | 2150 | */ |
| 2153 | - public function get_ctag($user, $filter='owner', $master_only=false) |
|
| 2151 | + public function get_ctag($user, $filter = 'owner', $master_only = false) |
|
| 2154 | 2152 | { |
| 2155 | 2153 | if ($this->debug > 1) $startime = microtime(true); |
| 2156 | 2154 | |
| 2157 | 2155 | // resolve users to add memberships for users and members for groups |
| 2158 | 2156 | $users = $this->resolve_users($user); |
| 2159 | - $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
| 2157 | + $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
|
| 2160 | 2158 | |
| 2161 | - 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"); |
|
| 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"); |
|
| 2162 | 2160 | return $ctag; |
| 2163 | 2161 | } |
| 2164 | 2162 | |
@@ -2178,7 +2176,7 @@ discard block |
||
| 2178 | 2176 | |
| 2179 | 2177 | $content = array( |
| 2180 | 2178 | 'info_cat' => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']), |
| 2181 | - 'info_priority' => $calendar['priority'] , |
|
| 2179 | + 'info_priority' => $calendar['priority'], |
|
| 2182 | 2180 | 'info_public' => $calendar['public'] != 'private', |
| 2183 | 2181 | 'info_subject' => $calendar['title'], |
| 2184 | 2182 | 'info_des' => $calendar['description'], |
@@ -2193,7 +2191,7 @@ discard block |
||
| 2193 | 2191 | $content['link_app'][] = $calendar['info_link']['app']; |
| 2194 | 2192 | $content['link_id'][] = $calendar['info_link']['id']; |
| 2195 | 2193 | // Copy claendar's links |
| 2196 | - foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link) |
|
| 2194 | + foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link) |
|
| 2197 | 2195 | { |
| 2198 | 2196 | if ($link['app'] != Link::VFS_APPNAME) |
| 2199 | 2197 | { |
@@ -2206,7 +2204,7 @@ discard block |
||
| 2206 | 2204 | } |
| 2207 | 2205 | } |
| 2208 | 2206 | // Copy same custom fields |
| 2209 | - foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
| 2207 | + foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
|
| 2210 | 2208 | { |
| 2211 | 2209 | if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
| 2212 | 2210 | } |
@@ -2224,20 +2222,20 @@ discard block |
||
| 2224 | 2222 | function timesheet_set($data) |
| 2225 | 2223 | { |
| 2226 | 2224 | $set = array(); |
| 2227 | - list($id,$recurrence) = explode(':',$data['id']); |
|
| 2228 | - if ((int)$id && ($event = $this->read($id,$recurrence))) |
|
| 2225 | + list($id, $recurrence) = explode(':', $data['id']); |
|
| 2226 | + if ((int)$id && ($event = $this->read($id, $recurrence))) |
|
| 2229 | 2227 | { |
| 2230 | 2228 | $set['ts_start'] = $event['start']; |
| 2231 | 2229 | $set['ts_title'] = $this->link_title($event); |
| 2232 | - $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
|
| 2230 | + $set['start_time'] = Api\DateTime::to($event['start'], 'H:i'); |
|
| 2233 | 2231 | $set['ts_description'] = $event['description']; |
| 2234 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2232 | + if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2235 | 2233 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2236 | 2234 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2237 | - $set['end_time'] = null; // unset end-time |
|
| 2235 | + $set['end_time'] = null; // unset end-time |
|
| 2238 | 2236 | $set['cat_id'] = (int)$event['category']; |
| 2239 | 2237 | |
| 2240 | - foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link) |
|
| 2238 | + foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link) |
|
| 2241 | 2239 | { |
| 2242 | 2240 | if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME) |
| 2243 | 2241 | { |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Egroupware |
|
| 4 | - * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
| 5 | - * @link http://www.egroupware.org |
|
| 6 | - * @author Nathan Gray |
|
| 7 | - * @version $Id$ |
|
| 8 | - */ |
|
| 3 | + * Egroupware |
|
| 4 | + * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
| 5 | + * @link http://www.egroupware.org |
|
| 6 | + * @author Nathan Gray |
|
| 7 | + * @version $Id$ |
|
| 8 | + */ |
|
| 9 | 9 | |
| 10 | 10 | use EGroupware\Api; |
| 11 | 11 | use EGroupware\Api\Etemplate; |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * Set up what we know on the server side. |
|
| 26 | - * |
|
| 27 | - * Sending a first chunk of rows |
|
| 28 | - * |
|
| 29 | - * @param string $cname |
|
| 30 | - * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 31 | - */ |
|
| 25 | + * Set up what we know on the server side. |
|
| 26 | + * |
|
| 27 | + * Sending a first chunk of rows |
|
| 28 | + * |
|
| 29 | + * @param string $cname |
|
| 30 | + * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
| 31 | + */ |
|
| 32 | 32 | public function beforeSendToClient($cname, array $expand=null) |
| 33 | 33 | { |
| 34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
@@ -29,24 +29,24 @@ |
||
| 29 | 29 | * @param string $cname |
| 30 | 30 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
| 31 | 31 | */ |
| 32 | - public function beforeSendToClient($cname, array $expand=null) |
|
| 32 | + public function beforeSendToClient($cname, array $expand = null) |
|
| 33 | 33 | { |
| 34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
| 35 | - $value =& self::get_array(self::$request->content, $form_name, true); |
|
| 36 | - if(!is_array($value)) $value = array(); |
|
| 35 | + $value = & self::get_array(self::$request->content, $form_name, true); |
|
| 36 | + if (!is_array($value)) $value = array(); |
|
| 37 | 37 | |
| 38 | - foreach($value as &$events) |
|
| 38 | + foreach ($value as &$events) |
|
| 39 | 39 | { |
| 40 | - if(!is_array($events)) |
|
| 40 | + if (!is_array($events)) |
|
| 41 | 41 | { |
| 42 | 42 | continue; |
| 43 | 43 | } |
| 44 | - foreach($events as &$event) |
|
| 44 | + foreach ($events as &$event) |
|
| 45 | 45 | { |
| 46 | - if(!is_array($event)) continue; |
|
| 47 | - foreach(array('start','end') as $date) |
|
| 46 | + if (!is_array($event)) continue; |
|
| 47 | + foreach (array('start', 'end') as $date) |
|
| 48 | 48 | { |
| 49 | - $event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z'); |
|
| 49 | + $event[$date] = Api\DateTime::to($event[$date], 'Y-m-d\TH:i:s\Z'); |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -33,7 +33,10 @@ discard block |
||
| 33 | 33 | { |
| 34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
| 35 | 35 | $value =& self::get_array(self::$request->content, $form_name, true); |
| 36 | - if(!is_array($value)) $value = array(); |
|
| 36 | + if(!is_array($value)) |
|
| 37 | + { |
|
| 38 | + $value = array(); |
|
| 39 | + } |
|
| 37 | 40 | |
| 38 | 41 | foreach($value as &$events) |
| 39 | 42 | { |
@@ -43,7 +46,10 @@ discard block |
||
| 43 | 46 | } |
| 44 | 47 | foreach($events as &$event) |
| 45 | 48 | { |
| 46 | - if(!is_array($event)) continue; |
|
| 49 | + if(!is_array($event)) |
|
| 50 | + { |
|
| 51 | + continue; |
|
| 52 | + } |
|
| 47 | 53 | foreach(array('start','end') as $date) |
| 48 | 54 | { |
| 49 | 55 | $event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z'); |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | - * Do some magic with the participants and recurrance. |
|
| 136 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 137 | - * filter by it later. |
|
| 138 | - */ |
|
| 135 | + * Do some magic with the participants and recurrance. |
|
| 136 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 137 | + * filter by it later. |
|
| 138 | + */ |
|
| 139 | 139 | if(is_array($data['participants'])) |
| 140 | 140 | { |
| 141 | 141 | $participants = $data['participants']; |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
| 198 | - * Do some magic with the participants and recurrance. |
|
| 199 | - * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 200 | - * filter by it later. |
|
| 201 | - */ |
|
| 198 | + * Do some magic with the participants and recurrance. |
|
| 199 | + * If this is one of a recurring event, append the recur_date to the participant field so we can |
|
| 200 | + * filter by it later. |
|
| 201 | + */ |
|
| 202 | 202 | protected function alter_participants($participants) |
| 203 | 203 | { |
| 204 | 204 | $data = array(); |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public function __construct() |
| 116 | 116 | { |
| 117 | - parent::__construct('calendar'); // adds custom fields |
|
| 117 | + parent::__construct('calendar'); // adds custom fields |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * Tracks the changes in one entry $data, by comparing it with the last version in $old |
| 122 | 122 | * Overrides parent to reformat participants into a format parent can handle |
| 123 | 123 | */ |
| 124 | - public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null) |
|
| 124 | + public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null) |
|
| 125 | 125 | { |
| 126 | 126 | // Don't try to track dates on recurring events. |
| 127 | 127 | // It won't change for the base event, and any change to the time creates an exception |
| 128 | - if($data['recur_type']) |
|
| 128 | + if ($data['recur_type']) |
|
| 129 | 129 | { |
| 130 | 130 | unset($data['start']); unset($data['end']); |
| 131 | 131 | unset($old['start']); unset($old['end']); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * If this is one of a recurring event, append the recur_date to the participant field so we can |
| 137 | 137 | * filter by it later. |
| 138 | 138 | */ |
| 139 | - if(is_array($data['participants'])) |
|
| 139 | + if (is_array($data['participants'])) |
|
| 140 | 140 | { |
| 141 | 141 | $participants = $data['participants']; |
| 142 | 142 | $data['participants'] = array(); |
@@ -144,25 +144,25 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | // if clients eg. CalDAV do NOT set participants, they are left untouched |
| 146 | 146 | // therefore we should not track them, as all updates then show up as all participants removed |
| 147 | - elseif(!isset($data['participants'])) |
|
| 147 | + elseif (!isset($data['participants'])) |
|
| 148 | 148 | { |
| 149 | 149 | unset($old['participants']); |
| 150 | 150 | } |
| 151 | - if(is_array($old['participants'])) |
|
| 151 | + if (is_array($old['participants'])) |
|
| 152 | 152 | { |
| 153 | 153 | $participants = $old['participants']; |
| 154 | 154 | $old['participants'] = array(); |
| 155 | 155 | $old = array_merge($old, $this->alter_participants($participants)); |
| 156 | 156 | } |
| 157 | - parent::track($data,$old,$user,$deleted, $changed_fields); |
|
| 157 | + parent::track($data, $old, $user, $deleted, $changed_fields); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
| 161 | 161 | * Overrides parent because calendar_boupdates handles the notifications |
| 162 | 162 | */ |
| 163 | - public function do_notifications($data,$old,$deleted=null) |
|
| 163 | + public function do_notifications($data, $old, $deleted = null) |
|
| 164 | 164 | { |
| 165 | - unset($data, $old, $deleted); // unused, but required by function signature |
|
| 165 | + unset($data, $old, $deleted); // unused, but required by function signature |
|
| 166 | 166 | return true; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -177,21 +177,21 @@ discard block |
||
| 177 | 177 | * @param array $old = null |
| 178 | 178 | * @return array of keys with different values in $data and $old |
| 179 | 179 | */ |
| 180 | - public function changed_fields(array $data,array $old=null) |
|
| 180 | + public function changed_fields(array $data, array $old = null) |
|
| 181 | 181 | { |
| 182 | - if(is_array($data['participants'])) |
|
| 182 | + if (is_array($data['participants'])) |
|
| 183 | 183 | { |
| 184 | 184 | $participants = $data['participants']; |
| 185 | 185 | $data['participants'] = array(); |
| 186 | 186 | $data = array_merge($data, $this->alter_participants($participants)); |
| 187 | 187 | } |
| 188 | - if(is_array($old['participants'])) |
|
| 188 | + if (is_array($old['participants'])) |
|
| 189 | 189 | { |
| 190 | 190 | $participants = $old['participants']; |
| 191 | 191 | $old['participants'] = array(); |
| 192 | 192 | $old = array_merge($old, $this->alter_participants($participants)); |
| 193 | 193 | } |
| 194 | - return parent::changed_fields($data,$old); |
|
| 194 | + return parent::changed_fields($data, $old); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | protected function alter_participants($participants) |
| 203 | 203 | { |
| 204 | 204 | $data = array(); |
| 205 | - foreach($participants as $uid => $status) |
|
| 205 | + foreach ($participants as $uid => $status) |
|
| 206 | 206 | { |
| 207 | 207 | $quantity = $role = $user_type = $user_id = null; |
| 208 | 208 | calendar_so::split_status($status, $quantity, $role); |
@@ -1528,7 +1528,7 @@ |
||
| 1528 | 1528 | if (!$set_recurrences) |
| 1529 | 1529 | { |
| 1530 | 1530 | $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
| 1531 | - $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1531 | + $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
|
| 1532 | 1532 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
| 1533 | 1533 | } |
| 1534 | 1534 | |
@@ -211,23 +211,11 @@ discard block |
||
| 211 | 211 | * @param int $start startdate of the search/list (servertime) |
| 212 | 212 | * @param int $end enddate of the search/list (servertime) |
| 213 | 213 | * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users |
| 214 | - * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 214 | + * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 215 | 215 | * @param string $filter ='default' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted) |
| 216 | 216 | * @param int|boolean $offset =False offset for a limited query or False (default) |
| 217 | 217 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 218 | 218 | * @param array $params =array() |
| 219 | - * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search) |
|
| 220 | - * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! |
|
| 221 | - * array: everything is directly used as $where |
|
| 222 | - * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma |
|
| 223 | - * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted) |
|
| 224 | - * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date", |
|
| 225 | - * if specified and not false an iterator for the rows is returned |
|
| 226 | - * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause |
|
| 227 | - * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names |
|
| 228 | - * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved! |
|
| 229 | - * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS) |
|
| 230 | - * @param boolean $params['enum_recuring'] =true enumerate recuring events |
|
| 231 | 219 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 232 | 220 | * @return array of events |
| 233 | 221 | */ |
@@ -594,7 +582,7 @@ discard block |
||
| 594 | 582 | /** |
| 595 | 583 | * generate SQL to filter after a given category (incl. subcategories) |
| 596 | 584 | * |
| 597 | - * @param array|int $cat_id cat-id or array of cat-ids, or !$cat_id for none |
|
| 585 | + * @param integer $cat_id cat-id or array of cat-ids, or !$cat_id for none |
|
| 598 | 586 | * @return string SQL to include in the query |
| 599 | 587 | */ |
| 600 | 588 | function cat_filter($cat_id) |
@@ -682,24 +670,11 @@ discard block |
||
| 682 | 670 | * @param int $start startdate of the search/list (servertime) |
| 683 | 671 | * @param int $end enddate of the search/list (servertime) |
| 684 | 672 | * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users |
| 685 | - * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 673 | + * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all |
|
| 686 | 674 | * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted) |
| 687 | 675 | * @param int|boolean $offset =False offset for a limited query or False (default) |
| 688 | 676 | * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs |
| 689 | 677 | * @param array $params =array() |
| 690 | - * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search) |
|
| 691 | - * Please Note: a search never returns repeating events more then once AND does not honor start+end date !!! |
|
| 692 | - * array: everything is directly used as $where |
|
| 693 | - * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma |
|
| 694 | - * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array |
|
| 695 | - * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date", |
|
| 696 | - * if specified and not false an iterator for the rows is returned |
|
| 697 | - * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause |
|
| 698 | - * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names |
|
| 699 | - * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved! |
|
| 700 | - * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS) |
|
| 701 | - * @param boolean $params['enum_recuring'] =true enumerate recuring events |
|
| 702 | - * @param boolean $params['use_so_events'] =false, true return result of new $this->events() |
|
| 703 | 678 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 704 | 679 | * @return Iterator|array of events |
| 705 | 680 | */ |
@@ -1140,11 +1115,11 @@ discard block |
||
| 1140 | 1115 | * Ask other apps if they want to participate in calendar search / display |
| 1141 | 1116 | * |
| 1142 | 1117 | * @param &$selects parts of union query |
| 1143 | - * @param $start see search() |
|
| 1144 | - * @param $end |
|
| 1118 | + * @param integer $start see search() |
|
| 1119 | + * @param integer $end |
|
| 1145 | 1120 | * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo) |
| 1146 | - * @param $cat_id |
|
| 1147 | - * @param $filter |
|
| 1121 | + * @param integer $cat_id |
|
| 1122 | + * @param string $filter |
|
| 1148 | 1123 | * @param $query |
| 1149 | 1124 | * @param $users_raw as passed to calendar_bo::search (no members and memberships added) |
| 1150 | 1125 | */ |
@@ -1312,6 +1287,7 @@ discard block |
||
| 1312 | 1287 | * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all |
| 1313 | 1288 | * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all |
| 1314 | 1289 | * @param int &$etag etag=null etag to check or null, on return new etag |
| 1290 | + * @param boolean $set_recurrences |
|
| 1315 | 1291 | * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise |
| 1316 | 1292 | */ |
| 1317 | 1293 | function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null) |
@@ -1722,7 +1698,7 @@ discard block |
||
| 1722 | 1698 | * @param int $cal_id |
| 1723 | 1699 | * @param int $start new starttime |
| 1724 | 1700 | * @param int $end new endtime |
| 1725 | - * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all |
|
| 1701 | + * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all |
|
| 1726 | 1702 | * @param int $old_start =0 old starttime or (default) 0, to query it from the db |
| 1727 | 1703 | * @param int $old_end =0 old starttime or (default) 0 |
| 1728 | 1704 | * @todo Recalculate recurrences, if timezone changes |
@@ -1899,7 +1875,7 @@ discard block |
||
| 1899 | 1875 | * |
| 1900 | 1876 | * @param int $cal_id |
| 1901 | 1877 | * @param array $participants uid => status pairs |
| 1902 | - * @param int|boolean $change_since =0, false=new event, |
|
| 1878 | + * @param integer $change_since =0, false=new event, |
|
| 1903 | 1879 | * 0=all, > 0 time from which on the repetitions should be changed |
| 1904 | 1880 | * @param boolean $add_only =false |
| 1905 | 1881 | * false = add AND delete participants if needed (full list of participants required in $participants) |
@@ -2045,7 +2021,7 @@ discard block |
||
| 2045 | 2021 | * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0) |
| 2046 | 2022 | * |
| 2047 | 2023 | * @param int $cal_id |
| 2048 | - * @param char $user_type 'u' regular user, 'r' resource, 'c' contact |
|
| 2024 | + * @param string $user_type 'u' regular user, 'r' resource, 'c' contact |
|
| 2049 | 2025 | * @param int|string $user_id |
| 2050 | 2026 | * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A' |
| 2051 | 2027 | * @param int $recur_date =0 date to change, or 0 = all since now |
@@ -2962,7 +2938,7 @@ discard block |
||
| 2962 | 2938 | * Updates the modification timestamp to force an etag, ctag and sync-token change |
| 2963 | 2939 | * |
| 2964 | 2940 | * @param int $id event id |
| 2965 | - * @param int|boolean $update_master =false id of series master or true, to update series master too |
|
| 2941 | + * @param boolean $update_master =false id of series master or true, to update series master too |
|
| 2966 | 2942 | * @param int $time =null new timestamp, default current (server-)time |
| 2967 | 2943 | * @param int $modifier =null uid of the modifier, default current user |
| 2968 | 2944 | */ |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | " CASE WHEN recur_type IS NULL THEN egw_cal.range_start ELSE cal_start END AS cal_start,\n". |
| 253 | 253 | " CASE WHEN recur_type IS NULL THEN egw_cal.range_end ELSE cal_end END AS cal_end\n". |
| 254 | 254 | // using time-limited range view, instead of complete table, give a big performance plus |
| 255 | - "FROM $egw_cal\n". |
|
| 255 | + "from $egw_cal\n". |
|
| 256 | 256 | "JOIN egw_cal_user ON egw_cal_user.cal_id=egw_cal.cal_id\n". |
| 257 | 257 | // need to left join dates, as egw_cal_user.recur_date is null for non-recuring event |
| 258 | 258 | "LEFT JOIN egw_cal_dates ON egw_cal_user.cal_id=egw_cal_dates.cal_id AND egw_cal_dates.cal_start=egw_cal_user.cal_recur_date\n". |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | $where[] = 'cal_start >= '.(int)$recur_date; |
| 346 | 346 | $group_by = 'GROUP BY '.$cols; |
| 347 | 347 | $cols .= ',MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end'; |
| 348 | - $join = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join"; |
|
| 348 | + $join = "join $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join"; |
|
| 349 | 349 | } |
| 350 | 350 | else |
| 351 | 351 | { |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | $cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted'); |
| 875 | 875 | $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
| 876 | 876 | |
| 877 | - $join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ". |
|
| 877 | + $join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ". |
|
| 878 | 878 | "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ". |
| 879 | 879 | $rejected_by_user_join; |
| 880 | 880 | // dates table join only needed to enum recuring events, we use a time-range limited view here too |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | { |
| 1402 | 1402 | $old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate", |
| 1403 | 1403 | "$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__, |
| 1404 | - false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch(); |
|
| 1404 | + false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch(); |
|
| 1405 | 1405 | } |
| 1406 | 1406 | $where = array('cal_id' => $cal_id); |
| 1407 | 1407 | // read only timezone id, to check if it is changed |
@@ -1766,13 +1766,13 @@ discard block |
||
| 1766 | 1766 | if ($move_start) |
| 1767 | 1767 | { |
| 1768 | 1768 | // move the recur-date of the participants |
| 1769 | - $this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
|
| 1769 | + $this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
|
| 1770 | 1770 | ((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__); |
| 1771 | 1771 | } |
| 1772 | 1772 | if ($move_start || $move_end) |
| 1773 | 1773 | { |
| 1774 | 1774 | // move the event and it's recurrences |
| 1775 | - $this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
|
| 1775 | + $this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
|
| 1776 | 1776 | ((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__); |
| 1777 | 1777 | } |
| 1778 | 1778 | return $this->db->affected_rows(); |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | ),__LINE__,__FILE__,'calendar'); |
| 2473 | 2473 | |
| 2474 | 2474 | // delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner) |
| 2475 | - foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2475 | + foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2476 | 2476 | False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
| 2477 | 2477 | { |
| 2478 | 2478 | $this->delete($row['cal_id']); |
@@ -154,16 +154,32 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
| 156 | 156 | { |
| 157 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
|
| 157 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) |
|
| 158 | 158 | { |
| 159 | - return $this->cal_table; // no need / use for a view |
|
| 159 | + // using view without start-date is slower! |
|
| 160 | + { |
|
| 161 | + return $this->cal_table; |
|
| 162 | + } |
|
| 163 | + // no need / use for a view |
|
| 160 | 164 | } |
| 161 | 165 | |
| 162 | 166 | $where = array(); |
| 163 | - if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 164 | - if ($end) $where[] = "range_start<".(int)$end; |
|
| 165 | - if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 166 | - if ($_where) $where = array_merge($where, $_where); |
|
| 167 | + if (isset($deleted)) |
|
| 168 | + { |
|
| 169 | + $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL'; |
|
| 170 | + } |
|
| 171 | + if ($end) |
|
| 172 | + { |
|
| 173 | + $where[] = "range_start<".(int)$end; |
|
| 174 | + } |
|
| 175 | + if ($start) |
|
| 176 | + { |
|
| 177 | + $where[] = "(range_end IS NULL OR range_end>".(int)$start.")"; |
|
| 178 | + } |
|
| 179 | + if ($_where) |
|
| 180 | + { |
|
| 181 | + $where = array_merge($where, $_where); |
|
| 182 | + } |
|
| 167 | 183 | |
| 168 | 184 | $sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table"; |
| 169 | 185 | |
@@ -184,16 +200,32 @@ discard block |
||
| 184 | 200 | */ |
| 185 | 201 | protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
| 186 | 202 | { |
| 187 | - if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
|
| 203 | + if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) |
|
| 204 | + { |
|
| 205 | + // using view without start- AND end-date is slower! |
|
| 188 | 206 | { |
| 189 | - return $this->dates_table; // no need / use for a view |
|
| 207 | + return $this->dates_table; |
|
| 208 | + } |
|
| 209 | + // no need / use for a view |
|
| 190 | 210 | } |
| 191 | 211 | |
| 192 | 212 | $where = array(); |
| 193 | - if (isset($deleted)) $where['recur_exception'] = $deleted; |
|
| 194 | - if ($end) $where[] = "cal_start<".(int)$end; |
|
| 195 | - if ($start) $where[] = "cal_end>".(int)$start; |
|
| 196 | - if ($_where) $where = array_merge($where, $_where); |
|
| 213 | + if (isset($deleted)) |
|
| 214 | + { |
|
| 215 | + $where['recur_exception'] = $deleted; |
|
| 216 | + } |
|
| 217 | + if ($end) |
|
| 218 | + { |
|
| 219 | + $where[] = "cal_start<".(int)$end; |
|
| 220 | + } |
|
| 221 | + if ($start) |
|
| 222 | + { |
|
| 223 | + $where[] = "cal_end>".(int)$start; |
|
| 224 | + } |
|
| 225 | + if ($_where) |
|
| 226 | + { |
|
| 227 | + $where = array_merge($where, $_where); |
|
| 228 | + } |
|
| 197 | 229 | |
| 198 | 230 | // Api\Db::union uses Api\Db::select which check if join contains "WHERE" |
| 199 | 231 | // to support old join syntax like ", other_table WHERE ...", |
@@ -243,7 +275,10 @@ discard block |
||
| 243 | 275 | throw new Api\Exception\AssertionFailed("Unsupported value for parameters!"); |
| 244 | 276 | } |
| 245 | 277 | $where = is_array($params['query']) ? $params['query'] : array(); |
| 246 | - if ($cat_id) $where[] = $this->cat_filter($cat_id); |
|
| 278 | + if ($cat_id) |
|
| 279 | + { |
|
| 280 | + $where[] = $this->cat_filter($cat_id); |
|
| 281 | + } |
|
| 247 | 282 | $egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted'); |
| 248 | 283 | |
| 249 | 284 | $status_filter = $this->status_filter($filter, $params['enum_recuring']); |
@@ -264,7 +299,10 @@ discard block |
||
| 264 | 299 | if ($users) |
| 265 | 300 | { |
| 266 | 301 | // fix $users to also prefix system users and groups (with 'u') |
| 267 | - if (!is_array($users)) $users = $users ? (array)$users : array(); |
|
| 302 | + if (!is_array($users)) |
|
| 303 | + { |
|
| 304 | + $users = $users ? (array)$users : array(); |
|
| 305 | + } |
|
| 268 | 306 | foreach($users as &$uid) |
| 269 | 307 | { |
| 270 | 308 | $user_type = $user_id = null; |
@@ -284,15 +322,22 @@ discard block |
||
| 284 | 322 | $sql .= " AND\n ".$params['sql_filter']; |
| 285 | 323 | } |
| 286 | 324 | |
| 287 | - if ($params['order']) // only order if requested |
|
| 325 | + if ($params['order']) |
|
| 288 | 326 | { |
| 289 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 327 | + // only order if requested |
|
| 328 | + { |
|
| 329 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; |
|
| 330 | + } |
|
| 331 | + // gard against SQL injection |
|
| 290 | 332 | $sql .= "\nORDER BY ".$params['order']; |
| 291 | 333 | } |
| 292 | 334 | |
| 293 | - if ($offset === false) // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 335 | + if ($offset === false) |
|
| 336 | + { |
|
| 337 | + // return all rows --> Api\Db::query wants offset=0, num_rows=-1 |
|
| 294 | 338 | { |
| 295 | 339 | $offset = 0; |
| 340 | + } |
|
| 296 | 341 | $num_rows = -1; |
| 297 | 342 | } |
| 298 | 343 | $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
@@ -318,26 +363,35 @@ discard block |
||
| 318 | 363 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
| 319 | 364 | |
| 320 | 365 | $where = array(); |
| 321 | - if (is_scalar($ids) && !is_numeric($ids)) // a single uid |
|
| 366 | + if (is_scalar($ids) && !is_numeric($ids)) |
|
| 367 | + { |
|
| 368 | + // a single uid |
|
| 322 | 369 | { |
| 323 | 370 | // We want only the parents to match |
| 324 | 371 | $where['cal_uid'] = $ids; |
| 372 | + } |
|
| 325 | 373 | $where['cal_reference'] = 0; |
| 326 | 374 | } |
| 327 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
| 375 | + elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) |
|
| 376 | + { |
|
| 377 | + // one or more cal_id's |
|
| 328 | 378 | { |
| 329 | 379 | $where['cal_id'] = $ids; |
| 330 | 380 | } |
| 381 | + } |
|
| 331 | 382 | else // array with column => value pairs |
| 332 | 383 | { |
| 333 | 384 | $where = $ids; |
| 334 | 385 | unset($ids); // otherwise users get not read! |
| 335 | 386 | } |
| 336 | - if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
|
| 387 | + if (isset($where['cal_id'])) |
|
| 388 | + { |
|
| 389 | + // prevent non-unique column-name cal_id |
|
| 337 | 390 | { |
| 338 | 391 | $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
| 339 | 392 | 'cal_id' => $where['cal_id'], |
| 340 | 393 | )); |
| 394 | + } |
|
| 341 | 395 | unset($where['cal_id']); |
| 342 | 396 | } |
| 343 | 397 | if ((int) $recur_date) |
@@ -387,10 +441,16 @@ discard block |
||
| 387 | 441 | $row['recur_exception'] = $row['alarm'] = array(); |
| 388 | 442 | $events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_'); |
| 389 | 443 | } |
| 390 | - if (!$events) return $events; |
|
| 444 | + if (!$events) |
|
| 445 | + { |
|
| 446 | + return $events; |
|
| 447 | + } |
|
| 391 | 448 | |
| 392 | 449 | $ids = array_keys($events); |
| 393 | - if (count($ids) == 1) $ids = $ids[0]; |
|
| 450 | + if (count($ids) == 1) |
|
| 451 | + { |
|
| 452 | + $ids = $ids[0]; |
|
| 453 | + } |
|
| 394 | 454 | |
| 395 | 455 | foreach ($events as &$event) |
| 396 | 456 | { |
@@ -464,10 +524,13 @@ discard block |
||
| 464 | 524 | 'cal_id' => $ids, |
| 465 | 525 | 'cal_recur_date' => $recur_date, |
| 466 | 526 | "cal_status NOT IN ('X','E')", |
| 467 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
| 527 | + ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) |
|
| 528 | + { |
|
| 529 | + // DESC puts users before resources and contacts |
|
| 468 | 530 | { |
| 469 | 531 | // combine all participant data in uid and status values |
| 470 | 532 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 533 | + } |
|
| 471 | 534 | $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
| 472 | 535 | |
| 473 | 536 | $events[$row['cal_id']]['participants'][$uid] = $status; |
@@ -524,7 +587,10 @@ discard block |
||
| 524 | 587 | $last_request = time(); |
| 525 | 588 | } |
| 526 | 589 | $signature = serialize(func_get_args()); |
| 527 | - if (isset($ctags[$signature])) return $ctags[$signature]; |
|
| 590 | + if (isset($ctags[$signature])) |
|
| 591 | + { |
|
| 592 | + return $ctags[$signature]; |
|
| 593 | + } |
|
| 528 | 594 | |
| 529 | 595 | $types = array(); |
| 530 | 596 | foreach((array)$users as $uid) |
@@ -557,7 +623,10 @@ discard block |
||
| 557 | 623 | // owner can only by users, no groups or resources |
| 558 | 624 | foreach($users as $key => $user) |
| 559 | 625 | { |
| 560 | - if (!($user > 0)) unset($users[$key]); |
|
| 626 | + if (!($user > 0)) |
|
| 627 | + { |
|
| 628 | + unset($users[$key]); |
|
| 629 | + } |
|
| 561 | 630 | } |
| 562 | 631 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
| 563 | 632 | $this->db->expression($this->cal_table, array( |
@@ -579,7 +648,10 @@ discard block |
||
| 579 | 648 | */ |
| 580 | 649 | function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
| 581 | 650 | { |
| 582 | - if (!is_array($cols)) $cols = explode(',', $cols); |
|
| 651 | + if (!is_array($cols)) |
|
| 652 | + { |
|
| 653 | + $cols = explode(',', $cols); |
|
| 654 | + } |
|
| 583 | 655 | |
| 584 | 656 | // special handling of cal_user_modified "pseudo" column |
| 585 | 657 | if (($key = array_search('cal_user_modified', $cols)) !== false) |
@@ -604,7 +676,10 @@ discard block |
||
| 604 | 676 | { |
| 605 | 677 | $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); |
| 606 | 678 | array_walk($cats,create_function('&$val,$key','$val = (int) $val;')); |
| 607 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
| 679 | + if (is_array($cat_id) && count($cat_id)==1) |
|
| 680 | + { |
|
| 681 | + $cat_id = $cat_id[0]; |
|
| 682 | + } |
|
| 608 | 683 | $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
| 609 | 684 | foreach($cats as $cat) |
| 610 | 685 | { |
@@ -663,10 +738,13 @@ discard block |
||
| 663 | 738 | $where[] = "$this->user_table.cal_status NOT IN ('X','E')"; |
| 664 | 739 | break; |
| 665 | 740 | default: |
| 666 | - if ($enum_recuring) // regular UI |
|
| 741 | + if ($enum_recuring) |
|
| 742 | + { |
|
| 743 | + // regular UI |
|
| 667 | 744 | { |
| 668 | 745 | $where[] = "$this->user_table.cal_status NOT IN ('R','X','E')"; |
| 669 | 746 | } |
| 747 | + } |
|
| 670 | 748 | else // CalDAV / eSync / iCal need to include 'E' = exceptions |
| 671 | 749 | { |
| 672 | 750 | $where[] = "$this->user_table.cal_status NOT IN ('R','X')"; |
@@ -805,7 +883,10 @@ discard block |
||
| 805 | 883 | $user_ids = array(); |
| 806 | 884 | foreach($ids as $user_id) |
| 807 | 885 | { |
| 808 | - if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
|
| 886 | + if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') |
|
| 887 | + { |
|
| 888 | + $user_ids[] = $user_id; |
|
| 889 | + } |
|
| 809 | 890 | } |
| 810 | 891 | $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
| 811 | 892 | } |
@@ -825,7 +906,10 @@ discard block |
||
| 825 | 906 | } |
| 826 | 907 | } |
| 827 | 908 | // this is only used, when we cannot use UNIONS |
| 828 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 909 | + if (!$useUnionQuery) |
|
| 910 | + { |
|
| 911 | + $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 912 | + } |
|
| 829 | 913 | |
| 830 | 914 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
| 831 | 915 | } |
@@ -844,7 +928,11 @@ discard block |
||
| 844 | 928 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
| 845 | 929 | } |
| 846 | 930 | } |
| 847 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 931 | + if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) |
|
| 932 | + { |
|
| 933 | + $params['order'] = 'cal_start'; |
|
| 934 | + } |
|
| 935 | + // gard against SQL injection |
|
| 848 | 936 | |
| 849 | 937 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
| 850 | 938 | if (!$params['enum_recuring']) |
@@ -854,9 +942,15 @@ discard block |
||
| 854 | 942 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
| 855 | 943 | $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
| 856 | 944 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
| 857 | - if ($end) $where[] = (int)$end.' > range_start'; |
|
| 945 | + if ($end) |
|
| 946 | + { |
|
| 947 | + $where[] = (int)$end.' > range_start'; |
|
| 948 | + } |
|
| 858 | 949 | } |
| 859 | - elseif ($end) $where[] = (int)$end.' > cal_start'; |
|
| 950 | + elseif ($end) |
|
| 951 | + { |
|
| 952 | + $where[] = (int)$end.' > cal_start'; |
|
| 953 | + } |
|
| 860 | 954 | |
| 861 | 955 | if ($remove_rejected_by_user && $filter != 'everything') |
| 862 | 956 | { |
@@ -870,7 +964,10 @@ discard block |
||
| 870 | 964 | 'rejected_by_user.cal_status IS NULL', |
| 871 | 965 | "rejected_by_user.cal_status NOT IN ('R','X')", |
| 872 | 966 | ); |
| 873 | - if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 967 | + if ($filter == 'owner') |
|
| 968 | + { |
|
| 969 | + $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
|
| 970 | + } |
|
| 874 | 971 | $where[] = '('.implode(' OR ',$or_required).')'; |
| 875 | 972 | } |
| 876 | 973 | // using a time-range and deleted attribute limited view instead of full table |
@@ -892,7 +989,10 @@ discard block |
||
| 892 | 989 | if ($useUnionQuery) |
| 893 | 990 | { |
| 894 | 991 | // allow apps to supply participants and/or icons |
| 895 | - if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 992 | + if (!isset($params['cols'])) |
|
| 993 | + { |
|
| 994 | + $cols .= ',NULL AS participants,NULL AS icons'; |
|
| 995 | + } |
|
| 896 | 996 | |
| 897 | 997 | // changed the original OR in the query into a union, to speed up the query execution under MySQL 5 |
| 898 | 998 | // with time-range views benefit is now at best slim for huge tables or none at all! |
@@ -947,9 +1047,12 @@ discard block |
||
| 947 | 1047 | $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
| 948 | 1048 | } |
| 949 | 1049 | } |
| 950 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1050 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1051 | + { |
|
| 1052 | + // get the total too |
|
| 951 | 1053 | { |
| 952 | 1054 | $save_selects = $selects; |
| 1055 | + } |
|
| 953 | 1056 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 954 | 1057 | foreach(array_keys($selects) as $key) |
| 955 | 1058 | { |
@@ -960,14 +1063,20 @@ discard block |
||
| 960 | 1063 | array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
| 961 | 1064 | } |
| 962 | 1065 | } |
| 963 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1066 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1067 | + { |
|
| 1068 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1069 | + } |
|
| 964 | 1070 | |
| 965 | 1071 | $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
| 966 | 1072 | |
| 967 | 1073 | // restore original cols / selects |
| 968 | 1074 | $selects = $save_selects; unset($save_selects); |
| 969 | 1075 | } |
| 970 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1076 | + if (!isset($params['cols']) && !$params['no_integration']) |
|
| 1077 | + { |
|
| 1078 | + self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1079 | + } |
|
| 971 | 1080 | |
| 972 | 1081 | $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
| 973 | 1082 | } |
@@ -985,9 +1094,12 @@ discard block |
||
| 985 | 1094 | 'table_def' => $cal_table_def, |
| 986 | 1095 | )); |
| 987 | 1096 | |
| 988 | - if (is_numeric($offset) && !$params['no_total']) // get the total too |
|
| 1097 | + if (is_numeric($offset) && !$params['no_total']) |
|
| 1098 | + { |
|
| 1099 | + // get the total too |
|
| 989 | 1100 | { |
| 990 | 1101 | $save_selects = $selects; |
| 1102 | + } |
|
| 991 | 1103 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 992 | 1104 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
| 993 | 1105 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
@@ -1015,7 +1127,10 @@ discard block |
||
| 1015 | 1127 | foreach($rs as $row) |
| 1016 | 1128 | { |
| 1017 | 1129 | $id = $row['cal_id']; |
| 1018 | - if (is_numeric($id)) $ids[] = $id; |
|
| 1130 | + if (is_numeric($id)) |
|
| 1131 | + { |
|
| 1132 | + $ids[] = $id; |
|
| 1133 | + } |
|
| 1019 | 1134 | |
| 1020 | 1135 | if ($row['cal_recur_date']) |
| 1021 | 1136 | { |
@@ -1035,7 +1150,10 @@ discard block |
||
| 1035 | 1150 | $row['recur_exception'] = $row['alarm'] = array(); |
| 1036 | 1151 | |
| 1037 | 1152 | // compile a list of recurrences per cal_id |
| 1038 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1153 | + if (!in_array($id,(array)$recur_ids[$row['cal_id']])) |
|
| 1154 | + { |
|
| 1155 | + $recur_ids[$row['cal_id']][] = $id; |
|
| 1156 | + } |
|
| 1039 | 1157 | |
| 1040 | 1158 | $events[$id] = Api\Db::strip_array_keys($row,'cal_'); |
| 1041 | 1159 | } |
@@ -1054,10 +1172,16 @@ discard block |
||
| 1054 | 1172 | //'cal_id' => array_unique($ids), |
| 1055 | 1173 | 'cal_recur_date' => $recur_dates, |
| 1056 | 1174 | ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='', |
| 1057 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1175 | + $this->db->get_table_definitions('calendar',$this->user_table)) as $row) |
|
| 1176 | + { |
|
| 1177 | + // DESC puts users before resources and contacts |
|
| 1058 | 1178 | { |
| 1059 | 1179 | $id = $row['cal_id']; |
| 1060 | - if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
|
| 1180 | + } |
|
| 1181 | + if ($row['cal_recur_date']) |
|
| 1182 | + { |
|
| 1183 | + $id .= '-'.$row['cal_recur_date']; |
|
| 1184 | + } |
|
| 1061 | 1185 | |
| 1062 | 1186 | // combine all participant data in uid and status values |
| 1063 | 1187 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
@@ -1076,7 +1200,10 @@ discard block |
||
| 1076 | 1200 | } |
| 1077 | 1201 | |
| 1078 | 1202 | // set data, if recurrence is requested |
| 1079 | - if (isset($events[$id])) $events[$id]['participants'][$uid] = $status; |
|
| 1203 | + if (isset($events[$id])) |
|
| 1204 | + { |
|
| 1205 | + $events[$id]['participants'][$uid] = $status; |
|
| 1206 | + } |
|
| 1080 | 1207 | } |
| 1081 | 1208 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
| 1082 | 1209 | if (!$params['enum_recuring'] || !$params['daywise']) |
@@ -1092,7 +1219,10 @@ discard block |
||
| 1092 | 1219 | { |
| 1093 | 1220 | foreach($events as $id => $event) |
| 1094 | 1221 | { |
| 1095 | - if ($event['id'] == $row['cal_id']) break; |
|
| 1222 | + if ($event['id'] == $row['cal_id']) |
|
| 1223 | + { |
|
| 1224 | + break; |
|
| 1225 | + } |
|
| 1096 | 1226 | } |
| 1097 | 1227 | } |
| 1098 | 1228 | $events[$id]['recur_exception'][] = $row['cal_start']; |
@@ -1102,7 +1232,10 @@ discard block |
||
| 1102 | 1232 | if (!is_null($params['cfs'])) |
| 1103 | 1233 | { |
| 1104 | 1234 | $where = array('cal_id' => $ids); |
| 1105 | - if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
|
| 1235 | + if ($params['cfs']) |
|
| 1236 | + { |
|
| 1237 | + $where['cal_extra_name'] = $params['cfs']; |
|
| 1238 | + } |
|
| 1106 | 1239 | foreach($this->db->select($this->extra_table,'*',$where, |
| 1107 | 1240 | __LINE__,__FILE__,false,'','calendar') as $row) |
| 1108 | 1241 | { |
@@ -1122,14 +1255,20 @@ discard block |
||
| 1122 | 1255 | { |
| 1123 | 1256 | $event_start = $alarm['time'] + $alarm['offset']; |
| 1124 | 1257 | |
| 1125 | - if (isset($events[$cal_id])) // none recuring event |
|
| 1258 | + if (isset($events[$cal_id])) |
|
| 1259 | + { |
|
| 1260 | + // none recuring event |
|
| 1126 | 1261 | { |
| 1127 | 1262 | $events[$cal_id]['alarm'][$id] = $alarm; |
| 1128 | 1263 | } |
| 1129 | - elseif (isset($events[$cal_id.'-'.$event_start])) // recuring event |
|
| 1264 | + } |
|
| 1265 | + elseif (isset($events[$cal_id.'-'.$event_start])) |
|
| 1266 | + { |
|
| 1267 | + // recuring event |
|
| 1130 | 1268 | { |
| 1131 | 1269 | $events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm; |
| 1132 | 1270 | } |
| 1271 | + } |
|
| 1133 | 1272 | } |
| 1134 | 1273 | } |
| 1135 | 1274 | } |
@@ -1229,10 +1368,13 @@ discard block |
||
| 1229 | 1368 | } |
| 1230 | 1369 | foreach((array)$cols as $col) |
| 1231 | 1370 | { |
| 1232 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
| 1371 | + if (substr($col,0,7) == 'egw_cal') |
|
| 1372 | + { |
|
| 1373 | + // remove table name |
|
| 1233 | 1374 | { |
| 1234 | 1375 | $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
| 1235 | 1376 | } |
| 1377 | + } |
|
| 1236 | 1378 | if (isset($app_cols[$col])) |
| 1237 | 1379 | { |
| 1238 | 1380 | $return_cols[] = $app_cols[$col]; |
@@ -1326,7 +1468,11 @@ discard block |
||
| 1326 | 1468 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 1327 | 1469 | { |
| 1328 | 1470 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
| 1329 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1471 | + if (empty($minimum_uid_length) || $minimum_uid_length<=1) |
|
| 1472 | + { |
|
| 1473 | + $minimum_uid_length = 8; |
|
| 1474 | + } |
|
| 1475 | + // we just do not accept no uid, or uid way to short! |
|
| 1330 | 1476 | } |
| 1331 | 1477 | else |
| 1332 | 1478 | { |
@@ -1374,7 +1520,10 @@ discard block |
||
| 1374 | 1520 | } |
| 1375 | 1521 | } |
| 1376 | 1522 | // set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values! |
| 1377 | - if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
|
| 1523 | + if (isset($event['cal_start'])) |
|
| 1524 | + { |
|
| 1525 | + $event['range_start'] = $event['cal_start']; |
|
| 1526 | + } |
|
| 1378 | 1527 | if (isset($event['cal_end'])) |
| 1379 | 1528 | { |
| 1380 | 1529 | $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
@@ -1395,7 +1544,10 @@ discard block |
||
| 1395 | 1544 | $event['cal_category'] = implode(',',$categories); |
| 1396 | 1545 | |
| 1397 | 1546 | // make sure recurring events never reference to an other recurrent event |
| 1398 | - if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
|
| 1547 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 1548 | + { |
|
| 1549 | + $event['cal_reference'] = 0; |
|
| 1550 | + } |
|
| 1399 | 1551 | |
| 1400 | 1552 | if ($cal_id) |
| 1401 | 1553 | { |
@@ -1412,7 +1564,10 @@ discard block |
||
| 1412 | 1564 | { |
| 1413 | 1565 | $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
| 1414 | 1566 | } |
| 1415 | - if (!is_null($etag)) $where['cal_etag'] = $etag; |
|
| 1567 | + if (!is_null($etag)) |
|
| 1568 | + { |
|
| 1569 | + $where['cal_etag'] = $etag; |
|
| 1570 | + } |
|
| 1416 | 1571 | |
| 1417 | 1572 | unset($event['cal_etag']); |
| 1418 | 1573 | $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
@@ -1423,14 +1578,24 @@ discard block |
||
| 1423 | 1578 | { |
| 1424 | 1579 | return 0; // wrong etag, someone else updated the entry |
| 1425 | 1580 | } |
| 1426 | - if (!is_null($etag)) ++$etag; |
|
| 1581 | + if (!is_null($etag)) |
|
| 1582 | + { |
|
| 1583 | + ++$etag; |
|
| 1584 | + } |
|
| 1427 | 1585 | } |
| 1428 | 1586 | else |
| 1429 | 1587 | { |
| 1430 | 1588 | // new event |
| 1431 | - if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1589 | + if (!$event['cal_owner']) |
|
| 1590 | + { |
|
| 1591 | + $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
|
| 1592 | + } |
|
| 1432 | 1593 | |
| 1433 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1594 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) |
|
| 1595 | + { |
|
| 1596 | + $event['cal_uid'] = ''; |
|
| 1597 | + } |
|
| 1598 | + // uid is NOT NULL! |
|
| 1434 | 1599 | |
| 1435 | 1600 | $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
| 1436 | 1601 | if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id'))) |
@@ -1582,8 +1747,7 @@ discard block |
||
| 1582 | 1747 | // recurrences need to be truncated |
| 1583 | 1748 | if((int)$event['recur_enddate'] > 0 && |
| 1584 | 1749 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
| 1585 | - ) |
|
| 1586 | - { |
|
| 1750 | + ) { |
|
| 1587 | 1751 | $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1588 | 1752 | $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
| 1589 | 1753 | } |
@@ -1591,8 +1755,7 @@ discard block |
||
| 1591 | 1755 | // recurrences need to be expanded |
| 1592 | 1756 | if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
| 1593 | 1757 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
| 1594 | - ) |
|
| 1595 | - { |
|
| 1758 | + ) { |
|
| 1596 | 1759 | $set_recurrences = true; |
| 1597 | 1760 | $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
| 1598 | 1761 | } |
@@ -1739,12 +1902,18 @@ discard block |
||
| 1739 | 1902 | { |
| 1740 | 1903 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
| 1741 | 1904 | |
| 1742 | - if (!(int) $cal_id) return false; |
|
| 1905 | + if (!(int) $cal_id) |
|
| 1906 | + { |
|
| 1907 | + return false; |
|
| 1908 | + } |
|
| 1743 | 1909 | |
| 1744 | 1910 | if (!$old_start) |
| 1745 | 1911 | { |
| 1746 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1912 | + if ($change_since !== false) |
|
| 1913 | + { |
|
| 1914 | + $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1747 | 1915 | array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
| 1916 | + } |
|
| 1748 | 1917 | // if no recurrence found, create one with the new dates |
| 1749 | 1918 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
| 1750 | 1919 | { |
@@ -1846,7 +2015,10 @@ discard block |
||
| 1846 | 2015 | $user_type = $uid[0]; |
| 1847 | 2016 | $email = substr($uid, 1); |
| 1848 | 2017 | $matches = null; |
| 1849 | - if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1]; |
|
| 2018 | + if (preg_match('/<([^<>]+)>$/', $email, $matches)) |
|
| 2019 | + { |
|
| 2020 | + $email = $matches[1]; |
|
| 2021 | + } |
|
| 1850 | 2022 | $user_id = md5(trim(strtolower($email))); |
| 1851 | 2023 | } |
| 1852 | 2024 | else |
@@ -1866,8 +2038,14 @@ discard block |
||
| 1866 | 2038 | */ |
| 1867 | 2039 | static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
| 1868 | 2040 | { |
| 1869 | - if ((int)$quantity > 1) $status .= (int)$quantity; |
|
| 1870 | - if ($role != 'REQ-PARTICIPANT') $status .= $role; |
|
| 2041 | + if ((int)$quantity > 1) |
|
| 2042 | + { |
|
| 2043 | + $status .= (int)$quantity; |
|
| 2044 | + } |
|
| 2045 | + if ($role != 'REQ-PARTICIPANT') |
|
| 2046 | + { |
|
| 2047 | + $status .= $role; |
|
| 2048 | + } |
|
| 1871 | 2049 | |
| 1872 | 2050 | return $status; |
| 1873 | 2051 | } |
@@ -1888,8 +2066,14 @@ discard block |
||
| 1888 | 2066 | $matches = null; |
| 1889 | 2067 | if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
| 1890 | 2068 | { |
| 1891 | - if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
|
| 1892 | - if ($matches[2]) $role = $matches[2]; |
|
| 2069 | + if ((int)$matches[1] > 0) |
|
| 2070 | + { |
|
| 2071 | + $quantity = (int)$matches[1]; |
|
| 2072 | + } |
|
| 2073 | + if ($matches[2]) |
|
| 2074 | + { |
|
| 2075 | + $role = $matches[2]; |
|
| 2076 | + } |
|
| 1893 | 2077 | $status = $status[0]; |
| 1894 | 2078 | } |
| 1895 | 2079 | elseif ($status === true) |
@@ -2000,9 +2184,13 @@ discard block |
||
| 2000 | 2184 | } |
| 2001 | 2185 | } |
| 2002 | 2186 | |
| 2003 | - if (count($participants)) // participants which need to be added |
|
| 2187 | + if (count($participants)) |
|
| 2188 | + { |
|
| 2189 | + // participants which need to be added |
|
| 2004 | 2190 | { |
| 2005 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2191 | + if (!count($recurrences)) $recurrences[] = 0; |
|
| 2192 | + } |
|
| 2193 | + // insert the default recurrence |
|
| 2006 | 2194 | |
| 2007 | 2195 | $delete_deleted = array(); |
| 2008 | 2196 | |
@@ -2074,7 +2262,10 @@ discard block |
||
| 2074 | 2262 | return false; |
| 2075 | 2263 | } |
| 2076 | 2264 | |
| 2077 | - if (is_numeric($status)) $status = $status_code_short[$status]; |
|
| 2265 | + if (is_numeric($status)) |
|
| 2266 | + { |
|
| 2267 | + $status = $status_code_short[$status]; |
|
| 2268 | + } |
|
| 2078 | 2269 | |
| 2079 | 2270 | $uid = self::combine_user($user_type, $user_id); |
| 2080 | 2271 | $user_id_md5 = null; |
@@ -2094,16 +2285,25 @@ discard block |
||
| 2094 | 2285 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')'; |
| 2095 | 2286 | } |
| 2096 | 2287 | |
| 2097 | - if ($status == 'G') // remove group invitations, as we dont store them in the db |
|
| 2288 | + if ($status == 'G') |
|
| 2289 | + { |
|
| 2290 | + // remove group invitations, as we dont store them in the db |
|
| 2098 | 2291 | { |
| 2099 | 2292 | $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
| 2293 | + } |
|
| 2100 | 2294 | $ret = $this->db->affected_rows(); |
| 2101 | 2295 | } |
| 2102 | 2296 | else |
| 2103 | 2297 | { |
| 2104 | 2298 | $set = array('cal_status' => $status); |
| 2105 | - if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2106 | - if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
|
| 2299 | + if ($user_type == 'e' || $attendee) |
|
| 2300 | + { |
|
| 2301 | + $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
|
| 2302 | + } |
|
| 2303 | + if (!is_null($role) && $role != 'REQ-PARTICIPANT') |
|
| 2304 | + { |
|
| 2305 | + $set['cal_role'] = $role; |
|
| 2306 | + } |
|
| 2107 | 2307 | $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
| 2108 | 2308 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2109 | 2309 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
@@ -2136,7 +2336,10 @@ discard block |
||
| 2136 | 2336 | { |
| 2137 | 2337 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
| 2138 | 2338 | $update = array('cal_end' => $end); |
| 2139 | - if (isset($exception)) $update['recur_exception'] = $exception; |
|
| 2339 | + if (isset($exception)) |
|
| 2340 | + { |
|
| 2341 | + $update['recur_exception'] = $exception; |
|
| 2342 | + } |
|
| 2140 | 2343 | |
| 2141 | 2344 | $this->db->insert($this->dates_table, $update, array( |
| 2142 | 2345 | 'cal_id' => $cal_id, |
@@ -2151,7 +2354,11 @@ discard block |
||
| 2151 | 2354 | { |
| 2152 | 2355 | foreach($participants as $uid => $status) |
| 2153 | 2356 | { |
| 2154 | - if ($status == 'G') continue; // dont save group-invitations |
|
| 2357 | + if ($status == 'G') |
|
| 2358 | + { |
|
| 2359 | + continue; |
|
| 2360 | + } |
|
| 2361 | + // dont save group-invitations |
|
| 2155 | 2362 | |
| 2156 | 2363 | $type = ''; |
| 2157 | 2364 | $id = null; |
@@ -2380,7 +2587,10 @@ discard block |
||
| 2380 | 2587 | } |
| 2381 | 2588 | $alarm['cal_id'] = $cal_id; // we need the back-reference |
| 2382 | 2589 | // add an alarm uid, if none is given |
| 2383 | - if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2590 | + if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) |
|
| 2591 | + { |
|
| 2592 | + $alarm['uid'] = (string)new Horde_Support_Uuid; |
|
| 2593 | + } |
|
| 2384 | 2594 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
| 2385 | 2595 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
| 2386 | 2596 | if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner'])) |
@@ -2389,10 +2599,16 @@ discard block |
||
| 2389 | 2599 | } |
| 2390 | 2600 | |
| 2391 | 2601 | // update the modification information of the related event |
| 2392 | - if ($update_modified) $this->updateModified($cal_id, true); |
|
| 2602 | + if ($update_modified) |
|
| 2603 | + { |
|
| 2604 | + $this->updateModified($cal_id, true); |
|
| 2605 | + } |
|
| 2393 | 2606 | |
| 2394 | 2607 | // update cache, if used |
| 2395 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2608 | + if (isset(self::$alarm_cache)) |
|
| 2609 | + { |
|
| 2610 | + $this->read_alarms($cal_id, true); |
|
| 2611 | + } |
|
| 2396 | 2612 | |
| 2397 | 2613 | return $id; |
| 2398 | 2614 | } |
@@ -2415,7 +2631,10 @@ discard block |
||
| 2415 | 2631 | $this->async->cancel_timer($id); |
| 2416 | 2632 | } |
| 2417 | 2633 | // update cache, if used |
| 2418 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false); |
|
| 2634 | + if (isset(self::$alarm_cache)) |
|
| 2635 | + { |
|
| 2636 | + $this->read_alarms($cal_id, false); |
|
| 2637 | + } |
|
| 2419 | 2638 | } |
| 2420 | 2639 | return count($alarms); |
| 2421 | 2640 | } |
@@ -2438,7 +2657,10 @@ discard block |
||
| 2438 | 2657 | $ret = $this->async->cancel_timer($id); |
| 2439 | 2658 | |
| 2440 | 2659 | // update cache, if used |
| 2441 | - if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true); |
|
| 2660 | + if (isset(self::$alarm_cache)) |
|
| 2661 | + { |
|
| 2662 | + $this->read_alarms($cal_id, true); |
|
| 2663 | + } |
|
| 2442 | 2664 | |
| 2443 | 2665 | return $ret; |
| 2444 | 2666 | } |
@@ -2462,11 +2684,14 @@ discard block |
||
| 2462 | 2684 | $user_id = null; |
| 2463 | 2685 | self::split_user($old_user,$user_type,$user_id); |
| 2464 | 2686 | |
| 2465 | - if ($user_type == 'u') // only accounts can be owners of events |
|
| 2687 | + if ($user_type == 'u') |
|
| 2688 | + { |
|
| 2689 | + // only accounts can be owners of events |
|
| 2466 | 2690 | { |
| 2467 | 2691 | foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
| 2468 | 2692 | { |
| 2469 | 2693 | $this->delete($row['cal_id']); |
| 2694 | + } |
|
| 2470 | 2695 | } |
| 2471 | 2696 | } |
| 2472 | 2697 | $this->db->delete($this->user_table,array( |
@@ -2494,11 +2719,14 @@ discard block |
||
| 2494 | 2719 | { |
| 2495 | 2720 | $ids[] = $row['cal_id']; |
| 2496 | 2721 | } |
| 2497 | - if ($ids) $this->db->delete($this->user_table,array( |
|
| 2722 | + if ($ids) |
|
| 2723 | + { |
|
| 2724 | + $this->db->delete($this->user_table,array( |
|
| 2498 | 2725 | 'cal_user_type' => 'u', |
| 2499 | 2726 | 'cal_user_id' => $old_user, |
| 2500 | 2727 | 'cal_id' => $ids, |
| 2501 | 2728 | ),__LINE__,__FILE__,'calendar'); |
| 2729 | + } |
|
| 2502 | 2730 | // now change participant in the rest to contain new user instead of old user |
| 2503 | 2731 | $this->db->update($this->user_table,array( |
| 2504 | 2732 | 'cal_user_id' => $new_user, |
@@ -2523,8 +2751,14 @@ discard block |
||
| 2523 | 2751 | { |
| 2524 | 2752 | $participant_status = array(); |
| 2525 | 2753 | $where = array('cal_id' => $cal_id); |
| 2526 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2527 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2754 | + if ($start != 0 && $end == 0) |
|
| 2755 | + { |
|
| 2756 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2757 | + } |
|
| 2758 | + if ($start == 0 && $end != 0) |
|
| 2759 | + { |
|
| 2760 | + $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2761 | + } |
|
| 2528 | 2762 | if ($start != 0 && $end != 0) |
| 2529 | 2763 | { |
| 2530 | 2764 | $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2535,7 +2769,10 @@ discard block |
||
| 2535 | 2769 | // inititalize the array |
| 2536 | 2770 | $participant_status[$row['cal_recur_date']] = null; |
| 2537 | 2771 | } |
| 2538 | - if (is_null($uid)) return $participant_status; |
|
| 2772 | + if (is_null($uid)) |
|
| 2773 | + { |
|
| 2774 | + return $participant_status; |
|
| 2775 | + } |
|
| 2539 | 2776 | $user_type = $user_id = null; |
| 2540 | 2777 | self::split_user($uid, $user_type, $user_id, true); |
| 2541 | 2778 | |
@@ -2544,8 +2781,14 @@ discard block |
||
| 2544 | 2781 | 'cal_user_type' => $user_type ? $user_type : 'u', |
| 2545 | 2782 | 'cal_user_id' => $user_id, |
| 2546 | 2783 | ); |
| 2547 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2548 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2784 | + if ($start != 0 && $end == 0) |
|
| 2785 | + { |
|
| 2786 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2787 | + } |
|
| 2788 | + if ($start == 0 && $end != 0) |
|
| 2789 | + { |
|
| 2790 | + $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2791 | + } |
|
| 2549 | 2792 | if ($start != 0 && $end != 0) |
| 2550 | 2793 | { |
| 2551 | 2794 | $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
@@ -2635,17 +2878,26 @@ discard block |
||
| 2635 | 2878 | */ |
| 2636 | 2879 | function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
| 2637 | 2880 | { |
| 2638 | - if (!is_array($event)) return false; |
|
| 2881 | + if (!is_array($event)) |
|
| 2882 | + { |
|
| 2883 | + return false; |
|
| 2884 | + } |
|
| 2639 | 2885 | $cal_id = (int) $event['id']; |
| 2640 | 2886 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2641 | 2887 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
| 2642 | - if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
|
| 2888 | + if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) |
|
| 2889 | + { |
|
| 2890 | + return false; |
|
| 2891 | + } |
|
| 2643 | 2892 | |
| 2644 | 2893 | $days = array(); |
| 2645 | 2894 | |
| 2646 | 2895 | $expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']); |
| 2647 | 2896 | |
| 2648 | - if ($filter == 'tz_only' && !$expand_all) return $days; |
|
| 2897 | + if ($filter == 'tz_only' && !$expand_all) |
|
| 2898 | + { |
|
| 2899 | + return $days; |
|
| 2900 | + } |
|
| 2649 | 2901 | |
| 2650 | 2902 | $remote = in_array($filter, array('tz_rrule', 'rrule')); |
| 2651 | 2903 | |
@@ -2688,7 +2940,10 @@ discard block |
||
| 2688 | 2940 | $remote_rrule->next_no_exception(); |
| 2689 | 2941 | } |
| 2690 | 2942 | $egw_rrule->next_no_exception(); |
| 2691 | - if (!$egw_rrule->valid()) return $days; |
|
| 2943 | + if (!$egw_rrule->valid()) |
|
| 2944 | + { |
|
| 2945 | + return $days; |
|
| 2946 | + } |
|
| 2692 | 2947 | } |
| 2693 | 2948 | $day = $egw_rrule->current(); |
| 2694 | 2949 | $locts = (int)Api\DateTime::to($day,'server'); |
@@ -2842,7 +3097,11 @@ discard block |
||
| 2842 | 3097 | } |
| 2843 | 3098 | } |
| 2844 | 3099 | |
| 2845 | - if (empty($participants)) return false; // occurrence does not exist at all yet |
|
| 3100 | + if (empty($participants)) |
|
| 3101 | + { |
|
| 3102 | + return false; |
|
| 3103 | + } |
|
| 3104 | + // occurrence does not exist at all yet |
|
| 2846 | 3105 | |
| 2847 | 3106 | foreach ($recurrence_zero as $uid => $status) |
| 2848 | 3107 | { |
@@ -2899,7 +3158,9 @@ discard block |
||
| 2899 | 3158 | } |
| 2900 | 3159 | if (!isset($participants[$uid]) |
| 2901 | 3160 | || $participants[$uid] != $status) |
| 2902 | - return true; |
|
| 3161 | + { |
|
| 3162 | + return true; |
|
| 3163 | + } |
|
| 2903 | 3164 | unset($participants[$uid]); |
| 2904 | 3165 | } |
| 2905 | 3166 | return (!empty($participants)); |
@@ -2913,7 +3174,10 @@ discard block |
||
| 2913 | 3174 | */ |
| 2914 | 3175 | function isWholeDay($event) |
| 2915 | 3176 | { |
| 2916 | - if (!isset($event['start']) || !isset($event['end'])) return false; |
|
| 3177 | + if (!isset($event['start']) || !isset($event['end'])) |
|
| 3178 | + { |
|
| 3179 | + return false; |
|
| 3180 | + } |
|
| 2917 | 3181 | |
| 2918 | 3182 | if (empty($event['tzid'])) |
| 2919 | 3183 | { |
@@ -2975,8 +3239,14 @@ discard block |
||
| 2975 | 3239 | */ |
| 2976 | 3240 | function updateModified($id, $update_master=false, $time=null, $modifier=null) |
| 2977 | 3241 | { |
| 2978 | - if (is_null($time) || !$time) $time = time(); |
|
| 2979 | - if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3242 | + if (is_null($time) || !$time) |
|
| 3243 | + { |
|
| 3244 | + $time = time(); |
|
| 3245 | + } |
|
| 3246 | + if (is_null($modifier)) |
|
| 3247 | + { |
|
| 3248 | + $modifier = $GLOBALS['egw_info']['user']['account_id']; |
|
| 3249 | + } |
|
| 2980 | 3250 | |
| 2981 | 3251 | $this->db->update($this->cal_table, |
| 2982 | 3252 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |
@@ -19,40 +19,40 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * some necessary defines used by the calendar |
| 21 | 21 | */ |
| 22 | -if(!extension_loaded('mcal')) |
|
| 22 | +if (!extension_loaded('mcal')) |
|
| 23 | 23 | { |
| 24 | - define('MCAL_RECUR_NONE',0); |
|
| 25 | - define('MCAL_RECUR_DAILY',1); |
|
| 26 | - define('MCAL_RECUR_WEEKLY',2); |
|
| 27 | - define('MCAL_RECUR_MONTHLY_MDAY',3); |
|
| 28 | - define('MCAL_RECUR_MONTHLY_WDAY',4); |
|
| 29 | - define('MCAL_RECUR_YEARLY',5); |
|
| 30 | - define('MCAL_RECUR_SECONDLY',6); |
|
| 31 | - define('MCAL_RECUR_MINUTELY',7); |
|
| 32 | - define('MCAL_RECUR_HOURLY',8); |
|
| 33 | - |
|
| 34 | - define('MCAL_M_SUNDAY',1); |
|
| 35 | - define('MCAL_M_MONDAY',2); |
|
| 36 | - define('MCAL_M_TUESDAY',4); |
|
| 37 | - define('MCAL_M_WEDNESDAY',8); |
|
| 38 | - define('MCAL_M_THURSDAY',16); |
|
| 39 | - define('MCAL_M_FRIDAY',32); |
|
| 40 | - define('MCAL_M_SATURDAY',64); |
|
| 41 | - |
|
| 42 | - define('MCAL_M_WEEKDAYS',62); |
|
| 43 | - define('MCAL_M_WEEKEND',65); |
|
| 44 | - define('MCAL_M_ALLDAYS',127); |
|
| 24 | + define('MCAL_RECUR_NONE', 0); |
|
| 25 | + define('MCAL_RECUR_DAILY', 1); |
|
| 26 | + define('MCAL_RECUR_WEEKLY', 2); |
|
| 27 | + define('MCAL_RECUR_MONTHLY_MDAY', 3); |
|
| 28 | + define('MCAL_RECUR_MONTHLY_WDAY', 4); |
|
| 29 | + define('MCAL_RECUR_YEARLY', 5); |
|
| 30 | + define('MCAL_RECUR_SECONDLY', 6); |
|
| 31 | + define('MCAL_RECUR_MINUTELY', 7); |
|
| 32 | + define('MCAL_RECUR_HOURLY', 8); |
|
| 33 | + |
|
| 34 | + define('MCAL_M_SUNDAY', 1); |
|
| 35 | + define('MCAL_M_MONDAY', 2); |
|
| 36 | + define('MCAL_M_TUESDAY', 4); |
|
| 37 | + define('MCAL_M_WEDNESDAY', 8); |
|
| 38 | + define('MCAL_M_THURSDAY', 16); |
|
| 39 | + define('MCAL_M_FRIDAY', 32); |
|
| 40 | + define('MCAL_M_SATURDAY', 64); |
|
| 41 | + |
|
| 42 | + define('MCAL_M_WEEKDAYS', 62); |
|
| 43 | + define('MCAL_M_WEEKEND', 65); |
|
| 44 | + define('MCAL_M_ALLDAYS', 127); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -define('REJECTED',0); |
|
| 48 | -define('NO_RESPONSE',1); |
|
| 49 | -define('TENTATIVE',2); |
|
| 50 | -define('ACCEPTED',3); |
|
| 51 | -define('DELEGATED',4); |
|
| 47 | +define('REJECTED', 0); |
|
| 48 | +define('NO_RESPONSE', 1); |
|
| 49 | +define('TENTATIVE', 2); |
|
| 50 | +define('ACCEPTED', 3); |
|
| 51 | +define('DELEGATED', 4); |
|
| 52 | 52 | |
| 53 | -define('HOUR_s',60*60); |
|
| 54 | -define('DAY_s',24*HOUR_s); |
|
| 55 | -define('WEEK_s',7*DAY_s); |
|
| 53 | +define('HOUR_s', 60 * 60); |
|
| 54 | +define('DAY_s', 24 * HOUR_s); |
|
| 55 | +define('WEEK_s', 7 * DAY_s); |
|
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Class to store all calendar data (storage object) |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * name of the main calendar table and prefix for all other calendar tables |
| 101 | 101 | */ |
| 102 | 102 | var $cal_table = 'egw_cal'; |
| 103 | - var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables; |
|
| 103 | + var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables; |
|
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * reference to global db-object |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $this->db = $GLOBALS['egw']->db; |
| 137 | 137 | |
| 138 | 138 | $this->all_tables = array($this->cal_table); |
| 139 | - foreach(array('extra','repeats','user','dates') as $name) |
|
| 139 | + foreach (array('extra', 'repeats', 'user', 'dates') as $name) |
|
| 140 | 140 | { |
| 141 | 141 | $vname = $name.'_table'; |
| 142 | 142 | $this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name; |
@@ -152,11 +152,11 @@ discard block |
||
| 152 | 152 | * @param boolean $deleted =false |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - protected function cal_range_view($start, $end, array $_where=null, $deleted=false) |
|
| 155 | + protected function cal_range_view($start, $end, array $_where = null, $deleted = false) |
|
| 156 | 156 | { |
| 157 | 157 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start) // using view without start-date is slower! |
| 158 | 158 | { |
| 159 | - return $this->cal_table; // no need / use for a view |
|
| 159 | + return $this->cal_table; // no need / use for a view |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | $where = array(); |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | * @param boolean $deleted =false |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | - protected function dates_range_view($start, $end, array $_where=null, $deleted=false) |
|
| 185 | + protected function dates_range_view($start, $end, array $_where = null, $deleted = false) |
|
| 186 | 186 | { |
| 187 | 187 | if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end) // using view without start- AND end-date is slower! |
| 188 | 188 | { |
| 189 | - return $this->dates_table; // no need / use for a view |
|
| 189 | + return $this->dates_table; // no need / use for a view |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $where = array(); |
@@ -231,14 +231,14 @@ discard block |
||
| 231 | 231 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 232 | 232 | * @return array of events |
| 233 | 233 | */ |
| 234 | - function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
| 234 | + function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
| 235 | 235 | { |
| 236 | - error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
| 236 | + error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
|
| 237 | 237 | $start_time = microtime(true); |
| 238 | 238 | // not everything is supported by now |
| 239 | 239 | if (!$start || !$end || is_string($params['query']) || |
| 240 | 240 | //in_array($filter,array('owner','deleted')) || |
| 241 | - $params['enum_recuring']===false) |
|
| 241 | + $params['enum_recuring'] === false) |
|
| 242 | 242 | { |
| 243 | 243 | throw new Api\Exception\AssertionFailed("Unsupported value for parameters!"); |
| 244 | 244 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | { |
| 266 | 266 | // fix $users to also prefix system users and groups (with 'u') |
| 267 | 267 | if (!is_array($users)) $users = $users ? (array)$users : array(); |
| 268 | - foreach($users as &$uid) |
|
| 268 | + foreach ($users as &$uid) |
|
| 269 | 269 | { |
| 270 | 270 | $user_type = $user_id = null; |
| 271 | 271 | self::split_user($uid, $user_type, $user_id, true); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | |
| 287 | 287 | if ($params['order']) // only order if requested |
| 288 | 288 | { |
| 289 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 289 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 290 | 290 | $sql .= "\nORDER BY ".$params['order']; |
| 291 | 291 | } |
| 292 | 292 | |
@@ -295,8 +295,8 @@ discard block |
||
| 295 | 295 | $offset = 0; |
| 296 | 296 | $num_rows = -1; |
| 297 | 297 | } |
| 298 | - $events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
| 299 | - error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3)); |
|
| 298 | + $events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows)); |
|
| 299 | + error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3)); |
|
| 300 | 300 | return $events; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one |
| 310 | 310 | * @return array|boolean array with cal_id => event array pairs or false if entry not found |
| 311 | 311 | */ |
| 312 | - function read($ids,$recur_date=0) |
|
| 312 | + function read($ids, $recur_date = 0) |
|
| 313 | 313 | { |
| 314 | 314 | //error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace()); |
| 315 | 315 | $cols = self::get_columns('calendar', $this->cal_table); |
| 316 | 316 | $cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
| 317 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols); |
|
| 317 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols); |
|
| 318 | 318 | $join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id"; |
| 319 | 319 | |
| 320 | 320 | $where = array(); |
@@ -324,23 +324,23 @@ discard block |
||
| 324 | 324 | $where['cal_uid'] = $ids; |
| 325 | 325 | $where['cal_reference'] = 0; |
| 326 | 326 | } |
| 327 | - elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids)) // one or more cal_id's |
|
| 327 | + elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids)) // one or more cal_id's |
|
| 328 | 328 | { |
| 329 | 329 | $where['cal_id'] = $ids; |
| 330 | 330 | } |
| 331 | 331 | else // array with column => value pairs |
| 332 | 332 | { |
| 333 | 333 | $where = $ids; |
| 334 | - unset($ids); // otherwise users get not read! |
|
| 334 | + unset($ids); // otherwise users get not read! |
|
| 335 | 335 | } |
| 336 | 336 | if (isset($where['cal_id'])) // prevent non-unique column-name cal_id |
| 337 | 337 | { |
| 338 | - $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array( |
|
| 338 | + $where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array( |
|
| 339 | 339 | 'cal_id' => $where['cal_id'], |
| 340 | 340 | )); |
| 341 | 341 | unset($where['cal_id']); |
| 342 | 342 | } |
| 343 | - if ((int) $recur_date) |
|
| 343 | + if ((int)$recur_date) |
|
| 344 | 344 | { |
| 345 | 345 | $where[] = 'cal_start >= '.(int)$recur_date; |
| 346 | 346 | $group_by = 'GROUP BY '.$cols; |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | $cols .= ',range_end-1 AS recur_enddate'; |
| 355 | 355 | |
| 356 | - $events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
| 356 | + $events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date); |
|
| 357 | 357 | |
| 358 | 358 | return $events ? $events : false; |
| 359 | 359 | } |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * @param int $recur_date =0 |
| 366 | 366 | * @return array |
| 367 | 367 | */ |
| 368 | - protected function &get_events($rs, $recur_date=0) |
|
| 368 | + protected function &get_events($rs, $recur_date = 0) |
|
| 369 | 369 | { |
| 370 | 370 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 371 | 371 | { |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $events = array(); |
| 380 | - foreach($rs as $row) |
|
| 380 | + foreach ($rs as $row) |
|
| 381 | 381 | { |
| 382 | 382 | if (!$row['recur_type']) |
| 383 | 383 | { |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | unset($row['recur_enddate']); |
| 386 | 386 | } |
| 387 | 387 | $row['recur_exception'] = $row['alarm'] = array(); |
| 388 | - $events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_'); |
|
| 388 | + $events[$row['cal_id']] = Api\Db::strip_array_keys($row, 'cal_'); |
|
| 389 | 389 | } |
| 390 | 390 | if (!$events) return $events; |
| 391 | 391 | |
@@ -397,26 +397,26 @@ discard block |
||
| 397 | 397 | if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length) |
| 398 | 398 | { |
| 399 | 399 | // event (without uid), not strong enough uid => create new uid |
| 400 | - $event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']); |
|
| 400 | + $event['uid'] = Api\CalDAV::generate_uid('calendar', $event['id']); |
|
| 401 | 401 | $this->db->update($this->cal_table, array('cal_uid' => $event['uid']), |
| 402 | - array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar'); |
|
| 402 | + array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar'); |
|
| 403 | 403 | } |
| 404 | 404 | if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE) |
| 405 | 405 | { |
| 406 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 406 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 407 | 407 | 'cal_id' => $ids, |
| 408 | 408 | 'recur_exception' => true, |
| 409 | 409 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
| 410 | 410 | { |
| 411 | 411 | $events[$row['cal_id']]['recur_exception'][] = $row['cal_start']; |
| 412 | 412 | } |
| 413 | - break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
| 413 | + break; // as above select read all exceptions (and I dont think too short uid problem still exists) |
|
| 414 | 414 | } |
| 415 | 415 | // make sure we fetch only real exceptions (deleted occurrences of a series should not show up) |
| 416 | - if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
| 416 | + if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE)) |
|
| 417 | 417 | { |
| 418 | 418 | //_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']); |
| 419 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 419 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 420 | 420 | 'cal_id' => $event['id'], |
| 421 | 421 | 'cal_start' => $event['start'], |
| 422 | 422 | 'recur_exception' => true, |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | 'cal_deleted' => NULL |
| 433 | 433 | ), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn()) |
| 434 | 434 | { |
| 435 | - $e = $this->read($event['id'],$event['start']+1); |
|
| 435 | + $e = $this->read($event['id'], $event['start'] + 1); |
|
| 436 | 436 | $event = $e[$event['id']]; |
| 437 | 437 | break; |
| 438 | 438 | } |
@@ -454,21 +454,21 @@ discard block |
||
| 454 | 454 | if ($recur_date) |
| 455 | 455 | { |
| 456 | 456 | // also remember recur_date, maybe we need it later, duno now |
| 457 | - $recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']); |
|
| 457 | + $recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']); |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0 |
| 462 | 462 | // sorting by cal_recur_date ASC makes sure recurence status always overwrites series status |
| 463 | - foreach($this->db->select($this->user_table,'*',array( |
|
| 463 | + foreach ($this->db->select($this->user_table, '*', array( |
|
| 464 | 464 | 'cal_id' => $ids, |
| 465 | 465 | 'cal_recur_date' => $recur_date, |
| 466 | 466 | "cal_status NOT IN ('X','E')", |
| 467 | - ),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row) // DESC puts users before resources and contacts |
|
| 467 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row) // DESC puts users before resources and contacts |
|
| 468 | 468 | { |
| 469 | 469 | // combine all participant data in uid and status values |
| 470 | 470 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 471 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 471 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 472 | 472 | |
| 473 | 473 | $events[$row['cal_id']]['participants'][$uid] = $status; |
| 474 | 474 | $events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status; |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | // custom fields |
| 480 | - foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 480 | + foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 481 | 481 | { |
| 482 | 482 | $events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value']; |
| 483 | 483 | } |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | // alarms |
| 486 | 486 | if (is_array($ids)) |
| 487 | 487 | { |
| 488 | - foreach($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
| 488 | + foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms) |
|
| 489 | 489 | { |
| 490 | 490 | $events[$cal_id]['alarm'] = $alarms; |
| 491 | 491 | } |
@@ -514,11 +514,11 @@ discard block |
||
| 514 | 514 | * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0) |
| 515 | 515 | * @return int maximum modification timestamp |
| 516 | 516 | */ |
| 517 | - function get_ctag($users, $owner_too=false,$master_only=false) |
|
| 517 | + function get_ctag($users, $owner_too = false, $master_only = false) |
|
| 518 | 518 | { |
| 519 | - static $ctags = array(); // some per-request caching |
|
| 519 | + static $ctags = array(); // some per-request caching |
|
| 520 | 520 | static $last_request = null; |
| 521 | - if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME) |
|
| 521 | + if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME) |
|
| 522 | 522 | { |
| 523 | 523 | $ctags = array(); |
| 524 | 524 | $last_request = time(); |
@@ -527,13 +527,13 @@ discard block |
||
| 527 | 527 | if (isset($ctags[$signature])) return $ctags[$signature]; |
| 528 | 528 | |
| 529 | 529 | $types = array(); |
| 530 | - foreach((array)$users as $uid) |
|
| 530 | + foreach ((array)$users as $uid) |
|
| 531 | 531 | { |
| 532 | 532 | $type = $id = null; |
| 533 | 533 | self::split_user($uid, $type, $id, true); |
| 534 | 534 | $types[$type][] = $id; |
| 535 | 535 | } |
| 536 | - foreach($types as $type => $ids) |
|
| 536 | + foreach ($types as $type => $ids) |
|
| 537 | 537 | { |
| 538 | 538 | $where = array( |
| 539 | 539 | 'cal_user_type' => $type, |
@@ -555,17 +555,17 @@ discard block |
||
| 555 | 555 | if ($owner_too) |
| 556 | 556 | { |
| 557 | 557 | // owner can only by users, no groups or resources |
| 558 | - foreach($users as $key => $user) |
|
| 558 | + foreach ($users as $key => $user) |
|
| 559 | 559 | { |
| 560 | 560 | if (!($user > 0)) unset($users[$key]); |
| 561 | 561 | } |
| 562 | 562 | $where = $this->db->expression($this->user_table, '(', $where, ' OR '). |
| 563 | 563 | $this->db->expression($this->cal_table, array( |
| 564 | 564 | 'cal_owner' => $users, |
| 565 | - ),')'); |
|
| 565 | + ), ')'); |
|
| 566 | 566 | } |
| 567 | - return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)', |
|
| 568 | - $where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
| 567 | + return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)', |
|
| 568 | + $where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn(); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | /** |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query |
| 578 | 578 | * @return Iterator as Api\Db::select |
| 579 | 579 | */ |
| 580 | - function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
| 580 | + function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified') |
|
| 581 | 581 | { |
| 582 | 582 | if (!is_array($cols)) $cols = explode(',', $cols); |
| 583 | 583 | |
@@ -603,12 +603,12 @@ discard block |
||
| 603 | 603 | if ($cat_id) |
| 604 | 604 | { |
| 605 | 605 | $cats = $GLOBALS['egw']->categories->return_all_children($cat_id); |
| 606 | - array_walk($cats,create_function('&$val,$key','$val = (int) $val;')); |
|
| 607 | - if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0]; |
|
| 608 | - $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
| 609 | - foreach($cats as $cat) |
|
| 606 | + array_walk($cats, create_function('&$val,$key', '$val = (int) $val;')); |
|
| 607 | + if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0]; |
|
| 608 | + $sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id)); |
|
| 609 | + foreach ($cats as $cat) |
|
| 610 | 610 | { |
| 611 | - $sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
| 611 | + $sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%'); |
|
| 612 | 612 | } |
| 613 | 613 | $sql .= ') '; |
| 614 | 614 | } |
@@ -623,13 +623,13 @@ discard block |
||
| 623 | 623 | * @param array $where =array() array to add filters too |
| 624 | 624 | * @return array |
| 625 | 625 | */ |
| 626 | - protected function status_filter($filter, $enum_recuring=true, array $where=array()) |
|
| 626 | + protected function status_filter($filter, $enum_recuring = true, array $where = array()) |
|
| 627 | 627 | { |
| 628 | - if($filter != 'deleted' && $filter != 'everything') |
|
| 628 | + if ($filter != 'deleted' && $filter != 'everything') |
|
| 629 | 629 | { |
| 630 | 630 | $where[] = 'cal_deleted IS NULL'; |
| 631 | 631 | } |
| 632 | - switch($filter) |
|
| 632 | + switch ($filter) |
|
| 633 | 633 | { |
| 634 | 634 | case 'everything': // no filter at all |
| 635 | 635 | break; |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it |
| 704 | 704 | * @return Iterator|array of events |
| 705 | 705 | */ |
| 706 | - function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null) |
|
| 706 | + function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null) |
|
| 707 | 707 | { |
| 708 | 708 | //error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace()); |
| 709 | 709 | |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | { |
| 727 | 727 | $all_cols = self::get_columns('calendar', $this->cal_table); |
| 728 | 728 | $all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); |
| 729 | - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end - 1 AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 729 | + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end - 1 AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; |
|
| 730 | 730 | } |
| 731 | 731 | $where = array(); |
| 732 | 732 | if (is_array($params['query'])) |
@@ -735,26 +735,26 @@ discard block |
||
| 735 | 735 | } |
| 736 | 736 | elseif ($params['query']) |
| 737 | 737 | { |
| 738 | - if(is_numeric($params['query'])) |
|
| 738 | + if (is_numeric($params['query'])) |
|
| 739 | 739 | { |
| 740 | - $where[] = $this->cal_table.'.cal_id = ' . (int)$params['query']; |
|
| 740 | + $where[] = $this->cal_table.'.cal_id = '.(int)$params['query']; |
|
| 741 | 741 | } |
| 742 | 742 | else |
| 743 | 743 | { |
| 744 | - foreach(array('cal_title','cal_description','cal_location') as $col) |
|
| 744 | + foreach (array('cal_title', 'cal_description', 'cal_location') as $col) |
|
| 745 | 745 | { |
| 746 | 746 | $to_or[] = $col.' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%'); |
| 747 | 747 | } |
| 748 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 748 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | // Searching - restrict private to own or private grant |
| 752 | 752 | if (!isset($params['private_grants'])) |
| 753 | 753 | { |
| 754 | 754 | $params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar'); |
| 755 | - $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
| 755 | + $params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user |
|
| 756 | 756 | } |
| 757 | - $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')'; |
|
| 757 | + $private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')'; |
|
| 758 | 758 | $where[] = $private_filter; |
| 759 | 759 | } |
| 760 | 760 | if (!empty($params['sql_filter'])) |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | { |
| 764 | 764 | $where[] = $params['sql_filter']; |
| 765 | 765 | } |
| 766 | - elseif(is_array($params['sql_filter'])) |
|
| 766 | + elseif (is_array($params['sql_filter'])) |
|
| 767 | 767 | { |
| 768 | 768 | $where = array_merge($where, $params['sql_filter']); |
| 769 | 769 | } |
@@ -772,11 +772,11 @@ discard block |
||
| 772 | 772 | if ($users) |
| 773 | 773 | { |
| 774 | 774 | $users_by_type = array(); |
| 775 | - foreach((array)$users as $user) |
|
| 775 | + foreach ((array)$users as $user) |
|
| 776 | 776 | { |
| 777 | 777 | if (is_numeric($user)) |
| 778 | 778 | { |
| 779 | - $users_by_type['u'][] = (int) $user; |
|
| 779 | + $users_by_type['u'][] = (int)$user; |
|
| 780 | 780 | } |
| 781 | 781 | else |
| 782 | 782 | { |
@@ -787,45 +787,45 @@ discard block |
||
| 787 | 787 | } |
| 788 | 788 | $to_or = $user_or = array(); |
| 789 | 789 | $owner_or = null; |
| 790 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
| 791 | - foreach($users_by_type as $type => $ids) |
|
| 790 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
| 791 | + foreach ($users_by_type as $type => $ids) |
|
| 792 | 792 | { |
| 793 | 793 | // when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union |
| 794 | 794 | if ($useUnionQuery) |
| 795 | 795 | { |
| 796 | - $user_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
| 796 | + $user_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
| 797 | 797 | 'cal_user_type' => $type, |
| 798 | - ),' AND '.$this->user_table.'.',array( |
|
| 798 | + ), ' AND '.$this->user_table.'.', array( |
|
| 799 | 799 | 'cal_user_id' => $ids, |
| 800 | 800 | )); |
| 801 | 801 | if ($type == 'u' && $filter == 'owner') |
| 802 | 802 | { |
| 803 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
| 803 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
| 804 | 804 | // only users can be owners, no need to add groups |
| 805 | 805 | $user_ids = array(); |
| 806 | - foreach($ids as $user_id) |
|
| 806 | + foreach ($ids as $user_id) |
|
| 807 | 807 | { |
| 808 | 808 | if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id; |
| 809 | 809 | } |
| 810 | - $owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids)); |
|
| 810 | + $owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids)); |
|
| 811 | 811 | } |
| 812 | 812 | } |
| 813 | 813 | else |
| 814 | 814 | { |
| 815 | - $to_or[] = $this->db->expression($table_def,$this->user_table.'.',array( |
|
| 815 | + $to_or[] = $this->db->expression($table_def, $this->user_table.'.', array( |
|
| 816 | 816 | 'cal_user_type' => $type, |
| 817 | - ),' AND '.$this->user_table.'.',array( |
|
| 817 | + ), ' AND '.$this->user_table.'.', array( |
|
| 818 | 818 | 'cal_user_id' => $ids, |
| 819 | 819 | )); |
| 820 | 820 | if ($type == 'u' && $filter == 'owner') |
| 821 | 821 | { |
| 822 | - $cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table); |
|
| 823 | - $to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids)); |
|
| 822 | + $cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table); |
|
| 823 | + $to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids)); |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | // this is only used, when we cannot use UNIONS |
| 828 | - if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 828 | + if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 829 | 829 | |
| 830 | 830 | $where = $this->status_filter($filter, $params['enum_recuring'], $where); |
| 831 | 831 | } |
@@ -844,15 +844,15 @@ discard block |
||
| 844 | 844 | $where[] = '('.((int)$start).' < range_end OR range_end IS NULL)'; |
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | - if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 847 | + if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection |
|
| 848 | 848 | |
| 849 | 849 | // if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id! |
| 850 | 850 | if (!$params['enum_recuring']) |
| 851 | 851 | { |
| 852 | 852 | $where[] = "$this->user_table.cal_recur_date=0"; |
| 853 | - $cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols); |
|
| 853 | + $cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols); |
|
| 854 | 854 | // in case cal_start is used in a query, eg. calendar_ical::find_event |
| 855 | - $where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
| 855 | + $where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where); |
|
| 856 | 856 | $params['order'] = str_replace('cal_start', 'range_start', $params['order']); |
| 857 | 857 | if ($end) $where[] = (int)$end.' > range_start'; |
| 858 | 858 | } |
@@ -864,14 +864,13 @@ discard block |
||
| 864 | 864 | " ON $this->cal_table.cal_id=rejected_by_user.cal_id". |
| 865 | 865 | " AND rejected_by_user.cal_user_type='u'". |
| 866 | 866 | " AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user). |
| 867 | - " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : |
|
| 868 | - '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
| 867 | + " AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)'); |
|
| 869 | 868 | $or_required = array( |
| 870 | 869 | 'rejected_by_user.cal_status IS NULL', |
| 871 | 870 | "rejected_by_user.cal_status NOT IN ('R','X')", |
| 872 | 871 | ); |
| 873 | 872 | if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user; |
| 874 | - $where[] = '('.implode(' OR ',$or_required).')'; |
|
| 873 | + $where[] = '('.implode(' OR ', $or_required).')'; |
|
| 875 | 874 | } |
| 876 | 875 | // using a time-range and deleted attribute limited view instead of full table |
| 877 | 876 | $cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted'); |
@@ -883,18 +882,18 @@ discard block |
||
| 883 | 882 | // dates table join only needed to enum recuring events, we use a time-range limited view here too |
| 884 | 883 | if ($params['enum_recuring']) |
| 885 | 884 | { |
| 886 | - $join = "JOIN ".$this->dates_table. // using dates_table direct seems quicker then an other view |
|
| 885 | + $join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view |
|
| 887 | 886 | //$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted'). |
| 888 | 887 | " ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join; |
| 889 | 888 | } |
| 890 | 889 | |
| 891 | 890 | // Check for some special sorting, used by planner views |
| 892 | - if($params['order'] == 'participants , cal_non_blocking DESC') |
|
| 891 | + if ($params['order'] == 'participants , cal_non_blocking DESC') |
|
| 893 | 892 | { |
| 894 | 893 | $order = ($GLOBALS['egw_info']['user']['preferences']['common']['account_display'] == 'lastname' ? 'n_family' : 'n_fileas'); |
| 895 | 894 | $cols .= ",egw_addressbook.{$order}"; |
| 896 | 895 | $join .= "LEFT JOIN egw_addressbook ON ". |
| 897 | - ($this->db->Type == 'pgsql'? "egw_addressbook.account_id::varchar = ":"egw_addressbook.account_id = "). |
|
| 896 | + ($this->db->Type == 'pgsql' ? "egw_addressbook.account_id::varchar = " : "egw_addressbook.account_id = "). |
|
| 898 | 897 | "{$this->user_table}.cal_user_id"; |
| 899 | 898 | $params['order'] = "$order, cal_non_blocking DESC"; |
| 900 | 899 | } |
@@ -927,29 +926,29 @@ discard block |
||
| 927 | 926 | // as replace the OR by construction of a suitable UNION for performance reasons |
| 928 | 927 | if ($owner_or || $user_or) |
| 929 | 928 | { |
| 930 | - foreach($user_or as $user_sql) |
|
| 929 | + foreach ($user_or as $user_sql) |
|
| 931 | 930 | { |
| 932 | 931 | $selects[] = $select; |
| 933 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
| 932 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
| 934 | 933 | if ($params['enum_recuring']) |
| 935 | 934 | { |
| 936 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 935 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 937 | 936 | $selects[] = $select; |
| 938 | - $selects[count($selects)-1]['where'][] = $user_sql; |
|
| 939 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 937 | + $selects[count($selects) - 1]['where'][] = $user_sql; |
|
| 938 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 940 | 939 | } |
| 941 | 940 | } |
| 942 | 941 | // if the query is to be filtered by owner we need to add more selects for the union |
| 943 | 942 | if ($owner_or) |
| 944 | 943 | { |
| 945 | 944 | $selects[] = $select; |
| 946 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
| 945 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
| 947 | 946 | if ($params['enum_recuring']) |
| 948 | 947 | { |
| 949 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 948 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 950 | 949 | $selects[] = $select; |
| 951 | - $selects[count($selects)-1]['where'][] = $owner_or; |
|
| 952 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 950 | + $selects[count($selects) - 1]['where'][] = $owner_or; |
|
| 951 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 953 | 952 | } |
| 954 | 953 | } |
| 955 | 954 | } |
@@ -959,34 +958,34 @@ discard block |
||
| 959 | 958 | $selects[] = $select; |
| 960 | 959 | if ($params['enum_recuring']) |
| 961 | 960 | { |
| 962 | - $selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 961 | + $selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0"; |
|
| 963 | 962 | $selects[] = $select; |
| 964 | - $selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 963 | + $selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start"; |
|
| 965 | 964 | } |
| 966 | 965 | } |
| 967 | 966 | if (is_numeric($offset) && !$params['no_total']) // get the total too |
| 968 | 967 | { |
| 969 | 968 | $save_selects = $selects; |
| 970 | 969 | // we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns) |
| 971 | - foreach(array_keys($selects) as $key) |
|
| 970 | + foreach (array_keys($selects) as $key) |
|
| 972 | 971 | { |
| 973 | 972 | $selects[$key]['cols'] = "$this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date"; |
| 974 | 973 | if (!$params['enum_recuring']) |
| 975 | 974 | { |
| 976 | - $selects[$key]['cols'] = str_replace(array('cal_start','cal_end'), |
|
| 977 | - array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']); |
|
| 975 | + $selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'), |
|
| 976 | + array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']); |
|
| 978 | 977 | } |
| 979 | 978 | } |
| 980 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 979 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 981 | 980 | |
| 982 | - $this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows(); |
|
| 981 | + $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
|
| 983 | 982 | |
| 984 | 983 | // restore original cols / selects |
| 985 | 984 | $selects = $save_selects; unset($save_selects); |
| 986 | 985 | } |
| 987 | - if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 986 | + if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 988 | 987 | |
| 989 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
| 988 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
| 990 | 989 | } |
| 991 | 990 | else // MsSQL oder MySQL 3.23 |
| 992 | 991 | { |
@@ -1009,27 +1008,27 @@ discard block |
||
| 1009 | 1008 | $selects[0]['cols'] = "$this->cal_table.cal_id,cal_start"; |
| 1010 | 1009 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
| 1011 | 1010 | { |
| 1012 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1011 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 1013 | 1012 | } |
| 1014 | 1013 | $this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows(); |
| 1015 | 1014 | $selects = $save_selects; |
| 1016 | 1015 | } |
| 1017 | 1016 | if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union']) |
| 1018 | 1017 | { |
| 1019 | - self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']); |
|
| 1018 | + self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']); |
|
| 1020 | 1019 | } |
| 1021 | - $rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows); |
|
| 1020 | + $rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows); |
|
| 1022 | 1021 | } |
| 1023 | 1022 | //error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql); |
| 1024 | 1023 | |
| 1025 | 1024 | if (isset($params['cols'])) |
| 1026 | 1025 | { |
| 1027 | - return $rs; // if colums are specified we return the recordset / iterator |
|
| 1026 | + return $rs; // if colums are specified we return the recordset / iterator |
|
| 1028 | 1027 | } |
| 1029 | 1028 | // Todo: return $this->get_events($rs); |
| 1030 | 1029 | |
| 1031 | 1030 | $events = $ids = $recur_dates = $recur_ids = array(); |
| 1032 | - foreach($rs as $row) |
|
| 1031 | + foreach ($rs as $row) |
|
| 1033 | 1032 | { |
| 1034 | 1033 | $id = $row['cal_id']; |
| 1035 | 1034 | if (is_numeric($id)) $ids[] = $id; |
@@ -1041,9 +1040,9 @@ discard block |
||
| 1041 | 1040 | } |
| 1042 | 1041 | if ($row['participants']) |
| 1043 | 1042 | { |
| 1044 | - $row['participants'] = explode(',',$row['participants']); |
|
| 1043 | + $row['participants'] = explode(',', $row['participants']); |
|
| 1045 | 1044 | $row['participants'] = array_combine($row['participants'], |
| 1046 | - array_fill(0,count($row['participants']),'')); |
|
| 1045 | + array_fill(0, count($row['participants']), '')); |
|
| 1047 | 1046 | } |
| 1048 | 1047 | else |
| 1049 | 1048 | { |
@@ -1052,9 +1051,9 @@ discard block |
||
| 1052 | 1051 | $row['recur_exception'] = $row['alarm'] = array(); |
| 1053 | 1052 | |
| 1054 | 1053 | // compile a list of recurrences per cal_id |
| 1055 | - if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1054 | + if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id; |
|
| 1056 | 1055 | |
| 1057 | - $events[$id] = Api\Db::strip_array_keys($row,'cal_'); |
|
| 1056 | + $events[$id] = Api\Db::strip_array_keys($row, 'cal_'); |
|
| 1058 | 1057 | } |
| 1059 | 1058 | //_debug_array($events); |
| 1060 | 1059 | if (count($ids)) |
@@ -1064,26 +1063,26 @@ discard block |
||
| 1064 | 1063 | // now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date) |
| 1065 | 1064 | // This will always read the first entry of each recuring event too, we eliminate it later |
| 1066 | 1065 | $recur_dates[] = 0; |
| 1067 | - $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")". |
|
| 1066 | + $utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")". |
|
| 1068 | 1067 | ($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid "; |
| 1069 | 1068 | //$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates "; |
| 1070 | - foreach($this->db->select($utcal_id_view,'*',array( |
|
| 1069 | + foreach ($this->db->select($utcal_id_view, '*', array( |
|
| 1071 | 1070 | //'cal_id' => array_unique($ids), |
| 1072 | 1071 | 'cal_recur_date' => $recur_dates, |
| 1073 | - ),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='', |
|
| 1074 | - $this->db->get_table_definitions('calendar',$this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1072 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', -1, $join = '', |
|
| 1073 | + $this->db->get_table_definitions('calendar', $this->user_table)) as $row) // DESC puts users before resources and contacts |
|
| 1075 | 1074 | { |
| 1076 | 1075 | $id = $row['cal_id']; |
| 1077 | 1076 | if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date']; |
| 1078 | 1077 | |
| 1079 | 1078 | // combine all participant data in uid and status values |
| 1080 | 1079 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1081 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 1080 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 1082 | 1081 | |
| 1083 | 1082 | // set accept/reject/tentative of series for all recurrences |
| 1084 | 1083 | if (!$row['cal_recur_date']) |
| 1085 | 1084 | { |
| 1086 | - foreach((array)$recur_ids[$row['cal_id']] as $i) |
|
| 1085 | + foreach ((array)$recur_ids[$row['cal_id']] as $i) |
|
| 1087 | 1086 | { |
| 1088 | 1087 | if (isset($events[$i]) && !isset($events[$i]['participants'][$uid])) |
| 1089 | 1088 | { |
@@ -1098,16 +1097,16 @@ discard block |
||
| 1098 | 1097 | // query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...) |
| 1099 | 1098 | if (!$params['enum_recuring'] || !$params['daywise']) |
| 1100 | 1099 | { |
| 1101 | - foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 1100 | + foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array( |
|
| 1102 | 1101 | 'cal_id' => $ids, |
| 1103 | 1102 | 'recur_exception' => true, |
| 1104 | 1103 | ), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row) |
| 1105 | 1104 | { |
| 1106 | 1105 | // for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start |
| 1107 | 1106 | // find master, which is first recurrence |
| 1108 | - if (!isset($events[$id=$row['cal_id']])) |
|
| 1107 | + if (!isset($events[$id = $row['cal_id']])) |
|
| 1109 | 1108 | { |
| 1110 | - foreach($events as $id => $event) |
|
| 1109 | + foreach ($events as $id => $event) |
|
| 1111 | 1110 | { |
| 1112 | 1111 | if ($event['id'] == $row['cal_id']) break; |
| 1113 | 1112 | } |
@@ -1120,10 +1119,10 @@ discard block |
||
| 1120 | 1119 | { |
| 1121 | 1120 | $where = array('cal_id' => $ids); |
| 1122 | 1121 | if ($params['cfs']) $where['cal_extra_name'] = $params['cfs']; |
| 1123 | - foreach($this->db->select($this->extra_table,'*',$where, |
|
| 1124 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1122 | + foreach ($this->db->select($this->extra_table, '*', $where, |
|
| 1123 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1125 | 1124 | { |
| 1126 | - foreach((array)$recur_ids[$row['cal_id']] as $id) |
|
| 1125 | + foreach ((array)$recur_ids[$row['cal_id']] as $id) |
|
| 1127 | 1126 | { |
| 1128 | 1127 | if (isset($events[$id])) |
| 1129 | 1128 | { |
@@ -1133,9 +1132,9 @@ discard block |
||
| 1133 | 1132 | } |
| 1134 | 1133 | } |
| 1135 | 1134 | // alarms |
| 1136 | - foreach($this->read_alarms($ids) as $cal_id => $alarms) |
|
| 1135 | + foreach ($this->read_alarms($ids) as $cal_id => $alarms) |
|
| 1137 | 1136 | { |
| 1138 | - foreach($alarms as $id => $alarm) |
|
| 1137 | + foreach ($alarms as $id => $alarm) |
|
| 1139 | 1138 | { |
| 1140 | 1139 | $event_start = $alarm['time'] + $alarm['offset']; |
| 1141 | 1140 | |
@@ -1172,16 +1171,16 @@ discard block |
||
| 1172 | 1171 | * @param $query |
| 1173 | 1172 | * @param $users_raw as passed to calendar_bo::search (no members and memberships added) |
| 1174 | 1173 | */ |
| 1175 | - private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw) |
|
| 1174 | + private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw) |
|
| 1176 | 1175 | { |
| 1177 | - if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) || |
|
| 1178 | - !in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home'))) |
|
| 1176 | + if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) || |
|
| 1177 | + !in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home'))) |
|
| 1179 | 1178 | { |
| 1180 | - return; // disable integration for GroupDAV, SyncML, ... |
|
| 1179 | + return; // disable integration for GroupDAV, SyncML, ... |
|
| 1181 | 1180 | } |
| 1182 | 1181 | self::$integration_data = Api\Hooks::process(array( |
| 1183 | 1182 | 'location' => 'calendar_search_union', |
| 1184 | - 'cols' => $selects[0]['cols'], // cols to return |
|
| 1183 | + 'cols' => $selects[0]['cols'], // cols to return |
|
| 1185 | 1184 | 'start' => $start, |
| 1186 | 1185 | 'end' => $end, |
| 1187 | 1186 | 'users' => $users, |
@@ -1190,12 +1189,12 @@ discard block |
||
| 1190 | 1189 | 'filter'=> $filter, |
| 1191 | 1190 | 'query' => $query, |
| 1192 | 1191 | )); |
| 1193 | - foreach(self::$integration_data as $data) |
|
| 1192 | + foreach (self::$integration_data as $data) |
|
| 1194 | 1193 | { |
| 1195 | 1194 | if (is_array($data['selects'])) |
| 1196 | 1195 | { |
| 1197 | 1196 | //echo $app; _debug_array($data); |
| 1198 | - $selects = array_merge($selects,$data['selects']); |
|
| 1197 | + $selects = array_merge($selects, $data['selects']); |
|
| 1199 | 1198 | } |
| 1200 | 1199 | } |
| 1201 | 1200 | } |
@@ -1220,35 +1219,35 @@ discard block |
||
| 1220 | 1219 | * @param string $required_app ='calendar' |
| 1221 | 1220 | * @return string cols for union query to match ones supplied in $required |
| 1222 | 1221 | */ |
| 1223 | - public static function union_cols(array $app_cols,$required,$required_app='calendar') |
|
| 1222 | + public static function union_cols(array $app_cols, $required, $required_app = 'calendar') |
|
| 1224 | 1223 | { |
| 1225 | 1224 | // remove evtl. used DISTINCT, we currently dont need it |
| 1226 | - if (($distinct = substr($required,0,9) == 'DISTINCT ')) |
|
| 1225 | + if (($distinct = substr($required, 0, 9) == 'DISTINCT ')) |
|
| 1227 | 1226 | { |
| 1228 | - $required = substr($required,9); |
|
| 1227 | + $required = substr($required, 9); |
|
| 1229 | 1228 | } |
| 1230 | 1229 | $return_cols = array(); |
| 1231 | - foreach(is_array($required) ? $required : explode(',',$required) as $cols) |
|
| 1230 | + foreach (is_array($required) ? $required : explode(',', $required) as $cols) |
|
| 1232 | 1231 | { |
| 1233 | 1232 | $matches = null; |
| 1234 | - if (substr($cols,-2) == '.*') |
|
| 1233 | + if (substr($cols, -2) == '.*') |
|
| 1235 | 1234 | { |
| 1236 | - $cols = self::get_columns($required_app,substr($cols,0,-2)); |
|
| 1235 | + $cols = self::get_columns($required_app, substr($cols, 0, -2)); |
|
| 1237 | 1236 | } |
| 1238 | 1237 | // remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)" |
| 1239 | 1238 | elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches)) |
| 1240 | 1239 | { |
| 1241 | 1240 | $cols = $matches[1]; |
| 1242 | 1241 | } |
| 1243 | - elseif (strpos($cols,' AS ') !== false) |
|
| 1242 | + elseif (strpos($cols, ' AS ') !== false) |
|
| 1244 | 1243 | { |
| 1245 | - list(,$cols) = explode(' AS ',$cols); |
|
| 1244 | + list(,$cols) = explode(' AS ', $cols); |
|
| 1246 | 1245 | } |
| 1247 | - foreach((array)$cols as $col) |
|
| 1246 | + foreach ((array)$cols as $col) |
|
| 1248 | 1247 | { |
| 1249 | - if (substr($col,0,7) == 'egw_cal') // remove table name |
|
| 1248 | + if (substr($col, 0, 7) == 'egw_cal') // remove table name |
|
| 1250 | 1249 | { |
| 1251 | - $col = preg_replace('/^egw_cal[a-z_]*\./','',$col); |
|
| 1250 | + $col = preg_replace('/^egw_cal[a-z_]*\./', '', $col); |
|
| 1252 | 1251 | } |
| 1253 | 1252 | if (isset($app_cols[$col])) |
| 1254 | 1253 | { |
@@ -1261,7 +1260,7 @@ discard block |
||
| 1261 | 1260 | } |
| 1262 | 1261 | } |
| 1263 | 1262 | //error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols))); |
| 1264 | - return implode(',',$return_cols); |
|
| 1263 | + return implode(',', $return_cols); |
|
| 1265 | 1264 | } |
| 1266 | 1265 | |
| 1267 | 1266 | /** |
@@ -1271,21 +1270,21 @@ discard block |
||
| 1271 | 1270 | * @param string $table |
| 1272 | 1271 | * @return array of column names |
| 1273 | 1272 | */ |
| 1274 | - static private function get_columns($app,$table) |
|
| 1273 | + static private function get_columns($app, $table) |
|
| 1275 | 1274 | { |
| 1276 | 1275 | if ($table != 'egw_cal') |
| 1277 | 1276 | { |
| 1278 | - $table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table); |
|
| 1277 | + $table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table); |
|
| 1279 | 1278 | $cols = array_keys($table_def['fd']); |
| 1280 | 1279 | } |
| 1281 | 1280 | else |
| 1282 | 1281 | { |
| 1283 | 1282 | // special handling for egw_cal, as old databases have a different column order!!! |
| 1284 | - $cols =& Api\Cache::getSession(__CLASS__,$table); |
|
| 1283 | + $cols = & Api\Cache::getSession(__CLASS__, $table); |
|
| 1285 | 1284 | |
| 1286 | 1285 | if (is_null($cols)) |
| 1287 | 1286 | { |
| 1288 | - $meta = $GLOBALS['egw']->db->metadata($table,true); |
|
| 1287 | + $meta = $GLOBALS['egw']->db->metadata($table, true); |
|
| 1289 | 1288 | $cols = array_keys($meta['meta']); |
| 1290 | 1289 | } |
| 1291 | 1290 | } |
@@ -1338,12 +1337,12 @@ discard block |
||
| 1338 | 1337 | * @param int &$etag etag=null etag to check or null, on return new etag |
| 1339 | 1338 | * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise |
| 1340 | 1339 | */ |
| 1341 | - function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null) |
|
| 1340 | + function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null) |
|
| 1342 | 1341 | { |
| 1343 | 1342 | if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) |
| 1344 | 1343 | { |
| 1345 | 1344 | $minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']; |
| 1346 | - if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1345 | + if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short! |
|
| 1347 | 1346 | } |
| 1348 | 1347 | else |
| 1349 | 1348 | { |
@@ -1354,7 +1353,7 @@ discard block |
||
| 1354 | 1353 | |
| 1355 | 1354 | //error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace()); |
| 1356 | 1355 | |
| 1357 | - $cal_id = (int) $event['id']; |
|
| 1356 | + $cal_id = (int)$event['id']; |
|
| 1358 | 1357 | unset($event['id']); |
| 1359 | 1358 | $set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE; |
| 1360 | 1359 | |
@@ -1365,9 +1364,9 @@ discard block |
||
| 1365 | 1364 | } |
| 1366 | 1365 | |
| 1367 | 1366 | // add colum prefix 'cal_' if there's not already a 'recur_' prefix |
| 1368 | - foreach($event as $col => $val) |
|
| 1367 | + foreach ($event as $col => $val) |
|
| 1369 | 1368 | { |
| 1370 | - if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
| 1369 | + if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name') |
|
| 1371 | 1370 | { |
| 1372 | 1371 | $event['cal_'.$col] = $val; |
| 1373 | 1372 | unset($event[$col]); |
@@ -1377,13 +1376,12 @@ discard block |
||
| 1377 | 1376 | if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start']; |
| 1378 | 1377 | if (isset($event['cal_end'])) |
| 1379 | 1378 | { |
| 1380 | - $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : |
|
| 1381 | - ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
| 1379 | + $event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null); |
|
| 1382 | 1380 | } |
| 1383 | 1381 | // ensure that we find mathing entries later on |
| 1384 | 1382 | if (!is_array($event['cal_category'])) |
| 1385 | 1383 | { |
| 1386 | - $categories = array_unique(explode(',',$event['cal_category'])); |
|
| 1384 | + $categories = array_unique(explode(',', $event['cal_category'])); |
|
| 1387 | 1385 | sort($categories); |
| 1388 | 1386 | } |
| 1389 | 1387 | else |
@@ -1392,7 +1390,7 @@ discard block |
||
| 1392 | 1390 | } |
| 1393 | 1391 | sort($categories, SORT_NUMERIC); |
| 1394 | 1392 | |
| 1395 | - $event['cal_category'] = implode(',',$categories); |
|
| 1393 | + $event['cal_category'] = implode(',', $categories); |
|
| 1396 | 1394 | |
| 1397 | 1395 | // make sure recurring events never reference to an other recurrent event |
| 1398 | 1396 | if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0; |
@@ -1410,18 +1408,18 @@ discard block |
||
| 1410 | 1408 | // read only timezone id, to check if it is changed |
| 1411 | 1409 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1412 | 1410 | { |
| 1413 | - $old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn(); |
|
| 1411 | + $old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn(); |
|
| 1414 | 1412 | } |
| 1415 | 1413 | if (!is_null($etag)) $where['cal_etag'] = $etag; |
| 1416 | 1414 | |
| 1417 | 1415 | unset($event['cal_etag']); |
| 1418 | - $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
| 1416 | + $event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check |
|
| 1419 | 1417 | |
| 1420 | - $this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar'); |
|
| 1418 | + $this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar'); |
|
| 1421 | 1419 | |
| 1422 | 1420 | if (!is_null($etag) && $this->db->affected_rows() < 1) |
| 1423 | 1421 | { |
| 1424 | - return 0; // wrong etag, someone else updated the entry |
|
| 1422 | + return 0; // wrong etag, someone else updated the entry |
|
| 1425 | 1423 | } |
| 1426 | 1424 | if (!is_null($etag)) ++$etag; |
| 1427 | 1425 | } |
@@ -1430,10 +1428,10 @@ discard block |
||
| 1430 | 1428 | // new event |
| 1431 | 1429 | if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id']; |
| 1432 | 1430 | |
| 1433 | - if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1431 | + if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL! |
|
| 1434 | 1432 | |
| 1435 | - $this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar'); |
|
| 1436 | - if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id'))) |
|
| 1433 | + $this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar'); |
|
| 1434 | + if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id'))) |
|
| 1437 | 1435 | { |
| 1438 | 1436 | return false; |
| 1439 | 1437 | } |
@@ -1443,7 +1441,7 @@ discard block |
||
| 1443 | 1441 | // event without uid or not strong enough uid |
| 1444 | 1442 | if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length) |
| 1445 | 1443 | { |
| 1446 | - $update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id); |
|
| 1444 | + $update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar', $cal_id); |
|
| 1447 | 1445 | } |
| 1448 | 1446 | // set caldav_name, if not given by caller |
| 1449 | 1447 | if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>=')) |
@@ -1452,37 +1450,37 @@ discard block |
||
| 1452 | 1450 | } |
| 1453 | 1451 | if ($update) |
| 1454 | 1452 | { |
| 1455 | - $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
| 1453 | + $this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 1456 | 1454 | } |
| 1457 | 1455 | |
| 1458 | 1456 | if ($event['recur_type'] == MCAL_RECUR_NONE) |
| 1459 | 1457 | { |
| 1460 | - $this->db->delete($this->dates_table,array( |
|
| 1458 | + $this->db->delete($this->dates_table, array( |
|
| 1461 | 1459 | 'cal_id' => $cal_id), |
| 1462 | - __LINE__,__FILE__,'calendar'); |
|
| 1460 | + __LINE__, __FILE__, 'calendar'); |
|
| 1463 | 1461 | |
| 1464 | 1462 | // delete all user-records, with recur-date != 0 |
| 1465 | - $this->db->delete($this->user_table,array( |
|
| 1463 | + $this->db->delete($this->user_table, array( |
|
| 1466 | 1464 | 'cal_id' => $cal_id, 'cal_recur_date != 0'), |
| 1467 | - __LINE__,__FILE__,'calendar'); |
|
| 1465 | + __LINE__, __FILE__, 'calendar'); |
|
| 1468 | 1466 | |
| 1469 | - $this->db->delete($this->repeats_table,array( |
|
| 1467 | + $this->db->delete($this->repeats_table, array( |
|
| 1470 | 1468 | 'cal_id' => $cal_id), |
| 1471 | - __LINE__,__FILE__,'calendar'); |
|
| 1469 | + __LINE__, __FILE__, 'calendar'); |
|
| 1472 | 1470 | |
| 1473 | 1471 | // add exception marker to master, so participants added to exceptions *only* get found |
| 1474 | 1472 | if ($event['cal_reference']) |
| 1475 | 1473 | { |
| 1476 | 1474 | $master_participants = array(); |
| 1477 | - foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
| 1475 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array( |
|
| 1478 | 1476 | 'cal_id' => $event['cal_reference'], |
| 1479 | 1477 | 'cal_recur_date' => 0, |
| 1480 | - "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
| 1478 | + "cal_status != 'X'", // deleted need to be replaced with exception marker too |
|
| 1481 | 1479 | ), __LINE__, __FILE__, 'calendar') as $row) |
| 1482 | 1480 | { |
| 1483 | 1481 | $master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1484 | 1482 | } |
| 1485 | - foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
| 1483 | + foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid) |
|
| 1486 | 1484 | { |
| 1487 | 1485 | $user_type = $user_id = null; |
| 1488 | 1486 | self::split_user($uid, $user_type, $user_id, true); |
@@ -1501,10 +1499,10 @@ discard block |
||
| 1501 | 1499 | else // write information about recuring event, if recur_type is present in the array |
| 1502 | 1500 | { |
| 1503 | 1501 | // fetch information about the currently saved (old) event |
| 1504 | - $old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 1505 | - $old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min; |
|
| 1502 | + $old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 1503 | + $old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min; |
|
| 1506 | 1504 | $old_exceptions = array(); |
| 1507 | - foreach($this->db->select($this->dates_table, 'cal_start', array( |
|
| 1505 | + foreach ($this->db->select($this->dates_table, 'cal_start', array( |
|
| 1508 | 1506 | 'cal_id' => $cal_id, |
| 1509 | 1507 | 'recur_exception' => true |
| 1510 | 1508 | ), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row) |
@@ -1523,8 +1521,8 @@ discard block |
||
| 1523 | 1521 | 'cal_recur_date' => 0, |
| 1524 | 1522 | ); |
| 1525 | 1523 | $old_participants = array(); |
| 1526 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
| 1527 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1524 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where, |
|
| 1525 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1528 | 1526 | { |
| 1529 | 1527 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1530 | 1528 | $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
@@ -1534,7 +1532,7 @@ discard block |
||
| 1534 | 1532 | // re-check: did so much recurrence data change that we have to rebuild it from scratch? |
| 1535 | 1533 | if (!$set_recurrences) |
| 1536 | 1534 | { |
| 1537 | - $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) || |
|
| 1535 | + $set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) || |
|
| 1538 | 1536 | $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] || |
| 1539 | 1537 | (int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id; |
| 1540 | 1538 | } |
@@ -1543,22 +1541,22 @@ discard block |
||
| 1543 | 1541 | { |
| 1544 | 1542 | // too much recurrence data has changed, we have to do a rebuild from scratch |
| 1545 | 1543 | // delete all, but the lowest dates record |
| 1546 | - $this->db->delete($this->dates_table,array( |
|
| 1544 | + $this->db->delete($this->dates_table, array( |
|
| 1547 | 1545 | 'cal_id' => $cal_id, |
| 1548 | 1546 | 'cal_start > '.(int)$old_min, |
| 1549 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1547 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1550 | 1548 | |
| 1551 | 1549 | // delete all user-records, with recur-date != 0 |
| 1552 | - $this->db->delete($this->user_table,array( |
|
| 1550 | + $this->db->delete($this->user_table, array( |
|
| 1553 | 1551 | 'cal_id' => $cal_id, |
| 1554 | 1552 | 'cal_recur_date != 0', |
| 1555 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1553 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1556 | 1554 | } |
| 1557 | 1555 | else |
| 1558 | 1556 | { |
| 1559 | 1557 | // we adjust some possibly changed recurrences manually |
| 1560 | 1558 | // deleted exceptions: re-insert recurrences into the user and dates table |
| 1561 | - if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception']))) |
|
| 1559 | + if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception']))) |
|
| 1562 | 1560 | { |
| 1563 | 1561 | if (isset($event['cal_participants'])) |
| 1564 | 1562 | { |
@@ -1569,7 +1567,7 @@ discard block |
||
| 1569 | 1567 | // use old default |
| 1570 | 1568 | $participants = $old_participants; |
| 1571 | 1569 | } |
| 1572 | - foreach($deleted_exceptions as $id => $deleted_exception) |
|
| 1570 | + foreach ($deleted_exceptions as $id => $deleted_exception) |
|
| 1573 | 1571 | { |
| 1574 | 1572 | // rebuild participants for the re-inserted recurrence |
| 1575 | 1573 | $this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants); |
@@ -1577,24 +1575,24 @@ discard block |
||
| 1577 | 1575 | } |
| 1578 | 1576 | |
| 1579 | 1577 | // check if recurrence enddate was adjusted |
| 1580 | - if(isset($event['recur_enddate'])) |
|
| 1578 | + if (isset($event['recur_enddate'])) |
|
| 1581 | 1579 | { |
| 1582 | 1580 | // recurrences need to be truncated |
| 1583 | - if((int)$event['recur_enddate'] > 0 && |
|
| 1581 | + if ((int)$event['recur_enddate'] > 0 && |
|
| 1584 | 1582 | ((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate']) |
| 1585 | 1583 | ) |
| 1586 | 1584 | { |
| 1587 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
| 1588 | - $this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar'); |
|
| 1585 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
| 1586 | + $this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar'); |
|
| 1589 | 1587 | } |
| 1590 | 1588 | |
| 1591 | 1589 | // recurrences need to be expanded |
| 1592 | - if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
| 1590 | + if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0) |
|
| 1593 | 1591 | || ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate']) |
| 1594 | 1592 | ) |
| 1595 | 1593 | { |
| 1596 | 1594 | $set_recurrences = true; |
| 1597 | - $set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s); |
|
| 1595 | + $set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s); |
|
| 1598 | 1596 | } |
| 1599 | 1597 | //error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start"); |
| 1600 | 1598 | } |
@@ -1603,9 +1601,9 @@ discard block |
||
| 1603 | 1601 | if (count($event['recur_exception'])) |
| 1604 | 1602 | { |
| 1605 | 1603 | // added and existing exceptions: delete the execeptions from the user table, it could be the first time |
| 1606 | - $this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar'); |
|
| 1604 | + $this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar'); |
|
| 1607 | 1605 | // update recur_exception flag based on current exceptions |
| 1608 | - $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array( |
|
| 1606 | + $this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array( |
|
| 1609 | 1607 | 'cal_start' => $event['recur_exception'], |
| 1610 | 1608 | )), array( |
| 1611 | 1609 | 'cal_id' => $cal_id, |
@@ -1614,27 +1612,27 @@ discard block |
||
| 1614 | 1612 | } |
| 1615 | 1613 | |
| 1616 | 1614 | // write the repeats table |
| 1617 | - unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
| 1618 | - $this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar'); |
|
| 1615 | + unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table |
|
| 1616 | + $this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 1619 | 1617 | } |
| 1620 | 1618 | // update start- and endtime if present in the event-array, evtl. we need to move all recurrences |
| 1621 | 1619 | if (isset($event['cal_start']) && isset($event['cal_end'])) |
| 1622 | 1620 | { |
| 1623 | - $this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
| 1621 | + $this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration); |
|
| 1624 | 1622 | } |
| 1625 | 1623 | // update participants if present in the event-array |
| 1626 | 1624 | if (isset($event['cal_participants'])) |
| 1627 | 1625 | { |
| 1628 | - $this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since); |
|
| 1626 | + $this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since); |
|
| 1629 | 1627 | } |
| 1630 | 1628 | // Custom fields |
| 1631 | 1629 | Api\Storage\Customfields::handle_files('calendar', $cal_id, $event); |
| 1632 | 1630 | |
| 1633 | - foreach($event as $name => $value) |
|
| 1631 | + foreach ($event as $name => $value) |
|
| 1634 | 1632 | { |
| 1635 | 1633 | if ($name[0] == '#') |
| 1636 | 1634 | { |
| 1637 | - if (is_array($value) && array_key_exists('id',$value)) |
|
| 1635 | + if (is_array($value) && array_key_exists('id', $value)) |
|
| 1638 | 1636 | { |
| 1639 | 1637 | //error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace()); |
| 1640 | 1638 | $value = $value['id']; |
@@ -1642,19 +1640,19 @@ discard block |
||
| 1642 | 1640 | } |
| 1643 | 1641 | if ($value) |
| 1644 | 1642 | { |
| 1645 | - $this->db->insert($this->extra_table,array( |
|
| 1646 | - 'cal_extra_value' => is_array($value) ? implode(',',$value) : $value, |
|
| 1647 | - ),array( |
|
| 1643 | + $this->db->insert($this->extra_table, array( |
|
| 1644 | + 'cal_extra_value' => is_array($value) ? implode(',', $value) : $value, |
|
| 1645 | + ), array( |
|
| 1648 | 1646 | 'cal_id' => $cal_id, |
| 1649 | - 'cal_extra_name' => substr($name,1), |
|
| 1650 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1647 | + 'cal_extra_name' => substr($name, 1), |
|
| 1648 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1651 | 1649 | } |
| 1652 | 1650 | else |
| 1653 | 1651 | { |
| 1654 | - $this->db->delete($this->extra_table,array( |
|
| 1652 | + $this->db->delete($this->extra_table, array( |
|
| 1655 | 1653 | 'cal_id' => $cal_id, |
| 1656 | - 'cal_extra_name' => substr($name,1), |
|
| 1657 | - ),__LINE__,__FILE__,'calendar'); |
|
| 1654 | + 'cal_extra_name' => substr($name, 1), |
|
| 1655 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 1658 | 1656 | } |
| 1659 | 1657 | } |
| 1660 | 1658 | } |
@@ -1665,9 +1663,9 @@ discard block |
||
| 1665 | 1663 | { |
| 1666 | 1664 | if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0) |
| 1667 | 1665 | { |
| 1668 | - unset($alarm['id']); // unset the temporary id to add the alarm |
|
| 1666 | + unset($alarm['id']); // unset the temporary id to add the alarm |
|
| 1669 | 1667 | } |
| 1670 | - if(!isset($alarm['offset'])) |
|
| 1668 | + if (!isset($alarm['offset'])) |
|
| 1671 | 1669 | { |
| 1672 | 1670 | $alarm['offset'] = $event['cal_start'] - $alarm['time']; |
| 1673 | 1671 | } |
@@ -1678,14 +1676,14 @@ discard block |
||
| 1678 | 1676 | |
| 1679 | 1677 | if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm)) |
| 1680 | 1678 | { |
| 1681 | - continue; // pgoerzen: don't add alarm in the past |
|
| 1679 | + continue; // pgoerzen: don't add alarm in the past |
|
| 1682 | 1680 | } |
| 1683 | - $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
| 1681 | + $this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway |
|
| 1684 | 1682 | } |
| 1685 | 1683 | } |
| 1686 | 1684 | if (is_null($etag)) |
| 1687 | 1685 | { |
| 1688 | - $etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn(); |
|
| 1686 | + $etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn(); |
|
| 1689 | 1687 | } |
| 1690 | 1688 | |
| 1691 | 1689 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
@@ -1705,7 +1703,7 @@ discard block |
||
| 1705 | 1703 | * are dealing with, default is now. |
| 1706 | 1704 | * @return boolean true if alarm could be shifted, false if not |
| 1707 | 1705 | */ |
| 1708 | - public static function shift_alarm(array $_event, array &$alarm, $timestamp=null) |
|
| 1706 | + public static function shift_alarm(array $_event, array &$alarm, $timestamp = null) |
|
| 1709 | 1707 | { |
| 1710 | 1708 | if ($_event['recur_type'] == MCAL_RECUR_NONE) |
| 1711 | 1709 | { |
@@ -1716,7 +1714,7 @@ discard block |
||
| 1716 | 1714 | $rrule = calendar_rrule::event2rrule($event, false); |
| 1717 | 1715 | foreach ($rrule as $time) |
| 1718 | 1716 | { |
| 1719 | - if ($start < ($ts = Api\DateTime::to($time,'server'))) |
|
| 1717 | + if ($start < ($ts = Api\DateTime::to($time, 'server'))) |
|
| 1720 | 1718 | { |
| 1721 | 1719 | $alarm['time'] = $ts - $alarm['offset']; |
| 1722 | 1720 | return true; |
@@ -1737,34 +1735,34 @@ discard block |
||
| 1737 | 1735 | * @todo Recalculate recurrences, if timezone changes |
| 1738 | 1736 | * @return int|boolean number of moved recurrences or false on error |
| 1739 | 1737 | */ |
| 1740 | - function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0) |
|
| 1738 | + function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0) |
|
| 1741 | 1739 | { |
| 1742 | 1740 | //echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n"; |
| 1743 | 1741 | |
| 1744 | - if (!(int) $cal_id) return false; |
|
| 1742 | + if (!(int)$cal_id) return false; |
|
| 1745 | 1743 | |
| 1746 | 1744 | if (!$old_start) |
| 1747 | 1745 | { |
| 1748 | - if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1749 | - array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch(); |
|
| 1746 | + if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
|
| 1747 | + array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch(); |
|
| 1750 | 1748 | // if no recurrence found, create one with the new dates |
| 1751 | 1749 | if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end']) |
| 1752 | 1750 | { |
| 1753 | - $this->db->insert($this->dates_table,array( |
|
| 1751 | + $this->db->insert($this->dates_table, array( |
|
| 1754 | 1752 | 'cal_id' => $cal_id, |
| 1755 | 1753 | 'cal_start' => $start, |
| 1756 | 1754 | 'cal_end' => $end, |
| 1757 | - ),false,__LINE__,__FILE__,'calendar'); |
|
| 1755 | + ), false, __LINE__, __FILE__, 'calendar'); |
|
| 1758 | 1756 | |
| 1759 | 1757 | return 1; |
| 1760 | 1758 | } |
| 1761 | - $move_start = (int) ($start-$row['cal_start']); |
|
| 1762 | - $move_end = (int) ($end-$row['cal_end']); |
|
| 1759 | + $move_start = (int)($start - $row['cal_start']); |
|
| 1760 | + $move_end = (int)($end - $row['cal_end']); |
|
| 1763 | 1761 | } |
| 1764 | 1762 | else |
| 1765 | 1763 | { |
| 1766 | - $move_start = (int) ($start-$old_start); |
|
| 1767 | - $move_end = (int) ($end-$old_end); |
|
| 1764 | + $move_start = (int)($start - $old_start); |
|
| 1765 | + $move_end = (int)($end - $old_end); |
|
| 1768 | 1766 | } |
| 1769 | 1767 | $where = 'cal_id='.(int)$cal_id; |
| 1770 | 1768 | |
@@ -1772,13 +1770,13 @@ discard block |
||
| 1772 | 1770 | { |
| 1773 | 1771 | // move the recur-date of the participants |
| 1774 | 1772 | $this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ". |
| 1775 | - ((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__); |
|
| 1773 | + ((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__); |
|
| 1776 | 1774 | } |
| 1777 | 1775 | if ($move_start || $move_end) |
| 1778 | 1776 | { |
| 1779 | 1777 | // move the event and it's recurrences |
| 1780 | 1778 | $this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where". |
| 1781 | - ((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__); |
|
| 1779 | + ((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__); |
|
| 1782 | 1780 | } |
| 1783 | 1781 | return $this->db->affected_rows(); |
| 1784 | 1782 | } |
@@ -1797,8 +1795,7 @@ discard block |
||
| 1797 | 1795 | } |
| 1798 | 1796 | if (is_array($attendee)) |
| 1799 | 1797 | { |
| 1800 | - $email = !empty($attendee['email']) ? $user_attendee['email'] : |
|
| 1801 | - (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
| 1798 | + $email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']); |
|
| 1802 | 1799 | $attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email; |
| 1803 | 1800 | } |
| 1804 | 1801 | return $attendee; |
@@ -1811,11 +1808,11 @@ discard block |
||
| 1811 | 1808 | * @param string|array $attendee attendee information: email, json or array with attr cn and url |
| 1812 | 1809 | * @return string|int combined id |
| 1813 | 1810 | */ |
| 1814 | - static function combine_user($user_type, $user_id, $attendee=null) |
|
| 1811 | + static function combine_user($user_type, $user_id, $attendee = null) |
|
| 1815 | 1812 | { |
| 1816 | 1813 | if (!$user_type || $user_type == 'u') |
| 1817 | 1814 | { |
| 1818 | - return (int) $user_id; |
|
| 1815 | + return (int)$user_id; |
|
| 1819 | 1816 | } |
| 1820 | 1817 | if ($user_type == 'e' && $attendee) |
| 1821 | 1818 | { |
@@ -1835,12 +1832,12 @@ discard block |
||
| 1835 | 1832 | * @param string|int &$user_id id |
| 1836 | 1833 | * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e" |
| 1837 | 1834 | */ |
| 1838 | - static function split_user($uid, &$user_type, &$user_id, $md5_email=false) |
|
| 1835 | + static function split_user($uid, &$user_type, &$user_id, $md5_email = false) |
|
| 1839 | 1836 | { |
| 1840 | 1837 | if (is_numeric($uid)) |
| 1841 | 1838 | { |
| 1842 | 1839 | $user_type = 'u'; |
| 1843 | - $user_id = (int) $uid; |
|
| 1840 | + $user_id = (int)$uid; |
|
| 1844 | 1841 | } |
| 1845 | 1842 | // create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>") |
| 1846 | 1843 | elseif ($md5_email && $uid[0] == 'e') |
@@ -1854,7 +1851,7 @@ discard block |
||
| 1854 | 1851 | else |
| 1855 | 1852 | { |
| 1856 | 1853 | $user_type = $uid[0]; |
| 1857 | - $user_id = substr($uid,1); |
|
| 1854 | + $user_id = substr($uid, 1); |
|
| 1858 | 1855 | } |
| 1859 | 1856 | } |
| 1860 | 1857 | |
@@ -1866,7 +1863,7 @@ discard block |
||
| 1866 | 1863 | * @param string $role ='REQ-PARTICIPANT' |
| 1867 | 1864 | * @return string |
| 1868 | 1865 | */ |
| 1869 | - static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT') |
|
| 1866 | + static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT') |
|
| 1870 | 1867 | { |
| 1871 | 1868 | if ((int)$quantity > 1) $status .= (int)$quantity; |
| 1872 | 1869 | if ($role != 'REQ-PARTICIPANT') $status .= $role; |
@@ -1882,13 +1879,13 @@ discard block |
||
| 1882 | 1879 | * @param string &$role=null only O: role |
| 1883 | 1880 | * @return string status U, T, A or R, same as $status parameter on return |
| 1884 | 1881 | */ |
| 1885 | - static function split_status(&$status,&$quantity=null,&$role=null) |
|
| 1882 | + static function split_status(&$status, &$quantity = null, &$role = null) |
|
| 1886 | 1883 | { |
| 1887 | 1884 | $quantity = 1; |
| 1888 | 1885 | $role = 'REQ-PARTICIPANT'; |
| 1889 | 1886 | //error_log(__METHOD__.__LINE__.array2string($status)); |
| 1890 | 1887 | $matches = null; |
| 1891 | - if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches)) |
|
| 1888 | + if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches)) |
|
| 1892 | 1889 | { |
| 1893 | 1890 | if ((int)$matches[1] > 0) $quantity = (int)$matches[1]; |
| 1894 | 1891 | if ($matches[2]) $role = $matches[2]; |
@@ -1915,14 +1912,14 @@ discard block |
||
| 1915 | 1912 | * true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants) |
| 1916 | 1913 | * @return int|boolean number of updated recurrences or false on error |
| 1917 | 1914 | */ |
| 1918 | - function participants($cal_id,$participants,$change_since=0,$add_only=false) |
|
| 1915 | + function participants($cal_id, $participants, $change_since = 0, $add_only = false) |
|
| 1919 | 1916 | { |
| 1920 | 1917 | //error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only"); |
| 1921 | 1918 | |
| 1922 | 1919 | $recurrences = array(); |
| 1923 | 1920 | |
| 1924 | 1921 | // remove group-invitations, they are NOT stored in the db |
| 1925 | - foreach($participants as $uid => $status) |
|
| 1922 | + foreach ($participants as $uid => $status) |
|
| 1926 | 1923 | { |
| 1927 | 1924 | if ($status[0] == 'G') |
| 1928 | 1925 | { |
@@ -1931,7 +1928,7 @@ discard block |
||
| 1931 | 1928 | } |
| 1932 | 1929 | $where = array('cal_id' => $cal_id); |
| 1933 | 1930 | |
| 1934 | - if ((int) $change_since) |
|
| 1931 | + if ((int)$change_since) |
|
| 1935 | 1932 | { |
| 1936 | 1933 | $where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')'; |
| 1937 | 1934 | } |
@@ -1939,31 +1936,31 @@ discard block |
||
| 1939 | 1936 | if ($change_since !== false) |
| 1940 | 1937 | { |
| 1941 | 1938 | // find all existing recurrences |
| 1942 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 1939 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 1943 | 1940 | { |
| 1944 | 1941 | $recurrences[] = $row['cal_recur_date']; |
| 1945 | 1942 | } |
| 1946 | 1943 | |
| 1947 | 1944 | // update existing entries |
| 1948 | - $existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar'); |
|
| 1945 | + $existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar'); |
|
| 1949 | 1946 | |
| 1950 | 1947 | // create a full list of participants which already exist in the db |
| 1951 | 1948 | // with status, quantity and role of the earliest recurence |
| 1952 | 1949 | $old_participants = array(); |
| 1953 | - foreach($existing_entries as $row) |
|
| 1950 | + foreach ($existing_entries as $row) |
|
| 1954 | 1951 | { |
| 1955 | 1952 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1956 | 1953 | if ($row['cal_recur_date'] || !isset($old_participants[$uid])) |
| 1957 | 1954 | { |
| 1958 | - $old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 1955 | + $old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 1959 | 1956 | } |
| 1960 | 1957 | } |
| 1961 | 1958 | |
| 1962 | 1959 | // tag participants which should be deleted |
| 1963 | - if($add_only === false) |
|
| 1960 | + if ($add_only === false) |
|
| 1964 | 1961 | { |
| 1965 | 1962 | $deleted = array(); |
| 1966 | - foreach($existing_entries as $row) |
|
| 1963 | + foreach ($existing_entries as $row) |
|
| 1967 | 1964 | { |
| 1968 | 1965 | $uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']); |
| 1969 | 1966 | // delete not longer set participants |
@@ -1976,7 +1973,7 @@ discard block |
||
| 1976 | 1973 | |
| 1977 | 1974 | // only keep added OR status (incl. quantity!) changed participants for further steps |
| 1978 | 1975 | // we do not touch unchanged (!) existing ones |
| 1979 | - foreach($participants as $uid => $status) |
|
| 1976 | + foreach ($participants as $uid => $status) |
|
| 1980 | 1977 | { |
| 1981 | 1978 | if ($old_participants[$uid] === $status) |
| 1982 | 1979 | { |
@@ -1988,46 +1985,46 @@ discard block |
||
| 1988 | 1985 | if ($add_only === false && count($deleted)) |
| 1989 | 1986 | { |
| 1990 | 1987 | $to_or = array(); |
| 1991 | - $table_def = $this->db->get_table_definitions('calendar',$this->user_table); |
|
| 1992 | - foreach($deleted as $type => $ids) |
|
| 1988 | + $table_def = $this->db->get_table_definitions('calendar', $this->user_table); |
|
| 1989 | + foreach ($deleted as $type => $ids) |
|
| 1993 | 1990 | { |
| 1994 | - $to_or[] = $this->db->expression($table_def,array( |
|
| 1991 | + $to_or[] = $this->db->expression($table_def, array( |
|
| 1995 | 1992 | 'cal_user_type' => $type, |
| 1996 | 1993 | 'cal_user_id' => $ids, |
| 1997 | 1994 | )); |
| 1998 | 1995 | } |
| 1999 | - $where[] = '('.implode(' OR ',$to_or).')'; |
|
| 2000 | - $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
| 2001 | - $this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar'); |
|
| 1996 | + $where[] = '('.implode(' OR ', $to_or).')'; |
|
| 1997 | + $where[] = "cal_status!='E'"; // do NOT delete exception marker |
|
| 1998 | + $this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar'); |
|
| 2002 | 1999 | } |
| 2003 | 2000 | } |
| 2004 | 2001 | |
| 2005 | 2002 | if (count($participants)) // participants which need to be added |
| 2006 | 2003 | { |
| 2007 | - if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2004 | + if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence |
|
| 2008 | 2005 | |
| 2009 | 2006 | $delete_deleted = array(); |
| 2010 | 2007 | |
| 2011 | 2008 | // update participants |
| 2012 | - foreach($participants as $uid => $status) |
|
| 2009 | + foreach ($participants as $uid => $status) |
|
| 2013 | 2010 | { |
| 2014 | 2011 | $type = $id = $quantity = $role = null; |
| 2015 | 2012 | self::split_user($uid, $type, $id, true); |
| 2016 | - self::split_status($status,$quantity,$role); |
|
| 2013 | + self::split_status($status, $quantity, $role); |
|
| 2017 | 2014 | $set = array( |
| 2018 | 2015 | 'cal_status' => $status, |
| 2019 | 2016 | 'cal_quantity' => $quantity, |
| 2020 | 2017 | 'cal_role' => $role, |
| 2021 | 2018 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
| 2022 | 2019 | ); |
| 2023 | - foreach($recurrences as $recur_date) |
|
| 2020 | + foreach ($recurrences as $recur_date) |
|
| 2024 | 2021 | { |
| 2025 | - $this->db->insert($this->user_table,$set,array( |
|
| 2022 | + $this->db->insert($this->user_table, $set, array( |
|
| 2026 | 2023 | 'cal_id' => $cal_id, |
| 2027 | 2024 | 'cal_recur_date' => $recur_date, |
| 2028 | 2025 | 'cal_user_type' => $type, |
| 2029 | 2026 | 'cal_user_id' => $id, |
| 2030 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2027 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2031 | 2028 | } |
| 2032 | 2029 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2033 | 2030 | if ($uid < 0) |
@@ -2037,13 +2034,13 @@ discard block |
||
| 2037 | 2034 | } |
| 2038 | 2035 | if ($delete_deleted) |
| 2039 | 2036 | { |
| 2040 | - $this->db->delete($this->user_table, $where=array( |
|
| 2037 | + $this->db->delete($this->user_table, $where = array( |
|
| 2041 | 2038 | 'cal_id' => $cal_id, |
| 2042 | 2039 | 'cal_recur_date' => $recurrences, |
| 2043 | 2040 | 'cal_user_type' => 'u', |
| 2044 | 2041 | 'cal_user_id' => array_unique($delete_deleted), |
| 2045 | 2042 | 'cal_status' => 'X', |
| 2046 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2043 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2047 | 2044 | //error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows'); |
| 2048 | 2045 | } |
| 2049 | 2046 | } |
@@ -2062,7 +2059,7 @@ discard block |
||
| 2062 | 2059 | * @param string $attendee =null extra attendee information to set for all types (incl. accounts!) |
| 2063 | 2060 | * @return int number of changed recurrences |
| 2064 | 2061 | */ |
| 2065 | - function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null) |
|
| 2062 | + function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null) |
|
| 2066 | 2063 | { |
| 2067 | 2064 | static $status_code_short = array( |
| 2068 | 2065 | REJECTED => 'R', |
@@ -2087,7 +2084,7 @@ discard block |
||
| 2087 | 2084 | 'cal_user_type' => $user_type, |
| 2088 | 2085 | 'cal_user_id' => $user_id_md5, |
| 2089 | 2086 | ); |
| 2090 | - if ((int) $recur_date) |
|
| 2087 | + if ((int)$recur_date) |
|
| 2091 | 2088 | { |
| 2092 | 2089 | $where['cal_recur_date'] = $recur_date; |
| 2093 | 2090 | } |
@@ -2098,7 +2095,7 @@ discard block |
||
| 2098 | 2095 | |
| 2099 | 2096 | if ($status == 'G') // remove group invitations, as we dont store them in the db |
| 2100 | 2097 | { |
| 2101 | - $this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar'); |
|
| 2098 | + $this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar'); |
|
| 2102 | 2099 | $ret = $this->db->affected_rows(); |
| 2103 | 2100 | } |
| 2104 | 2101 | else |
@@ -2106,7 +2103,7 @@ discard block |
||
| 2106 | 2103 | $set = array('cal_status' => $status); |
| 2107 | 2104 | if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id; |
| 2108 | 2105 | if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role; |
| 2109 | - $this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar'); |
|
| 2106 | + $this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar'); |
|
| 2110 | 2107 | // for new or changed group-invitations, remove previously deleted members, so they show up again |
| 2111 | 2108 | if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0) |
| 2112 | 2109 | { |
@@ -2119,7 +2116,7 @@ discard block |
||
| 2119 | 2116 | // update modified and modifier in main table |
| 2120 | 2117 | if ($ret) |
| 2121 | 2118 | { |
| 2122 | - $this->updateModified($cal_id, true); // true = update series master too |
|
| 2119 | + $this->updateModified($cal_id, true); // true = update series master too |
|
| 2123 | 2120 | } |
| 2124 | 2121 | //error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret"); |
| 2125 | 2122 | return $ret; |
@@ -2134,7 +2131,7 @@ discard block |
||
| 2134 | 2131 | * @param array $participants uid => status pairs |
| 2135 | 2132 | * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception) |
| 2136 | 2133 | */ |
| 2137 | - function recurrence($cal_id,$start,$end,$participants,$exception=null) |
|
| 2134 | + function recurrence($cal_id, $start, $end, $participants, $exception = null) |
|
| 2138 | 2135 | { |
| 2139 | 2136 | //error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception)); |
| 2140 | 2137 | $update = array('cal_end' => $end); |
@@ -2143,7 +2140,7 @@ discard block |
||
| 2143 | 2140 | $this->db->insert($this->dates_table, $update, array( |
| 2144 | 2141 | 'cal_id' => $cal_id, |
| 2145 | 2142 | 'cal_start' => $start, |
| 2146 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2143 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2147 | 2144 | |
| 2148 | 2145 | if (!is_array($participants)) |
| 2149 | 2146 | { |
@@ -2151,26 +2148,26 @@ discard block |
||
| 2151 | 2148 | } |
| 2152 | 2149 | if ($exception !== true) |
| 2153 | 2150 | { |
| 2154 | - foreach($participants as $uid => $status) |
|
| 2151 | + foreach ($participants as $uid => $status) |
|
| 2155 | 2152 | { |
| 2156 | - if ($status == 'G') continue; // dont save group-invitations |
|
| 2153 | + if ($status == 'G') continue; // dont save group-invitations |
|
| 2157 | 2154 | |
| 2158 | 2155 | $type = ''; |
| 2159 | 2156 | $id = null; |
| 2160 | 2157 | self::split_user($uid, $type, $id, true); |
| 2161 | 2158 | $quantity = $role = null; |
| 2162 | - self::split_status($status,$quantity,$role); |
|
| 2163 | - $this->db->insert($this->user_table,array( |
|
| 2159 | + self::split_status($status, $quantity, $role); |
|
| 2160 | + $this->db->insert($this->user_table, array( |
|
| 2164 | 2161 | 'cal_status' => $status, |
| 2165 | 2162 | 'cal_quantity' => $quantity, |
| 2166 | 2163 | 'cal_role' => $role, |
| 2167 | 2164 | 'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null, |
| 2168 | - ),array( |
|
| 2165 | + ), array( |
|
| 2169 | 2166 | 'cal_id' => $cal_id, |
| 2170 | 2167 | 'cal_recur_date' => $start, |
| 2171 | 2168 | 'cal_user_type' => $type, |
| 2172 | 2169 | 'cal_user_id' => $id, |
| 2173 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2170 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2174 | 2171 | } |
| 2175 | 2172 | } |
| 2176 | 2173 | } |
@@ -2184,7 +2181,7 @@ discard block |
||
| 2184 | 2181 | function unfinished_recuring($time) |
| 2185 | 2182 | { |
| 2186 | 2183 | $ids = array(); |
| 2187 | - foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
| 2184 | + foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start", |
|
| 2188 | 2185 | '(range_end IS NULL OR range_end > '.(int)$time.')', |
| 2189 | 2186 | __LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0, |
| 2190 | 2187 | " JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id". |
@@ -2210,9 +2207,9 @@ discard block |
||
| 2210 | 2207 | // update timestamp of series master, updates own timestamp too, which does not hurt ;-) |
| 2211 | 2208 | $this->updateModified($cal_id, true); |
| 2212 | 2209 | |
| 2213 | - foreach($this->all_tables as $table) |
|
| 2210 | + foreach ($this->all_tables as $table) |
|
| 2214 | 2211 | { |
| 2215 | - $this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar'); |
|
| 2212 | + $this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar'); |
|
| 2216 | 2213 | } |
| 2217 | 2214 | } |
| 2218 | 2215 | |
@@ -2228,19 +2225,19 @@ discard block |
||
| 2228 | 2225 | function purge($date) |
| 2229 | 2226 | { |
| 2230 | 2227 | // with new range_end we simple delete all with range_end < $date (range_end NULL is never returned) |
| 2231 | - foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2228 | + foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2232 | 2229 | { |
| 2233 | 2230 | //echo __METHOD__." About to delete".$row['cal_id']."\r\n"; |
| 2234 | - foreach($this->all_tables as $table) |
|
| 2231 | + foreach ($this->all_tables as $table) |
|
| 2235 | 2232 | { |
| 2236 | 2233 | $this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar'); |
| 2237 | 2234 | } |
| 2238 | 2235 | // handle sync |
| 2239 | - $this->db->update('egw_api_content_history',array( |
|
| 2236 | + $this->db->update('egw_api_content_history', array( |
|
| 2240 | 2237 | 'sync_deleted' => time(), |
| 2241 | - ),array( |
|
| 2238 | + ), array( |
|
| 2242 | 2239 | 'sync_appname' => 'calendar', |
| 2243 | - 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
| 2240 | + 'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)! |
|
| 2244 | 2241 | ), __LINE__, __FILE__, 'calendar'); |
| 2245 | 2242 | // handle links |
| 2246 | 2243 | Link::unlink('', 'calendar', $row['cal_id']); |
@@ -2263,23 +2260,23 @@ discard block |
||
| 2263 | 2260 | * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id |
| 2264 | 2261 | * @return array of (cal_id => array of) alarms with alarm-id as key |
| 2265 | 2262 | */ |
| 2266 | - function read_alarms($cal_id, $update_cache=null) |
|
| 2263 | + function read_alarms($cal_id, $update_cache = null) |
|
| 2267 | 2264 | { |
| 2268 | 2265 | if (!isset(self::$alarm_cache) && is_array($cal_id)) |
| 2269 | 2266 | { |
| 2270 | 2267 | self::$alarm_cache = array(); |
| 2271 | 2268 | if (($jobs = $this->async->read('cal:%'))) |
| 2272 | 2269 | { |
| 2273 | - foreach($jobs as $id => $job) |
|
| 2270 | + foreach ($jobs as $id => $job) |
|
| 2274 | 2271 | { |
| 2275 | - $alarm = $job['data']; // text, enabled |
|
| 2272 | + $alarm = $job['data']; // text, enabled |
|
| 2276 | 2273 | $alarm['id'] = $id; |
| 2277 | 2274 | $alarm['time'] = $job['next']; |
| 2278 | 2275 | |
| 2279 | 2276 | self::$alarm_cache[$alarm['cal_id']][$id] = $alarm; |
| 2280 | 2277 | } |
| 2281 | 2278 | } |
| 2282 | - unset($update_cache); // just done |
|
| 2279 | + unset($update_cache); // just done |
|
| 2283 | 2280 | } |
| 2284 | 2281 | $alarms = array(); |
| 2285 | 2282 | |
@@ -2287,13 +2284,13 @@ discard block |
||
| 2287 | 2284 | { |
| 2288 | 2285 | if (isset($update_cache)) |
| 2289 | 2286 | { |
| 2290 | - foreach((array)$cal_id as $id) |
|
| 2287 | + foreach ((array)$cal_id as $id) |
|
| 2291 | 2288 | { |
| 2292 | 2289 | if ($update_cache === false) |
| 2293 | 2290 | { |
| 2294 | 2291 | unset(self::$alarm_cache[$cal_id]); |
| 2295 | 2292 | } |
| 2296 | - elseif($update_cache === true) |
|
| 2293 | + elseif ($update_cache === true) |
|
| 2297 | 2294 | { |
| 2298 | 2295 | self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id); |
| 2299 | 2296 | } |
@@ -2305,7 +2302,7 @@ discard block |
||
| 2305 | 2302 | } |
| 2306 | 2303 | else |
| 2307 | 2304 | { |
| 2308 | - foreach($cal_id as $id) |
|
| 2305 | + foreach ($cal_id as $id) |
|
| 2309 | 2306 | { |
| 2310 | 2307 | $alarms[$id] = (array)self::$alarm_cache[$id]; |
| 2311 | 2308 | } |
@@ -2320,9 +2317,9 @@ discard block |
||
| 2320 | 2317 | { |
| 2321 | 2318 | if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%'))) |
| 2322 | 2319 | { |
| 2323 | - foreach($jobs as $id => $job) |
|
| 2320 | + foreach ($jobs as $id => $job) |
|
| 2324 | 2321 | { |
| 2325 | - $alarm = $job['data']; // text, enabled |
|
| 2322 | + $alarm = $job['data']; // text, enabled |
|
| 2326 | 2323 | $alarm['id'] = $id; |
| 2327 | 2324 | $alarm['time'] = $job['next']; |
| 2328 | 2325 | |
@@ -2345,8 +2342,8 @@ discard block |
||
| 2345 | 2342 | { |
| 2346 | 2343 | return False; |
| 2347 | 2344 | } |
| 2348 | - list($alarm_id,$job) = each($jobs); |
|
| 2349 | - $alarm = $job['data']; // text, enabled |
|
| 2345 | + list($alarm_id, $job) = each($jobs); |
|
| 2346 | + $alarm = $job['data']; // text, enabled |
|
| 2350 | 2347 | $alarm['id'] = $alarm_id; |
| 2351 | 2348 | $alarm['time'] = $job['next']; |
| 2352 | 2349 | |
@@ -2362,12 +2359,12 @@ discard block |
||
| 2362 | 2359 | * @param boolean $update_modified =true call update modified, default true |
| 2363 | 2360 | * @return string id of the alarm |
| 2364 | 2361 | */ |
| 2365 | - function save_alarm($cal_id, $alarm, $update_modified=true) |
|
| 2362 | + function save_alarm($cal_id, $alarm, $update_modified = true) |
|
| 2366 | 2363 | { |
| 2367 | 2364 | //error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace()); |
| 2368 | 2365 | if (!($id = $alarm['id'])) |
| 2369 | 2366 | { |
| 2370 | - $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
| 2367 | + $alarms = $this->read_alarms($cal_id); // find a free alarm# |
|
| 2371 | 2368 | $n = count($alarms); |
| 2372 | 2369 | do |
| 2373 | 2370 | { |
@@ -2380,12 +2377,12 @@ discard block |
||
| 2380 | 2377 | { |
| 2381 | 2378 | $this->async->cancel_timer($id); |
| 2382 | 2379 | } |
| 2383 | - $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
| 2380 | + $alarm['cal_id'] = $cal_id; // we need the back-reference |
|
| 2384 | 2381 | // add an alarm uid, if none is given |
| 2385 | 2382 | if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid; |
| 2386 | 2383 | //error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace()); |
| 2387 | 2384 | // allways store job with the alarm owner as job-owner to get eg. the correct from address |
| 2388 | - if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner'])) |
|
| 2385 | + if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner'])) |
|
| 2389 | 2386 | { |
| 2390 | 2387 | return False; |
| 2391 | 2388 | } |
@@ -2412,7 +2409,7 @@ discard block |
||
| 2412 | 2409 | //error_log(__METHOD__."($cal_id) ".function_backtrace()); |
| 2413 | 2410 | if (($alarms = $this->read_alarms($cal_id))) |
| 2414 | 2411 | { |
| 2415 | - foreach(array_keys($alarms) as $id) |
|
| 2412 | + foreach (array_keys($alarms) as $id) |
|
| 2416 | 2413 | { |
| 2417 | 2414 | $this->async->cancel_timer($id); |
| 2418 | 2415 | } |
@@ -2432,7 +2429,7 @@ discard block |
||
| 2432 | 2429 | { |
| 2433 | 2430 | //error_log(__METHOD__."('$id') ".function_backtrace()); |
| 2434 | 2431 | // update the modification information of the related event |
| 2435 | - list(,$cal_id) = explode(':',$id); |
|
| 2432 | + list(,$cal_id) = explode(':', $id); |
|
| 2436 | 2433 | if ($cal_id) |
| 2437 | 2434 | { |
| 2438 | 2435 | $this->updateModified($cal_id, true); |
@@ -2451,7 +2448,7 @@ discard block |
||
| 2451 | 2448 | * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it |
| 2452 | 2449 | * @param int $new_user =null |
| 2453 | 2450 | */ |
| 2454 | - function deleteaccount($old_user, $new_user=null) |
|
| 2451 | + function deleteaccount($old_user, $new_user = null) |
|
| 2455 | 2452 | { |
| 2456 | 2453 | if (is_array($old_user)) |
| 2457 | 2454 | { |
@@ -2462,52 +2459,52 @@ discard block |
||
| 2462 | 2459 | { |
| 2463 | 2460 | $user_type = ''; |
| 2464 | 2461 | $user_id = null; |
| 2465 | - self::split_user($old_user,$user_type,$user_id); |
|
| 2462 | + self::split_user($old_user, $user_type, $user_id); |
|
| 2466 | 2463 | |
| 2467 | 2464 | if ($user_type == 'u') // only accounts can be owners of events |
| 2468 | 2465 | { |
| 2469 | - foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2466 | + foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2470 | 2467 | { |
| 2471 | 2468 | $this->delete($row['cal_id']); |
| 2472 | 2469 | } |
| 2473 | 2470 | } |
| 2474 | - $this->db->delete($this->user_table,array( |
|
| 2471 | + $this->db->delete($this->user_table, array( |
|
| 2475 | 2472 | 'cal_user_type' => $user_type, |
| 2476 | 2473 | 'cal_user_id' => $user_id, |
| 2477 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2474 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2478 | 2475 | |
| 2479 | 2476 | // delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner) |
| 2480 | - foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__, |
|
| 2481 | - False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
| 2477 | + foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__, |
|
| 2478 | + False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row) |
|
| 2482 | 2479 | { |
| 2483 | 2480 | $this->delete($row['cal_id']); |
| 2484 | 2481 | } |
| 2485 | 2482 | } |
| 2486 | 2483 | else |
| 2487 | 2484 | { |
| 2488 | - $this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar'); |
|
| 2485 | + $this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar'); |
|
| 2489 | 2486 | // delete participation of old user, if new user is already a participant |
| 2490 | 2487 | $ids = array(); |
| 2491 | - foreach($this->db->select($this->user_table,'cal_id',array( // MySQL does NOT allow to run this as delete! |
|
| 2488 | + foreach ($this->db->select($this->user_table, 'cal_id', array( // MySQL does NOT allow to run this as delete! |
|
| 2492 | 2489 | 'cal_user_type' => 'u', |
| 2493 | 2490 | 'cal_user_id' => $old_user, |
| 2494 | 2491 | "cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')", |
| 2495 | - ),__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2492 | + ), __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2496 | 2493 | { |
| 2497 | 2494 | $ids[] = $row['cal_id']; |
| 2498 | 2495 | } |
| 2499 | - if ($ids) $this->db->delete($this->user_table,array( |
|
| 2496 | + if ($ids) $this->db->delete($this->user_table, array( |
|
| 2500 | 2497 | 'cal_user_type' => 'u', |
| 2501 | 2498 | 'cal_user_id' => $old_user, |
| 2502 | 2499 | 'cal_id' => $ids, |
| 2503 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2500 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2504 | 2501 | // now change participant in the rest to contain new user instead of old user |
| 2505 | - $this->db->update($this->user_table,array( |
|
| 2502 | + $this->db->update($this->user_table, array( |
|
| 2506 | 2503 | 'cal_user_id' => $new_user, |
| 2507 | - ),array( |
|
| 2504 | + ), array( |
|
| 2508 | 2505 | 'cal_user_type' => 'u', |
| 2509 | 2506 | 'cal_user_id' => $old_user, |
| 2510 | - ),__LINE__,__FILE__,'calendar'); |
|
| 2507 | + ), __LINE__, __FILE__, 'calendar'); |
|
| 2511 | 2508 | } |
| 2512 | 2509 | } |
| 2513 | 2510 | |
@@ -2521,18 +2518,18 @@ discard block |
||
| 2521 | 2518 | * |
| 2522 | 2519 | * @return array recur_date => status pairs (index 0 => main status) |
| 2523 | 2520 | */ |
| 2524 | - function get_recurrences($cal_id, $uid=null, $start=0, $end=0) |
|
| 2521 | + function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0) |
|
| 2525 | 2522 | { |
| 2526 | 2523 | $participant_status = array(); |
| 2527 | 2524 | $where = array('cal_id' => $cal_id); |
| 2528 | - if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2529 | - if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2525 | + if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
| 2526 | + if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
| 2530 | 2527 | if ($start != 0 && $end != 0) |
| 2531 | 2528 | { |
| 2532 | - $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
| 2533 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
| 2529 | + $where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
| 2530 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
| 2534 | 2531 | } |
| 2535 | - foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2532 | + foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2536 | 2533 | { |
| 2537 | 2534 | // inititalize the array |
| 2538 | 2535 | $participant_status[$row['cal_recur_date']] = null; |
@@ -2546,17 +2543,17 @@ discard block |
||
| 2546 | 2543 | 'cal_user_type' => $user_type ? $user_type : 'u', |
| 2547 | 2544 | 'cal_user_id' => $user_id, |
| 2548 | 2545 | ); |
| 2549 | - if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')'; |
|
| 2550 | - if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')'; |
|
| 2546 | + if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')'; |
|
| 2547 | + if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')'; |
|
| 2551 | 2548 | if ($start != 0 && $end != 0) |
| 2552 | 2549 | { |
| 2553 | - $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start . |
|
| 2554 | - ' AND cal_recur_date <= ' . (int)$end . '))'; |
|
| 2550 | + $where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start. |
|
| 2551 | + ' AND cal_recur_date <= '.(int)$end.'))'; |
|
| 2555 | 2552 | } |
| 2556 | - foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2, |
|
| 2557 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2553 | + foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2, |
|
| 2554 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2558 | 2555 | { |
| 2559 | - $status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']); |
|
| 2556 | + $status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']); |
|
| 2560 | 2557 | $participant_status[$row['cal_recur_date']] = $status; |
| 2561 | 2558 | } |
| 2562 | 2559 | return $participant_status; |
@@ -2605,8 +2602,8 @@ discard block |
||
| 2605 | 2602 | 'cal_uid' => $uid, |
| 2606 | 2603 | ); |
| 2607 | 2604 | $related = array(); |
| 2608 | - foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where, |
|
| 2609 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2605 | + foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where, |
|
| 2606 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2610 | 2607 | { |
| 2611 | 2608 | if ($row['cal_reference'] != 0) |
| 2612 | 2609 | { |
@@ -2635,10 +2632,10 @@ discard block |
||
| 2635 | 2632 | * |
| 2636 | 2633 | * @return array Array of exception days (false for non-recurring events). |
| 2637 | 2634 | */ |
| 2638 | - function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all') |
|
| 2635 | + function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all') |
|
| 2639 | 2636 | { |
| 2640 | 2637 | if (!is_array($event)) return false; |
| 2641 | - $cal_id = (int) $event['id']; |
|
| 2638 | + $cal_id = (int)$event['id']; |
|
| 2642 | 2639 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2643 | 2640 | // "($cal_id, $tz_id, $filter): " . $event['tzid']); |
| 2644 | 2641 | if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false; |
@@ -2662,27 +2659,27 @@ discard block |
||
| 2662 | 2659 | while ($egw_rrule->valid()) |
| 2663 | 2660 | { |
| 2664 | 2661 | while ($egw_rrule->exceptions && |
| 2665 | - in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions)) |
|
| 2662 | + in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions)) |
|
| 2666 | 2663 | { |
| 2667 | - if (in_array($filter, array('map','tz_map','rrule','tz_rrule'))) |
|
| 2664 | + if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule'))) |
|
| 2668 | 2665 | { |
| 2669 | 2666 | // real exception |
| 2670 | - $locts = (int)Api\DateTime::to($egw_rrule->current(),'server'); |
|
| 2667 | + $locts = (int)Api\DateTime::to($egw_rrule->current(), 'server'); |
|
| 2671 | 2668 | if ($expand_all) |
| 2672 | 2669 | { |
| 2673 | - $remts = (int)Api\DateTime::to($remote_rrule->current(),'server'); |
|
| 2670 | + $remts = (int)Api\DateTime::to($remote_rrule->current(), 'server'); |
|
| 2674 | 2671 | if ($remote) |
| 2675 | 2672 | { |
| 2676 | - $days[$locts]= $remts; |
|
| 2673 | + $days[$locts] = $remts; |
|
| 2677 | 2674 | } |
| 2678 | 2675 | else |
| 2679 | 2676 | { |
| 2680 | - $days[$remts]= $locts; |
|
| 2677 | + $days[$remts] = $locts; |
|
| 2681 | 2678 | } |
| 2682 | 2679 | } |
| 2683 | 2680 | else |
| 2684 | 2681 | { |
| 2685 | - $days[$locts]= $locts; |
|
| 2682 | + $days[$locts] = $locts; |
|
| 2686 | 2683 | } |
| 2687 | 2684 | } |
| 2688 | 2685 | if ($expand_all) |
@@ -2693,14 +2690,14 @@ discard block |
||
| 2693 | 2690 | if (!$egw_rrule->valid()) return $days; |
| 2694 | 2691 | } |
| 2695 | 2692 | $day = $egw_rrule->current(); |
| 2696 | - $locts = (int)Api\DateTime::to($day,'server'); |
|
| 2693 | + $locts = (int)Api\DateTime::to($day, 'server'); |
|
| 2697 | 2694 | $tz_exception = ($filter == 'tz_rrule'); |
| 2698 | 2695 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2699 | 2696 | // '()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)"); |
| 2700 | 2697 | if ($expand_all) |
| 2701 | 2698 | { |
| 2702 | 2699 | $remote_day = $remote_rrule->current(); |
| 2703 | - $remts = (int)Api\DateTime::to($remote_day,'server'); |
|
| 2700 | + $remts = (int)Api\DateTime::to($remote_day, 'server'); |
|
| 2704 | 2701 | // error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2705 | 2702 | // '()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)"); |
| 2706 | 2703 | } |
@@ -2719,11 +2716,11 @@ discard block |
||
| 2719 | 2716 | // '() tz exception: ' . $day->format('Ymd\THis')); |
| 2720 | 2717 | if ($remote) |
| 2721 | 2718 | { |
| 2722 | - $days[$locts]= $remts; |
|
| 2719 | + $days[$locts] = $remts; |
|
| 2723 | 2720 | } |
| 2724 | 2721 | else |
| 2725 | 2722 | { |
| 2726 | - $days[$remts]= $locts; |
|
| 2723 | + $days[$remts] = $locts; |
|
| 2727 | 2724 | } |
| 2728 | 2725 | } |
| 2729 | 2726 | } |
@@ -2745,18 +2742,18 @@ discard block |
||
| 2745 | 2742 | { |
| 2746 | 2743 | if ($remote) |
| 2747 | 2744 | { |
| 2748 | - $days[$locts]= $remts; |
|
| 2745 | + $days[$locts] = $remts; |
|
| 2749 | 2746 | } |
| 2750 | 2747 | else |
| 2751 | 2748 | { |
| 2752 | - $days[$remts]= $locts; |
|
| 2749 | + $days[$remts] = $locts; |
|
| 2753 | 2750 | } |
| 2754 | 2751 | } |
| 2755 | 2752 | } |
| 2756 | 2753 | } |
| 2757 | 2754 | elseif ($filter != 'map') |
| 2758 | 2755 | { |
| 2759 | - $days[$locts]= $locts; |
|
| 2756 | + $days[$locts] = $locts; |
|
| 2760 | 2757 | } |
| 2761 | 2758 | } |
| 2762 | 2759 | elseif (($filter == 'map' || filter == 'tz_map') && |
@@ -2766,11 +2763,11 @@ discard block |
||
| 2766 | 2763 | if ($expand_all) |
| 2767 | 2764 | { |
| 2768 | 2765 | |
| 2769 | - $days[$remts]= $locts; |
|
| 2766 | + $days[$remts] = $locts; |
|
| 2770 | 2767 | } |
| 2771 | 2768 | else |
| 2772 | 2769 | { |
| 2773 | - $days[$locts]= $locts; |
|
| 2770 | + $days[$locts] = $locts; |
|
| 2774 | 2771 | } |
| 2775 | 2772 | } |
| 2776 | 2773 | } |
@@ -2794,9 +2791,9 @@ discard block |
||
| 2794 | 2791 | */ |
| 2795 | 2792 | function status_pseudo_exception($cal_id, $recur_date, $filter) |
| 2796 | 2793 | { |
| 2797 | - static $recurrence_zero=null; |
|
| 2798 | - static $cached_id=null; |
|
| 2799 | - static $user=null; |
|
| 2794 | + static $recurrence_zero = null; |
|
| 2795 | + static $cached_id = null; |
|
| 2796 | + static $user = null; |
|
| 2800 | 2797 | |
| 2801 | 2798 | if (!isset($cached_id) || $cached_id != $cal_id) |
| 2802 | 2799 | { |
@@ -2807,8 +2804,8 @@ discard block |
||
| 2807 | 2804 | 'cal_id' => $cal_id, |
| 2808 | 2805 | 'cal_recur_date' => 0, |
| 2809 | 2806 | ); |
| 2810 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
| 2811 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2807 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
| 2808 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2812 | 2809 | { |
| 2813 | 2810 | switch ($row['cal_user_type']) |
| 2814 | 2811 | { |
@@ -2831,8 +2828,8 @@ discard block |
||
| 2831 | 2828 | 'cal_id' => $cal_id, |
| 2832 | 2829 | 'cal_recur_date' => $recur_date, |
| 2833 | 2830 | ); |
| 2834 | - foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where, |
|
| 2835 | - __LINE__,__FILE__,false,'','calendar') as $row) |
|
| 2831 | + foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where, |
|
| 2832 | + __LINE__, __FILE__, false, '', 'calendar') as $row) |
|
| 2836 | 2833 | { |
| 2837 | 2834 | switch ($row['cal_user_type']) |
| 2838 | 2835 | { |
@@ -2929,14 +2926,14 @@ discard block |
||
| 2929 | 2926 | } |
| 2930 | 2927 | $timezone = self::$tz_cache[$event['tzid']]; |
| 2931 | 2928 | } |
| 2932 | - $start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone); |
|
| 2929 | + $start_time = new Api\DateTime($event['start'], Api\DateTime::$server_timezone); |
|
| 2933 | 2930 | $start_time->setTimezone($timezone); |
| 2934 | - $end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone); |
|
| 2931 | + $end_time = new Api\DateTime($event['end'], Api\DateTime::$server_timezone); |
|
| 2935 | 2932 | $end_time->setTimezone($timezone); |
| 2936 | 2933 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2937 | 2934 | // '(): ' . $start . '-' . $end); |
| 2938 | - $start = Api\DateTime::to($start_time,'array'); |
|
| 2939 | - $end = Api\DateTime::to($end_time,'array'); |
|
| 2935 | + $start = Api\DateTime::to($start_time, 'array'); |
|
| 2936 | + $end = Api\DateTime::to($end_time, 'array'); |
|
| 2940 | 2937 | |
| 2941 | 2938 | |
| 2942 | 2939 | return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59; |
@@ -2950,7 +2947,7 @@ discard block |
||
| 2950 | 2947 | * |
| 2951 | 2948 | * @return DateTime |
| 2952 | 2949 | */ |
| 2953 | - function &startOfDay(Api\DateTime $time, $tz_id=null) |
|
| 2950 | + function &startOfDay(Api\DateTime $time, $tz_id = null) |
|
| 2954 | 2951 | { |
| 2955 | 2952 | if (empty($tz_id)) |
| 2956 | 2953 | { |
@@ -2975,14 +2972,14 @@ discard block |
||
| 2975 | 2972 | * @param int $time =null new timestamp, default current (server-)time |
| 2976 | 2973 | * @param int $modifier =null uid of the modifier, default current user |
| 2977 | 2974 | */ |
| 2978 | - function updateModified($id, $update_master=false, $time=null, $modifier=null) |
|
| 2975 | + function updateModified($id, $update_master = false, $time = null, $modifier = null) |
|
| 2979 | 2976 | { |
| 2980 | 2977 | if (is_null($time) || !$time) $time = time(); |
| 2981 | 2978 | if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id']; |
| 2982 | 2979 | |
| 2983 | 2980 | $this->db->update($this->cal_table, |
| 2984 | 2981 | array('cal_modified' => $time, 'cal_modifier' => $modifier), |
| 2985 | - array('cal_id' => $id), __LINE__,__FILE__, 'calendar'); |
|
| 2982 | + array('cal_id' => $id), __LINE__, __FILE__, 'calendar'); |
|
| 2986 | 2983 | |
| 2987 | 2984 | // if event is an exception: update modified of master, to force etag, ctag and sync-token change |
| 2988 | 2985 | if ($update_master) |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | use EGroupware\Api\Asyncservice; |
| 16 | 16 | |
| 17 | 17 | if (!isset($_REQUEST['domain'])) $_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default'; |
| 18 | -$path_to_egroupware = realpath(__DIR__.'/..'); // need to be adapted if this script is moved somewhere else |
|
| 18 | +$path_to_egroupware = realpath(__DIR__.'/..'); // need to be adapted if this script is moved somewhere else |
|
| 19 | 19 | |
| 20 | 20 | // remove the comment from one of the following lines to enable loging |
| 21 | 21 | // define('ASYNC_LOG','C:\\async.log'); // Windows |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | if (defined('ASYNC_LOG')) |
| 26 | 26 | { |
| 27 | 27 | $msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].": asyncservice started\n"; |
| 28 | - $f = fopen(ASYNC_LOG,'a+'); |
|
| 29 | - fwrite($f,$msg); |
|
| 28 | + $f = fopen(ASYNC_LOG, 'a+'); |
|
| 29 | + fwrite($f, $msg); |
|
| 30 | 30 | fclose($f); |
| 31 | 31 | } |
| 32 | 32 | $GLOBALS['egw_info']['flags'] = array( |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | if (defined('ASYNC_LOG')) |
| 45 | 45 | { |
| 46 | - $f = fopen(ASYNC_LOG,'a+'); |
|
| 47 | - fwrite($f,$msg); |
|
| 46 | + $f = fopen(ASYNC_LOG, 'a+'); |
|
| 47 | + fwrite($f, $msg); |
|
| 48 | 48 | fclose($f); |
| 49 | 49 | } |
| 50 | 50 | die($msg); |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | if (defined('ASYNC_LOG')) |
| 65 | 65 | { |
| 66 | - $f = fopen(ASYNC_LOG,'a+'); |
|
| 67 | - fwrite($f,$msg); |
|
| 66 | + $f = fopen(ASYNC_LOG, 'a+'); |
|
| 67 | + fwrite($f, $msg); |
|
| 68 | 68 | fclose($f); |
| 69 | 69 | } |
| 70 | 70 | die($msg); |
@@ -75,8 +75,7 @@ discard block |
||
| 75 | 75 | $async = new Asyncservice(); |
| 76 | 76 | $num = $async->check_run(isset($_REQUEST['run_by']) ? $_REQUEST['run_by'] : 'crontab'); |
| 77 | 77 | |
| 78 | -$msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].': '.($num === false ? 'An error occured: can not obtain semaphore!' : |
|
| 79 | - ($num ? "$num job(s) executed" : 'Nothing to execute'))."\n\n"; |
|
| 78 | +$msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].': '.($num === false ? 'An error occured: can not obtain semaphore!' : ($num ? "$num job(s) executed" : 'Nothing to execute'))."\n\n"; |
|
| 80 | 79 | |
| 81 | 80 | if (isset($_SERVER['HTTP_HOST'])) |
| 82 | 81 | { |
@@ -87,7 +86,7 @@ discard block |
||
| 87 | 86 | |
| 88 | 87 | if (defined('ASYNC_LOG')) |
| 89 | 88 | { |
| 90 | - $f = fopen(ASYNC_LOG,'a+'); |
|
| 91 | - fwrite($f,$msg); |
|
| 89 | + $f = fopen(ASYNC_LOG, 'a+'); |
|
| 90 | + fwrite($f, $msg); |
|
| 92 | 91 | fclose($f); |
| 93 | 92 | } |
@@ -14,7 +14,10 @@ |
||
| 14 | 14 | |
| 15 | 15 | use EGroupware\Api\Asyncservice; |
| 16 | 16 | |
| 17 | -if (!isset($_REQUEST['domain'])) $_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default'; |
|
| 17 | +if (!isset($_REQUEST['domain'])) |
|
| 18 | +{ |
|
| 19 | + $_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default'; |
|
| 20 | +} |
|
| 18 | 21 | $path_to_egroupware = realpath(__DIR__.'/..'); // need to be adapted if this script is moved somewhere else |
| 19 | 22 | |
| 20 | 23 | // remove the comment from one of the following lines to enable loging |
@@ -28,17 +28,17 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | include '../header.inc.php'; |
| 30 | 30 | |
| 31 | -$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i',$_GET['template']) ? $_GET['template'] : null, $_GET['svg']), |
|
| 32 | - JSON_FORCE_OBJECT | // export empty php-arrays as empty objects, not empty arrays |
|
| 33 | - JSON_UNESCAPED_SLASHES | // do not escape slashes, smaller and better readable |
|
| 31 | +$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i', $_GET['template']) ? $_GET['template'] : null, $_GET['svg']), |
|
| 32 | + JSON_FORCE_OBJECT|// export empty php-arrays as empty objects, not empty arrays |
|
| 33 | + JSON_UNESCAPED_SLASHES|// do not escape slashes, smaller and better readable |
|
| 34 | 34 | (!empty($_GET['debug']) ? JSON_PRETTY_PRINT : 0)); |
| 35 | 35 | |
| 36 | 36 | // use an etag over the image mapp |
| 37 | 37 | $etag = '"'.md5($content).'"'; |
| 38 | 38 | |
| 39 | 39 | // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header |
| 40 | -Api\Session::cache_control(86400); // cache for one day |
|
| 41 | -Header('Content-Type: '.(empty($_GET['debug'])?'text/javascript':'application/json').'; charset=utf-8'); |
|
| 40 | +Api\Session::cache_control(86400); // cache for one day |
|
| 41 | +Header('Content-Type: '.(empty($_GET['debug']) ? 'text/javascript' : 'application/json').'; charset=utf-8'); |
|
| 42 | 42 | Header('ETag: '.$etag); |
| 43 | 43 | |
| 44 | 44 | // if servers send a If-None-Match header, response with 304 Not Modified, if etag matches |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | if (empty($_GET['debug'])) $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; |
| 52 | 52 | |
| 53 | 53 | // we run our own gzip compression, to set a correct Content-Length of the encoded content |
| 54 | -if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 54 | +if (in_array('gzip', explode(',', $_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
|
| 55 | 55 | { |
| 56 | 56 | $content = gzencode($content); |
| 57 | 57 | header('Content-Encoding: gzip'); |
@@ -48,7 +48,10 @@ |
||
| 48 | 48 | exit; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if (empty($_GET['debug'])) $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; |
|
| 51 | +if (empty($_GET['debug'])) |
|
| 52 | +{ |
|
| 53 | + $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n"; |
|
| 54 | +} |
|
| 52 | 55 | |
| 53 | 56 | // we run our own gzip compression, to set a correct Content-Length of the encoded content |
| 54 | 57 | if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode')) |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | private function parse_file($file) |
| 81 | 81 | { |
| 82 | 82 | // file is from url and can contain query-params, eg. /phpgwapi/inc/jscalendar-setup.php?dateformat=d.m.Y&lang=de |
| 83 | - if (strpos($file,'?') !== false) list($file) = explode('?',$file); |
|
| 83 | + if (strpos($file, '?') !== false) list($file) = explode('?', $file); |
|
| 84 | 84 | |
| 85 | 85 | // Mark the file as parsed |
| 86 | 86 | $this->parsed_files[$file] = true; |
@@ -284,17 +284,17 @@ discard block |
||
| 284 | 284 | * @returns the correct path on the server if the file is found or false, if the |
| 285 | 285 | * file is not found or no further processing is needed. |
| 286 | 286 | */ |
| 287 | - private function translate_params($package, $file=null, $app='api') |
|
| 287 | + private function translate_params($package, $file = null, $app = 'api') |
|
| 288 | 288 | { |
| 289 | 289 | if ($package[0] == '/' && is_readable(EGW_SERVER_ROOT.parse_url($path = $package, PHP_URL_PATH)) || |
| 290 | 290 | // fix old /phpgwapi/js/ path by replacing it with /api/js/ |
| 291 | 291 | substr($package, 0, 13) == '/phpgwapi/js/' && is_readable(EGW_SERVER_ROOT.parse_url($path = str_replace('/phpgwapi/js/', '/api/js/', $package), PHP_URL_PATH)) || |
| 292 | 292 | $package[0] == '/' && is_readable(EGW_SERVER_ROOT.($path = $package)) || |
| 293 | - $package == '.' && is_readable(EGW_SERVER_ROOT.($path="/$app/js/$file.js")) || |
|
| 294 | - is_readable(EGW_SERVER_ROOT.($path="/$app/js/$package/$file.js")) || |
|
| 293 | + $package == '.' && is_readable(EGW_SERVER_ROOT.($path = "/$app/js/$file.js")) || |
|
| 294 | + is_readable(EGW_SERVER_ROOT.($path = "/$app/js/$package/$file.js")) || |
|
| 295 | 295 | // fix not found by using app='api' |
| 296 | - $app != 'api' && is_readable(EGW_SERVER_ROOT.($path="/api/js/$package/$file.js")) || |
|
| 297 | - $app != 'phpgwapi' && is_readable(EGW_SERVER_ROOT.($path="/phpgwapi/js/$package/$file.js"))) |
|
| 296 | + $app != 'api' && is_readable(EGW_SERVER_ROOT.($path = "/api/js/$package/$file.js")) || |
|
| 297 | + $app != 'phpgwapi' && is_readable(EGW_SERVER_ROOT.($path = "/phpgwapi/js/$package/$file.js"))) |
|
| 298 | 298 | { |
| 299 | 299 | // normalise /./ to / |
| 300 | 300 | $path = str_replace('/./', '/', $path); |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | // adding the ctime to all js files... |
| 306 | 306 | if (is_array($file)) |
| 307 | 307 | { |
| 308 | - foreach($file as $name => $val) |
|
| 308 | + foreach ($file as $name => $val) |
|
| 309 | 309 | { |
| 310 | 310 | $args .= (empty($args) ? '?' : '&').$name.'='.urlencode($val); |
| 311 | 311 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @param array $files |
| 376 | 376 | * @param boolean $clear_files =false if true clear list of files, before including given ones |
| 377 | 377 | */ |
| 378 | - public function include_files(array $files, $clear_files=false) |
|
| 378 | + public function include_files(array $files, $clear_files = false) |
|
| 379 | 379 | { |
| 380 | 380 | if ($clear_files) $this->included_files = array(); |
| 381 | 381 | |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | * @param boolean $clear_files =false if true clear list of files after returning them |
| 392 | 392 | * @return array |
| 393 | 393 | */ |
| 394 | - public function get_included_files($clear_files=false) |
|
| 394 | + public function get_included_files($clear_files = false) |
|
| 395 | 395 | { |
| 396 | 396 | $ret = array_keys($this->included_files); |
| 397 | 397 | if ($clear_files) $this->included_files = array(); |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | $paths = !empty($_GET['path']) ? (array)$_GET['path'] : (array)'/stylite/js/filemanager/filemanager.js'; |
| 426 | 426 | |
| 427 | - foreach($paths as $path) |
|
| 427 | + foreach ($paths as $path) |
|
| 428 | 428 | { |
| 429 | 429 | echo "\t<h1>".htmlspecialchars($path)."</h1>\n"; |
| 430 | 430 | $mgr->include_js_file($path); |
@@ -80,7 +80,10 @@ discard block |
||
| 80 | 80 | private function parse_file($file) |
| 81 | 81 | { |
| 82 | 82 | // file is from url and can contain query-params, eg. /phpgwapi/inc/jscalendar-setup.php?dateformat=d.m.Y&lang=de |
| 83 | - if (strpos($file,'?') !== false) list($file) = explode('?',$file); |
|
| 83 | + if (strpos($file,'?') !== false) |
|
| 84 | + { |
|
| 85 | + list($file) = explode('?',$file); |
|
| 86 | + } |
|
| 84 | 87 | |
| 85 | 88 | // Mark the file as parsed |
| 86 | 89 | $this->parsed_files[$file] = true; |
@@ -326,12 +329,15 @@ discard block |
||
| 326 | 329 | } |
| 327 | 330 | } |
| 328 | 331 | |
| 329 | - if (self::$DEBUG_MODE) // DEBUG_MODE is currently ALWAYS true. Comment this code out if you don't want error messages. |
|
| 332 | + if (self::$DEBUG_MODE) |
|
| 333 | + { |
|
| 334 | + // DEBUG_MODE is currently ALWAYS true. Comment this code out if you don't want error messages. |
|
| 330 | 335 | { |
| 331 | 336 | //error_log(__METHOD__."($package,$file,$app) $path NOT found".($this->debug_processing_file ? " while processing file '{$this->debug_processing_file}'." : "!").' '.function_backtrace()); |
| 332 | 337 | } |
| 333 | 338 | |
| 334 | 339 | return false; |
| 340 | + } |
|
| 335 | 341 | } |
| 336 | 342 | |
| 337 | 343 | /** |
@@ -377,7 +383,10 @@ discard block |
||
| 377 | 383 | */ |
| 378 | 384 | public function include_files(array $files, $clear_files=false) |
| 379 | 385 | { |
| 380 | - if ($clear_files) $this->included_files = array(); |
|
| 386 | + if ($clear_files) |
|
| 387 | + { |
|
| 388 | + $this->included_files = array(); |
|
| 389 | + } |
|
| 381 | 390 | |
| 382 | 391 | foreach ($files as $file) |
| 383 | 392 | { |
@@ -394,7 +403,10 @@ discard block |
||
| 394 | 403 | public function get_included_files($clear_files=false) |
| 395 | 404 | { |
| 396 | 405 | $ret = array_keys($this->included_files); |
| 397 | - if ($clear_files) $this->included_files = array(); |
|
| 406 | + if ($clear_files) |
|
| 407 | + { |
|
| 408 | + $this->included_files = array(); |
|
| 409 | + } |
|
| 398 | 410 | return $ret; |
| 399 | 411 | } |
| 400 | 412 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * - function-name like set_var to get eg. all assignments or |
| 33 | 33 | * - handle- / variable-names - if you are only interested in some variables ;-) |
| 34 | 34 | */ |
| 35 | - var $debug = False; // array('cat_list','cat_list_t'); |
|
| 35 | + var $debug = False; // array('cat_list','cat_list_t'); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * $file[handle] = 'filename'; |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | */ |
| 129 | 129 | function set_file($handle, $filename = '') |
| 130 | 130 | { |
| 131 | - if ($this->debug && $this->check_debug('set_file',$handle,$filename)) |
|
| 131 | + if ($this->debug && $this->check_debug('set_file', $handle, $filename)) |
|
| 132 | 132 | { |
| 133 | - echo "<p>Template::set_file('".print_r($handle,true)."','$filename')</p>\n"; |
|
| 133 | + echo "<p>Template::set_file('".print_r($handle, true)."','$filename')</p>\n"; |
|
| 134 | 134 | } |
| 135 | 135 | if (!is_array($handle)) |
| 136 | 136 | { |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | else |
| 145 | 145 | { |
| 146 | - foreach($handle as $h => $f) |
|
| 146 | + foreach ($handle as $h => $f) |
|
| 147 | 147 | { |
| 148 | 148 | $this->file[$h] = $this->filename($f); |
| 149 | 149 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | function set_block($parent, $handle, $name = '') |
| 162 | 162 | { |
| 163 | - if ($this->debug && $this->check_debug('set_block',$parent,$handle,$name)) |
|
| 163 | + if ($this->debug && $this->check_debug('set_block', $parent, $handle, $name)) |
|
| 164 | 164 | { |
| 165 | 165 | echo "<p>Template::set_block('$parent','$handle','$name')</p>\n"; |
| 166 | 166 | } |
@@ -177,14 +177,14 @@ discard block |
||
| 177 | 177 | $qhandle = preg_quote($handle); |
| 178 | 178 | $reg = "/<!--\\s+BEGIN $qhandle\\s+-->(.*)\n\\s*<!--\\s+END $qhandle\\s+-->/s"; |
| 179 | 179 | $match = null; |
| 180 | - if (!preg_match($reg,$str,$match)) |
|
| 180 | + if (!preg_match($reg, $str, $match)) |
|
| 181 | 181 | { |
| 182 | 182 | // unfortunaly some apps set non-existing blocks, therefor I have to disable this diagnostics again for now |
| 183 | 183 | $this->halt("set_block: unable to find block '$handle' in '$parent'=<pre>".htmlspecialchars($str)."</pre> this->root=$this->root"); |
| 184 | 184 | // return False; |
| 185 | 185 | } |
| 186 | - $this->set_var($handle,$match[1]); |
|
| 187 | - $this->set_var($parent,preg_replace($reg, '{' . "$name}",$str)); |
|
| 186 | + $this->set_var($handle, $match[1]); |
|
| 187 | + $this->set_var($parent, preg_replace($reg, '{'."$name}", $str)); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /* public: set_var(array $values) |
@@ -205,18 +205,18 @@ discard block |
||
| 205 | 205 | $varname => $value |
| 206 | 206 | ); |
| 207 | 207 | } |
| 208 | - foreach($varname as $k => $v) |
|
| 208 | + foreach ($varname as $k => $v) |
|
| 209 | 209 | { |
| 210 | 210 | if (!empty($k)) |
| 211 | 211 | { |
| 212 | - if ($this->debug && $this->check_debug('set_var',$k)) |
|
| 212 | + if ($this->debug && $this->check_debug('set_var', $k)) |
|
| 213 | 213 | { |
| 214 | 214 | echo "<p>Template::set_var('$k','$v')</p>\n"; |
| 215 | 215 | } |
| 216 | 216 | $this->varkeys[$k] = $this->varname($k); |
| 217 | 217 | $this->varvals[$k] = $this->egroupware_hack ? str_replace( |
| 218 | - array('phpGroupWare','www.phpgroupware.org'), |
|
| 219 | - array('eGroupWare','www.eGroupWare.org'),$v |
|
| 218 | + array('phpGroupWare', 'www.phpgroupware.org'), |
|
| 219 | + array('eGroupWare', 'www.eGroupWare.org'), $v |
|
| 220 | 220 | ) : $v; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | */ |
| 231 | 231 | function subst($handle) |
| 232 | 232 | { |
| 233 | - if ($this->debug && $this->check_debug('subst',$handle)) |
|
| 233 | + if ($this->debug && $this->check_debug('subst', $handle)) |
|
| 234 | 234 | { |
| 235 | 235 | echo "<p>Template::subst('$handle')</p>\n"; |
| 236 | 236 | } |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $str = $this->get_var($handle); |
| 244 | - foreach($this->varkeys as $k => $v) |
|
| 244 | + foreach ($this->varkeys as $k => $v) |
|
| 245 | 245 | { |
| 246 | 246 | $str = str_replace($v, $this->varvals[$k], $str); |
| 247 | 247 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $str = $this->subst($handle); |
| 277 | 277 | if ($append) |
| 278 | 278 | { |
| 279 | - $this->set_var($target, $this->get_var($target) . $str); |
|
| 279 | + $this->set_var($target, $this->get_var($target).$str); |
|
| 280 | 280 | } |
| 281 | 281 | else |
| 282 | 282 | { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | else |
| 287 | 287 | { |
| 288 | - foreach($handle as $h) |
|
| 288 | + foreach ($handle as $h) |
|
| 289 | 289 | { |
| 290 | 290 | $str = $this->subst($h); |
| 291 | 291 | $this->set_var($target, $str); |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | */ |
| 333 | 333 | function get_vars() |
| 334 | 334 | { |
| 335 | - foreach(array_keys($this->varkeys) as $k) |
|
| 335 | + foreach (array_keys($this->varkeys) as $k) |
|
| 336 | 336 | { |
| 337 | 337 | $result[$k] = $this->varvals[$k]; |
| 338 | 338 | } |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | } |
| 354 | 354 | else |
| 355 | 355 | { |
| 356 | - foreach(array_keys($varname) as $k) |
|
| 356 | + foreach (array_keys($varname) as $k) |
|
| 357 | 357 | { |
| 358 | 358 | $result[$k] = $this->varvals[$k]; |
| 359 | 359 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | { |
| 383 | 383 | return false; |
| 384 | 384 | } |
| 385 | - foreach($m as $v) |
|
| 385 | + foreach ($m as $v) |
|
| 386 | 386 | { |
| 387 | 387 | if (!isset($this->varkeys[$v])) |
| 388 | 388 | { |
@@ -448,15 +448,15 @@ discard block |
||
| 448 | 448 | * @param string $root ='' default $this->root |
| 449 | 449 | * @param int $time =1 |
| 450 | 450 | */ |
| 451 | - protected function filename($filename,$root='',$time=1) |
|
| 451 | + protected function filename($filename, $root = '', $time = 1) |
|
| 452 | 452 | { |
| 453 | - if($root == '') |
|
| 453 | + if ($root == '') |
|
| 454 | 454 | { |
| 455 | 455 | $root = $this->root; |
| 456 | 456 | } |
| 457 | - if(substr($filename, 0, 1) != '/') |
|
| 457 | + if (substr($filename, 0, 1) != '/') |
|
| 458 | 458 | { |
| 459 | - $new_filename = $root . '/' . $filename; |
|
| 459 | + $new_filename = $root.'/'.$filename; |
|
| 460 | 460 | } |
| 461 | 461 | else |
| 462 | 462 | { |
@@ -465,14 +465,14 @@ discard block |
||
| 465 | 465 | |
| 466 | 466 | if (!file_exists($new_filename)) |
| 467 | 467 | { |
| 468 | - if($time==2) |
|
| 468 | + if ($time == 2) |
|
| 469 | 469 | { |
| 470 | 470 | $this->halt("filename: file $new_filename does not exist."); |
| 471 | 471 | } |
| 472 | 472 | else |
| 473 | 473 | { |
| 474 | - $new_root = dirname($root) . DIRECTORY_SEPARATOR . 'default'; |
|
| 475 | - $new_filename = $this->filename(str_replace($root.'/','',$new_filename),$new_root,2); |
|
| 474 | + $new_root = dirname($root).DIRECTORY_SEPARATOR.'default'; |
|
| 475 | + $new_filename = $this->filename(str_replace($root.'/', '', $new_filename), $new_root, 2); |
|
| 476 | 476 | } |
| 477 | 477 | } |
| 478 | 478 | return $new_filename; |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | */ |
| 492 | 492 | function loadfile($handle) |
| 493 | 493 | { |
| 494 | - if ($this->debug && $this->check_debug('loadfile',$handle)) |
|
| 494 | + if ($this->debug && $this->check_debug('loadfile', $handle)) |
|
| 495 | 495 | { |
| 496 | - echo "<p>Template::loadfile('$handle') file=<pre>\n".print_r($this->file,True)."</pre>\n"; |
|
| 496 | + echo "<p>Template::loadfile('$handle') file=<pre>\n".print_r($this->file, True)."</pre>\n"; |
|
| 497 | 497 | echo "<p>backtrace: ".function_backtrace()."</p>\n"; |
| 498 | 498 | } |
| 499 | 499 | if (isset($this->varkeys[$handle]) && !empty($this->varvals[$handle])) |
@@ -502,9 +502,9 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | if (!isset($this->file[$handle])) |
| 504 | 504 | { |
| 505 | - if ($this->debug && $this->check_debug('loadfile',$handle)) |
|
| 505 | + if ($this->debug && $this->check_debug('loadfile', $handle)) |
|
| 506 | 506 | { |
| 507 | - echo "varkeys =<pre>".print_r($this->varkeys,True)."</pre>varvals =<pre>".print_r($this->varvals,True)."</pre>\n"; |
|
| 507 | + echo "varkeys =<pre>".print_r($this->varkeys, True)."</pre>varvals =<pre>".print_r($this->varvals, True)."</pre>\n"; |
|
| 508 | 508 | } |
| 509 | 509 | $this->halt("loadfile: $handle is not a valid handle."); |
| 510 | 510 | return false; |
@@ -549,10 +549,10 @@ discard block |
||
| 549 | 549 | { |
| 550 | 550 | if (!$this->debug) return False; |
| 551 | 551 | |
| 552 | - foreach(func_get_args() as $arg) |
|
| 552 | + foreach (func_get_args() as $arg) |
|
| 553 | 553 | { |
| 554 | 554 | if (!is_array($this->debug) && $this->debug === $arg || |
| 555 | - (is_array($this->debug) && (@$this->debug[$arg] || in_array($arg,$this->debug,True)))) |
|
| 555 | + (is_array($this->debug) && (@$this->debug[$arg] || in_array($arg, $this->debug, True)))) |
|
| 556 | 556 | { |
| 557 | 557 | return True; |
| 558 | 558 | } |
@@ -601,8 +601,8 @@ discard block |
||
| 601 | 601 | { |
| 602 | 602 | $GLOBALS['egw_info']['server']['template_set'] = 'idots'; |
| 603 | 603 | } |
| 604 | - $tpldir = EGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS['egw_info']['server']['template_set']; |
|
| 605 | - $tpldir_default = EGW_SERVER_ROOT . '/' . $appname . '/templates/default'; |
|
| 604 | + $tpldir = EGW_SERVER_ROOT.'/'.$appname.'/templates/'.$GLOBALS['egw_info']['server']['template_set']; |
|
| 605 | + $tpldir_default = EGW_SERVER_ROOT.'/'.$appname.'/templates/default'; |
|
| 606 | 606 | |
| 607 | 607 | if (@is_dir($tpldir)) |
| 608 | 608 | { |
@@ -547,7 +547,10 @@ |
||
| 547 | 547 | |
| 548 | 548 | function check_debug() |
| 549 | 549 | { |
| 550 | - if (!$this->debug) return False; |
|
| 550 | + if (!$this->debug) |
|
| 551 | + { |
|
| 552 | + return False; |
|
| 553 | + } |
|
| 551 | 554 | |
| 552 | 555 | foreach(func_get_args() as $arg) |
| 553 | 556 | { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param string $parent name of tempalte containing $handle |
| 157 | 157 | * @param string $handle name of part |
| 158 | 158 | * @param string $name name of variable/placeholder |
| 159 | - * @return boolean |
|
| 159 | + * @return false|null |
|
| 160 | 160 | */ |
| 161 | 161 | function set_block($parent, $handle, $name = '') |
| 162 | 162 | { |
@@ -311,6 +311,8 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | /** |
| 313 | 313 | * This is short for finish parse |
| 314 | + * @param string $target |
|
| 315 | + * @param string $handle |
|
| 314 | 316 | */ |
| 315 | 317 | function fp($target, $handle, $append = False) |
| 316 | 318 | { |
@@ -319,6 +321,8 @@ discard block |
||
| 319 | 321 | |
| 320 | 322 | /** |
| 321 | 323 | * This is a short cut for print finish parse |
| 324 | + * @param string $target |
|
| 325 | + * @param string $handle |
|
| 322 | 326 | */ |
| 323 | 327 | function pfp($target, $handle, $append = False) |
| 324 | 328 | { |
@@ -365,6 +369,7 @@ discard block |
||
| 365 | 369 | * Return undefined variables/placeholders of a handle |
| 366 | 370 | * |
| 367 | 371 | * @param string handle handle of a template |
| 372 | + * @param string $handle |
|
| 368 | 373 | * @return array|boolean array with undefined variables as key and value, or false if none |
| 369 | 374 | */ |
| 370 | 375 | function get_undefined($handle) |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @param array $content |
| 34 | 34 | */ |
| 35 | - function popup ($content=null) |
|
| 35 | + function popup($content = null) |
|
| 36 | 36 | { |
| 37 | 37 | // check and if not done register tutorial_menu hook |
| 38 | 38 | if (!Api\Hooks::exists('sidebox_all', 'api') || |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | if (!is_array($content)) |
| 49 | 49 | { |
| 50 | 50 | // Get tutorial object id |
| 51 | - $tuid_indx = explode('-',$_GET['tuid']); |
|
| 51 | + $tuid_indx = explode('-', $_GET['tuid']); |
|
| 52 | 52 | $appName = $tuid_indx[0]; |
| 53 | 53 | $lang = $tuid_indx[1]; |
| 54 | 54 | $id = $tuid_indx[2]; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $appName = $content['list']['apps']; |
| 59 | 59 | $lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang']; |
| 60 | - $id ="0"; |
|
| 60 | + $id = "0"; |
|
| 61 | 61 | } |
| 62 | 62 | // read tutorials json file to fetch data |
| 63 | 63 | $tutorials = json_decode(self::getJsonData(), true); |
@@ -74,8 +74,7 @@ discard block |
||
| 74 | 74 | if (in_array($appName, array_keys($GLOBALS['egw_info']['user']['apps'])) || $appName === "introduction") |
| 75 | 75 | { |
| 76 | 76 | // fallback to english video |
| 77 | - $tutorial = $tutorials[$appName][$lang][$id]? $tutorials[$appName][$lang][$id]: |
|
| 78 | - $tutorials[$appName]['en'][$id]; |
|
| 77 | + $tutorial = $tutorials[$appName][$lang][$id] ? $tutorials[$appName][$lang][$id] : $tutorials[$appName]['en'][$id]; |
|
| 79 | 78 | |
| 80 | 79 | $list = array( |
| 81 | 80 | 'apps' => $appName, |
@@ -86,7 +85,7 @@ discard block |
||
| 86 | 85 | $v ['onclick'] = 'app[egw.app_name()].tutorial_videoOnClick("'.$v['src'].'")'; |
| 87 | 86 | array_push($list, $v); |
| 88 | 87 | } |
| 89 | - $content = array ( |
|
| 88 | + $content = array( |
|
| 90 | 89 | 'src' => $tutorial['src'], |
| 91 | 90 | 'title' => $tutorial['title'], |
| 92 | 91 | 'desc' => $tutorial['desc'], |
@@ -137,13 +136,13 @@ discard block |
||
| 137 | 136 | public static function tutorial_menu() |
| 138 | 137 | { |
| 139 | 138 | if (Api\Header\UserAgent::mobile()) return; |
| 140 | - $tutorials = json_decode(self::getJsonData(),true); |
|
| 139 | + $tutorials = json_decode(self::getJsonData(), true); |
|
| 141 | 140 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 142 | 141 | if (!is_array($tutorials[$appname])) return false; |
| 143 | 142 | if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable'] |
| 144 | 143 | || $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro') |
| 145 | 144 | { |
| 146 | - $file = Array ( |
|
| 145 | + $file = Array( |
|
| 147 | 146 | array( |
| 148 | 147 | 'text' => '<div id="egw_tutorial_'.$appname.'_sidebox" class="egwTutorial"/>', |
| 149 | 148 | 'no_lang' => true, |
@@ -65,7 +65,10 @@ discard block |
||
| 65 | 65 | foreach (array_keys($tutorials) as $app) |
| 66 | 66 | { |
| 67 | 67 | // show only apps user has access to them |
| 68 | - if (in_array($app, array_keys($GLOBALS['egw_info']['user']['apps']))) $apps [$app] = $app; |
|
| 68 | + if (in_array($app, array_keys($GLOBALS['egw_info']['user']['apps']))) |
|
| 69 | + { |
|
| 70 | + $apps [$app] = $app; |
|
| 71 | + } |
|
| 69 | 72 | } |
| 70 | 73 | $sel_options = array( |
| 71 | 74 | 'apps' => $apps, |
@@ -122,7 +125,10 @@ discard block |
||
| 122 | 125 | { |
| 123 | 126 | $json = file_get_contents('http://www.egroupware.de/videos/tutorials.json'); |
| 124 | 127 | // Fallback tutorials.json |
| 125 | - if (!$json) $json = file_get_contents('api/setup/tutorials.json'); |
|
| 128 | + if (!$json) |
|
| 129 | + { |
|
| 130 | + $json = file_get_contents('api/setup/tutorials.json'); |
|
| 131 | + } |
|
| 126 | 132 | // Cache the json object for two hours |
| 127 | 133 | Api\Cache::setCache(Api\Cache::TREE, __CLASS__, 'egw_tutorial_json', $json, 7200); |
| 128 | 134 | } |
@@ -136,10 +142,16 @@ discard block |
||
| 136 | 142 | */ |
| 137 | 143 | public static function tutorial_menu() |
| 138 | 144 | { |
| 139 | - if (Api\Header\UserAgent::mobile()) return; |
|
| 145 | + if (Api\Header\UserAgent::mobile()) |
|
| 146 | + { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 140 | 149 | $tutorials = json_decode(self::getJsonData(),true); |
| 141 | 150 | $appname = $GLOBALS['egw_info']['flags']['currentapp']; |
| 142 | - if (!is_array($tutorials[$appname])) return false; |
|
| 151 | + if (!is_array($tutorials[$appname])) |
|
| 152 | + { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 143 | 155 | if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable'] |
| 144 | 156 | || $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro') |
| 145 | 157 | { |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable'] |
| 144 | 144 | || $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro') |
| 145 | 145 | { |
| 146 | - $file = Array ( |
|
| 146 | + $file = array ( |
|
| 147 | 147 | array( |
| 148 | 148 | 'text' => '<div id="egw_tutorial_'.$appname.'_sidebox" class="egwTutorial"/>', |
| 149 | 149 | 'no_lang' => true, |