@@ -179,7 +179,10 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public function week_number($time) |
| 181 | 181 | { |
| 182 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 182 | + if (!is_a($time,'DateTime')) |
|
| 183 | + { |
|
| 184 | + $time = new Api\DateTime($time); |
|
| 185 | + } |
|
| 183 | 186 | |
| 184 | 187 | // if week does not start Monday and $time is Sunday --> add one day |
| 185 | 188 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -237,7 +240,8 @@ discard block |
||
| 237 | 240 | $tmpl = new Etemplate('calendar.toolbar'); |
| 238 | 241 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 239 | 242 | // Adjust toolbar for mobile |
| 240 | - if(Api\Header\UserAgent::mobile()){ |
|
| 243 | + if(Api\Header\UserAgent::mobile()) |
|
| 244 | + { |
|
| 241 | 245 | $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
| 242 | 246 | $tmpl->setElementAttribute('toolbar','view_range', '3'); |
| 243 | 247 | } |
@@ -396,10 +400,12 @@ discard block |
||
| 396 | 400 | { |
| 397 | 401 | foreach (array_keys($actions) as $key) |
| 398 | 402 | { |
| 399 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 403 | + if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) |
|
| 404 | + { |
|
| 400 | 405 | $actions[$key]['toolbarDefault'] = false; |
| 401 | 406 | } |
| 402 | - else { |
|
| 407 | + else |
|
| 408 | + { |
|
| 403 | 409 | $actions[$key]['toolbarDefault'] = true; |
| 404 | 410 | } |
| 405 | 411 | } |
@@ -416,29 +422,38 @@ discard block |
||
| 416 | 422 | */ |
| 417 | 423 | function &planner($content = array(), $home=false) |
| 418 | 424 | { |
| 419 | - if ($this->sortby == 'month') // yearly planner with month rows |
|
| 425 | + if ($this->sortby == 'month') |
|
| 426 | + { |
|
| 427 | + // yearly planner with month rows |
|
| 420 | 428 | { |
| 421 | 429 | $this->first = $this->bo->date2array($this->date); |
| 430 | + } |
|
| 422 | 431 | $this->first['day'] = 1; |
| 423 | 432 | unset($this->first['raw']); |
| 424 | 433 | $this->last = $this->first; |
| 425 | 434 | $this->last['year']++; |
| 426 | 435 | $this->last = $this->bo->date2ts($this->last)-1; |
| 427 | 436 | } |
| 428 | - elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
|
| 437 | + elseif (!$this->planner_view || $this->planner_view == 'month') |
|
| 438 | + { |
|
| 439 | + // planner monthview |
|
| 429 | 440 | { |
| 430 | 441 | if ($this->day < 15) // show one complete month |
| 431 | 442 | { |
| 432 | 443 | $this->_week_align_month($this->first,$this->last); |
| 444 | + } |
|
| 433 | 445 | } |
| 434 | 446 | else // show 2 half month |
| 435 | 447 | { |
| 436 | 448 | $this->_week_align_month($this->first,$this->last,15); |
| 437 | 449 | } |
| 438 | 450 | } |
| 439 | - elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
|
| 451 | + elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') |
|
| 452 | + { |
|
| 453 | + // weeekview |
|
| 440 | 454 | { |
| 441 | 455 | $start = new Api\DateTime($this->date); |
| 456 | + } |
|
| 442 | 457 | $start->setWeekstart(); |
| 443 | 458 | $this->first = $start->format('ts'); |
| 444 | 459 | $this->last = $this->bo->date2array($this->first); |
@@ -477,7 +492,10 @@ discard block |
||
| 477 | 492 | $this->to_client($event); |
| 478 | 493 | } |
| 479 | 494 | |
| 480 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 495 | + if ($this->debug > 0) |
|
| 496 | + { |
|
| 497 | + $this->bo->debug_message('uiviews::planner() date=%1: first=%2, last=%3',False,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 498 | + } |
|
| 481 | 499 | |
| 482 | 500 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 483 | 501 | |
@@ -501,7 +519,10 @@ discard block |
||
| 501 | 519 | */ |
| 502 | 520 | function &month($weeks=0,$home=false) |
| 503 | 521 | { |
| 504 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 522 | + if ($this->debug > 0) |
|
| 523 | + { |
|
| 524 | + $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 525 | + } |
|
| 505 | 526 | |
| 506 | 527 | if (!$home) |
| 507 | 528 | { |
@@ -543,7 +564,10 @@ discard block |
||
| 543 | 564 | $weekNavH = "1 month"; |
| 544 | 565 | $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
| 545 | 566 | } |
| 546 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 567 | + if ($this->debug > 0) |
|
| 568 | + { |
|
| 569 | + $this->bo->debug_message('uiviews::month(%1) date=%2: first=%3, last=%4',False,$weeks,$this->date,$this->bo->date2string($this->first),$this->bo->date2string($this->last)); |
|
| 570 | + } |
|
| 547 | 571 | |
| 548 | 572 | // Loop through, using Api\DateTime to handle DST |
| 549 | 573 | $week = 0; |
@@ -588,7 +612,10 @@ discard block |
||
| 588 | 612 | $start->setWeekstart(); |
| 589 | 613 | $first = $start->format('ts'); |
| 590 | 614 | $start->setDate($this->year,$this->month+1,$day); |
| 591 | - if ($day == 1) $start->add('-1day'); |
|
| 615 | + if ($day == 1) |
|
| 616 | + { |
|
| 617 | + $start->add('-1day'); |
|
| 618 | + } |
|
| 592 | 619 | $start->setWeekstart(); |
| 593 | 620 | // now we need to calculate the end of the last day of that week |
| 594 | 621 | // as simple $last += WEEK_s - 1; does NOT work, if daylight saving changes in that week!!! |
@@ -611,19 +638,31 @@ discard block |
||
| 611 | 638 | if (!$days) |
| 612 | 639 | { |
| 613 | 640 | $days = isset($_GET['days']) ? $_GET['days'] : $this->cal_prefs['days_in_weekview']; |
| 614 | - if ($days != 5) $days = 7; |
|
| 615 | - if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
|
| 641 | + if ($days != 5) |
|
| 642 | + { |
|
| 643 | + $days = 7; |
|
| 644 | + } |
|
| 645 | + if ($days != $this->cal_prefs['days_in_weekview']) |
|
| 646 | + { |
|
| 647 | + // save the preference |
|
| 616 | 648 | { |
| 617 | 649 | $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
| 650 | + } |
|
| 618 | 651 | $GLOBALS['egw']->preferences->save_repository(); |
| 619 | 652 | $this->cal_prefs['days_in_weekview'] = $days; |
| 620 | 653 | } |
| 621 | 654 | } |
| 622 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 655 | + if ($this->debug > 0) |
|
| 656 | + { |
|
| 657 | + $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 658 | + } |
|
| 623 | 659 | |
| 624 | - if ($days <= 4) // next 4 days view |
|
| 660 | + if ($days <= 4) |
|
| 661 | + { |
|
| 662 | + // next 4 days view |
|
| 625 | 663 | { |
| 626 | 664 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 665 | + } |
|
| 627 | 666 | $this->last = strtotime("+$days days",$this->first) - 1; |
| 628 | 667 | $view = $days == 1 ? 'day' : 'day4'; |
| 629 | 668 | } |
@@ -632,12 +671,15 @@ discard block |
||
| 632 | 671 | $start = new Api\DateTime($this->date); |
| 633 | 672 | $start->setWeekstart(); |
| 634 | 673 | $wd_start = $this->first = $start->format('ts'); |
| 635 | - if ($days <= 5) // no weekend-days |
|
| 674 | + if ($days <= 5) |
|
| 675 | + { |
|
| 676 | + // no weekend-days |
|
| 636 | 677 | { |
| 637 | 678 | switch($this->cal_prefs['weekdaystarts']) |
| 638 | 679 | { |
| 639 | 680 | case 'Saturday': |
| 640 | 681 | $this->first = strtotime("+2 days",$this->first); |
| 682 | + } |
|
| 641 | 683 | break; |
| 642 | 684 | case 'Sunday': |
| 643 | 685 | $this->first = strtotime("+1 day",$this->first); |
@@ -666,7 +708,10 @@ discard block |
||
| 666 | 708 | ) + $this->search_params; |
| 667 | 709 | |
| 668 | 710 | $users = $this->search_params['users']; |
| 669 | - if (!is_array($users)) $users = array($users); |
|
| 711 | + if (!is_array($users)) |
|
| 712 | + { |
|
| 713 | + $users = array($users); |
|
| 714 | + } |
|
| 670 | 715 | |
| 671 | 716 | $content = array('view' => array()); |
| 672 | 717 | |
@@ -689,8 +734,7 @@ discard block |
||
| 689 | 734 | $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
| 690 | 735 | if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
| 691 | 736 | $days == 1 // Showing just 1 day |
| 692 | - ) |
|
| 693 | - { |
|
| 737 | + ) { |
|
| 694 | 738 | $content['view'][] = (array)$this->tagWholeDayOnTop($this->bo->search($search_params)) + |
| 695 | 739 | array('owner' => $users); |
| 696 | 740 | } |
@@ -793,7 +837,8 @@ discard block |
||
| 793 | 837 | } |
| 794 | 838 | $todo['icons'] = $icons; |
| 795 | 839 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 796 | - if($todo['edit']) { |
|
| 840 | + if($todo['edit']) |
|
| 841 | + { |
|
| 797 | 842 | $todo['edit_size'] = $todo['edit']['size']; |
| 798 | 843 | unset($todo['edit']['size']); |
| 799 | 844 | $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
@@ -914,7 +959,10 @@ discard block |
||
| 914 | 959 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 915 | 960 | foreach($actions as $id => &$action) |
| 916 | 961 | { |
| 917 | - if($id=='add') continue; |
|
| 962 | + if($id=='add') |
|
| 963 | + { |
|
| 964 | + continue; |
|
| 965 | + } |
|
| 918 | 966 | if(!$action['enabled']) |
| 919 | 967 | { |
| 920 | 968 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
@@ -120,7 +120,10 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
| 123 | - if (!is_array($event)) $event = $this->bo->read($event); |
|
| 123 | + if (!is_array($event)) |
|
| 124 | + { |
|
| 125 | + $event = $this->bo->read($event); |
|
| 126 | + } |
|
| 124 | 127 | $name = $event[self::$path_attr]; |
| 125 | 128 | } |
| 126 | 129 | $name .= self::$path_extension; |
@@ -181,10 +184,13 @@ discard block |
||
| 181 | 184 | } |
| 182 | 185 | $filter[$name] = $this->bo->now + 24*3600*($name == 'start' ? -1 : 1)*abs($value); |
| 183 | 186 | } |
| 184 | - if ($this->client_shared_uid_exceptions) // do NOT return (non-virtual) exceptions |
|
| 187 | + if ($this->client_shared_uid_exceptions) |
|
| 188 | + { |
|
| 189 | + // do NOT return (non-virtual) exceptions |
|
| 185 | 190 | { |
| 186 | 191 | $filter['query'] = array('cal_reference' => 0); |
| 187 | 192 | } |
| 193 | + } |
|
| 188 | 194 | |
| 189 | 195 | if ($path == '/calendar/') |
| 190 | 196 | { |
@@ -214,7 +220,11 @@ discard block |
||
| 214 | 220 | // when trying to request not supported components, eg. VTODO on a calendar collection |
| 215 | 221 | return true; |
| 216 | 222 | } |
| 217 | - if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback |
|
| 223 | + if ($id) |
|
| 224 | + { |
|
| 225 | + $path = dirname($path).'/'; |
|
| 226 | + } |
|
| 227 | + // caldav_name get's added anyway in the callback |
|
| 218 | 228 | |
| 219 | 229 | if ($this->debug > 1) |
| 220 | 230 | { |
@@ -276,7 +286,11 @@ discard block |
||
| 276 | 286 | $n = 0; |
| 277 | 287 | foreach($files as $file) |
| 278 | 288 | { |
| 279 | - if (!$n++) continue; // first entry is collection itself |
|
| 289 | + if (!$n++) |
|
| 290 | + { |
|
| 291 | + continue; |
|
| 292 | + } |
|
| 293 | + // first entry is collection itself |
|
| 280 | 294 | |
| 281 | 295 | $icalendar = $file['props']['calendar-data']['val']; |
| 282 | 296 | if (($start = strpos($icalendar, 'BEGIN:VEVENT')) !== false && |
@@ -320,10 +334,17 @@ discard block |
||
| 320 | 334 | */ |
| 321 | 335 | function propfind_callback($path,array $filter,$start=false) |
| 322 | 336 | { |
| 323 | - if ($this->debug) $starttime = microtime(true); |
|
| 337 | + if ($this->debug) |
|
| 338 | + { |
|
| 339 | + $starttime = microtime(true); |
|
| 340 | + } |
|
| 324 | 341 | |
| 325 | 342 | $calendar_data = $this->caldav->prop_requested('calendar-data', Api\CalDAV::CALDAV, true); |
| 326 | - if (!is_array($calendar_data)) $calendar_data = false; // not in allprop or autoindex |
|
| 343 | + if (!is_array($calendar_data)) |
|
| 344 | + { |
|
| 345 | + $calendar_data = false; |
|
| 346 | + } |
|
| 347 | + // not in allprop or autoindex |
|
| 327 | 348 | |
| 328 | 349 | $files = array(); |
| 329 | 350 | |
@@ -481,7 +502,10 @@ discard block |
||
| 481 | 502 | switch($filter['name']) |
| 482 | 503 | { |
| 483 | 504 | case 'comp-filter': |
| 484 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
| 505 | + if ($this->debug > 1) |
|
| 506 | + { |
|
| 507 | + error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'"); |
|
| 508 | + } |
|
| 485 | 509 | |
| 486 | 510 | switch($filter['attrs']['name']) |
| 487 | 511 | { |
@@ -496,14 +520,23 @@ discard block |
||
| 496 | 520 | } |
| 497 | 521 | break; |
| 498 | 522 | case 'prop-filter': |
| 499 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
| 523 | + if ($this->debug > 1) |
|
| 524 | + { |
|
| 525 | + error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'"); |
|
| 526 | + } |
|
| 500 | 527 | $prop_filter = $filter['attrs']['name']; |
| 501 | 528 | break; |
| 502 | 529 | case 'text-match': |
| 503 | - if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
| 530 | + if ($this->debug > 1) |
|
| 531 | + { |
|
| 532 | + error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'"); |
|
| 533 | + } |
|
| 504 | 534 | if (!isset($this->filter_prop2cal[strtoupper($prop_filter)])) |
| 505 | 535 | { |
| 506 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
| 536 | + if ($this->debug) |
|
| 537 | + { |
|
| 538 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored"); |
|
| 539 | + } |
|
| 507 | 540 | } |
| 508 | 541 | else |
| 509 | 542 | { |
@@ -512,10 +545,16 @@ discard block |
||
| 512 | 545 | unset($prop_filter); |
| 513 | 546 | break; |
| 514 | 547 | case 'param-filter': |
| 515 | - if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
| 548 | + if ($this->debug) |
|
| 549 | + { |
|
| 550 | + error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!"); |
|
| 551 | + } |
|
| 516 | 552 | break; |
| 517 | 553 | case 'time-range': |
| 518 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
| 554 | + if ($this->debug > 1) |
|
| 555 | + { |
|
| 556 | + error_log(__FILE__ . __METHOD__."($options[path],...) time-range={$filter['attrs']['start']}-{$filter['attrs']['end']}"); |
|
| 557 | + } |
|
| 519 | 558 | if (!empty($filter['attrs']['start'])) |
| 520 | 559 | { |
| 521 | 560 | $cal_filters['start'] = $this->vCalendar->_parseDateTime($filter['attrs']['start']); |
@@ -526,13 +565,19 @@ discard block |
||
| 526 | 565 | } |
| 527 | 566 | break; |
| 528 | 567 | default: |
| 529 | - if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
| 568 | + if ($this->debug) |
|
| 569 | + { |
|
| 570 | + error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored"); |
|
| 571 | + } |
|
| 530 | 572 | break; |
| 531 | 573 | } |
| 532 | 574 | } |
| 533 | - if (count($cal_filters) == $num_filters) // no filters set --> restore default start and end time |
|
| 575 | + if (count($cal_filters) == $num_filters) |
|
| 576 | + { |
|
| 577 | + // no filters set --> restore default start and end time |
|
| 534 | 578 | { |
| 535 | 579 | $cal_filters['start'] = $cal_start; |
| 580 | + } |
|
| 536 | 581 | $cal_filters['end'] = $cal_end; |
| 537 | 582 | } |
| 538 | 583 | } |
@@ -609,7 +654,10 @@ discard block |
||
| 609 | 654 | } |
| 610 | 655 | } |
| 611 | 656 | |
| 612 | - if ($this->debug > 1) error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
| 657 | + if ($this->debug > 1) |
|
| 658 | + { |
|
| 659 | + error_log(__FILE__ . __METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids).', cal_filters='.array2string($cal_filters)); |
|
| 660 | + } |
|
| 613 | 661 | } |
| 614 | 662 | return true; |
| 615 | 663 | } |
@@ -655,9 +703,15 @@ discard block |
||
| 655 | 703 | private function iCal(array $event,$user=null, $method=null, $expand=false) |
| 656 | 704 | { |
| 657 | 705 | static $handler = null; |
| 658 | - if (is_null($handler)) $handler = $this->_get_handler(); |
|
| 706 | + if (is_null($handler)) |
|
| 707 | + { |
|
| 708 | + $handler = $this->_get_handler(); |
|
| 709 | + } |
|
| 659 | 710 | |
| 660 | - if (!$user) $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 711 | + if (!$user) |
|
| 712 | + { |
|
| 713 | + $user = $GLOBALS['egw_info']['user']['account_id']; |
|
| 714 | + } |
|
| 661 | 715 | |
| 662 | 716 | // only return alarms in own calendar, not other users calendars |
| 663 | 717 | if ($user != $GLOBALS['egw_info']['user']['account_id']) |
@@ -673,8 +727,14 @@ discard block |
||
| 673 | 727 | { |
| 674 | 728 | if (is_array($expand)) |
| 675 | 729 | { |
| 676 | - if (isset($expand['start'])) $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
| 677 | - if (isset($expand['end'])) $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
| 730 | + if (isset($expand['start'])) |
|
| 731 | + { |
|
| 732 | + $expand['start'] = $this->vCalendar->_parseDateTime($expand['start']); |
|
| 733 | + } |
|
| 734 | + if (isset($expand['end'])) |
|
| 735 | + { |
|
| 736 | + $expand['end'] = $this->vCalendar->_parseDateTime($expand['end']); |
|
| 737 | + } |
|
| 678 | 738 | } |
| 679 | 739 | $events =& self::get_series($event['uid'], $this->bo, $expand, $user); |
| 680 | 740 | } |
@@ -698,7 +758,10 @@ discard block |
||
| 698 | 758 | */ |
| 699 | 759 | private static function &get_series($uid,calendar_bo $bo=null, $expand=false, $user=null) |
| 700 | 760 | { |
| 701 | - if (is_null($bo)) $bo = new calendar_bopdate(); |
|
| 761 | + if (is_null($bo)) |
|
| 762 | + { |
|
| 763 | + $bo = new calendar_bopdate(); |
|
| 764 | + } |
|
| 702 | 765 | |
| 703 | 766 | $params = array( |
| 704 | 767 | 'query' => array('cal_uid' => $uid), |
@@ -707,7 +770,10 @@ discard block |
||
| 707 | 770 | 'date_format' => 'server', |
| 708 | 771 | 'cfs' => array(), // read cfs as we use them to store X- attributes |
| 709 | 772 | ); |
| 710 | - if (is_array($expand)) $params += $expand; |
|
| 773 | + if (is_array($expand)) |
|
| 774 | + { |
|
| 775 | + $params += $expand; |
|
| 776 | + } |
|
| 711 | 777 | |
| 712 | 778 | if (!($events =& $bo->search($params))) |
| 713 | 779 | { |
@@ -728,12 +794,17 @@ discard block |
||
| 728 | 794 | } |
| 729 | 795 | } |
| 730 | 796 | // if recurring event starts in future behind horizont, nothing will be returned by bo::search() |
| 731 | - if (!isset($master)) $master = $bo->read($uid); |
|
| 797 | + if (!isset($master)) |
|
| 798 | + { |
|
| 799 | + $master = $bo->read($uid); |
|
| 800 | + } |
|
| 732 | 801 | |
| 733 | 802 | foreach($events as $k => &$recurrence) |
| 734 | 803 | { |
| 735 | 804 | //error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($uid)[$k]:" . array2string($recurrence)); |
| 736 | - if (!$master || $recurrence['id'] != $master['id']) // real exception |
|
| 805 | + if (!$master || $recurrence['id'] != $master['id']) |
|
| 806 | + { |
|
| 807 | + // real exception |
|
| 737 | 808 | { |
| 738 | 809 | // user is NOT participating in this exception |
| 739 | 810 | if ($user && !self::isParticipant($recurrence, $user)) |
@@ -742,6 +813,7 @@ discard block |
||
| 742 | 813 | if (!$master || !self::isParticipant($master, $user)) |
| 743 | 814 | { |
| 744 | 815 | unset($events[$k]); |
| 816 | + } |
|
| 745 | 817 | continue; |
| 746 | 818 | } |
| 747 | 819 | // otherwise mark him in this exception as rejected |
@@ -777,7 +849,10 @@ discard block |
||
| 777 | 849 | // this is a virtual exception now (no extra event/cal_id in DB) |
| 778 | 850 | //error_log('virtual exception: '.array2string($recurrence)); |
| 779 | 851 | $recurrence['recurrence'] = $recurrence['start']; |
| 780 | - if ($master) $recurrence['reference'] = $master['id']; |
|
| 852 | + if ($master) |
|
| 853 | + { |
|
| 854 | + $recurrence['reference'] = $master['id']; |
|
| 855 | + } |
|
| 781 | 856 | $recurrence['recur_type'] = MCAL_RECUR_NONE; // is set, as this is a copy of the master |
| 782 | 857 | // not for included exceptions (Lightning): $master['recur_exception'][] = $recurrence['start']; |
| 783 | 858 | } |
@@ -814,9 +889,16 @@ discard block |
||
| 814 | 889 | */ |
| 815 | 890 | function put(&$options,$id,$user=null,$prefix=null) |
| 816 | 891 | { |
| 817 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 892 | + if ($this->debug) |
|
| 893 | + { |
|
| 894 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 895 | + } |
|
| 818 | 896 | |
| 819 | - if (!$prefix) $user = null; // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 897 | + if (!$prefix) |
|
| 898 | + { |
|
| 899 | + $user = null; |
|
| 900 | + } |
|
| 901 | + // /infolog/ does not imply setting the current user (for new entries it's done anyway) |
|
| 820 | 902 | |
| 821 | 903 | // fix for iCal4OL using WinHTTP only supporting a certain header length |
| 822 | 904 | if (isset($_SERVER['HTTP_IF_SCHEDULE']) && !isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
@@ -828,7 +910,10 @@ discard block |
||
| 828 | 910 | isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])); // dont fail with 412 Precondition Failed in that case |
| 829 | 911 | if (!is_null($oldEvent) && !is_array($oldEvent)) |
| 830 | 912 | { |
| 831 | - if ($this->debug) error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 913 | + if ($this->debug) |
|
| 914 | + { |
|
| 915 | + error_log(__METHOD__.': '.print_r($oldEvent,true).function_backtrace()); |
|
| 916 | + } |
|
| 832 | 917 | return $oldEvent; |
| 833 | 918 | } |
| 834 | 919 | |
@@ -839,7 +924,10 @@ discard block |
||
| 839 | 924 | { |
| 840 | 925 | // we have no add permission on this user's calendar |
| 841 | 926 | // ToDo: create event in current users calendar and invite only $user |
| 842 | - if ($this->debug) error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 927 | + if ($this->debug) |
|
| 928 | + { |
|
| 929 | + error_log(__METHOD__."(,,$user) we have not enough rights on this calendar"); |
|
| 930 | + } |
|
| 843 | 931 | return '403 Forbidden'; |
| 844 | 932 | } |
| 845 | 933 | |
@@ -887,13 +975,19 @@ discard block |
||
| 887 | 975 | if ($this->use_schedule_tag && isset($_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH'])) |
| 888 | 976 | { |
| 889 | 977 | $schedule_tag_match = $_SERVER['HTTP_IF_SCHEDULE_TAG_MATCH']; |
| 890 | - if ($schedule_tag_match[0] == '"') $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 978 | + if ($schedule_tag_match[0] == '"') |
|
| 979 | + { |
|
| 980 | + $schedule_tag_match = substr($schedule_tag_match, 1, -1); |
|
| 981 | + } |
|
| 891 | 982 | $schedule_tag = null; |
| 892 | 983 | $this->get_etag($oldEvent, $schedule_tag); |
| 893 | 984 | |
| 894 | 985 | if ($schedule_tag_match !== $schedule_tag) |
| 895 | 986 | { |
| 896 | - if ($this->debug) error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 987 | + if ($this->debug) |
|
| 988 | + { |
|
| 989 | + error_log(__METHOD__."(,,$user) schedule_tag missmatch: given '$schedule_tag_match' != '$schedule_tag'"); |
|
| 990 | + } |
|
| 897 | 991 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 898 | 992 | $this->check_return_representation($options, $id, $user); |
| 899 | 993 | return '412 Precondition Failed'; |
@@ -908,7 +1002,10 @@ discard block |
||
| 908 | 1002 | // above can be true, if current user is not in master but just a recurrence |
| 909 | 1003 | (!$oldEvent['recur_type'] || !($series = self::get_series($oldEvent['uid'], $this->bo)))) |
| 910 | 1004 | { |
| 911 | - if ($this->debug) error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1005 | + if ($this->debug) |
|
| 1006 | + { |
|
| 1007 | + error_log(__METHOD__."(,,$user) user $user is NOT an attendee!"); |
|
| 1008 | + } |
|
| 912 | 1009 | return '403 Forbidden'; |
| 913 | 1010 | } |
| 914 | 1011 | // update only participant status and alarms of current user |
@@ -928,7 +1025,10 @@ discard block |
||
| 928 | 1025 | } |
| 929 | 1026 | foreach($series as $oldEvent) |
| 930 | 1027 | { |
| 931 | - if ($oldEvent['recurrence'] == $event['recurrence']) break; |
|
| 1028 | + if ($oldEvent['recurrence'] == $event['recurrence']) |
|
| 1029 | + { |
|
| 1030 | + break; |
|
| 1031 | + } |
|
| 932 | 1032 | } |
| 933 | 1033 | // if no exception found, check if it might be just a recurrence (no exception) |
| 934 | 1034 | if ($event['recurrence'] && $oldEvent['recurrence'] != $event['recurrence']) |
@@ -943,7 +1043,10 @@ discard block |
||
| 943 | 1043 | } |
| 944 | 1044 | } |
| 945 | 1045 | } |
| 946 | - if ($this->debug) error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event)); |
|
| 1046 | + if ($this->debug) |
|
| 1047 | + { |
|
| 1048 | + error_log(__METHOD__."(, $id, $user, '$prefix') eventId=$eventId ($oldEvent[id]), user=$user, old-status='{$oldEvent['participants'][$user]}', new-status='{$event['participants'][$user]}', recurrence=$event[recurrence]=".Api\DateTime::to($event['recurrence']).", event=".array2string($event)); |
|
| 1049 | + } |
|
| 947 | 1050 | if (isset($event['participants']) && isset($event['participants'][$user]) && |
| 948 | 1051 | $event['participants'][$user] !== $oldEvent['participants'][$user]) |
| 949 | 1052 | { |
@@ -951,13 +1054,19 @@ discard block |
||
| 951 | 1054 | // real (not virtual) exceptions use recurrence 0 in egw_cal_user.cal_recurrence! |
| 952 | 1055 | $recurrence = $eventId == $oldEvent['id'] ? $event['recurrence'] : 0)) |
| 953 | 1056 | { |
| 954 | - if ($this->debug) error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1057 | + if ($this->debug) |
|
| 1058 | + { |
|
| 1059 | + error_log(__METHOD__."(,,$user) failed to set_status($oldEvent[id], $user, '{$event['participants'][$user]}', $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1060 | + } |
|
| 955 | 1061 | return '403 Forbidden'; |
| 956 | 1062 | } |
| 957 | 1063 | else |
| 958 | 1064 | { |
| 959 | 1065 | ++$modified; |
| 960 | - if ($this->debug) error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1066 | + if ($this->debug) |
|
| 1067 | + { |
|
| 1068 | + error_log(__METHOD__."() set_status($oldEvent[id], $user, {$event['participants'][$user]} , $recurrence=".Api\DateTime::to($recurrence).')'); |
|
| 1069 | + } |
|
| 961 | 1070 | } |
| 962 | 1071 | } |
| 963 | 1072 | // import alarms, if given and changed |
@@ -967,15 +1076,21 @@ discard block |
||
| 967 | 1076 | $modified += $handler->sync_alarms($event, (array)$oldEvent['alarm'], $user); |
| 968 | 1077 | } |
| 969 | 1078 | } |
| 970 | - if (!$modified) // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 1079 | + if (!$modified) |
|
| 1080 | + { |
|
| 1081 | + // NO modififictions, or none we understood --> log it and return Ok: "204 No Content" |
|
| 971 | 1082 | { |
| 972 | 1083 | $this->caldav->log(__METHOD__."(,,$user) NO changes for current user events=".array2string($events).', old-event='.array2string($oldEvent)); |
| 973 | 1084 | } |
| 1085 | + } |
|
| 974 | 1086 | $this->put_response_headers($eventId, $options['path'], '204 No Content', self::$path_attr == 'caldav_name'); |
| 975 | 1087 | |
| 976 | 1088 | return '204 No Content'; |
| 977 | 1089 | } |
| 978 | - if ($this->debug && !isset($events)) error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1090 | + if ($this->debug && !isset($events)) |
|
| 1091 | + { |
|
| 1092 | + error_log(__METHOD__."(,,$user) only schedule-tag given for event without participants (only calendar owner) --> handle as regular PUT"); |
|
| 1093 | + } |
|
| 979 | 1094 | } |
| 980 | 1095 | if ($return_no_access) |
| 981 | 1096 | { |
@@ -1007,17 +1122,23 @@ discard block |
||
| 1007 | 1122 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, |
| 1008 | 1123 | self::etag2value($this->http_if_match), false, 0, $this->caldav->current_user_principal, $user, $charset, $id))) |
| 1009 | 1124 | { |
| 1010 | - if ($this->debug) error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1125 | + if ($this->debug) |
|
| 1126 | + { |
|
| 1127 | + error_log(__METHOD__."(,$id) eventId=$eventId: importVCal('$options[content]') returned ".array2string($cal_id)); |
|
| 1128 | + } |
|
| 1011 | 1129 | if ($eventId && $cal_id === false) |
| 1012 | 1130 | { |
| 1013 | 1131 | // ignore import failures |
| 1014 | 1132 | $cal_id = $eventId; |
| 1015 | 1133 | $retval = true; |
| 1016 | 1134 | } |
| 1017 | - elseif ($cal_id === 0) // etag failure |
|
| 1135 | + elseif ($cal_id === 0) |
|
| 1136 | + { |
|
| 1137 | + // etag failure |
|
| 1018 | 1138 | { |
| 1019 | 1139 | // honor Prefer: return=representation for 412 too (no need for client to explicitly reload) |
| 1020 | 1140 | $this->check_return_representation($options, $id, $user); |
| 1141 | + } |
|
| 1021 | 1142 | return '412 Precondition Failed'; |
| 1022 | 1143 | } |
| 1023 | 1144 | else |
@@ -1042,7 +1163,10 @@ discard block |
||
| 1042 | 1163 | */ |
| 1043 | 1164 | function post(&$options,$id,$user=null) |
| 1044 | 1165 | { |
| 1045 | - if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1166 | + if ($this->debug) |
|
| 1167 | + { |
|
| 1168 | + error_log(__METHOD__."($id, $user)".print_r($options,true)); |
|
| 1169 | + } |
|
| 1046 | 1170 | |
| 1047 | 1171 | $vCalendar = htmlspecialchars_decode($options['content']); |
| 1048 | 1172 | $charset = null; |
@@ -1097,7 +1221,10 @@ discard block |
||
| 1097 | 1221 | if (!($cal_id = $handler->importVCal($vCalendar, $eventId, null, |
| 1098 | 1222 | false, 0, $this->caldav->current_user_principal, $user, $charset))) |
| 1099 | 1223 | { |
| 1100 | - if ($this->debug) error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1224 | + if ($this->debug) |
|
| 1225 | + { |
|
| 1226 | + error_log(__METHOD__."() importVCal($eventId) returned false"); |
|
| 1227 | + } |
|
| 1101 | 1228 | } |
| 1102 | 1229 | header('ETag: "'.$this->get_etag($eventId).'"'); |
| 1103 | 1230 | } |
@@ -1265,7 +1392,10 @@ discard block |
||
| 1265 | 1392 | $org_recurrences = $exceptions = array(); |
| 1266 | 1393 | foreach(self::get_series($events[0]['uid'],$bo) as $k => $event) |
| 1267 | 1394 | { |
| 1268 | - if (!$k) $master = $event; |
|
| 1395 | + if (!$k) |
|
| 1396 | + { |
|
| 1397 | + $master = $event; |
|
| 1398 | + } |
|
| 1269 | 1399 | if ($event['recurrence']) |
| 1270 | 1400 | { |
| 1271 | 1401 | $org_recurrences[$event['recurrence']] = $event; |
@@ -1285,10 +1415,13 @@ discard block |
||
| 1285 | 1415 | |
| 1286 | 1416 | // from now on we deal with exceptions |
| 1287 | 1417 | $org_recurrence = $org_recurrences[$recurrence['recurrence']]; |
| 1288 | - if (isset($org_recurrence)) // already existing recurrence |
|
| 1418 | + if (isset($org_recurrence)) |
|
| 1419 | + { |
|
| 1420 | + // already existing recurrence |
|
| 1289 | 1421 | { |
| 1290 | 1422 | //error_log(__METHOD__.'() setting id #'.$org_recurrence['id']).' for '.$recurrence['recurrence'].' = '.date('Y-m-d H:i:s',$recurrence['recurrence']); |
| 1291 | 1423 | $recurrence['id'] = $org_recurrence['id']; |
| 1424 | + } |
|
| 1292 | 1425 | |
| 1293 | 1426 | // re-add (non-virtual) exceptions to master's recur_exception |
| 1294 | 1427 | if ($recurrence['id'] != $master['id']) |
@@ -1305,10 +1438,14 @@ discard block |
||
| 1305 | 1438 | // delete not longer existing recurrences |
| 1306 | 1439 | foreach($org_recurrences as $org_recurrence) |
| 1307 | 1440 | { |
| 1308 | - if ($org_recurrence['id'] != $master['id']) // non-virtual recurrence |
|
| 1441 | + if ($org_recurrence['id'] != $master['id']) |
|
| 1442 | + { |
|
| 1443 | + // non-virtual recurrence |
|
| 1309 | 1444 | { |
| 1310 | 1445 | //error_log(__METHOD__.'() deleting #'.$org_recurrence['id']); |
| 1311 | - $bo->delete($org_recurrence['id']); // might fail because of permissions |
|
| 1446 | + $bo->delete($org_recurrence['id']); |
|
| 1447 | + } |
|
| 1448 | + // might fail because of permissions |
|
| 1312 | 1449 | } |
| 1313 | 1450 | else // virtual recurrence |
| 1314 | 1451 | { |
@@ -1339,7 +1476,7 @@ discard block |
||
| 1339 | 1476 | if (!is_array($event = $this->_common_get_put_delete('DELETE',$options,$id,$return_no_access)) || !$return_no_access) |
| 1340 | 1477 | { |
| 1341 | 1478 | if (!$return_no_access) |
| 1342 | - { |
|
| 1479 | + { |
|
| 1343 | 1480 | // check if user is a participant or one of the groups he is a member of --> reject the meeting request |
| 1344 | 1481 | $ret = '403 Forbidden'; |
| 1345 | 1482 | $memberships = $GLOBALS['egw']->accounts->memberships($this->bo->user, true); |
@@ -1362,7 +1499,10 @@ discard block |
||
| 1362 | 1499 | { |
| 1363 | 1500 | $ret = $this->bo->delete($event['id']); |
| 1364 | 1501 | } |
| 1365 | - if ($this->debug) error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
| 1502 | + if ($this->debug) |
|
| 1503 | + { |
|
| 1504 | + error_log(__METHOD__."(,$id) return_no_access=$return_no_access, event[participants]=".array2string(is_array($event)?$event['participants']:null).", user={$this->bo->user} --> return ".array2string($ret)); |
|
| 1505 | + } |
|
| 1366 | 1506 | return $ret; |
| 1367 | 1507 | } |
| 1368 | 1508 | |
@@ -1377,16 +1517,26 @@ discard block |
||
| 1377 | 1517 | */ |
| 1378 | 1518 | function read($id) |
| 1379 | 1519 | { |
| 1380 | - if (strpos($column=self::$path_attr,'_') === false) $column = 'cal_'.$column; |
|
| 1520 | + if (strpos($column=self::$path_attr,'_') === false) |
|
| 1521 | + { |
|
| 1522 | + $column = 'cal_'.$column; |
|
| 1523 | + } |
|
| 1381 | 1524 | |
| 1382 | 1525 | $event = $this->bo->read(array($column => $id, 'cal_deleted IS NULL', 'cal_reference=0'), null, true, 'server'); |
| 1383 | - if ($event) $event = array_shift($event); // read with array as 1. param, returns an array of events! |
|
| 1526 | + if ($event) |
|
| 1527 | + { |
|
| 1528 | + $event = array_shift($event); |
|
| 1529 | + } |
|
| 1530 | + // read with array as 1. param, returns an array of events! |
|
| 1384 | 1531 | |
| 1385 | 1532 | if (!($retval = $this->bo->check_perms(calendar_bo::ACL_FREEBUSY,$event, 0, 'server')) && |
| 1386 | 1533 | // above can be true, if current user is not in master but just a recurrence |
| 1387 | 1534 | (!$event['recur_type'] || !($events = self::get_series($event['uid'], $this->bo)))) |
| 1388 | 1535 | { |
| 1389 | - if ($this->debug > 0) error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1536 | + if ($this->debug > 0) |
|
| 1537 | + { |
|
| 1538 | + error_log(__METHOD__."($id) no READ or FREEBUSY rights returning ".array2string($retval)); |
|
| 1539 | + } |
|
| 1390 | 1540 | return $retval; |
| 1391 | 1541 | } |
| 1392 | 1542 | if (!$this->bo->check_perms(Acl::READ, $event, 0, 'server')) |
@@ -1394,9 +1544,15 @@ discard block |
||
| 1394 | 1544 | $this->bo->clear_private_infos($event, array($this->bo->user, $event['owner'])); |
| 1395 | 1545 | } |
| 1396 | 1546 | // handle deleted events, as not existing |
| 1397 | - if ($event['deleted']) $event = null; |
|
| 1547 | + if ($event['deleted']) |
|
| 1548 | + { |
|
| 1549 | + $event = null; |
|
| 1550 | + } |
|
| 1398 | 1551 | |
| 1399 | - if ($this->debug > 1) error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1552 | + if ($this->debug > 1) |
|
| 1553 | + { |
|
| 1554 | + error_log(__METHOD__."($id) returning ".array2string($event)); |
|
| 1555 | + } |
|
| 1400 | 1556 | |
| 1401 | 1557 | return $event; |
| 1402 | 1558 | } |
@@ -1408,7 +1564,10 @@ discard block |
||
| 1408 | 1564 | */ |
| 1409 | 1565 | public function update_tags($entry) |
| 1410 | 1566 | { |
| 1411 | - if (!is_array($entry)) $entry = $this->read($entry); |
|
| 1567 | + if (!is_array($entry)) |
|
| 1568 | + { |
|
| 1569 | + $entry = $this->read($entry); |
|
| 1570 | + } |
|
| 1412 | 1571 | |
| 1413 | 1572 | $this->bo->update($entry, true); |
| 1414 | 1573 | } |
@@ -1422,7 +1581,10 @@ discard block |
||
| 1422 | 1581 | { |
| 1423 | 1582 | $ctag = $this->bo->get_ctag($user,$path == '/calendar/' ? 'owner' : 'default'); // default = not rejected |
| 1424 | 1583 | |
| 1425 | - if ($this->debug > 1) error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1584 | + if ($this->debug > 1) |
|
| 1585 | + { |
|
| 1586 | + error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. "($path)[$user] = $ctag"); |
|
| 1587 | + } |
|
| 1426 | 1588 | |
| 1427 | 1589 | return $ctag; |
| 1428 | 1590 | } |
@@ -1553,7 +1715,10 @@ discard block |
||
| 1553 | 1715 | $handler = new calendar_ical(); |
| 1554 | 1716 | $handler->setSupportedFields('GroupDAV',$this->agent); |
| 1555 | 1717 | $handler->supportedFields['attachments'] = true; // enabling attachments |
| 1556 | - if ($this->debug > 1) error_log("ical Handler called: " . $this->agent); |
|
| 1718 | + if ($this->debug > 1) |
|
| 1719 | + { |
|
| 1720 | + error_log("ical Handler called: " . $this->agent); |
|
| 1721 | + } |
|
| 1557 | 1722 | return $handler; |
| 1558 | 1723 | } |
| 1559 | 1724 | |
@@ -1624,7 +1789,11 @@ discard block |
||
| 1624 | 1789 | { |
| 1625 | 1790 | $calendars[$entry['grantor']] = $entry['name']; |
| 1626 | 1791 | } |
| 1627 | - if ($user > 0) unset($calendars[$user]); // skip current user |
|
| 1792 | + if ($user > 0) |
|
| 1793 | + { |
|
| 1794 | + unset($calendars[$user]); |
|
| 1795 | + } |
|
| 1796 | + // skip current user |
|
| 1628 | 1797 | } |
| 1629 | 1798 | |
| 1630 | 1799 | $settings = array(); |
@@ -166,7 +166,10 @@ discard block |
||
| 166 | 166 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
| 167 | 167 | |
| 168 | 168 | // make sure the hook for export_limit is registered |
| 169 | - if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true); |
|
| 169 | + if (!Api\Hooks::exists('export_limit','calendar')) |
|
| 170 | + { |
|
| 171 | + Api\Hooks::read(true); |
|
| 172 | + } |
|
| 170 | 173 | } |
| 171 | 174 | |
| 172 | 175 | /** |
@@ -279,11 +282,15 @@ discard block |
||
| 279 | 282 | { |
| 280 | 283 | // only change the owners of the same resource-type as given in set_state[owner] |
| 281 | 284 | $set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']); |
| 282 | - if ((string)$set_owners[0] === '0') // set exactly the specified owners (without the 0) |
|
| 285 | + if ((string)$set_owners[0] === '0') |
|
| 286 | + { |
|
| 287 | + // set exactly the specified owners (without the 0) |
|
| 283 | 288 | { |
| 284 | 289 | if ($set_states['owner'] === '0,r0') // small fix for resources |
| 285 | 290 | { |
| 286 | - $set_states['owner'] = $default; // --> set default, instead of none |
|
| 291 | + $set_states['owner'] = $default; |
|
| 292 | + } |
|
| 293 | + // --> set default, instead of none |
|
| 287 | 294 | } |
| 288 | 295 | else |
| 289 | 296 | { |
@@ -369,7 +376,10 @@ discard block |
||
| 369 | 376 | } |
| 370 | 377 | $this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index'; |
| 371 | 378 | |
| 372 | - if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 379 | + if ($this->debug > 0 || $this->debug == 'manage_states') |
|
| 380 | + { |
|
| 381 | + $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states); |
|
| 382 | + } |
|
| 373 | 383 | // save the states in the session only when we are in calendar |
| 374 | 384 | if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar') |
| 375 | 385 | { |
@@ -505,8 +515,11 @@ discard block |
||
| 505 | 515 | |
| 506 | 516 | // resources menu hooks |
| 507 | 517 | foreach ($this->bo->resources as $resource) |
| 508 | - { |
|
| 509 | - if(!is_array($resource['cal_sidebox'])) continue; |
|
| 518 | + { |
|
| 519 | + if(!is_array($resource['cal_sidebox'])) |
|
| 520 | + { |
|
| 521 | + continue; |
|
| 522 | + } |
|
| 510 | 523 | $menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']); |
| 511 | 524 | $file = ExecMethod($resource['cal_sidebox']['file'],array( |
| 512 | 525 | 'menuaction' => $this->view_menuaction, |
@@ -553,7 +566,10 @@ discard block |
||
| 553 | 566 | $sidebox = new Etemplate('calendar.sidebox'); |
| 554 | 567 | |
| 555 | 568 | $cont = $this->cal_prefs['saved_states']; |
| 556 | - if (!is_array($cont)) $cont = array(); |
|
| 569 | + if (!is_array($cont)) |
|
| 570 | + { |
|
| 571 | + $cont = array(); |
|
| 572 | + } |
|
| 557 | 573 | $cont['view'] = $this->view ? $this->view : 'week'; |
| 558 | 574 | $cont['date'] = $this->date ? $this->date : Api\DateTime(); |
| 559 | 575 | |
@@ -609,7 +625,10 @@ discard block |
||
| 609 | 625 | */ |
| 610 | 626 | public function update_client($event_id, Api\DateTime $recurrence_date = null) |
| 611 | 627 | { |
| 612 | - if(!$event_id) return; |
|
| 628 | + if(!$event_id) |
|
| 629 | + { |
|
| 630 | + return; |
|
| 631 | + } |
|
| 613 | 632 | |
| 614 | 633 | // Directly update stored data. |
| 615 | 634 | // Make sure we have the whole event |
@@ -657,7 +676,10 @@ discard block |
||
| 657 | 676 | */ |
| 658 | 677 | public function to_client(&$event) |
| 659 | 678 | { |
| 660 | - if(!$event || !is_array($event)) return false; |
|
| 679 | + if(!$event || !is_array($event)) |
|
| 680 | + { |
|
| 681 | + return false; |
|
| 682 | + } |
|
| 661 | 683 | |
| 662 | 684 | if (!$this->bo->check_perms(Acl::EDIT,$event)) |
| 663 | 685 | { |
@@ -678,8 +700,16 @@ discard block |
||
| 678 | 700 | |
| 679 | 701 | $event['recure'] = $this->bo->recure2string($event); |
| 680 | 702 | |
| 681 | - if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment |
|
| 682 | - if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment |
|
| 703 | + if (empty($event['description'])) |
|
| 704 | + { |
|
| 705 | + $event['description'] = ' '; |
|
| 706 | + } |
|
| 707 | + // no description screws the titles horz. alignment |
|
| 708 | + if (empty($event['location'])) |
|
| 709 | + { |
|
| 710 | + $event['location'] = ' '; |
|
| 711 | + } |
|
| 712 | + // no location screws the owner horz. alignment |
|
| 683 | 713 | |
| 684 | 714 | // respect category permissions |
| 685 | 715 | if(!empty($event['category'])) |
@@ -756,8 +786,14 @@ discard block |
||
| 756 | 786 | if(!$timespan) |
| 757 | 787 | { |
| 758 | 788 | // Try to make time span into appropriate ranges to match |
| 759 | - if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month'; |
|
| 760 | - if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week'; |
|
| 789 | + if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) |
|
| 790 | + { |
|
| 791 | + $template = 'month'; |
|
| 792 | + } |
|
| 793 | + if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) |
|
| 794 | + { |
|
| 795 | + $template = 'week'; |
|
| 796 | + } |
|
| 761 | 797 | //error_log("Detected template $template"); |
| 762 | 798 | switch ($template) |
| 763 | 799 | { |
@@ -41,7 +41,10 @@ discard block |
||
| 41 | 41 | $form_name = self::form_name($cname, $this->id, $expand); |
| 42 | 42 | |
| 43 | 43 | $value =& self::get_array(self::$request->content, $form_name); |
| 44 | - if(!is_array($value)) $value = array(); |
|
| 44 | + if(!is_array($value)) |
|
| 45 | + { |
|
| 46 | + $value = array(); |
|
| 47 | + } |
|
| 45 | 48 | if (!is_array(self::$request->sel_options[$form_name])) |
| 46 | 49 | { |
| 47 | 50 | self::$request->sel_options[$form_name] = array(); |
@@ -63,7 +66,8 @@ discard block |
||
| 63 | 66 | $accounts += $accounts_type; |
| 64 | 67 | } |
| 65 | 68 | $sel_options += array_map( |
| 66 | - function($account_id, $account_name) { |
|
| 69 | + function($account_id, $account_name) |
|
| 70 | + { |
|
| 67 | 71 | return array( |
| 68 | 72 | 'value' => ''.$account_id, |
| 69 | 73 | 'label' => $account_name, |
@@ -115,7 +119,10 @@ discard block |
||
| 115 | 119 | } |
| 116 | 120 | |
| 117 | 121 | $valid =& self::get_array($validated, $form_name, true); |
| 118 | - if (true) $valid = $value; |
|
| 122 | + if (true) |
|
| 123 | + { |
|
| 124 | + $valid = $value; |
|
| 125 | + } |
|
| 119 | 126 | } |
| 120 | 127 | } |
| 121 | 128 | /** |
@@ -161,7 +168,10 @@ discard block |
||
| 161 | 168 | { |
| 162 | 169 | $_results = Link::query($data['app'], $query,$options); |
| 163 | 170 | } |
| 164 | - if(!$_results) continue; |
|
| 171 | + if(!$_results) |
|
| 172 | + { |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 165 | 175 | |
| 166 | 176 | foreach(array_unique($_results) as $id => $title) |
| 167 | 177 | { |
@@ -202,7 +212,10 @@ discard block |
||
| 202 | 212 | public static function get_owner_label($id) |
| 203 | 213 | { |
| 204 | 214 | static $bo; |
| 205 | - if(!$bo) $bo = new calendar_bo(); |
|
| 215 | + if(!$bo) |
|
| 216 | + { |
|
| 217 | + $bo = new calendar_bo(); |
|
| 218 | + } |
|
| 206 | 219 | |
| 207 | 220 | $id = ''.$id; |
| 208 | 221 | if(!is_numeric($id)) |
@@ -110,11 +110,14 @@ discard block |
||
| 110 | 110 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 111 | 111 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 112 | 112 | { |
| 113 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 113 | + if ($owner) |
|
| 114 | + { |
|
| 115 | + // make an owner who is no user or we have no add-rights a participant |
|
| 114 | 116 | { |
| 115 | 117 | if(!is_array($owner)) |
| 116 | 118 | { |
| 117 | 119 | $owner = explode(',',$owner); |
| 120 | + } |
|
| 118 | 121 | } |
| 119 | 122 | // if we come from ressources we don't need any users selected in calendar |
| 120 | 123 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -150,9 +153,17 @@ discard block |
||
| 150 | 153 | $participant_types['u'] = $participant_types = $participants = array(); |
| 151 | 154 | foreach($extra_participants as $uid) |
| 152 | 155 | { |
| 153 | - if (isset($participants[$uid])) continue; // already included |
|
| 156 | + if (isset($participants[$uid])) |
|
| 157 | + { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 160 | + // already included |
|
| 154 | 161 | |
| 155 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 162 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 163 | + { |
|
| 164 | + continue; |
|
| 165 | + } |
|
| 166 | + // no right to invite --> ignored |
|
| 156 | 167 | |
| 157 | 168 | if (is_numeric($uid)) |
| 158 | 169 | { |
@@ -180,10 +191,13 @@ discard block |
||
| 180 | 191 | } |
| 181 | 192 | } |
| 182 | 193 | } |
| 183 | - if (!$participants) // if all participants got removed, include current user |
|
| 194 | + if (!$participants) |
|
| 195 | + { |
|
| 196 | + // if all participants got removed, include current user |
|
| 184 | 197 | { |
| 185 | 198 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 186 | 199 | } |
| 200 | + } |
|
| 187 | 201 | if(isset($_GET['cat_id'])) |
| 188 | 202 | { |
| 189 | 203 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -231,10 +245,13 @@ discard block |
||
| 231 | 245 | */ |
| 232 | 246 | function process_edit($content) |
| 233 | 247 | { |
| 234 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 248 | + if (!is_array($content)) |
|
| 249 | + { |
|
| 250 | + // redirect from etemplate, if POST empty |
|
| 235 | 251 | { |
| 236 | 252 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 237 | 253 | } |
| 254 | + } |
|
| 238 | 255 | // clear notification errors |
| 239 | 256 | notifications::errors(true); |
| 240 | 257 | $messages = null; |
@@ -247,7 +264,11 @@ discard block |
||
| 247 | 264 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 248 | 265 | |
| 249 | 266 | list($button) = @each($content['button']); |
| 250 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 267 | + if (!$button && $content['action']) |
|
| 268 | + { |
|
| 269 | + $button = $content['action']; |
|
| 270 | + } |
|
| 271 | + // action selectbox |
|
| 251 | 272 | unset($content['button']); unset($content['action']); |
| 252 | 273 | |
| 253 | 274 | $view = $content['view']; |
@@ -260,7 +281,10 @@ discard block |
||
| 260 | 281 | { |
| 261 | 282 | list($date) = each($content['recur_exception']['delete_exception']); |
| 262 | 283 | // eT2 converts time to |
| 263 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 284 | + if (!is_numeric($date)) |
|
| 285 | + { |
|
| 286 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 287 | + } |
|
| 264 | 288 | unset($content['recur_exception']['delete_exception']); |
| 265 | 289 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 266 | 290 | { |
@@ -269,7 +293,10 @@ discard block |
||
| 269 | 293 | foreach ($recur_exceptions as $id) |
| 270 | 294 | { |
| 271 | 295 | if (!($exception = $this->bo->read($id)) || |
| 272 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 296 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 297 | + { |
|
| 298 | + continue; |
|
| 299 | + } |
|
| 273 | 300 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 274 | 301 | $exception['reference'] = $exception['recurrence'] = 0; |
| 275 | 302 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -344,7 +371,10 @@ discard block |
||
| 344 | 371 | $event['end'] = $this->bo->date2ts($event['end']); |
| 345 | 372 | } |
| 346 | 373 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 347 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 374 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 375 | + { |
|
| 376 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 377 | + } |
|
| 348 | 378 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 349 | 379 | { |
| 350 | 380 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -371,7 +401,8 @@ discard block |
||
| 371 | 401 | break; |
| 372 | 402 | case 'participant': |
| 373 | 403 | foreach($data as $participant) |
| 374 | - { // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
|
| 404 | + { |
|
| 405 | +// email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
|
| 375 | 406 | $email = array(); |
| 376 | 407 | if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
| 377 | 408 | { |
@@ -451,7 +482,11 @@ discard block |
||
| 451 | 482 | break; |
| 452 | 483 | |
| 453 | 484 | default: // existing participant row |
| 454 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 485 | + if (!is_array($data)) |
|
| 486 | + { |
|
| 487 | + continue; |
|
| 488 | + } |
|
| 489 | + // widgets in participant tab, above participant list |
|
| 455 | 490 | foreach(array('uid','status','quantity','role') as $name) |
| 456 | 491 | { |
| 457 | 492 | $$name = $data[$name]; |
@@ -580,7 +615,10 @@ discard block |
||
| 580 | 615 | { |
| 581 | 616 | foreach($participants as $id => &$p_response) |
| 582 | 617 | { |
| 583 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 618 | + if($type == 'u' && $id == $event['owner']) |
|
| 619 | + { |
|
| 620 | + continue; |
|
| 621 | + } |
|
| 584 | 622 | calendar_so::split_status($p_response, $quantity, $role); |
| 585 | 623 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 586 | 624 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -662,17 +700,23 @@ discard block |
||
| 662 | 700 | { |
| 663 | 701 | foreach (array_keys($event['participants']) as $uid) |
| 664 | 702 | { |
| 665 | - if ($uid[0] == 'r') //ressource detection |
|
| 703 | + if ($uid[0] == 'r') |
|
| 704 | + { |
|
| 705 | + //ressource detection |
|
| 666 | 706 | { |
| 667 | 707 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 708 | + } |
|
| 668 | 709 | $button = ''; |
| 669 | 710 | break 2; //break foreach and case |
| 670 | 711 | } |
| 671 | 712 | } |
| 672 | 713 | } |
| 673 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 714 | + if ($content['edit_single']) |
|
| 715 | + { |
|
| 716 | + // we edited a single event from a series |
|
| 674 | 717 | { |
| 675 | 718 | $event['reference'] = $event['id']; |
| 719 | + } |
|
| 676 | 720 | $event['recurrence'] = $content['edit_single']; |
| 677 | 721 | unset($event['id']); |
| 678 | 722 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -768,7 +812,10 @@ discard block |
||
| 768 | 812 | case 'no': |
| 769 | 813 | break; |
| 770 | 814 | case 'startday': |
| 771 | - if ($sameday) break; |
|
| 815 | + if ($sameday) |
|
| 816 | + { |
|
| 817 | + break; |
|
| 818 | + } |
|
| 772 | 819 | default: |
| 773 | 820 | $status_reset_to_unknown = true; |
| 774 | 821 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -925,7 +972,10 @@ discard block |
||
| 925 | 972 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 926 | 973 | { |
| 927 | 974 | $msg = lang('Series deleted'); |
| 928 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 975 | + if ($exceptions_kept) |
|
| 976 | + { |
|
| 977 | + $msg .= lang(', exceptions preserved'); |
|
| 978 | + } |
|
| 929 | 979 | } |
| 930 | 980 | else |
| 931 | 981 | { |
@@ -961,11 +1011,14 @@ discard block |
||
| 961 | 1011 | { |
| 962 | 1012 | $msg = lang("Can't add alarms in the past !!!"); |
| 963 | 1013 | } |
| 964 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1014 | + elseif ($event['id']) |
|
| 1015 | + { |
|
| 1016 | + // save the alarm immediatly |
|
| 965 | 1017 | { |
| 966 | 1018 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 967 | 1019 | { |
| 968 | 1020 | $alarm['id'] = $alarm_id; |
| 1021 | + } |
|
| 969 | 1022 | $event['alarm'][$alarm_id] = $alarm; |
| 970 | 1023 | |
| 971 | 1024 | $msg = lang('Alarm added'); |
@@ -978,7 +1031,9 @@ discard block |
||
| 978 | 1031 | } |
| 979 | 1032 | else |
| 980 | 1033 | { |
| 981 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1035 | + { |
|
| 1036 | +} // get a temporary non-conflicting, numeric id |
|
| 982 | 1037 | $event['alarm'][$alarm['id']] = $alarm; |
| 983 | 1038 | } |
| 984 | 1039 | } |
@@ -1001,10 +1056,13 @@ discard block |
||
| 1001 | 1056 | } |
| 1002 | 1057 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1003 | 1058 | { |
| 1004 | - if ($content['lock_token']) // remove an existing lock |
|
| 1059 | + if ($content['lock_token']) |
|
| 1060 | + { |
|
| 1061 | + // remove an existing lock |
|
| 1005 | 1062 | { |
| 1006 | 1063 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1007 | 1064 | } |
| 1065 | + } |
|
| 1008 | 1066 | if ($content['no_popup']) |
| 1009 | 1067 | { |
| 1010 | 1068 | Egw::redirect_link('/index.php',array( |
@@ -1108,8 +1166,7 @@ discard block |
||
| 1108 | 1166 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1109 | 1167 | // Adjust for requested date in the past |
| 1110 | 1168 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1111 | - ) |
|
| 1112 | - { |
|
| 1169 | + ) { |
|
| 1113 | 1170 | |
| 1114 | 1171 | unset($orig_event); |
| 1115 | 1172 | // copy event by unsetting the id(s) |
@@ -1197,32 +1254,50 @@ discard block |
||
| 1197 | 1254 | foreach($event['participants'] as $uid => $status) |
| 1198 | 1255 | { |
| 1199 | 1256 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1200 | - if (empty($status)) continue; |
|
| 1257 | + if (empty($status)) |
|
| 1258 | + { |
|
| 1259 | + continue; |
|
| 1260 | + } |
|
| 1201 | 1261 | $toadd = ''; |
| 1202 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1262 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1263 | + { |
|
| 1264 | + continue; |
|
| 1265 | + } |
|
| 1203 | 1266 | |
| 1204 | 1267 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1205 | 1268 | { |
| 1206 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1269 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1270 | + { |
|
| 1271 | + continue; |
|
| 1272 | + } |
|
| 1207 | 1273 | |
| 1208 | 1274 | $lid = $firstname = $lastname = null; |
| 1209 | 1275 | $GLOBALS['egw']->accounts->get_account_name($status['uid'],$lid,$firstname,$lastname); |
| 1210 | 1276 | |
| 1211 | 1277 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1212 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1278 | + if (!in_array($toadd,$to)) |
|
| 1279 | + { |
|
| 1280 | + $to[] = $toadd; |
|
| 1281 | + } |
|
| 1213 | 1282 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1214 | 1283 | } |
| 1215 | 1284 | elseif ($uid < 0) |
| 1216 | 1285 | { |
| 1217 | 1286 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1218 | 1287 | { |
| 1219 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1288 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1289 | + { |
|
| 1290 | + continue; |
|
| 1291 | + } |
|
| 1220 | 1292 | |
| 1221 | 1293 | $GLOBALS['egw']->accounts->get_account_name($uid,$lid,$firstname,$lastname); |
| 1222 | 1294 | |
| 1223 | 1295 | $toadd = $firstname.' '.$lastname.' <'.$email.'>'; |
| 1224 | 1296 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1225 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1297 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1298 | + { |
|
| 1299 | + $to[] = $toadd; |
|
| 1300 | + } |
|
| 1226 | 1301 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1227 | 1302 | } |
| 1228 | 1303 | } |
@@ -1275,7 +1350,10 @@ discard block |
||
| 1275 | 1350 | 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
| 1276 | 1351 | 'preset[size]' => filesize($ics_file), |
| 1277 | 1352 | ); |
| 1278 | - if ($asrequest) $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1353 | + if ($asrequest) |
|
| 1354 | + { |
|
| 1355 | + $vars['preset[msg]'] = lang('You attempt to mail a meetingrequest to the recipients above. Depending on the client this mail is opened with, the recipient may or may not see the mailbody below, but only see the meeting request attached.'); |
|
| 1356 | + } |
|
| 1279 | 1357 | $response = Api\Json\Response::get(); |
| 1280 | 1358 | $response->call('app.calendar.custom_mail', $vars); |
| 1281 | 1359 | } |
@@ -1461,9 +1539,15 @@ discard block |
||
| 1461 | 1539 | } |
| 1462 | 1540 | } |
| 1463 | 1541 | // set new start and end if given by $_GET |
| 1464 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1465 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1466 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1542 | + if(isset($_GET['start'])) |
|
| 1543 | + { |
|
| 1544 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1545 | + if(isset($_GET['end'])) |
|
| 1546 | + { |
|
| 1547 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1548 | + if(isset($_GET['non_blocking'])) |
|
| 1549 | + { |
|
| 1550 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1467 | 1551 | // check if the event is the whole day |
| 1468 | 1552 | $start = $this->bo->date2array($event['start']); |
| 1469 | 1553 | $end = $this->bo->date2array($event['end']); |
@@ -1476,10 +1560,13 @@ discard block |
||
| 1476 | 1560 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1477 | 1561 | { |
| 1478 | 1562 | $link_id = $link_ids[$n]; |
| 1479 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1563 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1564 | + { |
|
| 1565 | + // guard against XSS |
|
| 1480 | 1566 | { |
| 1481 | 1567 | continue; |
| 1482 | 1568 | } |
| 1569 | + } |
|
| 1483 | 1570 | if(!$n) |
| 1484 | 1571 | { |
| 1485 | 1572 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1488,7 +1575,10 @@ discard block |
||
| 1488 | 1575 | { |
| 1489 | 1576 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1490 | 1577 | { |
| 1491 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1578 | + if (($l_id=$set['link_id'][$i])) |
|
| 1579 | + { |
|
| 1580 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1581 | + } |
|
| 1492 | 1582 | } |
| 1493 | 1583 | unset($set['link_app']); |
| 1494 | 1584 | unset($set['link_id']); |
@@ -1514,10 +1604,13 @@ discard block |
||
| 1514 | 1604 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1515 | 1605 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1516 | 1606 | |
| 1517 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1607 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1608 | + { |
|
| 1609 | + // already locked --> refresh the lock |
|
| 1518 | 1610 | { |
| 1519 | 1611 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1520 | 1612 | } |
| 1613 | + } |
|
| 1521 | 1614 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1522 | 1615 | { |
| 1523 | 1616 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1550,14 +1643,20 @@ discard block |
||
| 1550 | 1643 | )); |
| 1551 | 1644 | Framework::message($msg, $msg_type); |
| 1552 | 1645 | $content['duration'] = $content['end'] - $content['start']; |
| 1553 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1646 | + if (isset($this->durations[$content['duration']])) |
|
| 1647 | + { |
|
| 1648 | + $content['end'] = ''; |
|
| 1649 | + } |
|
| 1554 | 1650 | |
| 1555 | 1651 | $row = 3; |
| 1556 | 1652 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1557 | 1653 | // preserve some ui elements, if set eg. under error-conditions |
| 1558 | 1654 | foreach(array('quantity','resource','role') as $n) |
| 1559 | 1655 | { |
| 1560 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1656 | + if (isset($event['participants'][$n])) |
|
| 1657 | + { |
|
| 1658 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1659 | + } |
|
| 1561 | 1660 | } |
| 1562 | 1661 | foreach($event['participant_types'] as $type => $participants) |
| 1563 | 1662 | { |
@@ -1599,9 +1698,13 @@ discard block |
||
| 1599 | 1698 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1600 | 1699 | |
| 1601 | 1700 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1602 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1701 | + { |
|
| 1702 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1703 | + } |
|
| 1603 | 1704 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1604 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1705 | + { |
|
| 1706 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1707 | + } |
|
| 1605 | 1708 | // todo: make the participants available as links with email as title |
| 1606 | 1709 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1607 | 1710 | // enumerate group-invitations, so people can accept/reject them |
@@ -1632,7 +1735,11 @@ discard block |
||
| 1632 | 1735 | $content['participants']['cal_resources'] = ''; |
| 1633 | 1736 | foreach($this->bo->resources as $data) |
| 1634 | 1737 | { |
| 1635 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1738 | + if ($data['app'] == 'email') |
|
| 1739 | + { |
|
| 1740 | + continue; |
|
| 1741 | + } |
|
| 1742 | + // make no sense, as we cant search for email |
|
| 1636 | 1743 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1637 | 1744 | } |
| 1638 | 1745 | } |
@@ -1660,9 +1767,18 @@ discard block |
||
| 1660 | 1767 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1661 | 1768 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1662 | 1769 | $label = array(); |
| 1663 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1664 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1665 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1770 | + if ($days) |
|
| 1771 | + { |
|
| 1772 | + $label[] = $days.' '.lang('days'); |
|
| 1773 | + } |
|
| 1774 | + if ($hours) |
|
| 1775 | + { |
|
| 1776 | + $label[] = $hours.' '.lang('hours'); |
|
| 1777 | + } |
|
| 1778 | + if ($minutes) |
|
| 1779 | + { |
|
| 1780 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1781 | + } |
|
| 1666 | 1782 | $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
| 1667 | 1783 | $content['alarm'][] = $alarm; |
| 1668 | 1784 | |
@@ -1725,25 +1841,34 @@ discard block |
||
| 1725 | 1841 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1726 | 1842 | 'history' => !$event['id'], |
| 1727 | 1843 | ); |
| 1728 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1844 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1845 | + { |
|
| 1846 | + // no mail without mail-app |
|
| 1729 | 1847 | { |
| 1730 | 1848 | unset($sel_options['action']['mail']); |
| 1849 | + } |
|
| 1731 | 1850 | unset($sel_options['action']['sendmeetingrequest']); |
| 1732 | 1851 | } |
| 1733 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1852 | + if (!$event['id']) |
|
| 1853 | + { |
|
| 1854 | + // no ical export for new (not saved) events |
|
| 1734 | 1855 | { |
| 1735 | 1856 | $readonlys['action'] = true; |
| 1736 | 1857 | } |
| 1858 | + } |
|
| 1737 | 1859 | if (!($readonlys['button[exception]'] = !$this->bo->check_perms(Acl::EDIT,$event) || $event['recur_type'] == MCAL_RECUR_NONE || ($event['recur_enddate'] &&$event['start'] > $event['recur_enddate']))) |
| 1738 | 1860 | { |
| 1739 | 1861 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1740 | 1862 | } |
| 1741 | 1863 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1742 | 1864 | |
| 1743 | - if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1865 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1866 | + { |
|
| 1867 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1744 | 1868 | { |
| 1745 | 1869 | $sel_options['owner'][0] = lang('All participants'); |
| 1746 | 1870 | } |
| 1871 | + } |
|
| 1747 | 1872 | if (isset($event['participant_types']['u'][$this->user])) |
| 1748 | 1873 | { |
| 1749 | 1874 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1785,7 +1910,10 @@ discard block |
||
| 1785 | 1910 | |
| 1786 | 1911 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1787 | 1912 | |
| 1788 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 1913 | + if (!empty($preserved['lock_token'])) |
|
| 1914 | + { |
|
| 1915 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 1916 | + } |
|
| 1789 | 1917 | |
| 1790 | 1918 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1791 | 1919 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -1987,7 +2115,10 @@ discard block |
||
| 1987 | 2115 | // set status and send notification / meeting response |
| 1988 | 2116 | if ($this->bo->set_status($event['id'], $user, $status)) |
| 1989 | 2117 | { |
| 1990 | - if (!$msg) $msg = lang('Status changed'); |
|
| 2118 | + if (!$msg) |
|
| 2119 | + { |
|
| 2120 | + $msg = lang('Status changed'); |
|
| 2121 | + } |
|
| 1991 | 2122 | } |
| 1992 | 2123 | break; |
| 1993 | 2124 | |
@@ -2066,13 +2197,16 @@ discard block |
||
| 2066 | 2197 | |
| 2067 | 2198 | foreach (array_keys($allConflicts) as $pId) |
| 2068 | 2199 | { |
| 2069 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2200 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2201 | + { |
|
| 2202 | + // resources Allow ignore conflicts |
|
| 2070 | 2203 | { |
| 2071 | 2204 | |
| 2072 | 2205 | switch ($resources_config['ignoreconflicts']) |
| 2073 | 2206 | { |
| 2074 | 2207 | case 'no': |
| 2075 | 2208 | $readonlys['button[ignore]'] = true; |
| 2209 | + } |
|
| 2076 | 2210 | break; |
| 2077 | 2211 | case 'allusers': |
| 2078 | 2212 | $readonlys['button[ignore]'] = false; |
@@ -2216,7 +2350,10 @@ discard block |
||
| 2216 | 2350 | } |
| 2217 | 2351 | else |
| 2218 | 2352 | { |
| 2219 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2353 | + if (!$content['duration']) |
|
| 2354 | + { |
|
| 2355 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2356 | + } |
|
| 2220 | 2357 | $weekds = 0; |
| 2221 | 2358 | foreach ($content['weekdays'] as &$wdays) |
| 2222 | 2359 | { |
@@ -2238,7 +2375,10 @@ discard block |
||
| 2238 | 2375 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2239 | 2376 | |
| 2240 | 2377 | $sel_options['duration'] = $this->durations; |
| 2241 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2378 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2379 | + { |
|
| 2380 | + $content['end'] = ''; |
|
| 2381 | + } |
|
| 2242 | 2382 | |
| 2243 | 2383 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2244 | 2384 | 'participants' => $content['participants'], |
@@ -2259,7 +2399,10 @@ discard block |
||
| 2259 | 2399 | */ |
| 2260 | 2400 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2261 | 2401 | { |
| 2262 | - if ($this->debug > 2) $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2402 | + if ($this->debug > 2) |
|
| 2403 | + { |
|
| 2404 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2405 | + } |
|
| 2263 | 2406 | |
| 2264 | 2407 | $busy = $this->bo->search(array( |
| 2265 | 2408 | 'start' => $start, |
@@ -2276,15 +2419,26 @@ discard block |
||
| 2276 | 2419 | $n = 0; |
| 2277 | 2420 | foreach($busy as $event) |
| 2278 | 2421 | { |
| 2279 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2422 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2423 | + { |
|
| 2424 | + continue; |
|
| 2425 | + } |
|
| 2426 | + // ignore our own event |
|
| 2280 | 2427 | |
| 2281 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2428 | + if ($event['non_blocking']) |
|
| 2429 | + { |
|
| 2430 | + continue; |
|
| 2431 | + } |
|
| 2432 | + // ignore non_blocking events |
|
| 2282 | 2433 | |
| 2283 | 2434 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2284 | 2435 | $non_rejected_found = false; |
| 2285 | 2436 | foreach($participants as $uid) |
| 2286 | 2437 | { |
| 2287 | - if ($event['participants'][$uid] == 'R') continue; |
|
| 2438 | + if ($event['participants'][$uid] == 'R') |
|
| 2439 | + { |
|
| 2440 | + continue; |
|
| 2441 | + } |
|
| 2288 | 2442 | |
| 2289 | 2443 | if (isset($event['participants'][$uid]) || |
| 2290 | 2444 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2294,7 +2448,10 @@ discard block |
||
| 2294 | 2448 | break; |
| 2295 | 2449 | } |
| 2296 | 2450 | } |
| 2297 | - if (!$non_rejected_found) continue; |
|
| 2451 | + if (!$non_rejected_found) |
|
| 2452 | + { |
|
| 2453 | + continue; |
|
| 2454 | + } |
|
| 2298 | 2455 | |
| 2299 | 2456 | if ($this->debug) |
| 2300 | 2457 | { |
@@ -2325,11 +2482,17 @@ discard block |
||
| 2325 | 2482 | 'start' => $ft_start, |
| 2326 | 2483 | 'end' => $ft_end, |
| 2327 | 2484 | ); |
| 2328 | - if ($this->debug > 1) echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2485 | + if ($this->debug > 1) |
|
| 2486 | + { |
|
| 2487 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2488 | + } |
|
| 2329 | 2489 | } |
| 2330 | 2490 | $ft_start = $event['end']; |
| 2331 | 2491 | } |
| 2332 | - if ($this->debug > 0) $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2492 | + if ($this->debug > 0) |
|
| 2493 | + { |
|
| 2494 | + $this->bo->debug_message('uiforms::freetime(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5) freetime=%6',true,$participants,$start,$end,$duration,$cal_id,$freetime); |
|
| 2495 | + } |
|
| 2333 | 2496 | |
| 2334 | 2497 | return $freetime; |
| 2335 | 2498 | } |
@@ -2349,10 +2512,16 @@ discard block |
||
| 2349 | 2512 | */ |
| 2350 | 2513 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2351 | 2514 | { |
| 2352 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2515 | + if ($this->debug > 1) |
|
| 2516 | + { |
|
| 2517 | + $this->bo->debug_message('uiforms::split_freetime_daywise(freetime=%1, duration=%2, start_time=%3, end_time=%4)',true,$freetime,$duration,$_start_time,$_end_time); |
|
| 2518 | + } |
|
| 2353 | 2519 | |
| 2354 | 2520 | $freetime_daywise = array(); |
| 2355 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2521 | + if (!is_array($sel_options)) |
|
| 2522 | + { |
|
| 2523 | + $sel_options = array(); |
|
| 2524 | + } |
|
| 2356 | 2525 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2357 | 2526 | |
| 2358 | 2527 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2362,7 +2531,10 @@ discard block |
||
| 2362 | 2531 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2363 | 2532 | { |
| 2364 | 2533 | $end_time = 0; |
| 2365 | - if ($this->debug > 1) $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2534 | + if ($this->debug > 1) |
|
| 2535 | + { |
|
| 2536 | + $this->bo->debug_message('uiforms::split_freetime_daywise(, duration=%2, start_time=%3,..) end_time set to 0, it never fits durationn otherwise',true,$duration,$start_time); |
|
| 2537 | + } |
|
| 2366 | 2538 | } |
| 2367 | 2539 | $n = 0; |
| 2368 | 2540 | foreach($freetime as $ft) |
@@ -2383,13 +2555,19 @@ discard block |
||
| 2383 | 2555 | } |
| 2384 | 2556 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2385 | 2557 | |
| 2386 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2558 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2559 | + { |
|
| 2560 | + // start earlier then start_time |
|
| 2387 | 2561 | { |
| 2388 | 2562 | $start = $daybegin + $start_time*HOUR_s; |
| 2389 | 2563 | } |
| 2564 | + } |
|
| 2390 | 2565 | // if end_time given use it, else the original slot's end |
| 2391 | 2566 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2392 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2567 | + if ($end > $ft['end']) |
|
| 2568 | + { |
|
| 2569 | + $end = $ft['end']; |
|
| 2570 | + } |
|
| 2393 | 2571 | |
| 2394 | 2572 | // slot to small for duration |
| 2395 | 2573 | if ($end - $start < $duration) |
@@ -2431,7 +2609,10 @@ discard block |
||
| 2431 | 2609 | { |
| 2432 | 2610 | $msg = lang('Permission denied'); |
| 2433 | 2611 | |
| 2434 | - if ($return_error) return $msg; |
|
| 2612 | + if ($return_error) |
|
| 2613 | + { |
|
| 2614 | + return $msg; |
|
| 2615 | + } |
|
| 2435 | 2616 | } |
| 2436 | 2617 | else |
| 2437 | 2618 | { |
@@ -2493,27 +2674,42 @@ discard block |
||
| 2493 | 2674 | { |
| 2494 | 2675 | list($button) = each($_content['button']); |
| 2495 | 2676 | unset($_content['button']); |
| 2496 | - if ($button != 'cancel') // store changed Acl |
|
| 2677 | + if ($button != 'cancel') |
|
| 2678 | + { |
|
| 2679 | + // store changed Acl |
|
| 2497 | 2680 | { |
| 2498 | 2681 | foreach($_content as $data) |
| 2499 | 2682 | { |
| 2500 | 2683 | if (!($cat_id = $data['cat_id'])) continue; |
| 2684 | + } |
|
| 2501 | 2685 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2502 | 2686 | { |
| 2503 | 2687 | $rights = 0; |
| 2504 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2505 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2506 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2688 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2689 | + { |
|
| 2690 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2691 | + } |
|
| 2692 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2693 | + { |
|
| 2694 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2695 | + } |
|
| 2696 | + if ($account_id) |
|
| 2697 | + { |
|
| 2698 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2699 | + } |
|
| 2507 | 2700 | } |
| 2508 | 2701 | } |
| 2509 | 2702 | } |
| 2510 | - if ($button != 'apply') // end dialog |
|
| 2703 | + if ($button != 'apply') |
|
| 2704 | + { |
|
| 2705 | + // end dialog |
|
| 2511 | 2706 | { |
| 2512 | 2707 | Egw::redirect_link('/index.php', array( |
| 2513 | 2708 | 'menuaction' => 'admin.admin_ui.index', |
| 2514 | 2709 | 'ajax' => 'true' |
| 2515 | 2710 | ), 'admin'); |
| 2516 | 2711 | } |
| 2712 | + } |
|
| 2517 | 2713 | } |
| 2518 | 2714 | $content= $preserv = array(); |
| 2519 | 2715 | $n = 1; |
@@ -2527,8 +2723,14 @@ discard block |
||
| 2527 | 2723 | ); |
| 2528 | 2724 | foreach($data as $account_id => $rights) |
| 2529 | 2725 | { |
| 2530 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2531 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2726 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2727 | + { |
|
| 2728 | + $row['add'][] = $account_id; |
|
| 2729 | + } |
|
| 2730 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2731 | + { |
|
| 2732 | + $row['status'][] = $account_id; |
|
| 2733 | + } |
|
| 2532 | 2734 | } |
| 2533 | 2735 | $content[$n] = $row; |
| 2534 | 2736 | $preserv[$n] = array( |
@@ -2656,7 +2858,10 @@ discard block |
||
| 2656 | 2858 | break; |
| 2657 | 2859 | } |
| 2658 | 2860 | } |
| 2659 | - if($return) return; |
|
| 2861 | + if($return) |
|
| 2862 | + { |
|
| 2863 | + return; |
|
| 2864 | + } |
|
| 2660 | 2865 | } |
| 2661 | 2866 | $old_event=$event=$this->bo->read($eventId); |
| 2662 | 2867 | if (!$durationT) |
@@ -2741,7 +2946,10 @@ discard block |
||
| 2741 | 2946 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2742 | 2947 | |
| 2743 | 2948 | // Whole day non blocking with DAY_s would add a day |
| 2744 | - if($duration==DAY_s) $duration=0; |
|
| 2949 | + if($duration==DAY_s) |
|
| 2950 | + { |
|
| 2951 | + $duration=0; |
|
| 2952 | + } |
|
| 2745 | 2953 | } |
| 2746 | 2954 | // Drag a normal event to whole day non-blocking |
| 2747 | 2955 | else if ($durationT == 'whole_day') |
@@ -2765,7 +2973,10 @@ discard block |
||
| 2765 | 2973 | case 'no': |
| 2766 | 2974 | break; |
| 2767 | 2975 | case 'startday': |
| 2768 | - if ($sameday) break; |
|
| 2976 | + if ($sameday) |
|
| 2977 | + { |
|
| 2978 | + break; |
|
| 2979 | + } |
|
| 2769 | 2980 | default: |
| 2770 | 2981 | $status_reset_to_unknown = true; |
| 2771 | 2982 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -2803,7 +3014,10 @@ discard block |
||
| 2803 | 3014 | { |
| 2804 | 3015 | $response->call('egw.message', implode('<br />', $message)); |
| 2805 | 3016 | } |
| 2806 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3017 | + if($event['id'] != $eventId ) |
|
| 3018 | + { |
|
| 3019 | + $this->update_client($_eventId); |
|
| 3020 | + } |
|
| 2807 | 3021 | if ($status_reset_to_unknown) |
| 2808 | 3022 | { |
| 2809 | 3023 | foreach((array)$event['participants'] as $uid => $status) |
@@ -338,7 +338,10 @@ discard block |
||
| 338 | 338 | $duration = 366*24*3600; |
| 339 | 339 | break; |
| 340 | 340 | } |
| 341 | - if ($interval > 1) $duration *= $interval; |
|
| 341 | + if ($interval > 1) |
|
| 342 | + { |
|
| 343 | + $duration *= $interval; |
|
| 344 | + } |
|
| 342 | 345 | |
| 343 | 346 | return $duration; |
| 344 | 347 | } |
@@ -481,7 +484,10 @@ discard block |
||
| 481 | 484 | { |
| 482 | 485 | return clone $this->time; |
| 483 | 486 | } |
| 484 | - if (isset($this->current)) $backup = $this->current; |
|
| 487 | + if (isset($this->current)) |
|
| 488 | + { |
|
| 489 | + $backup = $this->current; |
|
| 490 | + } |
|
| 485 | 491 | $this->rewind(); |
| 486 | 492 | |
| 487 | 493 | while(--$count > 0) |
@@ -489,7 +495,10 @@ discard block |
||
| 489 | 495 | $this->next_no_exception(); |
| 490 | 496 | } |
| 491 | 497 | $ret = clone $this->current; |
| 492 | - if ($backup) $this->current = $backup; |
|
| 498 | + if ($backup) |
|
| 499 | + { |
|
| 500 | + $this->current = $backup; |
|
| 501 | + } |
|
| 493 | 502 | return $ret; |
| 494 | 503 | } |
| 495 | 504 | |
@@ -631,7 +640,11 @@ discard block |
||
| 631 | 640 | $repeat_days = array(); |
| 632 | 641 | $rrule = array(); |
| 633 | 642 | |
| 634 | - if ($this->type == self::NONE) return false; // no recuring event |
|
| 643 | + if ($this->type == self::NONE) |
|
| 644 | + { |
|
| 645 | + return false; |
|
| 646 | + } |
|
| 647 | + // no recuring event |
|
| 635 | 648 | |
| 636 | 649 | if ($version == '1.0') |
| 637 | 650 | { |
@@ -725,8 +738,14 @@ discard block |
||
| 725 | 738 | */ |
| 726 | 739 | public static function event2rrule(array $event,$usertime=true,$to_tz=null) |
| 727 | 740 | { |
| 728 | - if (!is_array($event) || !isset($event['tzid'])) return false; |
|
| 729 | - if (!$to_tz) $to_tz = $event['tzid']; |
|
| 741 | + if (!is_array($event) || !isset($event['tzid'])) |
|
| 742 | + { |
|
| 743 | + return false; |
|
| 744 | + } |
|
| 745 | + if (!$to_tz) |
|
| 746 | + { |
|
| 747 | + $to_tz = $event['tzid']; |
|
| 748 | + } |
|
| 730 | 749 | $timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone; |
| 731 | 750 | $time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz); |
| 732 | 751 | |
@@ -786,7 +805,10 @@ discard block |
||
| 786 | 805 | $event['recur_type'] == self::NONE || |
| 787 | 806 | empty($event['recur_data']) || $event['recur_data'] == ALLDAYS || |
| 788 | 807 | empty($event['tzid']) || empty($to_tz) || |
| 789 | - $event['tzid'] == $to_tz) return; |
|
| 808 | + $event['tzid'] == $to_tz) |
|
| 809 | + { |
|
| 810 | + return; |
|
| 811 | + } |
|
| 790 | 812 | |
| 791 | 813 | if (!isset(self::$tz_cache[$event['tzid']])) |
| 792 | 814 | { |
@@ -815,11 +837,19 @@ discard block |
||
| 815 | 837 | if ($delta == 1 || $delta == -6) |
| 816 | 838 | { |
| 817 | 839 | $mask = $mask << 1; |
| 818 | - if ($mask & 128) $mask = $mask - 127; // overflow |
|
| 840 | + if ($mask & 128) |
|
| 841 | + { |
|
| 842 | + $mask = $mask - 127; |
|
| 843 | + } |
|
| 844 | + // overflow |
|
| 819 | 845 | } |
| 820 | 846 | else |
| 821 | 847 | { |
| 822 | - if ($mask & 1) $mask = $mask + 128; // underflow |
|
| 848 | + if ($mask & 1) |
|
| 849 | + { |
|
| 850 | + $mask = $mask + 128; |
|
| 851 | + } |
|
| 852 | + // underflow |
|
| 823 | 853 | $mask = $mask >> 1; |
| 824 | 854 | } |
| 825 | 855 | $event['recur_data'] = $mask; |
@@ -828,11 +858,16 @@ discard block |
||
| 828 | 858 | } |
| 829 | 859 | } |
| 830 | 860 | |
| 831 | -if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
|
| 861 | +if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) |
|
| 862 | +{ |
|
| 863 | + // some tests |
|
| 832 | 864 | { |
| 833 | 865 | ini_set('display_errors',1); |
| 866 | +} |
|
| 834 | 867 | error_reporting(E_ALL & ~E_NOTICE); |
| 835 | - function lang($str) { return $str; } |
|
| 868 | + function lang($str) |
|
| 869 | + { |
|
| 870 | +return $str; } |
|
| 836 | 871 | $GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin'; |
| 837 | 872 | require_once('../../api/src/autoload.php'); |
| 838 | 873 | |
@@ -863,9 +898,18 @@ discard block |
||
| 863 | 898 | |
| 864 | 899 | $tz = new DateTimeZone($_REQUEST['tz']); |
| 865 | 900 | $time = new Api\DateTime($_REQUEST['time'],$tz); |
| 866 | - if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
| 867 | - $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
| 868 | - if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
| 901 | + if ($_REQUEST['enddate']) |
|
| 902 | + { |
|
| 903 | + $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
| 904 | + } |
|
| 905 | + $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) |
|
| 906 | + { |
|
| 907 | +$weekdays |= $mask; } |
|
| 908 | + if ($_REQUEST['exceptions']) |
|
| 909 | + { |
|
| 910 | + foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); |
|
| 911 | + } |
|
| 912 | + } |
|
| 869 | 913 | |
| 870 | 914 | $rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions); |
| 871 | 915 | echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n"; |
@@ -24,7 +24,11 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function __construct() |
| 26 | 26 | { |
| 27 | - if (false) parent::__construct(); // can not be called, but gives IDE warning |
|
| 27 | + if (false) |
|
| 28 | + { |
|
| 29 | + parent::__construct(); |
|
| 30 | + } |
|
| 31 | + // can not be called, but gives IDE warning |
|
| 28 | 32 | |
| 29 | 33 | $this->datasource('calendar'); |
| 30 | 34 | |
@@ -96,16 +100,22 @@ discard block |
||
| 96 | 100 | $c->read_repository(); |
| 97 | 101 | $this->pm_config = $c->config_data; |
| 98 | 102 | unset($c); |
| 99 | - if (!$this->pm_config['hours_per_workday']) $this->pm_config['hours_per_workday'] = 8; |
|
| 103 | + if (!$this->pm_config['hours_per_workday']) |
|
| 104 | + { |
|
| 105 | + $this->pm_config['hours_per_workday'] = 8; |
|
| 106 | + } |
|
| 100 | 107 | } |
| 101 | 108 | $ds['pe_planned_time'] -= $nights * 60 * (24 - $this->pm_config['hours_per_workday']); |
| 102 | 109 | } |
| 103 | 110 | foreach($data['participants'] as $uid => $status) |
| 104 | 111 | { |
| 105 | - if ($status != 'R' && is_numeric($uid)) // only users for now |
|
| 112 | + if ($status != 'R' && is_numeric($uid)) |
|
| 113 | + { |
|
| 114 | + // only users for now |
|
| 106 | 115 | { |
| 107 | 116 | $ds['pe_resources'][] = $uid; |
| 108 | 117 | } |
| 118 | + } |
|
| 109 | 119 | } |
| 110 | 120 | // if we have multiple participants we have to multiply the time by the number of participants to get the total time |
| 111 | 121 | $ds['pe_planned_time'] *= count($ds['pe_resources']); |
@@ -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); |
@@ -216,7 +219,10 @@ discard block |
||
| 216 | 219 | */ |
| 217 | 220 | function __construct() |
| 218 | 221 | { |
| 219 | - if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True); |
|
| 222 | + if ($this->debug > 0) |
|
| 223 | + { |
|
| 224 | + $this->debug_message('calendar_bo::bocal() started',True); |
|
| 225 | + } |
|
| 220 | 226 | |
| 221 | 227 | $this->so = new calendar_so(); |
| 222 | 228 | |
@@ -297,7 +303,10 @@ discard block |
||
| 297 | 303 | */ |
| 298 | 304 | static function email_info($ids) |
| 299 | 305 | { |
| 300 | - if (!$ids) return null; |
|
| 306 | + if (!$ids) |
|
| 307 | + { |
|
| 308 | + return null; |
|
| 309 | + } |
|
| 301 | 310 | |
| 302 | 311 | $data = array(); |
| 303 | 312 | foreach((array)$ids as $id) |
@@ -370,22 +379,31 @@ discard block |
||
| 370 | 379 | $user = trim($user); |
| 371 | 380 | if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user)) |
| 372 | 381 | { |
| 373 | - if ($user && !in_array($user,$users)) // already added? |
|
| 382 | + if ($user && !in_array($user,$users)) |
|
| 383 | + { |
|
| 384 | + // already added? |
|
| 374 | 385 | { |
| 375 | 386 | $users[] = $user; |
| 376 | 387 | } |
| 388 | + } |
|
| 377 | 389 | } |
| 378 | 390 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 379 | 391 | { |
| 380 | 392 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 381 | 393 | } |
| 382 | 394 | // the further code is only for real users |
| 383 | - if (!is_numeric($user)) continue; |
|
| 395 | + if (!is_numeric($user)) |
|
| 396 | + { |
|
| 397 | + continue; |
|
| 398 | + } |
|
| 384 | 399 | |
| 385 | 400 | // for groups we have to include the members |
| 386 | 401 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
| 387 | 402 | { |
| 388 | - if ($no_enum_groups) continue; |
|
| 403 | + if ($no_enum_groups) |
|
| 404 | + { |
|
| 405 | + continue; |
|
| 406 | + } |
|
| 389 | 407 | |
| 390 | 408 | $members = $GLOBALS['egw']->accounts->members($user, true); |
| 391 | 409 | if (is_array($members)) |
@@ -465,11 +483,14 @@ discard block |
||
| 465 | 483 | } |
| 466 | 484 | |
| 467 | 485 | if (!isset($params['users']) || !$params['users'] || |
| 468 | - count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) // null or '' casted to an array |
|
| 486 | + count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0]) |
|
| 487 | + { |
|
| 488 | + // null or '' casted to an array |
|
| 469 | 489 | { |
| 470 | 490 | // for a search use all account you have read grants from |
| 471 | 491 | $params['users'] = $params['query'] ? array_keys($this->grants) : $this->user; |
| 472 | 492 | } |
| 493 | + } |
|
| 473 | 494 | // resolve users to add memberships for users and members for groups |
| 474 | 495 | // for search, do NOT use freebusy rights, as it would allow to probe the content of event entries |
| 475 | 496 | $users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query'])); |
@@ -480,7 +501,10 @@ discard block |
||
| 480 | 501 | $params['private_grants'] = array(); |
| 481 | 502 | foreach($this->grants as $user => $rights) |
| 482 | 503 | { |
| 483 | - if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user; |
|
| 504 | + if ($rights & Acl::PRIVAT) |
|
| 505 | + { |
|
| 506 | + $params['private_grants'][] = $user; |
|
| 507 | + } |
|
| 484 | 508 | } |
| 485 | 509 | } |
| 486 | 510 | |
@@ -495,7 +519,10 @@ discard block |
||
| 495 | 519 | { |
| 496 | 520 | return false; |
| 497 | 521 | } |
| 498 | - if (isset($params['start'])) $start = $this->date2ts($params['start']); |
|
| 522 | + if (isset($params['start'])) |
|
| 523 | + { |
|
| 524 | + $start = $this->date2ts($params['start']); |
|
| 525 | + } |
|
| 499 | 526 | |
| 500 | 527 | if (isset($params['end'])) |
| 501 | 528 | { |
@@ -559,10 +586,13 @@ discard block |
||
| 559 | 586 | $this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events); |
| 560 | 587 | } |
| 561 | 588 | // create empty entries for each day in the reported time |
| 562 | - for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below. |
|
| 589 | + for($ts = $start; $ts <= $end; $ts += DAY_s) |
|
| 590 | + { |
|
| 591 | + // good enough for array creation, but see while loop below. |
|
| 563 | 592 | { |
| 564 | 593 | $daysEvents[$this->date2string($ts)] = array(); |
| 565 | 594 | } |
| 595 | + } |
|
| 566 | 596 | foreach($events as $k => $event) |
| 567 | 597 | { |
| 568 | 598 | $e_start = max($this->date2ts($event['start']),$start); |
@@ -614,7 +644,10 @@ discard block |
||
| 614 | 644 | $integration_data = calendar_so::get_integration_data(); |
| 615 | 645 | } |
| 616 | 646 | |
| 617 | - if (!isset($integration_data[$app])) return null; |
|
| 647 | + if (!isset($integration_data[$app])) |
|
| 648 | + { |
|
| 649 | + return null; |
|
| 650 | + } |
|
| 618 | 651 | |
| 619 | 652 | return $part ? $integration_data[$app][$part] : $integration_data[$app]; |
| 620 | 653 | } |
@@ -661,8 +694,14 @@ discard block |
||
| 661 | 694 | */ |
| 662 | 695 | function clear_private_infos(&$event,$allowed_participants = array()) |
| 663 | 696 | { |
| 664 | - if ($event == false) return; |
|
| 665 | - if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 697 | + if ($event == false) |
|
| 698 | + { |
|
| 699 | + return; |
|
| 700 | + } |
|
| 701 | + if (!is_array($event['participants'])) |
|
| 702 | + { |
|
| 703 | + error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace()); |
|
| 704 | + } |
|
| 666 | 705 | |
| 667 | 706 | $event = array( |
| 668 | 707 | 'id' => $event['id'], |
@@ -707,19 +746,29 @@ discard block |
||
| 707 | 746 | } |
| 708 | 747 | $new_horizont = $this->date2ts($_new_horizont,true); // now we are in server-time, where this function operates |
| 709 | 748 | |
| 710 | - if ($new_horizont <= $this->config['horizont']) // no move necessary |
|
| 749 | + if ($new_horizont <= $this->config['horizont']) |
|
| 750 | + { |
|
| 751 | + // no move necessary |
|
| 711 | 752 | { |
| 712 | 753 | 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']); |
| 754 | + } |
|
| 713 | 755 | return; |
| 714 | 756 | } |
| 715 | 757 | if (!empty($GLOBALS['egw_info']['server']['calendar_horizont'])) |
| 716 | 758 | { |
| 717 | 759 | $maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']); |
| 718 | 760 | } |
| 719 | - if (empty($maxdays)) $maxdays = 1000; // old default |
|
| 720 | - if ($new_horizont > time()+$maxdays*DAY_s) // some user tries to "look" more then the maximum number of days in the future |
|
| 761 | + if (empty($maxdays)) |
|
| 762 | + { |
|
| 763 | + $maxdays = 1000; |
|
| 764 | + } |
|
| 765 | + // old default |
|
| 766 | + if ($new_horizont > time()+$maxdays*DAY_s) |
|
| 767 | + { |
|
| 768 | + // some user tries to "look" more then the maximum number of days in the future |
|
| 721 | 769 | { |
| 722 | 770 | 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); |
| 771 | + } |
|
| 723 | 772 | $this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays); |
| 724 | 773 | return; |
| 725 | 774 | } |
@@ -747,7 +796,10 @@ discard block |
||
| 747 | 796 | // update the horizont |
| 748 | 797 | Api\Config::save_value('horizont',$this->config['horizont'],'calendar'); |
| 749 | 798 | |
| 750 | - 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']); |
|
| 799 | + if ($this->debug == 'check_move_horizont') |
|
| 800 | + { |
|
| 801 | + $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']); |
|
| 802 | + } |
|
| 751 | 803 | } |
| 752 | 804 | |
| 753 | 805 | /** |
@@ -778,7 +830,10 @@ discard block |
||
| 778 | 830 | $event['end'] = $event_read['end']; |
| 779 | 831 | } |
| 780 | 832 | } |
| 781 | - if (!$start) $start = $event['start']; |
|
| 833 | + if (!$start) |
|
| 834 | + { |
|
| 835 | + $start = $event['start']; |
|
| 836 | + } |
|
| 782 | 837 | |
| 783 | 838 | $events = array(); |
| 784 | 839 | $this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events); |
@@ -818,7 +873,10 @@ discard block |
||
| 818 | 873 | */ |
| 819 | 874 | function db2data(&$events,$date_format='ts') |
| 820 | 875 | { |
| 821 | - if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 876 | + if (!is_array($events)) |
|
| 877 | + { |
|
| 878 | + echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n"; |
|
| 879 | + } |
|
| 822 | 880 | foreach ($events as &$event) |
| 823 | 881 | { |
| 824 | 882 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
@@ -902,7 +960,10 @@ discard block |
||
| 902 | 960 | */ |
| 903 | 961 | function date2usertime($ts,$date_format='ts') |
| 904 | 962 | { |
| 905 | - if (empty($ts) || $date_format == 'server') return $ts; |
|
| 963 | + if (empty($ts) || $date_format == 'server') |
|
| 964 | + { |
|
| 965 | + return $ts; |
|
| 966 | + } |
|
| 906 | 967 | |
| 907 | 968 | return Api\DateTime::server2user($ts,$date_format); |
| 908 | 969 | } |
@@ -920,9 +981,15 @@ discard block |
||
| 920 | 981 | */ |
| 921 | 982 | function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null) |
| 922 | 983 | { |
| 923 | - if (!$ids) return false; |
|
| 984 | + if (!$ids) |
|
| 985 | + { |
|
| 986 | + return false; |
|
| 987 | + } |
|
| 924 | 988 | |
| 925 | - if ($date) $date = $this->date2ts($date); |
|
| 989 | + if ($date) |
|
| 990 | + { |
|
| 991 | + $date = $this->date2ts($date); |
|
| 992 | + } |
|
| 926 | 993 | |
| 927 | 994 | $return = null; |
| 928 | 995 | |
@@ -1087,7 +1154,10 @@ discard block |
||
| 1087 | 1154 | { |
| 1088 | 1155 | static $res_info_cache = array(); |
| 1089 | 1156 | |
| 1090 | - if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1157 | + if (!is_scalar($uid)) |
|
| 1158 | + { |
|
| 1159 | + throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar'); |
|
| 1160 | + } |
|
| 1091 | 1161 | |
| 1092 | 1162 | if (!isset($res_info_cache[$uid])) |
| 1093 | 1163 | { |
@@ -1142,7 +1212,10 @@ discard block |
||
| 1142 | 1212 | */ |
| 1143 | 1213 | function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null) |
| 1144 | 1214 | { |
| 1145 | - if (!$user) $user = $this->user; |
|
| 1215 | + if (!$user) |
|
| 1216 | + { |
|
| 1217 | + $user = $this->user; |
|
| 1218 | + } |
|
| 1146 | 1219 | if ($user == $this->user) |
| 1147 | 1220 | { |
| 1148 | 1221 | $grants = $this->grants; |
@@ -1181,7 +1254,10 @@ discard block |
||
| 1181 | 1254 | $grant = $grants[$owner]; |
| 1182 | 1255 | |
| 1183 | 1256 | // now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY) |
| 1184 | - if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY; |
|
| 1257 | + if ($grant & ~self::ACL_INVITE) |
|
| 1258 | + { |
|
| 1259 | + $grant |= self::ACL_FREEBUSY; |
|
| 1260 | + } |
|
| 1185 | 1261 | |
| 1186 | 1262 | if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY)) |
| 1187 | 1263 | { |
@@ -1207,7 +1283,10 @@ discard block |
||
| 1207 | 1283 | elseif (!is_numeric($uid)) |
| 1208 | 1284 | { |
| 1209 | 1285 | // if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights |
| 1210 | - if ($grant == self::ACL_FREEBUSY) continue; |
|
| 1286 | + if ($grant == self::ACL_FREEBUSY) |
|
| 1287 | + { |
|
| 1288 | + continue; |
|
| 1289 | + } |
|
| 1211 | 1290 | // if we have a resource as participant |
| 1212 | 1291 | $resource = $this->resource_info($uid); |
| 1213 | 1292 | $grant |= $resource['rights']; |
@@ -1357,13 +1436,19 @@ discard block |
||
| 1357 | 1436 | $param = $param ? 'True' : 'False'; |
| 1358 | 1437 | break; |
| 1359 | 1438 | case 'integer': |
| 1360 | - if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1439 | + if ($param >= mktime(0,0,0,1,1,2000)) |
|
| 1440 | + { |
|
| 1441 | + $param = adodb_date('Y-m-d H:i:s',$param)." ($param)"; |
|
| 1442 | + } |
|
| 1361 | 1443 | break; |
| 1362 | 1444 | } |
| 1363 | 1445 | } |
| 1364 | 1446 | $msg = str_replace('%'.($i-1),$param,$msg); |
| 1365 | 1447 | } |
| 1366 | - if ($backtrace) error_log(function_backtrace(1)); |
|
| 1448 | + if ($backtrace) |
|
| 1449 | + { |
|
| 1450 | + error_log(function_backtrace(1)); |
|
| 1451 | + } |
|
| 1367 | 1452 | } |
| 1368 | 1453 | |
| 1369 | 1454 | /** |
@@ -1471,14 +1556,20 @@ discard block |
||
| 1471 | 1556 | function timespan($start_m,$end_m,$both=false) |
| 1472 | 1557 | { |
| 1473 | 1558 | $duration = $end_m - $start_m; |
| 1474 | - if ($end_m == 24*60-1) ++$duration; |
|
| 1559 | + if ($end_m == 24*60-1) |
|
| 1560 | + { |
|
| 1561 | + ++$duration; |
|
| 1562 | + } |
|
| 1475 | 1563 | $duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : ''); |
| 1476 | 1564 | |
| 1477 | 1565 | $timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false); |
| 1478 | 1566 | |
| 1479 | - if ($both) // end-time too |
|
| 1567 | + if ($both) |
|
| 1568 | + { |
|
| 1569 | + // end-time too |
|
| 1480 | 1570 | { |
| 1481 | 1571 | $timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false); |
| 1572 | + } |
|
| 1482 | 1573 | // dont double am/pm if they are the same in both times |
| 1483 | 1574 | if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2)) |
| 1484 | 1575 | { |
@@ -1502,7 +1593,10 @@ discard block |
||
| 1502 | 1593 | static $id2lid = array(); |
| 1503 | 1594 | static $id2email = array(); |
| 1504 | 1595 | |
| 1505 | - if ($use_type && $use_type != 'u') $id = $use_type.$id; |
|
| 1596 | + if ($use_type && $use_type != 'u') |
|
| 1597 | + { |
|
| 1598 | + $id = $use_type.$id; |
|
| 1599 | + } |
|
| 1506 | 1600 | |
| 1507 | 1601 | if (!isset($id2lid[$id])) |
| 1508 | 1602 | { |
@@ -1512,7 +1606,10 @@ discard block |
||
| 1512 | 1606 | if (($info = $this->resource_info($id))) |
| 1513 | 1607 | { |
| 1514 | 1608 | $id2lid[$id] = $info['name'] ? $info['name'] : $info['email']; |
| 1515 | - if ($info['name']) $id2email[$id] = $info['email']; |
|
| 1609 | + if ($info['name']) |
|
| 1610 | + { |
|
| 1611 | + $id2email[$id] = $info['email']; |
|
| 1612 | + } |
|
| 1516 | 1613 | } |
| 1517 | 1614 | } |
| 1518 | 1615 | else |
@@ -1538,11 +1635,18 @@ discard block |
||
| 1538 | 1635 | $names = array(); |
| 1539 | 1636 | foreach((array)$event['participants'] as $id => $status) |
| 1540 | 1637 | { |
| 1541 | - if (!is_string($status)) continue; |
|
| 1638 | + if (!is_string($status)) |
|
| 1639 | + { |
|
| 1640 | + continue; |
|
| 1641 | + } |
|
| 1542 | 1642 | $quantity = $role = null; |
| 1543 | 1643 | calendar_so::split_status($status,$quantity,$role); |
| 1544 | 1644 | |
| 1545 | - if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation |
|
| 1645 | + if ($status == 'G' && !$show_group_invitation) |
|
| 1646 | + { |
|
| 1647 | + continue; |
|
| 1648 | + } |
|
| 1649 | + // dont show group-invitation |
|
| 1546 | 1650 | |
| 1547 | 1651 | $lang_status = lang($this->verbose_status[$status]); |
| 1548 | 1652 | if (!$long_status) |
@@ -1615,7 +1719,10 @@ discard block |
||
| 1615 | 1719 | |
| 1616 | 1720 | foreach(explode(',',$category) as $cat_id) |
| 1617 | 1721 | { |
| 1618 | - if (!$cat_id) continue; |
|
| 1722 | + if (!$cat_id) |
|
| 1723 | + { |
|
| 1724 | + continue; |
|
| 1725 | + } |
|
| 1619 | 1726 | |
| 1620 | 1727 | if (!isset($id2cat[$cat_id])) |
| 1621 | 1728 | { |
@@ -1681,7 +1788,10 @@ discard block |
||
| 1681 | 1788 | */ |
| 1682 | 1789 | public static function list_calendars($user, array $grants=null) |
| 1683 | 1790 | { |
| 1684 | - if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1791 | + if (is_null($grants)) |
|
| 1792 | + { |
|
| 1793 | + $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user); |
|
| 1794 | + } |
|
| 1685 | 1795 | |
| 1686 | 1796 | $users = $groups = array(); |
| 1687 | 1797 | foreach(array_keys($grants) as $id) |
@@ -1729,7 +1839,10 @@ discard block |
||
| 1729 | 1839 | */ |
| 1730 | 1840 | function recure2string($event) |
| 1731 | 1841 | { |
| 1732 | - if (!is_array($event)) return false; |
|
| 1842 | + if (!is_array($event)) |
|
| 1843 | + { |
|
| 1844 | + return false; |
|
| 1845 | + } |
|
| 1733 | 1846 | return (string)calendar_rrule::event2rrule($event); |
| 1734 | 1847 | } |
| 1735 | 1848 | |
@@ -1748,12 +1861,18 @@ discard block |
||
| 1748 | 1861 | */ |
| 1749 | 1862 | function read_holidays($year=0) |
| 1750 | 1863 | { |
| 1751 | - if (!$year) $year = (int) date('Y',$this->now_su); |
|
| 1864 | + if (!$year) |
|
| 1865 | + { |
|
| 1866 | + $year = (int) date('Y',$this->now_su); |
|
| 1867 | + } |
|
| 1752 | 1868 | |
| 1753 | - if (!$this->cached_holidays) // try reading the holidays from the session |
|
| 1869 | + if (!$this->cached_holidays) |
|
| 1870 | + { |
|
| 1871 | + // try reading the holidays from the session |
|
| 1754 | 1872 | { |
| 1755 | 1873 | $this->cached_holidays = Api\Cache::getSession('calendar', 'holidays'); |
| 1756 | 1874 | } |
| 1875 | + } |
|
| 1757 | 1876 | if (!isset($this->cached_holidays[$year])) |
| 1758 | 1877 | { |
| 1759 | 1878 | $this->cached_holidays[$year] = calendar_holidays::read( |
@@ -1791,7 +1910,11 @@ discard block |
||
| 1791 | 1910 | continue; |
| 1792 | 1911 | } |
| 1793 | 1912 | list($y,$m,$d) = explode('-',$pers['bday']); |
| 1794 | - if ($y > $year) continue; // not yet born |
|
| 1913 | + if ($y > $year) |
|
| 1914 | + { |
|
| 1915 | + continue; |
|
| 1916 | + } |
|
| 1917 | + // not yet born |
|
| 1795 | 1918 | $this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array( |
| 1796 | 1919 | 'day' => $d, |
| 1797 | 1920 | 'month' => $m, |
@@ -1884,7 +2007,10 @@ discard block |
||
| 1884 | 2007 | } |
| 1885 | 2008 | } |
| 1886 | 2009 | $str_fields = implode(', ',$extra_fields); |
| 1887 | - if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2010 | + if (is_array($extra_fields)) |
|
| 2011 | + { |
|
| 2012 | + return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:''); |
|
| 2013 | + } |
|
| 1888 | 2014 | } |
| 1889 | 2015 | return $this->format_date($event['start']) . ': ' . $event['title']; |
| 1890 | 2016 | } |
@@ -1905,7 +2031,8 @@ discard block |
||
| 1905 | 2031 | 'offset' => $options['start'], |
| 1906 | 2032 | 'order' => 'cal_start DESC', |
| 1907 | 2033 | ); |
| 1908 | - if($options['num_rows']) { |
|
| 2034 | + if($options['num_rows']) |
|
| 2035 | + { |
|
| 1909 | 2036 | $query['num_rows'] = $options['num_rows']; |
| 1910 | 2037 | } |
| 1911 | 2038 | foreach((array) $this->search($query) as $event) |
@@ -1966,7 +2093,10 @@ discard block |
||
| 1966 | 2093 | if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === '')) |
| 1967 | 2094 | { |
| 1968 | 2095 | $GLOBALS['egw']->preferences->add('calendar',$var,$default,'default'); // always store default, even if we have a forced too |
| 1969 | - if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2096 | + if ($type == 'forced') |
|
| 2097 | + { |
|
| 2098 | + $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced'); |
|
| 2099 | + } |
|
| 1970 | 2100 | $this->cal_prefs[$var] = $default; |
| 1971 | 2101 | $need_save = True; |
| 1972 | 2102 | } |
@@ -1986,7 +2116,10 @@ discard block |
||
| 1986 | 2116 | */ |
| 1987 | 2117 | static function freebusy_url($user='',$pw=null) |
| 1988 | 2118 | { |
| 1989 | - if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2119 | + if (is_numeric($user)) |
|
| 2120 | + { |
|
| 2121 | + $user = $GLOBALS['egw']->accounts->id2name($user); |
|
| 2122 | + } |
|
| 1990 | 2123 | |
| 1991 | 2124 | $credentials = ''; |
| 1992 | 2125 | |
@@ -2054,13 +2187,19 @@ discard block |
||
| 2054 | 2187 | */ |
| 2055 | 2188 | public function get_ctag($user, $filter='owner', $master_only=false) |
| 2056 | 2189 | { |
| 2057 | - if ($this->debug > 1) $startime = microtime(true); |
|
| 2190 | + if ($this->debug > 1) |
|
| 2191 | + { |
|
| 2192 | + $startime = microtime(true); |
|
| 2193 | + } |
|
| 2058 | 2194 | |
| 2059 | 2195 | // resolve users to add memberships for users and members for groups |
| 2060 | 2196 | $users = $this->resolve_users($user); |
| 2061 | 2197 | $ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!) |
| 2062 | 2198 | |
| 2063 | - 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"); |
|
| 2199 | + if ($this->debug > 1) |
|
| 2200 | + { |
|
| 2201 | + error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs"); |
|
| 2202 | + } |
|
| 2064 | 2203 | return $ctag; |
| 2065 | 2204 | } |
| 2066 | 2205 | |
@@ -2102,15 +2241,21 @@ discard block |
||
| 2102 | 2241 | $content['link_app'][] = $link['app']; |
| 2103 | 2242 | $content['link_id'][] = $link['id']; |
| 2104 | 2243 | } |
| 2105 | - if ($link['app'] == 'addressbook') // prefering contact as primary contact over calendar entry set above |
|
| 2244 | + if ($link['app'] == 'addressbook') |
|
| 2245 | + { |
|
| 2246 | + // prefering contact as primary contact over calendar entry set above |
|
| 2106 | 2247 | { |
| 2107 | 2248 | $content['info_contact'] = 'addressbook:'.$link['id']; |
| 2108 | 2249 | } |
| 2250 | + } |
|
| 2109 | 2251 | } |
| 2110 | 2252 | // Copy same custom fields |
| 2111 | 2253 | foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name) |
| 2112 | 2254 | { |
| 2113 | - if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name]; |
|
| 2255 | + if ($this->customfields[$name]) |
|
| 2256 | + { |
|
| 2257 | + $content['#'.$name] = $calendar['#'.$name]; |
|
| 2258 | + } |
|
| 2114 | 2259 | } |
| 2115 | 2260 | //error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content)); |
| 2116 | 2261 | return $content; |
@@ -2133,7 +2278,11 @@ discard block |
||
| 2133 | 2278 | $set['ts_title'] = $this->link_title($event); |
| 2134 | 2279 | $set['start_time'] = Api\DateTime::to($event['start'],'H:i'); |
| 2135 | 2280 | $set['ts_description'] = $event['description']; |
| 2136 | - if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short |
|
| 2281 | + if ($this->isWholeDay($event)) |
|
| 2282 | + { |
|
| 2283 | + $event['end']++; |
|
| 2284 | + } |
|
| 2285 | + // whole day events are 1sec short |
|
| 2137 | 2286 | $set['ts_duration'] = ($event['end'] - $event['start']) / 60; |
| 2138 | 2287 | $set['ts_quantity'] = ($event['end'] - $event['start']) / 3600; |
| 2139 | 2288 | $set['end_time'] = null; // unset end-time |
@@ -85,11 +85,17 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function __construct() |
| 87 | 87 | { |
| 88 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 88 | + if ($this->debug > 0) |
|
| 89 | + { |
|
| 90 | + $this->debug_message('calendar_boupdate::__construct() started',True); |
|
| 91 | + } |
|
| 89 | 92 | |
| 90 | 93 | parent::__construct(); // calling the parent constructor |
| 91 | 94 | |
| 92 | - if ($this->debug > 0) $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 95 | + if ($this->debug > 0) |
|
| 96 | + { |
|
| 97 | + $this->debug_message('calendar_boupdate::__construct() finished',True); |
|
| 98 | + } |
|
| 93 | 99 | } |
| 94 | 100 | |
| 95 | 101 | /** |
@@ -119,7 +125,10 @@ discard block |
||
| 119 | 125 | function update(&$event,$ignore_conflicts=false,$touch_modified=true,$ignore_acl=false,$updateTS=true,&$messages=null, $skip_notification=false) |
| 120 | 126 | { |
| 121 | 127 | //error_log(__METHOD__."(".array2string($event).",$ignore_conflicts,$touch_modified,$ignore_acl)"); |
| 122 | - if (!is_array($messages)) $messages = $messages ? (array)$messages : array(); |
|
| 128 | + if (!is_array($messages)) |
|
| 129 | + { |
|
| 130 | + $messages = $messages ? (array)$messages : array(); |
|
| 131 | + } |
|
| 123 | 132 | |
| 124 | 133 | if ($this->debug > 1 || $this->debug == 'update') |
| 125 | 134 | { |
@@ -139,10 +148,13 @@ discard block |
||
| 139 | 148 | |
| 140 | 149 | $status_reset_to_unknown = false; |
| 141 | 150 | |
| 142 | - if (($new_event = !$event['id'])) // some defaults for new entries |
|
| 151 | + if (($new_event = !$event['id'])) |
|
| 152 | + { |
|
| 153 | + // some defaults for new entries |
|
| 143 | 154 | { |
| 144 | 155 | // if no owner given, set user to owner |
| 145 | 156 | if (!$event['owner']) $event['owner'] = $this->user; |
| 157 | + } |
|
| 146 | 158 | // set owner as participant if none is given |
| 147 | 159 | if (!is_array($event['participants']) || !count($event['participants'])) |
| 148 | 160 | { |
@@ -182,7 +194,10 @@ discard block |
||
| 182 | 194 | // check category based ACL |
| 183 | 195 | if ($event['category']) |
| 184 | 196 | { |
| 185 | - if (!is_array($event['category'])) $event['category'] = explode(',',$event['category']); |
|
| 197 | + if (!is_array($event['category'])) |
|
| 198 | + { |
|
| 199 | + $event['category'] = explode(',',$event['category']); |
|
| 200 | + } |
|
| 186 | 201 | if (!$old_event || !isset($old_event['category'])) |
| 187 | 202 | { |
| 188 | 203 | $old_event['category'] = array(); |
@@ -235,18 +250,28 @@ discard block |
||
| 235 | 250 | $types_with_quantity = array(); |
| 236 | 251 | foreach($this->resources as $type => $data) |
| 237 | 252 | { |
| 238 | - if ($data['max_quantity']) $types_with_quantity[] = $type; |
|
| 253 | + if ($data['max_quantity']) |
|
| 254 | + { |
|
| 255 | + $types_with_quantity[] = $type; |
|
| 256 | + } |
|
| 239 | 257 | } |
| 240 | 258 | // get all NOT rejected participants and evtl. their quantity |
| 241 | 259 | $quantity = $users = array(); |
| 242 | 260 | foreach($event['participants'] as $uid => $status) |
| 243 | 261 | { |
| 244 | 262 | calendar_so::split_status($status,$q,$r); |
| 245 | - if ($status[0] == 'R') continue; // ignore rejected participants |
|
| 263 | + if ($status[0] == 'R') |
|
| 264 | + { |
|
| 265 | + continue; |
|
| 266 | + } |
|
| 267 | + // ignore rejected participants |
|
| 246 | 268 | |
| 247 | - if ($uid < 0) // group, check it's members too |
|
| 269 | + if ($uid < 0) |
|
| 270 | + { |
|
| 271 | + // group, check it's members too |
|
| 248 | 272 | { |
| 249 | 273 | $users += (array)$GLOBALS['egw']->accounts->members($uid,true); |
| 274 | + } |
|
| 250 | 275 | $users = array_unique($users); |
| 251 | 276 | } |
| 252 | 277 | $users[] = $uid; |
@@ -277,10 +302,13 @@ discard block |
||
| 277 | 302 | { |
| 278 | 303 | if ($overlap['id'] == $event['id'] || // that's the event itself |
| 279 | 304 | $overlap['id'] == $event['reference'] || // event is an exception of overlap |
| 280 | - $overlap['non_blocking']) // that's a non_blocking event |
|
| 305 | + $overlap['non_blocking']) |
|
| 306 | + { |
|
| 307 | + // that's a non_blocking event |
|
| 281 | 308 | { |
| 282 | 309 | continue; |
| 283 | 310 | } |
| 311 | + } |
|
| 284 | 312 | if ($this->debug > 3 || $this->debug == 'update') |
| 285 | 313 | { |
| 286 | 314 | $this->debug_message('calendar_boupdate::update() checking overlapping event %1',false,$overlap); |
@@ -438,7 +466,11 @@ discard block |
||
| 438 | 466 | */ |
| 439 | 467 | public function check_acl_invite($uid) |
| 440 | 468 | { |
| 441 | - if (!is_numeric($uid)) return true; // nothing implemented for resources so far |
|
| 469 | + if (!is_numeric($uid)) |
|
| 470 | + { |
|
| 471 | + return true; |
|
| 472 | + } |
|
| 473 | + // nothing implemented for resources so far |
|
| 442 | 474 | |
| 443 | 475 | if (!$this->require_acl_invite) |
| 444 | 476 | { |
@@ -778,14 +810,20 @@ discard block |
||
| 778 | 810 | $startdate = new Api\DateTime($event['start']); |
| 779 | 811 | $enddate = new Api\DateTime($event['end']); |
| 780 | 812 | $modified = new Api\DateTime($event['modified']); |
| 781 | - if ($old_event) $olddate = new Api\DateTime($old_event['start']); |
|
| 813 | + if ($old_event) |
|
| 814 | + { |
|
| 815 | + $olddate = new Api\DateTime($old_event['start']); |
|
| 816 | + } |
|
| 782 | 817 | //error_log(__METHOD__."() date_default_timezone_get()=".date_default_timezone_get().", user-timezone=".Api\DateTime::$user_timezone->getName().", startdate=".$startdate->format().", enddate=".$enddate->format().", updated=".$modified->format().", olddate=".($olddate ? $olddate->format() : '')); |
| 783 | 818 | $owner_prefs = $ics = null; |
| 784 | 819 | foreach($to_notify as $userid => $statusid) |
| 785 | 820 | { |
| 786 | 821 | $res_info = $quantity = $role = null; |
| 787 | 822 | calendar_so::split_status($statusid, $quantity, $role); |
| 788 | - if ($this->debug > 0) error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 823 | + if ($this->debug > 0) |
|
| 824 | + { |
|
| 825 | + error_log(__METHOD__." trying to notify $userid, with $statusid ($role)"); |
|
| 826 | + } |
|
| 789 | 827 | |
| 790 | 828 | if (!is_numeric($userid)) |
| 791 | 829 | { |
@@ -804,7 +842,11 @@ discard block |
||
| 804 | 842 | |
| 805 | 843 | if (!isset($userid)) |
| 806 | 844 | { |
| 807 | - if (empty($res_info['email'])) continue; // no way to notify |
|
| 845 | + if (empty($res_info['email'])) |
|
| 846 | + { |
|
| 847 | + continue; |
|
| 848 | + } |
|
| 849 | + // no way to notify |
|
| 808 | 850 | // check if event-owner wants non-EGroupware users notified |
| 809 | 851 | if (is_null($owner_prefs)) |
| 810 | 852 | { |
@@ -868,11 +910,20 @@ discard block |
||
| 868 | 910 | $details = $this->_get_event_details(isset($cleared_event) ? $cleared_event : $event, |
| 869 | 911 | $action, $event_arr, $disinvited); |
| 870 | 912 | $details['to-fullname'] = $fullname; |
| 871 | - if (isset($tfn)) $details['to-firstname'] = $tfn; |
|
| 872 | - if (isset($tln)) $details['to-lastname'] = $tln; |
|
| 913 | + if (isset($tfn)) |
|
| 914 | + { |
|
| 915 | + $details['to-firstname'] = $tfn; |
|
| 916 | + } |
|
| 917 | + if (isset($tln)) |
|
| 918 | + { |
|
| 919 | + $details['to-lastname'] = $tln; |
|
| 920 | + } |
|
| 873 | 921 | |
| 874 | 922 | // event is in user-time of current user, now we need to calculate the tz-difference to the notified user and take it into account |
| 875 | - if (!isset($part_prefs['common']['tz'])) $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 923 | + if (!isset($part_prefs['common']['tz'])) |
|
| 924 | + { |
|
| 925 | + $part_prefs['common']['tz'] = $GLOBALS['egw_info']['server']['server_timezone']; |
|
| 926 | + } |
|
| 876 | 927 | $timezone = new DateTimeZone($part_prefs['common']['tz']); |
| 877 | 928 | $timeformat = $part_prefs['common']['timeformat']; |
| 878 | 929 | switch($timeformat) |
@@ -907,9 +958,12 @@ discard block |
||
| 907 | 958 | switch($msg_type == MSG_ALARM ? 'extended' : $part_prefs['calendar']['update_format']) |
| 908 | 959 | { |
| 909 | 960 | case 'ical': |
| 910 | - if (is_null($ics) || $m_type != $msg_type) // need different ical for organizer notification |
|
| 961 | + if (is_null($ics) || $m_type != $msg_type) |
|
| 962 | + { |
|
| 963 | + // need different ical for organizer notification |
|
| 911 | 964 | { |
| 912 | 965 | $calendar_ical = new calendar_ical(); |
| 966 | + } |
|
| 913 | 967 | $calendar_ical->setSupportedFields('full'); // full iCal fields+event TZ |
| 914 | 968 | // we need to pass $event[id] so iCal class reads event again, |
| 915 | 969 | // as event is in user TZ, but iCal class expects server TZ! |
@@ -923,7 +977,10 @@ discard block |
||
| 923 | 977 | 'encoding' => '8bit', |
| 924 | 978 | 'type' => 'text/calendar; method='.$method, |
| 925 | 979 | ); |
| 926 | - if ($m_type != $msg_type) unset($ics); |
|
| 980 | + if ($m_type != $msg_type) |
|
| 981 | + { |
|
| 982 | + unset($ics); |
|
| 983 | + } |
|
| 927 | 984 | $subject = isset($cleared_event) ? $cleared_event['title'] : $event['title']; |
| 928 | 985 | // fall through |
| 929 | 986 | case 'extended': |
@@ -974,7 +1031,9 @@ discard block |
||
| 974 | 1031 | $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); |
| 975 | 1032 | $notification->set_popuplinks(array($details['link_arr'])); |
| 976 | 1033 | |
| 977 | - if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } |
|
| 1034 | + if(is_array($attachment)) |
|
| 1035 | + { |
|
| 1036 | +$notification->set_attachments(array($attachment)); } |
|
| 978 | 1037 | $notification->send(); |
| 979 | 1038 | } |
| 980 | 1039 | catch (Exception $exception) { |
@@ -1006,7 +1065,10 @@ discard block |
||
| 1006 | 1065 | Api\Translation::init(); |
| 1007 | 1066 | } |
| 1008 | 1067 | // restore timezone, in case we had to reset it to server-timezone |
| 1009 | - if ($restore_tz) date_default_timezone_set($restore_tz); |
|
| 1068 | + if ($restore_tz) |
|
| 1069 | + { |
|
| 1070 | + date_default_timezone_set($restore_tz); |
|
| 1071 | + } |
|
| 1010 | 1072 | |
| 1011 | 1073 | return true; |
| 1012 | 1074 | } |
@@ -1041,10 +1103,13 @@ discard block |
||
| 1041 | 1103 | { |
| 1042 | 1104 | $to_notify = $event['participants']; |
| 1043 | 1105 | } |
| 1044 | - elseif ($this->check_perms(Acl::READ,$event)) // checks agains $this->owner set to $alarm[owner] |
|
| 1106 | + elseif ($this->check_perms(Acl::READ,$event)) |
|
| 1107 | + { |
|
| 1108 | + // checks agains $this->owner set to $alarm[owner] |
|
| 1045 | 1109 | { |
| 1046 | 1110 | $to_notify[$alarm['owner']] = 'A'; |
| 1047 | 1111 | } |
| 1112 | + } |
|
| 1048 | 1113 | else |
| 1049 | 1114 | { |
| 1050 | 1115 | return False; // no rights |
@@ -1094,7 +1159,10 @@ discard block |
||
| 1094 | 1159 | if ($event['id']) |
| 1095 | 1160 | { |
| 1096 | 1161 | // invalidate the read-cache if it contains the event we store now |
| 1097 | - if ($event['id'] == self::$cached_event['id']) self::$cached_event = array(); |
|
| 1162 | + if ($event['id'] == self::$cached_event['id']) |
|
| 1163 | + { |
|
| 1164 | + self::$cached_event = array(); |
|
| 1165 | + } |
|
| 1098 | 1166 | $old_event = $this->read($event['id'], $event['recurrence'], false, 'server'); |
| 1099 | 1167 | } |
| 1100 | 1168 | else |
@@ -1102,7 +1170,10 @@ discard block |
||
| 1102 | 1170 | $old_event = null; |
| 1103 | 1171 | } |
| 1104 | 1172 | |
| 1105 | - if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); |
|
| 1173 | + if (!isset($event['whole_day'])) |
|
| 1174 | + { |
|
| 1175 | + $event['whole_day'] = $this->isWholeDay($event); |
|
| 1176 | + } |
|
| 1106 | 1177 | $save_event = $event; |
| 1107 | 1178 | if ($event['whole_day']) |
| 1108 | 1179 | { |
@@ -1143,7 +1214,10 @@ discard block |
||
| 1143 | 1214 | foreach($timestamps as $ts) |
| 1144 | 1215 | { |
| 1145 | 1216 | // we convert here from user-time to timestamps in server-time! |
| 1146 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1217 | + if (isset($event[$ts])) |
|
| 1218 | + { |
|
| 1219 | + $event[$ts] = $event[$ts] ? $this->date2ts($event[$ts],true) : 0; |
|
| 1220 | + } |
|
| 1147 | 1221 | } |
| 1148 | 1222 | // convert tzid name to integer tz_id, of set user default |
| 1149 | 1223 | if (empty($event['tzid']) || !($event['tz_id'] = calendar_timezones::tz2id($event['tzid']))) |
@@ -1193,7 +1267,10 @@ discard block |
||
| 1193 | 1267 | if (!isset($event['alarm'][$id])) |
| 1194 | 1268 | { |
| 1195 | 1269 | $alarm['time'] = $event['start'] - $alarm['offset']; |
| 1196 | - if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm); |
|
| 1270 | + if ($alarm['time'] < time()) |
|
| 1271 | + { |
|
| 1272 | + calendar_so::shift_alarm($event, $alarm); |
|
| 1273 | + } |
|
| 1197 | 1274 | // remove (not store) alarms belonging to not longer existing or rejected participants |
| 1198 | 1275 | $status = isset($event['participants']) ? $event['participants'][$alarm['owner']] : |
| 1199 | 1276 | $old_event['participants'][$alarm['owner']]; |
@@ -1246,7 +1323,10 @@ discard block |
||
| 1246 | 1323 | |
| 1247 | 1324 | // Update history |
| 1248 | 1325 | $tracking = new calendar_tracking($this); |
| 1249 | - if (empty($event['id']) && !empty($cal_id)) $event['id']=$cal_id; |
|
| 1326 | + if (empty($event['id']) && !empty($cal_id)) |
|
| 1327 | + { |
|
| 1328 | + $event['id']=$cal_id; |
|
| 1329 | + } |
|
| 1250 | 1330 | $tracking->track($event, $old_event); |
| 1251 | 1331 | |
| 1252 | 1332 | return $cal_id; |
@@ -1263,9 +1343,12 @@ discard block |
||
| 1263 | 1343 | */ |
| 1264 | 1344 | function check_status_perms($uid,$event) |
| 1265 | 1345 | { |
| 1266 | - if ($uid[0] == 'c' || $uid[0] == 'e') // for contact we use the owner of the event |
|
| 1346 | + if ($uid[0] == 'c' || $uid[0] == 'e') |
|
| 1347 | + { |
|
| 1348 | + // for contact we use the owner of the event |
|
| 1267 | 1349 | { |
| 1268 | 1350 | if (!is_array($event) && !($event = $this->read($event))) return false; |
| 1351 | + } |
|
| 1269 | 1352 | |
| 1270 | 1353 | return $this->check_perms(Acl::EDIT,0,$event['owner']); |
| 1271 | 1354 | } |
@@ -1276,13 +1359,19 @@ discard block |
||
| 1276 | 1359 | return $access; |
| 1277 | 1360 | } |
| 1278 | 1361 | // no access or denied access because of category acl --> regular check |
| 1279 | - if (!is_numeric($uid)) // this is eg. for resources (r123) |
|
| 1362 | + if (!is_numeric($uid)) |
|
| 1363 | + { |
|
| 1364 | + // this is eg. for resources (r123) |
|
| 1280 | 1365 | { |
| 1281 | 1366 | $resource = $this->resource_info($uid); |
| 1367 | + } |
|
| 1282 | 1368 | |
| 1283 | 1369 | return Acl::EDIT & $resource['rights']; |
| 1284 | 1370 | } |
| 1285 | - if (!is_array($event) && !($event = $this->read($event))) return false; |
|
| 1371 | + if (!is_array($event) && !($event = $this->read($event))) |
|
| 1372 | + { |
|
| 1373 | + return false; |
|
| 1374 | + } |
|
| 1286 | 1375 | |
| 1287 | 1376 | // regular user and groups (need to check memberships too) |
| 1288 | 1377 | if (!isset($event['participants'][$uid])) |
@@ -1306,7 +1395,10 @@ discard block |
||
| 1306 | 1395 | */ |
| 1307 | 1396 | function check_cat_acl($right,$event) |
| 1308 | 1397 | { |
| 1309 | - if (!is_array($event)) $event = $this->read($event); |
|
| 1398 | + if (!is_array($event)) |
|
| 1399 | + { |
|
| 1400 | + $event = $this->read($event); |
|
| 1401 | + } |
|
| 1310 | 1402 | |
| 1311 | 1403 | $ret = null; |
| 1312 | 1404 | if ($event['category']) |
@@ -1363,7 +1455,10 @@ discard block |
||
| 1363 | 1455 | public static function set_cat_rights($cat_id,$user,$rights) |
| 1364 | 1456 | { |
| 1365 | 1457 | //echo "<p>".__METHOD__."($cat_id,$user,$rights)</p>\n"; |
| 1366 | - if (!isset(self::$cat_rights_cache)) self::get_cat_rights($cat_id); |
|
| 1458 | + if (!isset(self::$cat_rights_cache)) |
|
| 1459 | + { |
|
| 1460 | + self::get_cat_rights($cat_id); |
|
| 1461 | + } |
|
| 1367 | 1462 | |
| 1368 | 1463 | if ((int)$rights != (int)self::$cat_rights_cache['L'.$cat_id][$user]) |
| 1369 | 1464 | { |
@@ -1375,7 +1470,10 @@ discard block |
||
| 1375 | 1470 | else |
| 1376 | 1471 | { |
| 1377 | 1472 | unset(self::$cat_rights_cache['L'.$cat_id][$user]); |
| 1378 | - if (!self::$cat_rights_cache['L'.$cat_id]) unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1473 | + if (!self::$cat_rights_cache['L'.$cat_id]) |
|
| 1474 | + { |
|
| 1475 | + unset(self::$cat_rights_cache['L'.$cat_id]); |
|
| 1476 | + } |
|
| 1379 | 1477 | $GLOBALS['egw']->acl->delete_repository('calendar','L'.$cat_id,$user); |
| 1380 | 1478 | } |
| 1381 | 1479 | Api\Cache::setSession('calendar','cat_rights',self::$cat_rights_cache); |
@@ -1408,7 +1506,10 @@ discard block |
||
| 1408 | 1506 | foreach($cat_rights as $uid => $value) |
| 1409 | 1507 | { |
| 1410 | 1508 | $all |= $value; |
| 1411 | - if (in_array($uid,$memberships)) $own |= $value; |
|
| 1509 | + if (in_array($uid,$memberships)) |
|
| 1510 | + { |
|
| 1511 | + $own |= $value; |
|
| 1512 | + } |
|
| 1412 | 1513 | } |
| 1413 | 1514 | } |
| 1414 | 1515 | foreach(array(self::CAT_ACL_ADD,self::CAT_ACL_STATUS) as $mask) |
@@ -1455,13 +1556,16 @@ discard block |
||
| 1455 | 1556 | is_numeric($uid)?$uid:substr($uid,1),$status, |
| 1456 | 1557 | $recur_date?$this->date2ts($recur_date,true):0,$role))) |
| 1457 | 1558 | { |
| 1458 | - if ($status == 'R') // remove alarms belonging to rejected participants |
|
| 1559 | + if ($status == 'R') |
|
| 1560 | + { |
|
| 1561 | + // remove alarms belonging to rejected participants |
|
| 1459 | 1562 | { |
| 1460 | 1563 | foreach(isset($event['alarm']) ? $event['alarm'] : $old_event['alarm'] as $id => $alarm) |
| 1461 | 1564 | { |
| 1462 | 1565 | if ((string)$alarm['owner'] === (string)$uid) |
| 1463 | 1566 | { |
| 1464 | 1567 | $this->so->delete_alarm($id); |
| 1568 | + } |
|
| 1465 | 1569 | //error_log(__LINE__.': '.__METHOD__."(".array2string($event).", '$uid', '$status', ...) deleting alarm=".array2string($alarm).", $status=".array2string($alarm)); |
| 1466 | 1570 | } |
| 1467 | 1571 | } |
@@ -1475,8 +1579,15 @@ discard block |
||
| 1475 | 1579 | ); |
| 1476 | 1580 | if (isset($status2msg[$status]) && !$skip_notification) |
| 1477 | 1581 | { |
| 1478 | - if (!is_array($event)) $event = $this->read($cal_id); |
|
| 1479 | - if (isset($recur_date)) $event = $this->read($event['id'],$recur_date); //re-read the actually edited recurring event |
|
| 1582 | + if (!is_array($event)) |
|
| 1583 | + { |
|
| 1584 | + $event = $this->read($cal_id); |
|
| 1585 | + } |
|
| 1586 | + if (isset($recur_date)) |
|
| 1587 | + { |
|
| 1588 | + $event = $this->read($event['id'],$recur_date); |
|
| 1589 | + } |
|
| 1590 | + //re-read the actually edited recurring event |
|
| 1480 | 1591 | $this->send_update($status2msg[$status],$event['participants'],$event); |
| 1481 | 1592 | } |
| 1482 | 1593 | |
@@ -1499,12 +1610,16 @@ discard block |
||
| 1499 | 1610 | */ |
| 1500 | 1611 | function update_status($new_event, $old_event , $recur_date=0, $skip_notification=false) |
| 1501 | 1612 | { |
| 1502 | - if (!isset($new_event['participants'])) return; |
|
| 1613 | + if (!isset($new_event['participants'])) |
|
| 1614 | + { |
|
| 1615 | + return; |
|
| 1616 | + } |
|
| 1503 | 1617 | |
| 1504 | 1618 | // check the old list against the new list |
| 1505 | 1619 | foreach ($old_event['participants'] as $userid => $status) |
| 1506 | - { |
|
| 1507 | - if (!isset($new_event['participants'][$userid])){ |
|
| 1620 | + { |
|
| 1621 | + if (!isset($new_event['participants'][$userid])) |
|
| 1622 | + { |
|
| 1508 | 1623 | // Attendee will be deleted this way |
| 1509 | 1624 | $new_event['participants'][$userid] = 'G'; |
| 1510 | 1625 | } |
@@ -1587,7 +1702,10 @@ discard block |
||
| 1587 | 1702 | } |
| 1588 | 1703 | else |
| 1589 | 1704 | { |
| 1590 | - if (!($exception = $this->read($id))) continue; |
|
| 1705 | + if (!($exception = $this->read($id))) |
|
| 1706 | + { |
|
| 1707 | + continue; |
|
| 1708 | + } |
|
| 1591 | 1709 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 1592 | 1710 | $exception['reference'] = $exception['recurrence'] = 0; |
| 1593 | 1711 | $this->update($exception, true, true, false, true, $msg=null, true); |
@@ -1658,7 +1776,10 @@ discard block |
||
| 1658 | 1776 | $event_arr = $this->event2array($event); |
| 1659 | 1777 | foreach($event_arr as $key => $val) |
| 1660 | 1778 | { |
| 1661 | - if ($key == 'recur_type') $key = 'repetition'; |
|
| 1779 | + if ($key == 'recur_type') |
|
| 1780 | + { |
|
| 1781 | + $key = 'repetition'; |
|
| 1782 | + } |
|
| 1662 | 1783 | $details[$key] = $val['data']; |
| 1663 | 1784 | } |
| 1664 | 1785 | $details['participants'] = $details['participants'] ? implode("\n",$details['participants']) : ''; |
@@ -1830,7 +1951,10 @@ discard block |
||
| 1830 | 1951 | */ |
| 1831 | 1952 | function check_move_alarms(Array &$event, Array $old_event = null, Api\DateTime $instance_date = null) |
| 1832 | 1953 | { |
| 1833 | - if ($old_event !== null && $event['start'] == $old_event['start']) return; |
|
| 1954 | + if ($old_event !== null && $event['start'] == $old_event['start']) |
|
| 1955 | + { |
|
| 1956 | + return; |
|
| 1957 | + } |
|
| 1834 | 1958 | |
| 1835 | 1959 | $time = new Api\DateTime($event['start']); |
| 1836 | 1960 | if(!is_array($event['alarm'])) |
@@ -1904,7 +2028,10 @@ discard block |
||
| 1904 | 2028 | if (is_array($old_event) || $old_event > 0) |
| 1905 | 2029 | { |
| 1906 | 2030 | // preserve categories without users read access |
| 1907 | - if (!is_array($old_event)) $old_event = $this->read($old_event); |
|
| 2031 | + if (!is_array($old_event)) |
|
| 2032 | + { |
|
| 2033 | + $old_event = $this->read($old_event); |
|
| 2034 | + } |
|
| 1908 | 2035 | $old_categories = explode(',',$old_event['category']); |
| 1909 | 2036 | $old_cats_preserve = array(); |
| 1910 | 2037 | if (is_array($old_categories) && count($old_categories) > 0) |
@@ -1995,7 +2122,10 @@ discard block |
||
| 1995 | 2122 | "($filter)[EVENT]:" . array2string($event)."\n",3,$this->logfile); |
| 1996 | 2123 | } |
| 1997 | 2124 | |
| 1998 | - if (!isset($event['recurrence'])) $event['recurrence'] = 0; |
|
| 2125 | + if (!isset($event['recurrence'])) |
|
| 2126 | + { |
|
| 2127 | + $event['recurrence'] = 0; |
|
| 2128 | + } |
|
| 1999 | 2129 | |
| 2000 | 2130 | if ($filter == 'master') |
| 2001 | 2131 | { |
@@ -2049,19 +2179,26 @@ discard block |
||
| 2049 | 2179 | $matchingEvents[] = $egwEvent['id'] . ':' . (int)$event['recurrence']; |
| 2050 | 2180 | } |
| 2051 | 2181 | } |
| 2052 | - } elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2182 | + } |
|
| 2183 | + elseif ($filter != 'master' && ($filter == 'exact' || |
|
| 2053 | 2184 | $event['recur_type'] == $egwEvent['recur_type'] && |
| 2054 | 2185 | strpos($egwEvent['title'], $event['title']) === 0)) |
| 2055 | 2186 | { |
| 2056 | 2187 | $matchingEvents[] = $egwEvent['id']; // we found the event |
| 2057 | 2188 | } |
| 2058 | 2189 | } |
| 2059 | - if (!empty($matchingEvents) || $filter == 'exact') return $matchingEvents; |
|
| 2190 | + if (!empty($matchingEvents) || $filter == 'exact') |
|
| 2191 | + { |
|
| 2192 | + return $matchingEvents; |
|
| 2193 | + } |
|
| 2060 | 2194 | } |
| 2061 | 2195 | unset($event['id']); |
| 2062 | 2196 | |
| 2063 | 2197 | // No chance to find a master without [U]ID |
| 2064 | - if ($filter == 'master' && empty($event['uid'])) return $matchingEvents; |
|
| 2198 | + if ($filter == 'master' && empty($event['uid'])) |
|
| 2199 | + { |
|
| 2200 | + return $matchingEvents; |
|
| 2201 | + } |
|
| 2065 | 2202 | |
| 2066 | 2203 | // only query calendars of users, we have READ-grants from |
| 2067 | 2204 | $users = array(); |
@@ -2070,17 +2207,23 @@ discard block |
||
| 2070 | 2207 | $user = trim($user); |
| 2071 | 2208 | if ($this->check_perms(Acl::READ|self::ACL_READ_FOR_PARTICIPANTS|self::ACL_FREEBUSY,0,$user)) |
| 2072 | 2209 | { |
| 2073 | - if ($user && !in_array($user,$users)) // already added? |
|
| 2210 | + if ($user && !in_array($user,$users)) |
|
| 2211 | + { |
|
| 2212 | + // already added? |
|
| 2074 | 2213 | { |
| 2075 | 2214 | $users[] = $user; |
| 2076 | 2215 | } |
| 2216 | + } |
|
| 2077 | 2217 | } |
| 2078 | 2218 | elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g') |
| 2079 | 2219 | { |
| 2080 | 2220 | continue; // for non-groups (eg. users), we stop here if we have no read-rights |
| 2081 | 2221 | } |
| 2082 | 2222 | // the further code is only for real users |
| 2083 | - if (!is_numeric($user)) continue; |
|
| 2223 | + if (!is_numeric($user)) |
|
| 2224 | + { |
|
| 2225 | + continue; |
|
| 2226 | + } |
|
| 2084 | 2227 | |
| 2085 | 2228 | // for groups we have to include the members |
| 2086 | 2229 | if ($GLOBALS['egw']->accounts->get_type($user) == 'g') |
@@ -2160,7 +2303,10 @@ discard block |
||
| 2160 | 2303 | } |
| 2161 | 2304 | foreach ($matchFields as $key) |
| 2162 | 2305 | { |
| 2163 | - if (isset($event[$key])) $query['cal_'.$key] = $event[$key]; |
|
| 2306 | + if (isset($event[$key])) |
|
| 2307 | + { |
|
| 2308 | + $query['cal_'.$key] = $event[$key]; |
|
| 2309 | + } |
|
| 2164 | 2310 | } |
| 2165 | 2311 | } |
| 2166 | 2312 | |
@@ -2200,7 +2346,10 @@ discard block |
||
| 2200 | 2346 | '[FOUND]: ' . array2string($egwEvent)."\n",3,$this->logfile); |
| 2201 | 2347 | } |
| 2202 | 2348 | |
| 2203 | - if (in_array($egwEvent['id'], $matchingEvents)) continue; |
|
| 2349 | + if (in_array($egwEvent['id'], $matchingEvents)) |
|
| 2350 | + { |
|
| 2351 | + continue; |
|
| 2352 | + } |
|
| 2204 | 2353 | |
| 2205 | 2354 | // convert timezone id of event to tzid (iCal id like 'Europe/Berlin') |
| 2206 | 2355 | if (!$egwEvent['tz_id'] || !($egwEvent['tzid'] = calendar_timezones::id2tz($egwEvent['tz_id']))) |
@@ -2367,13 +2516,16 @@ discard block |
||
| 2367 | 2516 | foreach ($event['participants'] as $attendee => $status) |
| 2368 | 2517 | { |
| 2369 | 2518 | if (!isset($egwEvent['participants'][$attendee]) && |
| 2370 | - $attendee != $egwEvent['owner']) // || |
|
| 2519 | + $attendee != $egwEvent['owner']) |
|
| 2520 | + { |
|
| 2521 | + // || |
|
| 2371 | 2522 | //(!$relax && $egw_event['participants'][$attendee] != $status)) |
| 2372 | 2523 | { |
| 2373 | 2524 | if ($this->log) |
| 2374 | 2525 | { |
| 2375 | 2526 | error_log(__FILE__.'['.__LINE__.'] '.__METHOD__. |
| 2376 | 2527 | "() additional event['participants']: $attendee\n",3,$this->logfile); |
| 2528 | + } |
|
| 2377 | 2529 | } |
| 2378 | 2530 | continue 2; |
| 2379 | 2531 | } |
@@ -2695,7 +2847,10 @@ discard block |
||
| 2695 | 2847 | foreach(array('start','end','recur_enddate','recurrence') as $ts) |
| 2696 | 2848 | { |
| 2697 | 2849 | // we convert here from server-time to timestamps in user-time! |
| 2698 | - if (isset($event[$ts])) $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 2850 | + if (isset($event[$ts])) |
|
| 2851 | + { |
|
| 2852 | + $event[$ts] = $event[$ts] ? $this->date2usertime($event[$ts]) : 0; |
|
| 2853 | + } |
|
| 2699 | 2854 | } |
| 2700 | 2855 | // same with the recur exceptions |
| 2701 | 2856 | if (isset($event['recur_exception']) && is_array($event['recur_exception'])) |
@@ -2723,9 +2878,12 @@ discard block |
||
| 2723 | 2878 | */ |
| 2724 | 2879 | function purge($age) |
| 2725 | 2880 | { |
| 2726 | - if (is_numeric($age) && $age > 0) // just make sure bogus values dont delete everything |
|
| 2881 | + if (is_numeric($age) && $age > 0) |
|
| 2882 | + { |
|
| 2883 | + // just make sure bogus values dont delete everything |
|
| 2727 | 2884 | { |
| 2728 | 2885 | $this->so->purge(time() - 365*24*3600*(float)$age); |
| 2729 | 2886 | } |
| 2887 | + } |
|
| 2730 | 2888 | } |
| 2731 | 2889 | } |