@@ -1077,7 +1077,7 @@ discard block |
||
| 1077 | 1077 | * date instead of today |
| 1078 | 1078 | * @param boolean $no_notifications Toggle notifications to participants |
| 1079 | 1079 | * |
| 1080 | - * @return false or error message |
|
| 1080 | + * @return string|false or error message |
|
| 1081 | 1081 | */ |
| 1082 | 1082 | function _break_recurring(&$event, $old_event, $as_of_date = null, $no_notifications = true) |
| 1083 | 1083 | { |
@@ -2173,7 +2173,7 @@ discard block |
||
| 2173 | 2173 | * Freetime search |
| 2174 | 2174 | * |
| 2175 | 2175 | * As the function is called in a popup via javascript, parametes get initialy transfered via the url |
| 2176 | - * @param array $content=null array with parameters or false (default) to use the get-params |
|
| 2176 | + * @param array $content array with parameters or false (default) to use the get-params |
|
| 2177 | 2177 | * @param string start[str] start-date |
| 2178 | 2178 | * @param string start[hour] start-hour |
| 2179 | 2179 | * @param string start[min] start-minutes |
@@ -2417,7 +2417,7 @@ discard block |
||
| 2417 | 2417 | /** |
| 2418 | 2418 | * Export events as vCalendar version 2.0 files (iCal) |
| 2419 | 2419 | * |
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2420 | + * @param integer $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | 2421 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2422 | 2422 | * @return string error-msg if $return_error |
| 2423 | 2423 | */ |
@@ -2415,14 +2415,14 @@ discard block |
||
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | /** |
| 2418 | - * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | - * |
|
| 2420 | - * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | - * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | - * @return string error-msg if $return_error |
|
| 2423 | - */ |
|
| 2424 | - function export($content=0,$return_error=false) |
|
| 2425 | - { |
|
| 2418 | + * Export events as vCalendar version 2.0 files (iCal) |
|
| 2419 | + * |
|
| 2420 | + * @param int|array $content numeric cal_id or submitted content from etempalte::exec |
|
| 2421 | + * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
|
| 2422 | + * @return string error-msg if $return_error |
|
| 2423 | + */ |
|
| 2424 | + function export($content=0,$return_error=false) |
|
| 2425 | + { |
|
| 2426 | 2426 | $boical = new calendar_ical(); |
| 2427 | 2427 | #error_log(__METHOD__.print_r($content,true)); |
| 2428 | 2428 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
@@ -2476,7 +2476,7 @@ discard block |
||
| 2476 | 2476 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
| 2477 | 2477 | $etpl = new etemplate_new('calendar.export'); |
| 2478 | 2478 | $etpl->exec('calendar.calendar_uiforms.export',$content); |
| 2479 | - } |
|
| 2479 | + } |
|
| 2480 | 2480 | |
| 2481 | 2481 | /** |
| 2482 | 2482 | * Edit category ACL (admin only) |
@@ -2548,8 +2548,8 @@ discard block |
||
| 2548 | 2548 | } |
| 2549 | 2549 | |
| 2550 | 2550 | /** |
| 2551 | - * Set up the required fields to get the history tab |
|
| 2552 | - */ |
|
| 2551 | + * Set up the required fields to get the history tab |
|
| 2552 | + */ |
|
| 2553 | 2553 | public function setup_history(&$content, &$sel_options) |
| 2554 | 2554 | { |
| 2555 | 2555 | $status = 'history_status'; |
@@ -2890,11 +2890,11 @@ |
||
| 2890 | 2890 | { |
| 2891 | 2891 | $msg = lang('Event deleted'); |
| 2892 | 2892 | } |
| 2893 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 2893 | + $response->apply('egw.refresh', array($msg,'calendar',$eventId,'delete')); |
|
| 2894 | 2894 | } |
| 2895 | 2895 | else |
| 2896 | 2896 | { |
| 2897 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 2897 | + $response->apply('egw.message', array(lang('Error')),'error'); |
|
| 2898 | 2898 | } |
| 2899 | 2899 | } |
| 2900 | 2900 | |
@@ -598,220 +598,220 @@ discard block |
||
| 598 | 598 | |
| 599 | 599 | switch((string)$button) |
| 600 | 600 | { |
| 601 | - case 'exception': // create an exception in a recuring event |
|
| 602 | - $msg = $this->_create_exception($event,$preserv); |
|
| 603 | - break; |
|
| 601 | + case 'exception': // create an exception in a recuring event |
|
| 602 | + $msg = $this->_create_exception($event,$preserv); |
|
| 603 | + break; |
|
| 604 | 604 | |
| 605 | - case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 606 | - unset($event['id']); |
|
| 607 | - unset($event['uid']); |
|
| 608 | - unset($event['reference']); |
|
| 609 | - unset($preserv['reference']); |
|
| 610 | - unset($event['recurrence']); |
|
| 611 | - unset($preserv['recurrence']); |
|
| 612 | - unset($event['recur_exception']); |
|
| 613 | - unset($event['edit_single']); // in case it has been set |
|
| 614 | - unset($event['modified']); |
|
| 615 | - unset($event['modifier']); |
|
| 616 | - unset($event['caldav_name']); |
|
| 617 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 605 | + case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
|
| 606 | + unset($event['id']); |
|
| 607 | + unset($event['uid']); |
|
| 608 | + unset($event['reference']); |
|
| 609 | + unset($preserv['reference']); |
|
| 610 | + unset($event['recurrence']); |
|
| 611 | + unset($preserv['recurrence']); |
|
| 612 | + unset($event['recur_exception']); |
|
| 613 | + unset($event['edit_single']); // in case it has been set |
|
| 614 | + unset($event['modified']); |
|
| 615 | + unset($event['modifier']); |
|
| 616 | + unset($event['caldav_name']); |
|
| 617 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 618 | + |
|
| 619 | + // Clear participant stati |
|
| 620 | + foreach($event['participant_types'] as $type => &$participants) |
|
| 621 | + { |
|
| 622 | + foreach($participants as $id => &$p_response) |
|
| 623 | + { |
|
| 624 | + if($type == 'u' && $id == $event['owner']) continue; |
|
| 625 | + calendar_so::split_status($p_response, $quantity, $role); |
|
| 626 | + // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 627 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 628 | + $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 629 | + } |
|
| 630 | + } |
|
| 618 | 631 | |
| 619 | - // Clear participant stati |
|
| 620 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 621 | - { |
|
| 622 | - foreach($participants as $id => &$p_response) |
|
| 632 | + // Copy alarms |
|
| 633 | + if (is_array($event['alarm'])) |
|
| 623 | 634 | { |
| 624 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 625 | - calendar_so::split_status($p_response, $quantity, $role); |
|
| 626 | - // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
|
| 627 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 628 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 635 | + foreach($event['alarm'] as $n => &$alarm) |
|
| 636 | + { |
|
| 637 | + unset($alarm['id']); |
|
| 638 | + unset($alarm['cal_id']); |
|
| 639 | + } |
|
| 629 | 640 | } |
| 630 | - } |
|
| 631 | 641 | |
| 632 | - // Copy alarms |
|
| 633 | - if (is_array($event['alarm'])) |
|
| 634 | - { |
|
| 635 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 642 | + // Get links to be copied |
|
| 643 | + // With no ID, $content['link_to']['to_id'] is used |
|
| 644 | + $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 645 | + foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 636 | 646 | { |
| 637 | - unset($alarm['id']); |
|
| 638 | - unset($alarm['cal_id']); |
|
| 647 | + if ($link['app'] != Link::VFS_APPNAME) |
|
| 648 | + { |
|
| 649 | + Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 650 | + } |
|
| 651 | + elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 652 | + { |
|
| 653 | + Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 654 | + 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 655 | + 'name' => $link['id'], |
|
| 656 | + ), $link['remark']); |
|
| 657 | + } |
|
| 639 | 658 | } |
| 640 | - } |
|
| 659 | + unset($link); |
|
| 660 | + $preserv['view'] = $preserv['edit_single'] = false; |
|
| 661 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 662 | + $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 663 | + break; |
|
| 641 | 664 | |
| 642 | - // Get links to be copied |
|
| 643 | - // With no ID, $content['link_to']['to_id'] is used |
|
| 644 | - $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
|
| 645 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 646 | - { |
|
| 647 | - if ($link['app'] != Link::VFS_APPNAME) |
|
| 665 | + case 'mail': |
|
| 666 | + case 'sendrequest': |
|
| 667 | + case 'save': |
|
| 668 | + case 'print': |
|
| 669 | + case 'apply': |
|
| 670 | + case 'infolog': |
|
| 671 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 648 | 672 | { |
| 649 | - Link::link('calendar', $content['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
|
| 673 | + $msg = lang('Permission denied'); |
|
| 674 | + $button = ''; |
|
| 675 | + break; |
|
| 650 | 676 | } |
| 651 | - elseif ($link['app'] == Link::VFS_APPNAME) |
|
| 677 | + if ($event['start'] > $event['end']) |
|
| 652 | 678 | { |
| 653 | - Link::link('calendar', $content['link_to']['to_id'], Link::VFS_APPNAME, array( |
|
| 654 | - 'tmp_name' => Link::vfs_path($link['app2'], $link['id2']).'/'.$link['id'], |
|
| 655 | - 'name' => $link['id'], |
|
| 656 | - ), $link['remark']); |
|
| 679 | + $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 680 | + $button = ''; |
|
| 681 | + break; |
|
| 657 | 682 | } |
| 658 | - } |
|
| 659 | - unset($link); |
|
| 660 | - $preserv['view'] = $preserv['edit_single'] = false; |
|
| 661 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 662 | - $event['title'] = lang('Copy of:').' '.$event['title']; |
|
| 663 | - break; |
|
| 664 | - |
|
| 665 | - case 'mail': |
|
| 666 | - case 'sendrequest': |
|
| 667 | - case 'save': |
|
| 668 | - case 'print': |
|
| 669 | - case 'apply': |
|
| 670 | - case 'infolog': |
|
| 671 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 672 | - { |
|
| 673 | - $msg = lang('Permission denied'); |
|
| 674 | - $button = ''; |
|
| 675 | - break; |
|
| 676 | - } |
|
| 677 | - if ($event['start'] > $event['end']) |
|
| 678 | - { |
|
| 679 | - $msg = lang('Error: Starttime has to be before the endtime !!!'); |
|
| 680 | - $button = ''; |
|
| 681 | - break; |
|
| 682 | - } |
|
| 683 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 684 | - { |
|
| 685 | - $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 686 | - $button = ''; |
|
| 687 | - break; |
|
| 688 | - } |
|
| 689 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 690 | - { |
|
| 691 | - $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 692 | - $button = ''; |
|
| 693 | - break; |
|
| 694 | - } |
|
| 695 | - if (!$event['participants']) |
|
| 696 | - { |
|
| 697 | - $msg = lang('Error: no participants selected !!!'); |
|
| 698 | - $button = ''; |
|
| 699 | - break; |
|
| 700 | - } |
|
| 701 | - // if private event with ressource reservation is forbidden |
|
| 702 | - if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 703 | - { |
|
| 704 | - foreach (array_keys($event['participants']) as $uid) |
|
| 683 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['recur_enddate'] && $event['start'] > $event['recur_enddate']) |
|
| 684 | + { |
|
| 685 | + $msg = lang('repetition').': '.lang('Error: Starttime has to be before the endtime !!!'); |
|
| 686 | + $button = ''; |
|
| 687 | + break; |
|
| 688 | + } |
|
| 689 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 690 | + { |
|
| 691 | + $msg = lang('Error: Duration of event longer then recurrence interval!'); |
|
| 692 | + $button = ''; |
|
| 693 | + break; |
|
| 694 | + } |
|
| 695 | + if (!$event['participants']) |
|
| 705 | 696 | { |
| 706 | - if ($uid[0] == 'r') //ressource detection |
|
| 697 | + $msg = lang('Error: no participants selected !!!'); |
|
| 698 | + $button = ''; |
|
| 699 | + break; |
|
| 700 | + } |
|
| 701 | + // if private event with ressource reservation is forbidden |
|
| 702 | + if (!$event['public'] && $GLOBALS['egw_info']['server']['no_ressources_private']) |
|
| 703 | + { |
|
| 704 | + foreach (array_keys($event['participants']) as $uid) |
|
| 707 | 705 | { |
| 708 | - $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 709 | - $button = ''; |
|
| 710 | - break 2; //break foreach and case |
|
| 706 | + if ($uid[0] == 'r') //ressource detection |
|
| 707 | + { |
|
| 708 | + $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
|
| 709 | + $button = ''; |
|
| 710 | + break 2; //break foreach and case |
|
| 711 | + } |
|
| 711 | 712 | } |
| 712 | 713 | } |
| 713 | - } |
|
| 714 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 715 | - { |
|
| 716 | - $event['reference'] = $event['id']; |
|
| 717 | - $event['recurrence'] = $content['edit_single']; |
|
| 718 | - unset($event['id']); |
|
| 719 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 720 | - if (!is_array($conflicts) && $conflicts) |
|
| 714 | + if ($content['edit_single']) // we edited a single event from a series |
|
| 721 | 715 | { |
| 722 | - // now we need to add the original start as recur-execption to the series |
|
| 723 | - $recur_event = $this->bo->read($event['reference']); |
|
| 724 | - $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 725 | - // check if we need to move the alarms, because they are next on that exception |
|
| 726 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 716 | + $event['reference'] = $event['id']; |
|
| 717 | + $event['recurrence'] = $content['edit_single']; |
|
| 718 | + unset($event['id']); |
|
| 719 | + $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 720 | + if (!is_array($conflicts) && $conflicts) |
|
| 727 | 721 | { |
| 728 | - if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 722 | + // now we need to add the original start as recur-execption to the series |
|
| 723 | + $recur_event = $this->bo->read($event['reference']); |
|
| 724 | + $recur_event['recur_exception'][] = $content['edit_single']; |
|
| 725 | + // check if we need to move the alarms, because they are next on that exception |
|
| 726 | + foreach($recur_event['alarm'] as $id => $alarm) |
|
| 729 | 727 | { |
| 730 | - $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 731 | - foreach ($rrule as $time) |
|
| 728 | + if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
|
| 732 | 729 | { |
| 733 | - if ($content['edit_single'] < $time->format('ts')) |
|
| 730 | + $rrule = calendar_rrule::event2rrule($recur_event, true); |
|
| 731 | + foreach ($rrule as $time) |
|
| 734 | 732 | { |
| 735 | - $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 736 | - $this->bo->save_alarm($event['reference'], $alarm); |
|
| 737 | - break; |
|
| 733 | + if ($content['edit_single'] < $time->format('ts')) |
|
| 734 | + { |
|
| 735 | + $alarm['time'] = $time->format('ts') - $alarm['offset']; |
|
| 736 | + $this->bo->save_alarm($event['reference'], $alarm); |
|
| 737 | + break; |
|
| 738 | + } |
|
| 738 | 739 | } |
| 739 | 740 | } |
| 740 | 741 | } |
| 741 | - } |
|
| 742 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 743 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 744 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 742 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 743 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 744 | + $this->bo->update($recur_event,true); // no conflict check here |
|
| 745 | 745 | |
| 746 | - // Save links |
|
| 747 | - if($content['links']) |
|
| 748 | - { |
|
| 749 | - Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
| 750 | - } |
|
| 746 | + // Save links |
|
| 747 | + if($content['links']) |
|
| 748 | + { |
|
| 749 | + Link::link('calendar', $event['id'], $content['links']['to_id']); |
|
| 750 | + } |
|
| 751 | 751 | |
| 752 | - if(Api\Json\Response::isJSONResponse()) |
|
| 752 | + if(Api\Json\Response::isJSONResponse()) |
|
| 753 | + { |
|
| 754 | + // Sending null will trigger a removal of the original |
|
| 755 | + // for that date |
|
| 756 | + Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + unset($recur_event); |
|
| 760 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 761 | + unset($preserv['edit_single']); |
|
| 762 | + } |
|
| 763 | + else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 753 | 764 | { |
| 754 | - // Sending null will trigger a removal of the original |
|
| 755 | - // for that date |
|
| 756 | - Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$content['reference'].':'.$content['actual_date'], 'data' => null)); |
|
| 765 | + $event['id'] = $event['reference']; |
|
| 766 | + $event['reference'] = $event['recurrence'] = 0; |
|
| 767 | + $event['uid'] = $content['uid']; |
|
| 757 | 768 | } |
| 758 | - |
|
| 759 | - unset($recur_event); |
|
| 760 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 761 | - unset($preserv['edit_single']); |
|
| 769 | + $update_type = 'edit'; |
|
| 762 | 770 | } |
| 763 | - else // conflict or error, we need to reset everything to the state befor we tried to save it |
|
| 771 | + else // we edited a non-reccuring event or the whole series |
|
| 764 | 772 | { |
| 765 | - $event['id'] = $event['reference']; |
|
| 766 | - $event['reference'] = $event['recurrence'] = 0; |
|
| 767 | - $event['uid'] = $content['uid']; |
|
| 768 | - } |
|
| 769 | - $update_type = 'edit'; |
|
| 770 | - } |
|
| 771 | - else // we edited a non-reccuring event or the whole series |
|
| 772 | - { |
|
| 773 | - if (($old_event = $this->bo->read($event['id']))) |
|
| 774 | - { |
|
| 775 | - if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 773 | + if (($old_event = $this->bo->read($event['id']))) |
|
| 776 | 774 | { |
| 777 | - $update_type = 'edit'; |
|
| 778 | - |
|
| 779 | - // we edit a existing series event |
|
| 780 | - if ($event['start'] != $old_event['start'] || |
|
| 781 | - $event['whole_day'] != $old_event['whole_day'] || |
|
| 782 | - $event['end'] != $old_event['end']) |
|
| 775 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 783 | 776 | { |
| 784 | - // calculate offset against old series start or clicked recurrance, |
|
| 785 | - // depending on which is smaller |
|
| 786 | - $offset = $event['start'] - $old_event['start']; |
|
| 787 | - if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 788 | - { |
|
| 789 | - $offset = $off2; |
|
| 790 | - } |
|
| 791 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 792 | - if($msg) |
|
| 777 | + $update_type = 'edit'; |
|
| 778 | + |
|
| 779 | + // we edit a existing series event |
|
| 780 | + if ($event['start'] != $old_event['start'] || |
|
| 781 | + $event['whole_day'] != $old_event['whole_day'] || |
|
| 782 | + $event['end'] != $old_event['end']) |
|
| 793 | 783 | { |
| 794 | - $noerror = false; |
|
| 784 | + // calculate offset against old series start or clicked recurrance, |
|
| 785 | + // depending on which is smaller |
|
| 786 | + $offset = $event['start'] - $old_event['start']; |
|
| 787 | + if (abs($offset) > abs($off2 = $event['start'] - $event['actual_date'])) |
|
| 788 | + { |
|
| 789 | + $offset = $off2; |
|
| 790 | + } |
|
| 791 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 792 | + if($msg) |
|
| 793 | + { |
|
| 794 | + $noerror = false; |
|
| 795 | + } |
|
| 795 | 796 | } |
| 796 | 797 | } |
| 797 | - } |
|
| 798 | - else |
|
| 799 | - { |
|
| 800 | - if ($old_event['start'] != $event['start'] || |
|
| 801 | - $old_event['end'] != $event['end'] || |
|
| 802 | - $event['whole_day'] != $old_event['whole_day']) |
|
| 798 | + else |
|
| 803 | 799 | { |
| 804 | - $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 805 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 800 | + if ($old_event['start'] != $event['start'] || |
|
| 801 | + $old_event['end'] != $event['end'] || |
|
| 802 | + $event['whole_day'] != $old_event['whole_day']) |
|
| 806 | 803 | { |
| 807 | - $q = $r = null; |
|
| 808 | - calendar_so::split_status($status,$q,$r); |
|
| 809 | - if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 804 | + $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
|
| 805 | + foreach((array)$event['participants'] as $uid => $status) |
|
| 810 | 806 | { |
| 811 | - $preferences = new Api\Preferences($uid); |
|
| 812 | - $part_prefs = $preferences->read_repository(); |
|
| 813 | - switch ($part_prefs['calendar']['reset_stati']) |
|
| 807 | + $q = $r = null; |
|
| 808 | + calendar_so::split_status($status,$q,$r); |
|
| 809 | + if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
|
| 814 | 810 | { |
| 811 | + $preferences = new Api\Preferences($uid); |
|
| 812 | + $part_prefs = $preferences->read_repository(); |
|
| 813 | + switch ($part_prefs['calendar']['reset_stati']) |
|
| 814 | + { |
|
| 815 | 815 | case 'no': |
| 816 | 816 | break; |
| 817 | 817 | case 'startday': |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | $status_reset_to_unknown = true; |
| 821 | 821 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
| 822 | 822 | // todo: report reset status to user |
| 823 | - } |
|
| 823 | + } |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | // check if we need to move the alarms, because they are relative |
@@ -962,83 +962,83 @@ discard block |
||
| 962 | 962 | } |
| 963 | 963 | break; |
| 964 | 964 | |
| 965 | - case 'cancel': |
|
| 966 | - if($content['cancel_needs_refresh']) |
|
| 967 | - { |
|
| 968 | - Framework::refresh_opener($msg, 'calendar'); |
|
| 969 | - } |
|
| 970 | - break; |
|
| 971 | - |
|
| 972 | - case 'delete': // delete of event (regular or series) |
|
| 973 | - $exceptions_kept = null; |
|
| 974 | - if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 975 | - $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 976 | - { |
|
| 977 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 965 | + case 'cancel': |
|
| 966 | + if($content['cancel_needs_refresh']) |
|
| 978 | 967 | { |
| 979 | - $msg = lang('Series deleted'); |
|
| 980 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 968 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 981 | 969 | } |
| 982 | - else |
|
| 970 | + break; |
|
| 971 | + |
|
| 972 | + case 'delete': // delete of event (regular or series) |
|
| 973 | + $exceptions_kept = null; |
|
| 974 | + if ($this->bo->delete($event['id'], (int)$content['edit_single'], false, $event['no_notifications'], |
|
| 975 | + $content['delete_exceptions'] == 'true', $exceptions_kept)) |
|
| 983 | 976 | { |
| 984 | - $msg = lang('Event deleted'); |
|
| 985 | - } |
|
| 977 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
|
| 978 | + { |
|
| 979 | + $msg = lang('Series deleted'); |
|
| 980 | + if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 981 | + } |
|
| 982 | + else |
|
| 983 | + { |
|
| 984 | + $msg = lang('Event deleted'); |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | - } |
|
| 988 | - break; |
|
| 987 | + } |
|
| 988 | + break; |
|
| 989 | 989 | |
| 990 | - case 'freetime': |
|
| 991 | - // the "click" has to be in onload, to make sure the button is already created |
|
| 992 | - $event['button_was'] = $button; |
|
| 993 | - break; |
|
| 990 | + case 'freetime': |
|
| 991 | + // the "click" has to be in onload, to make sure the button is already created |
|
| 992 | + $event['button_was'] = $button; |
|
| 993 | + break; |
|
| 994 | 994 | |
| 995 | - case 'add_alarm': |
|
| 996 | - $time = $content['start']; |
|
| 997 | - $offset = $time - $content['new_alarm']['date']; |
|
| 998 | - if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 999 | - ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 1000 | - $time < $next_occurrence['start']) |
|
| 1001 | - { |
|
| 1002 | - $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 1003 | - } |
|
| 1004 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1005 | - { |
|
| 1006 | - $alarm = array( |
|
| 1007 | - 'offset' => $offset, |
|
| 1008 | - 'time' => $content['new_alarm']['date'], |
|
| 1009 | - 'all' => !$content['new_alarm']['owner'], |
|
| 1010 | - 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 1011 | - ); |
|
| 1012 | - if ($alarm['time'] < $this->bo->now_su) |
|
| 995 | + case 'add_alarm': |
|
| 996 | + $time = $content['start']; |
|
| 997 | + $offset = $time - $content['new_alarm']['date']; |
|
| 998 | + if ($event['recur_type'] != MCAL_RECUR_NONE && |
|
| 999 | + ($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $offset, true)) && |
|
| 1000 | + $time < $next_occurrence['start']) |
|
| 1013 | 1001 | { |
| 1014 | - $msg = lang("Can't add alarms in the past !!!"); |
|
| 1002 | + $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
|
| 1015 | 1003 | } |
| 1016 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1004 | + if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1017 | 1005 | { |
| 1018 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1006 | + $alarm = array( |
|
| 1007 | + 'offset' => $offset, |
|
| 1008 | + 'time' => $content['new_alarm']['date'], |
|
| 1009 | + 'all' => !$content['new_alarm']['owner'], |
|
| 1010 | + 'owner' => $content['new_alarm']['owner'] ? $content['new_alarm']['owner'] : $this->user, |
|
| 1011 | + ); |
|
| 1012 | + if ($alarm['time'] < $this->bo->now_su) |
|
| 1013 | + { |
|
| 1014 | + $msg = lang("Can't add alarms in the past !!!"); |
|
| 1015 | + } |
|
| 1016 | + elseif ($event['id']) // save the alarm immediatly |
|
| 1019 | 1017 | { |
| 1020 | - $alarm['id'] = $alarm_id; |
|
| 1021 | - $event['alarm'][$alarm_id] = $alarm; |
|
| 1018 | + if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1019 | + { |
|
| 1020 | + $alarm['id'] = $alarm_id; |
|
| 1021 | + $event['alarm'][$alarm_id] = $alarm; |
|
| 1022 | 1022 | |
| 1023 | - $msg = lang('Alarm added'); |
|
| 1024 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1023 | + $msg = lang('Alarm added'); |
|
| 1024 | + Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1025 | + } |
|
| 1026 | + else |
|
| 1027 | + { |
|
| 1028 | + $msg = lang('Error adding the alarm'); |
|
| 1029 | + } |
|
| 1025 | 1030 | } |
| 1026 | 1031 | else |
| 1027 | 1032 | { |
| 1028 | - $msg = lang('Error adding the alarm'); |
|
| 1033 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | + $event['alarm'][$alarm['id']] = $alarm; |
|
| 1029 | 1035 | } |
| 1030 | 1036 | } |
| 1031 | 1037 | else |
| 1032 | 1038 | { |
| 1033 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1034 | - $event['alarm'][$alarm['id']] = $alarm; |
|
| 1039 | + $msg = lang('Permission denied'); |
|
| 1035 | 1040 | } |
| 1036 | - } |
|
| 1037 | - else |
|
| 1038 | - { |
|
| 1039 | - $msg = lang('Permission denied'); |
|
| 1040 | - } |
|
| 1041 | - break; |
|
| 1041 | + break; |
|
| 1042 | 1042 | } |
| 1043 | 1043 | // add notification-errors, if we have some |
| 1044 | 1044 | if (($notification_errors = notifications::errors(true))) |
@@ -121,11 +121,14 @@ discard block |
||
| 121 | 121 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 122 | 122 | !$this->bo->check_perms(Acl::ADD,0,$owner)) |
| 123 | 123 | { |
| 124 | - if ($owner) // make an owner who is no user or we have no add-rights a participant |
|
| 124 | + if ($owner) |
|
| 125 | + { |
|
| 126 | + // make an owner who is no user or we have no add-rights a participant |
|
| 125 | 127 | { |
| 126 | 128 | if(!is_array($owner)) |
| 127 | 129 | { |
| 128 | 130 | $owner = explode(',',$owner); |
| 131 | + } |
|
| 129 | 132 | } |
| 130 | 133 | // if we come from ressources we don't need any users selected in calendar |
| 131 | 134 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
@@ -157,9 +160,17 @@ discard block |
||
| 157 | 160 | $participant_types['u'] = $participant_types = $participants = array(); |
| 158 | 161 | foreach($extra_participants as $uid) |
| 159 | 162 | { |
| 160 | - if (isset($participants[$uid])) continue; // already included |
|
| 163 | + if (isset($participants[$uid])) |
|
| 164 | + { |
|
| 165 | + continue; |
|
| 166 | + } |
|
| 167 | + // already included |
|
| 161 | 168 | |
| 162 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 169 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 170 | + { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 173 | + // no right to invite --> ignored |
|
| 163 | 174 | |
| 164 | 175 | if (is_numeric($uid)) |
| 165 | 176 | { |
@@ -197,10 +208,13 @@ discard block |
||
| 197 | 208 | } |
| 198 | 209 | } |
| 199 | 210 | } |
| 200 | - if (!$participants) // if all participants got removed, include current user |
|
| 211 | + if (!$participants) |
|
| 212 | + { |
|
| 213 | + // if all participants got removed, include current user |
|
| 201 | 214 | { |
| 202 | 215 | $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
| 203 | 216 | } |
| 217 | + } |
|
| 204 | 218 | if(isset($_GET['cat_id'])) |
| 205 | 219 | { |
| 206 | 220 | $cat_id = explode(',',$_GET['cat_id']); |
@@ -250,10 +264,13 @@ discard block |
||
| 250 | 264 | */ |
| 251 | 265 | function process_edit($content) |
| 252 | 266 | { |
| 253 | - if (!is_array($content)) // redirect from etemplate, if POST empty |
|
| 267 | + if (!is_array($content)) |
|
| 268 | + { |
|
| 269 | + // redirect from etemplate, if POST empty |
|
| 254 | 270 | { |
| 255 | 271 | return $this->edit(null,null,strip_tags($_GET['msg'])); |
| 256 | 272 | } |
| 273 | + } |
|
| 257 | 274 | // clear notification errors |
| 258 | 275 | notifications::errors(true); |
| 259 | 276 | $messages = null; |
@@ -266,7 +283,11 @@ discard block |
||
| 266 | 283 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 267 | 284 | |
| 268 | 285 | list($button) = @each($content['button']); |
| 269 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 286 | + if (!$button && $content['action']) |
|
| 287 | + { |
|
| 288 | + $button = $content['action']; |
|
| 289 | + } |
|
| 290 | + // action selectbox |
|
| 270 | 291 | unset($content['button']); unset($content['action']); |
| 271 | 292 | |
| 272 | 293 | $view = $content['view']; |
@@ -279,7 +300,10 @@ discard block |
||
| 279 | 300 | { |
| 280 | 301 | list($date) = each($content['recur_exception']['delete_exception']); |
| 281 | 302 | // eT2 converts time to |
| 282 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 303 | + if (!is_numeric($date)) |
|
| 304 | + { |
|
| 305 | + $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 306 | + } |
|
| 283 | 307 | unset($content['recur_exception']['delete_exception']); |
| 284 | 308 | if (($key = array_search($date,$content['recur_exception'])) !== false) |
| 285 | 309 | { |
@@ -288,7 +312,10 @@ discard block |
||
| 288 | 312 | foreach ($recur_exceptions as $id) |
| 289 | 313 | { |
| 290 | 314 | if (!($exception = $this->bo->read($id)) || |
| 291 | - $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
|
| 315 | + $exception['recurrence'] != $content['recur_exception'][$key]) |
|
| 316 | + { |
|
| 317 | + continue; |
|
| 318 | + } |
|
| 292 | 319 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 293 | 320 | $exception['reference'] = $exception['recurrence'] = 0; |
| 294 | 321 | $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
@@ -363,7 +390,10 @@ discard block |
||
| 363 | 390 | $event['end'] = $this->bo->date2ts($event['end']); |
| 364 | 391 | } |
| 365 | 392 | // some checks for recurrences, if you give a date, make it a weekly repeating event and visa versa |
| 366 | - if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 393 | + if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) |
|
| 394 | + { |
|
| 395 | + $event['recur_type'] = MCAL_RECUR_WEEKLY; |
|
| 396 | + } |
|
| 367 | 397 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 368 | 398 | { |
| 369 | 399 | $event['recur_data'] = 1 << (int)date('w',$event['start']); |
@@ -489,7 +519,11 @@ discard block |
||
| 489 | 519 | break; |
| 490 | 520 | |
| 491 | 521 | default: // existing participant row |
| 492 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 522 | + if (!is_array($data)) |
|
| 523 | + { |
|
| 524 | + continue; |
|
| 525 | + } |
|
| 526 | + // widgets in participant tab, above participant list |
|
| 493 | 527 | foreach(array('uid','status','quantity','role') as $name) |
| 494 | 528 | { |
| 495 | 529 | $$name = $data[$name]; |
@@ -621,7 +655,10 @@ discard block |
||
| 621 | 655 | { |
| 622 | 656 | foreach($participants as $id => &$p_response) |
| 623 | 657 | { |
| 624 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 658 | + if($type == 'u' && $id == $event['owner']) |
|
| 659 | + { |
|
| 660 | + continue; |
|
| 661 | + } |
|
| 625 | 662 | calendar_so::split_status($p_response, $quantity, $role); |
| 626 | 663 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 627 | 664 | $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
@@ -703,17 +740,23 @@ discard block |
||
| 703 | 740 | { |
| 704 | 741 | foreach (array_keys($event['participants']) as $uid) |
| 705 | 742 | { |
| 706 | - if ($uid[0] == 'r') //ressource detection |
|
| 743 | + if ($uid[0] == 'r') |
|
| 744 | + { |
|
| 745 | + //ressource detection |
|
| 707 | 746 | { |
| 708 | 747 | $msg = lang('Error: ressources reservation in private events is not allowed!!!'); |
| 748 | + } |
|
| 709 | 749 | $button = ''; |
| 710 | 750 | break 2; //break foreach and case |
| 711 | 751 | } |
| 712 | 752 | } |
| 713 | 753 | } |
| 714 | - if ($content['edit_single']) // we edited a single event from a series |
|
| 754 | + if ($content['edit_single']) |
|
| 755 | + { |
|
| 756 | + // we edited a single event from a series |
|
| 715 | 757 | { |
| 716 | 758 | $event['reference'] = $event['id']; |
| 759 | + } |
|
| 717 | 760 | $event['recurrence'] = $content['edit_single']; |
| 718 | 761 | unset($event['id']); |
| 719 | 762 | $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
@@ -815,7 +858,10 @@ discard block |
||
| 815 | 858 | case 'no': |
| 816 | 859 | break; |
| 817 | 860 | case 'startday': |
| 818 | - if ($sameday) break; |
|
| 861 | + if ($sameday) |
|
| 862 | + { |
|
| 863 | + break; |
|
| 864 | + } |
|
| 819 | 865 | default: |
| 820 | 866 | $status_reset_to_unknown = true; |
| 821 | 867 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -977,7 +1023,10 @@ discard block |
||
| 977 | 1023 | if ($event['recur_type'] != MCAL_RECUR_NONE && $content['reference'] == 0 && !$content['edit_single']) |
| 978 | 1024 | { |
| 979 | 1025 | $msg = lang('Series deleted'); |
| 980 | - if ($exceptions_kept) $msg .= lang(', exceptions preserved'); |
|
| 1026 | + if ($exceptions_kept) |
|
| 1027 | + { |
|
| 1028 | + $msg .= lang(', exceptions preserved'); |
|
| 1029 | + } |
|
| 981 | 1030 | } |
| 982 | 1031 | else |
| 983 | 1032 | { |
@@ -1013,11 +1062,14 @@ discard block |
||
| 1013 | 1062 | { |
| 1014 | 1063 | $msg = lang("Can't add alarms in the past !!!"); |
| 1015 | 1064 | } |
| 1016 | - elseif ($event['id']) // save the alarm immediatly |
|
| 1065 | + elseif ($event['id']) |
|
| 1066 | + { |
|
| 1067 | + // save the alarm immediatly |
|
| 1017 | 1068 | { |
| 1018 | 1069 | if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
| 1019 | 1070 | { |
| 1020 | 1071 | $alarm['id'] = $alarm_id; |
| 1072 | + } |
|
| 1021 | 1073 | $event['alarm'][$alarm_id] = $alarm; |
| 1022 | 1074 | |
| 1023 | 1075 | $msg = lang('Alarm added'); |
@@ -1030,7 +1082,9 @@ discard block |
||
| 1030 | 1082 | } |
| 1031 | 1083 | else |
| 1032 | 1084 | { |
| 1033 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1085 | + for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) |
|
| 1086 | + { |
|
| 1087 | +} // get a temporary non-conflicting, numeric id |
|
| 1034 | 1088 | $event['alarm'][$alarm['id']] = $alarm; |
| 1035 | 1089 | } |
| 1036 | 1090 | } |
@@ -1053,10 +1107,13 @@ discard block |
||
| 1053 | 1107 | } |
| 1054 | 1108 | if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
| 1055 | 1109 | { |
| 1056 | - if ($content['lock_token']) // remove an existing lock |
|
| 1110 | + if ($content['lock_token']) |
|
| 1111 | + { |
|
| 1112 | + // remove an existing lock |
|
| 1057 | 1113 | { |
| 1058 | 1114 | Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
| 1059 | 1115 | } |
| 1116 | + } |
|
| 1060 | 1117 | if ($content['no_popup']) |
| 1061 | 1118 | { |
| 1062 | 1119 | Egw::redirect_link('/index.php',array( |
@@ -1113,13 +1170,19 @@ discard block |
||
| 1113 | 1170 | } |
| 1114 | 1171 | |
| 1115 | 1172 | // Copy links |
| 1116 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1173 | + if(!is_array($event['link_to'])) |
|
| 1174 | + { |
|
| 1175 | + $event['link_to'] = array(); |
|
| 1176 | + } |
|
| 1117 | 1177 | $event['link_to']['to_app'] = 'calendar'; |
| 1118 | 1178 | $event['link_to']['to_id'] = 0; |
| 1119 | 1179 | |
| 1120 | 1180 | foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
| 1121 | 1181 | { |
| 1122 | - if(!$link['id']) continue; |
|
| 1182 | + if(!$link['id']) |
|
| 1183 | + { |
|
| 1184 | + continue; |
|
| 1185 | + } |
|
| 1123 | 1186 | if ($link['app'] != Link::VFS_APPNAME) |
| 1124 | 1187 | { |
| 1125 | 1188 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1187,8 +1250,7 @@ discard block |
||
| 1187 | 1250 | if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
| 1188 | 1251 | // Adjust for requested date in the past |
| 1189 | 1252 | Api\DateTime::to($as_of_date,'ts') < time() |
| 1190 | - ) |
|
| 1191 | - { |
|
| 1253 | + ) { |
|
| 1192 | 1254 | |
| 1193 | 1255 | unset($orig_event); |
| 1194 | 1256 | // copy event by unsetting the id(s) |
@@ -1276,30 +1338,48 @@ discard block |
||
| 1276 | 1338 | foreach($event['participants'] as $uid => $status) |
| 1277 | 1339 | { |
| 1278 | 1340 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1279 | - if (empty($status)) continue; |
|
| 1341 | + if (empty($status)) |
|
| 1342 | + { |
|
| 1343 | + continue; |
|
| 1344 | + } |
|
| 1280 | 1345 | $toadd = ''; |
| 1281 | - if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) continue; |
|
| 1346 | + if ((isset($status['status']) && $status['status'] == 'R') || (isset($status['uid']) && $status['uid'] == $this->user)) |
|
| 1347 | + { |
|
| 1348 | + continue; |
|
| 1349 | + } |
|
| 1282 | 1350 | |
| 1283 | 1351 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1284 | 1352 | { |
| 1285 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1353 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) |
|
| 1354 | + { |
|
| 1355 | + continue; |
|
| 1356 | + } |
|
| 1286 | 1357 | |
| 1287 | 1358 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1288 | 1359 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1289 | 1360 | |
| 1290 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1361 | + if (!in_array($toadd,$to)) |
|
| 1362 | + { |
|
| 1363 | + $to[] = $toadd; |
|
| 1364 | + } |
|
| 1291 | 1365 | } |
| 1292 | 1366 | elseif ($uid < 0) |
| 1293 | 1367 | { |
| 1294 | 1368 | foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
| 1295 | 1369 | { |
| 1296 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1370 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) |
|
| 1371 | + { |
|
| 1372 | + continue; |
|
| 1373 | + } |
|
| 1297 | 1374 | |
| 1298 | 1375 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1299 | 1376 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1300 | 1377 | |
| 1301 | 1378 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1302 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1379 | + if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) |
|
| 1380 | + { |
|
| 1381 | + $to[] = $toadd; |
|
| 1382 | + } |
|
| 1303 | 1383 | } |
| 1304 | 1384 | } |
| 1305 | 1385 | elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
@@ -1351,7 +1431,10 @@ discard block |
||
| 1351 | 1431 | 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
| 1352 | 1432 | 'preset[size]' => filesize($ics_file), |
| 1353 | 1433 | ); |
| 1354 | - 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.'); |
|
| 1434 | + if ($asrequest) |
|
| 1435 | + { |
|
| 1436 | + $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.'); |
|
| 1437 | + } |
|
| 1355 | 1438 | $response = Api\Json\Response::get(); |
| 1356 | 1439 | $response->call('app.calendar.custom_mail', $vars); |
| 1357 | 1440 | } |
@@ -1537,9 +1620,15 @@ discard block |
||
| 1537 | 1620 | } |
| 1538 | 1621 | } |
| 1539 | 1622 | // set new start and end if given by $_GET |
| 1540 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1541 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1542 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1623 | + if(isset($_GET['start'])) |
|
| 1624 | + { |
|
| 1625 | +$event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1626 | + if(isset($_GET['end'])) |
|
| 1627 | + { |
|
| 1628 | +$event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1629 | + if(isset($_GET['non_blocking'])) |
|
| 1630 | + { |
|
| 1631 | +$event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1543 | 1632 | // check if the event is the whole day |
| 1544 | 1633 | $start = $this->bo->date2array($event['start']); |
| 1545 | 1634 | $end = $this->bo->date2array($event['end']); |
@@ -1552,10 +1641,13 @@ discard block |
||
| 1552 | 1641 | foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
| 1553 | 1642 | { |
| 1554 | 1643 | $link_id = $link_ids[$n]; |
| 1555 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1644 | + if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) |
|
| 1645 | + { |
|
| 1646 | + // guard against XSS |
|
| 1556 | 1647 | { |
| 1557 | 1648 | continue; |
| 1558 | 1649 | } |
| 1650 | + } |
|
| 1559 | 1651 | if(!$n) |
| 1560 | 1652 | { |
| 1561 | 1653 | $event['title'] = Link::title($link_app,$link_id); |
@@ -1564,7 +1656,10 @@ discard block |
||
| 1564 | 1656 | { |
| 1565 | 1657 | foreach((array)$set['link_app'] as $i => $l_app) |
| 1566 | 1658 | { |
| 1567 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1659 | + if (($l_id=$set['link_id'][$i])) |
|
| 1660 | + { |
|
| 1661 | + Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1662 | + } |
|
| 1568 | 1663 | } |
| 1569 | 1664 | unset($set['link_app']); |
| 1570 | 1665 | unset($set['link_id']); |
@@ -1590,10 +1685,13 @@ discard block |
||
| 1590 | 1685 | $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
| 1591 | 1686 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1592 | 1687 | |
| 1593 | - if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
|
| 1688 | + if (($preserv['lock_token'] = $event['lock_token'])) |
|
| 1689 | + { |
|
| 1690 | + // already locked --> refresh the lock |
|
| 1594 | 1691 | { |
| 1595 | 1692 | Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
| 1596 | 1693 | } |
| 1694 | + } |
|
| 1597 | 1695 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1598 | 1696 | { |
| 1599 | 1697 | $msg .= ' '.lang('This entry is currently opened by %1!', |
@@ -1627,14 +1725,20 @@ discard block |
||
| 1627 | 1725 | )); |
| 1628 | 1726 | Framework::message($msg, $msg_type); |
| 1629 | 1727 | $content['duration'] = $content['end'] - $content['start']; |
| 1630 | - if (isset($this->durations[$content['duration']])) $content['end'] = ''; |
|
| 1728 | + if (isset($this->durations[$content['duration']])) |
|
| 1729 | + { |
|
| 1730 | + $content['end'] = ''; |
|
| 1731 | + } |
|
| 1631 | 1732 | |
| 1632 | 1733 | $row = 3; |
| 1633 | 1734 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1634 | 1735 | // preserve some ui elements, if set eg. under error-conditions |
| 1635 | 1736 | foreach(array('quantity','resource','role') as $n) |
| 1636 | 1737 | { |
| 1637 | - if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
|
| 1738 | + if (isset($event['participants'][$n])) |
|
| 1739 | + { |
|
| 1740 | + $content['participants'][$n] = $event['participants'][$n]; |
|
| 1741 | + } |
|
| 1638 | 1742 | } |
| 1639 | 1743 | foreach($event['participant_types'] as $type => $participants) |
| 1640 | 1744 | { |
@@ -1676,9 +1780,13 @@ discard block |
||
| 1676 | 1780 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1677 | 1781 | |
| 1678 | 1782 | if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
| 1679 | - $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1783 | + { |
|
| 1784 | + $readonlys['participants'][$row]['status'] = $no_status; |
|
| 1785 | + } |
|
| 1680 | 1786 | if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
| 1681 | - $readonlys['participants']['delete'][$uid] = true; |
|
| 1787 | + { |
|
| 1788 | + $readonlys['participants']['delete'][$uid] = true; |
|
| 1789 | + } |
|
| 1682 | 1790 | // todo: make the participants available as links with email as title |
| 1683 | 1791 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1684 | 1792 | // enumerate group-invitations, so people can accept/reject them |
@@ -1709,7 +1817,11 @@ discard block |
||
| 1709 | 1817 | $content['participants']['cal_resources'] = ''; |
| 1710 | 1818 | foreach($this->bo->resources as $data) |
| 1711 | 1819 | { |
| 1712 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1820 | + if ($data['app'] == 'email') |
|
| 1821 | + { |
|
| 1822 | + continue; |
|
| 1823 | + } |
|
| 1824 | + // make no sense, as we cant search for email |
|
| 1713 | 1825 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1714 | 1826 | } |
| 1715 | 1827 | } |
@@ -1737,9 +1849,18 @@ discard block |
||
| 1737 | 1849 | $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
| 1738 | 1850 | $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
| 1739 | 1851 | $label = array(); |
| 1740 | - if ($days) $label[] = $days.' '.lang('days'); |
|
| 1741 | - if ($hours) $label[] = $hours.' '.lang('hours'); |
|
| 1742 | - if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
|
| 1852 | + if ($days) |
|
| 1853 | + { |
|
| 1854 | + $label[] = $days.' '.lang('days'); |
|
| 1855 | + } |
|
| 1856 | + if ($hours) |
|
| 1857 | + { |
|
| 1858 | + $label[] = $hours.' '.lang('hours'); |
|
| 1859 | + } |
|
| 1860 | + if ($minutes) |
|
| 1861 | + { |
|
| 1862 | + $label[] = $minutes.' '.lang('Minutes'); |
|
| 1863 | + } |
|
| 1743 | 1864 | $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
| 1744 | 1865 | $content['alarm'][] = $alarm; |
| 1745 | 1866 | |
@@ -1802,25 +1923,34 @@ discard block |
||
| 1802 | 1923 | 'participants' => $this->accountsel->account_selection == 'none', |
| 1803 | 1924 | 'history' => !$event['id'], |
| 1804 | 1925 | ); |
| 1805 | - if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) // no mail without mail-app |
|
| 1926 | + if (!isset($GLOBALS['egw_info']['user']['apps']['mail'])) |
|
| 1927 | + { |
|
| 1928 | + // no mail without mail-app |
|
| 1806 | 1929 | { |
| 1807 | 1930 | unset($sel_options['action']['mail']); |
| 1931 | + } |
|
| 1808 | 1932 | unset($sel_options['action']['sendmeetingrequest']); |
| 1809 | 1933 | } |
| 1810 | - if (!$event['id']) // no ical export for new (not saved) events |
|
| 1934 | + if (!$event['id']) |
|
| 1935 | + { |
|
| 1936 | + // no ical export for new (not saved) events |
|
| 1811 | 1937 | { |
| 1812 | 1938 | $readonlys['action'] = true; |
| 1813 | 1939 | } |
| 1940 | + } |
|
| 1814 | 1941 | 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']))) |
| 1815 | 1942 | { |
| 1816 | 1943 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1817 | 1944 | } |
| 1818 | 1945 | $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
| 1819 | 1946 | |
| 1820 | - 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 |
|
| 1947 | + if (!$event['id'] || $this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1948 | + { |
|
| 1949 | + // new event or edit rights to the event ==> allow to add alarm for all users |
|
| 1821 | 1950 | { |
| 1822 | 1951 | $sel_options['owner'][0] = lang('All participants'); |
| 1823 | 1952 | } |
| 1953 | + } |
|
| 1824 | 1954 | if (isset($event['participant_types']['u'][$this->user])) |
| 1825 | 1955 | { |
| 1826 | 1956 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
@@ -1862,7 +1992,10 @@ discard block |
||
| 1862 | 1992 | |
| 1863 | 1993 | $content['cancel_needs_refresh'] = (bool)$_GET['cancel_needs_refresh']; |
| 1864 | 1994 | |
| 1865 | - if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
|
| 1995 | + if (!empty($preserved['lock_token'])) |
|
| 1996 | + { |
|
| 1997 | + $content['lock_token'] = $preserved['lock_token']; |
|
| 1998 | + } |
|
| 1866 | 1999 | |
| 1867 | 2000 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1868 | 2001 | if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
@@ -2064,7 +2197,10 @@ discard block |
||
| 2064 | 2197 | // set status and send notification / meeting response |
| 2065 | 2198 | if ($this->bo->set_status($event['id'], $user, $status)) |
| 2066 | 2199 | { |
| 2067 | - if (!$msg) $msg = lang('Status changed'); |
|
| 2200 | + if (!$msg) |
|
| 2201 | + { |
|
| 2202 | + $msg = lang('Status changed'); |
|
| 2203 | + } |
|
| 2068 | 2204 | } |
| 2069 | 2205 | break; |
| 2070 | 2206 | |
@@ -2143,13 +2279,16 @@ discard block |
||
| 2143 | 2279 | |
| 2144 | 2280 | foreach (array_keys($allConflicts) as $pId) |
| 2145 | 2281 | { |
| 2146 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2282 | + if(substr($pId,0,1) == 'r' && $resources_config ) |
|
| 2283 | + { |
|
| 2284 | + // resources Allow ignore conflicts |
|
| 2147 | 2285 | { |
| 2148 | 2286 | |
| 2149 | 2287 | switch ($resources_config['ignoreconflicts']) |
| 2150 | 2288 | { |
| 2151 | 2289 | case 'no': |
| 2152 | 2290 | $readonlys['button[ignore]'] = true; |
| 2291 | + } |
|
| 2153 | 2292 | break; |
| 2154 | 2293 | case 'allusers': |
| 2155 | 2294 | $readonlys['button[ignore]'] = false; |
@@ -2293,7 +2432,10 @@ discard block |
||
| 2293 | 2432 | } |
| 2294 | 2433 | else |
| 2295 | 2434 | { |
| 2296 | - if (!$content['duration']) $content['duration'] = $content['end'] - $content['start']; |
|
| 2435 | + if (!$content['duration']) |
|
| 2436 | + { |
|
| 2437 | + $content['duration'] = $content['end'] - $content['start']; |
|
| 2438 | + } |
|
| 2297 | 2439 | $weekds = 0; |
| 2298 | 2440 | foreach ($content['weekdays'] as &$wdays) |
| 2299 | 2441 | { |
@@ -2315,7 +2457,10 @@ discard block |
||
| 2315 | 2457 | $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
| 2316 | 2458 | |
| 2317 | 2459 | $sel_options['duration'] = $this->durations; |
| 2318 | - if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
|
| 2460 | + if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) |
|
| 2461 | + { |
|
| 2462 | + $content['end'] = ''; |
|
| 2463 | + } |
|
| 2319 | 2464 | |
| 2320 | 2465 | $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
| 2321 | 2466 | 'participants' => $content['participants'], |
@@ -2336,7 +2481,10 @@ discard block |
||
| 2336 | 2481 | */ |
| 2337 | 2482 | function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
| 2338 | 2483 | { |
| 2339 | - 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); |
|
| 2484 | + if ($this->debug > 2) |
|
| 2485 | + { |
|
| 2486 | + $this->bo->debug_message(__METHOD__.'(participants=%1, start=%2, end=%3, duration=%4, cal_id=%5)',true,$participants,$start,$end,$duration,$cal_id); |
|
| 2487 | + } |
|
| 2340 | 2488 | |
| 2341 | 2489 | $busy = $this->bo->search(array( |
| 2342 | 2490 | 'start' => $start, |
@@ -2353,15 +2501,26 @@ discard block |
||
| 2353 | 2501 | $n = 0; |
| 2354 | 2502 | foreach($busy as $event) |
| 2355 | 2503 | { |
| 2356 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2504 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) |
|
| 2505 | + { |
|
| 2506 | + continue; |
|
| 2507 | + } |
|
| 2508 | + // ignore our own event |
|
| 2357 | 2509 | |
| 2358 | - if ($event['non_blocking']) continue; // ignore non_blocking events |
|
| 2510 | + if ($event['non_blocking']) |
|
| 2511 | + { |
|
| 2512 | + continue; |
|
| 2513 | + } |
|
| 2514 | + // ignore non_blocking events |
|
| 2359 | 2515 | |
| 2360 | 2516 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2361 | 2517 | $non_rejected_found = false; |
| 2362 | 2518 | foreach($participants as $uid) |
| 2363 | 2519 | { |
| 2364 | - if ($event['participants'][$uid] == 'R') continue; |
|
| 2520 | + if ($event['participants'][$uid] == 'R') |
|
| 2521 | + { |
|
| 2522 | + continue; |
|
| 2523 | + } |
|
| 2365 | 2524 | |
| 2366 | 2525 | if (isset($event['participants'][$uid]) || |
| 2367 | 2526 | $uid > 0 && array_intersect(array_keys((array)$event['participants']), |
@@ -2371,7 +2530,10 @@ discard block |
||
| 2371 | 2530 | break; |
| 2372 | 2531 | } |
| 2373 | 2532 | } |
| 2374 | - if (!$non_rejected_found) continue; |
|
| 2533 | + if (!$non_rejected_found) |
|
| 2534 | + { |
|
| 2535 | + continue; |
|
| 2536 | + } |
|
| 2375 | 2537 | |
| 2376 | 2538 | if ($this->debug) |
| 2377 | 2539 | { |
@@ -2402,11 +2564,17 @@ discard block |
||
| 2402 | 2564 | 'start' => $ft_start, |
| 2403 | 2565 | 'end' => $ft_end, |
| 2404 | 2566 | ); |
| 2405 | - 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"; |
|
| 2567 | + if ($this->debug > 1) |
|
| 2568 | + { |
|
| 2569 | + echo "<p>freetime: ".date('D d.m.Y H:i',$ft_start)." - ".date('D d.m.Y H:i',$ft_end)."</p>\n"; |
|
| 2570 | + } |
|
| 2406 | 2571 | } |
| 2407 | 2572 | $ft_start = $event['end']; |
| 2408 | 2573 | } |
| 2409 | - 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); |
|
| 2574 | + if ($this->debug > 0) |
|
| 2575 | + { |
|
| 2576 | + $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); |
|
| 2577 | + } |
|
| 2410 | 2578 | |
| 2411 | 2579 | return $freetime; |
| 2412 | 2580 | } |
@@ -2426,10 +2594,16 @@ discard block |
||
| 2426 | 2594 | */ |
| 2427 | 2595 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2428 | 2596 | { |
| 2429 | - 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); |
|
| 2597 | + if ($this->debug > 1) |
|
| 2598 | + { |
|
| 2599 | + $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); |
|
| 2600 | + } |
|
| 2430 | 2601 | |
| 2431 | 2602 | $freetime_daywise = array(); |
| 2432 | - if (!is_array($sel_options)) $sel_options = array(); |
|
| 2603 | + if (!is_array($sel_options)) |
|
| 2604 | + { |
|
| 2605 | + $sel_options = array(); |
|
| 2606 | + } |
|
| 2433 | 2607 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2434 | 2608 | |
| 2435 | 2609 | $start_time = (int) $_start_time; // ignore leading zeros |
@@ -2439,7 +2613,10 @@ discard block |
||
| 2439 | 2613 | if (($end_time - $start_time)*HOUR_s < $duration) |
| 2440 | 2614 | { |
| 2441 | 2615 | $end_time = 0; |
| 2442 | - 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); |
|
| 2616 | + if ($this->debug > 1) |
|
| 2617 | + { |
|
| 2618 | + $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); |
|
| 2619 | + } |
|
| 2443 | 2620 | } |
| 2444 | 2621 | $n = 0; |
| 2445 | 2622 | foreach($freetime as $ft) |
@@ -2460,13 +2637,19 @@ discard block |
||
| 2460 | 2637 | } |
| 2461 | 2638 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2462 | 2639 | |
| 2463 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2640 | + if ($start-$daybegin < $start_time*HOUR_s) |
|
| 2641 | + { |
|
| 2642 | + // start earlier then start_time |
|
| 2464 | 2643 | { |
| 2465 | 2644 | $start = $daybegin + $start_time*HOUR_s; |
| 2466 | 2645 | } |
| 2646 | + } |
|
| 2467 | 2647 | // if end_time given use it, else the original slot's end |
| 2468 | 2648 | $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
| 2469 | - if ($end > $ft['end']) $end = $ft['end']; |
|
| 2649 | + if ($end > $ft['end']) |
|
| 2650 | + { |
|
| 2651 | + $end = $ft['end']; |
|
| 2652 | + } |
|
| 2470 | 2653 | |
| 2471 | 2654 | // slot to small for duration |
| 2472 | 2655 | if ($end - $start < $duration) |
@@ -2508,7 +2691,10 @@ discard block |
||
| 2508 | 2691 | { |
| 2509 | 2692 | $msg = lang('Permission denied'); |
| 2510 | 2693 | |
| 2511 | - if ($return_error) return $msg; |
|
| 2694 | + if ($return_error) |
|
| 2695 | + { |
|
| 2696 | + return $msg; |
|
| 2697 | + } |
|
| 2512 | 2698 | } |
| 2513 | 2699 | else |
| 2514 | 2700 | { |
@@ -2570,27 +2756,42 @@ discard block |
||
| 2570 | 2756 | { |
| 2571 | 2757 | list($button) = each($_content['button']); |
| 2572 | 2758 | unset($_content['button']); |
| 2573 | - if ($button != 'cancel') // store changed Acl |
|
| 2759 | + if ($button != 'cancel') |
|
| 2760 | + { |
|
| 2761 | + // store changed Acl |
|
| 2574 | 2762 | { |
| 2575 | 2763 | foreach($_content as $data) |
| 2576 | 2764 | { |
| 2577 | 2765 | if (!($cat_id = $data['cat_id'])) continue; |
| 2766 | + } |
|
| 2578 | 2767 | foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
| 2579 | 2768 | { |
| 2580 | 2769 | $rights = 0; |
| 2581 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2582 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2583 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2770 | + if (in_array($account_id,(array)$data['add'])) |
|
| 2771 | + { |
|
| 2772 | + $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2773 | + } |
|
| 2774 | + if (in_array($account_id,(array)$data['status'])) |
|
| 2775 | + { |
|
| 2776 | + $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2777 | + } |
|
| 2778 | + if ($account_id) |
|
| 2779 | + { |
|
| 2780 | + $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2781 | + } |
|
| 2584 | 2782 | } |
| 2585 | 2783 | } |
| 2586 | 2784 | } |
| 2587 | - if ($button != 'apply') // end dialog |
|
| 2785 | + if ($button != 'apply') |
|
| 2786 | + { |
|
| 2787 | + // end dialog |
|
| 2588 | 2788 | { |
| 2589 | 2789 | Egw::redirect_link('/index.php', array( |
| 2590 | 2790 | 'menuaction' => 'admin.admin_ui.index', |
| 2591 | 2791 | 'ajax' => 'true' |
| 2592 | 2792 | ), 'admin'); |
| 2593 | 2793 | } |
| 2794 | + } |
|
| 2594 | 2795 | } |
| 2595 | 2796 | $content= $preserv = array(); |
| 2596 | 2797 | $n = 1; |
@@ -2604,8 +2805,14 @@ discard block |
||
| 2604 | 2805 | ); |
| 2605 | 2806 | foreach($data as $account_id => $rights) |
| 2606 | 2807 | { |
| 2607 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2608 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2808 | + if ($rights & calendar_boupdate::CAT_ACL_ADD) |
|
| 2809 | + { |
|
| 2810 | + $row['add'][] = $account_id; |
|
| 2811 | + } |
|
| 2812 | + if ($rights & calendar_boupdate::CAT_ACL_STATUS) |
|
| 2813 | + { |
|
| 2814 | + $row['status'][] = $account_id; |
|
| 2815 | + } |
|
| 2609 | 2816 | } |
| 2610 | 2817 | $content[$n] = $row; |
| 2611 | 2818 | $preserv[$n] = array( |
@@ -2733,7 +2940,10 @@ discard block |
||
| 2733 | 2940 | break; |
| 2734 | 2941 | } |
| 2735 | 2942 | } |
| 2736 | - if($return) return; |
|
| 2943 | + if($return) |
|
| 2944 | + { |
|
| 2945 | + return; |
|
| 2946 | + } |
|
| 2737 | 2947 | } |
| 2738 | 2948 | $old_event=$event=$this->bo->read($eventId); |
| 2739 | 2949 | if (!$durationT) |
@@ -2827,7 +3037,10 @@ discard block |
||
| 2827 | 3037 | $this->bo->update($event,true, true, false, true, $message,true); |
| 2828 | 3038 | |
| 2829 | 3039 | // Whole day non blocking with DAY_s would add a day |
| 2830 | - if($duration==DAY_s) $duration=0; |
|
| 3040 | + if($duration==DAY_s) |
|
| 3041 | + { |
|
| 3042 | + $duration=0; |
|
| 3043 | + } |
|
| 2831 | 3044 | } |
| 2832 | 3045 | |
| 2833 | 3046 | $status_reset_to_unknown = false; |
@@ -2845,7 +3058,10 @@ discard block |
||
| 2845 | 3058 | case 'no': |
| 2846 | 3059 | break; |
| 2847 | 3060 | case 'startday': |
| 2848 | - if ($sameday) break; |
|
| 3061 | + if ($sameday) |
|
| 3062 | + { |
|
| 3063 | + break; |
|
| 3064 | + } |
|
| 2849 | 3065 | default: |
| 2850 | 3066 | $status_reset_to_unknown = true; |
| 2851 | 3067 | $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
@@ -2889,7 +3105,10 @@ discard block |
||
| 2889 | 3105 | { |
| 2890 | 3106 | $response->call('egw.message', implode('<br />', $message)); |
| 2891 | 3107 | } |
| 2892 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 3108 | + if($event['id'] != $eventId ) |
|
| 3109 | + { |
|
| 3110 | + $this->update_client($_eventId); |
|
| 3111 | + } |
|
| 2893 | 3112 | if ($status_reset_to_unknown) |
| 2894 | 3113 | { |
| 2895 | 3114 | foreach((array)$event['participants'] as $uid => $status) |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @var locktime in seconds |
| 57 | 57 | */ |
| 58 | - var $locktime_default=1; |
|
| 58 | + var $locktime_default = 1; |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * Constructor |
| 62 | 62 | */ |
| 63 | 63 | function __construct() |
| 64 | 64 | { |
| 65 | - parent::__construct(true); // call the parent's constructor |
|
| 65 | + parent::__construct(true); // call the parent's constructor |
|
| 66 | 66 | |
| 67 | - for ($n=15; $n <= 16*60; $n+=($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 67 | + for ($n = 15; $n <= 16 * 60; $n += ($n < 60 ? 15 : ($n < 240 ? 30 : ($n < 600 ? 60 : 120)))) |
|
| 68 | 68 | { |
| 69 | - $this->durations[$n*60] = sprintf('%d:%02d',$n/60,$n%60); |
|
| 69 | + $this->durations[$n * 60] = sprintf('%d:%02d', $n / 60, $n % 60); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
@@ -78,11 +78,10 @@ discard block |
||
| 78 | 78 | function &default_add_event() |
| 79 | 79 | { |
| 80 | 80 | $extra_participants = $_GET['participants'] ? |
| 81 | - (!is_array($_GET['participants']) ? explode(',',$_GET['participants']) : $_GET['participants']) : |
|
| 82 | - array(); |
|
| 81 | + (!is_array($_GET['participants']) ? explode(',', $_GET['participants']) : $_GET['participants']) : array(); |
|
| 83 | 82 | |
| 84 | 83 | // if participant is a contact, add its link title as title |
| 85 | - foreach($extra_participants as $uid) |
|
| 84 | + foreach ($extra_participants as $uid) |
|
| 86 | 85 | { |
| 87 | 86 | if ($uid[0] == 'c') |
| 88 | 87 | { |
@@ -94,14 +93,14 @@ discard block |
||
| 94 | 93 | if (isset($_GET['owner'])) |
| 95 | 94 | { |
| 96 | 95 | $owner = $_GET['owner']; |
| 97 | - if(!is_array($owner) && strpos($owner, ',')) |
|
| 96 | + if (!is_array($owner) && strpos($owner, ',')) |
|
| 98 | 97 | { |
| 99 | - $owner = explode(',',$owner); |
|
| 98 | + $owner = explode(',', $owner); |
|
| 100 | 99 | } |
| 101 | - if(is_array($owner)) |
|
| 100 | + if (is_array($owner)) |
|
| 102 | 101 | { |
| 103 | 102 | // old behavior "selected" should also be used for not set preference, therefore we need to test for !== '0' |
| 104 | - if($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
| 103 | + if ($this->cal_prefs['default_participant'] !== '0' || count($extra_participants) === 0 && count($owner) === 1) |
|
| 105 | 104 | { |
| 106 | 105 | $extra_participants += $owner; |
| 107 | 106 | } |
@@ -117,21 +116,21 @@ discard block |
||
| 117 | 116 | // old behavior "selected" should also be used for not set preference, therefore we need to test for === '0' |
| 118 | 117 | $owner = $this->cal_prefs['default_participant'] === '0' ? $this->user : $this->owner; |
| 119 | 118 | } |
| 120 | - error_log(__METHOD__ . ' owner: ' . array2string($owner)); |
|
| 119 | + error_log(__METHOD__.' owner: '.array2string($owner)); |
|
| 121 | 120 | |
| 122 | 121 | if (!$owner || !is_numeric($owner) || $GLOBALS['egw']->accounts->get_type($owner) != 'u' || |
| 123 | - !$this->bo->check_perms(Acl::ADD,0,$owner)) |
|
| 122 | + !$this->bo->check_perms(Acl::ADD, 0, $owner)) |
|
| 124 | 123 | { |
| 125 | 124 | if ($owner) // make an owner who is no user or we have no add-rights a participant |
| 126 | 125 | { |
| 127 | - if(!is_array($owner)) |
|
| 126 | + if (!is_array($owner)) |
|
| 128 | 127 | { |
| 129 | - $owner = explode(',',$owner); |
|
| 128 | + $owner = explode(',', $owner); |
|
| 130 | 129 | } |
| 131 | 130 | // if we come from ressources we don't need any users selected in calendar |
| 132 | 131 | if (!isset($_GET['participants']) || $_GET['participants'][0] != 'r') |
| 133 | 132 | { |
| 134 | - foreach($owner as $uid) |
|
| 133 | + foreach ($owner as $uid) |
|
| 135 | 134 | { |
| 136 | 135 | $extra_participants[] = $uid; |
| 137 | 136 | } |
@@ -141,71 +140,71 @@ discard block |
||
| 141 | 140 | } |
| 142 | 141 | //error_log("this->owner=$this->owner, _GET[owner]=$_GET[owner], user=$this->user => owner=$owner, extra_participants=".implode(',',$extra_participants).")"); |
| 143 | 142 | |
| 144 | - if(isset($_GET['start'])) |
|
| 143 | + if (isset($_GET['start'])) |
|
| 145 | 144 | { |
| 146 | 145 | $start = Api\DateTime::to($_GET['start'], 'ts'); |
| 147 | 146 | } |
| 148 | 147 | else |
| 149 | 148 | { |
| 150 | 149 | $start = $this->bo->date2ts(array( |
| 151 | - 'full' => isset($_GET['date']) && (int) $_GET['date'] ? (int) $_GET['date'] : $this->date, |
|
| 152 | - 'hour' => (int) (isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 153 | - 'minute' => (int) $_GET['minute'], |
|
| 150 | + 'full' => isset($_GET['date']) && (int)$_GET['date'] ? (int)$_GET['date'] : $this->date, |
|
| 151 | + 'hour' => (int)(isset($_GET['hour']) ? $_GET['hour'] : $this->bo->cal_prefs['workdaystarts']), |
|
| 152 | + 'minute' => (int)$_GET['minute'], |
|
| 154 | 153 | )); |
| 155 | 154 | } |
| 156 | 155 | //echo "<p>_GET[date]=$_GET[date], _GET[hour]=$_GET[hour], _GET[minute]=$_GET[minute], this->date=$this->date ==> start=$start=".date('Y-m-d H:i',$start)."</p>\n"; |
| 157 | 156 | |
| 158 | 157 | $participant_types['u'] = $participant_types = $participants = array(); |
| 159 | - foreach($extra_participants as $uid) |
|
| 158 | + foreach ($extra_participants as $uid) |
|
| 160 | 159 | { |
| 161 | - if (isset($participants[$uid])) continue; // already included |
|
| 160 | + if (isset($participants[$uid])) continue; // already included |
|
| 162 | 161 | |
| 163 | - if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 162 | + if (!$this->bo->check_acl_invite($uid)) continue; // no right to invite --> ignored |
|
| 164 | 163 | |
| 165 | 164 | if (is_numeric($uid)) |
| 166 | 165 | { |
| 167 | 166 | $participants[$uid] = $participant_types['u'][$uid] = |
| 168 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 169 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 167 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 168 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 170 | 169 | } |
| 171 | 170 | elseif (is_array($this->bo->resources[$uid[0]])) |
| 172 | 171 | { |
| 173 | 172 | // Expand mailing lists |
| 174 | - if($uid[0] == 'l') |
|
| 173 | + if ($uid[0] == 'l') |
|
| 175 | 174 | { |
| 176 | - foreach($this->bo->enum_mailing_list($uid) as $contact) |
|
| 175 | + foreach ($this->bo->enum_mailing_list($uid) as $contact) |
|
| 177 | 176 | { |
| 178 | - $participants[$contact] = $participant_types['c'][substr($contact,1)] = |
|
| 179 | - calendar_so::combine_status('U',1,'REQ-PARTICIPANT'); |
|
| 177 | + $participants[$contact] = $participant_types['c'][substr($contact, 1)] = |
|
| 178 | + calendar_so::combine_status('U', 1, 'REQ-PARTICIPANT'); |
|
| 180 | 179 | } |
| 181 | 180 | continue; |
| 182 | 181 | } |
| 183 | 182 | // if contact is a user, use the user instead (as the GUI) |
| 184 | - if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid,1),'person_id'))) |
|
| 183 | + if ($uid[0] == 'c' && ($account_id = $GLOBALS['egw']->accounts->name2id(substr($uid, 1), 'person_id'))) |
|
| 185 | 184 | { |
| 186 | 185 | $uid = $account_id; |
| 187 | 186 | $participants[$uid] = $participant_types['u'][$uid] = |
| 188 | - calendar_so::combine_status($uid == $this->user ? 'A' : 'U',1, |
|
| 189 | - ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD,0,$owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 187 | + calendar_so::combine_status($uid == $this->user ? 'A' : 'U', 1, |
|
| 188 | + ($uid == $this->user || ($uid == $owner && $this->bo->check_perms(Acl::ADD, 0, $owner))) ? 'CHAIR' : 'REQ-PARTICIPANT'); |
|
| 190 | 189 | continue; |
| 191 | 190 | } |
| 192 | 191 | $res_data = $this->bo->resources[$uid[0]]; |
| 193 | - list($id,$quantity) = explode(':',substr($uid,1)); |
|
| 194 | - if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'],$id) : 'U')) |
|
| 192 | + list($id, $quantity) = explode(':', substr($uid, 1)); |
|
| 193 | + if (($status = $res_data['new_status'] ? ExecMethod($res_data['new_status'], $id) : 'U')) |
|
| 195 | 194 | { |
| 196 | 195 | $participants[$uid] = $participant_types[$uid[0]][$id] = |
| 197 | - calendar_so::combine_status($status,$quantity,'REQ-PARTICIPANT'); |
|
| 196 | + calendar_so::combine_status($status, $quantity, 'REQ-PARTICIPANT'); |
|
| 198 | 197 | } |
| 199 | 198 | } |
| 200 | 199 | } |
| 201 | 200 | if (!$participants) // if all participants got removed, include current user |
| 202 | 201 | { |
| 203 | - $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A',1,'CHAIR'); |
|
| 202 | + $participants[$this->user] = $participant_types['u'][$this->user] = calendar_so::combine_status('A', 1, 'CHAIR'); |
|
| 204 | 203 | } |
| 205 | - if(isset($_GET['cat_id'])) |
|
| 204 | + if (isset($_GET['cat_id'])) |
|
| 206 | 205 | { |
| 207 | - $cat_id = explode(',',$_GET['cat_id']); |
|
| 208 | - foreach($cat_id as &$cat) |
|
| 206 | + $cat_id = explode(',', $_GET['cat_id']); |
|
| 207 | + foreach ($cat_id as &$cat) |
|
| 209 | 208 | { |
| 210 | 209 | $cat = (int)$cat; |
| 211 | 210 | } |
@@ -216,16 +215,16 @@ discard block |
||
| 216 | 215 | if ((string)$this->cal_prefs['default-alarm'] !== '') |
| 217 | 216 | { |
| 218 | 217 | $offset = 60 * $this->cal_prefs['default-alarm']; |
| 219 | - $alarms[1] = array( |
|
| 218 | + $alarms[1] = array( |
|
| 220 | 219 | 'default' => 1, |
| 221 | - 'offset' => $offset , |
|
| 220 | + 'offset' => $offset, |
|
| 222 | 221 | 'time' => $start - $offset, |
| 223 | 222 | 'all' => false, |
| 224 | 223 | 'owner' => $owner, |
| 225 | 224 | 'id' => 1, |
| 226 | 225 | ); |
| 227 | 226 | } |
| 228 | - $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int) $this->bo->cal_prefs['defaultlength']*60; |
|
| 227 | + $duration = isset($_GET['duration']) ? (int)$_GET['duration'] : (int)$this->bo->cal_prefs['defaultlength'] * 60; |
|
| 229 | 228 | $end = isset($_GET['end']) ? Api\DateTime::to($_GET['end'], 'ts') : $start + $duration; |
| 230 | 229 | return array( |
| 231 | 230 | 'participant_types' => $participant_types, |
@@ -234,7 +233,7 @@ discard block |
||
| 234 | 233 | 'start' => $start, |
| 235 | 234 | 'end' => $end, |
| 236 | 235 | 'tzid' => $this->bo->common_prefs['tz'], |
| 237 | - 'priority' => 2, // normal |
|
| 236 | + 'priority' => 2, // normal |
|
| 238 | 237 | 'public'=> $this->cal_prefs['default_private'] ? 0 : 1, |
| 239 | 238 | 'alarm' => $alarms, |
| 240 | 239 | 'recur_exception' => array(), |
@@ -253,7 +252,7 @@ discard block |
||
| 253 | 252 | { |
| 254 | 253 | if (!is_array($content)) // redirect from etemplate, if POST empty |
| 255 | 254 | { |
| 256 | - return $this->edit(null,null,strip_tags($_GET['msg'])); |
|
| 255 | + return $this->edit(null, null, strip_tags($_GET['msg'])); |
|
| 257 | 256 | } |
| 258 | 257 | // clear notification errors |
| 259 | 258 | notifications::errors(true); |
@@ -267,22 +266,22 @@ discard block |
||
| 267 | 266 | $update_type = $content['id'] ? ($content['recur_type'] == MCAL_RECUR_NONE ? 'update' : 'edit') : 'add'; |
| 268 | 267 | |
| 269 | 268 | list($button) = @each($content['button']); |
| 270 | - if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 269 | + if (!$button && $content['action']) $button = $content['action']; // action selectbox |
|
| 271 | 270 | unset($content['button']); unset($content['action']); |
| 272 | 271 | |
| 273 | 272 | $view = $content['view']; |
| 274 | 273 | if ($button == 'ical') |
| 275 | 274 | { |
| 276 | - $msg = $this->export($content['id'],true); |
|
| 275 | + $msg = $this->export($content['id'], true); |
|
| 277 | 276 | } |
| 278 | 277 | // delete a recur-exception |
| 279 | 278 | if ($content['recur_exception']['delete_exception']) |
| 280 | 279 | { |
| 281 | 280 | list($date) = each($content['recur_exception']['delete_exception']); |
| 282 | 281 | // eT2 converts time to |
| 283 | - if (!is_numeric($date)) $date = Api\DateTime::to (str_replace('Z','', $date), 'ts'); |
|
| 282 | + if (!is_numeric($date)) $date = Api\DateTime::to(str_replace('Z', '', $date), 'ts'); |
|
| 284 | 283 | unset($content['recur_exception']['delete_exception']); |
| 285 | - if (($key = array_search($date,$content['recur_exception'])) !== false) |
|
| 284 | + if (($key = array_search($date, $content['recur_exception'])) !== false) |
|
| 286 | 285 | { |
| 287 | 286 | // propagate the exception to a single event |
| 288 | 287 | $recur_exceptions = $this->bo->so->get_related($content['uid']); |
@@ -292,7 +291,7 @@ discard block |
||
| 292 | 291 | $exception['recurrence'] != $content['recur_exception'][$key]) continue; |
| 293 | 292 | $exception['uid'] = Api\CalDAV::generate_uid('calendar', $id); |
| 294 | 293 | $exception['reference'] = $exception['recurrence'] = 0; |
| 295 | - $this->bo->update($exception, true, true,false,true,$messages,$content['no_notifications']); |
|
| 294 | + $this->bo->update($exception, true, true, false, true, $messages, $content['no_notifications']); |
|
| 296 | 295 | break; |
| 297 | 296 | } |
| 298 | 297 | unset($content['recur_exception'][$key]); |
@@ -333,7 +332,7 @@ discard block |
||
| 333 | 332 | $def_alarm = $this->cal_prefs['default-alarm'.($content['whole_day'] ? '-wholeday' : '')]; |
| 334 | 333 | if ((string)$def_alarm === '') |
| 335 | 334 | { |
| 336 | - unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 335 | + unset($content['alarm'][1]); // '' = no alarm on whole day --> delete it |
|
| 337 | 336 | } |
| 338 | 337 | else |
| 339 | 338 | { |
@@ -347,7 +346,7 @@ discard block |
||
| 347 | 346 | unset($event['alarm']['delete_alarm']); |
| 348 | 347 | unset($event['duration']); |
| 349 | 348 | |
| 350 | - if (in_array($button,array('ignore','freetime','reedit','confirm_edit_series'))) |
|
| 349 | + if (in_array($button, array('ignore', 'freetime', 'reedit', 'confirm_edit_series'))) |
|
| 351 | 350 | { |
| 352 | 351 | // no conversation necessary, event is already in the right format |
| 353 | 352 | } |
@@ -367,7 +366,7 @@ discard block |
||
| 367 | 366 | if ($event['recur_type'] == MCAL_RECUR_NONE && $event['recur_data']) $event['recur_type'] = MCAL_RECUR_WEEKLY; |
| 368 | 367 | if ($event['recur_type'] == MCAL_RECUR_WEEKLY && !$event['recur_data']) |
| 369 | 368 | { |
| 370 | - $event['recur_data'] = 1 << (int)date('w',$event['start']); |
|
| 369 | + $event['recur_data'] = 1 << (int)date('w', $event['start']); |
|
| 371 | 370 | } |
| 372 | 371 | if ($event['recur_type'] != MCAL_RECUR_NONE && !isset($event['recur_enddate'])) |
| 373 | 372 | { |
@@ -379,9 +378,9 @@ discard block |
||
| 379 | 378 | |
| 380 | 379 | $event['participants'] = $event['participant_types'] = array(); |
| 381 | 380 | |
| 382 | - foreach($content['participants'] as $key => $data) |
|
| 381 | + foreach ($content['participants'] as $key => $data) |
|
| 383 | 382 | { |
| 384 | - switch($key) |
|
| 383 | + switch ($key) |
|
| 385 | 384 | { |
| 386 | 385 | case 'delete': // handled in default |
| 387 | 386 | case 'quantity': // handled in new_resource |
@@ -390,7 +389,7 @@ discard block |
||
| 390 | 389 | case 'status_date': |
| 391 | 390 | break; |
| 392 | 391 | case 'participant': |
| 393 | - foreach($data as $participant) |
|
| 392 | + foreach ($data as $participant) |
|
| 394 | 393 | { |
| 395 | 394 | if (is_null($participant)) |
| 396 | 395 | { |
@@ -399,17 +398,17 @@ discard block |
||
| 399 | 398 | |
| 400 | 399 | // email or rfc822 addresse (eg. "Ralf Becker <[email protected]>") |
| 401 | 400 | $email = array(); |
| 402 | - if(preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i',$participant,$email)) |
|
| 401 | + if (preg_match('/^(.*<)?([a-z0-9_.-]+@[a-z0-9_.-]{5,})>?$/i', $participant, $email)) |
|
| 403 | 402 | { |
| 404 | - $status = calendar_so::combine_status('U',$content['participants']['quantity'],$content['participants']['role']); |
|
| 405 | - if (($data = $GLOBALS['egw']->accounts->name2id($email[2],'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 403 | + $status = calendar_so::combine_status('U', $content['participants']['quantity'], $content['participants']['role']); |
|
| 404 | + if (($data = $GLOBALS['egw']->accounts->name2id($email[2], 'account_email')) && $this->bo->check_acl_invite($data)) |
|
| 406 | 405 | { |
| 407 | 406 | $event['participants'][$data] = $event['participant_types']['u'][$data] = $status; |
| 408 | 407 | } |
| 409 | - elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search',array( |
|
| 408 | + elseif ((list($data) = ExecMethod2('addressbook.addressbook_bo.search', array( |
|
| 410 | 409 | 'email' => $email[2], |
| 411 | 410 | 'email_home' => $email[2], |
| 412 | - ),true,'','','',false,'OR'))) |
|
| 411 | + ), true, '', '', '', false, 'OR'))) |
|
| 413 | 412 | { |
| 414 | 413 | $event['participants']['c'.$data['id']] = $event['participant_types']['c'][$data['id']] = $status; |
| 415 | 414 | } |
@@ -420,7 +419,7 @@ discard block |
||
| 420 | 419 | } |
| 421 | 420 | else |
| 422 | 421 | { |
| 423 | - if(is_numeric($participant)) |
|
| 422 | + if (is_numeric($participant)) |
|
| 424 | 423 | { |
| 425 | 424 | $uid = $participant; |
| 426 | 425 | $id = $participant; |
@@ -429,12 +428,12 @@ discard block |
||
| 429 | 428 | else |
| 430 | 429 | { |
| 431 | 430 | $uid = $participant; |
| 432 | - $id = substr($participant,1); |
|
| 431 | + $id = substr($participant, 1); |
|
| 433 | 432 | $resource = $this->bo->resources[$participant[0]]; |
| 434 | 433 | } |
| 435 | - if(!$this->bo->check_acl_invite($uid)) |
|
| 434 | + if (!$this->bo->check_acl_invite($uid)) |
|
| 436 | 435 | { |
| 437 | - if(!$msg_permission_denied_added) |
|
| 436 | + if (!$msg_permission_denied_added) |
|
| 438 | 437 | { |
| 439 | 438 | $msg .= lang('Permission denied!'); |
| 440 | 439 | $msg_permission_denied_added = true; |
@@ -444,20 +443,19 @@ discard block |
||
| 444 | 443 | |
| 445 | 444 | $type = $resource['type']; |
| 446 | 445 | $status = isset($this->bo->resources[$type]['new_status']) ? |
| 447 | - ExecMethod($this->bo->resources[$type]['new_status'],$id) : |
|
| 448 | - ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 446 | + ExecMethod($this->bo->resources[$type]['new_status'], $id) : ($uid == $this->bo->user ? 'A' : 'U'); |
|
| 449 | 447 | |
| 450 | 448 | // Expand mailing lists |
| 451 | - if($type == 'l') |
|
| 449 | + if ($type == 'l') |
|
| 452 | 450 | { |
| 453 | 451 | // Ignore ACL here, allow inviting anyone in the list |
| 454 | - foreach($this->bo->enum_mailing_list($participant, true) as $contact) |
|
| 452 | + foreach ($this->bo->enum_mailing_list($participant, true) as $contact) |
|
| 455 | 453 | { |
| 456 | 454 | // Mailing lists can contain users, so allow for that possibility |
| 457 | 455 | $_type = is_numeric($contact) ? '' : $contact[0]; |
| 458 | - $_uid = is_numeric($contact) ? $contact : substr($contact,1); |
|
| 456 | + $_uid = is_numeric($contact) ? $contact : substr($contact, 1); |
|
| 459 | 457 | $event['participants'][$contact] = $event['participant_types'][$_type][$_uid] = |
| 460 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 458 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 461 | 459 | } |
| 462 | 460 | continue; |
| 463 | 461 | } |
@@ -467,8 +465,8 @@ discard block |
||
| 467 | 465 | // todo check real availability = maximum - already booked quantity |
| 468 | 466 | if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable']) |
| 469 | 467 | { |
| 470 | - $msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']); |
|
| 471 | - foreach(array('quantity','resource','role') as $n) |
|
| 468 | + $msg .= lang('Maximum available quantity of %1 exceeded!', $res_info['useable']); |
|
| 469 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 472 | 470 | { |
| 473 | 471 | $event['participants'][$n] = $content['participants'][$n]; |
| 474 | 472 | } |
@@ -477,7 +475,7 @@ discard block |
||
| 477 | 475 | else |
| 478 | 476 | { |
| 479 | 477 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 480 | - calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']); |
|
| 478 | + calendar_so::combine_status($status, $content['participants']['quantity'], $content['participants']['role']); |
|
| 481 | 479 | } |
| 482 | 480 | } |
| 483 | 481 | } |
@@ -491,14 +489,14 @@ discard block |
||
| 491 | 489 | break; |
| 492 | 490 | |
| 493 | 491 | default: // existing participant row |
| 494 | - if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 495 | - foreach(array('uid','status','quantity','role') as $name) |
|
| 492 | + if (!is_array($data)) continue; // widgets in participant tab, above participant list |
|
| 493 | + foreach (array('uid', 'status', 'quantity', 'role') as $name) |
|
| 496 | 494 | { |
| 497 | 495 | $$name = $data[$name]; |
| 498 | 496 | } |
| 499 | 497 | if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)]) |
| 500 | 498 | { |
| 501 | - $uid = false; // entry has been deleted |
|
| 499 | + $uid = false; // entry has been deleted |
|
| 502 | 500 | } |
| 503 | 501 | elseif ($uid) |
| 504 | 502 | { |
@@ -509,27 +507,27 @@ discard block |
||
| 509 | 507 | } |
| 510 | 508 | else |
| 511 | 509 | { |
| 512 | - $id = substr($uid,1); |
|
| 510 | + $id = substr($uid, 1); |
|
| 513 | 511 | $type = $uid[0]; |
| 514 | 512 | } |
| 515 | 513 | if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G')) |
| 516 | 514 | { |
| 517 | 515 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 518 | 516 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 519 | - if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 517 | + if ($this->bo->set_status($event['id'], $uid, $new_status, isset($content['edit_single']) ? $content['participants']['status_date'] : 0, false, true, $content['no_notifications'])) |
|
| 520 | 518 | { |
| 521 | 519 | // Update main window |
| 522 | 520 | $d = new Api\DateTime($content['edit_single'], Api\DateTime::$user_timezone); |
| 523 | 521 | $client_updated = $this->update_client($event['id'], $d); |
| 524 | 522 | |
| 525 | 523 | // refreshing the calendar-view with the changed participant-status |
| 526 | - if($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 524 | + if ($event['recur_type'] != MCAL_RECUR_NONE) |
|
| 527 | 525 | { |
| 528 | 526 | $msg = lang('Status for all future scheduled days changed'); |
| 529 | 527 | } |
| 530 | 528 | else |
| 531 | 529 | { |
| 532 | - if(isset($content['edit_single'])) |
|
| 530 | + if (isset($content['edit_single'])) |
|
| 533 | 531 | { |
| 534 | 532 | $msg = lang('Status for this particular day changed'); |
| 535 | 533 | // prevent accidentally creating a real exception afterwards |
@@ -550,7 +548,7 @@ discard block |
||
| 550 | 548 | if ($status == 'R' && $event['alarm']) |
| 551 | 549 | { |
| 552 | 550 | // remove from bo->set_status deleted alarms of rejected users from UI too |
| 553 | - foreach($event['alarm'] as $alarm_id => $alarm) |
|
| 551 | + foreach ($event['alarm'] as $alarm_id => $alarm) |
|
| 554 | 552 | { |
| 555 | 553 | if ((string)$alarm['owner'] === (string)$uid) |
| 556 | 554 | { |
@@ -563,7 +561,7 @@ discard block |
||
| 563 | 561 | if ($uid && $status != 'G') |
| 564 | 562 | { |
| 565 | 563 | $event['participants'][$uid] = $event['participant_types'][$type][$id] = |
| 566 | - calendar_so::combine_status($status,$quantity,$role); |
|
| 564 | + calendar_so::combine_status($status, $quantity, $role); |
|
| 567 | 565 | } |
| 568 | 566 | } |
| 569 | 567 | break; |
@@ -582,26 +580,26 @@ discard block |
||
| 582 | 580 | 'tabs' => $content['tabs'], |
| 583 | 581 | 'template' => $content['template'], |
| 584 | 582 | ); |
| 585 | - $noerror=true; |
|
| 583 | + $noerror = true; |
|
| 586 | 584 | |
| 587 | 585 | //error_log(__METHOD__.$button.'#'.array2string($content['edit_single']).'#'); |
| 588 | 586 | |
| 589 | 587 | $ignore_conflicts = $status_reset_to_unknown = false; |
| 590 | 588 | |
| 591 | - switch((string)$button) |
|
| 589 | + switch ((string)$button) |
|
| 592 | 590 | { |
| 593 | 591 | case 'ignore': |
| 594 | 592 | $ignore_conflicts = true; |
| 595 | - $button = $event['button_was']; // save or apply |
|
| 593 | + $button = $event['button_was']; // save or apply |
|
| 596 | 594 | unset($event['button_was']); |
| 597 | 595 | break; |
| 598 | 596 | |
| 599 | 597 | } |
| 600 | 598 | |
| 601 | - switch((string)$button) |
|
| 599 | + switch ((string)$button) |
|
| 602 | 600 | { |
| 603 | 601 | case 'exception': // create an exception in a recuring event |
| 604 | - $msg = $this->_create_exception($event,$preserv); |
|
| 602 | + $msg = $this->_create_exception($event, $preserv); |
|
| 605 | 603 | break; |
| 606 | 604 | |
| 607 | 605 | case 'copy': // create new event with copied content, some content need to be unset to make a "new" event |
@@ -612,29 +610,29 @@ discard block |
||
| 612 | 610 | unset($event['recurrence']); |
| 613 | 611 | unset($preserv['recurrence']); |
| 614 | 612 | unset($event['recur_exception']); |
| 615 | - unset($event['edit_single']); // in case it has been set |
|
| 613 | + unset($event['edit_single']); // in case it has been set |
|
| 616 | 614 | unset($event['modified']); |
| 617 | 615 | unset($event['modifier']); |
| 618 | 616 | unset($event['caldav_name']); |
| 619 | - $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD,0,$event['owner']) ? $this->user : $event['owner']; |
|
| 617 | + $event['owner'] = !(int)$event['owner'] || !$this->bo->check_perms(Acl::ADD, 0, $event['owner']) ? $this->user : $event['owner']; |
|
| 620 | 618 | |
| 621 | 619 | // Clear participant stati |
| 622 | - foreach($event['participant_types'] as $type => &$participants) |
|
| 620 | + foreach ($event['participant_types'] as $type => &$participants) |
|
| 623 | 621 | { |
| 624 | - foreach($participants as $id => &$p_response) |
|
| 622 | + foreach ($participants as $id => &$p_response) |
|
| 625 | 623 | { |
| 626 | - if($type == 'u' && $id == $event['owner']) continue; |
|
| 624 | + if ($type == 'u' && $id == $event['owner']) continue; |
|
| 627 | 625 | calendar_so::split_status($p_response, $quantity, $role); |
| 628 | 626 | // if resource defines callback for status of new status (eg. Resources app acknowledges direct booking acl), call it |
| 629 | - $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U'; |
|
| 630 | - $p_response = calendar_so::combine_status($status,$quantity,$role); |
|
| 627 | + $status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'], $id) : 'U'; |
|
| 628 | + $p_response = calendar_so::combine_status($status, $quantity, $role); |
|
| 631 | 629 | } |
| 632 | 630 | } |
| 633 | 631 | |
| 634 | 632 | // Copy alarms |
| 635 | 633 | if (is_array($event['alarm'])) |
| 636 | 634 | { |
| 637 | - foreach($event['alarm'] as $n => &$alarm) |
|
| 635 | + foreach ($event['alarm'] as $n => &$alarm) |
|
| 638 | 636 | { |
| 639 | 637 | unset($alarm['id']); |
| 640 | 638 | unset($alarm['cal_id']); |
@@ -644,7 +642,7 @@ discard block |
||
| 644 | 642 | // Get links to be copied |
| 645 | 643 | // With no ID, $content['link_to']['to_id'] is used |
| 646 | 644 | $content['link_to']['to_id'] = array('to_app' => 'calendar', 'to_id' => 0); |
| 647 | - foreach(Link::get_links('calendar', $content['id']) as $link) |
|
| 645 | + foreach (Link::get_links('calendar', $content['id']) as $link) |
|
| 648 | 646 | { |
| 649 | 647 | if ($link['app'] != Link::VFS_APPNAME) |
| 650 | 648 | { |
@@ -660,7 +658,7 @@ discard block |
||
| 660 | 658 | } |
| 661 | 659 | unset($link); |
| 662 | 660 | $preserv['view'] = $preserv['edit_single'] = false; |
| 663 | - $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar','entry'))); |
|
| 661 | + $msg = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('calendar', 'entry'))); |
|
| 664 | 662 | $event['title'] = lang('Copy of:').' '.$event['title']; |
| 665 | 663 | break; |
| 666 | 664 | |
@@ -670,7 +668,7 @@ discard block |
||
| 670 | 668 | case 'print': |
| 671 | 669 | case 'apply': |
| 672 | 670 | case 'infolog': |
| 673 | - if ($event['id'] && !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 671 | + if ($event['id'] && !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 674 | 672 | { |
| 675 | 673 | $msg = lang('Permission denied'); |
| 676 | 674 | $button = ''; |
@@ -688,7 +686,7 @@ discard block |
||
| 688 | 686 | $button = ''; |
| 689 | 687 | break; |
| 690 | 688 | } |
| 691 | - if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end']-$event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 689 | + if ($event['recur_type'] != MCAL_RECUR_NONE && $event['end'] - $event['start'] > calendar_rrule::recurrence_interval($event['recur_type'], $event['recur_interval'])) |
|
| 692 | 690 | { |
| 693 | 691 | $msg = lang('Error: Duration of event longer then recurrence interval!'); |
| 694 | 692 | $button = ''; |
@@ -718,14 +716,14 @@ discard block |
||
| 718 | 716 | $event['reference'] = $event['id']; |
| 719 | 717 | $event['recurrence'] = $content['edit_single']; |
| 720 | 718 | unset($event['id']); |
| 721 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 719 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 722 | 720 | if (!is_array($conflicts) && $conflicts) |
| 723 | 721 | { |
| 724 | 722 | // now we need to add the original start as recur-execption to the series |
| 725 | 723 | $recur_event = $this->bo->read($event['reference']); |
| 726 | 724 | $recur_event['recur_exception'][] = $content['edit_single']; |
| 727 | 725 | // check if we need to move the alarms, because they are next on that exception |
| 728 | - foreach($recur_event['alarm'] as $id => $alarm) |
|
| 726 | + foreach ($recur_event['alarm'] as $id => $alarm) |
|
| 729 | 727 | { |
| 730 | 728 | if ($alarm['time'] == $content['edit_single'] - $alarm['offset']) |
| 731 | 729 | { |
@@ -741,17 +739,17 @@ discard block |
||
| 741 | 739 | } |
| 742 | 740 | } |
| 743 | 741 | } |
| 744 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 745 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 746 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 742 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 743 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 744 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 747 | 745 | |
| 748 | 746 | // Save links |
| 749 | - if($content['links']) |
|
| 747 | + if ($content['links']) |
|
| 750 | 748 | { |
| 751 | 749 | Link::link('calendar', $event['id'], $content['links']['to_id']); |
| 752 | 750 | } |
| 753 | 751 | |
| 754 | - if(Api\Json\Response::isJSONResponse()) |
|
| 752 | + if (Api\Json\Response::isJSONResponse()) |
|
| 755 | 753 | { |
| 756 | 754 | // Sending null will trigger a removal of the original |
| 757 | 755 | // for that date |
@@ -759,7 +757,7 @@ discard block |
||
| 759 | 757 | } |
| 760 | 758 | |
| 761 | 759 | unset($recur_event); |
| 762 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 760 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 763 | 761 | unset($preserv['edit_single']); |
| 764 | 762 | } |
| 765 | 763 | else // conflict or error, we need to reset everything to the state befor we tried to save it |
@@ -790,8 +788,8 @@ discard block |
||
| 790 | 788 | { |
| 791 | 789 | $offset = $off2; |
| 792 | 790 | } |
| 793 | - $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset,$content['no_notifications']); |
|
| 794 | - if($msg) |
|
| 791 | + $msg = $this->_break_recurring($event, $old_event, $event['actual_date'] + $offset, $content['no_notifications']); |
|
| 792 | + if ($msg) |
|
| 795 | 793 | { |
| 796 | 794 | $noerror = false; |
| 797 | 795 | } |
@@ -804,10 +802,10 @@ discard block |
||
| 804 | 802 | $event['whole_day'] != $old_event['whole_day']) |
| 805 | 803 | { |
| 806 | 804 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 807 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 805 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 808 | 806 | { |
| 809 | 807 | $q = $r = null; |
| 810 | - calendar_so::split_status($status,$q,$r); |
|
| 808 | + calendar_so::split_status($status, $q, $r); |
|
| 811 | 809 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 812 | 810 | { |
| 813 | 811 | $preferences = new Api\Preferences($uid); |
@@ -820,7 +818,7 @@ discard block |
||
| 820 | 818 | if ($sameday) break; |
| 821 | 819 | default: |
| 822 | 820 | $status_reset_to_unknown = true; |
| 823 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 821 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 824 | 822 | // todo: report reset status to user |
| 825 | 823 | } |
| 826 | 824 | } |
@@ -838,43 +836,43 @@ discard block |
||
| 838 | 836 | } |
| 839 | 837 | // Adding participants needs to be done as an edit, in case we |
| 840 | 838 | // have participants visible in seperate calendars |
| 841 | - if(is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 839 | + if (is_array($old_event['participants']) && count(array_diff_key($event['participants'], $old_event['participants']))) |
|
| 842 | 840 | { |
| 843 | 841 | $update_type = 'edit'; |
| 844 | 842 | } |
| 845 | 843 | // Changing category may affect event filtering |
| 846 | - if($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 844 | + if ($this->cal_prefs['saved_states']['cat_id'] && $old_event['category'] != $event['category']) |
|
| 847 | 845 | { |
| 848 | 846 | $update_type = 'edit'; |
| 849 | 847 | } |
| 850 | - $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); |
|
| 848 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $messages, $content['no_notifications']); |
|
| 851 | 849 | unset($event['ignore']); |
| 852 | 850 | } |
| 853 | 851 | if (is_array($conflicts)) |
| 854 | 852 | { |
| 855 | - $event['button_was'] = $button; // remember for ignore |
|
| 856 | - return $this->conflicts($event,$conflicts,$preserv); |
|
| 853 | + $event['button_was'] = $button; // remember for ignore |
|
| 854 | + return $this->conflicts($event, $conflicts, $preserv); |
|
| 857 | 855 | } |
| 858 | 856 | |
| 859 | 857 | // Event spans multiple days, need an edit to make sure they all get updated |
| 860 | 858 | // We could check old date, as removing from days could still be an update |
| 861 | - if(date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 859 | + if (date('Ymd', $event['start']) != date('Ymd', $event['end'])) |
|
| 862 | 860 | { |
| 863 | 861 | $update_type = 'edit'; |
| 864 | 862 | } |
| 865 | 863 | // check if there are messages from update, eg. removed participants or Api\Categories because of missing rights |
| 866 | 864 | if ($messages) |
| 867 | 865 | { |
| 868 | - $msg .= ($msg ? ', ' : '').implode(', ',$messages); |
|
| 866 | + $msg .= ($msg ? ', ' : '').implode(', ', $messages); |
|
| 869 | 867 | } |
| 870 | 868 | if ($conflicts === 0) |
| 871 | 869 | { |
| 872 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 873 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 874 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 870 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 871 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 872 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 875 | 873 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 876 | 874 | 'cal_id' => $content['id'], |
| 877 | - ))).'">','</a>'); |
|
| 875 | + ))).'">', '</a>'); |
|
| 878 | 876 | $noerror = false; |
| 879 | 877 | } |
| 880 | 878 | elseif ($conflicts > 0) |
@@ -896,19 +894,19 @@ discard block |
||
| 896 | 894 | // if alarm would be in the past (eg. event moved back) --> move to next possible recurrence |
| 897 | 895 | if ($alarm['time'] < $this->bo->now_su) |
| 898 | 896 | { |
| 899 | - if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su+$alarm['offset'], true))) |
|
| 897 | + if (($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + $alarm['offset'], true))) |
|
| 900 | 898 | { |
| 901 | - $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 899 | + $alarm['time'] = $next_occurrence['start'] - $alarm['offset']; |
|
| 902 | 900 | } |
| 903 | 901 | else |
| 904 | 902 | { |
| 905 | - $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 903 | + $alarm = false; // no (further) recurence found --> ignore alarm |
|
| 906 | 904 | } |
| 907 | 905 | } |
| 908 | 906 | // alarm is currently on a previous recurrence --> set for first recurrence of new series |
| 909 | 907 | elseif ($event_time < $event['start']) |
| 910 | 908 | { |
| 911 | - $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 909 | + $alarm['time'] = $event['start'] - $alarm['offset']; |
|
| 912 | 910 | } |
| 913 | 911 | if ($alarm) |
| 914 | 912 | { |
@@ -917,9 +915,9 @@ discard block |
||
| 917 | 915 | } |
| 918 | 916 | } |
| 919 | 917 | // attach all future exceptions to the new series |
| 920 | - $events =& $this->bo->search(array( |
|
| 918 | + $events = & $this->bo->search(array( |
|
| 921 | 919 | 'query' => array('cal_uid' => $old_event['uid']), |
| 922 | - 'filter' => 'owner', // return all possible entries |
|
| 920 | + 'filter' => 'owner', // return all possible entries |
|
| 923 | 921 | 'daywise' => false, |
| 924 | 922 | 'date_format' => 'ts', |
| 925 | 923 | )); |
@@ -930,7 +928,7 @@ discard block |
||
| 930 | 928 | $exception['recurrence'] += $offset; |
| 931 | 929 | $exception['reference'] = $event['id']; |
| 932 | 930 | $exception['uid'] = $event['uid']; |
| 933 | - $this->bo->update($exception, true, true, true, true, $msg=null, $content['no_notifications']); |
|
| 931 | + $this->bo->update($exception, true, true, true, true, $msg = null, $content['no_notifications']); |
|
| 934 | 932 | } |
| 935 | 933 | } |
| 936 | 934 | } |
@@ -938,12 +936,12 @@ discard block |
||
| 938 | 936 | $message = lang('Event saved'); |
| 939 | 937 | if ($status_reset_to_unknown) |
| 940 | 938 | { |
| 941 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 939 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 942 | 940 | { |
| 943 | 941 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 944 | 942 | { |
| 945 | - calendar_so::split_status($status,$q,$r); |
|
| 946 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 943 | + calendar_so::split_status($status, $q, $r); |
|
| 944 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 947 | 945 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 948 | 946 | } |
| 949 | 947 | } |
@@ -951,17 +949,17 @@ discard block |
||
| 951 | 949 | } |
| 952 | 950 | |
| 953 | 951 | $response = Api\Json\Response::get(); |
| 954 | - if($response && $update_type != 'delete') |
|
| 952 | + if ($response && $update_type != 'delete') |
|
| 955 | 953 | { |
| 956 | 954 | $client_updated = $this->update_client($event['id']); |
| 957 | 955 | } |
| 958 | 956 | |
| 959 | - $msg = $message . ($msg ? ', ' . $msg : ''); |
|
| 957 | + $msg = $message.($msg ? ', '.$msg : ''); |
|
| 960 | 958 | Framework::refresh_opener($msg, 'calendar', $event['id'], $client_updated ? ($event['recur_type'] ? 'edit' : $update_type) : 'delete'); |
| 961 | 959 | // writing links for new entry, existing ones are handled by the widget itself |
| 962 | 960 | if (!$content['id'] && is_array($content['link_to']['to_id'])) |
| 963 | 961 | { |
| 964 | - Link::link('calendar',$event['id'],$content['link_to']['to_id']); |
|
| 962 | + Link::link('calendar', $event['id'], $content['link_to']['to_id']); |
|
| 965 | 963 | } |
| 966 | 964 | } |
| 967 | 965 | else |
@@ -971,7 +969,7 @@ discard block |
||
| 971 | 969 | break; |
| 972 | 970 | |
| 973 | 971 | case 'cancel': |
| 974 | - if($content['cancel_needs_refresh']) |
|
| 972 | + if ($content['cancel_needs_refresh']) |
|
| 975 | 973 | { |
| 976 | 974 | Framework::refresh_opener($msg, 'calendar'); |
| 977 | 975 | } |
@@ -1009,7 +1007,7 @@ discard block |
||
| 1009 | 1007 | { |
| 1010 | 1008 | $content['new_alarm']['date'] = $next_occurrence['start'] - $offset; |
| 1011 | 1009 | } |
| 1012 | - if ($this->bo->check_perms(Acl::EDIT,!$content['new_alarm']['owner'] ? $event : 0,$content['new_alarm']['owner'])) |
|
| 1010 | + if ($this->bo->check_perms(Acl::EDIT, !$content['new_alarm']['owner'] ? $event : 0, $content['new_alarm']['owner'])) |
|
| 1013 | 1011 | { |
| 1014 | 1012 | $alarm = array( |
| 1015 | 1013 | 'offset' => $offset, |
@@ -1023,13 +1021,13 @@ discard block |
||
| 1023 | 1021 | } |
| 1024 | 1022 | elseif ($event['id']) // save the alarm immediatly |
| 1025 | 1023 | { |
| 1026 | - if (($alarm_id = $this->bo->save_alarm($event['id'],$alarm))) |
|
| 1024 | + if (($alarm_id = $this->bo->save_alarm($event['id'], $alarm))) |
|
| 1027 | 1025 | { |
| 1028 | 1026 | $alarm['id'] = $alarm_id; |
| 1029 | 1027 | $event['alarm'][$alarm_id] = $alarm; |
| 1030 | 1028 | |
| 1031 | 1029 | $msg = lang('Alarm added'); |
| 1032 | - Framework::refresh_opener($msg,'calendar', $event['id'], 'update'); |
|
| 1030 | + Framework::refresh_opener($msg, 'calendar', $event['id'], 'update'); |
|
| 1033 | 1031 | } |
| 1034 | 1032 | else |
| 1035 | 1033 | { |
@@ -1038,7 +1036,7 @@ discard block |
||
| 1038 | 1036 | } |
| 1039 | 1037 | else |
| 1040 | 1038 | { |
| 1041 | - for($alarm['id']=1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1039 | + for ($alarm['id'] = 1; isset($event['alarm'][$alarm['id']]); $alarm['id']++) {} // get a temporary non-conflicting, numeric id |
|
| 1042 | 1040 | $event['alarm'][$alarm['id']] = $alarm; |
| 1043 | 1041 | } |
| 1044 | 1042 | } |
@@ -1055,31 +1053,31 @@ discard block |
||
| 1055 | 1053 | } |
| 1056 | 1054 | // New event, send data before updating so it's there |
| 1057 | 1055 | $response = Api\Json\Response::get(); |
| 1058 | - if($response && !$content['id'] && $event['id']) |
|
| 1056 | + if ($response && !$content['id'] && $event['id']) |
|
| 1059 | 1057 | { |
| 1060 | 1058 | $client_updated = $this->update_client($event['id']); |
| 1061 | 1059 | } |
| 1062 | - if (in_array($button,array('cancel','save','delete','delete_exceptions','delete_keep_exceptions')) && $noerror) |
|
| 1060 | + if (in_array($button, array('cancel', 'save', 'delete', 'delete_exceptions', 'delete_keep_exceptions')) && $noerror) |
|
| 1063 | 1061 | { |
| 1064 | 1062 | if ($content['lock_token']) // remove an existing lock |
| 1065 | 1063 | { |
| 1066 | - Vfs::unlock(Vfs::app_entry_lock_path('calendar',$content['id']),$content['lock_token'],false); |
|
| 1064 | + Vfs::unlock(Vfs::app_entry_lock_path('calendar', $content['id']), $content['lock_token'], false); |
|
| 1067 | 1065 | } |
| 1068 | 1066 | if ($content['no_popup']) |
| 1069 | 1067 | { |
| 1070 | - Egw::redirect_link('/index.php',array( |
|
| 1068 | + Egw::redirect_link('/index.php', array( |
|
| 1071 | 1069 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 1072 | 1070 | 'msg' => $msg, |
| 1073 | 1071 | )); |
| 1074 | 1072 | } |
| 1075 | - if (in_array($button,array('delete_exceptions','delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1073 | + if (in_array($button, array('delete_exceptions', 'delete_keep_exceptions')) || $content['recur_type'] && $button == 'delete') |
|
| 1076 | 1074 | { |
| 1077 | - Framework::refresh_opener($msg,'calendar'); |
|
| 1075 | + Framework::refresh_opener($msg, 'calendar'); |
|
| 1078 | 1076 | } |
| 1079 | 1077 | else |
| 1080 | 1078 | { |
| 1081 | 1079 | Framework::refresh_opener($msg, 'calendar', |
| 1082 | - $event['id'] . ($content['edit_single'] ? ':' . (int)$content['edit_single'] : '' ), |
|
| 1080 | + $event['id'].($content['edit_single'] ? ':'.(int)$content['edit_single'] : ''), |
|
| 1083 | 1081 | $button == 'save' && $client_updated ? ($content['id'] ? $update_type : 'add') : 'delete' |
| 1084 | 1082 | ); |
| 1085 | 1083 | } |
@@ -1087,7 +1085,7 @@ discard block |
||
| 1087 | 1085 | exit(); |
| 1088 | 1086 | } |
| 1089 | 1087 | unset($event['no_notifications']); |
| 1090 | - return $this->edit($event,$preserv,$msg,$event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1088 | + return $this->edit($event, $preserv, $msg, $event['id'] ? $event['id'] : $content['link_to']['to_id']); |
|
| 1091 | 1089 | } |
| 1092 | 1090 | |
| 1093 | 1091 | /** |
@@ -1099,7 +1097,7 @@ discard block |
||
| 1099 | 1097 | * @param array &$preserv |
| 1100 | 1098 | * @return string message that exception was created |
| 1101 | 1099 | */ |
| 1102 | - function _create_exception(&$event,&$preserv) |
|
| 1100 | + function _create_exception(&$event, &$preserv) |
|
| 1103 | 1101 | { |
| 1104 | 1102 | // In some cases where the user makes the first day an exception, actual_date may be missing |
| 1105 | 1103 | $preserv['actual_date'] = $preserv['actual_date'] ? $preserv['actual_date'] : $event['start']; |
@@ -1109,25 +1107,25 @@ discard block |
||
| 1109 | 1107 | $event['recurrence'] = $preserv['recurrence'] = $preserv['actual_date']; |
| 1110 | 1108 | $event['start'] = $preserv['edit_single'] = $preserv['actual_date']; |
| 1111 | 1109 | $event['recur_type'] = MCAL_RECUR_NONE; |
| 1112 | - foreach(array('recur_enddate','recur_interval','recur_exception','recur_data') as $name) |
|
| 1110 | + foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data') as $name) |
|
| 1113 | 1111 | { |
| 1114 | 1112 | unset($event[$name]); |
| 1115 | 1113 | } |
| 1116 | 1114 | // add all alarms as new alarms to execption |
| 1117 | 1115 | $event['alarm'] = array_values((array)$event['alarm']); |
| 1118 | - foreach($event['alarm'] as &$alarm) |
|
| 1116 | + foreach ($event['alarm'] as &$alarm) |
|
| 1119 | 1117 | { |
| 1120 | 1118 | unset($alarm['uid'], $alarm['id'], $alarm['time']); |
| 1121 | 1119 | } |
| 1122 | 1120 | |
| 1123 | 1121 | // Copy links |
| 1124 | - if(!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1122 | + if (!is_array($event['link_to'])) $event['link_to'] = array(); |
|
| 1125 | 1123 | $event['link_to']['to_app'] = 'calendar'; |
| 1126 | 1124 | $event['link_to']['to_id'] = 0; |
| 1127 | 1125 | |
| 1128 | - foreach(Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
| 1126 | + foreach (Link::get_links($event['link_to']['to_app'], $event['id']) as $link) |
|
| 1129 | 1127 | { |
| 1130 | - if(!$link['id']) continue; |
|
| 1128 | + if (!$link['id']) continue; |
|
| 1131 | 1129 | if ($link['app'] != Link::VFS_APPNAME) |
| 1132 | 1130 | { |
| 1133 | 1131 | Link::link('calendar', $event['link_to']['to_id'], $link['app'], $link['id'], $link['remark']); |
@@ -1143,7 +1141,7 @@ discard block |
||
| 1143 | 1141 | |
| 1144 | 1142 | $event['links'] = $event['link_to']; |
| 1145 | 1143 | |
| 1146 | - if($this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1144 | + if ($this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1147 | 1145 | { |
| 1148 | 1146 | return lang('Save event as exception - Delete single occurrence - Edit status or alarms for this particular day'); |
| 1149 | 1147 | } |
@@ -1170,14 +1168,14 @@ discard block |
||
| 1170 | 1168 | { |
| 1171 | 1169 | $msg = false; |
| 1172 | 1170 | |
| 1173 | - if(!$as_of_date ) |
|
| 1171 | + if (!$as_of_date) |
|
| 1174 | 1172 | { |
| 1175 | 1173 | $as_of_date = time(); |
| 1176 | 1174 | } |
| 1177 | 1175 | |
| 1178 | 1176 | //error_log(__METHOD__ . Api\DateTime::to($old_event['start']) . ' -> '. Api\DateTime::to($event['start']) . ' as of ' . Api\DateTime::to($as_of_date)); |
| 1179 | 1177 | |
| 1180 | - if(!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1178 | + if (!($next_occurrence = $this->bo->read($event['id'], $this->bo->now_su + 1, true))) |
|
| 1181 | 1179 | { |
| 1182 | 1180 | $msg = lang("Error: You can't shift a series from the past!"); |
| 1183 | 1181 | return $msg; |
@@ -1190,11 +1188,11 @@ discard block |
||
| 1190 | 1188 | $duration = $event['duration'] ? $event['duration'] : $event['end'] - $event['start']; |
| 1191 | 1189 | |
| 1192 | 1190 | // base start-date of new series on actual / clicked date |
| 1193 | - $event['start'] = $as_of_date ; |
|
| 1191 | + $event['start'] = $as_of_date; |
|
| 1194 | 1192 | |
| 1195 | - if (Api\DateTime::to($old_event['start'],'Ymd') < Api\DateTime::to($as_of_date,'Ymd') || |
|
| 1193 | + if (Api\DateTime::to($old_event['start'], 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') || |
|
| 1196 | 1194 | // Adjust for requested date in the past |
| 1197 | - Api\DateTime::to($as_of_date,'ts') < time() |
|
| 1195 | + Api\DateTime::to($as_of_date, 'ts') < time() |
|
| 1198 | 1196 | ) |
| 1199 | 1197 | { |
| 1200 | 1198 | |
@@ -1214,17 +1212,17 @@ discard block |
||
| 1214 | 1212 | $rriter->next_no_exception(); |
| 1215 | 1213 | $occurrence = $rriter->current(); |
| 1216 | 1214 | } |
| 1217 | - while ($rriter->valid() && ( |
|
| 1215 | + while ($rriter->valid() && ( |
|
| 1218 | 1216 | Api\DateTime::to($occurrence, 'ts') <= time() || |
| 1219 | - Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date,'Ymd') |
|
| 1217 | + Api\DateTime::to($occurrence, 'Ymd') < Api\DateTime::to($as_of_date, 'Ymd') |
|
| 1220 | 1218 | ) && ($last = $occurrence)); |
| 1221 | 1219 | |
| 1222 | 1220 | |
| 1223 | 1221 | // Make sure as_of_date is still valid, may have to move forward |
| 1224 | - if(Api\DateTime::to($as_of_date,'ts') < Api\DateTime::to($last,'ts') || |
|
| 1222 | + if (Api\DateTime::to($as_of_date, 'ts') < Api\DateTime::to($last, 'ts') || |
|
| 1225 | 1223 | Api\DateTime::to($as_of_date, 'Ymd') == Api\DateTime::to($last, 'Ymd')) |
| 1226 | 1224 | { |
| 1227 | - $event['start'] = Api\DateTime::to($rriter->current(),'ts') + $offset; |
|
| 1225 | + $event['start'] = Api\DateTime::to($rriter->current(), 'ts') + $offset; |
|
| 1228 | 1226 | } |
| 1229 | 1227 | |
| 1230 | 1228 | //error_log(__METHOD__ ." Series should end at " . Api\DateTime::to($last) . " New series starts at " . Api\DateTime::to($event['start'])); |
@@ -1232,7 +1230,7 @@ discard block |
||
| 1232 | 1230 | { |
| 1233 | 1231 | $event['end'] = $event['start'] + $duration; |
| 1234 | 1232 | } |
| 1235 | - elseif($event['end'] < $event['start']) |
|
| 1233 | + elseif ($event['end'] < $event['start']) |
|
| 1236 | 1234 | { |
| 1237 | 1235 | $event['end'] = $old_event['end'] - $old_event['start'] + $event['start']; |
| 1238 | 1236 | } |
@@ -1241,7 +1239,7 @@ discard block |
||
| 1241 | 1239 | $event['participants'] = $old_event['participants']; |
| 1242 | 1240 | foreach ($old_event['recur_exception'] as $key => $exdate) |
| 1243 | 1241 | { |
| 1244 | - if ($exdate > Api\DateTime::to($last,'ts')) |
|
| 1242 | + if ($exdate > Api\DateTime::to($last, 'ts')) |
|
| 1245 | 1243 | { |
| 1246 | 1244 | //error_log("Moved exception on " . Api\DateTime::to($exdate)); |
| 1247 | 1245 | unset($old_event['recur_exception'][$key]); |
@@ -1255,18 +1253,18 @@ discard block |
||
| 1255 | 1253 | } |
| 1256 | 1254 | $last->setTime(0, 0, 0); |
| 1257 | 1255 | $old_event['recur_enddate'] = Api\DateTime::to($last, 'ts'); |
| 1258 | - if (!$this->bo->update($old_event,true,true,false,true,$dummy=null,$no_notifications)) |
|
| 1256 | + if (!$this->bo->update($old_event, true, true, false, true, $dummy = null, $no_notifications)) |
|
| 1259 | 1257 | { |
| 1260 | - $msg .= ($msg ? ', ' : '') .lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1261 | - lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'. |
|
| 1262 | - htmlspecialchars(Egw::link('/index.php',array( |
|
| 1258 | + $msg .= ($msg ? ', ' : '').lang('Error: the entry has been updated since you opened it for editing!').'<br />'. |
|
| 1259 | + lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'. |
|
| 1260 | + htmlspecialchars(Egw::link('/index.php', array( |
|
| 1263 | 1261 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
| 1264 | 1262 | 'cal_id' => $event['id'], |
| 1265 | - ))).'">','</a>'); |
|
| 1263 | + ))).'">', '</a>'); |
|
| 1266 | 1264 | $event = $orig_event; |
| 1267 | 1265 | } |
| 1268 | 1266 | } |
| 1269 | - $event['start'] = Api\DateTime::to($event['start'],'ts'); |
|
| 1267 | + $event['start'] = Api\DateTime::to($event['start'], 'ts'); |
|
| 1270 | 1268 | return $msg; |
| 1271 | 1269 | } |
| 1272 | 1270 | |
@@ -1277,11 +1275,11 @@ discard block |
||
| 1277 | 1275 | * @param boolean $added |
| 1278 | 1276 | * @return string javascript window.open command |
| 1279 | 1277 | */ |
| 1280 | - function ajax_custom_mail($event,$added,$asrequest=false) |
|
| 1278 | + function ajax_custom_mail($event, $added, $asrequest = false) |
|
| 1281 | 1279 | { |
| 1282 | 1280 | $to = array(); |
| 1283 | 1281 | |
| 1284 | - foreach($event['participants'] as $uid => $status) |
|
| 1282 | + foreach ($event['participants'] as $uid => $status) |
|
| 1285 | 1283 | { |
| 1286 | 1284 | //error_log(__METHOD__.__LINE__.' '.$uid.':'.array2string($status)); |
| 1287 | 1285 | if (empty($status)) continue; |
@@ -1290,32 +1288,32 @@ discard block |
||
| 1290 | 1288 | |
| 1291 | 1289 | if (isset($status['uid']) && is_numeric($status['uid']) && $GLOBALS['egw']->accounts->get_type($status['uid']) == 'u') |
| 1292 | 1290 | { |
| 1293 | - if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'],'account_email'))) continue; |
|
| 1291 | + if (!($email = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_email'))) continue; |
|
| 1294 | 1292 | |
| 1295 | 1293 | $toadd = $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_firstname').' '. |
| 1296 | 1294 | $GLOBALS['egw']->accounts->id2name($status['uid'], 'account_lastname').' <'.$email.'>'; |
| 1297 | 1295 | |
| 1298 | - if (!in_array($toadd,$to)) $to[] = $toadd; |
|
| 1296 | + if (!in_array($toadd, $to)) $to[] = $toadd; |
|
| 1299 | 1297 | } |
| 1300 | 1298 | elseif ($uid < 0) |
| 1301 | 1299 | { |
| 1302 | - foreach($GLOBALS['egw']->accounts->members($uid,true) as $uid) |
|
| 1300 | + foreach ($GLOBALS['egw']->accounts->members($uid, true) as $uid) |
|
| 1303 | 1301 | { |
| 1304 | - if (!($email = $GLOBALS['egw']->accounts->id2name($uid,'account_email'))) continue; |
|
| 1302 | + if (!($email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email'))) continue; |
|
| 1305 | 1303 | |
| 1306 | 1304 | $toadd = $GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '. |
| 1307 | 1305 | $GLOBALS['egw']->accounts->id2name($uid, 'account_lastname').' <'.$email.'>'; |
| 1308 | 1306 | |
| 1309 | 1307 | // dont add groupmembers if they already rejected the event, or are the current user |
| 1310 | - if (!in_array($toadd,$to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1308 | + if (!in_array($toadd, $to) && ($event['participants'][$uid] !== 'R' && $uid != $this->user)) $to[] = $toadd; |
|
| 1311 | 1309 | } |
| 1312 | 1310 | } |
| 1313 | - elseif(!empty($status['uid'])&& !is_numeric(substr($status['uid'],0,1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1311 | + elseif (!empty($status['uid']) && !is_numeric(substr($status['uid'], 0, 1)) && ($info = $this->bo->resource_info($status['uid']))) |
|
| 1314 | 1312 | { |
| 1315 | 1313 | $to[] = $info['email']; |
| 1316 | 1314 | //error_log(__METHOD__.__LINE__.array2string($to)); |
| 1317 | 1315 | } |
| 1318 | - elseif(!is_numeric(substr($uid,0,1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1316 | + elseif (!is_numeric(substr($uid, 0, 1)) && ($info = $this->bo->resource_info($uid))) |
|
| 1319 | 1317 | { |
| 1320 | 1318 | $to[] = $info['email']; |
| 1321 | 1319 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1324,7 +1322,7 @@ discard block |
||
| 1324 | 1322 | // prefer event description over standard notification text |
| 1325 | 1323 | if (empty($event['description'])) |
| 1326 | 1324 | { |
| 1327 | - list(,$body) = $this->bo->get_update_message($event,$added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1325 | + list(,$body) = $this->bo->get_update_message($event, $added ? MSG_ADDED : MSG_MODIFIED); // update-message is in TZ of the user |
|
| 1328 | 1326 | } |
| 1329 | 1327 | else |
| 1330 | 1328 | { |
@@ -1339,12 +1337,12 @@ discard block |
||
| 1339 | 1337 | $boical = new calendar_ical(); |
| 1340 | 1338 | // we need to pass $event[id] so iCal class reads event again, |
| 1341 | 1339 | // as event is in user TZ, but iCal class expects server TZ! |
| 1342 | - $ics = $boical->exportVCal(array($event['id']),'2.0','REQUEST',false); |
|
| 1340 | + $ics = $boical->exportVCal(array($event['id']), '2.0', 'REQUEST', false); |
|
| 1343 | 1341 | |
| 1344 | - $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'ics'); |
|
| 1345 | - if(($f = fopen($ics_file,'w'))) |
|
| 1342 | + $ics_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'ics'); |
|
| 1343 | + if (($f = fopen($ics_file, 'w'))) |
|
| 1346 | 1344 | { |
| 1347 | - fwrite($f,$ics); |
|
| 1345 | + fwrite($f, $ics); |
|
| 1348 | 1346 | fclose($f); |
| 1349 | 1347 | } |
| 1350 | 1348 | //error_log(__METHOD__.__LINE__.array2string($to)); |
@@ -1356,7 +1354,7 @@ discard block |
||
| 1356 | 1354 | 'preset[body]' => $body, |
| 1357 | 1355 | 'preset[name]' => 'event.ics', |
| 1358 | 1356 | 'preset[file]' => $ics_file, |
| 1359 | - 'preset[type]' => 'text/calendar'.($asrequest?'; method=REQUEST':''), |
|
| 1357 | + 'preset[type]' => 'text/calendar'.($asrequest ? '; method=REQUEST' : ''), |
|
| 1360 | 1358 | 'preset[size]' => filesize($ics_file), |
| 1361 | 1359 | ); |
| 1362 | 1360 | 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.'); |
@@ -1412,7 +1410,7 @@ discard block |
||
| 1412 | 1410 | * @param mixed $link_to_id ='' from or for the link-widget |
| 1413 | 1411 | * @param string $msg_type =null default automatic detect, if it contains "error" |
| 1414 | 1412 | */ |
| 1415 | - function edit($event=null,$preserv=null,$msg='',$link_to_id='',$msg_type=null) |
|
| 1413 | + function edit($event = null, $preserv = null, $msg = '', $link_to_id = '', $msg_type = null) |
|
| 1416 | 1414 | { |
| 1417 | 1415 | $sel_options = array( |
| 1418 | 1416 | 'recur_type' => &$this->bo->recur_types, |
@@ -1436,8 +1434,8 @@ discard block |
||
| 1436 | 1434 | 'no_popup' => isset($_GET['no_popup']), |
| 1437 | 1435 | 'template' => isset($_GET['template']) ? $_GET['template'] : (isset($_REQUEST['print']) ? 'calendar.print' : 'calendar.edit'), |
| 1438 | 1436 | ); |
| 1439 | - $cal_id = (int) $_GET['cal_id']; |
|
| 1440 | - if($_GET['action']) |
|
| 1437 | + $cal_id = (int)$_GET['cal_id']; |
|
| 1438 | + if ($_GET['action']) |
|
| 1441 | 1439 | { |
| 1442 | 1440 | $event = $this->bo->read($cal_id); |
| 1443 | 1441 | $event['action'] = $_GET['action']; |
@@ -1455,14 +1453,14 @@ discard block |
||
| 1455 | 1453 | { |
| 1456 | 1454 | //error_log(__METHOD__."() Error: importing the iCal: vfs file not found '$_GET[ical_vfs]'!"); |
| 1457 | 1455 | $msg = lang('Error: importing the iCal').': '.lang('VFS file not found').': '.$_GET['ical_vfs']; |
| 1458 | - $event =& $this->default_add_event(); |
|
| 1456 | + $event = & $this->default_add_event(); |
|
| 1459 | 1457 | } |
| 1460 | 1458 | if (!empty($_GET['ical_data']) && |
| 1461 | 1459 | !($_GET['ical'] = Link::get_data($_GET['ical_data']))) |
| 1462 | 1460 | { |
| 1463 | 1461 | //error_log(__METHOD__."() Error: importing the iCal: data not found '$_GET[ical_data]'!"); |
| 1464 | 1462 | $msg = lang('Error: importing the iCal').': '.lang('Data not found').': '.$_GET['ical_data']; |
| 1465 | - $event =& $this->default_add_event(); |
|
| 1463 | + $event = & $this->default_add_event(); |
|
| 1466 | 1464 | } |
| 1467 | 1465 | if (!empty($_GET['ical'])) |
| 1468 | 1466 | { |
@@ -1471,14 +1469,14 @@ discard block |
||
| 1471 | 1469 | { |
| 1472 | 1470 | error_log(__METHOD__."('$_GET[ical]') error parsing iCal!"); |
| 1473 | 1471 | $msg = lang('Error: importing the iCal'); |
| 1474 | - $event =& $this->default_add_event(); |
|
| 1472 | + $event = & $this->default_add_event(); |
|
| 1475 | 1473 | } |
| 1476 | 1474 | else |
| 1477 | 1475 | { |
| 1478 | 1476 | if (count($events) > 1) |
| 1479 | 1477 | { |
| 1480 | 1478 | $msg = lang('%1 events in iCal file, only first one imported and displayed!', count($events)); |
| 1481 | - $msg_type = 'notice'; // no not hide automatic |
|
| 1479 | + $msg_type = 'notice'; // no not hide automatic |
|
| 1482 | 1480 | } |
| 1483 | 1481 | // as icaltoegw returns timestamps in server-time, we have to convert them here to user-time |
| 1484 | 1482 | $this->bo->db2data($events, 'ts'); |
@@ -1491,7 +1489,7 @@ discard block |
||
| 1491 | 1489 | else |
| 1492 | 1490 | { |
| 1493 | 1491 | $event['participant_types'] = array(); |
| 1494 | - foreach($event['participants'] as $uid => $status) |
|
| 1492 | + foreach ($event['participants'] as $uid => $status) |
|
| 1495 | 1493 | { |
| 1496 | 1494 | $user_type = $user_id = null; |
| 1497 | 1495 | calendar_so::split_user($uid, $user_type, $user_id); |
@@ -1512,15 +1510,15 @@ discard block |
||
| 1512 | 1510 | } |
| 1513 | 1511 | else |
| 1514 | 1512 | { |
| 1515 | - $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n",null,true); |
|
| 1513 | + $GLOBALS['egw']->framework->render('<p class="message" align="center">'.lang('Permission denied')."</p>\n", null, true); |
|
| 1516 | 1514 | exit(); |
| 1517 | 1515 | } |
| 1518 | 1516 | } |
| 1519 | - $event =& $this->default_add_event(); |
|
| 1517 | + $event = & $this->default_add_event(); |
|
| 1520 | 1518 | } |
| 1521 | 1519 | else |
| 1522 | 1520 | { |
| 1523 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1521 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1524 | 1522 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1525 | 1523 | { |
| 1526 | 1524 | if (empty($event['whole_day'])) |
@@ -1533,10 +1531,10 @@ discard block |
||
| 1533 | 1531 | $date->setUser(); |
| 1534 | 1532 | } |
| 1535 | 1533 | $event = $this->bo->read($cal_id, $date, true); |
| 1536 | - $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1534 | + $preserv['actual_date'] = $event['start']; // remember the date clicked |
|
| 1537 | 1535 | if ($_GET['exception']) |
| 1538 | 1536 | { |
| 1539 | - $msg = $this->_create_exception($event,$preserv); |
|
| 1537 | + $msg = $this->_create_exception($event, $preserv); |
|
| 1540 | 1538 | } |
| 1541 | 1539 | else |
| 1542 | 1540 | { |
@@ -1545,9 +1543,9 @@ discard block |
||
| 1545 | 1543 | } |
| 1546 | 1544 | } |
| 1547 | 1545 | // set new start and end if given by $_GET |
| 1548 | - if(isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'],'ts'); } |
|
| 1549 | - if(isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'],'ts'); } |
|
| 1550 | - if(isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1546 | + if (isset($_GET['start'])) { $event['start'] = Api\DateTime::to($_GET['start'], 'ts'); } |
|
| 1547 | + if (isset($_GET['end'])) { $event['end'] = Api\DateTime::to($_GET['end'], 'ts'); } |
|
| 1548 | + if (isset($_GET['non_blocking'])) { $event['non_blocking'] = (bool)$_GET['non_blocking']; } |
|
| 1551 | 1549 | // check if the event is the whole day |
| 1552 | 1550 | $start = $this->bo->date2array($event['start']); |
| 1553 | 1551 | $end = $this->bo->date2array($event['end']); |
@@ -1557,30 +1555,30 @@ discard block |
||
| 1557 | 1555 | if (!$event['id'] && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id'])) |
| 1558 | 1556 | { |
| 1559 | 1557 | $link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']); |
| 1560 | - foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1558 | + foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app) |
|
| 1561 | 1559 | { |
| 1562 | 1560 | $link_id = $link_ids[$n]; |
| 1563 | - if(!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id)) // guard against XSS |
|
| 1561 | + if (!preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id)) // guard against XSS |
|
| 1564 | 1562 | { |
| 1565 | 1563 | continue; |
| 1566 | 1564 | } |
| 1567 | - if(!$n) |
|
| 1565 | + if (!$n) |
|
| 1568 | 1566 | { |
| 1569 | - $event['title'] = Link::title($link_app,$link_id); |
|
| 1567 | + $event['title'] = Link::title($link_app, $link_id); |
|
| 1570 | 1568 | // ask first linked app via "calendar_set" hook, for further data to set, incl. links |
| 1571 | - if (($set = Api\Hooks::single($event+array('location'=>'calendar_set','entry_id'=>$link_id),$link_app))) |
|
| 1569 | + if (($set = Api\Hooks::single($event + array('location'=>'calendar_set', 'entry_id'=>$link_id), $link_app))) |
|
| 1572 | 1570 | { |
| 1573 | - foreach((array)$set['link_app'] as $i => $l_app) |
|
| 1571 | + foreach ((array)$set['link_app'] as $i => $l_app) |
|
| 1574 | 1572 | { |
| 1575 | - if (($l_id=$set['link_id'][$i])) Link::link('calendar',$event['link_to']['to_id'],$l_app,$l_id); |
|
| 1573 | + if (($l_id = $set['link_id'][$i])) Link::link('calendar', $event['link_to']['to_id'], $l_app, $l_id); |
|
| 1576 | 1574 | } |
| 1577 | 1575 | unset($set['link_app']); |
| 1578 | 1576 | unset($set['link_id']); |
| 1579 | 1577 | |
| 1580 | - $event = array_merge($event,$set); |
|
| 1578 | + $event = array_merge($event, $set); |
|
| 1581 | 1579 | } |
| 1582 | 1580 | } |
| 1583 | - Link::link('calendar',$link_to_id,$link_app,$link_id); |
|
| 1581 | + Link::link('calendar', $link_to_id, $link_app, $link_id); |
|
| 1584 | 1582 | } |
| 1585 | 1583 | } |
| 1586 | 1584 | } |
@@ -1590,44 +1588,44 @@ discard block |
||
| 1590 | 1588 | { |
| 1591 | 1589 | $etpl->read($preserv['template'] = 'calendar.edit'); |
| 1592 | 1590 | } |
| 1593 | - $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT,$event); |
|
| 1591 | + $view = $preserv['view'] = $preserv['view'] || $event['id'] && !$this->bo->check_perms(Acl::EDIT, $event); |
|
| 1594 | 1592 | //echo "view=$view, event="; _debug_array($event); |
| 1595 | 1593 | // shared locking of entries to edit |
| 1596 | 1594 | if (!$view && ($locktime = $GLOBALS['egw_info']['server']['Lock_Time_Calender']) && $event['id']) |
| 1597 | 1595 | { |
| 1598 | - $lock_path = Vfs::app_entry_lock_path('calendar',$event['id']); |
|
| 1596 | + $lock_path = Vfs::app_entry_lock_path('calendar', $event['id']); |
|
| 1599 | 1597 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1600 | 1598 | |
| 1601 | 1599 | if (($preserv['lock_token'] = $event['lock_token'])) // already locked --> refresh the lock |
| 1602 | 1600 | { |
| 1603 | - Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',true,false); |
|
| 1601 | + Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', true, false); |
|
| 1604 | 1602 | } |
| 1605 | 1603 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] != $lock_owner) |
| 1606 | 1604 | { |
| 1607 | 1605 | $msg .= ' '.lang('This entry is currently opened by %1!', |
| 1608 | - (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'],7),'account_email')) ? |
|
| 1606 | + (($lock_uid = $GLOBALS['egw']->accounts->name2id(substr($lock['owner'], 7), 'account_email')) ? |
|
| 1609 | 1607 | Api\Accounts::username($lock_uid) : $lock['owner'])); |
| 1610 | 1608 | } |
| 1611 | - elseif($lock) |
|
| 1609 | + elseif ($lock) |
|
| 1612 | 1610 | { |
| 1613 | 1611 | $preserv['lock_token'] = $lock['token']; |
| 1614 | 1612 | } |
| 1615 | - elseif(Vfs::lock($lock_path,$preserv['lock_token'],$locktime,$lock_owner,$scope='shared',$type='write',false,false)) |
|
| 1613 | + elseif (Vfs::lock($lock_path, $preserv['lock_token'], $locktime, $lock_owner, $scope = 'shared', $type = 'write', false, false)) |
|
| 1616 | 1614 | { |
| 1617 | 1615 | //We handle AJAX_REQUEST in client-side for unlocking the locked entry, in case of closing the entry by X button or close button |
| 1618 | 1616 | } |
| 1619 | 1617 | else |
| 1620 | 1618 | { |
| 1621 | - $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1619 | + $msg .= ' '.lang("Can't aquire lock!"); // eg. an exclusive lock via CalDAV ... |
|
| 1622 | 1620 | $view = true; |
| 1623 | 1621 | } |
| 1624 | 1622 | } |
| 1625 | - $content = array_merge($event,array( |
|
| 1623 | + $content = array_merge($event, array( |
|
| 1626 | 1624 | 'link_to' => array( |
| 1627 | 1625 | 'to_id' => $link_to_id, |
| 1628 | 1626 | 'to_app' => 'calendar', |
| 1629 | 1627 | ), |
| 1630 | - 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1628 | + 'edit_single' => $preserv['edit_single'], // need to be in content too, as it is used in the template |
|
| 1631 | 1629 | 'tabs' => $preserv['tabs'], |
| 1632 | 1630 | 'view' => $view, |
| 1633 | 1631 | 'query_delete_exceptions' => (int)($event['recur_type'] && $event['recur_exception']), |
@@ -1639,11 +1637,11 @@ discard block |
||
| 1639 | 1637 | $row = 3; |
| 1640 | 1638 | $readonlys = $content['participants'] = $preserv['participants'] = array(); |
| 1641 | 1639 | // preserve some ui elements, if set eg. under error-conditions |
| 1642 | - foreach(array('quantity','resource','role') as $n) |
|
| 1640 | + foreach (array('quantity', 'resource', 'role') as $n) |
|
| 1643 | 1641 | { |
| 1644 | 1642 | if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n]; |
| 1645 | 1643 | } |
| 1646 | - foreach($event['participant_types'] as $type => $participants) |
|
| 1644 | + foreach ($event['participant_types'] as $type => $participants) |
|
| 1647 | 1645 | { |
| 1648 | 1646 | $name = 'accounts'; |
| 1649 | 1647 | if (isset($this->bo->resources[$type])) |
@@ -1652,17 +1650,17 @@ discard block |
||
| 1652 | 1650 | } |
| 1653 | 1651 | // sort participants (in there group/app) by title |
| 1654 | 1652 | uksort($participants, array($this, 'uid_title_cmp')); |
| 1655 | - foreach($participants as $id => $status) |
|
| 1653 | + foreach ($participants as $id => $status) |
|
| 1656 | 1654 | { |
| 1657 | 1655 | $uid = $type == 'u' ? $id : $type.$id; |
| 1658 | 1656 | $quantity = $role = null; |
| 1659 | - calendar_so::split_status($status,$quantity,$role); |
|
| 1657 | + calendar_so::split_status($status, $quantity, $role); |
|
| 1660 | 1658 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1661 | 1659 | 'app' => $name == 'accounts' ? ($GLOBALS['egw']->accounts->get_type($id) == 'g' ? 'Group' : 'User') : $name, |
| 1662 | 1660 | 'uid' => $uid, |
| 1663 | 1661 | 'status' => $status, |
| 1664 | 1662 | 'old_status' => $status, |
| 1665 | - 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1663 | + 'quantity' => $quantity > 1 || $uid[0] == 'r' ? $quantity : '', // only display quantity for resources or if > 1 |
|
| 1666 | 1664 | 'role' => $role, |
| 1667 | 1665 | ); |
| 1668 | 1666 | // replace iCal roles with a nicer label and remove regular REQ-PARTICIPANT |
@@ -1671,33 +1669,33 @@ discard block |
||
| 1671 | 1669 | $content['participants'][$row]['role_label'] = lang($this->bo->roles[$role]); |
| 1672 | 1670 | } |
| 1673 | 1671 | // allow third party apps to use categories for roles |
| 1674 | - elseif(substr($role,0,6) == 'X-CAT-') |
|
| 1672 | + elseif (substr($role, 0, 6) == 'X-CAT-') |
|
| 1675 | 1673 | { |
| 1676 | - $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role,6)); |
|
| 1674 | + $content['participants'][$row]['role_label'] = $GLOBALS['egw']->categories->id2name(substr($role, 6)); |
|
| 1677 | 1675 | } |
| 1678 | 1676 | else |
| 1679 | 1677 | { |
| 1680 | - $content['participants'][$row]['role_label'] = lang(str_replace('X-','',$role)); |
|
| 1678 | + $content['participants'][$row]['role_label'] = lang(str_replace('X-', '', $role)); |
|
| 1681 | 1679 | } |
| 1682 | - $content['participants'][$row]['delete_id'] = strpbrk($uid,'"\'<>') !== false ? md5($uid) : $uid; |
|
| 1680 | + $content['participants'][$row]['delete_id'] = strpbrk($uid, '"\'<>') !== false ? md5($uid) : $uid; |
|
| 1683 | 1681 | //echo "<p>$uid ($quantity): $role --> {$content['participants'][$row]['role']}</p>\n"; |
| 1684 | 1682 | |
| 1685 | - if (($no_status = !$this->bo->check_status_perms($uid,$event)) || $view) |
|
| 1683 | + if (($no_status = !$this->bo->check_status_perms($uid, $event)) || $view) |
|
| 1686 | 1684 | $readonlys['participants'][$row]['status'] = $no_status; |
| 1687 | - if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT,$event)) |
|
| 1685 | + if ($preserv['hide_delete'] || !$this->bo->check_perms(Acl::EDIT, $event)) |
|
| 1688 | 1686 | $readonlys['participants']['delete'][$uid] = true; |
| 1689 | 1687 | // todo: make the participants available as links with email as title |
| 1690 | 1688 | $content['participants'][$row++]['title'] = $this->get_title($uid); |
| 1691 | 1689 | // enumerate group-invitations, so people can accept/reject them |
| 1692 | 1690 | if ($name == 'accounts' && $GLOBALS['egw']->accounts->get_type($id) == 'g' && |
| 1693 | - ($members = $GLOBALS['egw']->accounts->members($id,true))) |
|
| 1691 | + ($members = $GLOBALS['egw']->accounts->members($id, true))) |
|
| 1694 | 1692 | { |
| 1695 | 1693 | $sel_options['status']['G'] = lang('Select one'); |
| 1696 | 1694 | // sort members by title |
| 1697 | 1695 | usort($members, array($this, 'uid_title_cmp')); |
| 1698 | - foreach($members as $member) |
|
| 1696 | + foreach ($members as $member) |
|
| 1699 | 1697 | { |
| 1700 | - if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ,0,$member)) |
|
| 1698 | + if (!isset($participants[$member]) && $this->bo->check_perms(Acl::READ, 0, $member)) |
|
| 1701 | 1699 | { |
| 1702 | 1700 | $preserv['participants'][$row] = $content['participants'][$row] = array( |
| 1703 | 1701 | 'app' => 'Group invitation', |
@@ -1706,7 +1704,7 @@ discard block |
||
| 1706 | 1704 | ); |
| 1707 | 1705 | $readonlys['participants'][$row]['quantity'] = $readonlys['participants']['delete'][$member] = true; |
| 1708 | 1706 | // read access is enough to invite participants, but you need edit rights to change status |
| 1709 | - $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT,0,$member); |
|
| 1707 | + $readonlys['participants'][$row]['status'] = !$this->bo->check_perms(Acl::EDIT, 0, $member); |
|
| 1710 | 1708 | $content['participants'][$row++]['title'] = Api\Accounts::username($member); |
| 1711 | 1709 | } |
| 1712 | 1710 | } |
@@ -1714,43 +1712,43 @@ discard block |
||
| 1714 | 1712 | } |
| 1715 | 1713 | // resouces / apps we shedule, atm. resources and addressbook |
| 1716 | 1714 | $content['participants']['cal_resources'] = ''; |
| 1717 | - foreach($this->bo->resources as $data) |
|
| 1715 | + foreach ($this->bo->resources as $data) |
|
| 1718 | 1716 | { |
| 1719 | - if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1717 | + if ($data['app'] == 'email') continue; // make no sense, as we cant search for email |
|
| 1720 | 1718 | $content['participants']['cal_resources'] .= ','.$data['app']; |
| 1721 | 1719 | } |
| 1722 | 1720 | } |
| 1723 | 1721 | $content['participants']['status_date'] = $preserv['actual_date']; |
| 1724 | - $preserved = array_merge($preserv,$content); |
|
| 1722 | + $preserved = array_merge($preserv, $content); |
|
| 1725 | 1723 | $event['new_alarm']['options'] = $content['new_alarm']['options']; |
| 1726 | 1724 | if ($event['alarm']) |
| 1727 | 1725 | { |
| 1728 | 1726 | // makes keys of the alarm-array starting with 1 |
| 1729 | 1727 | $content['alarm'] = array(false); |
| 1730 | - foreach(array_values($event['alarm']) as $id => $alarm) |
|
| 1728 | + foreach (array_values($event['alarm']) as $id => $alarm) |
|
| 1731 | 1729 | { |
| 1732 | - if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ,0,$alarm['owner'])) |
|
| 1730 | + if (!$alarm['all'] && !$this->bo->check_perms(Acl::READ, 0, $alarm['owner'])) |
|
| 1733 | 1731 | { |
| 1734 | - continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1732 | + continue; // no read rights to the calendar of the alarm-owner, dont show the alarm |
|
| 1735 | 1733 | } |
| 1736 | - $alarm['all'] = (int) $alarm['all']; |
|
| 1734 | + $alarm['all'] = (int)$alarm['all']; |
|
| 1737 | 1735 | $after = false; |
| 1738 | - if($alarm['offset'] < 0) |
|
| 1736 | + if ($alarm['offset'] < 0) |
|
| 1739 | 1737 | { |
| 1740 | 1738 | $after = true; |
| 1741 | 1739 | $alarm['offset'] = -1 * $alarm['offset']; |
| 1742 | 1740 | } |
| 1743 | - $days = (int) ($alarm['offset'] / DAY_s); |
|
| 1744 | - $hours = (int) (($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1745 | - $minutes = (int) (($alarm['offset'] % HOUR_s) / 60); |
|
| 1741 | + $days = (int)($alarm['offset'] / DAY_s); |
|
| 1742 | + $hours = (int)(($alarm['offset'] % DAY_s) / HOUR_s); |
|
| 1743 | + $minutes = (int)(($alarm['offset'] % HOUR_s) / 60); |
|
| 1746 | 1744 | $label = array(); |
| 1747 | 1745 | if ($days) $label[] = $days.' '.lang('days'); |
| 1748 | 1746 | if ($hours) $label[] = $hours.' '.lang('hours'); |
| 1749 | 1747 | if ($minutes) $label[] = $minutes.' '.lang('Minutes'); |
| 1750 | - $alarm['offset'] = implode(', ',$label) . ' ' . ($after ? lang('after') : lang('before')); |
|
| 1748 | + $alarm['offset'] = implode(', ', $label).' '.($after ? lang('after') : lang('before')); |
|
| 1751 | 1749 | $content['alarm'][] = $alarm; |
| 1752 | 1750 | |
| 1753 | - $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT,$alarm['all'] ? $event : 0,$alarm['owner']); |
|
| 1751 | + $readonlys['alarm[delete_alarm]['.$alarm['id'].']'] = !$this->bo->check_perms(Acl::EDIT, $alarm['all'] ? $event : 0, $alarm['owner']); |
|
| 1754 | 1752 | } |
| 1755 | 1753 | if (count($content['alarm']) == 1) |
| 1756 | 1754 | { |
@@ -1765,20 +1763,20 @@ discard block |
||
| 1765 | 1763 | |
| 1766 | 1764 | if ($view) |
| 1767 | 1765 | { |
| 1768 | - $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1766 | + $readonlys['__ALL__'] = true; // making everything readonly, but widgets set explicitly to false |
|
| 1769 | 1767 | $readonlys['button[cancel]'] = $readonlys['action'] = |
| 1770 | 1768 | $readonlys['before_after'] = $readonlys['button[add_alarm]'] = $readonlys['new_alarm[owner]'] = |
| 1771 | 1769 | $readonlys['new_alarm[options]'] = $readonlys['new_alarm[date]'] = false; |
| 1772 | 1770 | |
| 1773 | 1771 | $content['participants']['no_add'] = true; |
| 1774 | 1772 | |
| 1775 | - if(!$event['whole_day']) |
|
| 1773 | + if (!$event['whole_day']) |
|
| 1776 | 1774 | { |
| 1777 | 1775 | $etpl->setElementAttribute('whole_day', 'disabled', true); |
| 1778 | 1776 | } |
| 1779 | 1777 | |
| 1780 | 1778 | // respect category permissions |
| 1781 | - if(!empty($event['category'])) |
|
| 1779 | + if (!empty($event['category'])) |
|
| 1782 | 1780 | { |
| 1783 | 1781 | $content['category'] = $this->categories->check_list(Acl::READ, $event['category']); |
| 1784 | 1782 | } |
@@ -1789,7 +1787,7 @@ discard block |
||
| 1789 | 1787 | |
| 1790 | 1788 | if ($event['recur_type'] != MCAL_RECUR_NONE) |
| 1791 | 1789 | { |
| 1792 | - $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1790 | + $readonlys['recur_exception'] = !count($content['recur_exception']); // otherwise we get a delete button |
|
| 1793 | 1791 | //$onclick =& $etpl->get_cell_attribute('button[delete]','onclick'); |
| 1794 | 1792 | //$onclick = str_replace('Delete this event','Delete this series of recuring events',$onclick); |
| 1795 | 1793 | } |
@@ -1799,9 +1797,9 @@ discard block |
||
| 1799 | 1797 | $readonlys['recur_interval'] = $readonlys['recur_data'] = true; |
| 1800 | 1798 | } |
| 1801 | 1799 | } |
| 1802 | - if($content['category'] && !is_array($content['category'])) |
|
| 1800 | + if ($content['category'] && !is_array($content['category'])) |
|
| 1803 | 1801 | { |
| 1804 | - $content['category'] = explode(',',$event['category']); |
|
| 1802 | + $content['category'] = explode(',', $event['category']); |
|
| 1805 | 1803 | } |
| 1806 | 1804 | // disabling the custom fields tab, if there are none |
| 1807 | 1805 | $readonlys['tabs'] = array( |
@@ -1818,13 +1816,13 @@ discard block |
||
| 1818 | 1816 | { |
| 1819 | 1817 | $readonlys['action'] = true; |
| 1820 | 1818 | } |
| 1821 | - 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']))) |
|
| 1819 | + 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']))) |
|
| 1822 | 1820 | { |
| 1823 | 1821 | $content['exception_label'] = $this->bo->long_date(max($preserved['actual_date'], $event['start'])); |
| 1824 | 1822 | } |
| 1825 | - $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE,$event); |
|
| 1823 | + $readonlys['button[delete]'] = !$event['id'] || $preserved['hide_delete'] || !$this->bo->check_perms(Acl::DELETE, $event); |
|
| 1826 | 1824 | |
| 1827 | - 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 |
|
| 1825 | + 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 |
|
| 1828 | 1826 | { |
| 1829 | 1827 | $sel_options['owner'][0] = lang('All participants'); |
| 1830 | 1828 | } |
@@ -1832,26 +1830,26 @@ discard block |
||
| 1832 | 1830 | { |
| 1833 | 1831 | $sel_options['owner'][$this->user] = $this->bo->participant_name($this->user); |
| 1834 | 1832 | } |
| 1835 | - foreach((array) $event['participant_types']['u'] as $uid => $status) |
|
| 1833 | + foreach ((array)$event['participant_types']['u'] as $uid => $status) |
|
| 1836 | 1834 | { |
| 1837 | - if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT,0,$uid)) |
|
| 1835 | + if ($uid != $this->user && $status != 'R' && $this->bo->check_perms(Acl::EDIT, 0, $uid)) |
|
| 1838 | 1836 | { |
| 1839 | 1837 | $sel_options['owner'][$uid] = $this->bo->participant_name($uid); |
| 1840 | 1838 | } |
| 1841 | 1839 | } |
| 1842 | - $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1840 | + $content['no_add_alarm'] = !count($sel_options['owner']); // no rights to set any alarm |
|
| 1843 | 1841 | if (!$event['id']) |
| 1844 | 1842 | { |
| 1845 | - $etpl->set_cell_attribute('button[new_alarm]','type','checkbox'); |
|
| 1843 | + $etpl->set_cell_attribute('button[new_alarm]', 'type', 'checkbox'); |
|
| 1846 | 1844 | } |
| 1847 | 1845 | if ($preserved['no_popup']) |
| 1848 | 1846 | { |
| 1849 | 1847 | // If not a popup, load the normal calendar interface on cancel |
| 1850 | - $etpl->set_cell_attribute('button[cancel]','onclick','app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')'); |
|
| 1848 | + $etpl->set_cell_attribute('button[cancel]', 'onclick', 'app.calendar.linkHandler(\'index.php?menuaction=calendar.calendar_uiviews.index\')'); |
|
| 1851 | 1849 | } |
| 1852 | 1850 | |
| 1853 | 1851 | // Allow admins to restore deleted events |
| 1854 | - if($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted'] ) |
|
| 1852 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history'] && $event['deleted']) |
|
| 1855 | 1853 | { |
| 1856 | 1854 | $content['deleted'] = $preserved['deleted'] = null; |
| 1857 | 1855 | $etpl->set_cell_attribute('button[save]', 'label', 'Recover'); |
@@ -1863,7 +1861,7 @@ discard block |
||
| 1863 | 1861 | // Setup history tab |
| 1864 | 1862 | $this->setup_history($content, $sel_options); |
| 1865 | 1863 | |
| 1866 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' |
|
| 1864 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - ' |
|
| 1867 | 1865 | . (!$event['id'] ? lang('Add') |
| 1868 | 1866 | : ($view ? ($content['edit_single'] ? lang('View exception') : ($content['recur_type'] ? lang('View series') : lang('View'))) |
| 1869 | 1867 | : ($content['edit_single'] ? lang('Create exception') : ($content['recur_type'] ? lang('Edit series') : lang('Edit'))))); |
@@ -1873,15 +1871,15 @@ discard block |
||
| 1873 | 1871 | if (!empty($preserved['lock_token'])) $content['lock_token'] = $preserved['lock_token']; |
| 1874 | 1872 | |
| 1875 | 1873 | // non_interactive==true from $_GET calls immediate save action without displaying the edit form |
| 1876 | - if(isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1874 | + if (isset($_GET['non_interactive']) && (bool)$_GET['non_interactive'] === true) |
|
| 1877 | 1875 | { |
| 1878 | - unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1876 | + unset($_GET['non_interactive']); // prevent process_exec <--> edit loops |
|
| 1879 | 1877 | $content['button']['save'] = true; |
| 1880 | - $this->process_edit(array_merge($content,$preserved)); |
|
| 1878 | + $this->process_edit(array_merge($content, $preserved)); |
|
| 1881 | 1879 | } |
| 1882 | 1880 | else |
| 1883 | 1881 | { |
| 1884 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,$sel_options,$readonlys,$preserved,$preserved['no_popup'] ? 0 : 2); |
|
| 1882 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, $sel_options, $readonlys, $preserved, $preserved['no_popup'] ? 0 : 2); |
|
| 1885 | 1883 | } |
| 1886 | 1884 | } |
| 1887 | 1885 | |
@@ -1891,14 +1889,14 @@ discard block |
||
| 1891 | 1889 | * @param int $id |
| 1892 | 1890 | * @param string $token |
| 1893 | 1891 | */ |
| 1894 | - function ajax_unlock($id,$token) |
|
| 1892 | + function ajax_unlock($id, $token) |
|
| 1895 | 1893 | { |
| 1896 | - $lock_path = Vfs::app_entry_lock_path('calendar',$id); |
|
| 1894 | + $lock_path = Vfs::app_entry_lock_path('calendar', $id); |
|
| 1897 | 1895 | $lock_owner = 'mailto:'.$GLOBALS['egw_info']['user']['account_email']; |
| 1898 | 1896 | |
| 1899 | 1897 | if (($lock = Vfs::checkLock($lock_path)) && $lock['owner'] == $lock_owner || $lock['token'] == $token) |
| 1900 | 1898 | { |
| 1901 | - Vfs::unlock($lock_path,$token,false); |
|
| 1899 | + Vfs::unlock($lock_path, $token, false); |
|
| 1902 | 1900 | } |
| 1903 | 1901 | } |
| 1904 | 1902 | |
@@ -1910,17 +1908,17 @@ discard block |
||
| 1910 | 1908 | * are called by new mail-app; and we intend to use the stuff passed on by session |
| 1911 | 1909 | * @param string $msg = null |
| 1912 | 1910 | */ |
| 1913 | - function meeting(array $event=null, $msg=null) |
|
| 1911 | + function meeting(array $event = null, $msg = null) |
|
| 1914 | 1912 | { |
| 1915 | 1913 | $user = $GLOBALS['egw_info']['user']['account_id']; |
| 1916 | 1914 | $readonlys['button[apply]'] = true; |
| 1917 | - $_usesession=!is_array($event); |
|
| 1915 | + $_usesession = !is_array($event); |
|
| 1918 | 1916 | //special usage if $event is array('event'=>null,'msg'=>'','useSession'=>true) we |
| 1919 | 1917 | //are called by new mail-app; and we intend to use the stuff passed on by session |
| 1920 | - if ($event == array('event'=>null,'msg'=>'','useSession'=>true)) |
|
| 1918 | + if ($event == array('event'=>null, 'msg'=>'', 'useSession'=>true)) |
|
| 1921 | 1919 | { |
| 1922 | - $event=null; // set to null |
|
| 1923 | - $_usesession=true; // trigger session read |
|
| 1920 | + $event = null; // set to null |
|
| 1921 | + $_usesession = true; // trigger session read |
|
| 1924 | 1922 | } |
| 1925 | 1923 | if (!is_array($event)) |
| 1926 | 1924 | { |
@@ -1949,7 +1947,7 @@ discard block |
||
| 1949 | 1947 | |
| 1950 | 1948 | if (($existing_event = $this->bo->read($event['uid'])) && !$existing_event['deleted']) |
| 1951 | 1949 | { |
| 1952 | - switch(strtolower($ical_method)) |
|
| 1950 | + switch (strtolower($ical_method)) |
|
| 1953 | 1951 | { |
| 1954 | 1952 | case 'reply': |
| 1955 | 1953 | // first participant is the one replying (our iCal parser adds owner first!) |
@@ -2003,19 +2001,19 @@ discard block |
||
| 2003 | 2001 | } |
| 2004 | 2002 | else // event not in calendar |
| 2005 | 2003 | { |
| 2006 | - $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 2004 | + $readonlys['button[cancel]'] = true; // no way to remove a canceled event not in calendar |
|
| 2007 | 2005 | } |
| 2008 | 2006 | $event['participant_types'] = array(); |
| 2009 | - foreach($event['participants'] as $uid => $status) |
|
| 2007 | + foreach ($event['participants'] as $uid => $status) |
|
| 2010 | 2008 | { |
| 2011 | 2009 | $user_type = $user_id = null; |
| 2012 | 2010 | calendar_so::split_user($uid, $user_type, $user_id); |
| 2013 | 2011 | $event['participants'][$uid] = $event['participant_types'][$user_type][$user_id] = |
| 2014 | - $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 2012 | + $status && $status !== 'X' ? $status : 'U'; // X --> no status given --> U = unknown |
|
| 2015 | 2013 | } |
| 2016 | 2014 | //error_log(__METHOD__."(...) parsed as ".array2string($event)); |
| 2017 | 2015 | $event['recure'] = $this->bo->recure2string($event); |
| 2018 | - $event['all_participants'] = implode(",\n",$this->bo->participants($event, true)); |
|
| 2016 | + $event['all_participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 2019 | 2017 | |
| 2020 | 2018 | // ignore events in the past (for recurring events check enddate!) |
| 2021 | 2019 | if ($this->bo->date2ts($event['start']) < $this->bo->now_su && |
@@ -2035,23 +2033,23 @@ discard block |
||
| 2035 | 2033 | // clear notification errors |
| 2036 | 2034 | notifications::errors(true); |
| 2037 | 2035 | |
| 2038 | - switch($button) |
|
| 2036 | + switch ($button) |
|
| 2039 | 2037 | { |
| 2040 | 2038 | case 'reject': |
| 2041 | 2039 | if (!$event['id']) |
| 2042 | 2040 | { |
| 2043 | 2041 | // send reply to organizer |
| 2044 | - $this->bo->send_update(MSG_REJECTED,array('e'.$event['organizer'] => 'DCHAIR'),$event); |
|
| 2045 | - break; // no need to store rejected event |
|
| 2042 | + $this->bo->send_update(MSG_REJECTED, array('e'.$event['organizer'] => 'DCHAIR'), $event); |
|
| 2043 | + break; // no need to store rejected event |
|
| 2046 | 2044 | } |
| 2047 | 2045 | // fall-through |
| 2048 | 2046 | case 'accept': |
| 2049 | 2047 | case 'tentativ': |
| 2050 | - $status = strtoupper($button[0]); // A, R or T |
|
| 2048 | + $status = strtoupper($button[0]); // A, R or T |
|
| 2051 | 2049 | if (!$event['id']) |
| 2052 | 2050 | { |
| 2053 | 2051 | // if organizer is a EGroupware user, but we have no rights to organizers calendar |
| 2054 | - if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD,0,$event['owner'])) |
|
| 2052 | + if (isset($event['owner']) && !$this->bo->check_perms(Acl::ADD, 0, $event['owner'])) |
|
| 2055 | 2053 | { |
| 2056 | 2054 | // --> make organize a participant with role chair and current user the owner |
| 2057 | 2055 | $event['participant_types']['u'] = $event['participants'][$event['owner']] = |
@@ -2059,7 +2057,7 @@ discard block |
||
| 2059 | 2057 | $event['owner'] = $this->user; |
| 2060 | 2058 | } |
| 2061 | 2059 | // store event without notifications! |
| 2062 | - if (($event['id'] = $this->bo->update($event, $ignore_conflicts=true, true, false, true, $msg, true))) |
|
| 2060 | + if (($event['id'] = $this->bo->update($event, $ignore_conflicts = true, true, false, true, $msg, true))) |
|
| 2063 | 2061 | { |
| 2064 | 2062 | $msg[] = lang('Event saved'); |
| 2065 | 2063 | } |
@@ -2097,7 +2095,7 @@ discard block |
||
| 2097 | 2095 | Framework::message(implode("\n", (array)$msg)); |
| 2098 | 2096 | $readonlys['button[edit]'] = !$event['id']; |
| 2099 | 2097 | $event['ics_method'] = $readonlys['ics_method'] = strtolower($ical_method); |
| 2100 | - switch(strtolower($ical_method)) |
|
| 2098 | + switch (strtolower($ical_method)) |
|
| 2101 | 2099 | { |
| 2102 | 2100 | case 'reply': |
| 2103 | 2101 | $event['ics_method_label'] = lang('Reply to meeting request'); |
@@ -2121,37 +2119,37 @@ discard block |
||
| 2121 | 2119 | * @param array $conflicts array with conflicting events, the events are not garantied to be readable by the user! |
| 2122 | 2120 | * @param array $preserv data to preserv |
| 2123 | 2121 | */ |
| 2124 | - function conflicts($event,$conflicts,$preserv) |
|
| 2122 | + function conflicts($event, $conflicts, $preserv) |
|
| 2125 | 2123 | { |
| 2126 | 2124 | $etpl = new Etemplate('calendar.conflicts'); |
| 2127 | 2125 | $allConflicts = array(); |
| 2128 | 2126 | |
| 2129 | - foreach($conflicts as $k => $conflict) |
|
| 2127 | + foreach ($conflicts as $k => $conflict) |
|
| 2130 | 2128 | { |
| 2131 | - $is_readable = $this->bo->check_perms(Acl::READ,$conflict); |
|
| 2129 | + $is_readable = $this->bo->check_perms(Acl::READ, $conflict); |
|
| 2132 | 2130 | |
| 2133 | 2131 | $conflicts[$k] += array( |
| 2134 | 2132 | 'icon_participants' => $is_readable ? (count($conflict['participants']) > 1 ? 'users' : 'single') : 'private', |
| 2135 | - 'tooltip_participants' => $is_readable ? implode(', ',$this->bo->participants($conflict)) : '', |
|
| 2136 | - 'time' => $this->bo->long_date($conflict['start'],$conflict['end'],true), |
|
| 2137 | - 'conflicting_participants' => implode(",\n",$this->bo->participants(array( |
|
| 2138 | - 'participants' => array_intersect_key((array)$conflict['participants'],$event['participants']), |
|
| 2139 | - ),true,true)), // show group invitations too |
|
| 2133 | + 'tooltip_participants' => $is_readable ? implode(', ', $this->bo->participants($conflict)) : '', |
|
| 2134 | + 'time' => $this->bo->long_date($conflict['start'], $conflict['end'], true), |
|
| 2135 | + 'conflicting_participants' => implode(",\n", $this->bo->participants(array( |
|
| 2136 | + 'participants' => array_intersect_key((array)$conflict['participants'], $event['participants']), |
|
| 2137 | + ), true, true)), // show group invitations too |
|
| 2140 | 2138 | 'icon_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? 'recur' : '', |
| 2141 | 2139 | 'text_recur' => $conflict['recur_type'] != MCAL_RECUR_NONE ? lang('Recurring event') : ' ', |
| 2142 | 2140 | ); |
| 2143 | - $allConflicts += array_intersect_key((array)$conflict['participants'],$event['participants']); |
|
| 2141 | + $allConflicts += array_intersect_key((array)$conflict['participants'], $event['participants']); |
|
| 2144 | 2142 | } |
| 2145 | 2143 | $content = $event + array( |
| 2146 | - 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2144 | + 'conflicts' => array_values($conflicts), // conflicts have id-start as key |
|
| 2147 | 2145 | ); |
| 2148 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('Scheduling conflict'); |
|
| 2146 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('Scheduling conflict'); |
|
| 2149 | 2147 | $resources_config = Api\Config::read('resources'); |
| 2150 | 2148 | $readonlys = array(); |
| 2151 | 2149 | |
| 2152 | 2150 | foreach (array_keys($allConflicts) as $pId) |
| 2153 | 2151 | { |
| 2154 | - if(substr($pId,0,1) == 'r' && $resources_config ) // resources Allow ignore conflicts |
|
| 2152 | + if (substr($pId, 0, 1) == 'r' && $resources_config) // resources Allow ignore conflicts |
|
| 2155 | 2153 | { |
| 2156 | 2154 | |
| 2157 | 2155 | switch ($resources_config['ignoreconflicts']) |
@@ -2171,7 +2169,7 @@ discard block |
||
| 2171 | 2169 | } |
| 2172 | 2170 | } |
| 2173 | 2171 | } |
| 2174 | - $etpl->exec('calendar.calendar_uiforms.process_edit',$content,array(),$readonlys,array_merge($event,$preserv),$preserv['no_popup'] ? 0 : 2); |
|
| 2172 | + $etpl->exec('calendar.calendar_uiforms.process_edit', $content, array(), $readonlys, array_merge($event, $preserv), $preserv['no_popup'] ? 0 : 2); |
|
| 2175 | 2173 | } |
| 2176 | 2174 | |
| 2177 | 2175 | /** |
@@ -2189,7 +2187,7 @@ discard block |
||
| 2189 | 2187 | //$response->addAlert(__METHOD__.'('.array2string($edit_content).')'); |
| 2190 | 2188 | |
| 2191 | 2189 | // convert start/end date-time values to timestamps |
| 2192 | - foreach(array('start', 'end') as $name) |
|
| 2190 | + foreach (array('start', 'end') as $name) |
|
| 2193 | 2191 | { |
| 2194 | 2192 | if (!empty($edit_content[$name])) |
| 2195 | 2193 | { |
@@ -2219,7 +2217,7 @@ discard block |
||
| 2219 | 2217 | 'recur_type' => $edit_content['recur_type'], |
| 2220 | 2218 | 'participants' => array(), |
| 2221 | 2219 | ); |
| 2222 | - foreach($edit_content['participants'] as $key => $data) |
|
| 2220 | + foreach ($edit_content['participants'] as $key => $data) |
|
| 2223 | 2221 | { |
| 2224 | 2222 | if (is_numeric($key) && !$edit_content['participants']['delete'][$data['uid']] && |
| 2225 | 2223 | !$edit_content['participants']['delete'][md5($data['uid'])]) |
@@ -2234,21 +2232,21 @@ discard block |
||
| 2234 | 2232 | // default search parameters |
| 2235 | 2233 | $content['start_time'] = $edit_content['whole_day'] ? 0 : $this->cal_prefs['workdaystarts']; |
| 2236 | 2234 | $content['end_time'] = $this->cal_prefs['workdayends']; |
| 2237 | - if ($this->cal_prefs['workdayends']*HOUR_s < $this->cal_prefs['workdaystarts']*HOUR_s+$content['duration']) |
|
| 2235 | + if ($this->cal_prefs['workdayends'] * HOUR_s < $this->cal_prefs['workdaystarts'] * HOUR_s + $content['duration']) |
|
| 2238 | 2236 | { |
| 2239 | - $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2237 | + $content['end_time'] = 0; // no end-time limit, as duration would never fit |
|
| 2240 | 2238 | } |
| 2241 | 2239 | $content['weekdays'] = MCAL_M_WEEKDAYS; |
| 2242 | 2240 | |
| 2243 | 2241 | $content['search_window'] = 7 * DAY_s; |
| 2244 | 2242 | |
| 2245 | 2243 | // store content in session |
| 2246 | - Api\Cache::setSession('calendar','freetimesearch_args_'.(int)$edit_content['id'],$content); |
|
| 2244 | + Api\Cache::setSession('calendar', 'freetimesearch_args_'.(int)$edit_content['id'], $content); |
|
| 2247 | 2245 | |
| 2248 | 2246 | //menuaction=calendar.calendar_uiforms.freetimesearch&values2url('start,end,duration,participants,recur_type,whole_day'),ft_search,700,500 |
| 2249 | - $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='. $edit_content['id']; |
|
| 2247 | + $link = 'calendar.calendar_uiforms.freetimesearch&cal_id='.$edit_content['id']; |
|
| 2250 | 2248 | |
| 2251 | - $response->call('app.calendar.freetime_search_popup',$link); |
|
| 2249 | + $response->call('app.calendar.freetime_search_popup', $link); |
|
| 2252 | 2250 | |
| 2253 | 2251 | //$response->addScriptCall('egw_openWindowCentered2',$link,'ft_search',700,500); |
| 2254 | 2252 | |
@@ -2271,26 +2269,26 @@ discard block |
||
| 2271 | 2269 | { |
| 2272 | 2270 | $etpl = new Etemplate('calendar.freetimesearch'); |
| 2273 | 2271 | $sel_options['search_window'] = array( |
| 2274 | - 7*DAY_s => lang('one week'), |
|
| 2275 | - 14*DAY_s => lang('two weeks'), |
|
| 2276 | - 31*DAY_s => lang('one month'), |
|
| 2277 | - 92*DAY_s => lang('three month'), |
|
| 2278 | - 365*DAY_s => lang('one year'), |
|
| 2272 | + 7 * DAY_s => lang('one week'), |
|
| 2273 | + 14 * DAY_s => lang('two weeks'), |
|
| 2274 | + 31 * DAY_s => lang('one month'), |
|
| 2275 | + 92 * DAY_s => lang('three month'), |
|
| 2276 | + 365 * DAY_s => lang('one year'), |
|
| 2279 | 2277 | ); |
| 2280 | 2278 | if (!is_array($content)) |
| 2281 | 2279 | { |
| 2282 | 2280 | // get content from session (and delete it immediatly) |
| 2283 | - $content = Api\Cache::getSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2284 | - Api\Cache::unsetSession('calendar','freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2281 | + $content = Api\Cache::getSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2282 | + Api\Cache::unsetSession('calendar', 'freetimesearch_args_'.(int)$_GET['cal_id']); |
|
| 2285 | 2283 | //Since the start_time and end_time from calendar_user_preferences are numbers, not timestamp, in order to show them on date-timeonly |
| 2286 | 2284 | //widget we need to convert them from numbers to timestamps, only for the first time when we have template without content |
| 2287 | 2285 | $sTime = $content['start_time']; |
| 2288 | 2286 | $eTime = $content['end_time']; |
| 2289 | - $content['start_time'] = strtotime(((strlen($content['start_time'])<2)?("0".$content['start_time']):$content['start_time']).":00"); |
|
| 2290 | - $content['end_time'] = strtotime(((strlen($content['end_time'])<2)?("0".$content['end_time']):$content['end_time']).":00"); |
|
| 2287 | + $content['start_time'] = strtotime(((strlen($content['start_time']) < 2) ? ("0".$content['start_time']) : $content['start_time']).":00"); |
|
| 2288 | + $content['end_time'] = strtotime(((strlen($content['end_time']) < 2) ? ("0".$content['end_time']) : $content['end_time']).":00"); |
|
| 2291 | 2289 | |
| 2292 | 2290 | // pick a searchwindow fitting the duration (search for a 10 day slot in a one week window never succeeds) |
| 2293 | - foreach(array_keys($sel_options['search_window']) as $window) |
|
| 2291 | + foreach (array_keys($sel_options['search_window']) as $window) |
|
| 2294 | 2292 | { |
| 2295 | 2293 | if ($window > $content['duration']) |
| 2296 | 2294 | { |
@@ -2317,19 +2315,19 @@ discard block |
||
| 2317 | 2315 | { |
| 2318 | 2316 | $content['msg'] .= lang('Only the initial date of that recuring event is checked!'); |
| 2319 | 2317 | } |
| 2320 | - $content['freetime'] = $this->freetime($content['participants'],$content['start'],$content['start']+$content['search_window'],$content['duration'],$content['cal_id']); |
|
| 2321 | - $content['freetime'] = $this->split_freetime_daywise($content['freetime'],$content['duration'],(is_array($content['weekdays'])?$weekds:$content['weekdays']),$sTime,$eTime,$sel_options); |
|
| 2318 | + $content['freetime'] = $this->freetime($content['participants'], $content['start'], $content['start'] + $content['search_window'], $content['duration'], $content['cal_id']); |
|
| 2319 | + $content['freetime'] = $this->split_freetime_daywise($content['freetime'], $content['duration'], (is_array($content['weekdays']) ? $weekds : $content['weekdays']), $sTime, $eTime, $sel_options); |
|
| 2322 | 2320 | |
| 2323 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('freetime search'); |
|
| 2321 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('freetime search'); |
|
| 2324 | 2322 | |
| 2325 | 2323 | $sel_options['duration'] = $this->durations; |
| 2326 | 2324 | if ($content['duration'] && isset($sel_options['duration'][$content['duration']])) $content['end'] = ''; |
| 2327 | 2325 | |
| 2328 | - $etpl->exec('calendar.calendar_uiforms.freetimesearch',$content,$sel_options,NULL,array( |
|
| 2326 | + $etpl->exec('calendar.calendar_uiforms.freetimesearch', $content, $sel_options, NULL, array( |
|
| 2329 | 2327 | 'participants' => $content['participants'], |
| 2330 | 2328 | 'cal_id' => $content['cal_id'], |
| 2331 | 2329 | 'recur_type' => $content['recur_type'], |
| 2332 | - ),2); |
|
| 2330 | + ), 2); |
|
| 2333 | 2331 | } |
| 2334 | 2332 | |
| 2335 | 2333 | /** |
@@ -2342,15 +2340,15 @@ discard block |
||
| 2342 | 2340 | * @param int $cal_id own id for existing events, to exclude them from being busy-time, default 0 |
| 2343 | 2341 | * @return array of free time-slots: array with start and end values |
| 2344 | 2342 | */ |
| 2345 | - function freetime($participants,$start,$end,$duration=1,$cal_id=0) |
|
| 2343 | + function freetime($participants, $start, $end, $duration = 1, $cal_id = 0) |
|
| 2346 | 2344 | { |
| 2347 | - 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); |
|
| 2345 | + 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); |
|
| 2348 | 2346 | |
| 2349 | 2347 | $busy = $this->bo->search(array( |
| 2350 | 2348 | 'start' => $start, |
| 2351 | 2349 | 'end' => $end, |
| 2352 | 2350 | 'users' => $participants, |
| 2353 | - 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2351 | + 'ignore_acl' => true, // otherwise we get only events readable by the user |
|
| 2354 | 2352 | )); |
| 2355 | 2353 | $busy[] = array( // add end-of-search-date as event, to cope with empty search and get freetime til that date |
| 2356 | 2354 | 'start' => $end, |
@@ -2359,15 +2357,15 @@ discard block |
||
| 2359 | 2357 | $ft_start = $start; |
| 2360 | 2358 | $freetime = array(); |
| 2361 | 2359 | $n = 0; |
| 2362 | - foreach($busy as $event) |
|
| 2360 | + foreach ($busy as $event) |
|
| 2363 | 2361 | { |
| 2364 | - if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2362 | + if ((int)$cal_id && $event['id'] == (int)$cal_id) continue; // ignore our own event |
|
| 2365 | 2363 | |
| 2366 | 2364 | if ($event['non_blocking']) continue; // ignore non_blocking events |
| 2367 | 2365 | |
| 2368 | 2366 | // check if from all wanted participants at least one has a not rejected status in found event |
| 2369 | 2367 | $non_rejected_found = false; |
| 2370 | - foreach($participants as $uid) |
|
| 2368 | + foreach ($participants as $uid) |
|
| 2371 | 2369 | { |
| 2372 | 2370 | if ($event['participants'][$uid] == 'R') continue; |
| 2373 | 2371 | |
@@ -2383,10 +2381,10 @@ discard block |
||
| 2383 | 2381 | |
| 2384 | 2382 | if ($this->debug) |
| 2385 | 2383 | { |
| 2386 | - echo "<p>ft_start=".date('D d.m.Y H:i',$ft_start)."<br>\n"; |
|
| 2384 | + echo "<p>ft_start=".date('D d.m.Y H:i', $ft_start)."<br>\n"; |
|
| 2387 | 2385 | echo "event[title]=$event[title]<br>\n"; |
| 2388 | - echo "event[start]=".date('D d.m.Y H:i',$event['start'])."<br>\n"; |
|
| 2389 | - echo "event[end]=".date('D d.m.Y H:i',$event['end'])."<br>\n"; |
|
| 2386 | + echo "event[start]=".date('D d.m.Y H:i', $event['start'])."<br>\n"; |
|
| 2387 | + echo "event[end]=".date('D d.m.Y H:i', $event['end'])."<br>\n"; |
|
| 2390 | 2388 | } |
| 2391 | 2389 | // $events ends before our actual position ==> ignore it |
| 2392 | 2390 | if ($event['end'] < $ft_start) |
@@ -2410,11 +2408,11 @@ discard block |
||
| 2410 | 2408 | 'start' => $ft_start, |
| 2411 | 2409 | 'end' => $ft_end, |
| 2412 | 2410 | ); |
| 2413 | - 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"; |
|
| 2411 | + 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"; |
|
| 2414 | 2412 | } |
| 2415 | 2413 | $ft_start = $event['end']; |
| 2416 | 2414 | } |
| 2417 | - 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); |
|
| 2415 | + 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); |
|
| 2418 | 2416 | |
| 2419 | 2417 | return $freetime; |
| 2420 | 2418 | } |
@@ -2434,46 +2432,46 @@ discard block |
||
| 2434 | 2432 | */ |
| 2435 | 2433 | function split_freetime_daywise($freetime, $duration, $weekdays, $_start_time, $_end_time, &$sel_options) |
| 2436 | 2434 | { |
| 2437 | - 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); |
|
| 2435 | + 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); |
|
| 2438 | 2436 | |
| 2439 | 2437 | $freetime_daywise = array(); |
| 2440 | 2438 | if (!is_array($sel_options)) $sel_options = array(); |
| 2441 | 2439 | $time_format = $this->common_prefs['timeformat'] == 12 ? 'h:i a' : 'H:i'; |
| 2442 | 2440 | |
| 2443 | - $start_time = (int) $_start_time; // ignore leading zeros |
|
| 2444 | - $end_time = (int) $_end_time; |
|
| 2441 | + $start_time = (int)$_start_time; // ignore leading zeros |
|
| 2442 | + $end_time = (int)$_end_time; |
|
| 2445 | 2443 | |
| 2446 | 2444 | // ignore the end_time, if duration would never fit |
| 2447 | - if (($end_time - $start_time)*HOUR_s < $duration) |
|
| 2445 | + if (($end_time - $start_time) * HOUR_s < $duration) |
|
| 2448 | 2446 | { |
| 2449 | 2447 | $end_time = 0; |
| 2450 | - 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); |
|
| 2448 | + 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); |
|
| 2451 | 2449 | } |
| 2452 | 2450 | $n = 0; |
| 2453 | - foreach($freetime as $ft) |
|
| 2451 | + foreach ($freetime as $ft) |
|
| 2454 | 2452 | { |
| 2455 | 2453 | $adaybegin = $this->bo->date2array($ft['start']); |
| 2456 | 2454 | $adaybegin['hour'] = $adaybegin['minute'] = $adaybegin['second'] = 0; |
| 2457 | 2455 | unset($adaybegin['raw']); |
| 2458 | 2456 | $daybegin = $this->bo->date2ts($adaybegin); |
| 2459 | 2457 | |
| 2460 | - for($t = $daybegin; $t < $ft['end']; $t += DAY_s,$daybegin += DAY_s) |
|
| 2458 | + for ($t = $daybegin; $t < $ft['end']; $t += DAY_s, $daybegin += DAY_s) |
|
| 2461 | 2459 | { |
| 2462 | - $dow = date('w',$daybegin+DAY_s/2); // 0=Sun, .., 6=Sat |
|
| 2463 | - $mcal_dow = pow(2,$dow); |
|
| 2464 | - if (!($weekdays & $mcal_dow)) |
|
| 2460 | + $dow = date('w', $daybegin + DAY_s / 2); // 0=Sun, .., 6=Sat |
|
| 2461 | + $mcal_dow = pow(2, $dow); |
|
| 2462 | + if (!($weekdays&$mcal_dow)) |
|
| 2465 | 2463 | { |
| 2466 | 2464 | //echo "wrong day of week $dow<br>\n"; |
| 2467 | - continue; // wrong day of week |
|
| 2465 | + continue; // wrong day of week |
|
| 2468 | 2466 | } |
| 2469 | 2467 | $start = $t < $ft['start'] ? $ft['start'] : $t; |
| 2470 | 2468 | |
| 2471 | - if ($start-$daybegin < $start_time*HOUR_s) // start earlier then start_time |
|
| 2469 | + if ($start - $daybegin < $start_time * HOUR_s) // start earlier then start_time |
|
| 2472 | 2470 | { |
| 2473 | - $start = $daybegin + $start_time*HOUR_s; |
|
| 2471 | + $start = $daybegin + $start_time * HOUR_s; |
|
| 2474 | 2472 | } |
| 2475 | 2473 | // if end_time given use it, else the original slot's end |
| 2476 | - $end = $end_time ? $daybegin + $end_time*HOUR_s : $ft['end']; |
|
| 2474 | + $end = $end_time ? $daybegin + $end_time * HOUR_s : $ft['end']; |
|
| 2477 | 2475 | if ($end > $ft['end']) $end = $ft['end']; |
| 2478 | 2476 | |
| 2479 | 2477 | // slot to small for duration |
@@ -2487,11 +2485,11 @@ discard block |
||
| 2487 | 2485 | 'end' => $end, |
| 2488 | 2486 | ); |
| 2489 | 2487 | $times = array(); |
| 2490 | - for ($s = $start; $s+$duration <= $end && $s < $daybegin+DAY_s; $s += 60*$this->cal_prefs['interval']) |
|
| 2488 | + for ($s = $start; $s + $duration <= $end && $s < $daybegin + DAY_s; $s += 60 * $this->cal_prefs['interval']) |
|
| 2491 | 2489 | { |
| 2492 | 2490 | $e = $s + $duration; |
| 2493 | - $end_date = $e-$daybegin > DAY_s ? lang(date('l',$e)).' '.date($this->common_prefs['dateformat'],$e).' ' : ''; |
|
| 2494 | - $times[$s] = date($time_format,$s).' - '.$end_date.date($time_format,$e); |
|
| 2491 | + $end_date = $e - $daybegin > DAY_s ? lang(date('l', $e)).' '.date($this->common_prefs['dateformat'], $e).' ' : ''; |
|
| 2492 | + $times[$s] = date($time_format, $s).' - '.$end_date.date($time_format, $e); |
|
| 2495 | 2493 | } |
| 2496 | 2494 | $sel_options[$n.'start'] = $times; |
| 2497 | 2495 | } |
@@ -2506,13 +2504,13 @@ discard block |
||
| 2506 | 2504 | * @param boolean $return_error should an error-msg be returned or a regular page with it generated (default) |
| 2507 | 2505 | * @return string error-msg if $return_error |
| 2508 | 2506 | */ |
| 2509 | - function export($content=0,$return_error=false) |
|
| 2507 | + function export($content = 0, $return_error = false) |
|
| 2510 | 2508 | { |
| 2511 | 2509 | $boical = new calendar_ical(); |
| 2512 | 2510 | #error_log(__METHOD__.print_r($content,true)); |
| 2513 | 2511 | if (is_numeric($cal_id = $content ? $content : $_REQUEST['cal_id'])) |
| 2514 | 2512 | { |
| 2515 | - if (!($ical =& $boical->exportVCal(array($cal_id),'2.0','PUBLISH',false))) |
|
| 2513 | + if (!($ical = & $boical->exportVCal(array($cal_id), '2.0', 'PUBLISH', false))) |
|
| 2516 | 2514 | { |
| 2517 | 2515 | $msg = lang('Permission denied'); |
| 2518 | 2516 | |
@@ -2520,20 +2518,20 @@ discard block |
||
| 2520 | 2518 | } |
| 2521 | 2519 | else |
| 2522 | 2520 | { |
| 2523 | - html::content_header('event.ics','text/calendar',bytes($ical)); |
|
| 2521 | + html::content_header('event.ics', 'text/calendar', bytes($ical)); |
|
| 2524 | 2522 | echo $ical; |
| 2525 | 2523 | common::egw_exit(); |
| 2526 | 2524 | } |
| 2527 | 2525 | } |
| 2528 | 2526 | if (is_array($content)) |
| 2529 | 2527 | { |
| 2530 | - $events =& $this->bo->search(array( |
|
| 2528 | + $events = & $this->bo->search(array( |
|
| 2531 | 2529 | 'start' => $content['start'], |
| 2532 | 2530 | 'end' => $content['end'], |
| 2533 | 2531 | 'enum_recuring' => false, |
| 2534 | 2532 | 'daywise' => false, |
| 2535 | 2533 | 'owner' => $this->owner, |
| 2536 | - 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2534 | + 'date_format' => 'server', // timestamp in server time for boical class |
|
| 2537 | 2535 | )); |
| 2538 | 2536 | if (!$events) |
| 2539 | 2537 | { |
@@ -2541,8 +2539,8 @@ discard block |
||
| 2541 | 2539 | } |
| 2542 | 2540 | else |
| 2543 | 2541 | { |
| 2544 | - $ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); |
|
| 2545 | - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); |
|
| 2542 | + $ical = & $boical->exportVCal($events, '2.0', 'PUBLISH', false); |
|
| 2543 | + html::content_header($content['file'] ? $content['file'] : 'event.ics', 'text/calendar', bytes($ical)); |
|
| 2546 | 2544 | echo $ical; |
| 2547 | 2545 | common::egw_exit(); |
| 2548 | 2546 | } |
@@ -2558,9 +2556,9 @@ discard block |
||
| 2558 | 2556 | } |
| 2559 | 2557 | $content['msg'] = $msg; |
| 2560 | 2558 | |
| 2561 | - $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar') . ' - ' . lang('iCal Export'); |
|
| 2559 | + $GLOBALS['egw_info']['flags']['app_header'] = lang('calendar').' - '.lang('iCal Export'); |
|
| 2562 | 2560 | $etpl = new etemplate_new('calendar.export'); |
| 2563 | - $etpl->exec('calendar.calendar_uiforms.export',$content); |
|
| 2561 | + $etpl->exec('calendar.calendar_uiforms.export', $content); |
|
| 2564 | 2562 | } |
| 2565 | 2563 | |
| 2566 | 2564 | /** |
@@ -2568,7 +2566,7 @@ discard block |
||
| 2568 | 2566 | * |
| 2569 | 2567 | * @param array $_content |
| 2570 | 2568 | */ |
| 2571 | - function cat_acl(array $_content=null) |
|
| 2569 | + function cat_acl(array $_content = null) |
|
| 2572 | 2570 | { |
| 2573 | 2571 | if (!$GLOBALS['egw_info']['user']['apps']['admin']) |
| 2574 | 2572 | { |
@@ -2580,15 +2578,15 @@ discard block |
||
| 2580 | 2578 | unset($_content['button']); |
| 2581 | 2579 | if ($button != 'cancel') // store changed Acl |
| 2582 | 2580 | { |
| 2583 | - foreach($_content as $data) |
|
| 2581 | + foreach ($_content as $data) |
|
| 2584 | 2582 | { |
| 2585 | 2583 | if (!($cat_id = $data['cat_id'])) continue; |
| 2586 | - foreach(array_merge((array)$data['add'],(array)$data['status'],array_keys((array)$data['old'])) as $account_id) |
|
| 2584 | + foreach (array_merge((array)$data['add'], (array)$data['status'], array_keys((array)$data['old'])) as $account_id) |
|
| 2587 | 2585 | { |
| 2588 | 2586 | $rights = 0; |
| 2589 | - if (in_array($account_id,(array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2590 | - if (in_array($account_id,(array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2591 | - if ($account_id) $this->bo->set_cat_rights($cat_id,$account_id,$rights); |
|
| 2587 | + if (in_array($account_id, (array)$data['add'])) $rights |= calendar_boupdate::CAT_ACL_ADD; |
|
| 2588 | + if (in_array($account_id, (array)$data['status'])) $rights |= calendar_boupdate::CAT_ACL_STATUS; |
|
| 2589 | + if ($account_id) $this->bo->set_cat_rights($cat_id, $account_id, $rights); |
|
| 2592 | 2590 | } |
| 2593 | 2591 | } |
| 2594 | 2592 | } |
@@ -2600,20 +2598,20 @@ discard block |
||
| 2600 | 2598 | ), 'admin'); |
| 2601 | 2599 | } |
| 2602 | 2600 | } |
| 2603 | - $content= $preserv = array(); |
|
| 2601 | + $content = $preserv = array(); |
|
| 2604 | 2602 | $n = 1; |
| 2605 | - foreach($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2603 | + foreach ($this->bo->get_cat_rights() as $Lcat_id => $data) |
|
| 2606 | 2604 | { |
| 2607 | - $cat_id = substr($Lcat_id,1); |
|
| 2605 | + $cat_id = substr($Lcat_id, 1); |
|
| 2608 | 2606 | $row = array( |
| 2609 | 2607 | 'cat_id' => $cat_id, |
| 2610 | 2608 | 'add' => array(), |
| 2611 | 2609 | 'status' => array(), |
| 2612 | 2610 | ); |
| 2613 | - foreach($data as $account_id => $rights) |
|
| 2611 | + foreach ($data as $account_id => $rights) |
|
| 2614 | 2612 | { |
| 2615 | - if ($rights & calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2616 | - if ($rights & calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2613 | + if ($rights&calendar_boupdate::CAT_ACL_ADD) $row['add'][] = $account_id; |
|
| 2614 | + if ($rights&calendar_boupdate::CAT_ACL_STATUS) $row['status'][] = $account_id; |
|
| 2617 | 2615 | } |
| 2618 | 2616 | $content[$n] = $row; |
| 2619 | 2617 | $preserv[$n] = array( |
@@ -2629,7 +2627,7 @@ discard block |
||
| 2629 | 2627 | $GLOBALS['egw_info']['flags']['app_header'] = lang('Calendar').' - '.lang('Category ACL'); |
| 2630 | 2628 | $tmp = new Etemplate('calendar.cat_acl'); |
| 2631 | 2629 | $GLOBALS['egw_info']['flags']['nonavbar'] = 1; |
| 2632 | - $tmp->exec('calendar.calendar_uiforms.cat_acl',$content,null,$readonlys,$preserv); |
|
| 2630 | + $tmp->exec('calendar.calendar_uiforms.cat_acl', $content, null, $readonlys, $preserv); |
|
| 2633 | 2631 | } |
| 2634 | 2632 | |
| 2635 | 2633 | /** |
@@ -2679,18 +2677,18 @@ discard block |
||
| 2679 | 2677 | |
| 2680 | 2678 | |
| 2681 | 2679 | // Get participants for only this one, if it's recurring. The date is on the end of the value. |
| 2682 | - if($content['recur_type'] || $content['recurrence']) |
|
| 2680 | + if ($content['recur_type'] || $content['recurrence']) |
|
| 2683 | 2681 | { |
| 2684 | 2682 | $content['history']['filter'] = array( |
| 2685 | 2683 | '(history_status NOT LIKE \'participants%\' OR (history_status LIKE \'participants%\' AND ( |
| 2686 | - history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\' OR |
|
| 2687 | - history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR . $content['recurrence'] . '\')))' |
|
| 2684 | + history_new_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\' OR |
|
| 2685 | + history_old_value LIKE \'%' . Api\Storage\Tracking::ONE2N_SEPERATOR.$content['recurrence'].'\')))' |
|
| 2688 | 2686 | ); |
| 2689 | 2687 | } |
| 2690 | 2688 | |
| 2691 | 2689 | // Translate labels |
| 2692 | 2690 | $tracking = new calendar_tracking(); |
| 2693 | - foreach($tracking->field2label as $field => $label) |
|
| 2691 | + foreach ($tracking->field2label as $field => $label) |
|
| 2694 | 2692 | { |
| 2695 | 2693 | $sel_options[$status][$field] = lang($label); |
| 2696 | 2694 | } |
@@ -2709,44 +2707,44 @@ discard block |
||
| 2709 | 2707 | * which particular instance was dragged |
| 2710 | 2708 | * @return string XML response if no error occurs |
| 2711 | 2709 | */ |
| 2712 | - function ajax_moveEvent($_eventId,$calendarOwner,$targetDateTime,$targetOwner,$durationT=null,$seriesInstance=null) |
|
| 2710 | + function ajax_moveEvent($_eventId, $calendarOwner, $targetDateTime, $targetOwner, $durationT = null, $seriesInstance = null) |
|
| 2713 | 2711 | { |
| 2714 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 2712 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 2715 | 2713 | $ignore_conflicts = false; |
| 2716 | 2714 | |
| 2717 | 2715 | // we do not allow dragging into another users calendar ATM |
| 2718 | - if($targetOwner < 0) |
|
| 2716 | + if ($targetOwner < 0) |
|
| 2719 | 2717 | { |
| 2720 | 2718 | $targetOwner = array($targetOwner); |
| 2721 | 2719 | } |
| 2722 | - if($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2720 | + if ($targetOwner == 0 || is_array($targetOwner) && $targetOwner[0] == 0) |
|
| 2723 | 2721 | { |
| 2724 | 2722 | $targetOwner = $calendarOwner; |
| 2725 | 2723 | } |
| 2726 | 2724 | // But you may be viewing multiple users, or a group calendar and |
| 2727 | 2725 | // dragging your event - dragging across calendars does not change owner |
| 2728 | - if(is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2726 | + if (is_array($targetOwner) && !in_array($calendarOwner, $targetOwner)) |
|
| 2729 | 2727 | { |
| 2730 | 2728 | $return = true; |
| 2731 | - foreach($targetOwner as $owner) |
|
| 2729 | + foreach ($targetOwner as $owner) |
|
| 2732 | 2730 | { |
| 2733 | - if($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner,true))) |
|
| 2731 | + if ($owner < 0 && in_array($calendarOwner, $GLOBALS['egw']->accounts->members($owner, true))) |
|
| 2734 | 2732 | { |
| 2735 | 2733 | $return = false; |
| 2736 | 2734 | break; |
| 2737 | 2735 | } |
| 2738 | - else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId,0,'ts',$date)) |
|
| 2736 | + else if ($owner > 0 && $this->bo->check_perms(Acl::EDIT, $eventId, 0, 'ts', $date)) |
|
| 2739 | 2737 | { |
| 2740 | 2738 | $return = false; |
| 2741 | 2739 | break; |
| 2742 | 2740 | } |
| 2743 | 2741 | } |
| 2744 | - if($return) return; |
|
| 2742 | + if ($return) return; |
|
| 2745 | 2743 | } |
| 2746 | - $old_event=$event=$this->bo->read($eventId); |
|
| 2744 | + $old_event = $event = $this->bo->read($eventId); |
|
| 2747 | 2745 | if (!$durationT) |
| 2748 | 2746 | { |
| 2749 | - $duration=$event['end']-$event['start']; |
|
| 2747 | + $duration = $event['end'] - $event['start']; |
|
| 2750 | 2748 | } |
| 2751 | 2749 | // Drag a normal event to whole day non-blocking |
| 2752 | 2750 | else if ($durationT == 'whole_day') |
@@ -2754,7 +2752,7 @@ discard block |
||
| 2754 | 2752 | $event['whole_day'] = true; |
| 2755 | 2753 | $event['non_blocking'] = true; |
| 2756 | 2754 | // Make duration whole days, less 1 second |
| 2757 | - $duration = round(($event['end']-$event['start'])/DAY_s) * DAY_s - 1; |
|
| 2755 | + $duration = round(($event['end'] - $event['start']) / DAY_s) * DAY_s - 1; |
|
| 2758 | 2756 | } |
| 2759 | 2757 | else |
| 2760 | 2758 | { |
@@ -2767,19 +2765,19 @@ discard block |
||
| 2767 | 2765 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2768 | 2766 | if (!empty($event['whole_day'])) |
| 2769 | 2767 | { |
| 2770 | - $d =& $this->bo->so->startOfDay($d); |
|
| 2768 | + $d = & $this->bo->so->startOfDay($d); |
|
| 2771 | 2769 | $d->setUser(); |
| 2772 | 2770 | } |
| 2773 | 2771 | $event = $this->bo->read($eventId, $d, true); |
| 2774 | 2772 | |
| 2775 | 2773 | // For DnD, create an exception if they gave the date |
| 2776 | 2774 | $preserv = null; |
| 2777 | - $this->_create_exception($event,$preserv); |
|
| 2775 | + $this->_create_exception($event, $preserv); |
|
| 2778 | 2776 | unset($event['id']); |
| 2779 | 2777 | $links = $event['link_to']['to_id']; |
| 2780 | 2778 | |
| 2781 | 2779 | $messages = null; |
| 2782 | - $conflicts = $this->bo->update($event,false,true,false,true,$messages); |
|
| 2780 | + $conflicts = $this->bo->update($event, false, true, false, true, $messages); |
|
| 2783 | 2781 | if (!is_array($conflicts) && $conflicts) |
| 2784 | 2782 | { |
| 2785 | 2783 | // now we need to add the original start as recur-execption to the series |
@@ -2787,28 +2785,28 @@ discard block |
||
| 2787 | 2785 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 2788 | 2786 | // check if we need to move the alarms, because they are next on that exception |
| 2789 | 2787 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 2790 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2791 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2792 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 2788 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 2789 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 2790 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 2793 | 2791 | |
| 2794 | 2792 | // Sending null will trigger a removal of the original for that date |
| 2795 | 2793 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 2796 | 2794 | |
| 2797 | 2795 | unset($recur_event); |
| 2798 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2796 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 2799 | 2797 | unset($preserv['edit_single']); |
| 2800 | 2798 | } |
| 2801 | 2799 | } |
| 2802 | 2800 | |
| 2803 | 2801 | $d = new Api\DateTime($targetDateTime, Api\DateTime::$user_timezone); |
| 2804 | 2802 | $event['start'] = $d->format('ts'); |
| 2805 | - $event['end'] = $event['start']+$duration; |
|
| 2803 | + $event['end'] = $event['start'] + $duration; |
|
| 2806 | 2804 | |
| 2807 | 2805 | if ($event['recur_type'] != MCAL_RECUR_NONE && !$date && $seriesInstance) |
| 2808 | 2806 | { |
| 2809 | 2807 | // calculate offset against clicked recurrance, |
| 2810 | 2808 | // depending on which is smaller |
| 2811 | - $offset = Api\DateTime::to($targetDateTime,'ts') - Api\DateTime::to($seriesInstance,'ts'); |
|
| 2809 | + $offset = Api\DateTime::to($targetDateTime, 'ts') - Api\DateTime::to($seriesInstance, 'ts'); |
|
| 2812 | 2810 | $event['start'] = $old_event['start'] + $offset; |
| 2813 | 2811 | $event['duration'] = $duration; |
| 2814 | 2812 | |
@@ -2819,31 +2817,31 @@ discard block |
||
| 2819 | 2817 | // Can't handle conflict. Just ignore it. |
| 2820 | 2818 | $ignore_conflicts = true; |
| 2821 | 2819 | } |
| 2822 | - if(!$event['recur_type']) |
|
| 2820 | + if (!$event['recur_type']) |
|
| 2823 | 2821 | { |
| 2824 | 2822 | $this->bo->check_move_alarms($event, $old_event); |
| 2825 | 2823 | } |
| 2826 | 2824 | |
| 2827 | 2825 | // Drag a whole day to a time |
| 2828 | - if($durationT && $durationT != 'whole_day') |
|
| 2826 | + if ($durationT && $durationT != 'whole_day') |
|
| 2829 | 2827 | { |
| 2830 | 2828 | $event['whole_day'] = ($duration == DAY_s); |
| 2831 | 2829 | $event['non_blocking'] = false; |
| 2832 | 2830 | // If there's a conflict, it won't save the change and the conflict popup will be blank |
| 2833 | 2831 | // so save the change now, and then let the conflict check happen. |
| 2834 | 2832 | $message = null; |
| 2835 | - $this->bo->update($event,true, true, false, true, $message,true); |
|
| 2833 | + $this->bo->update($event, true, true, false, true, $message, true); |
|
| 2836 | 2834 | |
| 2837 | 2835 | // Whole day non blocking with DAY_s would add a day |
| 2838 | - if($duration==DAY_s) $duration=0; |
|
| 2836 | + if ($duration == DAY_s) $duration = 0; |
|
| 2839 | 2837 | } |
| 2840 | 2838 | |
| 2841 | 2839 | $status_reset_to_unknown = false; |
| 2842 | 2840 | $sameday = (date('Ymd', $old_event['start']) == date('Ymd', $event['start'])); |
| 2843 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 2841 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 2844 | 2842 | { |
| 2845 | 2843 | $q = $r = null; |
| 2846 | - calendar_so::split_status($status,$q,$r); |
|
| 2844 | + calendar_so::split_status($status, $q, $r); |
|
| 2847 | 2845 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user && $status != 'U') |
| 2848 | 2846 | { |
| 2849 | 2847 | $preferences = new Api\Preferences($uid); |
@@ -2856,29 +2854,29 @@ discard block |
||
| 2856 | 2854 | if ($sameday) break; |
| 2857 | 2855 | default: |
| 2858 | 2856 | $status_reset_to_unknown = true; |
| 2859 | - $event['participants'][$uid] = calendar_so::combine_status('U',$q,$r); |
|
| 2857 | + $event['participants'][$uid] = calendar_so::combine_status('U', $q, $r); |
|
| 2860 | 2858 | // todo: report reset status to user |
| 2861 | 2859 | } |
| 2862 | 2860 | } |
| 2863 | 2861 | } |
| 2864 | 2862 | |
| 2865 | 2863 | $message = false; |
| 2866 | - $conflicts=$this->bo->update($event,$ignore_conflicts, true, false, true, $message); |
|
| 2864 | + $conflicts = $this->bo->update($event, $ignore_conflicts, true, false, true, $message); |
|
| 2867 | 2865 | |
| 2868 | 2866 | // Save links |
| 2869 | - if($links) |
|
| 2867 | + if ($links) |
|
| 2870 | 2868 | { |
| 2871 | 2869 | Link::link('calendar', $event['id'], $links); |
| 2872 | 2870 | } |
| 2873 | 2871 | |
| 2874 | - $this->update_client($event['id'],$d); |
|
| 2872 | + $this->update_client($event['id'], $d); |
|
| 2875 | 2873 | $response = Api\Json\Response::get(); |
| 2876 | - if(!is_array($conflicts) && $conflicts) |
|
| 2874 | + if (!is_array($conflicts) && $conflicts) |
|
| 2877 | 2875 | { |
| 2878 | - if(is_int($conflicts)) |
|
| 2876 | + if (is_int($conflicts)) |
|
| 2879 | 2877 | { |
| 2880 | 2878 | $event['id'] = $conflicts; |
| 2881 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 2879 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 2882 | 2880 | } |
| 2883 | 2881 | } |
| 2884 | 2882 | else if ($conflicts) |
@@ -2891,21 +2889,21 @@ discard block |
||
| 2891 | 2889 | .'&end='.$event['end'] |
| 2892 | 2890 | .'&non_interactive=true' |
| 2893 | 2891 | .'&cancel_needs_refresh=true', |
| 2894 | - '',750,410); |
|
| 2892 | + '', 750, 410); |
|
| 2895 | 2893 | } |
| 2896 | 2894 | else if ($message) |
| 2897 | 2895 | { |
| 2898 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 2896 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 2899 | 2897 | } |
| 2900 | - if($event['id'] != $eventId ) $this->update_client($_eventId); |
|
| 2898 | + if ($event['id'] != $eventId) $this->update_client($_eventId); |
|
| 2901 | 2899 | if ($status_reset_to_unknown) |
| 2902 | 2900 | { |
| 2903 | - foreach((array)$event['participants'] as $uid => $status) |
|
| 2901 | + foreach ((array)$event['participants'] as $uid => $status) |
|
| 2904 | 2902 | { |
| 2905 | 2903 | if ($uid[0] != 'c' && $uid[0] != 'e' && $uid != $this->bo->user) |
| 2906 | 2904 | { |
| 2907 | - calendar_so::split_status($status,$q,$r); |
|
| 2908 | - $status = calendar_so::combine_status('U',$q,$r); |
|
| 2905 | + calendar_so::split_status($status, $q, $r); |
|
| 2906 | + $status = calendar_so::combine_status('U', $q, $r); |
|
| 2909 | 2907 | $this->bo->set_status($event['id'], $uid, $status, 0, true); |
| 2910 | 2908 | } |
| 2911 | 2909 | } |
@@ -2922,7 +2920,7 @@ discard block |
||
| 2922 | 2920 | { |
| 2923 | 2921 | list($eventId, $date) = explode(':', $_eventId); |
| 2924 | 2922 | $event = $this->bo->read($eventId); |
| 2925 | - if($date) |
|
| 2923 | + if ($date) |
|
| 2926 | 2924 | { |
| 2927 | 2925 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 2928 | 2926 | } |
@@ -2932,29 +2930,29 @@ discard block |
||
| 2932 | 2930 | { |
| 2933 | 2931 | if (!empty($event['whole_day'])) |
| 2934 | 2932 | { |
| 2935 | - $d =& $this->bo->so->startOfDay($date); |
|
| 2933 | + $d = & $this->bo->so->startOfDay($date); |
|
| 2936 | 2934 | $d->setUser(); |
| 2937 | 2935 | } |
| 2938 | 2936 | $event = $this->bo->read($eventId, $d, true); |
| 2939 | 2937 | $date = $d->format('ts'); |
| 2940 | 2938 | } |
| 2941 | - if($event['participants'][$uid]) |
|
| 2939 | + if ($event['participants'][$uid]) |
|
| 2942 | 2940 | { |
| 2943 | 2941 | $q = $r = null; |
| 2944 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 2945 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 2946 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 2942 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 2943 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 2944 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 2947 | 2945 | } |
| 2948 | 2946 | else |
| 2949 | 2947 | { |
| 2950 | 2948 | // Group membership |
| 2951 | - foreach($event['participants'] as $id => $status) |
|
| 2949 | + foreach ($event['participants'] as $id => $status) |
|
| 2952 | 2950 | { |
| 2953 | - if($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid,$GLOBALS['egw']->accounts->members($id,true))) |
|
| 2951 | + if ($GLOBALS['egw']->accounts->get_type($id) == 'g' && in_array($uid, $GLOBALS['egw']->accounts->members($id, true))) |
|
| 2954 | 2952 | { |
| 2955 | - calendar_so::split_status($event['participants'][$uid],$q,$r); |
|
| 2956 | - $event['participants'][$uid] = $status = calendar_so::combine_status($status,$q,$r); |
|
| 2957 | - $this->bo->set_status($event['id'],$uid,$status,$date,true); |
|
| 2953 | + calendar_so::split_status($event['participants'][$uid], $q, $r); |
|
| 2954 | + $event['participants'][$uid] = $status = calendar_so::combine_status($status, $q, $r); |
|
| 2955 | + $this->bo->set_status($event['id'], $uid, $status, $date, true); |
|
| 2958 | 2956 | break; |
| 2959 | 2957 | } |
| 2960 | 2958 | } |
@@ -2962,7 +2960,7 @@ discard block |
||
| 2962 | 2960 | |
| 2963 | 2961 | // Directly update stored data. If event is still visible, it will |
| 2964 | 2962 | // be notified & update itself. |
| 2965 | - $this->update_client($eventId,$d); |
|
| 2963 | + $this->update_client($eventId, $d); |
|
| 2966 | 2964 | } |
| 2967 | 2965 | |
| 2968 | 2966 | /** |
@@ -2970,8 +2968,8 @@ discard block |
||
| 2970 | 2968 | */ |
| 2971 | 2969 | public function ajax_delete($eventId) |
| 2972 | 2970 | { |
| 2973 | - list($id, $date) = explode(':',$eventId); |
|
| 2974 | - $event=$this->bo->read($id); |
|
| 2971 | + list($id, $date) = explode(':', $eventId); |
|
| 2972 | + $event = $this->bo->read($id); |
|
| 2975 | 2973 | $response = Api\Json\Response::get(); |
| 2976 | 2974 | |
| 2977 | 2975 | if ($this->bo->delete($event['id'], (int)$date)) |
@@ -2984,11 +2982,11 @@ discard block |
||
| 2984 | 2982 | { |
| 2985 | 2983 | $msg = lang('Event deleted'); |
| 2986 | 2984 | } |
| 2987 | - $response->apply('egw.refresh', Array($msg,'calendar',$eventId,'delete')); |
|
| 2985 | + $response->apply('egw.refresh', Array($msg, 'calendar', $eventId, 'delete')); |
|
| 2988 | 2986 | } |
| 2989 | 2987 | else |
| 2990 | 2988 | { |
| 2991 | - $response->apply('egw.message', Array(lang('Error')),'error'); |
|
| 2989 | + $response->apply('egw.message', Array(lang('Error')), 'error'); |
|
| 2992 | 2990 | } |
| 2993 | 2991 | } |
| 2994 | 2992 | |
@@ -3001,10 +2999,10 @@ discard block |
||
| 3001 | 2999 | */ |
| 3002 | 3000 | public function ajax_invite($_eventId, $invite = array(), $remove = array()) |
| 3003 | 3001 | { |
| 3004 | - list($eventId, $date) = explode(':', $_eventId,2); |
|
| 3002 | + list($eventId, $date) = explode(':', $_eventId, 2); |
|
| 3005 | 3003 | |
| 3006 | 3004 | $event = $this->bo->read($eventId); |
| 3007 | - if($date) |
|
| 3005 | + if ($date) |
|
| 3008 | 3006 | { |
| 3009 | 3007 | $d = new Api\DateTime($date, Api\DateTime::$user_timezone); |
| 3010 | 3008 | } |
@@ -3014,17 +3012,17 @@ discard block |
||
| 3014 | 3012 | { |
| 3015 | 3013 | if (!empty($event['whole_day'])) |
| 3016 | 3014 | { |
| 3017 | - $d =& $this->bo->so->startOfDay($date); |
|
| 3015 | + $d = & $this->bo->so->startOfDay($date); |
|
| 3018 | 3016 | $d->setUser(); |
| 3019 | 3017 | } |
| 3020 | 3018 | $event = $this->bo->read($eventId, $d, true); |
| 3021 | 3019 | // For DnD, create an exception if they gave the date |
| 3022 | 3020 | $preserv = null; |
| 3023 | - $this->_create_exception($event,$preserv); |
|
| 3021 | + $this->_create_exception($event, $preserv); |
|
| 3024 | 3022 | unset($event['id']); |
| 3025 | 3023 | |
| 3026 | 3024 | $messages = null; |
| 3027 | - $conflicts = $this->bo->update($event,true,true,false,true,$messages); |
|
| 3025 | + $conflicts = $this->bo->update($event, true, true, false, true, $messages); |
|
| 3028 | 3026 | if (!is_array($conflicts) && $conflicts) |
| 3029 | 3027 | { |
| 3030 | 3028 | // now we need to add the original start as recur-execption to the series |
@@ -3032,28 +3030,28 @@ discard block |
||
| 3032 | 3030 | $recur_event['recur_exception'][] = $d->format('ts'); |
| 3033 | 3031 | // check if we need to move the alarms, because they are next on that exception |
| 3034 | 3032 | $this->bo->check_move_alarms($recur_event, null, $d); |
| 3035 | - unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 3036 | - unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 3037 | - $this->bo->update($recur_event,true); // no conflict check here |
|
| 3033 | + unset($recur_event['start']); unset($recur_event['end']); // no update necessary |
|
| 3034 | + unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start! |
|
| 3035 | + $this->bo->update($recur_event, true); // no conflict check here |
|
| 3038 | 3036 | |
| 3039 | 3037 | // Sending null will trigger a removal of the original for that date |
| 3040 | 3038 | Api\Json\Response::get()->generic('data', array('uid' => 'calendar::'.$_eventId, 'data' => null)); |
| 3041 | 3039 | |
| 3042 | 3040 | unset($recur_event); |
| 3043 | - unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 3041 | + unset($event['edit_single']); // if we further edit it, it's just a single event |
|
| 3044 | 3042 | unset($preserv['edit_single']); |
| 3045 | 3043 | } |
| 3046 | 3044 | } |
| 3047 | - foreach($remove as $participant) |
|
| 3045 | + foreach ($remove as $participant) |
|
| 3048 | 3046 | { |
| 3049 | 3047 | unset($event['participants'][$participant]); |
| 3050 | 3048 | } |
| 3051 | - foreach($invite as $participant) |
|
| 3049 | + foreach ($invite as $participant) |
|
| 3052 | 3050 | { |
| 3053 | 3051 | $event['participants'][$participant] = 'U'; |
| 3054 | 3052 | } |
| 3055 | 3053 | $message = null; |
| 3056 | - $conflicts=$this->bo->update($event,false, true, false, true, $message); |
|
| 3054 | + $conflicts = $this->bo->update($event, false, true, false, true, $message); |
|
| 3057 | 3055 | |
| 3058 | 3056 | $response = Api\Json\Response::get(); |
| 3059 | 3057 | |
@@ -3061,8 +3059,8 @@ discard block |
||
| 3061 | 3059 | { |
| 3062 | 3060 | // Save it anyway, was done with explicit user interaction, |
| 3063 | 3061 | // and if we don't we lose the invite |
| 3064 | - $this->bo->update($event,true); // no conflict check here |
|
| 3065 | - $this->update_client($event['id'],$d); |
|
| 3062 | + $this->bo->update($event, true); // no conflict check here |
|
| 3063 | + $this->update_client($event['id'], $d); |
|
| 3066 | 3064 | $response->call( |
| 3067 | 3065 | 'egw_openWindowCentered2', |
| 3068 | 3066 | $GLOBALS['egw_info']['server']['webserver_url'].'/index.php?menuaction=calendar.calendar_uiforms.edit |
@@ -3071,22 +3069,22 @@ discard block |
||
| 3071 | 3069 | .'&end='.$event['end'] |
| 3072 | 3070 | .'&non_interactive=true' |
| 3073 | 3071 | .'&cancel_needs_refresh=true', |
| 3074 | - '',750,410); |
|
| 3072 | + '', 750, 410); |
|
| 3075 | 3073 | } |
| 3076 | 3074 | else if ($message) |
| 3077 | 3075 | { |
| 3078 | - $response->call('egw.message', implode('<br />', $message)); |
|
| 3076 | + $response->call('egw.message', implode('<br />', $message)); |
|
| 3079 | 3077 | } |
| 3080 | - if($conflicts) |
|
| 3078 | + if ($conflicts) |
|
| 3081 | 3079 | { |
| 3082 | - $this->update_client($event['id'],$d); |
|
| 3083 | - if(is_int($conflicts)) |
|
| 3080 | + $this->update_client($event['id'], $d); |
|
| 3081 | + if (is_int($conflicts)) |
|
| 3084 | 3082 | { |
| 3085 | 3083 | $event['id'] = $conflicts; |
| 3086 | 3084 | } |
| 3087 | - if($event['id']) |
|
| 3085 | + if ($event['id']) |
|
| 3088 | 3086 | { |
| 3089 | - $response->call('egw.refresh', '','calendar',$event['id'],'edit'); |
|
| 3087 | + $response->call('egw.refresh', '', 'calendar', $event['id'], 'edit'); |
|
| 3090 | 3088 | } |
| 3091 | 3089 | } |
| 3092 | 3090 | } |
@@ -3097,13 +3095,13 @@ discard block |
||
| 3097 | 3095 | * @param array $mailContent = null mail content |
| 3098 | 3096 | * @return array |
| 3099 | 3097 | */ |
| 3100 | - function mail_import(array $mailContent=null) |
|
| 3098 | + function mail_import(array $mailContent = null) |
|
| 3101 | 3099 | { |
| 3102 | 3100 | // It would get called from compose as a popup with egw_data |
| 3103 | 3101 | if (!is_array($mailContent) && ($_GET['egw_data'])) |
| 3104 | 3102 | { |
| 3105 | 3103 | // get raw mail data |
| 3106 | - Link::get_data ($_GET['egw_data']); |
|
| 3104 | + Link::get_data($_GET['egw_data']); |
|
| 3107 | 3105 | return false; |
| 3108 | 3106 | } |
| 3109 | 3107 | |
@@ -3113,7 +3111,7 @@ discard block |
||
| 3113 | 3111 | $AB = new Api\Contacts(); |
| 3114 | 3112 | $accounts = array(0 => $GLOBALS['egw_info']['user']['account_id']); |
| 3115 | 3113 | |
| 3116 | - $participants[0] = array ( |
|
| 3114 | + $participants[0] = array( |
|
| 3117 | 3115 | 'uid' => $GLOBALS['egw_info']['user']['account_id'], |
| 3118 | 3116 | 'delete_id' => $GLOBALS['egw_info']['user']['account_id'], |
| 3119 | 3117 | 'status' => 'A', |
@@ -3121,23 +3119,23 @@ discard block |
||
| 3121 | 3119 | 'app' => 'User', |
| 3122 | 3120 | 'role' => 'REQ-PARTICIPANT' |
| 3123 | 3121 | ); |
| 3124 | - foreach($mailContent['addresses'] as $address) |
|
| 3122 | + foreach ($mailContent['addresses'] as $address) |
|
| 3125 | 3123 | { |
| 3126 | 3124 | // Get available contacts from the email |
| 3127 | 3125 | $contacts = $AB->search(array( |
| 3128 | 3126 | 'email' => $address['email'], |
| 3129 | 3127 | 'email_home' => $address['email'] |
| 3130 | - ),'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id','','','',false,'OR',false,array('owner' => 0),'',false); |
|
| 3128 | + ), 'contact_id,contact_email,contact_email_home,egw_addressbook.account_id as account_id', '', '', '', false, 'OR', false, array('owner' => 0), '', false); |
|
| 3131 | 3129 | if (is_array($contacts)) |
| 3132 | 3130 | { |
| 3133 | - foreach($contacts as $account) |
|
| 3131 | + foreach ($contacts as $account) |
|
| 3134 | 3132 | { |
| 3135 | 3133 | $accounts[] = $account['account_id']; |
| 3136 | 3134 | } |
| 3137 | 3135 | } |
| 3138 | 3136 | else |
| 3139 | 3137 | { |
| 3140 | - $participants []= array ( |
|
| 3138 | + $participants [] = array( |
|
| 3141 | 3139 | 'app' => 'email', |
| 3142 | 3140 | 'uid' => 'e'.$address['email'], |
| 3143 | 3141 | 'status' => 'U', |
@@ -3145,7 +3143,7 @@ discard block |
||
| 3145 | 3143 | ); |
| 3146 | 3144 | } |
| 3147 | 3145 | } |
| 3148 | - $participants = array_merge($participants , array( |
|
| 3146 | + $participants = array_merge($participants, array( |
|
| 3149 | 3147 | "participant" => $accounts, |
| 3150 | 3148 | "role" => "REQ-PARTICIPANT", |
| 3151 | 3149 | "add" => "pressed" |
@@ -3169,14 +3167,14 @@ discard block |
||
| 3169 | 3167 | { |
| 3170 | 3168 | foreach ($mailContent['attachments'] as $attachment) |
| 3171 | 3169 | { |
| 3172 | - if($attachment['egw_data']) |
|
| 3170 | + if ($attachment['egw_data']) |
|
| 3173 | 3171 | { |
| 3174 | - Link::link('calendar',$event['link_to']['to_id'],Link::DATA_APPNAME, $attachment); |
|
| 3172 | + Link::link('calendar', $event['link_to']['to_id'], Link::DATA_APPNAME, $attachment); |
|
| 3175 | 3173 | } |
| 3176 | - else if(is_readable($attachment['tmp_name']) || |
|
| 3174 | + else if (is_readable($attachment['tmp_name']) || |
|
| 3177 | 3175 | (Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs')) |
| 3178 | 3176 | { |
| 3179 | - Link::link('calendar',$event['link_to']['to_id'],'file', $attachment); |
|
| 3177 | + Link::link('calendar', $event['link_to']['to_id'], 'file', $attachment); |
|
| 3180 | 3178 | } |
| 3181 | 3179 | } |
| 3182 | 3180 | } |
@@ -539,8 +539,9 @@ |
||
| 539 | 539 | * @param int &$success number of succeded actions |
| 540 | 540 | * @param int &$failed number of failed actions (not enought permissions) |
| 541 | 541 | * @param string &$action_msg translated verb for the actions, to be used in a message like %1 events 'deleted' |
| 542 | - * @param string/array $session_name 'calendar_list' |
|
| 543 | - * @return boolean true if all actions succeded, false otherwise |
|
| 542 | + * @param string $session_name 'calendar_list' |
|
| 543 | + * @param null|string $msg |
|
| 544 | + * @return null|boolean true if all actions succeded, false otherwise |
|
| 544 | 545 | */ |
| 545 | 546 | function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
| 546 | 547 | { |
@@ -77,8 +77,14 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function listview($_content=null,$msg='',$home=false) |
| 79 | 79 | { |
| 80 | - if ($_GET['msg']) $msg .= $_GET['msg']; |
|
| 81 | - if ($this->group_warning) $msg .= $this->group_warning; |
|
| 80 | + if ($_GET['msg']) |
|
| 81 | + { |
|
| 82 | + $msg .= $_GET['msg']; |
|
| 83 | + } |
|
| 84 | + if ($this->group_warning) |
|
| 85 | + { |
|
| 86 | + $msg .= $this->group_warning; |
|
| 87 | + } |
|
| 82 | 88 | |
| 83 | 89 | $etpl = new Etemplate('calendar.list'); |
| 84 | 90 | |
@@ -106,7 +112,8 @@ discard block |
||
| 106 | 112 | { |
| 107 | 113 | // Allow merge using the date range filter |
| 108 | 114 | if(strpos($_content['nm']['action'],'document') !== false && |
| 109 | - !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
|
| 115 | + !count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
|
| 116 | + { |
|
| 110 | 117 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 111 | 118 | } |
| 112 | 119 | if (!count($_content['nm']['selected']) && !$_content['nm']['select_all']) |
@@ -165,15 +172,21 @@ discard block |
||
| 165 | 172 | { |
| 166 | 173 | $params = null; |
| 167 | 174 | parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
| 168 | - if (isset($params['keywords'])) // new search => set filters so every match is shown |
|
| 175 | + if (isset($params['keywords'])) |
|
| 176 | + { |
|
| 177 | + // new search => set filters so every match is shown |
|
| 169 | 178 | { |
| 170 | 179 | $this->adjust_for_search($params['keywords'], $content['nm']); |
| 171 | 180 | } |
| 181 | + } |
|
| 172 | 182 | } |
| 173 | - if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
|
| 183 | + if (isset($_REQUEST['keywords'])) |
|
| 184 | + { |
|
| 185 | + // new search => set filters so every match is shown |
|
| 174 | 186 | { |
| 175 | 187 | $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
| 176 | 188 | } |
| 189 | + } |
|
| 177 | 190 | $sel_options['filter'] = &$this->date_filters; |
| 178 | 191 | |
| 179 | 192 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
@@ -263,9 +276,12 @@ discard block |
||
| 263 | 276 | $old_params = Api\Cache::getSession('calendar', 'calendar_list'); |
| 264 | 277 | if (is_array($old_params)) |
| 265 | 278 | { |
| 266 | - if ($old_params['filter'] && $old_params['filter'] != $params['filter']) // filter changed => order accordingly |
|
| 279 | + if ($old_params['filter'] && $old_params['filter'] != $params['filter']) |
|
| 280 | + { |
|
| 281 | + // filter changed => order accordingly |
|
| 267 | 282 | { |
| 268 | 283 | $params['order'] = 'cal_start'; |
| 284 | + } |
|
| 269 | 285 | $params['sort'] = $params['filter'] == 'before' ? 'DESC' : 'ASC'; |
| 270 | 286 | } |
| 271 | 287 | if ($old_params['search'] != $params['search']) |
@@ -292,7 +308,10 @@ discard block |
||
| 292 | 308 | $cfs = array(); |
| 293 | 309 | foreach($select_cols as $col) |
| 294 | 310 | { |
| 295 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 311 | + if ($col[0] == '#') |
|
| 312 | + { |
|
| 313 | + $cfs[] = substr($col,1); |
|
| 314 | + } |
|
| 296 | 315 | } |
| 297 | 316 | } |
| 298 | 317 | $search_params = array( |
@@ -524,7 +543,10 @@ discard block |
||
| 524 | 543 | { |
| 525 | 544 | $rows['format'] = '64'; |
| 526 | 545 | } |
| 527 | - if ($this->cat_id) $rows['no_cat_id'] = true; |
|
| 546 | + if ($this->cat_id) |
|
| 547 | + { |
|
| 548 | + $rows['no_cat_id'] = true; |
|
| 549 | + } |
|
| 528 | 550 | if (!$GLOBALS['egw_info']['user']['apps']['projectmanager']) |
| 529 | 551 | { |
| 530 | 552 | $params['options-selectcols']['pm_id'] = false; |
@@ -590,7 +612,10 @@ discard block |
||
| 590 | 612 | $this->get_rows($query,$events,$readonlys); |
| 591 | 613 | foreach($events as $key => $event) |
| 592 | 614 | { |
| 593 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 615 | + if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) |
|
| 616 | + { |
|
| 617 | + unset($events[$key]); |
|
| 618 | + } |
|
| 594 | 619 | } |
| 595 | 620 | $checked = array_values($events); // Clear keys |
| 596 | 621 | } |
@@ -604,7 +629,10 @@ discard block |
||
| 604 | 629 | $ids = array(); |
| 605 | 630 | foreach($checked as $id) |
| 606 | 631 | { |
| 607 | - if (is_array($id)) $id = $id['id']; |
|
| 632 | + if (is_array($id)) |
|
| 633 | + { |
|
| 634 | + $id = $id['id']; |
|
| 635 | + } |
|
| 608 | 636 | // get rid of recurrences, doublicate series and calendar-integration events |
| 609 | 637 | if (($id = (int)$id)) |
| 610 | 638 | { |
@@ -618,7 +646,10 @@ discard block |
||
| 618 | 646 | exit(); |
| 619 | 647 | |
| 620 | 648 | case 'document': |
| 621 | - if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 649 | + if (!$settings) |
|
| 650 | + { |
|
| 651 | + $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; |
|
| 652 | + } |
|
| 622 | 653 | $document_merge = new calendar_merge(); |
| 623 | 654 | $msg = $document_merge->download($settings, $checked, '', $GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir']); |
| 624 | 655 | $failed = count($checked); |
@@ -805,7 +836,8 @@ discard block |
||
| 805 | 836 | $success++; |
| 806 | 837 | |
| 807 | 838 | // Can't link to just one of a recurring series of events |
| 808 | - if(!$recur_date || $app) { |
|
| 839 | + if(!$recur_date || $app) |
|
| 840 | + { |
|
| 809 | 841 | // Create link |
| 810 | 842 | $link_id = $app ? $app_id : $id; |
| 811 | 843 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @var mixed |
| 41 | 41 | */ |
| 42 | - var $debug=false; |
|
| 42 | + var $debug = false; |
|
| 43 | 43 | /** |
| 44 | 44 | * Filternames |
| 45 | 45 | * |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 62 | 62 | */ |
| 63 | - function __construct($set_states=null) |
|
| 63 | + function __construct($set_states = null) |
|
| 64 | 64 | { |
| 65 | - parent::__construct(true,$set_states); // call the parent's constructor |
|
| 65 | + parent::__construct(true, $set_states); // call the parent's constructor |
|
| 66 | 66 | |
| 67 | - foreach($this->date_filters as $name => $label) |
|
| 67 | + foreach ($this->date_filters as $name => $label) |
|
| 68 | 68 | { |
| 69 | 69 | $this->date_filters[$name] = lang($label); |
| 70 | 70 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * Show the listview |
| 77 | 77 | */ |
| 78 | - function listview($_content=null,$msg='',$home=false) |
|
| 78 | + function listview($_content = null, $msg = '', $home = false) |
|
| 79 | 79 | { |
| 80 | 80 | if ($_GET['msg']) $msg .= $_GET['msg']; |
| 81 | 81 | if ($this->group_warning) $msg .= $this->group_warning; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $etpl = new Etemplate('calendar.list'); |
| 84 | 84 | |
| 85 | 85 | // Handle merge from sidebox |
| 86 | - if($_GET['merge']) |
|
| 86 | + if ($_GET['merge']) |
|
| 87 | 87 | { |
| 88 | 88 | $_content['nm']['action'] = 'document_'.$_GET['merge']; |
| 89 | 89 | $_content['nm']['select_all'] = true; |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if (is_array($_content)) |
| 93 | 93 | { |
| 94 | 94 | // handle a single button like actions |
| 95 | - foreach(array('delete','timesheet','document') as $button) |
|
| 95 | + foreach (array('delete', 'timesheet', 'document') as $button) |
|
| 96 | 96 | { |
| 97 | 97 | if ($_content['nm']['rows'][$button]) |
| 98 | 98 | { |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | if ($_content['nm']['action']) |
| 106 | 106 | { |
| 107 | 107 | // Allow merge using the date range filter |
| 108 | - if(strpos($_content['nm']['action'],'document') !== false && |
|
| 108 | + if (strpos($_content['nm']['action'], 'document') !== false && |
|
| 109 | 109 | !count($_content['nm']['selected']) && !$_content['nm']['select_all']) { |
| 110 | 110 | $_content['nm']['selected'][] = $this->get_merge_range($_content['nm']); |
| 111 | 111 | } |
@@ -116,14 +116,14 @@ discard block |
||
| 116 | 116 | else |
| 117 | 117 | { |
| 118 | 118 | $success = $failed = $action_msg = null; |
| 119 | - if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'], |
|
| 120 | - $success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 119 | + if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'], |
|
| 120 | + $success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications'])) |
|
| 121 | 121 | { |
| 122 | - $msg .= lang('%1 event(s) %2',$success,$action_msg); |
|
| 122 | + $msg .= lang('%1 event(s) %2', $success, $action_msg); |
|
| 123 | 123 | } |
| 124 | - elseif(is_null($msg)) |
|
| 124 | + elseif (is_null($msg)) |
|
| 125 | 125 | { |
| 126 | - $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); |
|
| 126 | + $msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | { |
| 136 | 136 | $content['nm'] = array( |
| 137 | 137 | 'get_rows' => 'calendar.calendar_uilist.get_rows', |
| 138 | - 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | - 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | - 'no_cat' => True, // I disable the cat-selectbox |
|
| 138 | + 'filter_no_lang' => True, // I set no_lang for filter (=dont translate the options) |
|
| 139 | + 'no_filter2' => True, // I disable the 2. filter (params are the same as for filter) |
|
| 140 | + 'no_cat' => True, // I disable the cat-selectbox |
|
| 141 | 141 | 'filter' => 'after', |
| 142 | - 'order' => 'cal_start',// IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | - 'sort' => 'ASC',// IO direction of the sort: 'ASC' or 'DESC' |
|
| 142 | + 'order' => 'cal_start', // IO name of the column to sort after (optional for the sortheaders) |
|
| 143 | + 'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC' |
|
| 144 | 144 | 'default_cols' => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id', |
| 145 | 145 | 'filter_onchange' => "app.calendar.filter_change", |
| 146 | - 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 146 | + 'row_id' => 'row_id', // set in get rows "$event[id]:$event[recur_date]" |
|
| 147 | 147 | 'row_modified' => 'modified', |
| 148 | 148 | 'favorites' => true, |
| 149 | 149 | 'placeholder_actions' => array('add') |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | } |
| 152 | 152 | $content['nm']['actions'] = $this->get_actions(); |
| 153 | 153 | |
| 154 | - if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters))) |
|
| 154 | + if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters))) |
|
| 155 | 155 | { |
| 156 | 156 | $content['nm']['filter'] = $_GET['filter']; |
| 157 | 157 | } |
@@ -159,16 +159,16 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | $content['nm']['search'] = $_GET['search']; |
| 161 | 161 | } |
| 162 | - if($this->owner) |
|
| 162 | + if ($this->owner) |
|
| 163 | 163 | { |
| 164 | - $content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',',$this->owner); |
|
| 164 | + $content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',', $this->owner); |
|
| 165 | 165 | } |
| 166 | 166 | // search via jdots ajax_exec uses $_REQUEST['json_data'] instead of regular GET parameters |
| 167 | 167 | if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) && |
| 168 | 168 | !empty($json_data['request']['parameters'][0])) |
| 169 | 169 | { |
| 170 | 170 | $params = null; |
| 171 | - parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 171 | + parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?" |
|
| 172 | 172 | if (isset($params['keywords'])) // new search => set filters so every match is shown |
| 173 | 173 | { |
| 174 | 174 | $this->adjust_for_search($params['keywords'], $content['nm']); |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | } |
| 177 | 177 | if (isset($_REQUEST['keywords'])) // new search => set filters so every match is shown |
| 178 | 178 | { |
| 179 | - $this->adjust_for_search($_REQUEST['keywords'],$content['nm']); |
|
| 179 | + $this->adjust_for_search($_REQUEST['keywords'], $content['nm']); |
|
| 180 | 180 | } |
| 181 | 181 | $sel_options['filter'] = &$this->date_filters; |
| 182 | 182 | |
| 183 | 183 | // Send categories for row styling - calendar uses no_cat, so they don't go automatically |
| 184 | 184 | $sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar'); |
| 185 | 185 | // Prevent double encoding - widget does this on its own, but we're just grabbing the options |
| 186 | - foreach($sel_options['category'] as &$label) |
|
| 186 | + foreach ($sel_options['category'] as &$label) |
|
| 187 | 187 | { |
| 188 | - if(!is_array($label)) |
|
| 188 | + if (!is_array($label)) |
|
| 189 | 189 | { |
| 190 | - $label = html_entity_decode($label, ENT_NOQUOTES,'utf-8'); |
|
| 190 | + $label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8'); |
|
| 191 | 191 | } |
| 192 | - elseif($label['label']) |
|
| 192 | + elseif ($label['label']) |
|
| 193 | 193 | { |
| 194 | - $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8'); |
|
| 194 | + $label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8'); |
|
| 195 | 195 | } |
| 196 | 196 | } |
| 197 | 197 | |
@@ -199,15 +199,15 @@ discard block |
||
| 199 | 199 | if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '') |
| 200 | 200 | { |
| 201 | 201 | $content['css'] .= '<style type="text/css">@media screen { .listDescription { max-height: '. |
| 202 | - (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35). // dono why em is not real lines |
|
| 202 | + (($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines |
|
| 203 | 203 | 'em; overflow: auto; }}</style>'; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if($msg) |
|
| 206 | + if ($msg) |
|
| 207 | 207 | { |
| 208 | 208 | Framework::message($msg); |
| 209 | 209 | } |
| 210 | - $html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0); |
|
| 210 | + $html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0); |
|
| 211 | 211 | |
| 212 | 212 | // Not sure why this has to be echoed instead of appended, but that's what works. |
| 213 | 213 | //echo calendar_uiviews::edit_series(); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * set filter for search, so that everything is shown |
| 220 | 220 | */ |
| 221 | - function adjust_for_search($keywords,&$params) |
|
| 221 | + function adjust_for_search($keywords, &$params) |
|
| 222 | 222 | { |
| 223 | 223 | $params['search'] = $keywords; |
| 224 | 224 | $params['start'] = 0; |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | * @param array &$rows returned rows/events |
| 243 | 243 | * @param array &$readonlys eg. to disable buttons based on Acl |
| 244 | 244 | */ |
| 245 | - function get_rows(&$params,&$rows,&$readonlys) |
|
| 245 | + function get_rows(&$params, &$rows, &$readonlys) |
|
| 246 | 246 | { |
| 247 | - unset($readonlys); // not used; |
|
| 247 | + unset($readonlys); // not used; |
|
| 248 | 248 | //echo "uilist::get_rows() params="; _debug_array($params); |
| 249 | 249 | $this->filter = $params['filter']; |
| 250 | 250 | if ($params['filter'] == 'custom') |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | if ($old_params['search'] != $params['search']) |
| 276 | 276 | { |
| 277 | - $this->adjust_for_search($params['search'],$params); |
|
| 277 | + $this->adjust_for_search($params['search'], $params); |
|
| 278 | 278 | $this->filter = $params['filter']; |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -282,28 +282,28 @@ discard block |
||
| 282 | 282 | if (!$params['csv_export']) |
| 283 | 283 | { |
| 284 | 284 | Api\Cache::setSession('calendar', 'calendar_list', |
| 285 | - array_diff_key ($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 285 | + array_diff_key($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions')))); |
|
| 286 | 286 | } |
| 287 | 287 | // do we need to query custom fields and which |
| 288 | 288 | // Check stored preference if selectcols isn't available (ie: first call) |
| 289 | 289 | $select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows']; |
| 290 | - if(!is_array($params['selectcols'])) |
|
| 290 | + if (!is_array($params['selectcols'])) |
|
| 291 | 291 | { |
| 292 | - $select_cols = explode(',',$select_cols); |
|
| 292 | + $select_cols = explode(',', $select_cols); |
|
| 293 | 293 | } |
| 294 | - if (in_array('cfs',$select_cols)) |
|
| 294 | + if (in_array('cfs', $select_cols)) |
|
| 295 | 295 | { |
| 296 | 296 | $cfs = array(); |
| 297 | - foreach($select_cols as $col) |
|
| 297 | + foreach ($select_cols as $col) |
|
| 298 | 298 | { |
| 299 | - if ($col[0] == '#') $cfs[] = substr($col,1); |
|
| 299 | + if ($col[0] == '#') $cfs[] = substr($col, 1); |
|
| 300 | 300 | } |
| 301 | 301 | } |
| 302 | 302 | $search_params = array( |
| 303 | 303 | 'cat_id' => $params['cat_id'] ? $params['cat_id'] : 0, |
| 304 | 304 | 'filter' => $this->filter, |
| 305 | 305 | 'query' => $params['search'], |
| 306 | - 'offset' => (int) $params['start'], |
|
| 306 | + 'offset' => (int)$params['start'], |
|
| 307 | 307 | 'num_rows'=> $params['num_rows'], |
| 308 | 308 | 'order' => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC', |
| 309 | 309 | 'cfs' => $params['csv_export'] ? array() : $cfs, |
@@ -311,24 +311,24 @@ discard block |
||
| 311 | 311 | // Non-blocking events above blocking |
| 312 | 312 | $search_params['order'] .= ', cal_non_blocking DESC'; |
| 313 | 313 | |
| 314 | - switch($this->filter) |
|
| 314 | + switch ($this->filter) |
|
| 315 | 315 | { |
| 316 | 316 | case 'all': |
| 317 | 317 | break; |
| 318 | 318 | case 'before': |
| 319 | - $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date; |
|
| 320 | - $label = lang('Before %1',$this->bo->long_date($search_params['end'])); |
|
| 319 | + $search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date; |
|
| 320 | + $label = lang('Before %1', $this->bo->long_date($search_params['end'])); |
|
| 321 | 321 | break; |
| 322 | 322 | case 'custom': |
| 323 | - $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts'); |
|
| 324 | - $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1; |
|
| 325 | - $label = $this->bo->long_date($this->first,$this->last); |
|
| 323 | + $this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts'); |
|
| 324 | + $this->last = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1; |
|
| 325 | + $label = $this->bo->long_date($this->first, $this->last); |
|
| 326 | 326 | break; |
| 327 | 327 | case 'today': |
| 328 | 328 | $today = new Api\DateTime(); |
| 329 | 329 | $today->setTime(0, 0, 0); |
| 330 | 330 | $this->first = $search_params['start'] = $today->format('ts'); |
| 331 | - $today->setTime(23,59,59); |
|
| 331 | + $today->setTime(23, 59, 59); |
|
| 332 | 332 | $this->last = $search_params['end'] = $today->format('ts'); |
| 333 | 333 | break; |
| 334 | 334 | case 'week': |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 341 | 341 | unset($this->last['raw']); |
| 342 | 342 | $this->last = $this->bo->date2ts($this->last); |
| 343 | - $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last); |
|
| 343 | + $this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last); |
|
| 344 | 344 | $search_params['start'] = $this->first; |
| 345 | 345 | $search_params['end'] = $this->last; |
| 346 | 346 | $params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2); |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | unset($this->first['raw']); |
| 354 | 354 | $this->last = $this->first; |
| 355 | 355 | $this->last['month'] += 1; |
| 356 | - $this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 356 | + $this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year']; |
|
| 357 | 357 | $this->first = $this->bo->date2ts($this->first); |
| 358 | 358 | $this->last = $this->bo->date2ts($this->last); |
| 359 | 359 | $this->last--; |
@@ -366,29 +366,29 @@ discard block |
||
| 366 | 366 | // fall through to after given date |
| 367 | 367 | case 'after': |
| 368 | 368 | default: |
| 369 | - $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date; |
|
| 370 | - $label = lang('After %1',$this->bo->long_date($this->date)); |
|
| 369 | + $this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date; |
|
| 370 | + $label = lang('After %1', $this->bo->long_date($this->date)); |
|
| 371 | 371 | $search_params['start'] = $this->date; |
| 372 | 372 | break; |
| 373 | 373 | } |
| 374 | - if($params['status_filter']) |
|
| 374 | + if ($params['status_filter']) |
|
| 375 | 375 | { |
| 376 | 376 | $search_params['filter'] = $params['status_filter']; |
| 377 | 377 | } |
| 378 | 378 | if ($params['col_filter']['participant']) |
| 379 | 379 | { |
| 380 | - $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']); |
|
| 380 | + $search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']); |
|
| 381 | 381 | } |
| 382 | 382 | elseif (!$params['col_filter'] || !$params['col_filter']['participant']) |
| 383 | 383 | { |
| 384 | - $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner); |
|
| 384 | + $search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner); |
|
| 385 | 385 | } |
| 386 | 386 | if ($params['col_filter']) |
| 387 | 387 | { |
| 388 | 388 | $col_filter = array(); |
| 389 | - foreach($params['col_filter'] as $name => $val) |
|
| 389 | + foreach ($params['col_filter'] as $name => $val) |
|
| 390 | 390 | { |
| 391 | - if (!in_array($name, array('participant','row_id')) && (string)$val !== '') |
|
| 391 | + if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '') |
|
| 392 | 392 | { |
| 393 | 393 | $col_filter[$name] = $val; |
| 394 | 394 | } |
@@ -398,18 +398,18 @@ discard block |
||
| 398 | 398 | |
| 399 | 399 | // App header is mostly taken care of on the client side, but here we update |
| 400 | 400 | // it to match changing list filters |
| 401 | - if($params['view'] && $params['view'] == 'listview') |
|
| 401 | + if ($params['view'] && $params['view'] == 'listview') |
|
| 402 | 402 | { |
| 403 | 403 | Api\Json\Response::get()->call('app.calendar.set_app_header', |
| 404 | - (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') . |
|
| 404 | + (count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : ''). |
|
| 405 | 405 | $label); |
| 406 | 406 | } |
| 407 | - foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 407 | + foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event) |
|
| 408 | 408 | { |
| 409 | 409 | |
| 410 | 410 | if ($params['csv_export']) |
| 411 | 411 | { |
| 412 | - $event['participants'] = implode(",\n",$this->bo->participants($event,true)); |
|
| 412 | + $event['participants'] = implode(",\n", $this->bo->participants($event, true)); |
|
| 413 | 413 | } |
| 414 | 414 | else |
| 415 | 415 | { |
@@ -417,23 +417,23 @@ discard block |
||
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | $matches = null; |
| 420 | - if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches)) |
|
| 420 | + if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches)) |
|
| 421 | 421 | { |
| 422 | 422 | $app = $matches[1]; |
| 423 | 423 | $app_id = $matches[2]; |
| 424 | 424 | $icons = array(); |
| 425 | - if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event))) |
|
| 425 | + if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event))) |
|
| 426 | 426 | { |
| 427 | - $icons[] = Api\Html::image('calendar','private'); |
|
| 427 | + $icons[] = Api\Html::image('calendar', 'private'); |
|
| 428 | 428 | } |
| 429 | 429 | else |
| 430 | 430 | { |
| 431 | - $icons = calendar_uiviews::integration_get_icons($app,$app_id,$event); |
|
| 431 | + $icons = calendar_uiviews::integration_get_icons($app, $app_id, $event); |
|
| 432 | 432 | } |
| 433 | 433 | } |
| 434 | 434 | else |
| 435 | 435 | { |
| 436 | - $is_private = !$this->bo->check_perms(Acl::READ,$event); |
|
| 436 | + $is_private = !$this->bo->check_perms(Acl::READ, $event); |
|
| 437 | 437 | } |
| 438 | 438 | if ($is_private) |
| 439 | 439 | { |
@@ -444,9 +444,9 @@ discard block |
||
| 444 | 444 | $event['app_id'] = $event['id']; |
| 445 | 445 | |
| 446 | 446 | // Edit link |
| 447 | - if($app && $app_id) |
|
| 447 | + if ($app && $app_id) |
|
| 448 | 448 | { |
| 449 | - $popup = calendar_uiviews::integration_get_popup($app,$app_id); |
|
| 449 | + $popup = calendar_uiviews::integration_get_popup($app, $app_id); |
|
| 450 | 450 | |
| 451 | 451 | // Need to strip off 'onclick' |
| 452 | 452 | $event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup); |
@@ -457,18 +457,18 @@ discard block |
||
| 457 | 457 | // populate js_integration_data, if not already set |
| 458 | 458 | if (!isset($js_integration_data[$app])) |
| 459 | 459 | { |
| 460 | - $js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 460 | + $js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | 463 | elseif ($event['recur_type'] != MCAL_RECUR_NONE) |
| 464 | 464 | { |
| 465 | - $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts'); |
|
| 465 | + $event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts'); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Format start and end with timezone |
| 469 | - foreach(array('start','end') as $time) |
|
| 469 | + foreach (array('start', 'end') as $time) |
|
| 470 | 470 | { |
| 471 | - $event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z'); |
|
| 471 | + $event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z'); |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | $rows[] = $event; |
@@ -478,35 +478,35 @@ discard block |
||
| 478 | 478 | // set js_calendar_integration object, to use it in app.js cal_open() function |
| 479 | 479 | $params['js_integration_data'] = json_encode($js_integration_data); |
| 480 | 480 | |
| 481 | - $wv=0; |
|
| 482 | - $dv=0; |
|
| 481 | + $wv = 0; |
|
| 482 | + $dv = 0; |
|
| 483 | 483 | |
| 484 | 484 | // Add in some select options |
| 485 | - $users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']); |
|
| 485 | + $users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']); |
|
| 486 | 486 | |
| 487 | 487 | $this->bo->warnings['groupmembers'] = ''; |
| 488 | - if(($message = $this->check_owners_access($users))) |
|
| 488 | + if (($message = $this->check_owners_access($users))) |
|
| 489 | 489 | { |
| 490 | 490 | Api\Json\Response::get()->error($message); |
| 491 | 491 | } |
| 492 | - else if($this->bo->warnings['groupmembers']) |
|
| 492 | + else if ($this->bo->warnings['groupmembers']) |
|
| 493 | 493 | { |
| 494 | 494 | Api\Json\Response::get()->error($this->bo->warnings['groupmembers']); |
| 495 | 495 | } |
| 496 | 496 | $rows['sel_options']['filter'] = $this->date_filters; |
| 497 | - if($label) |
|
| 497 | + if ($label) |
|
| 498 | 498 | { |
| 499 | 499 | $rows['sel_options']['filter'][$params['filter']] = $label; |
| 500 | 500 | } |
| 501 | - foreach($users as $owner) |
|
| 501 | + foreach ($users as $owner) |
|
| 502 | 502 | { |
| 503 | - if(!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 503 | + if (!is_int($owner) && $this->bo->resources[$owner[0]]) |
|
| 504 | 504 | { |
| 505 | 505 | $app = $this->bo->resources[$owner[0]]['app']; |
| 506 | - $_owner = substr($owner,1); |
|
| 506 | + $_owner = substr($owner, 1); |
|
| 507 | 507 | // Try link first |
| 508 | - $title = Link::title($app, $_owner ); |
|
| 509 | - if($title) |
|
| 508 | + $title = Link::title($app, $_owner); |
|
| 509 | + if ($title) |
|
| 510 | 510 | { |
| 511 | 511 | $rows['sel_options']['owner'][$owner] = $title; |
| 512 | 512 | } |
@@ -514,15 +514,15 @@ discard block |
||
| 514 | 514 | } |
| 515 | 515 | $params['options-selectcols']['week'] = lang('Week'); |
| 516 | 516 | $params['options-selectcols']['weekday'] = lang('Weekday'); |
| 517 | - if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,') |
|
| 517 | + if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,') |
|
| 518 | 518 | { |
| 519 | - $rows['format'] = '32'; // prefix date with week-number |
|
| 520 | - $wv=1; |
|
| 519 | + $rows['format'] = '32'; // prefix date with week-number |
|
| 520 | + $wv = 1; |
|
| 521 | 521 | } |
| 522 | - if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE)) |
|
| 522 | + if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE)) |
|
| 523 | 523 | { |
| 524 | 524 | $rows['format'] = '16'; |
| 525 | - $dv=1; |
|
| 525 | + $dv = 1; |
|
| 526 | 526 | } |
| 527 | 527 | if ($wv && $dv) |
| 528 | 528 | { |
@@ -549,36 +549,36 @@ discard block |
||
| 549 | 549 | * @param string/array $session_name 'calendar_list' |
| 550 | 550 | * @return boolean true if all actions succeded, false otherwise |
| 551 | 551 | */ |
| 552 | - function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) |
|
| 552 | + function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false) |
|
| 553 | 553 | { |
| 554 | 554 | //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)"); |
| 555 | 555 | $success = $failed = 0; |
| 556 | 556 | $msg = null; |
| 557 | 557 | |
| 558 | 558 | // Split out combined values |
| 559 | - if(strpos($action, 'status') !== false) |
|
| 559 | + if (strpos($action, 'status') !== false) |
|
| 560 | 560 | { |
| 561 | 561 | list($action, $status) = explode('-', $action); |
| 562 | 562 | } |
| 563 | 563 | elseif (strpos($action, '_') !== false) |
| 564 | 564 | { |
| 565 | - list($action, $settings) = explode('_', $action,2); |
|
| 565 | + list($action, $settings) = explode('_', $action, 2); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | if ($use_all) |
| 569 | 569 | { |
| 570 | 570 | // get the whole selection |
| 571 | 571 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 572 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 573 | - $query['num_rows'] = -1; // all |
|
| 572 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 573 | + $query['num_rows'] = -1; // all |
|
| 574 | 574 | $readonlys = null; |
| 575 | - $this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document'))); // true = only return the id's |
|
| 575 | + $this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's |
|
| 576 | 576 | // Get rid of any extras (rows that aren't events) |
| 577 | - if(in_array($action,array('ical','document'))) |
|
| 577 | + if (in_array($action, array('ical', 'document'))) |
|
| 578 | 578 | { |
| 579 | - foreach($checked as $key => $event) |
|
| 579 | + foreach ($checked as $key => $event) |
|
| 580 | 580 | { |
| 581 | - if(!is_numeric($key)) |
|
| 581 | + if (!is_numeric($key)) |
|
| 582 | 582 | { |
| 583 | 583 | unset($checked[$key]); |
| 584 | 584 | } |
@@ -586,27 +586,27 @@ discard block |
||
| 586 | 586 | } |
| 587 | 587 | } |
| 588 | 588 | // for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id |
| 589 | - elseif($action == 'document') |
|
| 589 | + elseif ($action == 'document') |
|
| 590 | 590 | { |
| 591 | 591 | $query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name); |
| 592 | - @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 592 | + @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small |
|
| 593 | 593 | $events = null; |
| 594 | - $this->get_rows($query,$events,$readonlys); |
|
| 595 | - foreach($events as $key => $event) |
|
| 594 | + $this->get_rows($query, $events, $readonlys); |
|
| 595 | + foreach ($events as $key => $event) |
|
| 596 | 596 | { |
| 597 | - if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 597 | + if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]); |
|
| 598 | 598 | } |
| 599 | 599 | $checked = array_values($events); // Clear keys |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | // Actions where one action is done to the group |
| 603 | - switch($action) |
|
| 603 | + switch ($action) |
|
| 604 | 604 | { |
| 605 | 605 | case 'ical': |
| 606 | 606 | // compile list of unique cal_id's, as iCal should contain whole series, not recurrences |
| 607 | 607 | // calendar_ical->exportVCal needs to read events again, to get them in server-time |
| 608 | 608 | $ids = array(); |
| 609 | - foreach($checked as $id) |
|
| 609 | + foreach ($checked as $id) |
|
| 610 | 610 | { |
| 611 | 611 | if (is_array($id)) $id = $id['id']; |
| 612 | 612 | // get rid of recurrences, doublicate series and calendar-integration events |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | $boical = new calendar_ical(); |
| 619 | - $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 619 | + $ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH'); |
|
| 620 | 620 | Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical)); |
| 621 | 621 | echo $ical; |
| 622 | 622 | exit(); |
@@ -631,19 +631,19 @@ discard block |
||
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | // Actions where the action is applied to each entry |
| 634 | - if(strpos($action, 'timesheet') !== false) |
|
| 634 | + if (strpos($action, 'timesheet') !== false) |
|
| 635 | 635 | { |
| 636 | 636 | $timesheet_bo = new timesheet_bo(); |
| 637 | 637 | } |
| 638 | - foreach($checked as &$id) |
|
| 638 | + foreach ($checked as &$id) |
|
| 639 | 639 | { |
| 640 | 640 | $recur_date = $app = $app_id = null; |
| 641 | - if(is_array($id) && $id['id']) |
|
| 641 | + if (is_array($id) && $id['id']) |
|
| 642 | 642 | { |
| 643 | 643 | $id = $id['id']; |
| 644 | 644 | } |
| 645 | 645 | $matches = null; |
| 646 | - if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches)) |
|
| 646 | + if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches)) |
|
| 647 | 647 | { |
| 648 | 648 | $app = $matches[1]; |
| 649 | 649 | $app_id = $matches[2]; |
@@ -651,36 +651,36 @@ discard block |
||
| 651 | 651 | } |
| 652 | 652 | else |
| 653 | 653 | { |
| 654 | - list($id,$recur_date) = explode(':',$id); |
|
| 654 | + list($id, $recur_date) = explode(':', $id); |
|
| 655 | 655 | } |
| 656 | - switch($action) |
|
| 656 | + switch ($action) |
|
| 657 | 657 | { |
| 658 | 658 | case 'delete': |
| 659 | 659 | $action_msg = lang('deleted'); |
| 660 | - if($settings == 'series') |
|
| 660 | + if ($settings == 'series') |
|
| 661 | 661 | { |
| 662 | 662 | // Delete the whole thing |
| 663 | 663 | $recur_date = 0; |
| 664 | 664 | } |
| 665 | - if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification)) |
|
| 665 | + if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification)) |
|
| 666 | 666 | { |
| 667 | 667 | $success++; |
| 668 | - if(!$recur_date && $settings == 'series') |
|
| 668 | + if (!$recur_date && $settings == 'series') |
|
| 669 | 669 | { |
| 670 | 670 | // If there are multiple events in a series selected, the next one could purge |
| 671 | - foreach($checked as $key => $c_id) |
|
| 671 | + foreach ($checked as $key => $c_id) |
|
| 672 | 672 | { |
| 673 | - list($c_id,$recur_date) = explode(':',$c_id); |
|
| 674 | - if($c_id == $id) |
|
| 673 | + list($c_id, $recur_date) = explode(':', $c_id); |
|
| 674 | + if ($c_id == $id) |
|
| 675 | 675 | { |
| 676 | 676 | unset($checked[$key]); |
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - if(Api\Json\Response::isJSONResponse()) |
|
| 681 | + if (Api\Json\Response::isJSONResponse()) |
|
| 682 | 682 | { |
| 683 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete'); |
|
| 683 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete'); |
|
| 684 | 684 | } |
| 685 | 685 | } |
| 686 | 686 | else |
@@ -690,23 +690,23 @@ discard block |
||
| 690 | 690 | break; |
| 691 | 691 | case 'undelete': |
| 692 | 692 | $action_msg = lang('recovered'); |
| 693 | - if($settings == 'series') |
|
| 693 | + if ($settings == 'series') |
|
| 694 | 694 | { |
| 695 | 695 | // unDelete the whole thing |
| 696 | 696 | $recur_date = 0; |
| 697 | 697 | } |
| 698 | - if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) && |
|
| 698 | + if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) && |
|
| 699 | 699 | is_array($event) && $event['deleted']) |
| 700 | 700 | { |
| 701 | 701 | $event['deleted'] = null; |
| 702 | - if($this->bo->save($event)) |
|
| 702 | + if ($this->bo->save($event)) |
|
| 703 | 703 | { |
| 704 | 704 | $success++; |
| 705 | 705 | |
| 706 | - if(Api\Json\Response::isJSONResponse()) |
|
| 706 | + if (Api\Json\Response::isJSONResponse()) |
|
| 707 | 707 | { |
| 708 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 709 | - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit'); |
|
| 708 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 709 | + Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit'); |
|
| 710 | 710 | } |
| 711 | 711 | break; |
| 712 | 712 | } |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | break; |
| 716 | 716 | case 'status': |
| 717 | 717 | $action_msg = lang('Status changed'); |
| 718 | - if($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 718 | + if ($id && ($event = $this->bo->read($id, $recur_date))) |
|
| 719 | 719 | { |
| 720 | 720 | $old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']]; |
| 721 | 721 | $quantity = $role = null; |
@@ -724,12 +724,12 @@ discard block |
||
| 724 | 724 | { |
| 725 | 725 | //echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n"; |
| 726 | 726 | $new_status = calendar_so::combine_status($status, $quantity, $role); |
| 727 | - if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date, |
|
| 728 | - false,true,$skip_notification)) |
|
| 727 | + if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date, |
|
| 728 | + false, true, $skip_notification)) |
|
| 729 | 729 | { |
| 730 | - if(Api\Json\Response::isJSONResponse()) |
|
| 730 | + if (Api\Json\Response::isJSONResponse()) |
|
| 731 | 731 | { |
| 732 | - Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); |
|
| 732 | + Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date))); |
|
| 733 | 733 | } |
| 734 | 734 | $success++; |
| 735 | 735 | //$msg = lang('Status changed'); |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | } |
| 747 | 747 | break; |
| 748 | 748 | case 'timesheet-add': |
| 749 | - if($id && !$app) |
|
| 749 | + if ($id && !$app) |
|
| 750 | 750 | { |
| 751 | 751 | $event = $this->bo->read($id, $recur_date); |
| 752 | 752 | } |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | $result = $this->bo->search($query); |
| 759 | 759 | $event = $result[$app.$app_id]; |
| 760 | 760 | } |
| 761 | - if(!$event) |
|
| 761 | + if (!$event) |
|
| 762 | 762 | { |
| 763 | 763 | $failed++; |
| 764 | 764 | continue; |
@@ -775,16 +775,16 @@ discard block |
||
| 775 | 775 | ); |
| 776 | 776 | |
| 777 | 777 | // Add global categories |
| 778 | - $categories = explode(',',$event['category']); |
|
| 778 | + $categories = explode(',', $event['category']); |
|
| 779 | 779 | $global_categories = array(); |
| 780 | - foreach($categories as $cat_id) |
|
| 780 | + foreach ($categories as $cat_id) |
|
| 781 | 781 | { |
| 782 | - if($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 782 | + if ($GLOBALS['egw']->categories->is_global($cat_id)) |
|
| 783 | 783 | { |
| 784 | 784 | $global_categories[] = $cat_id; |
| 785 | 785 | } |
| 786 | 786 | } |
| 787 | - if(count($global_categories)) |
|
| 787 | + if (count($global_categories)) |
|
| 788 | 788 | { |
| 789 | 789 | $timesheet['cat_id'] = implode(',', $global_categories); |
| 790 | 790 | } |
@@ -804,12 +804,12 @@ discard block |
||
| 804 | 804 | } |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - if(!$err) |
|
| 807 | + if (!$err) |
|
| 808 | 808 | { |
| 809 | 809 | $success++; |
| 810 | 810 | |
| 811 | 811 | // Can't link to just one of a recurring series of events |
| 812 | - if(!$recur_date || $app) { |
|
| 812 | + if (!$recur_date || $app) { |
|
| 813 | 813 | // Create link |
| 814 | 814 | $link_id = $app ? $app_id : $id; |
| 815 | 815 | Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']); |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | protected function get_merge_range($nm) |
| 838 | 838 | { |
| 839 | 839 | $checked = array(); |
| 840 | - if($nm['filter'] == 'fixed') |
|
| 840 | + if ($nm['filter'] == 'fixed') |
|
| 841 | 841 | { |
| 842 | 842 | $checked['start'] = $nm['startdate']; |
| 843 | 843 | $last = $this->bo->date2array($nm['enddate']); |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | } |
| 847 | 847 | else |
| 848 | 848 | { |
| 849 | - switch($nm['filter']) |
|
| 849 | + switch ($nm['filter']) |
|
| 850 | 850 | { |
| 851 | 851 | case 'after': |
| 852 | 852 | $checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today'); |
@@ -859,8 +859,8 @@ discard block |
||
| 859 | 859 | $checked['end'] = $nm['enddate']; |
| 860 | 860 | break; |
| 861 | 861 | default: |
| 862 | - $date = date_create_from_format('Ymd',$this->date); |
|
| 863 | - $checked['start']= $date->format('U'); |
|
| 862 | + $date = date_create_from_format('Ymd', $this->date); |
|
| 863 | + $checked['start'] = $date->format('U'); |
|
| 864 | 864 | } |
| 865 | 865 | } |
| 866 | 866 | return $checked; |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | 'allowOnMultiple' => false, |
| 886 | 886 | 'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id', |
| 887 | 887 | 'popup' => Link::get_registry('calendar', 'view_popup'), |
| 888 | - 'group' => $group=1, |
|
| 888 | + 'group' => $group = 1, |
|
| 889 | 889 | 'onExecute' => 'javaScript:app.calendar.cal_open', |
| 890 | 890 | 'disableClass' => 'rowNoView', |
| 891 | 891 | ), |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | 'group' => $group, |
| 919 | 919 | ), |
| 920 | 920 | ); |
| 921 | - $status = array_map('lang',$this->bo->verbose_status); |
|
| 921 | + $status = array_map('lang', $this->bo->verbose_status); |
|
| 922 | 922 | unset($status['G']); |
| 923 | 923 | $actions['status'] = array( |
| 924 | 924 | 'caption' => 'Change your status', |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | 'children' => $status, |
| 928 | 928 | 'group' => ++$group, |
| 929 | 929 | ); |
| 930 | - ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 930 | + ++$group; // integration with other apps: infolog, calendar, filemanager |
|
| 931 | 931 | if ($GLOBALS['egw_info']['user']['apps']['filemanager']) |
| 932 | 932 | { |
| 933 | 933 | $actions['filemanager'] = array( |
@@ -959,7 +959,7 @@ discard block |
||
| 959 | 959 | 'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id', |
| 960 | 960 | 'group' => $group, |
| 961 | 961 | 'allowOnMultiple' => false, |
| 962 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 962 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 963 | 963 | 'onExecute' => 'javaScript:app.calendar.cal_fix_app_id', |
| 964 | 964 | 'popup' => Link::get_registry('timesheet', 'add_popup'), |
| 965 | 965 | ); |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | 'caption' => 'Timesheet', |
| 969 | 969 | 'group' => $group, |
| 970 | 970 | 'allowOnMultiple' => 'only', |
| 971 | - 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 971 | + 'hideOnDisabled' => true, // show only one timesheet action in context menu |
|
| 972 | 972 | ); |
| 973 | 973 | } |
| 974 | 974 | $actions['ical'] = array( |
@@ -977,11 +977,11 @@ discard block |
||
| 977 | 977 | 'group' => ++$group, |
| 978 | 978 | 'hint' => 'Download this event as iCal', |
| 979 | 979 | 'disableClass' => 'rowNoView', |
| 980 | - 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 980 | + 'postSubmit' => true, // download needs post submit (not Ajax) to work |
|
| 981 | 981 | ); |
| 982 | 982 | $actions['documents'] = calendar_merge::document_action( |
| 983 | 983 | $this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_', |
| 984 | - $this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar') |
|
| 984 | + $this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar') |
|
| 985 | 985 | ); |
| 986 | 986 | ++$group; |
| 987 | 987 | $actions['delete'] = array( |
@@ -991,7 +991,7 @@ discard block |
||
| 991 | 991 | 'disableClass' => 'rowNoDelete', |
| 992 | 992 | ); |
| 993 | 993 | // Add in deleted for admins |
| 994 | - if($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 994 | + if ($GLOBALS['egw_info']['server']['calendar_delete_history']) |
|
| 995 | 995 | { |
| 996 | 996 | $actions['undelete'] = array( |
| 997 | 997 | 'caption' => 'Un-delete', |
@@ -412,7 +412,7 @@ discard block |
||
| 412 | 412 | /** |
| 413 | 413 | * Displays the planner view |
| 414 | 414 | * |
| 415 | - * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 415 | + * @param null|Etemplate $home = false if etemplate return content suitable for home-page |
|
| 416 | 416 | */ |
| 417 | 417 | function &planner($content = array(), $home=false) |
| 418 | 418 | { |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * Used for home app |
| 498 | 498 | * |
| 499 | 499 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 500 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 500 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 501 | 501 | */ |
| 502 | 502 | function &month($weeks=0,$home=false) |
| 503 | 503 | { |
@@ -580,6 +580,8 @@ discard block |
||
| 580 | 580 | * @param int &$first timestamp 0h of first day of week containing the first of the current month |
| 581 | 581 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 582 | 582 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 583 | + * @param integer $first |
|
| 584 | + * @param integer $last |
|
| 583 | 585 | */ |
| 584 | 586 | function _week_align_month(&$first,&$last,$day=1) |
| 585 | 587 | { |
@@ -604,7 +606,7 @@ discard block |
||
| 604 | 606 | * Displays the weekview, with 5 or 7 days |
| 605 | 607 | * |
| 606 | 608 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 607 | - * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
|
| 609 | + * @param null|Etemplate $home = false if not false return content suitable for home-page |
|
| 608 | 610 | */ |
| 609 | 611 | function week($days=0,$home=false) |
| 610 | 612 | { |
@@ -740,7 +742,7 @@ discard block |
||
| 740 | 742 | /** |
| 741 | 743 | * Query the open ToDo's via a hook from InfoLog or any other 'calendar_include_todos' provider |
| 742 | 744 | * |
| 743 | - * @param array/string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 745 | + * @param string $todo_label label for the todo-box or array with 2 values: the label and a boolean show_all |
|
| 744 | 746 | * On return $todo_label contains the label for the todo-box |
| 745 | 747 | * @return string/boolean Api\Html with a table of open todo's or false if no hook availible |
| 746 | 748 | */ |
@@ -824,7 +826,7 @@ discard block |
||
| 824 | 826 | * - 'edit_popup' => '400x300' (optional) |
| 825 | 827 | * |
| 826 | 828 | * @param string $app |
| 827 | - * @param int|string $id |
|
| 829 | + * @param string $id |
|
| 828 | 830 | * @return string |
| 829 | 831 | */ |
| 830 | 832 | public static function integration_get_popup($app,$id) |
@@ -864,7 +866,7 @@ discard block |
||
| 864 | 866 | * Icons specified in $events['icons'] are always displayed! |
| 865 | 867 | * |
| 866 | 868 | * @param string $app |
| 867 | - * @param int|string $id |
|
| 869 | + * @param string $id |
|
| 868 | 870 | * @param array $event |
| 869 | 871 | * @return array |
| 870 | 872 | */ |
@@ -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'; |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @var mixed |
| 43 | 43 | */ |
| 44 | - var $debug=false; |
|
| 44 | + var $debug = false; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * extra rows above and below the workday |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @var boolean |
| 94 | 94 | */ |
| 95 | - var $use_time_grid=true; |
|
| 95 | + var $use_time_grid = true; |
|
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | 98 | * Pref value of use_time_grid preference |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @var boolean |
| 107 | 107 | */ |
| 108 | - var $scroll_to_wdstart=false; |
|
| 108 | + var $scroll_to_wdstart = false; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * counter for the current whole day event of a single day |
| 112 | 112 | * |
| 113 | 113 | * @var int |
| 114 | 114 | */ |
| 115 | - var $wholeDayPosCounter=1; |
|
| 115 | + var $wholeDayPosCounter = 1; |
|
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | 118 | * Switch to disable private data and possibility to view and edit events |
@@ -125,26 +125,26 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @param array $set_states = null to manualy set / change one of the states, default NULL = use $_REQUEST |
| 127 | 127 | */ |
| 128 | - function __construct($set_states=null) |
|
| 128 | + function __construct($set_states = null) |
|
| 129 | 129 | { |
| 130 | - parent::__construct(false,$set_states); // call the parent's constructor |
|
| 130 | + parent::__construct(false, $set_states); // call the parent's constructor |
|
| 131 | 131 | $this->extraRowsOriginal = $this->extraRows; //save original extraRows value |
| 132 | 132 | |
| 133 | 133 | $GLOBALS['egw_info']['flags']['nonavbar'] = False; |
| 134 | 134 | |
| 135 | 135 | // Check for GET message (from merge) |
| 136 | - if($_GET['msg']) |
|
| 136 | + if ($_GET['msg']) |
|
| 137 | 137 | { |
| 138 | 138 | Framework::message($_GET['msg']); |
| 139 | 139 | unset($_GET['msg']); |
| 140 | 140 | } |
| 141 | 141 | // standard params for calling bocal::search for all views |
| 142 | - $this->owner = str_replace('%2C',',',$this->owner); |
|
| 142 | + $this->owner = str_replace('%2C', ',', $this->owner); |
|
| 143 | 143 | $this->search_params = array( |
| 144 | 144 | 'start' => $this->date, |
| 145 | - 'cat_id' => $this->cat_id ? (is_array($this->cat_id)?$this->cat_id:explode(',',$this->cat_id)) : 0, |
|
| 146 | - 'users' => explode(',',$this->owner), |
|
| 147 | - 'owner' => explode(',',$this->owner), |
|
| 145 | + 'cat_id' => $this->cat_id ? (is_array($this->cat_id) ? $this->cat_id : explode(',', $this->cat_id)) : 0, |
|
| 146 | + 'users' => explode(',', $this->owner), |
|
| 147 | + 'owner' => explode(',', $this->owner), |
|
| 148 | 148 | 'filter' => $this->filter, |
| 149 | 149 | 'daywise' => True, |
| 150 | 150 | 'use_so_events' => $this->test === 'true', |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function week_number($time) |
| 172 | 172 | { |
| 173 | - if (!is_a($time,'DateTime')) $time = new Api\DateTime($time); |
|
| 173 | + if (!is_a($time, 'DateTime')) $time = new Api\DateTime($time); |
|
| 174 | 174 | |
| 175 | 175 | // if week does not start Monday and $time is Sunday --> add one day |
| 176 | 176 | if ($this->cal_prefs['weekdaystarts'] != 'Monday' && !($wday = $time->format('w'))) |
@@ -188,19 +188,19 @@ discard block |
||
| 188 | 188 | /** |
| 189 | 189 | * Load all views used by calendar, client side switches between them as needed |
| 190 | 190 | */ |
| 191 | - function index($content=array()) |
|
| 191 | + function index($content = array()) |
|
| 192 | 192 | { |
| 193 | - if($content['merge']) |
|
| 193 | + if ($content['merge']) |
|
| 194 | 194 | { |
| 195 | 195 | // View from sidebox is JSON encoded |
| 196 | - $this->manage_states(array_merge($content,json_decode($content['view'],true))); |
|
| 197 | - if($content['first']) |
|
| 196 | + $this->manage_states(array_merge($content, json_decode($content['view'], true))); |
|
| 197 | + if ($content['first']) |
|
| 198 | 198 | { |
| 199 | - $this->first = Api\DateTime::to($content['first'],'ts'); |
|
| 199 | + $this->first = Api\DateTime::to($content['first'], 'ts'); |
|
| 200 | 200 | } |
| 201 | - if($content['last']) |
|
| 201 | + if ($content['last']) |
|
| 202 | 202 | { |
| 203 | - $this->last = Api\DateTime::to($content['last'],'ts'); |
|
| 203 | + $this->last = Api\DateTime::to($content['last'], 'ts'); |
|
| 204 | 204 | } |
| 205 | 205 | $_GET['merge'] = $content['merge']; |
| 206 | 206 | $this->merge(); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualCalendar'.ucfirst($this->view)); |
| 217 | 217 | |
| 218 | 218 | // Sidebox & iframe for old views |
| 219 | - if(in_array($this->view,array('year')) && $_GET['view']) |
|
| 219 | + if (in_array($this->view, array('year')) && $_GET['view']) |
|
| 220 | 220 | { |
| 221 | 221 | $GLOBALS['egw_info']['flags']['nonavbar'] = true; |
| 222 | 222 | $this->manage_states($_GET); |
@@ -228,24 +228,24 @@ discard block |
||
| 228 | 228 | $tmpl = new Etemplate('calendar.toolbar'); |
| 229 | 229 | $tmpl->setElementAttribute('toolbar', 'actions', $this->getToolbarActions($content)); |
| 230 | 230 | // Adjust toolbar for mobile |
| 231 | - if(Api\Header\UserAgent::mobile()){ |
|
| 232 | - $tmpl->setElementAttribute('toolbar','class', 'et2_head_toolbar'); |
|
| 233 | - $tmpl->setElementAttribute('toolbar','view_range', '3'); |
|
| 231 | + if (Api\Header\UserAgent::mobile()) { |
|
| 232 | + $tmpl->setElementAttribute('toolbar', 'class', 'et2_head_toolbar'); |
|
| 233 | + $tmpl->setElementAttribute('toolbar', 'view_range', '3'); |
|
| 234 | 234 | } |
| 235 | - $tmpl->exec('calendar_uiviews::index',array()); |
|
| 235 | + $tmpl->exec('calendar_uiviews::index', array()); |
|
| 236 | 236 | |
| 237 | 237 | // Load the different views once, we'll switch between them on the client side |
| 238 | 238 | $todo = new Etemplate('calendar.todo'); |
| 239 | 239 | $label = ''; |
| 240 | - $todo->exec('calendar_uiviews::index',array('todos'=>'', 'label' => $label)); |
|
| 240 | + $todo->exec('calendar_uiviews::index', array('todos'=>'', 'label' => $label)); |
|
| 241 | 241 | |
| 242 | 242 | // Actually, this takes care of most of it... |
| 243 | 243 | $this->week(); |
| 244 | 244 | |
| 245 | 245 | $planner = new Etemplate('calendar.planner'); |
| 246 | 246 | // Get the actions |
| 247 | - $planner->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 248 | - $planner->exec('calendar_uiviews::index',array()); |
|
| 247 | + $planner->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 248 | + $planner->exec('calendar_uiviews::index', array()); |
|
| 249 | 249 | |
| 250 | 250 | // List view in a separate file |
| 251 | 251 | $list_ui = new calendar_uilist(); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | { |
| 388 | 388 | foreach (array_keys($actions) as $key) |
| 389 | 389 | { |
| 390 | - if (!in_array($key, array('day_view','week_view','next', 'today','previous'))) { |
|
| 390 | + if (!in_array($key, array('day_view', 'week_view', 'next', 'today', 'previous'))) { |
|
| 391 | 391 | $actions[$key]['toolbarDefault'] = false; |
| 392 | 392 | } |
| 393 | 393 | else { |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | * |
| 406 | 406 | * @param boolean|Etemplate $home = false if etemplate return content suitable for home-page |
| 407 | 407 | */ |
| 408 | - function &planner($content = array(), $home=false) |
|
| 408 | + function &planner($content = array(), $home = false) |
|
| 409 | 409 | { |
| 410 | 410 | if ($this->sortby == 'month') // yearly planner with month rows |
| 411 | 411 | { |
@@ -414,17 +414,17 @@ discard block |
||
| 414 | 414 | unset($this->first['raw']); |
| 415 | 415 | $this->last = $this->first; |
| 416 | 416 | $this->last['year']++; |
| 417 | - $this->last = $this->bo->date2ts($this->last)-1; |
|
| 417 | + $this->last = $this->bo->date2ts($this->last) - 1; |
|
| 418 | 418 | } |
| 419 | 419 | elseif (!$this->planner_view || $this->planner_view == 'month') // planner monthview |
| 420 | 420 | { |
| 421 | 421 | if ($this->day < 15) // show one complete month |
| 422 | 422 | { |
| 423 | - $this->_week_align_month($this->first,$this->last); |
|
| 423 | + $this->_week_align_month($this->first, $this->last); |
|
| 424 | 424 | } |
| 425 | 425 | else // show 2 half month |
| 426 | 426 | { |
| 427 | - $this->_week_align_month($this->first,$this->last,15); |
|
| 427 | + $this->_week_align_month($this->first, $this->last, 15); |
|
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | elseif ($this->planner_view == 'week' || $this->planner_view == 'weekN') // weeekview |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $start->setWeekstart(); |
| 434 | 434 | $this->first = $start->format('ts'); |
| 435 | 435 | $this->last = $this->bo->date2array($this->first); |
| 436 | - $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks'])-1; |
|
| 436 | + $this->last['day'] += ($this->planner_view == 'week' ? 7 : 7 * $this->cal_prefs['multiple_weeks']) - 1; |
|
| 437 | 437 | $this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59; |
| 438 | 438 | unset($this->last['raw']); |
| 439 | 439 | $this->last = $this->bo->date2ts($this->last); |
@@ -449,9 +449,9 @@ discard block |
||
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | $merge = $this->merge(); |
| 452 | - if($merge) |
|
| 452 | + if ($merge) |
|
| 453 | 453 | { |
| 454 | - Egw::redirect_link('/index.php',array( |
|
| 454 | + Egw::redirect_link('/index.php', array( |
|
| 455 | 455 | 'menuaction' => 'calendar.calendar_uiviews.index', |
| 456 | 456 | 'msg' => $merge, |
| 457 | 457 | )); |
@@ -463,21 +463,21 @@ discard block |
||
| 463 | 463 | $search_params['end'] = $this->last; |
| 464 | 464 | $search_params['enum_groups'] = $this->sortby == 'user'; |
| 465 | 465 | $content['planner'] = $this->bo->search($search_params); |
| 466 | - foreach($content['planner'] as &$event) |
|
| 466 | + foreach ($content['planner'] as &$event) |
|
| 467 | 467 | { |
| 468 | 468 | $this->to_client($event); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - 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)); |
|
| 471 | + 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)); |
|
| 472 | 472 | |
| 473 | 473 | $tmpl = $home ? $home : new Etemplate('calendar.planner'); |
| 474 | 474 | |
| 475 | - $tmpl->setElementAttribute('planner','start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 476 | - $tmpl->setElementAttribute('planner','end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 477 | - $tmpl->setElementAttribute('planner','owner', $search_params['users']); |
|
| 478 | - $tmpl->setElementAttribute('planner','group_by', $this->sortby); |
|
| 475 | + $tmpl->setElementAttribute('planner', 'start_date', Api\DateTime::to($this->first, Api\DateTime::ET2)); |
|
| 476 | + $tmpl->setElementAttribute('planner', 'end_date', Api\DateTime::to($this->last, Api\DateTime::ET2)); |
|
| 477 | + $tmpl->setElementAttribute('planner', 'owner', $search_params['users']); |
|
| 478 | + $tmpl->setElementAttribute('planner', 'group_by', $this->sortby); |
|
| 479 | 479 | // Get the actions |
| 480 | - $tmpl->setElementAttribute('planner','actions',$this->get_actions()); |
|
| 480 | + $tmpl->setElementAttribute('planner', 'actions', $this->get_actions()); |
|
| 481 | 481 | |
| 482 | 482 | $tmpl->exec(__METHOD__, $content); |
| 483 | 483 | } |
@@ -490,30 +490,30 @@ discard block |
||
| 490 | 490 | * @param int $weeks = 0 number of weeks to show, if 0 (default) all weeks of one month are shown |
| 491 | 491 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 492 | 492 | */ |
| 493 | - function &month($weeks=0,$home=false) |
|
| 493 | + function &month($weeks = 0, $home = false) |
|
| 494 | 494 | { |
| 495 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2',True,$weeks,$this->date); |
|
| 495 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::month(weeks=%1) date=%2', True, $weeks, $this->date); |
|
| 496 | 496 | |
| 497 | 497 | if (!$home) |
| 498 | 498 | { |
| 499 | - trigger_error(__METHOD__ .' only used by home app', E_USER_DEPRECATED); |
|
| 499 | + trigger_error(__METHOD__.' only used by home app', E_USER_DEPRECATED); |
|
| 500 | 500 | return; |
| 501 | 501 | } |
| 502 | 502 | |
| 503 | - $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 503 | + $this->use_time_grid = !$this->use_time_grid_pref || $this->use_time_grid_pref == 'all'; // all views |
|
| 504 | 504 | $granularity = 0; |
| 505 | - if($weeks) |
|
| 505 | + if ($weeks) |
|
| 506 | 506 | { |
| 507 | 507 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 508 | 508 | |
| 509 | 509 | $list = $this->cal_prefs['use_time_grid']; |
| 510 | - if(!is_array($list)) |
|
| 510 | + if (!is_array($list)) |
|
| 511 | 511 | { |
| 512 | - $list = explode(',',$list); |
|
| 512 | + $list = explode(',', $list); |
|
| 513 | 513 | } |
| 514 | - if(is_array($list)) |
|
| 514 | + if (is_array($list)) |
|
| 515 | 515 | { |
| 516 | - $granularity = in_array('weekN',$list) ? 0 : $granularity; |
|
| 516 | + $granularity = in_array('weekN', $list) ? 0 : $granularity; |
|
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | $content = array('view' => array()); |
@@ -523,23 +523,23 @@ discard block |
||
| 523 | 523 | $start = new Api\DateTime($this->date); |
| 524 | 524 | $start->setWeekstart(); |
| 525 | 525 | $this->first = $start->format('ts'); |
| 526 | - $this->last = strtotime("+$weeks weeks",$this->first) - 1; |
|
| 526 | + $this->last = strtotime("+$weeks weeks", $this->first) - 1; |
|
| 527 | 527 | $weekNavH = "$weeks weeks"; |
| 528 | 528 | $navHeader = lang('Week').' '.$this->week_number($this->first).' - '.$this->week_number($this->last).': '. |
| 529 | - $this->bo->long_date($this->first,$this->last); |
|
| 529 | + $this->bo->long_date($this->first, $this->last); |
|
| 530 | 530 | } |
| 531 | 531 | else |
| 532 | 532 | { |
| 533 | - $this->_week_align_month($this->first,$this->last); |
|
| 533 | + $this->_week_align_month($this->first, $this->last); |
|
| 534 | 534 | $weekNavH = "1 month"; |
| 535 | - $navHeader = lang(adodb_date('F',$this->bo->date2ts($this->date))).' '.$this->year; |
|
| 535 | + $navHeader = lang(adodb_date('F', $this->bo->date2ts($this->date))).' '.$this->year; |
|
| 536 | 536 | } |
| 537 | - 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)); |
|
| 537 | + 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)); |
|
| 538 | 538 | |
| 539 | 539 | // Loop through, using Api\DateTime to handle DST |
| 540 | 540 | $week = 0; |
| 541 | 541 | $week_start = new EGroupware\Api\DateTime($this->first); |
| 542 | - $week_start->setTime(0,0,0); |
|
| 542 | + $week_start->setTime(0, 0, 0); |
|
| 543 | 543 | $week_end = new Api\DateTime($week_start); |
| 544 | 544 | $week_end->add(new DateInterval('P6DT23H59M59S')); |
| 545 | 545 | $last = new EGroupware\Api\DateTime($this->last); |
@@ -553,14 +553,14 @@ discard block |
||
| 553 | 553 | array( |
| 554 | 554 | 'id' => $week_start->format('Ymd') |
| 555 | 555 | ); |
| 556 | - $home->setElementAttribute("view[$week]",'onchange',false); |
|
| 557 | - $home->setElementAttribute("view[$week]",'granularity',$granularity); |
|
| 558 | - $home->setElementAttribute("view[$week]",'show_weekend', $this->search_params['weekend']); |
|
| 556 | + $home->setElementAttribute("view[$week]", 'onchange', false); |
|
| 557 | + $home->setElementAttribute("view[$week]", 'granularity', $granularity); |
|
| 558 | + $home->setElementAttribute("view[$week]", 'show_weekend', $this->search_params['weekend']); |
|
| 559 | 559 | $week++; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | // Get the actions |
| 563 | - $home->setElementAttribute('view','actions',$this->get_actions()); |
|
| 563 | + $home->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 564 | 564 | |
| 565 | 565 | $home->exec(__METHOD__, $content); |
| 566 | 566 | } |
@@ -572,13 +572,13 @@ discard block |
||
| 572 | 572 | * @param int &$last timestamp 23:59:59 of last day of week containg the last day of the current month |
| 573 | 573 | * @param int $day = 1 should the alignment be based on the 1. of the month or an other date, eg. the 15. |
| 574 | 574 | */ |
| 575 | - function _week_align_month(&$first,&$last,$day=1) |
|
| 575 | + function _week_align_month(&$first, &$last, $day = 1) |
|
| 576 | 576 | { |
| 577 | 577 | $start = new Api\DateTime($this->date); |
| 578 | - $start->setDate($this->year,$this->month,$this->day=$day); |
|
| 578 | + $start->setDate($this->year, $this->month, $this->day = $day); |
|
| 579 | 579 | $start->setWeekstart(); |
| 580 | 580 | $first = $start->format('ts'); |
| 581 | - $start->setDate($this->year,$this->month+1,$day); |
|
| 581 | + $start->setDate($this->year, $this->month + 1, $day); |
|
| 582 | 582 | if ($day == 1) $start->add('-1day'); |
| 583 | 583 | $start->setWeekstart(); |
| 584 | 584 | // now we need to calculate the end of the last day of that week |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | $arr['day'] += 6; |
| 588 | 588 | $arr['hour'] = 23; |
| 589 | 589 | $arr['min'] = $arr['sec'] = 59; |
| 590 | - unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 590 | + unset($arr['raw']); // otherwise date2ts does not calc raw new, but uses it |
|
| 591 | 591 | $last = $this->bo->date2ts($arr); |
| 592 | 592 | } |
| 593 | 593 | |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | * @param int $days = 0 number of days to show, if 0 (default) the value from the URL or the prefs is used |
| 598 | 598 | * @param boolean|etemplate2 $home = false if not false return content suitable for home-page |
| 599 | 599 | */ |
| 600 | - function week($days=0,$home=false) |
|
| 600 | + function week($days = 0, $home = false) |
|
| 601 | 601 | { |
| 602 | 602 | if (!$days) |
| 603 | 603 | { |
@@ -605,17 +605,17 @@ discard block |
||
| 605 | 605 | if ($days != 5) $days = 7; |
| 606 | 606 | if ($days != $this->cal_prefs['days_in_weekview']) // save the preference |
| 607 | 607 | { |
| 608 | - $GLOBALS['egw']->preferences->add('calendar','days_in_weekview',$days); |
|
| 608 | + $GLOBALS['egw']->preferences->add('calendar', 'days_in_weekview', $days); |
|
| 609 | 609 | $GLOBALS['egw']->preferences->save_repository(); |
| 610 | 610 | $this->cal_prefs['days_in_weekview'] = $days; |
| 611 | 611 | } |
| 612 | 612 | } |
| 613 | - if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2',True,$days,$this->date); |
|
| 613 | + if ($this->debug > 0) $this->bo->debug_message('uiviews::week(days=%1) date=%2', True, $days, $this->date); |
|
| 614 | 614 | |
| 615 | 615 | if ($days <= 4) // next 4 days view |
| 616 | 616 | { |
| 617 | 617 | $wd_start = $this->first = $this->bo->date2ts($this->date); |
| 618 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 618 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 619 | 619 | $view = $days == 1 ? 'day' : 'day4'; |
| 620 | 620 | } |
| 621 | 621 | else |
@@ -625,30 +625,30 @@ discard block |
||
| 625 | 625 | $wd_start = $this->first = $start->format('ts'); |
| 626 | 626 | if ($days <= 5) // no weekend-days |
| 627 | 627 | { |
| 628 | - switch($this->cal_prefs['weekdaystarts']) |
|
| 628 | + switch ($this->cal_prefs['weekdaystarts']) |
|
| 629 | 629 | { |
| 630 | 630 | case 'Saturday': |
| 631 | - $this->first = strtotime("+2 days",$this->first); |
|
| 631 | + $this->first = strtotime("+2 days", $this->first); |
|
| 632 | 632 | break; |
| 633 | 633 | case 'Sunday': |
| 634 | - $this->first = strtotime("+1 day",$this->first); |
|
| 634 | + $this->first = strtotime("+1 day", $this->first); |
|
| 635 | 635 | break; |
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | - $this->last = strtotime("+$days days",$this->first) - 1; |
|
| 638 | + $this->last = strtotime("+$days days", $this->first) - 1; |
|
| 639 | 639 | $view = 'week'; |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | $granularity = ($this->cal_prefs['interval'] ? (int)$this->cal_prefs['interval'] : 30); |
| 643 | 643 | |
| 644 | 644 | $list = $this->cal_prefs['use_time_grid']; |
| 645 | - if(!is_array($list)) |
|
| 645 | + if (!is_array($list)) |
|
| 646 | 646 | { |
| 647 | - $list = explode(',',$list); |
|
| 647 | + $list = explode(',', $list); |
|
| 648 | 648 | } |
| 649 | - if(is_array($list)) |
|
| 649 | + if (is_array($list)) |
|
| 650 | 650 | { |
| 651 | - $granularity = in_array($view,$list) ? 0 : $granularity; |
|
| 651 | + $granularity = in_array($view, $list) ? 0 : $granularity; |
|
| 652 | 652 | } |
| 653 | 653 | |
| 654 | 654 | $search_params = array( |
@@ -661,15 +661,15 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | $content = array('view' => array()); |
| 663 | 663 | |
| 664 | - if(!$home) |
|
| 664 | + if (!$home) |
|
| 665 | 665 | { |
| 666 | 666 | // Fill with the minimum needed 'weeks' |
| 667 | 667 | $min = max( |
| 668 | 668 | 6, // Some months need 6 weeks for full display |
| 669 | - $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 669 | + $this->cal_prefs['multiple_weeks'], // WeekN view |
|
| 670 | 670 | $this->cal_prefs['week_consolidate'] // We collapse after this many users |
| 671 | 671 | ); |
| 672 | - for($i = 0; $i < $min; $i++) |
|
| 672 | + for ($i = 0; $i < $min; $i++) |
|
| 673 | 673 | { |
| 674 | 674 | $content['view'][] = array(); |
| 675 | 675 | } |
@@ -677,8 +677,8 @@ discard block |
||
| 677 | 677 | else |
| 678 | 678 | { |
| 679 | 679 | // Always do 7 days for a week so scrolling works properly |
| 680 | - $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days",$this->first) - 1); |
|
| 681 | - if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] ||// for more then X users, show all in one row |
|
| 680 | + $this->last = ($days == 4 ? $this->last : $search_params['end'] = strtotime("+$days days", $this->first) - 1); |
|
| 681 | + if (count($users) == 1 || count($users) >= $this->cal_prefs['week_consolidate'] || // for more then X users, show all in one row |
|
| 682 | 682 | $days == 1 // Showing just 1 day |
| 683 | 683 | ) |
| 684 | 684 | { |
@@ -687,7 +687,7 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | else |
| 689 | 689 | { |
| 690 | - foreach($users as $uid) |
|
| 690 | + foreach ($users as $uid) |
|
| 691 | 691 | { |
| 692 | 692 | $search_params['users'] = $uid; |
| 693 | 693 | $content['view'][] = $this->tagWholeDayOnTop($this->bo->search($search_params)) |
@@ -695,15 +695,15 @@ discard block |
||
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | - $tmpl = $home ? $home :new Etemplate('calendar.view'); |
|
| 699 | - foreach(array_keys($content['view']) as $index) |
|
| 698 | + $tmpl = $home ? $home : new Etemplate('calendar.view'); |
|
| 699 | + foreach (array_keys($content['view']) as $index) |
|
| 700 | 700 | { |
| 701 | - $tmpl->setElementAttribute("view[$index]",'granularity',$granularity); |
|
| 702 | - $tmpl->setElementAttribute("view[$index]",'show_weekend',$this->search_params['weekend']); |
|
| 701 | + $tmpl->setElementAttribute("view[$index]", 'granularity', $granularity); |
|
| 702 | + $tmpl->setElementAttribute("view[$index]", 'show_weekend', $this->search_params['weekend']); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | // Get the actions |
| 706 | - $tmpl->setElementAttribute('view','actions',$this->get_actions()); |
|
| 706 | + $tmpl->setElementAttribute('view', 'actions', $this->get_actions()); |
|
| 707 | 707 | |
| 708 | 708 | $tmpl->exec(__METHOD__, $content); |
| 709 | 709 | } |
@@ -745,57 +745,56 @@ discard block |
||
| 745 | 745 | 'owner' => $this->owner // num. id of the user, not necessary current user |
| 746 | 746 | )); |
| 747 | 747 | |
| 748 | - if(is_array($todo_label)) |
|
| 748 | + if (is_array($todo_label)) |
|
| 749 | 749 | { |
| 750 | - list($label,$showall)=$todo_label; |
|
| 750 | + list($label, $showall) = $todo_label; |
|
| 751 | 751 | } |
| 752 | 752 | else |
| 753 | 753 | { |
| 754 | - $label=$todo_label; |
|
| 755 | - $showall=true; |
|
| 754 | + $label = $todo_label; |
|
| 755 | + $showall = true; |
|
| 756 | 756 | } |
| 757 | 757 | $maxshow = (int)$GLOBALS['egw_info']['user']['preferences']['infolog']['mainscreen_maxshow']; |
| 758 | - if($maxshow <= 0) |
|
| 758 | + if ($maxshow <= 0) |
|
| 759 | 759 | { |
| 760 | - $maxshow=10; |
|
| 760 | + $maxshow = 10; |
|
| 761 | 761 | } |
| 762 | 762 | //print_debug("get_todos(): label=$label; showall=$showall; max=$maxshow"); |
| 763 | 763 | |
| 764 | 764 | $content = $todo_label = ''; |
| 765 | 765 | if (is_array($todos_from_hook) && count($todos_from_hook)) |
| 766 | 766 | { |
| 767 | - foreach($todos_from_hook as $todos) |
|
| 767 | + foreach ($todos_from_hook as $todos) |
|
| 768 | 768 | { |
| 769 | 769 | $i = 0; |
| 770 | 770 | if (is_array($todos)) |
| 771 | 771 | { |
| 772 | 772 | $todo_label = !empty($label) ? $label : lang("open ToDo's:"); |
| 773 | 773 | |
| 774 | - foreach($todos as &$todo) |
|
| 774 | + foreach ($todos as &$todo) |
|
| 775 | 775 | { |
| 776 | - if(!$showall && ($i++ > $maxshow)) |
|
| 776 | + if (!$showall && ($i++ > $maxshow)) |
|
| 777 | 777 | { |
| 778 | 778 | break; |
| 779 | 779 | } |
| 780 | 780 | $icons = ''; |
| 781 | - foreach($todo['icons'] as $name => $alt) |
|
| 781 | + foreach ($todo['icons'] as $name => $alt) |
|
| 782 | 782 | { |
| 783 | - $icons .= ($icons?' ':'').Api\Html::image('infolog',$name,lang($alt),'border="0" width="15" height="15"'); |
|
| 783 | + $icons .= ($icons ? ' ' : '').Api\Html::image('infolog', $name, lang($alt), 'border="0" width="15" height="15"'); |
|
| 784 | 784 | } |
| 785 | 785 | $todo['icons'] = $icons; |
| 786 | 786 | $class = $class == 'row_on' ? 'row_off' : 'row_on'; |
| 787 | - if($todo['edit']) { |
|
| 787 | + if ($todo['edit']) { |
|
| 788 | 788 | $todo['edit_size'] = $todo['edit']['size']; |
| 789 | 789 | unset($todo['edit']['size']); |
| 790 | - $edit_icon_href = Api\Html::a_href( $icons, $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 791 | - $edit_href = Api\Html::a_href( $todo['title'], $todo['edit'],'',' data-todo="app|750x590" '); |
|
| 792 | - $todo['edit'] = Framework::link('/index.php',$todo['edit'],true); |
|
| 790 | + $edit_icon_href = Api\Html::a_href($icons, $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 791 | + $edit_href = Api\Html::a_href($todo['title'], $todo['edit'], '', ' data-todo="app|750x590" '); |
|
| 792 | + $todo['edit'] = Framework::link('/index.php', $todo['edit'], true); |
|
| 793 | 793 | } |
| 794 | - $icon_href = Api\Html::a_href($icons,$todo['view']); |
|
| 794 | + $icon_href = Api\Html::a_href($icons, $todo['view']); |
|
| 795 | 795 | $content .= " <tr class=\"$class\">\n <td valign=\"top\" width=\"15%\" nowrap>". |
| 796 | - ($this->bo->printer_friendly?$icons:($edit_icon_href ? $edit_icon_href : $icon_href)). |
|
| 797 | - "</td>\n <td>".($this->printer_friendly?$todo['title']: |
|
| 798 | - $edit_href)."</td>\n </tr>\n"; |
|
| 796 | + ($this->bo->printer_friendly ? $icons : ($edit_icon_href ? $edit_icon_href : $icon_href)). |
|
| 797 | + "</td>\n <td>".($this->printer_friendly ? $todo['title'] : $edit_href)."</td>\n </tr>\n"; |
|
| 799 | 798 | /** |
| 800 | 799 | * ToDo: add delete and closing action |
| 801 | 800 | */ |
@@ -818,9 +817,9 @@ discard block |
||
| 818 | 817 | * @param int|string $id |
| 819 | 818 | * @return string |
| 820 | 819 | */ |
| 821 | - public static function integration_get_popup($app,$id) |
|
| 820 | + public static function integration_get_popup($app, $id) |
|
| 822 | 821 | { |
| 823 | - $app_data = calendar_bo::integration_get_data($app,'edit_link'); |
|
| 822 | + $app_data = calendar_bo::integration_get_data($app, 'edit_link'); |
|
| 824 | 823 | |
| 825 | 824 | if (is_array($app_data) && isset($app_data['edit'])) |
| 826 | 825 | { |
@@ -830,7 +829,7 @@ discard block |
||
| 830 | 829 | } |
| 831 | 830 | else |
| 832 | 831 | { |
| 833 | - $edit = Link::edit($app,$id,$popup_size); |
|
| 832 | + $edit = Link::edit($app, $id, $popup_size); |
|
| 834 | 833 | } |
| 835 | 834 | if ($edit) |
| 836 | 835 | { |
@@ -859,28 +858,28 @@ discard block |
||
| 859 | 858 | * @param array $event |
| 860 | 859 | * @return array |
| 861 | 860 | */ |
| 862 | - static function integration_get_icons($app,$id,$event) |
|
| 861 | + static function integration_get_icons($app, $id, $event) |
|
| 863 | 862 | { |
| 864 | 863 | $icons = array(); |
| 865 | 864 | if ($event['icons']) |
| 866 | 865 | { |
| 867 | - foreach(explode(',',$event['icons']) as $icon) |
|
| 866 | + foreach (explode(',', $event['icons']) as $icon) |
|
| 868 | 867 | { |
| 869 | - list($icon_app,$icon) = explode(':',$icon); |
|
| 870 | - if (Api\Image::find($icon_app,$icon)) |
|
| 868 | + list($icon_app, $icon) = explode(':', $icon); |
|
| 869 | + if (Api\Image::find($icon_app, $icon)) |
|
| 871 | 870 | { |
| 872 | - $icons[] = Api\Html::image($icon_app,$icon); |
|
| 871 | + $icons[] = Api\Html::image($icon_app, $icon); |
|
| 873 | 872 | } |
| 874 | 873 | } |
| 875 | 874 | } |
| 876 | - $app_data = calendar_bo::integration_get_data($app,'icons'); |
|
| 875 | + $app_data = calendar_bo::integration_get_data($app, 'icons'); |
|
| 877 | 876 | if (is_null($app_data)) |
| 878 | 877 | { |
| 879 | - $icons[] = Api\Html::image($app,'navbar'); // use navbar icon |
|
| 878 | + $icons[] = Api\Html::image($app, 'navbar'); // use navbar icon |
|
| 880 | 879 | } |
| 881 | 880 | elseif ($app_data) |
| 882 | 881 | { |
| 883 | - $icons += (array)ExecMethod2($app_data,$id,$event); |
|
| 882 | + $icons += (array)ExecMethod2($app_data, $id, $event); |
|
| 884 | 883 | } |
| 885 | 884 | return $icons; |
| 886 | 885 | } |
@@ -903,22 +902,22 @@ discard block |
||
| 903 | 902 | unset($actions['select_all']); |
| 904 | 903 | |
| 905 | 904 | // This disables the event actions for the grid rows (calendar weeks/owners) |
| 906 | - foreach($actions as $id => &$action) |
|
| 905 | + foreach ($actions as $id => &$action) |
|
| 907 | 906 | { |
| 908 | - if($id=='add') continue; |
|
| 909 | - if(!$action['enabled']) |
|
| 907 | + if ($id == 'add') continue; |
|
| 908 | + if (!$action['enabled']) |
|
| 910 | 909 | { |
| 911 | 910 | $action['enabled'] = 'javaScript:app.calendar.is_event'; |
| 912 | 911 | } |
| 913 | 912 | } |
| 914 | 913 | $actions['add']['open'] = '{"app":"calendar","type":"add"}'; |
| 915 | - $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 914 | + $actions['add']['onExecute'] = 'javaScript:app.calendar.action_open'; |
|
| 916 | 915 | $actions['copy']['open'] = '{"app": "calendar", "type": "add", "extra": "cal_id=$id&action=copy"}'; |
| 917 | 916 | $actions['copy']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 918 | 917 | $actions['print']['open'] = '{"app": "calendar", "type": "add", "extra": "cal_id=$id&print=1"}'; |
| 919 | 918 | $actions['print']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 920 | 919 | |
| 921 | - foreach($actions['status']['children'] as $id => &$status) |
|
| 920 | + foreach ($actions['status']['children'] as $id => &$status) |
|
| 922 | 921 | { |
| 923 | 922 | $status = array( |
| 924 | 923 | 'id' => $id, |
@@ -929,7 +928,7 @@ discard block |
||
| 929 | 928 | |
| 930 | 929 | if ($actions['filemanager']) |
| 931 | 930 | { |
| 932 | - $actions['filemanager']['url'] = '/index.php?'. $actions['filemanager']['url']; |
|
| 931 | + $actions['filemanager']['url'] = '/index.php?'.$actions['filemanager']['url']; |
|
| 933 | 932 | $actions['filemanager']['onExecute'] = 'javaScript:app.calendar.action_open'; |
| 934 | 933 | } |
| 935 | 934 | if ($actions['infolog_app']) |
@@ -974,26 +973,26 @@ discard block |
||
| 974 | 973 | { |
| 975 | 974 | $start = $this->bo->date2array($event['start']); |
| 976 | 975 | $end = $this->bo->date2array($event['end']); |
| 977 | - if(!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 976 | + if (!$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59) |
|
| 978 | 977 | { |
| 979 | - if($event['non_blocking']) |
|
| 978 | + if ($event['non_blocking']) |
|
| 980 | 979 | { |
| 981 | - $dayEvents[$day][$num]['whole_day_on_top']=true; |
|
| 982 | - $this->whole_day_positions[$num]=($this->rowHeight*($num+2)); |
|
| 980 | + $dayEvents[$day][$num]['whole_day_on_top'] = true; |
|
| 981 | + $this->whole_day_positions[$num] = ($this->rowHeight * ($num + 2)); |
|
| 983 | 982 | $extraRowsToAdd++; |
| 984 | 983 | } |
| 985 | 984 | else |
| 986 | 985 | { |
| 987 | - $dayEvents[$day][$num]['whole_day']=true; |
|
| 986 | + $dayEvents[$day][$num]['whole_day'] = true; |
|
| 988 | 987 | } |
| 989 | 988 | } |
| 990 | 989 | $this->to_client($dayEvents[$day][$num]); |
| 991 | 990 | } |
| 992 | 991 | // check after every day if we have to increase $this->extraRows |
| 993 | - if(($this->extraRowsOriginal+$extraRowsToAdd) > $this->extraRows) |
|
| 992 | + if (($this->extraRowsOriginal + $extraRowsToAdd) > $this->extraRows) |
|
| 994 | 993 | { |
| 995 | 994 | $this->remBotExtraRows = $extraRowsToAdd; |
| 996 | - $this->extraRows = ($this->extraRowsOriginal+$extraRowsToAdd); |
|
| 995 | + $this->extraRows = ($this->extraRowsOriginal + $extraRowsToAdd); |
|
| 997 | 996 | } |
| 998 | 997 | } |
| 999 | 998 | } |
@@ -11,6 +11,10 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | use EGroupware\Api; |
| 13 | 13 | |
| 14 | +/** |
|
| 15 | + * @param string $table |
|
| 16 | + * @param string $field |
|
| 17 | + */ |
|
| 14 | 18 | function calendar_v0_9_2to0_9_3update_owner($table, $field) |
| 15 | 19 | { |
| 16 | 20 | $GLOBALS['egw_setup']->oProc->query("select distinct($field) from $table"); |
@@ -2306,7 +2310,7 @@ discard block |
||
| 2306 | 2310 | * |
| 2307 | 2311 | * Also fix recurring events containing a reference to an other master, created when an exception is made a recurring event. |
| 2308 | 2312 | * |
| 2309 | - * @return type |
|
| 2313 | + * @return string |
|
| 2310 | 2314 | */ |
| 2311 | 2315 | function calendar_upgrade14_1() |
| 2312 | 2316 | { |
@@ -1909,7 +1909,7 @@ |
||
| 1909 | 1909 | WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1912 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
|
| 1913 | 1913 | WHERE recur_interval=0',__LINE__,__FILE__); |
| 1914 | 1914 | |
| 1915 | 1915 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 34 | 34 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 35 | - $GLOBALS['egw_setup']->oProc->query("UPDATE $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 35 | + $GLOBALS['egw_setup']->oProc->query("update $table SET $field=".$GLOBALS['egw_setup']->oProc->f('account_id')." WHERE $field='".$owner[$i]."'"); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | $GLOBALS['egw_setup']->oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0)); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 189 | 189 | |
| 190 | 190 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry', |
| 191 | - Array( |
|
| 191 | + array( |
|
| 192 | 192 | 'fd' => array( |
| 193 | 193 | 'cal_id' => array('type' => 'auto', 'nullable' => false), |
| 194 | 194 | 'cal_owner' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry'); |
| 239 | 239 | |
| 240 | 240 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_user', |
| 241 | - Array( |
|
| 241 | + array( |
|
| 242 | 242 | 'fd' => array( |
| 243 | 243 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
| 244 | 244 | 'cal_login' => array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => '0'), |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_user'); |
| 269 | 269 | |
| 270 | 270 | $GLOBALS['egw_setup']->oProc->CreateTable('calendar_entry_repeats', |
| 271 | - Array( |
|
| 271 | + array( |
|
| 272 | 272 | 'fd' => array( |
| 273 | 273 | 'cal_id' => array('type' => 'int', 'precision' => 4, 'default' => '0', 'nullable' => false), |
| 274 | 274 | 'cal_type' => array('type' => 'varchar', 'precision' => 20, 'default' => 'daily', 'nullable' => false), |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 313 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 313 | + $GLOBALS['egw_setup']->oProc->query("update {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 314 | 314 | |
| 315 | 315 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 316 | 316 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | |
| 603 | 603 | // calendar_entry => phpgw_cal |
| 604 | 604 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal', |
| 605 | - Array( |
|
| 605 | + array( |
|
| 606 | 606 | 'fd' => array( |
| 607 | 607 | 'cal_id' => array('type' => 'auto', 'nullable' => False), |
| 608 | 608 | 'owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | |
| 659 | 659 | // calendar_entry_repeats => phpgw_cal_repeats |
| 660 | 660 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 661 | - Array( |
|
| 661 | + array( |
|
| 662 | 662 | 'fd' => array( |
| 663 | 663 | 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
| 664 | 664 | 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | function calendar_upgrade0_9_11_003() |
| 732 | 732 | { |
| 733 | 733 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 734 | - Array( |
|
| 734 | + array( |
|
| 735 | 735 | 'fd' => array( |
| 736 | 736 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
| 737 | 737 | 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | { |
| 768 | 768 | $GLOBALS['egw_setup']->oProc->DropTable('phpgw_cal_holidays'); |
| 769 | 769 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 770 | - Array( |
|
| 770 | + array( |
|
| 771 | 771 | 'fd' => array( |
| 772 | 772 | 'hol_id' => array('type' => 'auto','nullable' => False), |
| 773 | 773 | 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | function calendar_upgrade0_9_13_003() |
| 855 | 855 | { |
| 856 | 856 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 857 | - Array( |
|
| 857 | + array( |
|
| 858 | 858 | 'fd' => array( |
| 859 | 859 | 'alarm_id' => array('type' => 'auto','nullable' => False), |
| 860 | 860 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | |
| 889 | 889 | function calendar_upgrade0_9_13_005() |
| 890 | 890 | { |
| 891 | - $calendar_data = Array(); |
|
| 891 | + $calendar_data = array(); |
|
| 892 | 892 | $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
| 893 | 893 | while($GLOBALS['egw_setup']->oProc->next_record()) |
| 894 | 894 | { |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $owner[count($owner)] = $GLOBALS['egw_setup']->oProc->f($field); |
| 22 | 22 | } |
| 23 | - if($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'],'0.9.10pre4')) |
|
| 23 | + if ($GLOBALS['egw_setup']->alessthanb($GLOBALS['setup_info']['phpgwapi']['currentver'], '0.9.10pre4')) |
|
| 24 | 24 | { |
| 25 | 25 | $acctstbl = 'accounts'; |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $acctstbl = 'phpgw_accounts'; |
| 30 | 30 | } |
| 31 | - for($i=0;$i<count($owner);$i++) |
|
| 31 | + for ($i = 0; $i < count($owner); $i++) |
|
| 32 | 32 | { |
| 33 | 33 | $GLOBALS['egw_setup']->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'"); |
| 34 | 34 | $GLOBALS['egw_setup']->oProc->next_record(); |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function calendar_upgrade0_9_3pre1() |
| 43 | 43 | { |
| 44 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry','cal_create_by'); |
|
| 45 | - calendar_v0_9_2to0_9_3update_owner('webcal_entry_user','cal_login'); |
|
| 44 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry', 'cal_create_by'); |
|
| 45 | + calendar_v0_9_2to0_9_3update_owner('webcal_entry_user', 'cal_login'); |
|
| 46 | 46 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.3pre2'; |
| 47 | 47 | return $GLOBALS['setup_info']['calendar']['currentver']; |
| 48 | 48 | } |
@@ -209,12 +209,12 @@ discard block |
||
| 209 | 209 | ) |
| 210 | 210 | ); |
| 211 | 211 | |
| 212 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry',__LINE__,__FILE__); |
|
| 212 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry', __LINE__, __FILE__); |
|
| 213 | 213 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 214 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 214 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 215 | 215 | { |
| 216 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 217 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 216 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_owner,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description,cal_id,cal_date,cal_time,cal_mod_date,cal_mod_time FROM webcal_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 217 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 218 | 218 | { |
| 219 | 219 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 220 | 220 | $cal_owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
@@ -224,13 +224,13 @@ discard block |
||
| 224 | 224 | $cal_access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 225 | 225 | $cal_name = $GLOBALS['egw_setup']->oProc->f('cal_name'); |
| 226 | 226 | $cal_description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 227 | - $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'),0,4))); |
|
| 228 | - $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),4))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),2,2))),intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')),0,2))),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'),0,4))); |
|
| 229 | - $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 227 | + $datetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_date'), 0, 4))); |
|
| 228 | + $moddatetime = mktime(intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 4))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 2, 2))), intval(strrev(substr(strrev($GLOBALS['egw_setup']->oProc->f('cal_mod_time')), 0, 2))), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_mod_date'), 0, 4))); |
|
| 229 | + $db2->query('SELECT groups FROM webcal_entry_groups WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 230 | 230 | $db2->next_record(); |
| 231 | 231 | $cal_group = $db2->f('groups'); |
| 232 | 232 | $db2->query('INSERT INTO calendar_entry(cal_id,cal_owner,cal_group,cal_datetime,cal_mdatetime,cal_duration,cal_priority,cal_type,cal_access,cal_name,cal_description) ' |
| 233 | - .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')",__LINE__,__FILE__); |
|
| 233 | + .'VALUES('.$cal_id.",'".$cal_owner."','".$cal_group."',".$datetime.",".$moddatetime.",".$cal_duration.",".$cal_priority.",'".$cal_type."','".$cal_access."','".$cal_name."','".$cal_description."')", __LINE__, __FILE__); |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -251,17 +251,17 @@ discard block |
||
| 251 | 251 | ) |
| 252 | 252 | ); |
| 253 | 253 | |
| 254 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user',__LINE__,__FILE__); |
|
| 254 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_user', __LINE__, __FILE__); |
|
| 255 | 255 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 256 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 256 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 257 | 257 | { |
| 258 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id',__LINE__,__FILE__); |
|
| 259 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 258 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_login,cal_status FROM webcal_entry_user ORDER BY cal_id', __LINE__, __FILE__); |
|
| 259 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 260 | 260 | { |
| 261 | 261 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 262 | 262 | $cal_login = $GLOBALS['egw_setup']->oProc->f('cal_login'); |
| 263 | 263 | $cal_status = $GLOBALS['egw_setup']->oProc->f('cal_status'); |
| 264 | - $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')",__LINE__,__FILE__); |
|
| 264 | + $db2->query('INSERT INTO calendar_entry_user(cal_id,cal_login,cal_status) VALUES('.$cal_id.','.$cal_login.",'".$cal_status."')", __LINE__, __FILE__); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
@@ -284,18 +284,18 @@ discard block |
||
| 284 | 284 | ) |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats',__LINE__,__FILE__); |
|
| 287 | + $GLOBALS['egw_setup']->oProc->query('SELECT count(*) FROM webcal_entry_repeats', __LINE__, __FILE__); |
|
| 288 | 288 | $GLOBALS['egw_setup']->oProc->next_record(); |
| 289 | - if($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 289 | + if ($GLOBALS['egw_setup']->oProc->f(0)) |
|
| 290 | 290 | { |
| 291 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id',__LINE__,__FILE__); |
|
| 292 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 291 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_type,cal_end,cal_frequency,cal_days FROM webcal_entry_repeats ORDER BY cal_id', __LINE__, __FILE__); |
|
| 292 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 293 | 293 | { |
| 294 | 294 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 295 | 295 | $cal_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 296 | - if(isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 296 | + if (isset($GLOBALS['egw_setup']->oProc->Record['cal_end'])) |
|
| 297 | 297 | { |
| 298 | - $enddate = mktime(0,0,0,intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),4,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),6,2)),intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'),0,4))); |
|
| 298 | + $enddate = mktime(0, 0, 0, intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 4, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 6, 2)), intval(substr($GLOBALS['egw_setup']->oProc->f('cal_end'), 0, 4))); |
|
| 299 | 299 | $useend = 1; |
| 300 | 300 | } |
| 301 | 301 | else |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | } |
| 306 | 306 | $cal_frequency = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 307 | 307 | $cal_days = $GLOBALS['egw_setup']->oProc->f('cal_days'); |
| 308 | - $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')",__LINE__,__FILE__); |
|
| 308 | + $db2->query('INSERT INTO calendar_entry_repeats(cal_id,cal_type,cal_use_end,cal_end,cal_frequency,cal_days) VALUES('.$cal_id.",'".$cal_type."',".$useend.",".$enddate.",".$cal_frequency.",'".$cal_days."')", __LINE__, __FILE__); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | $GLOBALS['egw_setup']->oProc->DropTable('webcal_entry_repeats'); |
| 313 | - $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'",__LINE__,__FILE__); |
|
| 313 | + $GLOBALS['egw_setup']->oProc->query("UPDATE {$GLOBALS['egw_setup']->applications_table} SET app_tables='calendar_entry,calendar_entry_user,calendar_entry_repeats' WHERE app_name='calendar'", __LINE__, __FILE__); |
|
| 314 | 314 | |
| 315 | 315 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.7pre2'; |
| 316 | 316 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -322,19 +322,19 @@ discard block |
||
| 322 | 322 | $db2 = $GLOBALS['egw_setup']->db; |
| 323 | 323 | |
| 324 | 324 | $GLOBALS['egw_setup']->oProc->RenameColumn('calendar_entry', 'cal_duration', 'cal_edatetime'); |
| 325 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id',__LINE__,__FILE__); |
|
| 326 | - if($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 325 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id,cal_datetime,cal_owner,cal_edatetime,cal_mdatetime FROM calendar_entry ORDER BY cal_id', __LINE__, __FILE__); |
|
| 326 | + if ($GLOBALS['egw_setup']->oProc->num_rows()) |
|
| 327 | 327 | { |
| 328 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 328 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 329 | 329 | { |
| 330 | - $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'),__LINE__,__FILE__); |
|
| 330 | + $db2->query("SELECT preference_value FROM preferences WHERE preference_name='tz_offset' AND preference_appname='common' AND preference_owner=".$GLOBALS['egw_setup']->db->f('cal_owner'), __LINE__, __FILE__); |
|
| 331 | 331 | $db2->next_record(); |
| 332 | 332 | $tz = $db2->f('preference_value'); |
| 333 | 333 | $cal_id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 334 | 334 | $datetime = $GLOBALS['egw_setup']->oProc->f('cal_datetime') - ((60 * 60) * $tz); |
| 335 | 335 | $mdatetime = $GLOBALS['egw_setup']->oProc->f('cal_mdatetime') - ((60 * 60) * $tz); |
| 336 | 336 | $edatetime = $datetime + (60 * $GLOBALS['egw_setup']->oProc->f('cal_edatetime')); |
| 337 | - $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id,__LINE__,__FILE__); |
|
| 337 | + $db2->query('UPDATE calendar_entry SET cal_datetime='.$datetime.', cal_edatetime='.$edatetime.', cal_mdatetime='.$mdatetime.' WHERE cal_id='.$cal_id, __LINE__, __FILE__); |
|
| 338 | 338 | } |
| 339 | 339 | } |
| 340 | 340 | |
@@ -582,22 +582,22 @@ discard block |
||
| 582 | 582 | { |
| 583 | 583 | $db2 = $GLOBALS['egw_setup']->db; |
| 584 | 584 | |
| 585 | - if(extension_loaded('mcal') == False) |
|
| 585 | + if (extension_loaded('mcal') == False) |
|
| 586 | 586 | { |
| 587 | - define(RECUR_NONE,0); |
|
| 588 | - define(RECUR_DAILY,1); |
|
| 589 | - define(RECUR_WEEKLY,2); |
|
| 590 | - define(RECUR_MONTHLY_MDAY,3); |
|
| 591 | - define(RECUR_MONTHLY_WDAY,4); |
|
| 592 | - define(RECUR_YEARLY,5); |
|
| 593 | - |
|
| 594 | - define(M_SUNDAY,1); |
|
| 595 | - define(M_MONDAY,2); |
|
| 596 | - define(M_TUESDAY,4); |
|
| 597 | - define(M_WEDNESDAY,8); |
|
| 598 | - define(M_THURSDAY,16); |
|
| 599 | - define(M_FRIDAY,32); |
|
| 600 | - define(M_SATURDAY,64); |
|
| 587 | + define(RECUR_NONE, 0); |
|
| 588 | + define(RECUR_DAILY, 1); |
|
| 589 | + define(RECUR_WEEKLY, 2); |
|
| 590 | + define(RECUR_MONTHLY_MDAY, 3); |
|
| 591 | + define(RECUR_MONTHLY_WDAY, 4); |
|
| 592 | + define(RECUR_YEARLY, 5); |
|
| 593 | + |
|
| 594 | + define(M_SUNDAY, 1); |
|
| 595 | + define(M_MONDAY, 2); |
|
| 596 | + define(M_TUESDAY, 4); |
|
| 597 | + define(M_WEDNESDAY, 8); |
|
| 598 | + define(M_THURSDAY, 16); |
|
| 599 | + define(M_FRIDAY, 32); |
|
| 600 | + define(M_SATURDAY, 64); |
|
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | // calendar_entry => phpgw_cal |
@@ -624,13 +624,13 @@ discard block |
||
| 624 | 624 | ) |
| 625 | 625 | ); |
| 626 | 626 | |
| 627 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry',__LINE__,__FILE__); |
|
| 628 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 627 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry', __LINE__, __FILE__); |
|
| 628 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 629 | 629 | { |
| 630 | 630 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 631 | 631 | $owner = $GLOBALS['egw_setup']->oProc->f('cal_owner'); |
| 632 | 632 | $access = $GLOBALS['egw_setup']->oProc->f('cal_access'); |
| 633 | - switch($access) |
|
| 633 | + switch ($access) |
|
| 634 | 634 | { |
| 635 | 635 | case 'private': |
| 636 | 636 | $is_public = 0; |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | $description = $GLOBALS['egw_setup']->oProc->f('cal_description'); |
| 653 | 653 | |
| 654 | 654 | $db2->query("INSERT INTO phpgw_cal(cal_id,owner,groups,datetime,mdatetime,edatetime,priority,cal_type,is_public,title,description) " |
| 655 | - . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')",__LINE__,__FILE__); |
|
| 655 | + . "VALUES($id,$owner,'$groups',$datetime,$mdatetime,$edatetime,$priority,'$type',$is_public,'$title','$description')", __LINE__, __FILE__); |
|
| 656 | 656 | } |
| 657 | 657 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry'); |
| 658 | 658 | |
@@ -660,12 +660,12 @@ discard block |
||
| 660 | 660 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_repeats', |
| 661 | 661 | Array( |
| 662 | 662 | 'fd' => array( |
| 663 | - 'cal_id' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 664 | - 'recur_type' => array('type' => 'int', 'precision' => 8,'nullable' => False), |
|
| 665 | - 'recur_use_end' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 666 | - 'recur_enddate' => array('type' => 'int', 'precision' => 8,'nullable' => True), |
|
| 667 | - 'recur_interval' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1'), |
|
| 668 | - 'recur_data' => array('type' => 'int', 'precision' => 8,'nullable' => True,'default' => '1') |
|
| 663 | + 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 664 | + 'recur_type' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
|
| 665 | + 'recur_use_end' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 666 | + 'recur_enddate' => array('type' => 'int', 'precision' => 8, 'nullable' => True), |
|
| 667 | + 'recur_interval' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1'), |
|
| 668 | + 'recur_data' => array('type' => 'int', 'precision' => 8, 'nullable' => True, 'default' => '1') |
|
| 669 | 669 | ), |
| 670 | 670 | 'pk' => array(), |
| 671 | 671 | 'fk' => array(), |
@@ -673,12 +673,12 @@ discard block |
||
| 673 | 673 | 'uc' => array() |
| 674 | 674 | ) |
| 675 | 675 | ); |
| 676 | - $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats',__LINE__,__FILE__); |
|
| 677 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 676 | + $GLOBALS['egw_setup']->oProc->query('SELECT * FROM calendar_entry_repeats', __LINE__, __FILE__); |
|
| 677 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 678 | 678 | { |
| 679 | 679 | $id = $GLOBALS['egw_setup']->oProc->f('cal_id'); |
| 680 | 680 | $recur_type = $GLOBALS['egw_setup']->oProc->f('cal_type'); |
| 681 | - switch($recur_type) |
|
| 681 | + switch ($recur_type) |
|
| 682 | 682 | { |
| 683 | 683 | case 'daily': |
| 684 | 684 | $recur_type_num = RECUR_DAILY; |
@@ -701,20 +701,20 @@ discard block |
||
| 701 | 701 | $recur_interval = $GLOBALS['egw_setup']->oProc->f('cal_frequency'); |
| 702 | 702 | $days = strtoupper($GLOBALS['egw_setup']->oProc->f('cal_days')); |
| 703 | 703 | $recur_data = 0; |
| 704 | - $recur_data += (substr($days,0,1)=='Y'?M_SUNDAY:0); |
|
| 705 | - $recur_data += (substr($days,1,1)=='Y'?M_MONDAY:0); |
|
| 706 | - $recur_data += (substr($days,2,1)=='Y'?M_TUESDAY:0); |
|
| 707 | - $recur_data += (substr($days,3,1)=='Y'?M_WEDNESDAY:0); |
|
| 708 | - $recur_data += (substr($days,4,1)=='Y'?M_THURSDAY:0); |
|
| 709 | - $recur_data += (substr($days,5,1)=='Y'?M_FRIDAY:0); |
|
| 710 | - $recur_data += (substr($days,6,1)=='Y'?M_SATURDAY:0); |
|
| 704 | + $recur_data += (substr($days, 0, 1) == 'Y' ? M_SUNDAY : 0); |
|
| 705 | + $recur_data += (substr($days, 1, 1) == 'Y' ? M_MONDAY : 0); |
|
| 706 | + $recur_data += (substr($days, 2, 1) == 'Y' ? M_TUESDAY : 0); |
|
| 707 | + $recur_data += (substr($days, 3, 1) == 'Y' ? M_WEDNESDAY : 0); |
|
| 708 | + $recur_data += (substr($days, 4, 1) == 'Y' ? M_THURSDAY : 0); |
|
| 709 | + $recur_data += (substr($days, 5, 1) == 'Y' ? M_FRIDAY : 0); |
|
| 710 | + $recur_data += (substr($days, 6, 1) == 'Y' ? M_SATURDAY : 0); |
|
| 711 | 711 | $db2->query("INSERT INTO phpgw_cal_repeats(cal_id,recur_type,recur_use_end,recur_enddate,recur_interval,recur_data) " |
| 712 | - . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)",__LINE__,__FILE__); |
|
| 712 | + . "VALUES($id,$recur_type_num,$recur_use_end,$recur_end,$recur_interval,$recur_data)", __LINE__, __FILE__); |
|
| 713 | 713 | } |
| 714 | 714 | $GLOBALS['egw_setup']->oProc->DropTable('calendar_entry_repeats'); |
| 715 | 715 | |
| 716 | 716 | // calendar_entry_user => phpgw_cal_user |
| 717 | - $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user','phpgw_cal_user'); |
|
| 717 | + $GLOBALS['egw_setup']->oProc->RenameTable('calendar_entry_user', 'phpgw_cal_user'); |
|
| 718 | 718 | |
| 719 | 719 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.002'; |
| 720 | 720 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -733,11 +733,11 @@ discard block |
||
| 733 | 733 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 734 | 734 | Array( |
| 735 | 735 | 'fd' => array( |
| 736 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 737 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 738 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 736 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 737 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 738 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 739 | 739 | ), |
| 740 | - 'pk' => array('locale','name'), |
|
| 740 | + 'pk' => array('locale', 'name'), |
|
| 741 | 741 | 'fk' => array(), |
| 742 | 742 | 'ix' => array(), |
| 743 | 743 | 'uc' => array() |
@@ -769,10 +769,10 @@ discard block |
||
| 769 | 769 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_holidays', |
| 770 | 770 | Array( |
| 771 | 771 | 'fd' => array( |
| 772 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 773 | - 'locale' => array('type' => 'char', 'precision' => 2,'nullable' => False), |
|
| 774 | - 'name' => array('type' => 'varchar', 'precision' => 50,'nullable' => False), |
|
| 775 | - 'date_time' => array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0') |
|
| 772 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 773 | + 'locale' => array('type' => 'char', 'precision' => 2, 'nullable' => False), |
|
| 774 | + 'name' => array('type' => 'varchar', 'precision' => 50, 'nullable' => False), |
|
| 775 | + 'date_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0') |
|
| 776 | 776 | ), |
| 777 | 777 | 'pk' => array('hol_id'), |
| 778 | 778 | 'fk' => array(), |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | function calendar_upgrade0_9_11_007() |
| 790 | 790 | { |
| 791 | 791 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 792 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','mday',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 793 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','month_num',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 794 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','occurence',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 795 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','dow',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 792 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'mday', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 793 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'month_num', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 794 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'occurence', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 795 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'dow', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 796 | 796 | |
| 797 | 797 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.008'; |
| 798 | 798 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | function calendar_upgrade0_9_11_009() |
| 810 | 810 | { |
| 811 | 811 | $GLOBALS['egw_setup']->oProc->query('DELETE FROM phpgw_cal_holidays'); |
| 812 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays','observance_rule',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 812 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_holidays', 'observance_rule', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 813 | 813 | |
| 814 | 814 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.11.010'; |
| 815 | 815 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -844,7 +844,7 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | function calendar_upgrade0_9_13_002() |
| 846 | 846 | { |
| 847 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','reference',array('type' => 'int', 'precision' => 8,'nullable' => False, 'default' => '0')); |
|
| 847 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'reference', array('type' => 'int', 'precision' => 8, 'nullable' => False, 'default' => '0')); |
|
| 848 | 848 | |
| 849 | 849 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.003'; |
| 850 | 850 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_alarm', |
| 857 | 857 | Array( |
| 858 | 858 | 'fd' => array( |
| 859 | - 'alarm_id' => array('type' => 'auto','nullable' => False), |
|
| 859 | + 'alarm_id' => array('type' => 'auto', 'nullable' => False), |
|
| 860 | 860 | 'cal_id' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 861 | 861 | 'cal_owner' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
| 862 | 862 | 'cal_time' => array('type' => 'int', 'precision' => 8, 'nullable' => False), |
@@ -869,8 +869,8 @@ discard block |
||
| 869 | 869 | ) |
| 870 | 870 | ); |
| 871 | 871 | |
| 872 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','uid',array('type' => 'varchar', 'precision' => 255,'nullable' => False)); |
|
| 873 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal','location',array('type' => 'varchar', 'precision' => 255,'nullable' => True)); |
|
| 872 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'uid', array('type' => 'varchar', 'precision' => 255, 'nullable' => False)); |
|
| 873 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal', 'location', array('type' => 'varchar', 'precision' => 255, 'nullable' => True)); |
|
| 874 | 874 | |
| 875 | 875 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.004'; |
| 876 | 876 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | |
| 880 | 880 | function calendar_upgrade0_9_13_004() |
| 881 | 881 | { |
| 882 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm','alarm_enabled',array('type' => 'int', 'precision' => 4,'nullable' => False, 'default' => '1')); |
|
| 882 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_alarm', 'alarm_enabled', array('type' => 'int', 'precision' => 4, 'nullable' => False, 'default' => '1')); |
|
| 883 | 883 | |
| 884 | 884 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.005'; |
| 885 | 885 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -889,18 +889,18 @@ discard block |
||
| 889 | 889 | function calendar_upgrade0_9_13_005() |
| 890 | 890 | { |
| 891 | 891 | $calendar_data = Array(); |
| 892 | - $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal',__LINE__,__FILE__); |
|
| 893 | - while($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 892 | + $GLOBALS['egw_setup']->oProc->query('SELECT cal_id, category FROM phpgw_cal', __LINE__, __FILE__); |
|
| 893 | + while ($GLOBALS['egw_setup']->oProc->next_record()) |
|
| 894 | 894 | { |
| 895 | 895 | $calendar_data[$GLOBALS['egw_setup']->oProc->f('cal_id')] = $GLOBALS['egw_setup']->oProc->f('category'); |
| 896 | 896 | } |
| 897 | 897 | |
| 898 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','category',array('type' => 'varchar', 'precision' => 30,'nullable' => True)); |
|
| 898 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'category', array('type' => 'varchar', 'precision' => 30, 'nullable' => True)); |
|
| 899 | 899 | |
| 900 | 900 | @reset($calendar_data); |
| 901 | - while($calendar_data && list($cal_id,$category) = each($calendar_data)) |
|
| 901 | + while ($calendar_data && list($cal_id, $category) = each($calendar_data)) |
|
| 902 | 902 | { |
| 903 | - $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id,__LINE__,__FILE__); |
|
| 903 | + $GLOBALS['egw_setup']->oProc->query("UPDATE phpgw_cal SET category='".$category."' WHERE cal_id=".$cal_id, __LINE__, __FILE__); |
|
| 904 | 904 | } |
| 905 | 905 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.006'; |
| 906 | 906 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -909,7 +909,7 @@ discard block |
||
| 909 | 909 | |
| 910 | 910 | function calendar_upgrade0_9_13_006() |
| 911 | 911 | { |
| 912 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats','recur_exception',array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 912 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_repeats', 'recur_exception', array('type' => 'varchar', 'precision' => 255, 'nullable' => True, 'default' => '')); |
|
| 913 | 913 | |
| 914 | 914 | $GLOBALS['setup_info']['calendar']['currentver'] = '0.9.13.007'; |
| 915 | 915 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -919,20 +919,20 @@ discard block |
||
| 919 | 919 | |
| 920 | 920 | function calendar_upgrade0_9_13_007() |
| 921 | 921 | { |
| 922 | - $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user','cal_type',array( |
|
| 922 | + $GLOBALS['egw_setup']->oProc->AddColumn('phpgw_cal_user', 'cal_type', array( |
|
| 923 | 923 | 'type' => 'varchar', |
| 924 | 924 | 'precision' => '1', |
| 925 | 925 | 'nullable' => False, |
| 926 | 926 | 'default' => 'u' |
| 927 | 927 | )); |
| 928 | 928 | |
| 929 | - $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra',array( |
|
| 929 | + $GLOBALS['egw_setup']->oProc->CreateTable('phpgw_cal_extra', array( |
|
| 930 | 930 | 'fd' => array( |
| 931 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 932 | - 'cal_extra_name' => array('type' => 'varchar','precision' => '40','nullable' => False), |
|
| 933 | - 'cal_extra_value' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '') |
|
| 931 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 932 | + 'cal_extra_name' => array('type' => 'varchar', 'precision' => '40', 'nullable' => False), |
|
| 933 | + 'cal_extra_value' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '') |
|
| 934 | 934 | ), |
| 935 | - 'pk' => array('cal_id','cal_extra_name'), |
|
| 935 | + 'pk' => array('cal_id', 'cal_extra_name'), |
|
| 936 | 936 | 'fk' => array(), |
| 937 | 937 | 'ix' => array(), |
| 938 | 938 | 'uc' => array() |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | function calendar_upgrade0_9_16_001() |
| 950 | 950 | { |
| 951 | 951 | // this is to set the default as schema_proc was not setting an empty default |
| 952 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user','cal_type',array( |
|
| 952 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal_user', 'cal_type', array( |
|
| 953 | 953 | 'type' => 'varchar', |
| 954 | 954 | 'precision' => '1', |
| 955 | 955 | 'nullable' => False, |
@@ -966,15 +966,15 @@ discard block |
||
| 966 | 966 | |
| 967 | 967 | function calendar_upgrade0_9_16_002() |
| 968 | 968 | { |
| 969 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 969 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 970 | 970 | 'fd' => array( |
| 971 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 972 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 973 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 974 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 975 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 976 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 977 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 971 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 972 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 973 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 974 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 975 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 976 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 977 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 978 | 978 | ), |
| 979 | 979 | 'pk' => array(), |
| 980 | 980 | 'fk' => array(), |
@@ -990,14 +990,14 @@ discard block |
||
| 990 | 990 | |
| 991 | 991 | function calendar_upgrade0_9_16_003() |
| 992 | 992 | { |
| 993 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user',array( |
|
| 993 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_user', array( |
|
| 994 | 994 | 'fd' => array( |
| 995 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 996 | - 'cal_login' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 997 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A'), |
|
| 998 | - 'cal_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u') |
|
| 995 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 996 | + 'cal_login' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 997 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A'), |
|
| 998 | + 'cal_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u') |
|
| 999 | 999 | ), |
| 1000 | - 'pk' => array('cal_id','cal_login','cal_type'), |
|
| 1000 | + 'pk' => array('cal_id', 'cal_login', 'cal_type'), |
|
| 1001 | 1001 | 'fk' => array(), |
| 1002 | 1002 | 'ix' => array(), |
| 1003 | 1003 | 'uc' => array() |
@@ -1011,16 +1011,16 @@ discard block |
||
| 1011 | 1011 | |
| 1012 | 1012 | function calendar_upgrade0_9_16_004() |
| 1013 | 1013 | { |
| 1014 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays',array( |
|
| 1014 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_holidays', array( |
|
| 1015 | 1015 | 'fd' => array( |
| 1016 | - 'hol_id' => array('type' => 'auto','nullable' => False), |
|
| 1017 | - 'locale' => array('type' => 'char','precision' => '2','nullable' => False), |
|
| 1018 | - 'name' => array('type' => 'varchar','precision' => '50','nullable' => False), |
|
| 1019 | - 'mday' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1020 | - 'month_num' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1021 | - 'occurence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1022 | - 'dow' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1023 | - 'observance_rule' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1016 | + 'hol_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1017 | + 'locale' => array('type' => 'char', 'precision' => '2', 'nullable' => False), |
|
| 1018 | + 'name' => array('type' => 'varchar', 'precision' => '50', 'nullable' => False), |
|
| 1019 | + 'mday' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1020 | + 'month_num' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1021 | + 'occurence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1022 | + 'dow' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1023 | + 'observance_rule' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1024 | 1024 | ), |
| 1025 | 1025 | 'pk' => array('hol_id'), |
| 1026 | 1026 | 'fk' => array(), |
@@ -1038,13 +1038,13 @@ discard block |
||
| 1038 | 1038 | { |
| 1039 | 1039 | // creates uid's for all entries which do not have unique ones, they are '[email protected]' |
| 1040 | 1040 | // very old entries even have an empty uid, see 0.9.16.006 update |
| 1041 | - $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'",__LINE__,__FILE__); |
|
| 1041 | + $GLOBALS['egw_setup']->oProc->query("SELECT config_name,config_value FROM {$GLOBALS['egw_setup']->config_table} WHERE config_name IN ('install_id','mail_suffix') AND config_app='phpgwapi'", __LINE__, __FILE__); |
|
| 1042 | 1042 | while ($GLOBALS['egw_setup']->oProc->next_record()) |
| 1043 | 1043 | { |
| 1044 | 1044 | $config[$GLOBALS['egw_setup']->oProc->f(0)] = $GLOBALS['egw_setup']->oProc->f(1); |
| 1045 | 1045 | } |
| 1046 | 1046 | $GLOBALS['egw_setup']->oProc->query('UPDATE phpgw_cal SET uid='. |
| 1047 | - $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'),'cal_id', |
|
| 1047 | + $GLOBALS['egw_setup']->db->concat($GLOBALS['egw_setup']->db->quote('cal-'), 'cal_id', |
|
| 1048 | 1048 | $GLOBALS['egw_setup']->db->quote('-'.$config['install_id'].'@'. |
| 1049 | 1049 | ($config['mail_suffix'] ? $config['mail_suffix'] : 'local'))). |
| 1050 | 1050 | " WHERE uid LIKE '-@%' OR uid=''"); |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | function calendar_upgrade0_9_16_007() |
| 1068 | 1068 | { |
| 1069 | 1069 | // update the sequenzes for refreshed tables (postgres only) |
| 1070 | - $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays','hol_id'); |
|
| 1070 | + $GLOBALS['egw_setup']->oProc->UpdateSequence('phpgw_cal_holidays', 'hol_id'); |
|
| 1071 | 1071 | |
| 1072 | 1072 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0'; |
| 1073 | 1073 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1077,19 +1077,19 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | function calendar_upgrade1_0_0() |
| 1079 | 1079 | { |
| 1080 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','uid','cal_uid'); |
|
| 1081 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','owner','cal_owner'); |
|
| 1082 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','category','cal_category'); |
|
| 1083 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','groups','cal_groups'); |
|
| 1084 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','datetime','cal_starttime'); |
|
| 1085 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','mdatetime','cal_modified'); |
|
| 1086 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','edatetime','cal_endtime'); |
|
| 1087 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','priority','cal_priority'); |
|
| 1088 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','is_public','cal_public'); |
|
| 1089 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','title','cal_title'); |
|
| 1090 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','description','cal_description'); |
|
| 1091 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','location','cal_location'); |
|
| 1092 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal','reference','cal_reference'); |
|
| 1080 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'uid', 'cal_uid'); |
|
| 1081 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'owner', 'cal_owner'); |
|
| 1082 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'category', 'cal_category'); |
|
| 1083 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'groups', 'cal_groups'); |
|
| 1084 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'datetime', 'cal_starttime'); |
|
| 1085 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'mdatetime', 'cal_modified'); |
|
| 1086 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'edatetime', 'cal_endtime'); |
|
| 1087 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'priority', 'cal_priority'); |
|
| 1088 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'is_public', 'cal_public'); |
|
| 1089 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'title', 'cal_title'); |
|
| 1090 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'description', 'cal_description'); |
|
| 1091 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'location', 'cal_location'); |
|
| 1092 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal', 'reference', 'cal_reference'); |
|
| 1093 | 1093 | |
| 1094 | 1094 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.001'; |
| 1095 | 1095 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1099,13 +1099,13 @@ discard block |
||
| 1099 | 1099 | |
| 1100 | 1100 | function calendar_upgrade1_0_0_001() |
| 1101 | 1101 | { |
| 1102 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','locale','hol_locale'); |
|
| 1103 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','name','hol_name'); |
|
| 1104 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','mday','hol_mday'); |
|
| 1105 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','month_num','hol_month_num'); |
|
| 1106 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','occurence','hol_occurence'); |
|
| 1107 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','dow','hol_dow'); |
|
| 1108 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays','observance_rule','hol_observance_rule'); |
|
| 1102 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'locale', 'hol_locale'); |
|
| 1103 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'name', 'hol_name'); |
|
| 1104 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'mday', 'hol_mday'); |
|
| 1105 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'month_num', 'hol_month_num'); |
|
| 1106 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'occurence', 'hol_occurence'); |
|
| 1107 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'dow', 'hol_dow'); |
|
| 1108 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_holidays', 'observance_rule', 'hol_observance_rule'); |
|
| 1109 | 1109 | |
| 1110 | 1110 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.002'; |
| 1111 | 1111 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1115,8 +1115,8 @@ discard block |
||
| 1115 | 1115 | |
| 1116 | 1116 | function calendar_upgrade1_0_0_002() |
| 1117 | 1117 | { |
| 1118 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_login','cal_user_id'); |
|
| 1119 | - $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user','cal_type','cal_user_type'); |
|
| 1118 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_login', 'cal_user_id'); |
|
| 1119 | + $GLOBALS['egw_setup']->oProc->RenameColumn('phpgw_cal_user', 'cal_type', 'cal_user_type'); |
|
| 1120 | 1120 | |
| 1121 | 1121 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.0.003'; |
| 1122 | 1122 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | |
| 1127 | 1127 | function calendar_upgrade1_0_0_003() |
| 1128 | 1128 | { |
| 1129 | - $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal','cal_title',array( |
|
| 1129 | + $GLOBALS['egw_setup']->oProc->AlterColumn('phpgw_cal', 'cal_title', array( |
|
| 1130 | 1130 | 'type' => 'varchar', |
| 1131 | 1131 | 'precision' => '255', |
| 1132 | 1132 | 'nullable' => False, |
@@ -1141,15 +1141,15 @@ discard block |
||
| 1141 | 1141 | |
| 1142 | 1142 | function calendar_upgrade1_0_0_004() |
| 1143 | 1143 | { |
| 1144 | - $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats',array( |
|
| 1144 | + $GLOBALS['egw_setup']->oProc->RefreshTable('phpgw_cal_repeats', array( |
|
| 1145 | 1145 | 'fd' => array( |
| 1146 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1147 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1148 | - 'recur_use_end' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1149 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1150 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1151 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1152 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1146 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1147 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1148 | + 'recur_use_end' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1149 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1150 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1151 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1152 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1153 | 1153 | ), |
| 1154 | 1154 | 'pk' => array('cal_id'), |
| 1155 | 1155 | 'fk' => array(), |
@@ -1166,19 +1166,19 @@ discard block |
||
| 1166 | 1166 | function calendar_upgrade1_0_0_005() |
| 1167 | 1167 | { |
| 1168 | 1168 | // change prefix of all calendar tables to egw_ |
| 1169 | - foreach(array('cal_user','cal_repeats','cal_extra','cal_holidays','cal') as $name) |
|
| 1169 | + foreach (array('cal_user', 'cal_repeats', 'cal_extra', 'cal_holidays', 'cal') as $name) |
|
| 1170 | 1170 | { |
| 1171 | - $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name,'egw_'.$name); |
|
| 1171 | + $GLOBALS['egw_setup']->oProc->RenameTable('phpgw_'.$name, 'egw_'.$name); |
|
| 1172 | 1172 | } |
| 1173 | 1173 | |
| 1174 | 1174 | // create new dates table, with content from the egw_cal table |
| 1175 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates',array( |
|
| 1175 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_dates', array( |
|
| 1176 | 1176 | 'fd' => array( |
| 1177 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1178 | - 'cal_start' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1179 | - 'cal_end' => array('type' => 'int','precision' => '8','nullable' => False) |
|
| 1177 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1178 | + 'cal_start' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1179 | + 'cal_end' => array('type' => 'int', 'precision' => '8', 'nullable' => False) |
|
| 1180 | 1180 | ), |
| 1181 | - 'pk' => array('cal_id','cal_start'), |
|
| 1181 | + 'pk' => array('cal_id', 'cal_start'), |
|
| 1182 | 1182 | 'fk' => array(), |
| 1183 | 1183 | 'ix' => array(), |
| 1184 | 1184 | 'uc' => array() |
@@ -1186,49 +1186,49 @@ discard block |
||
| 1186 | 1186 | $GLOBALS['egw_setup']->oProc->query("INSERT INTO egw_cal_dates SELECT cal_id,cal_starttime,cal_endtime FROM egw_cal"); |
| 1187 | 1187 | |
| 1188 | 1188 | // drop the fields transfered to the dates table |
| 1189 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1189 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1190 | 1190 | 'fd' => array( |
| 1191 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1192 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1193 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1194 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1195 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1196 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1197 | - 'cal_endtime' => array('type' => 'int','precision' => '8'), |
|
| 1198 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1199 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1200 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1201 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1191 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1192 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1193 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1194 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1195 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1196 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1197 | + 'cal_endtime' => array('type' => 'int', 'precision' => '8'), |
|
| 1198 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1199 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1200 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1201 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1202 | 1202 | 'cal_description' => array('type' => 'text'), |
| 1203 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1204 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1203 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1204 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1205 | 1205 | ), |
| 1206 | 1206 | 'pk' => array('cal_id'), |
| 1207 | 1207 | 'fk' => array(), |
| 1208 | 1208 | 'ix' => array(), |
| 1209 | 1209 | 'uc' => array() |
| 1210 | - ),'cal_starttime'); |
|
| 1211 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1210 | + ), 'cal_starttime'); |
|
| 1211 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1212 | 1212 | 'fd' => array( |
| 1213 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1214 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1215 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1216 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1217 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1218 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1219 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1220 | - 'cal_type' => array('type' => 'varchar','precision' => '10'), |
|
| 1221 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1222 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1213 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1214 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1215 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1216 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1217 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1218 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1219 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1220 | + 'cal_type' => array('type' => 'varchar', 'precision' => '10'), |
|
| 1221 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1222 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1223 | 1223 | 'cal_description' => array('type' => 'text'), |
| 1224 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1225 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1224 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1225 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1226 | 1226 | ), |
| 1227 | 1227 | 'pk' => array('cal_id'), |
| 1228 | 1228 | 'fk' => array(), |
| 1229 | 1229 | 'ix' => array(), |
| 1230 | 1230 | 'uc' => array() |
| 1231 | - ),'cal_endtime'); |
|
| 1231 | + ), 'cal_endtime'); |
|
| 1232 | 1232 | |
| 1233 | 1233 | $GLOBALS['setup_info']['calendar']['currentver'] = '1.0.1.001'; |
| 1234 | 1234 | return $GLOBALS['setup_info']['calendar']['currentver']; |
@@ -1244,15 +1244,15 @@ discard block |
||
| 1244 | 1244 | 'precision' => '8', |
| 1245 | 1245 | 'default' => '0' |
| 1246 | 1246 | ));*/ |
| 1247 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 1247 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 1248 | 1248 | 'fd' => array( |
| 1249 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1250 | - 'cal_recur_date' => array('type' => 'int','precision' => '8','default' => '0'), |
|
| 1251 | - 'cal_user_type' => array('type' => 'varchar','precision' => '1','nullable' => False,'default' => 'u'), |
|
| 1252 | - 'cal_user_id' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0'), |
|
| 1253 | - 'cal_status' => array('type' => 'char','precision' => '1','default' => 'A') |
|
| 1249 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1250 | + 'cal_recur_date' => array('type' => 'int', 'precision' => '8', 'default' => '0'), |
|
| 1251 | + 'cal_user_type' => array('type' => 'varchar', 'precision' => '1', 'nullable' => False, 'default' => 'u'), |
|
| 1252 | + 'cal_user_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 1253 | + 'cal_status' => array('type' => 'char', 'precision' => '1', 'default' => 'A') |
|
| 1254 | 1254 | ), |
| 1255 | - 'pk' => array('cal_id','cal_recur_date','cal_user_type','cal_user_id'), |
|
| 1255 | + 'pk' => array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id'), |
|
| 1256 | 1256 | 'fk' => array(), |
| 1257 | 1257 | 'ix' => array(), |
| 1258 | 1258 | 'uc' => array() |
@@ -1266,50 +1266,50 @@ discard block |
||
| 1266 | 1266 | |
| 1267 | 1267 | function calendar_upgrade1_0_1_002() |
| 1268 | 1268 | { |
| 1269 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1269 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1270 | 1270 | 'fd' => array( |
| 1271 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1272 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1273 | - 'cal_owner' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1274 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1275 | - 'cal_groups' => array('type' => 'varchar','precision' => '255'), |
|
| 1276 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1277 | - 'cal_priority' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '2'), |
|
| 1278 | - 'cal_public' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '1'), |
|
| 1279 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1271 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1272 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1273 | + 'cal_owner' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1274 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1275 | + 'cal_groups' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1276 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1277 | + 'cal_priority' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '2'), |
|
| 1278 | + 'cal_public' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '1'), |
|
| 1279 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1280 | 1280 | 'cal_description' => array('type' => 'text'), |
| 1281 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1282 | - 'cal_reference' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0') |
|
| 1281 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1282 | + 'cal_reference' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0') |
|
| 1283 | 1283 | ), |
| 1284 | 1284 | 'pk' => array('cal_id'), |
| 1285 | 1285 | 'fk' => array(), |
| 1286 | 1286 | 'ix' => array(), |
| 1287 | 1287 | 'uc' => array() |
| 1288 | - ),'cal_type'); |
|
| 1289 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_owner',array( |
|
| 1288 | + ), 'cal_type'); |
|
| 1289 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_owner', array( |
|
| 1290 | 1290 | 'type' => 'int', |
| 1291 | 1291 | 'precision' => '4', |
| 1292 | 1292 | 'nullable' => False |
| 1293 | 1293 | )); |
| 1294 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_priority',array( |
|
| 1294 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_priority', array( |
|
| 1295 | 1295 | 'type' => 'int', |
| 1296 | 1296 | 'precision' => '2', |
| 1297 | 1297 | 'nullable' => False, |
| 1298 | 1298 | 'default' => '2' |
| 1299 | 1299 | )); |
| 1300 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_public',array( |
|
| 1300 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_public', array( |
|
| 1301 | 1301 | 'type' => 'int', |
| 1302 | 1302 | 'precision' => '2', |
| 1303 | 1303 | 'nullable' => False, |
| 1304 | 1304 | 'default' => '1' |
| 1305 | 1305 | )); |
| 1306 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_reference',array( |
|
| 1306 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_reference', array( |
|
| 1307 | 1307 | 'type' => 'int', |
| 1308 | 1308 | 'precision' => '4', |
| 1309 | 1309 | 'nullable' => False, |
| 1310 | 1310 | 'default' => '0' |
| 1311 | 1311 | )); |
| 1312 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_modifier',array( |
|
| 1312 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_modifier', array( |
|
| 1313 | 1313 | 'type' => 'int', |
| 1314 | 1314 | 'precision' => '4' |
| 1315 | 1315 | )); |
@@ -1322,36 +1322,36 @@ discard block |
||
| 1322 | 1322 | |
| 1323 | 1323 | function calendar_upgrade1_0_1_003() |
| 1324 | 1324 | { |
| 1325 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 1325 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 1326 | 1326 | 'fd' => array( |
| 1327 | - 'cal_id' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1328 | - 'recur_type' => array('type' => 'int','precision' => '8','nullable' => False), |
|
| 1329 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 1330 | - 'recur_interval' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1331 | - 'recur_data' => array('type' => 'int','precision' => '8','default' => '1'), |
|
| 1332 | - 'recur_exception' => array('type' => 'varchar','precision' => '255','default' => '') |
|
| 1327 | + 'cal_id' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1328 | + 'recur_type' => array('type' => 'int', 'precision' => '8', 'nullable' => False), |
|
| 1329 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 1330 | + 'recur_interval' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1331 | + 'recur_data' => array('type' => 'int', 'precision' => '8', 'default' => '1'), |
|
| 1332 | + 'recur_exception' => array('type' => 'varchar', 'precision' => '255', 'default' => '') |
|
| 1333 | 1333 | ), |
| 1334 | 1334 | 'pk' => array('cal_id'), |
| 1335 | 1335 | 'fk' => array(), |
| 1336 | 1336 | 'ix' => array(), |
| 1337 | 1337 | 'uc' => array() |
| 1338 | - ),'recur_use_end'); |
|
| 1339 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','cal_id',array( |
|
| 1338 | + ), 'recur_use_end'); |
|
| 1339 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'cal_id', array( |
|
| 1340 | 1340 | 'type' => 'int', |
| 1341 | 1341 | 'precision' => '4', |
| 1342 | 1342 | 'nullable' => False |
| 1343 | 1343 | )); |
| 1344 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_type',array( |
|
| 1344 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_type', array( |
|
| 1345 | 1345 | 'type' => 'int', |
| 1346 | 1346 | 'precision' => '2', |
| 1347 | 1347 | 'nullable' => False |
| 1348 | 1348 | )); |
| 1349 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_interval',array( |
|
| 1349 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_interval', array( |
|
| 1350 | 1350 | 'type' => 'int', |
| 1351 | 1351 | 'precision' => '2', |
| 1352 | 1352 | 'default' => '1' |
| 1353 | 1353 | )); |
| 1354 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_data',array( |
|
| 1354 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_data', array( |
|
| 1355 | 1355 | 'type' => 'int', |
| 1356 | 1356 | 'precision' => '2', |
| 1357 | 1357 | 'default' => '1' |
@@ -1365,13 +1365,13 @@ discard block |
||
| 1365 | 1365 | |
| 1366 | 1366 | function calendar_upgrade1_0_1_004() |
| 1367 | 1367 | { |
| 1368 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1368 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1369 | 1369 | 'type' => 'int', |
| 1370 | 1370 | 'precision' => '4', |
| 1371 | 1371 | 'nullable' => False, |
| 1372 | 1372 | 'default' => '0' |
| 1373 | 1373 | )); |
| 1374 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1374 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1375 | 1375 | 'type' => 'int', |
| 1376 | 1376 | 'precision' => '4', |
| 1377 | 1377 | 'nullable' => False, |
@@ -1386,7 +1386,7 @@ discard block |
||
| 1386 | 1386 | |
| 1387 | 1387 | function calendar_upgrade1_0_1_005() |
| 1388 | 1388 | { |
| 1389 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_quantity',array( |
|
| 1389 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1390 | 1390 | 'type' => 'int', |
| 1391 | 1391 | 'precision' => '4', |
| 1392 | 1392 | 'default' => '1' |
@@ -1400,7 +1400,7 @@ discard block |
||
| 1400 | 1400 | |
| 1401 | 1401 | function calendar_upgrade1_0_1_006() |
| 1402 | 1402 | { |
| 1403 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_non_blocking',array( |
|
| 1403 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_non_blocking', array( |
|
| 1404 | 1404 | 'type' => 'int', |
| 1405 | 1405 | 'precision' => '2', |
| 1406 | 1406 | 'default' => '0' |
@@ -1414,9 +1414,9 @@ discard block |
||
| 1414 | 1414 | |
| 1415 | 1415 | function calendar_upgrade1_0_1_007() |
| 1416 | 1416 | { |
| 1417 | - $GLOBALS['egw_setup']->db->update('egw_cal_repeats',array('recur_exception' => null),array('recur_exception' => ''),__LINE__,__FILE__,'calendar'); |
|
| 1417 | + $GLOBALS['egw_setup']->db->update('egw_cal_repeats', array('recur_exception' => null), array('recur_exception' => ''), __LINE__, __FILE__, 'calendar'); |
|
| 1418 | 1418 | |
| 1419 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats','recur_exception',array( |
|
| 1419 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_repeats', 'recur_exception', array( |
|
| 1420 | 1420 | 'type' => 'text' |
| 1421 | 1421 | )); |
| 1422 | 1422 | |
@@ -1433,11 +1433,11 @@ discard block |
||
| 1433 | 1433 | { |
| 1434 | 1434 | $customfields = array(); |
| 1435 | 1435 | $order = 0; |
| 1436 | - foreach($config_data['fields'] as $name => $data) |
|
| 1436 | + foreach ($config_data['fields'] as $name => $data) |
|
| 1437 | 1437 | { |
| 1438 | 1438 | if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
| 1439 | 1439 | { |
| 1440 | - $customfields[substr($name,1)] = array( |
|
| 1440 | + $customfields[substr($name, 1)] = array( |
|
| 1441 | 1441 | 'type' => 'text', |
| 1442 | 1442 | 'len' => $data['length'].($data['shown'] ? ','.$data['shown'] : ''), |
| 1443 | 1443 | 'label' => $data['name'], |
@@ -1460,38 +1460,38 @@ discard block |
||
| 1460 | 1460 | function calendar_upgrade1_0_1_009() |
| 1461 | 1461 | { |
| 1462 | 1462 | $db2 = clone($GLOBALS['egw_setup']->db); |
| 1463 | - $GLOBALS['egw_setup']->db->select('egw_cal','DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date',"cal_groups != ''",__LINE__,__FILE__, |
|
| 1464 | - False,'','calendar',0,',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1465 | - while(($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1463 | + $GLOBALS['egw_setup']->db->select('egw_cal', 'DISTINCT egw_cal.cal_id,cal_groups,cal_recur_date', "cal_groups != ''", __LINE__, __FILE__, |
|
| 1464 | + False, '', 'calendar', 0, ',egw_cal_user WHERE egw_cal.cal_id=egw_cal_user.cal_id'); |
|
| 1465 | + while (($row = $GLOBALS['egw_setup']->db->row(true))) |
|
| 1466 | 1466 | { |
| 1467 | 1467 | $row['cal_user_type'] = 'u'; |
| 1468 | - foreach(explode(',',$row['cal_groups']) as $group) |
|
| 1468 | + foreach (explode(',', $row['cal_groups']) as $group) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | $row['cal_user_id'] = $group; |
| 1471 | - $db2->insert('egw_cal_user',array('cal_status' => 'U'),$row,__LINE__,__FILE__,'calendar'); |
|
| 1471 | + $db2->insert('egw_cal_user', array('cal_status' => 'U'), $row, __LINE__, __FILE__, 'calendar'); |
|
| 1472 | 1472 | } |
| 1473 | 1473 | } |
| 1474 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1474 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1475 | 1475 | 'fd' => array( |
| 1476 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1477 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1478 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1479 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1480 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1481 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1482 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1483 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1476 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1477 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1478 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1479 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1480 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1481 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1482 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1483 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1484 | 1484 | 'cal_description' => array('type' => 'text'), |
| 1485 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1486 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1487 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1488 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0') |
|
| 1485 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1486 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1487 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1488 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0') |
|
| 1489 | 1489 | ), |
| 1490 | 1490 | 'pk' => array('cal_id'), |
| 1491 | 1491 | 'fk' => array(), |
| 1492 | 1492 | 'ix' => array(), |
| 1493 | 1493 | 'uc' => array() |
| 1494 | - ),'cal_groups'); |
|
| 1494 | + ), 'cal_groups'); |
|
| 1495 | 1495 | |
| 1496 | 1496 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2'; |
| 1497 | 1497 | } |
@@ -1501,7 +1501,7 @@ discard block |
||
| 1501 | 1501 | function calendar_upgrade1_2() |
| 1502 | 1502 | { |
| 1503 | 1503 | // get old alarms (saved before 1.2) working again |
| 1504 | - $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'",__LINE__,__FILE__); |
|
| 1504 | + $GLOBALS['egw_setup']->db->query("UPDATE egw_async SET async_method ='calendar.bocalupdate.send_alarm' WHERE async_method ='calendar.bocalendar.send_alarm'", __LINE__, __FILE__); |
|
| 1505 | 1505 | |
| 1506 | 1506 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.2.001'; |
| 1507 | 1507 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | |
| 1510 | 1510 | function calendar_upgrade1_2_001() |
| 1511 | 1511 | { |
| 1512 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_special',array( |
|
| 1512 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_special', array( |
|
| 1513 | 1513 | 'type' => 'int', |
| 1514 | 1514 | 'precision' => '2', |
| 1515 | 1515 | 'default' => '0' |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | |
| 1528 | 1528 | function calendar_upgrade1_4() |
| 1529 | 1529 | { |
| 1530 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_etag',array( |
|
| 1530 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_etag', array( |
|
| 1531 | 1531 | 'type' => 'int', |
| 1532 | 1532 | 'precision' => '4', |
| 1533 | 1533 | 'default' => '0' |
@@ -1539,59 +1539,59 @@ discard block |
||
| 1539 | 1539 | |
| 1540 | 1540 | function calendar_upgrade1_5() |
| 1541 | 1541 | { |
| 1542 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1542 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1543 | 1543 | 'fd' => array( |
| 1544 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1545 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1546 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1547 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1548 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1549 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1550 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1551 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1544 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1545 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1546 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1547 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1548 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1549 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1550 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1551 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1552 | 1552 | 'cal_description' => array('type' => 'text'), |
| 1553 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1554 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1555 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1556 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1557 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1558 | - 'cal_etag' => array('type' => 'int','precision' => '4'), |
|
| 1559 | - 'cal_edit_time' => array('type' => 'int','precision' => '8') |
|
| 1553 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1554 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1555 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1556 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1557 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1558 | + 'cal_etag' => array('type' => 'int', 'precision' => '4'), |
|
| 1559 | + 'cal_edit_time' => array('type' => 'int', 'precision' => '8') |
|
| 1560 | 1560 | ), |
| 1561 | 1561 | 'pk' => array('cal_id'), |
| 1562 | 1562 | 'fk' => array(), |
| 1563 | 1563 | 'ix' => array(), |
| 1564 | 1564 | 'uc' => array() |
| 1565 | - ),'cal_edit_user'); |
|
| 1566 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal',array( |
|
| 1565 | + ), 'cal_edit_user'); |
|
| 1566 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal', array( |
|
| 1567 | 1567 | 'fd' => array( |
| 1568 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 1569 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False), |
|
| 1570 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 1571 | - 'cal_category' => array('type' => 'varchar','precision' => '30'), |
|
| 1572 | - 'cal_modified' => array('type' => 'int','precision' => '8'), |
|
| 1573 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 1574 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1'), |
|
| 1575 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 1568 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1569 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False), |
|
| 1570 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 1571 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30'), |
|
| 1572 | + 'cal_modified' => array('type' => 'int', 'precision' => '8'), |
|
| 1573 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 1574 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1'), |
|
| 1575 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 1576 | 1576 | 'cal_description' => array('type' => 'text'), |
| 1577 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 1578 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0'), |
|
| 1579 | - 'cal_modifier' => array('type' => 'int','precision' => '4'), |
|
| 1580 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1581 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 1582 | - 'cal_etag' => array('type' => 'int','precision' => '4') |
|
| 1577 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 1578 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0'), |
|
| 1579 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4'), |
|
| 1580 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1581 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 1582 | + 'cal_etag' => array('type' => 'int', 'precision' => '4') |
|
| 1583 | 1583 | ), |
| 1584 | 1584 | 'pk' => array('cal_id'), |
| 1585 | 1585 | 'fk' => array(), |
| 1586 | 1586 | 'ix' => array(), |
| 1587 | 1587 | 'uc' => array() |
| 1588 | - ),'cal_edit_time'); |
|
| 1589 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_etag',array( |
|
| 1588 | + ), 'cal_edit_time'); |
|
| 1589 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_etag', array( |
|
| 1590 | 1590 | 'type' => 'int', |
| 1591 | 1591 | 'precision' => '4', |
| 1592 | 1592 | 'default' => '0' |
| 1593 | 1593 | )); |
| 1594 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL',__LINE__,__FILE__); |
|
| 1594 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_etag=0 WHERE cal_etag IS NULL', __LINE__, __FILE__); |
|
| 1595 | 1595 | |
| 1596 | 1596 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.5.001'; |
| 1597 | 1597 | } |
@@ -1599,12 +1599,12 @@ discard block |
||
| 1599 | 1599 | |
| 1600 | 1600 | function calendar_upgrade1_5_001() |
| 1601 | 1601 | { |
| 1602 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_id',array( |
|
| 1602 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_id', array( |
|
| 1603 | 1603 | 'type' => 'int', |
| 1604 | 1604 | 'precision' => '4', |
| 1605 | 1605 | 'nullable' => False |
| 1606 | 1606 | )); |
| 1607 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1607 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1608 | 1608 | 'type' => 'varchar', |
| 1609 | 1609 | 'precision' => '128', |
| 1610 | 1610 | 'nullable' => False |
@@ -1618,12 +1618,12 @@ discard block |
||
| 1618 | 1618 | { |
| 1619 | 1619 | // update the alarm methods |
| 1620 | 1620 | $async = new Api\Asyncservice(); |
| 1621 | - foreach((array)$async->read('cal:%') as $job) |
|
| 1621 | + foreach ((array)$async->read('cal:%') as $job) |
|
| 1622 | 1622 | { |
| 1623 | 1623 | if ($job['method'] == 'calendar.bocalupdate.send_alarm') |
| 1624 | 1624 | { |
| 1625 | 1625 | $job['method'] = 'calendar.calendar_boupdate.send_alarm'; |
| 1626 | - $async->write($job,true); |
|
| 1626 | + $async->write($job, true); |
|
| 1627 | 1627 | } |
| 1628 | 1628 | } |
| 1629 | 1629 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.6'; |
@@ -1640,48 +1640,48 @@ discard block |
||
| 1640 | 1640 | { |
| 1641 | 1641 | // Set UID of series exception to UID of series master |
| 1642 | 1642 | // update cal_etag, cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1643 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1643 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1644 | 1644 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1645 | 1645 | FROM egw_cal cal_ex |
| 1646 | 1646 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1647 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1647 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1648 | 1648 | { |
| 1649 | 1649 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1650 | 1650 | { |
| 1651 | 1651 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1652 | 1652 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1653 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1653 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1654 | 1654 | } |
| 1655 | 1655 | } |
| 1656 | 1656 | |
| 1657 | 1657 | // Search series exception for nearest exception in series master and add that RECURRENCE-ID |
| 1658 | 1658 | // as cal_reference (for 1.6.003 and move it to new field cal_recurrence in 1.7.001) |
| 1659 | 1659 | $diff = null; |
| 1660 | - foreach($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1660 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT egw_cal.cal_id,cal_start,recur_exception FROM egw_cal |
|
| 1661 | 1661 | JOIN egw_cal_dates ON egw_cal.cal_id=egw_cal_dates.cal_id |
| 1662 | 1662 | JOIN egw_cal_repeats ON cal_reference=egw_cal_repeats.cal_id |
| 1663 | - WHERE cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1663 | + WHERE cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1664 | 1664 | { |
| 1665 | 1665 | $recurrence = null; |
| 1666 | - foreach(explode(',',$row['recur_exception']) as $ts) |
|
| 1666 | + foreach (explode(',', $row['recur_exception']) as $ts) |
|
| 1667 | 1667 | { |
| 1668 | - if (is_null($recurrence) || abs($ts-$row['cal_start']) < $diff) |
|
| 1668 | + if (is_null($recurrence) || abs($ts - $row['cal_start']) < $diff) |
|
| 1669 | 1669 | { |
| 1670 | 1670 | $recurrence = $ts; |
| 1671 | - $diff = abs($ts-$row['cal_start']); |
|
| 1671 | + $diff = abs($ts - $row['cal_start']); |
|
| 1672 | 1672 | } |
| 1673 | 1673 | } |
| 1674 | 1674 | if ($recurrence) |
| 1675 | 1675 | { |
| 1676 | 1676 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$recurrence. |
| 1677 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1677 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1678 | 1678 | } |
| 1679 | 1679 | else |
| 1680 | 1680 | { |
| 1681 | 1681 | // if we cannot determine the RECURRENCE-ID use cal_start |
| 1682 | 1682 | // because RECURRENCE-ID must be present |
| 1683 | 1683 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_reference='.(int)$row['cal_start']. |
| 1684 | - ' WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1684 | + ' WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1685 | 1685 | } |
| 1686 | 1686 | } |
| 1687 | 1687 | |
@@ -1696,33 +1696,33 @@ discard block |
||
| 1696 | 1696 | */ |
| 1697 | 1697 | function calendar_upgrade1_6_003() |
| 1698 | 1698 | { |
| 1699 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_creator',array( |
|
| 1699 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_creator', array( |
|
| 1700 | 1700 | 'type' => 'int', |
| 1701 | 1701 | 'precision' => '4', |
| 1702 | 1702 | 'comment' => 'creating user' |
| 1703 | 1703 | )); |
| 1704 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner',__LINE__,__FILE__); |
|
| 1705 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_creator',array( |
|
| 1704 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_creator=cal_owner', __LINE__, __FILE__); |
|
| 1705 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_creator', array( |
|
| 1706 | 1706 | 'type' => 'int', |
| 1707 | 1707 | 'precision' => '4', |
| 1708 | 1708 | 'nullable' => False, |
| 1709 | 1709 | 'comment' => 'creating user' |
| 1710 | 1710 | )); |
| 1711 | 1711 | |
| 1712 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_created',array( |
|
| 1712 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_created', array( |
|
| 1713 | 1713 | 'type' => 'int', |
| 1714 | 1714 | 'precision' => '8', |
| 1715 | 1715 | 'comment' => 'creation time of event' |
| 1716 | 1716 | )); |
| 1717 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified',__LINE__,__FILE__); |
|
| 1718 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_created',array( |
|
| 1717 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_created=cal_modified', __LINE__, __FILE__); |
|
| 1718 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_created', array( |
|
| 1719 | 1719 | 'type' => 'int', |
| 1720 | 1720 | 'precision' => '8', |
| 1721 | 1721 | 'nullable' => False, |
| 1722 | 1722 | 'comment' => 'creation time of event' |
| 1723 | 1723 | )); |
| 1724 | 1724 | |
| 1725 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_recurrence',array( |
|
| 1725 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_recurrence', array( |
|
| 1726 | 1726 | 'type' => 'int', |
| 1727 | 1727 | 'precision' => '8', |
| 1728 | 1728 | 'nullable' => False, |
@@ -1733,14 +1733,14 @@ discard block |
||
| 1733 | 1733 | // move RECURRENCE-ID from temporarily (1.6.003) |
| 1734 | 1734 | // used field cal_reference to new field cal_recurrence |
| 1735 | 1735 | // and restore cal_reference field of series exceptions with id of the series master |
| 1736 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1736 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1737 | 1737 | SELECT cal_ex.cal_id AS cal_id_ex,cal_master.cal_id AS cal_id_master, |
| 1738 | 1738 | cal_ex.cal_reference AS cal_reference_ex,cal_ex.cal_uid AS cal_uid_ex, |
| 1739 | 1739 | cal_master.cal_uid AS cal_uid_master |
| 1740 | 1740 | FROM egw_cal cal_ex |
| 1741 | 1741 | JOIN egw_cal cal_master |
| 1742 | 1742 | ON cal_ex.cal_uid=cal_master.cal_uid AND cal_master.cal_reference = 0 AND cal_ex.cal_owner = cal_master.cal_owner |
| 1743 | - WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__,__FILE__) as $row) |
|
| 1743 | + WHERE cal_ex.cal_reference !=0 AND cal_master.cal_id IS NOT NULL',__LINE__, __FILE__) as $row) |
|
| 1744 | 1744 | { |
| 1745 | 1745 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_recurrence='.(int)$row['cal_reference_ex']. |
| 1746 | 1746 | ', cal_reference='.(int)$row['cal_id_master']. |
@@ -1757,7 +1757,7 @@ discard block |
||
| 1757 | 1757 | */ |
| 1758 | 1758 | function calendar_upgrade1_7_001() |
| 1759 | 1759 | { |
| 1760 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_role',array( |
|
| 1760 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_role', array( |
|
| 1761 | 1761 | 'type' => 'varchar', |
| 1762 | 1762 | 'precision' => '64', |
| 1763 | 1763 | 'default' => 'REQ-PARTICIPANT' |
@@ -1773,14 +1773,14 @@ discard block |
||
| 1773 | 1773 | */ |
| 1774 | 1774 | function calendar_upgrade1_7_002() |
| 1775 | 1775 | { |
| 1776 | - $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones',array( |
|
| 1776 | + $GLOBALS['egw_setup']->oProc->CreateTable('egw_cal_timezones', array( |
|
| 1777 | 1777 | 'fd' => array( |
| 1778 | - 'tz_id' => array('type' => 'auto','nullable' => False), |
|
| 1779 | - 'tz_tzid' => array('type' => 'varchar','precision' => '128','nullable' => False), |
|
| 1780 | - 'tz_alias' => array('type' => 'int','precision' => '4','comment' => 'tz_id for data'), |
|
| 1781 | - 'tz_latitude' => array('type' => 'int','precision' => '4'), |
|
| 1782 | - 'tz_longitude' => array('type' => 'int','precision' => '4'), |
|
| 1783 | - 'tz_component' => array('type' => 'text','comment' => 'iCal VTIMEZONE component') |
|
| 1778 | + 'tz_id' => array('type' => 'auto', 'nullable' => False), |
|
| 1779 | + 'tz_tzid' => array('type' => 'varchar', 'precision' => '128', 'nullable' => False), |
|
| 1780 | + 'tz_alias' => array('type' => 'int', 'precision' => '4', 'comment' => 'tz_id for data'), |
|
| 1781 | + 'tz_latitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1782 | + 'tz_longitude' => array('type' => 'int', 'precision' => '4'), |
|
| 1783 | + 'tz_component' => array('type' => 'text', 'comment' => 'iCal VTIMEZONE component') |
|
| 1784 | 1784 | ), |
| 1785 | 1785 | 'pk' => array('tz_id'), |
| 1786 | 1786 | 'fk' => array(), |
@@ -1800,38 +1800,38 @@ discard block |
||
| 1800 | 1800 | */ |
| 1801 | 1801 | function calendar_upgrade1_7_003() |
| 1802 | 1802 | { |
| 1803 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_type',array( |
|
| 1803 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_type', array( |
|
| 1804 | 1804 | 'type' => 'varchar', |
| 1805 | 1805 | 'precision' => '1', |
| 1806 | 1806 | 'nullable' => False, |
| 1807 | 1807 | 'default' => 'u', |
| 1808 | 1808 | 'comment' => 'u=user, g=group, c=contact, r=resource, e=email' |
| 1809 | 1809 | )); |
| 1810 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 1810 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 1811 | 1811 | 'type' => 'varchar', |
| 1812 | 1812 | 'precision' => '128', |
| 1813 | 1813 | 'nullable' => False, |
| 1814 | 1814 | 'comment' => 'id or email-address for type=e' |
| 1815 | 1815 | )); |
| 1816 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_status',array( |
|
| 1816 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_status', array( |
|
| 1817 | 1817 | 'type' => 'char', |
| 1818 | 1818 | 'precision' => '1', |
| 1819 | 1819 | 'default' => 'A', |
| 1820 | 1820 | 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative' |
| 1821 | 1821 | )); |
| 1822 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_quantity',array( |
|
| 1822 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_quantity', array( |
|
| 1823 | 1823 | 'type' => 'int', |
| 1824 | 1824 | 'precision' => '4', |
| 1825 | 1825 | 'default' => '1', |
| 1826 | 1826 | 'comment' => 'only for certain types (eg. resources)' |
| 1827 | 1827 | )); |
| 1828 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_role',array( |
|
| 1828 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_role', array( |
|
| 1829 | 1829 | 'type' => 'varchar', |
| 1830 | 1830 | 'precision' => '64', |
| 1831 | 1831 | 'default' => 'REQ-PARTICIPANT', |
| 1832 | 1832 | 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id' |
| 1833 | 1833 | )); |
| 1834 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_modified',array( |
|
| 1834 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_modified', array( |
|
| 1835 | 1835 | 'type' => 'timestamp', |
| 1836 | 1836 | 'default' => 'current_timestamp', |
| 1837 | 1837 | 'comment' => 'automatic timestamp of last update' |
@@ -1847,19 +1847,19 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | function calendar_upgrade1_7_004() |
| 1849 | 1849 | { |
| 1850 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_start',array( |
|
| 1850 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_start', array( |
|
| 1851 | 1851 | 'type' => 'int', |
| 1852 | 1852 | 'precision' => '8', |
| 1853 | 1853 | 'nullable' => False, |
| 1854 | 1854 | 'comment' => 'starttime in server time' |
| 1855 | 1855 | )); |
| 1856 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates','cal_end',array( |
|
| 1856 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_dates', 'cal_end', array( |
|
| 1857 | 1857 | 'type' => 'int', |
| 1858 | 1858 | 'precision' => '8', |
| 1859 | 1859 | 'nullable' => False, |
| 1860 | 1860 | 'comment' => 'endtime in server time' |
| 1861 | 1861 | )); |
| 1862 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','tz_id',array( |
|
| 1862 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'tz_id', array( |
|
| 1863 | 1863 | 'type' => 'int', |
| 1864 | 1864 | 'precision' => '4', |
| 1865 | 1865 | 'comment' => 'key into egw_cal_timezones' |
@@ -1868,7 +1868,7 @@ discard block |
||
| 1868 | 1868 | // set id of server timezone for existing events, as that's the timezone their recurrences are using |
| 1869 | 1869 | if (($tzid = date_default_timezone_get()) && ($tz_id = calendar_timezones::tz2id($tzid))) |
| 1870 | 1870 | { |
| 1871 | - $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id,__LINE__,__FILE__); |
|
| 1871 | + $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET tz_id='.(int)$tz_id, __LINE__, __FILE__); |
|
| 1872 | 1872 | } |
| 1873 | 1873 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.005'; |
| 1874 | 1874 | } |
@@ -1895,22 +1895,22 @@ discard block |
||
| 1895 | 1895 | */ |
| 1896 | 1896 | function calendar_upgrade1_7_006() |
| 1897 | 1897 | { |
| 1898 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1899 | - WHERE (cal_end-cal_start)%86400=86340',__LINE__,__FILE__) as $row) |
|
| 1898 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1899 | + WHERE (cal_end-cal_start)%86400=86340',__LINE__, __FILE__) as $row) |
|
| 1900 | 1900 | { |
| 1901 | 1901 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end+59 |
| 1902 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1902 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | - foreach($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1906 | - WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__,__FILE__) as $row) |
|
| 1905 | + foreach ($GLOBALS['egw_setup']->db->query('SELECT * FROM egw_cal_dates |
|
| 1906 | + WHERE cal_end-cal_start>0 AND (cal_end-cal_start)%86400=0',__LINE__, __FILE__) as $row) |
|
| 1907 | 1907 | { |
| 1908 | 1908 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_dates SET cal_end=cal_end-1 |
| 1909 | - WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'],__LINE__,__FILE__); |
|
| 1909 | + WHERE cal_id='.(int)$row['cal_id'].' AND cal_start='.(int)$row['cal_start'], __LINE__, __FILE__); |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal_repeats SET recur_interval=1 |
| 1913 | - WHERE recur_interval=0',__LINE__,__FILE__); |
|
| 1913 | + WHERE recur_interval=0',__LINE__, __FILE__); |
|
| 1914 | 1914 | |
| 1915 | 1915 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.007'; |
| 1916 | 1916 | } |
@@ -1926,17 +1926,17 @@ discard block |
||
| 1926 | 1926 | { |
| 1927 | 1927 | // Set UID of series exception to UID of series master |
| 1928 | 1928 | // update cal_etag,cal_modified and cal_modifier to distribute changes on GroupDAV devices |
| 1929 | - foreach($GLOBALS['egw_setup']->db->query(' |
|
| 1929 | + foreach ($GLOBALS['egw_setup']->db->query(' |
|
| 1930 | 1930 | SELECT cal_ex.cal_id,cal_ex.cal_uid AS cal_uid_ex,cal_master.cal_uid AS cal_uid_master |
| 1931 | 1931 | FROM egw_cal cal_ex |
| 1932 | 1932 | JOIN egw_cal cal_master ON cal_ex.cal_reference=cal_master.cal_id |
| 1933 | - WHERE cal_ex.cal_reference != 0',__LINE__,__FILE__) as $row) |
|
| 1933 | + WHERE cal_ex.cal_reference != 0',__LINE__, __FILE__) as $row) |
|
| 1934 | 1934 | { |
| 1935 | 1935 | if (strlen($row['cal_uid_master']) > 0 && $row['cal_uid_ex'] != $row['cal_uid_master']) |
| 1936 | 1936 | { |
| 1937 | 1937 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET cal_uid=\''.$row['cal_uid_master']. |
| 1938 | 1938 | '\',cal_etag=cal_etag+1,cal_modified='.time(). |
| 1939 | - ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'],__LINE__,__FILE__); |
|
| 1939 | + ',cal_modifier=NULL WHERE cal_id='.(int)$row['cal_id'], __LINE__, __FILE__); |
|
| 1940 | 1940 | } |
| 1941 | 1941 | } |
| 1942 | 1942 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.008'; |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | */ |
| 1950 | 1950 | function calendar_upgrade1_7_008() |
| 1951 | 1951 | { |
| 1952 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user',array('cal_user_type','cal_user_id')); |
|
| 1952 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', array('cal_user_type', 'cal_user_id')); |
|
| 1953 | 1953 | |
| 1954 | 1954 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.009'; |
| 1955 | 1955 | } |
@@ -1961,22 +1961,22 @@ discard block |
||
| 1961 | 1961 | */ |
| 1962 | 1962 | function calendar_upgrade1_7_009() |
| 1963 | 1963 | { |
| 1964 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_uid'); |
|
| 1965 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_owner'); |
|
| 1964 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_uid'); |
|
| 1965 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_owner'); |
|
| 1966 | 1966 | |
| 1967 | 1967 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.7.010'; |
| 1968 | 1968 | } |
| 1969 | 1969 | |
| 1970 | 1970 | function calendar_upgrade1_7_010() |
| 1971 | 1971 | { |
| 1972 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','cal_deleted',array( |
|
| 1972 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'cal_deleted', array( |
|
| 1973 | 1973 | 'type' => 'bool', |
| 1974 | 1974 | 'nullable' => False, |
| 1975 | 1975 | 'default' => '0', |
| 1976 | 1976 | 'comment' => '1 if the event has been deleted, but you want to keep it around' |
| 1977 | 1977 | )); |
| 1978 | 1978 | |
| 1979 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1979 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.001'; // was 1.7.011 |
|
| 1980 | 1980 | } |
| 1981 | 1981 | |
| 1982 | 1982 | function calendar_upgrade1_7_011() |
@@ -2006,36 +2006,36 @@ discard block |
||
| 2006 | 2006 | 'precision' => '8', |
| 2007 | 2007 | 'comment' => 'ts when event was deleted' |
| 2008 | 2008 | ));*/ |
| 2009 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal',array( |
|
| 2009 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal', array( |
|
| 2010 | 2010 | 'fd' => array( |
| 2011 | - 'cal_id' => array('type' => 'auto','nullable' => False), |
|
| 2012 | - 'cal_uid' => array('type' => 'varchar','precision' => '255','nullable' => False,'comment' => 'unique id of event(-series)'), |
|
| 2013 | - 'cal_owner' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'event owner / calendar'), |
|
| 2014 | - 'cal_category' => array('type' => 'varchar','precision' => '30','comment' => 'category id'), |
|
| 2015 | - 'cal_modified' => array('type' => 'int','precision' => '8','comment' => 'ts of last modification'), |
|
| 2016 | - 'cal_priority' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '2'), |
|
| 2017 | - 'cal_public' => array('type' => 'int','precision' => '2','nullable' => False,'default' => '1','comment' => '1=public, 0=private event'), |
|
| 2018 | - 'cal_title' => array('type' => 'varchar','precision' => '255','nullable' => False,'default' => '1'), |
|
| 2011 | + 'cal_id' => array('type' => 'auto', 'nullable' => False), |
|
| 2012 | + 'cal_uid' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'comment' => 'unique id of event(-series)'), |
|
| 2013 | + 'cal_owner' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'event owner / calendar'), |
|
| 2014 | + 'cal_category' => array('type' => 'varchar', 'precision' => '30', 'comment' => 'category id'), |
|
| 2015 | + 'cal_modified' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts of last modification'), |
|
| 2016 | + 'cal_priority' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '2'), |
|
| 2017 | + 'cal_public' => array('type' => 'int', 'precision' => '2', 'nullable' => False, 'default' => '1', 'comment' => '1=public, 0=private event'), |
|
| 2018 | + 'cal_title' => array('type' => 'varchar', 'precision' => '255', 'nullable' => False, 'default' => '1'), |
|
| 2019 | 2019 | 'cal_description' => array('type' => 'text'), |
| 2020 | - 'cal_location' => array('type' => 'varchar','precision' => '255'), |
|
| 2021 | - 'cal_reference' => array('type' => 'int','precision' => '4','nullable' => False,'default' => '0','comment' => 'cal_id of series for exception'), |
|
| 2022 | - 'cal_modifier' => array('type' => 'int','precision' => '4','comment' => 'user who last modified event'), |
|
| 2023 | - 'cal_non_blocking' => array('type' => 'int','precision' => '2','default' => '0','comment' => '1 for non-blocking events'), |
|
| 2024 | - 'cal_special' => array('type' => 'int','precision' => '2','default' => '0'), |
|
| 2025 | - 'cal_etag' => array('type' => 'int','precision' => '4','default' => '0','comment' => 'etag for optimistic locking'), |
|
| 2026 | - 'cal_creator' => array('type' => 'int','precision' => '4','nullable' => False,'comment' => 'creating user'), |
|
| 2027 | - 'cal_created' => array('type' => 'int','precision' => '8','nullable' => False,'comment' => 'creation time of event'), |
|
| 2028 | - 'cal_recurrence' => array('type' => 'int','precision' => '8','nullable' => False,'default' => '0','comment' => 'cal_start of original recurrence for exception'), |
|
| 2029 | - 'tz_id' => array('type' => 'int','precision' => '4','comment' => 'key into egw_cal_timezones'), |
|
| 2030 | - 'cal_deleted' => array('type' => 'int','precision' => '8','comment' => 'ts when event was deleted') |
|
| 2020 | + 'cal_location' => array('type' => 'varchar', 'precision' => '255'), |
|
| 2021 | + 'cal_reference' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'default' => '0', 'comment' => 'cal_id of series for exception'), |
|
| 2022 | + 'cal_modifier' => array('type' => 'int', 'precision' => '4', 'comment' => 'user who last modified event'), |
|
| 2023 | + 'cal_non_blocking' => array('type' => 'int', 'precision' => '2', 'default' => '0', 'comment' => '1 for non-blocking events'), |
|
| 2024 | + 'cal_special' => array('type' => 'int', 'precision' => '2', 'default' => '0'), |
|
| 2025 | + 'cal_etag' => array('type' => 'int', 'precision' => '4', 'default' => '0', 'comment' => 'etag for optimistic locking'), |
|
| 2026 | + 'cal_creator' => array('type' => 'int', 'precision' => '4', 'nullable' => False, 'comment' => 'creating user'), |
|
| 2027 | + 'cal_created' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'comment' => 'creation time of event'), |
|
| 2028 | + 'cal_recurrence' => array('type' => 'int', 'precision' => '8', 'nullable' => False, 'default' => '0', 'comment' => 'cal_start of original recurrence for exception'), |
|
| 2029 | + 'tz_id' => array('type' => 'int', 'precision' => '4', 'comment' => 'key into egw_cal_timezones'), |
|
| 2030 | + 'cal_deleted' => array('type' => 'int', 'precision' => '8', 'comment' => 'ts when event was deleted') |
|
| 2031 | 2031 | ), |
| 2032 | 2032 | 'pk' => array('cal_id'), |
| 2033 | 2033 | 'fk' => array(), |
| 2034 | - 'ix' => array('cal_uid','cal_owner','cal_deleted'), |
|
| 2034 | + 'ix' => array('cal_uid', 'cal_owner', 'cal_deleted'), |
|
| 2035 | 2035 | 'uc' => array() |
| 2036 | - ),array( |
|
| 2036 | + ), array( |
|
| 2037 | 2037 | // for deleted rows use cal_modified as deleted date, NULL for not deleted ones |
| 2038 | - 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN cal_modified ELSE NULL END', |
|
| 2038 | + 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true, 'bool').' THEN cal_modified ELSE NULL END', |
|
| 2039 | 2039 | )); |
| 2040 | 2040 | |
| 2041 | 2041 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.002'; |
@@ -2047,16 +2047,16 @@ discard block |
||
| 2047 | 2047 | */ |
| 2048 | 2048 | function calendar_upgrade1_9_002() |
| 2049 | 2049 | { |
| 2050 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','caldav_name',array( |
|
| 2050 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'caldav_name', array( |
|
| 2051 | 2051 | 'type' => 'varchar', |
| 2052 | 2052 | 'precision' => '64', |
| 2053 | 2053 | 'comment' => 'name part of CalDAV URL, if specified by client' |
| 2054 | 2054 | )); |
| 2055 | - $GLOBALS['egw_setup']->db->query($sql='UPDATE egw_cal SET caldav_name='. |
|
| 2055 | + $GLOBALS['egw_setup']->db->query($sql = 'UPDATE egw_cal SET caldav_name='. |
|
| 2056 | 2056 | $GLOBALS['egw_setup']->db->concat( |
| 2057 | - $GLOBALS['egw_setup']->db->to_varchar('cal_id'),"'.ics'"),__LINE__,__FILE__); |
|
| 2057 | + $GLOBALS['egw_setup']->db->to_varchar('cal_id'), "'.ics'"), __LINE__, __FILE__); |
|
| 2058 | 2058 | |
| 2059 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','caldav_name'); |
|
| 2059 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'caldav_name'); |
|
| 2060 | 2060 | |
| 2061 | 2061 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.003'; |
| 2062 | 2062 | } |
@@ -2067,8 +2067,8 @@ discard block |
||
| 2067 | 2067 | */ |
| 2068 | 2068 | function calendar_upgrade1_9_003() |
| 2069 | 2069 | { |
| 2070 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal','cal_modified'); |
|
| 2071 | - $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user','cal_user_modified'); |
|
| 2070 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal', 'cal_modified'); |
|
| 2071 | + $GLOBALS['egw_setup']->oProc->CreateIndex('egw_cal_user', 'cal_user_modified'); |
|
| 2072 | 2072 | |
| 2073 | 2073 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.004'; |
| 2074 | 2074 | } |
@@ -2080,7 +2080,7 @@ discard block |
||
| 2080 | 2080 | */ |
| 2081 | 2081 | function calendar_upgrade1_9_004() |
| 2082 | 2082 | { |
| 2083 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates','recur_exception',array( |
|
| 2083 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_dates', 'recur_exception', array( |
|
| 2084 | 2084 | 'type' => 'bool', |
| 2085 | 2085 | 'default' => '', |
| 2086 | 2086 | 'null' => false, |
@@ -2088,16 +2088,16 @@ discard block |
||
| 2088 | 2088 | )); |
| 2089 | 2089 | |
| 2090 | 2090 | // migrate existing exceptions to egw_cal_dates |
| 2091 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2091 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_repeats', |
|
| 2092 | 2092 | 'egw_cal_repeats.cal_id AS cal_id,egw_cal_repeats.recur_exception AS recur_exception,MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end', |
| 2093 | 2093 | 'egw_cal_repeats.recur_exception IS NOT NULL', __LINE__, __FILE__, false, |
| 2094 | 2094 | 'GROUP BY egw_cal_repeats.cal_id,egw_cal_repeats.recur_exception', 'calendar', '', |
| 2095 | 2095 | 'JOIN egw_cal_dates ON egw_cal_repeats.cal_id=egw_cal_dates.cal_id') as $row) |
| 2096 | 2096 | { |
| 2097 | - foreach($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2097 | + foreach ($row['recur_exception'] ? array_unique(explode(',', $row['recur_exception'])) : array() as $recur_exception) |
|
| 2098 | 2098 | { |
| 2099 | 2099 | $GLOBALS['egw_setup']->db->insert('egw_cal_dates', array( |
| 2100 | - 'cal_end' => $recur_exception+$row['cal_end']-$row['cal_start'], |
|
| 2100 | + 'cal_end' => $recur_exception + $row['cal_end'] - $row['cal_start'], |
|
| 2101 | 2101 | 'recur_exception' => true, |
| 2102 | 2102 | ), array( |
| 2103 | 2103 | 'cal_id' => $row['cal_id'], |
@@ -2109,11 +2109,11 @@ discard block |
||
| 2109 | 2109 | |
| 2110 | 2110 | $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
| 2111 | 2111 | 'fd' => array( |
| 2112 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2113 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2114 | - 'recur_enddate' => array('type' => 'int','precision' => '8'), |
|
| 2115 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2116 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2112 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2113 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2114 | + 'recur_enddate' => array('type' => 'int', 'precision' => '8'), |
|
| 2115 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2116 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2117 | 2117 | ), |
| 2118 | 2118 | 'pk' => array('cal_id'), |
| 2119 | 2119 | 'fk' => array(), |
@@ -2134,19 +2134,19 @@ discard block |
||
| 2134 | 2134 | // returns NULL, if there are no rows! |
| 2135 | 2135 | if ((int)$max_description_length <= 16384 && $GLOBALS['egw_setup']->oProc->max_varchar_length >= 16384) |
| 2136 | 2136 | { |
| 2137 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_description',array( |
|
| 2137 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_description', array( |
|
| 2138 | 2138 | 'type' => 'varchar', |
| 2139 | 2139 | 'precision' => '16384' |
| 2140 | 2140 | )); |
| 2141 | 2141 | } |
| 2142 | 2142 | // allow more categories |
| 2143 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2143 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2144 | 2144 | 'type' => 'varchar', |
| 2145 | 2145 | 'precision' => '64', |
| 2146 | 2146 | 'comment' => 'category id(s)' |
| 2147 | 2147 | )); |
| 2148 | 2148 | // remove silly default of 1 |
| 2149 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_title',array( |
|
| 2149 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_title', array( |
|
| 2150 | 2150 | 'type' => 'varchar', |
| 2151 | 2151 | 'precision' => '255', |
| 2152 | 2152 | 'nullable' => False |
@@ -2161,14 +2161,14 @@ discard block |
||
| 2161 | 2161 | { |
| 2162 | 2162 | // PostgreSQL needs temporary a nullable column, to not stall on broken events without dates! |
| 2163 | 2163 | // We add that constrain in 1.9.007, after deleting all rows with range_start=0 OR range_start IS NULL |
| 2164 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_start',array( |
|
| 2164 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_start', array( |
|
| 2165 | 2165 | 'type' => 'int', |
| 2166 | 2166 | 'precision' => '8', |
| 2167 | 2167 | 'comment' => 'startdate (of range)' |
| 2168 | 2168 | )); |
| 2169 | 2169 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_start = (SELECT MIN(cal_start) FROM egw_cal_dates WHERE egw_cal_dates.cal_id=egw_cal.cal_id)', __LINE__, __FILE__); |
| 2170 | 2170 | |
| 2171 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal','range_end',array( |
|
| 2171 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal', 'range_end', array( |
|
| 2172 | 2172 | 'type' => 'int', |
| 2173 | 2173 | 'precision' => '8', |
| 2174 | 2174 | 'comment' => 'enddate (of range, UNTIL of RRULE)' |
@@ -2184,18 +2184,18 @@ discard block |
||
| 2184 | 2184 | { |
| 2185 | 2185 | $GLOBALS['egw_setup']->db->query('UPDATE egw_cal SET range_end=recur_enddate FROM egw_cal_repeats WHERE egw_cal.cal_id=egw_cal_repeats.cal_id', __LINE__, __FILE__); |
| 2186 | 2186 | } |
| 2187 | - $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats',array( |
|
| 2187 | + $GLOBALS['egw_setup']->oProc->DropColumn('egw_cal_repeats', array( |
|
| 2188 | 2188 | 'fd' => array( |
| 2189 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2190 | - 'recur_type' => array('type' => 'int','precision' => '2','nullable' => False), |
|
| 2191 | - 'recur_interval' => array('type' => 'int','precision' => '2','default' => '1'), |
|
| 2192 | - 'recur_data' => array('type' => 'int','precision' => '2','default' => '1') |
|
| 2189 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2190 | + 'recur_type' => array('type' => 'int', 'precision' => '2', 'nullable' => False), |
|
| 2191 | + 'recur_interval' => array('type' => 'int', 'precision' => '2', 'default' => '1'), |
|
| 2192 | + 'recur_data' => array('type' => 'int', 'precision' => '2', 'default' => '1') |
|
| 2193 | 2193 | ), |
| 2194 | 2194 | 'pk' => array('cal_id'), |
| 2195 | 2195 | 'fk' => array(), |
| 2196 | 2196 | 'ix' => array(), |
| 2197 | 2197 | 'uc' => array() |
| 2198 | - ),'recur_enddate'); |
|
| 2198 | + ), 'recur_enddate'); |
|
| 2199 | 2199 | |
| 2200 | 2200 | return $GLOBALS['setup_info']['calendar']['currentver'] = '1.9.007'; |
| 2201 | 2201 | } |
@@ -2207,14 +2207,14 @@ discard block |
||
| 2207 | 2207 | */ |
| 2208 | 2208 | function calendar_upgrade1_9_007() |
| 2209 | 2209 | { |
| 2210 | - foreach(array('egw_cal_repeats','egw_cal_dates','egw_cal_user','egw_cal_extra') as $table) |
|
| 2210 | + foreach (array('egw_cal_repeats', 'egw_cal_dates', 'egw_cal_user', 'egw_cal_extra') as $table) |
|
| 2211 | 2211 | { |
| 2212 | 2212 | $GLOBALS['egw_setup']->db->query("DELETE FROM $table WHERE cal_id IN (SELECT cal_id FROM egw_cal WHERE range_start=0 OR range_start IS NULL)", __LINE__, __FILE__); |
| 2213 | 2213 | } |
| 2214 | 2214 | $GLOBALS['egw_setup']->db->query("DELETE FROM egw_cal WHERE range_start=0 OR range_start IS NULL", __LINE__, __FILE__); |
| 2215 | 2215 | |
| 2216 | 2216 | // now we can remove temporary default of 0 from range_start and set it NOT NULL |
| 2217 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','range_start',array( |
|
| 2217 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'range_start', array( |
|
| 2218 | 2218 | 'type' => 'int', |
| 2219 | 2219 | 'precision' => '8', |
| 2220 | 2220 | 'nullable' => False, |
@@ -2279,7 +2279,7 @@ discard block |
||
| 2279 | 2279 | |
| 2280 | 2280 | function calendar_upgrade1_9_010() |
| 2281 | 2281 | { |
| 2282 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2282 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2283 | 2283 | 'type' => 'varchar', |
| 2284 | 2284 | 'precision' => '200', |
| 2285 | 2285 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2309,7 +2309,7 @@ discard block |
||
| 2309 | 2309 | SET cal_reference=0,cal_recurrence=0,cal_etag=cal_etag+1,cal_modifier=0,cal_modified=".time()." |
| 2310 | 2310 | WHERE cal_reference != 0 AND cal_id IN (SELECT cal_id FROM egw_cal_repeats)", __LINE__, __FILE__); |
| 2311 | 2311 | |
| 2312 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2312 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2313 | 2313 | "SELECT DISTINCT master.cal_id,egw_cal_user.cal_user_type,egw_cal_user.cal_user_id,'E' AS cal_status |
| 2314 | 2314 | FROM egw_cal_user |
| 2315 | 2315 | JOIN egw_cal ON egw_cal_user.cal_id=egw_cal.cal_id |
@@ -2336,7 +2336,7 @@ discard block |
||
| 2336 | 2336 | */ |
| 2337 | 2337 | function calendar_upgrade14_1_001() |
| 2338 | 2338 | { |
| 2339 | - foreach($GLOBALS['egw_setup']->db->query( |
|
| 2339 | + foreach ($GLOBALS['egw_setup']->db->query( |
|
| 2340 | 2340 | "SELECT egw_cal.cal_id AS cal_id,cal_start,cal_end,range_start,range_end,egw_cal_repeats.*,tz_tzid AS tzid |
| 2341 | 2341 | FROM egw_cal |
| 2342 | 2342 | JOIN egw_cal_repeats ON egw_cal_repeats.cal_id=egw_cal.cal_id |
@@ -2364,7 +2364,7 @@ discard block |
||
| 2364 | 2364 | $enddate->modify(($event['end'] - $event['start']).' second'); |
| 2365 | 2365 | if (($range_end = $enddate->format('server')) != $event['range_end']) |
| 2366 | 2366 | { |
| 2367 | - $GLOBALS['egw_setup']->db->update('egw_cal',array( |
|
| 2367 | + $GLOBALS['egw_setup']->db->update('egw_cal', array( |
|
| 2368 | 2368 | 'range_end' => $range_end, |
| 2369 | 2369 | 'cal_etag=cal_etag+1', |
| 2370 | 2370 | 'cal_modified' => time(), |
@@ -2374,7 +2374,7 @@ discard block |
||
| 2374 | 2374 | //error_log(__FUNCTION__."() #$event[id], start=".date('Y-m-d H:i:s', $event['start']).', end='.date('Y-m-d H:i:s', $event['end']).', range_end='.date('Y-m-d H:i:s', $event['recur_enddate']).' --> '.date('Y-m-d H:i:s', $range_end)); |
| 2375 | 2375 | } |
| 2376 | 2376 | } |
| 2377 | - return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2377 | + return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.002'; // skip 14.2.001 update, as query is fixed now |
|
| 2378 | 2378 | } |
| 2379 | 2379 | |
| 2380 | 2380 | /** |
@@ -2398,7 +2398,7 @@ discard block |
||
| 2398 | 2398 | // if maximum is bigger then 3 |
| 2399 | 2399 | if ($values[1] > 3) |
| 2400 | 2400 | { |
| 2401 | - switch($GLOBALS['egw_setup']->db->Type) |
|
| 2401 | + switch ($GLOBALS['egw_setup']->db->Type) |
|
| 2402 | 2402 | { |
| 2403 | 2403 | case 'mysql': |
| 2404 | 2404 | $sql = "UPDATE egw_cal |
@@ -2443,7 +2443,7 @@ discard block |
||
| 2443 | 2443 | |
| 2444 | 2444 | function calendar_upgrade14_2_003() |
| 2445 | 2445 | { |
| 2446 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_uid',array( |
|
| 2446 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_uid', array( |
|
| 2447 | 2447 | 'type' => 'ascii', |
| 2448 | 2448 | 'precision' => '128', |
| 2449 | 2449 | 'nullable' => False, |
@@ -2455,13 +2455,13 @@ discard block |
||
| 2455 | 2455 | { |
| 2456 | 2456 | $GLOBALS['egw_setup']->db->query("UPDATE egw_cal SET cal_category='' WHERE cal_category NOT REGEXP '^[0-9,]*$'", __LINE__, __FILE__); |
| 2457 | 2457 | } |
| 2458 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','cal_category',array( |
|
| 2458 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'cal_category', array( |
|
| 2459 | 2459 | 'type' => 'ascii', |
| 2460 | 2460 | 'meta' => 'category', |
| 2461 | 2461 | 'precision' => '64', |
| 2462 | 2462 | 'comment' => 'category id(s)' |
| 2463 | 2463 | )); |
| 2464 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal','caldav_name',array( |
|
| 2464 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal', 'caldav_name', array( |
|
| 2465 | 2465 | 'type' => 'ascii', |
| 2466 | 2466 | 'precision' => '128', |
| 2467 | 2467 | 'comment' => 'name part of CalDAV URL, if specified by client' |
@@ -2518,22 +2518,22 @@ discard block |
||
| 2518 | 2518 | 'type' => 'auto', |
| 2519 | 2519 | 'nullable' => False |
| 2520 | 2520 | ));*/ |
| 2521 | - $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user',array( |
|
| 2521 | + $GLOBALS['egw_setup']->oProc->RefreshTable('egw_cal_user', array( |
|
| 2522 | 2522 | 'fd' => array( |
| 2523 | - 'cal_id' => array('type' => 'int','precision' => '4','nullable' => False), |
|
| 2524 | - 'cal_recur_date' => array('type' => 'int','meta' => 'timestamp','precision' => '8','nullable' => False,'default' => '0'), |
|
| 2525 | - 'cal_user_type' => array('type' => 'ascii','precision' => '1','nullable' => False,'default' => 'u','comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2526 | - 'cal_user_id' => array('type' => 'varchar','meta' => array("cal_user_type='u'" => 'account'),'precision' => '128','nullable' => False,'comment' => 'id or email-address for type=e'), |
|
| 2527 | - 'cal_status' => array('type' => 'ascii','precision' => '1','default' => 'A','comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2528 | - 'cal_quantity' => array('type' => 'int','precision' => '4','default' => '1','comment' => 'only for certain types (eg. resources)'), |
|
| 2529 | - 'cal_role' => array('type' => 'ascii','precision' => '64','default' => 'REQ-PARTICIPANT','comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2530 | - 'cal_user_modified' => array('type' => 'timestamp','default' => 'current_timestamp','comment' => 'automatic timestamp of last update'), |
|
| 2531 | - 'cal_user_auto' => array('type' => 'auto','nullable' => False) |
|
| 2523 | + 'cal_id' => array('type' => 'int', 'precision' => '4', 'nullable' => False), |
|
| 2524 | + 'cal_recur_date' => array('type' => 'int', 'meta' => 'timestamp', 'precision' => '8', 'nullable' => False, 'default' => '0'), |
|
| 2525 | + 'cal_user_type' => array('type' => 'ascii', 'precision' => '1', 'nullable' => False, 'default' => 'u', 'comment' => 'u=user, g=group, c=contact, r=resource, e=email'), |
|
| 2526 | + 'cal_user_id' => array('type' => 'varchar', 'meta' => array("cal_user_type='u'" => 'account'), 'precision' => '128', 'nullable' => False, 'comment' => 'id or email-address for type=e'), |
|
| 2527 | + 'cal_status' => array('type' => 'ascii', 'precision' => '1', 'default' => 'A', 'comment' => 'U=unknown, A=accepted, R=rejected, T=tentative'), |
|
| 2528 | + 'cal_quantity' => array('type' => 'int', 'precision' => '4', 'default' => '1', 'comment' => 'only for certain types (eg. resources)'), |
|
| 2529 | + 'cal_role' => array('type' => 'ascii', 'precision' => '64', 'default' => 'REQ-PARTICIPANT', 'comment' => 'CHAIR, REQ-PARTICIPANT, OPT-PARTICIPANT, NON-PARTICIPANT, X-CAT-$cat_id'), |
|
| 2530 | + 'cal_user_modified' => array('type' => 'timestamp', 'default' => 'current_timestamp', 'comment' => 'automatic timestamp of last update'), |
|
| 2531 | + 'cal_user_auto' => array('type' => 'auto', 'nullable' => False) |
|
| 2532 | 2532 | ), |
| 2533 | 2533 | 'pk' => array('cal_user_auto'), |
| 2534 | 2534 | 'fk' => array(), |
| 2535 | - 'ix' => array('cal_user_modified',array('cal_user_type','cal_user_id')), |
|
| 2536 | - 'uc' => array(array('cal_id','cal_recur_date','cal_user_type','cal_user_id')) |
|
| 2535 | + 'ix' => array('cal_user_modified', array('cal_user_type', 'cal_user_id')), |
|
| 2536 | + 'uc' => array(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id')) |
|
| 2537 | 2537 | )); |
| 2538 | 2538 | |
| 2539 | 2539 | return $GLOBALS['setup_info']['calendar']['currentver'] = '14.2.005'; |
@@ -2542,12 +2542,12 @@ discard block |
||
| 2542 | 2542 | |
| 2543 | 2543 | function calendar_upgrade14_2_005() |
| 2544 | 2544 | { |
| 2545 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_tzid',array( |
|
| 2545 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_tzid', array( |
|
| 2546 | 2546 | 'type' => 'ascii', |
| 2547 | 2547 | 'precision' => '128', |
| 2548 | 2548 | 'nullable' => False |
| 2549 | 2549 | )); |
| 2550 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones','tz_component',array( |
|
| 2550 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_timezones', 'tz_component', array( |
|
| 2551 | 2551 | 'type' => 'ascii', |
| 2552 | 2552 | 'precision' => '8192', |
| 2553 | 2553 | 'comment' => 'iCal VTIMEZONE component' |
@@ -2563,7 +2563,7 @@ discard block |
||
| 2563 | 2563 | */ |
| 2564 | 2564 | function calendar_upgrade14_3() |
| 2565 | 2565 | { |
| 2566 | - $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user','cal_user_attendee',array( |
|
| 2566 | + $GLOBALS['egw_setup']->oProc->AddColumn('egw_cal_user', 'cal_user_attendee', array( |
|
| 2567 | 2567 | 'type' => 'varchar', |
| 2568 | 2568 | 'precision' => '255', |
| 2569 | 2569 | 'comment' => 'email or json object with attr. cn, url, ...' |
@@ -2574,12 +2574,12 @@ discard block |
||
| 2574 | 2574 | |
| 2575 | 2575 | // delete all but one row, which would give a doublicate key, after above normalising of email addresses |
| 2576 | 2576 | // by ordering by status we prever accepted over tentative over unknow over deleted |
| 2577 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2577 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "cal_id,cal_recur_date,$email AS email", array( |
|
| 2578 | 2578 | 'cal_user_type' => 'e', |
| 2579 | 2579 | ), __LINE__, __FILE__, false, "GROUP BY cal_id,cal_recur_date,$email HAVING COUNT(*)>1", 'calendar') as $row) |
| 2580 | 2580 | { |
| 2581 | 2581 | $n = 0; |
| 2582 | - foreach($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2582 | + foreach ($GLOBALS['egw_setup']->db->select('egw_cal_user', "*,$email AS email", array( |
|
| 2583 | 2583 | 'cal_id' => $row['cal_id'], |
| 2584 | 2584 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2585 | 2585 | 'cal_user_type' => 'e', |
@@ -2588,7 +2588,7 @@ discard block |
||
| 2588 | 2588 | { |
| 2589 | 2589 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2590 | 2590 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2591 | - array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
|
| 2591 | + array_intersect_key($user, array_flip(array('cal_id', 'cal_recur_date', 'cal_user_type', 'cal_user_id', 'cal_status'))), |
|
| 2592 | 2592 | __LINE__, __FILE__, 'calendar'); |
| 2593 | 2593 | } |
| 2594 | 2594 | } |
@@ -2598,7 +2598,7 @@ discard block |
||
| 2598 | 2598 | "UPDATE egw_cal_user SET cal_user_attendee=cal_user_id,cal_user_id=MD5($email) WHERE cal_user_type='e'", |
| 2599 | 2599 | __LINE__, __FILE__); |
| 2600 | 2600 | |
| 2601 | - $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user','cal_user_id',array( |
|
| 2601 | + $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_user', 'cal_user_id', array( |
|
| 2602 | 2602 | 'type' => 'ascii', |
| 2603 | 2603 | 'meta' => array( |
| 2604 | 2604 | "cal_user_type='u'" => 'account' |
@@ -2620,7 +2620,7 @@ discard block |
||
| 2620 | 2620 | { |
| 2621 | 2621 | $GLOBALS['calendar_upgrade14_3_001-run'] = true; |
| 2622 | 2622 | |
| 2623 | - foreach($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2623 | + foreach ($GLOBALS['egw_setup']->db->query("SELECT egw_cal_user.cal_id AS cal_id,egw_cal_user.cal_user_id AS cal_user_id,egw_cal_user.cal_user_attendee AS cal_user_attendee |
|
| 2624 | 2624 | FROM egw_cal_user |
| 2625 | 2625 | JOIN egw_cal_user euser ON euser.cal_id=egw_cal_user.cal_id AND euser.cal_user_type='e' AND euser.cal_user_id=egw_cal_user.cal_user_id AND euser.cal_user_attendee IS NULL |
| 2626 | 2626 | WHERE egw_cal_user.cal_user_type='e' AND egw_cal_user.cal_user_attendee IS NOT NULL |
@@ -2671,8 +2671,8 @@ discard block |
||
| 2671 | 2671 | { |
| 2672 | 2672 | Api\Preferences::change_preference('calendar', '/^favorite_/', function($attr, $old_value, $owner) |
| 2673 | 2673 | { |
| 2674 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2675 | - if($old_value['state'] && is_array($old_value['state'])) |
|
| 2674 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2675 | + if ($old_value['state'] && is_array($old_value['state'])) |
|
| 2676 | 2676 | { |
| 2677 | 2677 | unset($old_value['state']['date']); |
| 2678 | 2678 | unset($old_value['state']['startdate']); |
@@ -2692,15 +2692,15 @@ discard block |
||
| 2692 | 2692 | { |
| 2693 | 2693 | Api\Preferences::change_preference('calendar', 'use_time_grid', function($attr, $old_value, $owner) |
| 2694 | 2694 | { |
| 2695 | - unset($attr, $owner); // not used, but required by function signature |
|
| 2696 | - switch($old_value) |
|
| 2695 | + unset($attr, $owner); // not used, but required by function signature |
|
| 2696 | + switch ($old_value) |
|
| 2697 | 2697 | { |
| 2698 | 2698 | case 'all': |
| 2699 | 2699 | return 0; |
| 2700 | 2700 | case 'day_week': |
| 2701 | - return ['day','day4','week']; |
|
| 2701 | + return ['day', 'day4', 'week']; |
|
| 2702 | 2702 | case 'day4': |
| 2703 | - return ['day','day4']; |
|
| 2703 | + return ['day', 'day4']; |
|
| 2704 | 2704 | } |
| 2705 | 2705 | return null; |
| 2706 | 2706 | }); |
@@ -2725,7 +2725,7 @@ discard block |
||
| 2725 | 2725 | function calendar_upgrade16_1_001() |
| 2726 | 2726 | { |
| 2727 | 2727 | $GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_extra', 'cal_extra_value', |
| 2728 | - array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')); |
|
| 2728 | + array('type' => 'varchar', 'meta' => 'cfvalue', 'precision' => '16384', 'nullable' => False, 'default' => '')); |
|
| 2729 | 2729 | |
| 2730 | 2730 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'forced'); |
| 2731 | 2731 | Api\Preferences::change_preference('calendar', 'defaultresource_sel', 'resources', 'addressbook', 'default'); |
@@ -1429,13 +1429,18 @@ discard block |
||
| 1429 | 1429 | function calendar_upgrade1_0_1_008() |
| 1430 | 1430 | { |
| 1431 | 1431 | $config_data = Api\Config::read('calendar'); |
| 1432 | - if (isset($config_data['fields'])) // old custom fields |
|
| 1432 | + if (isset($config_data['fields'])) |
|
| 1433 | + { |
|
| 1434 | + // old custom fields |
|
| 1433 | 1435 | { |
| 1434 | 1436 | $customfields = array(); |
| 1437 | + } |
|
| 1435 | 1438 | $order = 0; |
| 1436 | 1439 | foreach($config_data['fields'] as $name => $data) |
| 1437 | 1440 | { |
| 1438 | - if ($name{0} == '#' && !$data['disabled']) // real not-disabled custom field |
|
| 1441 | + if ($name{0} == '#' && !$data['disabled']) |
|
| 1442 | + { |
|
| 1443 | + // real not-disabled custom field |
|
| 1439 | 1444 | { |
| 1440 | 1445 | $customfields[substr($name,1)] = array( |
| 1441 | 1446 | 'type' => 'text', |
@@ -1444,6 +1449,7 @@ discard block |
||
| 1444 | 1449 | 'order' => ($order += 10), |
| 1445 | 1450 | ); |
| 1446 | 1451 | } |
| 1452 | + } |
|
| 1447 | 1453 | } |
| 1448 | 1454 | if (count($customfields)) |
| 1449 | 1455 | { |
@@ -2584,9 +2590,12 @@ discard block |
||
| 2584 | 2590 | 'cal_recur_date' => $row['cal_recur_date'], |
| 2585 | 2591 | 'cal_user_type' => 'e', |
| 2586 | 2592 | $email.'='.$GLOBALS['egw_setup']->db->quote($row['email']), |
| 2587 | - ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) // order A, T, U, X |
|
| 2593 | + ), __LINE__, __FILE__, false, 'ORDER BY cal_status', 'calendar') as $user) |
|
| 2594 | + { |
|
| 2595 | + // order A, T, U, X |
|
| 2588 | 2596 | { |
| 2589 | 2597 | if (strpos($user['email'], '@') !== false && !$n++) continue; |
| 2598 | + } |
|
| 2590 | 2599 | $GLOBALS['egw_setup']->db->delete('egw_cal_user', |
| 2591 | 2600 | array_intersect_key($user, array_flip(array('cal_id','cal_recur_date','cal_user_type','cal_user_id','cal_status'))), |
| 2592 | 2601 | __LINE__, __FILE__, 'calendar'); |
@@ -187,7 +187,7 @@ |
||
| 187 | 187 | * |
| 188 | 188 | * @param string $file filename |
| 189 | 189 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 190 | - * @return boolean false on error |
|
| 190 | + * @return boolean|null false on error |
|
| 191 | 191 | */ |
| 192 | 192 | function fix_api($file, $dry_run=false) |
| 193 | 193 | { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | // raw replacements |
| 19 | 19 | $add_use_api = array( |
| 20 | - "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
| 20 | + "#use EGroupware\\\\Api;\n#" => '', // remove evtl. use EGroupware\Api, as we add it again below |
|
| 21 | 21 | "#<\?php\n+\s*/\*+?(.*)\*/#msU" => "<?php\n/**$1*/\n\nuse EGroupware\\Api;", |
| 22 | 22 | ); |
| 23 | 23 | $replace = array( |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | // enclose class-names and static methods with some syntax check |
| 47 | 47 | $class_start = '#(?<!function)([\[\s,;().!=])'; |
| 48 | 48 | $class_end = '(::|\\(|\\)|;|\?|:|\\s|,|$)#'; |
| 49 | -foreach(array( |
|
| 49 | +foreach (array( |
|
| 50 | 50 | 'accounts' => 'Api\\Accounts', |
| 51 | 51 | 'acl' => 'Api\\Acl', |
| 52 | 52 | 'EGW_ACL_READ' => 'Api\\Acl::READ', |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 190 | 190 | * @return boolean false on error |
| 191 | 191 | */ |
| 192 | -function fix_api($file, $dry_run=false) |
|
| 192 | +function fix_api($file, $dry_run = false) |
|
| 193 | 193 | { |
| 194 | 194 | global $prog, $replace, $add_use_api; |
| 195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 195 | + if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 196 | 196 | |
| 197 | 197 | if (($content = $content_in = file_get_contents($file)) === false) return false; |
| 198 | 198 | |
@@ -203,12 +203,12 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
| 205 | 205 | |
| 206 | - if ($content2 == $content_in) return true; // nothing changed |
|
| 206 | + if ($content2 == $content_in) return true; // nothing changed |
|
| 207 | 207 | |
| 208 | 208 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
| 209 | 209 | |
| 210 | 210 | // shorten some classes, if used, with further use declarations |
| 211 | - foreach(array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
| 211 | + foreach (array('Api\\Etemplate', 'Api\\Vfs', 'Api\\Acl', 'Api\\Egw', 'Api\\Framework', 'Api\\Link') as $namespace) |
|
| 212 | 212 | { |
| 213 | 213 | if (strpos($content, $namespace) !== false && strpos($content, 'use EGroupware\\'.$namespace) === false) |
| 214 | 214 | { |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | * @param boolean $dry_run =false true: only echo fixed file, not fix it |
| 248 | 248 | * @return boolean false on error |
| 249 | 249 | */ |
| 250 | -function fix_api_recursive($dir, $dry_run=false) |
|
| 250 | +function fix_api_recursive($dir, $dry_run = false) |
|
| 251 | 251 | { |
| 252 | 252 | if (!is_dir($dir)) return false; |
| 253 | 253 | |
| 254 | - foreach(scandir($dir) as $file) |
|
| 254 | + foreach (scandir($dir) as $file) |
|
| 255 | 255 | { |
| 256 | 256 | if ($file == '.' || $file == '..') continue; |
| 257 | 257 | |
@@ -259,13 +259,13 @@ discard block |
||
| 259 | 259 | { |
| 260 | 260 | fix_api_recursive($dir.'/'.$file, $dry_run); |
| 261 | 261 | } |
| 262 | - elseif(substr($file,-4) == '.php') |
|
| 262 | + elseif (substr($file, -4) == '.php') |
|
| 263 | 263 | { |
| 264 | - echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': '; |
|
| 264 | + echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': '; |
|
| 265 | 265 | fix_api($dir.'/'.$file, $dry_run); |
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | - echo "\r".str_repeat(' ',100)."\r"; |
|
| 268 | + echo "\r".str_repeat(' ', 100)."\r"; |
|
| 269 | 269 | return true; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @param string $error =null |
| 276 | 276 | */ |
| 277 | -function usage($error=null) |
|
| 277 | +function usage($error = null) |
|
| 278 | 278 | { |
| 279 | 279 | global $prog; |
| 280 | 280 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
@@ -288,9 +288,9 @@ discard block |
||
| 288 | 288 | if (!$args) usage(); |
| 289 | 289 | |
| 290 | 290 | $dry_run = false; |
| 291 | -while(($arg = array_shift($args)) && $arg[0] == '-') |
|
| 291 | +while (($arg = array_shift($args)) && $arg[0] == '-') |
|
| 292 | 292 | { |
| 293 | - switch($arg) |
|
| 293 | + switch ($arg) |
|
| 294 | 294 | { |
| 295 | 295 | case '-h': |
| 296 | 296 | case '--help': |
@@ -323,4 +323,4 @@ discard block |
||
| 323 | 323 | fix_api_recursive($arg, $dry_run); |
| 324 | 324 | } |
| 325 | 325 | } |
| 326 | -while(($arg = array_shift($args))); |
|
| 326 | +while (($arg = array_shift($args))); |
|
@@ -10,10 +10,13 @@ discard block |
||
| 10 | 10 | * @version $Id$ |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
| 13 | +if (php_sapi_name() !== 'cli') |
|
| 14 | +{ |
|
| 15 | + // security precaution: forbit calling as web-page |
|
| 14 | 16 | { |
| 15 | 17 | die('<h1>fix_api.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 16 | 18 | } |
| 19 | +} |
|
| 17 | 20 | |
| 18 | 21 | // raw replacements |
| 19 | 22 | $add_use_api = array( |
@@ -192,9 +195,16 @@ discard block |
||
| 192 | 195 | function fix_api($file, $dry_run=false) |
| 193 | 196 | { |
| 194 | 197 | global $prog, $replace, $add_use_api; |
| 195 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 198 | + if (basename($file) == $prog) |
|
| 199 | + { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 202 | + // dont fix ourself ;-) |
|
| 196 | 203 | |
| 197 | - if (($content = $content_in = file_get_contents($file)) === false) return false; |
|
| 204 | + if (($content = $content_in = file_get_contents($file)) === false) |
|
| 205 | + { |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 198 | 208 | |
| 199 | 209 | if (!preg_match("|<\?php\n+\s*/\*\*?.*\*/|msU", $content)) |
| 200 | 210 | { |
@@ -203,7 +213,11 @@ discard block |
||
| 203 | 213 | } |
| 204 | 214 | $content2 = preg_replace(array_keys($replace), array_values($replace), $content); |
| 205 | 215 | |
| 206 | - if ($content2 == $content_in) return true; // nothing changed |
|
| 216 | + if ($content2 == $content_in) |
|
| 217 | + { |
|
| 218 | + return true; |
|
| 219 | + } |
|
| 220 | + // nothing changed |
|
| 207 | 221 | |
| 208 | 222 | $content = preg_replace(array_keys($add_use_api), array_values($add_use_api), $content2); |
| 209 | 223 | |
@@ -249,11 +263,17 @@ discard block |
||
| 249 | 263 | */ |
| 250 | 264 | function fix_api_recursive($dir, $dry_run=false) |
| 251 | 265 | { |
| 252 | - if (!is_dir($dir)) return false; |
|
| 266 | + if (!is_dir($dir)) |
|
| 267 | + { |
|
| 268 | + return false; |
|
| 269 | + } |
|
| 253 | 270 | |
| 254 | 271 | foreach(scandir($dir) as $file) |
| 255 | 272 | { |
| 256 | - if ($file == '.' || $file == '..') continue; |
|
| 273 | + if ($file == '.' || $file == '..') |
|
| 274 | + { |
|
| 275 | + continue; |
|
| 276 | + } |
|
| 257 | 277 | |
| 258 | 278 | if (is_dir($dir.'/'.$file)) |
| 259 | 279 | { |
@@ -278,14 +298,20 @@ discard block |
||
| 278 | 298 | { |
| 279 | 299 | global $prog; |
| 280 | 300 | echo "Usage: $prog [-h|--help] [-d|--dry-run] file(s) or dir(s)\n\n"; |
| 281 | - if ($error) echo $error."\n\n"; |
|
| 301 | + if ($error) |
|
| 302 | + { |
|
| 303 | + echo $error."\n\n"; |
|
| 304 | + } |
|
| 282 | 305 | exit($error ? 1 : 0); |
| 283 | 306 | } |
| 284 | 307 | |
| 285 | 308 | $args = $_SERVER['argv']; |
| 286 | 309 | $prog = basename(array_shift($args)); |
| 287 | 310 | |
| 288 | -if (!$args) usage(); |
|
| 311 | +if (!$args) |
|
| 312 | +{ |
|
| 313 | + usage(); |
|
| 314 | +} |
|
| 289 | 315 | |
| 290 | 316 | $dry_run = false; |
| 291 | 317 | while(($arg = array_shift($args)) && $arg[0] == '-') |
@@ -303,16 +329,22 @@ discard block |
||
| 303 | 329 | break; |
| 304 | 330 | |
| 305 | 331 | default: |
| 306 | - if ($args) // not last argument |
|
| 332 | + if ($args) |
|
| 333 | + { |
|
| 334 | + // not last argument |
|
| 307 | 335 | { |
| 308 | 336 | usage("Unknown argument '$arg'!"); |
| 309 | 337 | } |
| 338 | + } |
|
| 310 | 339 | break 2; |
| 311 | 340 | } |
| 312 | 341 | } |
| 313 | 342 | |
| 314 | 343 | do { |
| 315 | - if (!file_exists($arg)) usage("Error: $arg not found!"); |
|
| 344 | + if (!file_exists($arg)) |
|
| 345 | + { |
|
| 346 | + usage("Error: $arg not found!"); |
|
| 347 | + } |
|
| 316 | 348 | |
| 317 | 349 | if (!is_dir($arg)) |
| 318 | 350 | { |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Fix depricated stuff in a given file |
| 24 | 24 | * |
| 25 | 25 | * @param string $file filename |
| 26 | - * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
|
| 26 | + * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created |
|
| 27 | 27 | * @return boolean false on error |
| 28 | 28 | */ |
| 29 | 29 | function fix_depricated($file,$replace_file=false) |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * Loop recursive through directory and call fix_depricated for each php file |
| 147 | 147 | * |
| 148 | 148 | * @param string $dir |
| 149 | - * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
|
| 149 | + * @param boolean $replace_file replace existing file if modifications are necessary, otherwise .php53 file is created |
|
| 150 | 150 | * @return boolean false on error |
| 151 | 151 | */ |
| 152 | 152 | function fix_depricated_recursive($dir,$replace_file=false) |
@@ -174,7 +174,6 @@ discard block |
||
| 174 | 174 | /** |
| 175 | 175 | * Give usage |
| 176 | 176 | * |
| 177 | - * @param string $error=null |
|
| 178 | 177 | */ |
| 179 | 178 | function usage($error=null) |
| 180 | 179 | { |
@@ -26,47 +26,47 @@ discard block |
||
| 26 | 26 | * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
| 27 | 27 | * @return boolean false on error |
| 28 | 28 | */ |
| 29 | -function fix_depricated($file,$replace_file=false) |
|
| 29 | +function fix_depricated($file, $replace_file = false) |
|
| 30 | 30 | { |
| 31 | 31 | $orig = $lines = file_get_contents($file); |
| 32 | 32 | if ($lines === false) return false; |
| 33 | 33 | global $prog; |
| 34 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 34 | + if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 35 | 35 | |
| 36 | 36 | // PHP Deprecated: Assigning the return value of new by reference is deprecated |
| 37 | - if (preg_match('/= *& *new /m',$lines)) |
|
| 37 | + if (preg_match('/= *& *new /m', $lines)) |
|
| 38 | 38 | { |
| 39 | - $lines = preg_replace('/= *& *new /','= new ',$lines); |
|
| 39 | + $lines = preg_replace('/= *& *new /', '= new ', $lines); |
|
| 40 | 40 | } |
| 41 | 41 | // PHP Deprecated: Function split() is deprecated |
| 42 | - if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m',$lines,$matches)) |
|
| 42 | + if (preg_match_all('/[= \t(]+spliti? *\\(("[^"]*"|\'[^\']*\'),/m', $lines, $matches)) |
|
| 43 | 43 | { |
| 44 | 44 | $replace = array(); |
| 45 | 45 | //print_r($matches); |
| 46 | - foreach($matches[1] as $key => $pattern) |
|
| 46 | + foreach ($matches[1] as $key => $pattern) |
|
| 47 | 47 | { |
| 48 | 48 | $full_pattern = $matches[0][$key]; |
| 49 | 49 | // single char --> just explode |
| 50 | - if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern,0,2) == '"\\') |
|
| 50 | + if (strlen($pattern) == 3 || strlen($pattern) == 4 && substr($pattern, 0, 2) == '"\\') |
|
| 51 | 51 | { |
| 52 | - $replace[$full_pattern] = str_replace('split','explode',$full_pattern); |
|
| 52 | + $replace[$full_pattern] = str_replace('split', 'explode', $full_pattern); |
|
| 53 | 53 | } |
| 54 | 54 | else |
| 55 | 55 | { |
| 56 | - $preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0]; |
|
| 57 | - if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
| 58 | - $replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern); |
|
| 56 | + $preg_pattern = $pattern[0].'/'.str_replace('/', '\\\\/', substr($pattern, 1, -1)).'/'.$pattern[0]; |
|
| 57 | + if (strpos($full_pattern, 'spliti')) $preg_pattern = substr($preg_pattern, 0, -1).'i'.$pattern[0]; |
|
| 58 | + $replace[$full_pattern] = str_replace(array('spliti', 'split', $pattern), array('preg_split', 'preg_split', $preg_pattern), $full_pattern); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | //print_r($replace); |
| 62 | - $lines = strtr($lines,$replace); |
|
| 62 | + $lines = strtr($lines, $replace); |
|
| 63 | 63 | } |
| 64 | 64 | // PHP Deprecated: Function ereg() is deprecated |
| 65 | - if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m',$lines,$matches)) |
|
| 65 | + if (preg_match_all('/!?eregi? *\\(("[^"]+"[^,]*|\'[^\']+\'[^,]*), *(\$[A-Za-z0-9_\[\]\$\'\"]+)(, *\$[A-Za-z0-9_\[\]\$\'\"]+)?\)([ )&|]+)/m', $lines, $matches)) |
|
| 66 | 66 | { |
| 67 | 67 | $replace = array(); |
| 68 | 68 | //print_r($matches); |
| 69 | - foreach($matches[1] as $key => $pattern) |
|
| 69 | + foreach ($matches[1] as $key => $pattern) |
|
| 70 | 70 | { |
| 71 | 71 | $full_pattern = $matches[0][$key]; |
| 72 | 72 | $what = $matches[2][$key]; |
@@ -75,25 +75,25 @@ discard block |
||
| 75 | 75 | if (preg_quote($pattern) == $pattern) |
| 76 | 76 | { |
| 77 | 77 | |
| 78 | - $replace[$full_pattern] = (strpos($full_pattern,'eregi')!==false?'strposi':'strpos').'('.$what.','.$pattern. |
|
| 79 | - ') '.($full_pattern[0]=='!'?'===':'!==').' false'.$matches[4][$key]; |
|
| 78 | + $replace[$full_pattern] = (strpos($full_pattern, 'eregi') !== false ? 'strposi' : 'strpos').'('.$what.','.$pattern. |
|
| 79 | + ') '.($full_pattern[0] == '!' ? '===' : '!==').' false'.$matches[4][$key]; |
|
| 80 | 80 | } |
| 81 | 81 | else |
| 82 | 82 | { |
| 83 | 83 | // full ereg regular expression --> preg_match |
| 84 | - $preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'"); |
|
| 85 | - $replace[$full_pattern] = str_replace(array('eregi','ereg',$pattern),array('preg_match','preg_match',$preg_pattern),$full_pattern); |
|
| 84 | + $preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'"); |
|
| 85 | + $replace[$full_pattern] = str_replace(array('eregi', 'ereg', $pattern), array('preg_match', 'preg_match', $preg_pattern), $full_pattern); |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | //print_r($replace); |
| 89 | - $lines = strtr($lines,$replace); |
|
| 89 | + $lines = strtr($lines, $replace); |
|
| 90 | 90 | } |
| 91 | 91 | // PHP Deprecated: Function ereg_replace() is deprecated |
| 92 | - if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m',$lines,$matches)) |
|
| 92 | + if (preg_match_all('/eregi?_replace *\\((".+"|\'.+\'|[^,]+), *(.+), *[\'s$].+\)[,; =]/m', $lines, $matches)) |
|
| 93 | 93 | { |
| 94 | 94 | $replace = array(); |
| 95 | 95 | //print_r($matches); |
| 96 | - foreach($matches[1] as $key => $pattern) |
|
| 96 | + foreach ($matches[1] as $key => $pattern) |
|
| 97 | 97 | { |
| 98 | 98 | $full_pattern = $matches[0][$key]; |
| 99 | 99 | $other = $matches[2][$key]; |
@@ -101,41 +101,41 @@ discard block |
||
| 101 | 101 | // simple replace --> use str_replace() |
| 102 | 102 | if (preg_quote($pattern) == $pattern) |
| 103 | 103 | { |
| 104 | - $replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace'),array('stri_replace','str_replace'),$full_pattern); |
|
| 104 | + $replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace'), array('stri_replace', 'str_replace'), $full_pattern); |
|
| 105 | 105 | } |
| 106 | 106 | else |
| 107 | 107 | { |
| 108 | 108 | // full ereg regular expression --> preg_replace |
| 109 | - $preg_pattern = "'/'.".str_replace('/','\\\\/',$pattern).(strpos($full_pattern,'eregi') !== false ? ".'/i'" : ".'/'"); |
|
| 110 | - $replace[$full_pattern] = str_replace(array('eregi_replace','ereg_replace',$pattern), |
|
| 111 | - array('preg_replace','preg_replace',$preg_pattern),$full_pattern); |
|
| 109 | + $preg_pattern = "'/'.".str_replace('/', '\\\\/', $pattern).(strpos($full_pattern, 'eregi') !== false ? ".'/i'" : ".'/'"); |
|
| 110 | + $replace[$full_pattern] = str_replace(array('eregi_replace', 'ereg_replace', $pattern), |
|
| 111 | + array('preg_replace', 'preg_replace', $preg_pattern), $full_pattern); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | //print_r($replace); |
| 115 | - $lines = strtr($lines,$replace); |
|
| 115 | + $lines = strtr($lines, $replace); |
|
| 116 | 116 | } |
| 117 | 117 | // remove extra '/' from regular expressions |
| 118 | - $lines = str_replace(array("'/'.'","'.'/'","'.'/i'"),array("'/","/'","/i'"),$lines); |
|
| 118 | + $lines = str_replace(array("'/'.'", "'.'/'", "'.'/i'"), array("'/", "/'", "/i'"), $lines); |
|
| 119 | 119 | |
| 120 | 120 | // fix call to not longer existing PDO method $result->fetchSingle() |
| 121 | - $lines = str_replace('->fetchSingle(','->fetchColumn(',$lines); |
|
| 121 | + $lines = str_replace('->fetchSingle(', '->fetchColumn(', $lines); |
|
| 122 | 122 | |
| 123 | 123 | // fix calls to deprecated call_user_method(_array)?(method,object[,args]) |
| 124 | - if (preg_match('/call_user_method(_array)?\(/',$lines,$matches)) |
|
| 124 | + if (preg_match('/call_user_method(_array)?\(/', $lines, $matches)) |
|
| 125 | 125 | { |
| 126 | - $lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/','call_user_func(array(\\2,\\1)\\3',$lines); |
|
| 127 | - $lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/','call_user_func_array(array(\\2,\\1)\\3',$lines); |
|
| 126 | + $lines = preg_replace('/call_user_method\(([^,]+),([^,\)]+)([,)])/', 'call_user_func(array(\\2,\\1)\\3', $lines); |
|
| 127 | + $lines = preg_replace('/call_user_method_array\(([^,]+),([^,\)]+)([,)])/', 'call_user_func_array(array(\\2,\\1)\\3', $lines); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | if ($lines != $orig) |
| 131 | 131 | { |
| 132 | - file_put_contents($file.'53',$lines); |
|
| 133 | - system('/usr/bin/php -l '.$file.'53',$ret); |
|
| 132 | + file_put_contents($file.'53', $lines); |
|
| 133 | + system('/usr/bin/php -l '.$file.'53', $ret); |
|
| 134 | 134 | system('/usr/bin/diff -u '.$file.' '.$file.'53'); |
| 135 | 135 | if (!$ret && $replace_file) |
| 136 | 136 | { |
| 137 | 137 | unlink($file); |
| 138 | - rename($file.'53',$file); |
|
| 138 | + rename($file.'53', $file); |
|
| 139 | 139 | } |
| 140 | 140 | return !$ret; |
| 141 | 141 | } |
@@ -149,25 +149,25 @@ discard block |
||
| 149 | 149 | * @param boolean $replace_file=false replace existing file if modifications are necessary, otherwise .php53 file is created |
| 150 | 150 | * @return boolean false on error |
| 151 | 151 | */ |
| 152 | -function fix_depricated_recursive($dir,$replace_file=false) |
|
| 152 | +function fix_depricated_recursive($dir, $replace_file = false) |
|
| 153 | 153 | { |
| 154 | 154 | if (!is_dir($dir)) return false; |
| 155 | 155 | |
| 156 | - foreach(scandir($dir) as $file) |
|
| 156 | + foreach (scandir($dir) as $file) |
|
| 157 | 157 | { |
| 158 | 158 | if ($file == '.' || $file == '..') continue; |
| 159 | 159 | |
| 160 | 160 | if (is_dir($dir.'/'.$file)) |
| 161 | 161 | { |
| 162 | - fix_depricated_recursive($dir.'/'.$file,$replace_file); |
|
| 162 | + fix_depricated_recursive($dir.'/'.$file, $replace_file); |
|
| 163 | 163 | } |
| 164 | - elseif(substr($file,-4) == '.php') |
|
| 164 | + elseif (substr($file, -4) == '.php') |
|
| 165 | 165 | { |
| 166 | - echo "\r".str_repeat(' ',100)."\r".$dir.'/'.$file.': '; |
|
| 167 | - fix_depricated($dir.'/'.$file,$replace_file); |
|
| 166 | + echo "\r".str_repeat(' ', 100)."\r".$dir.'/'.$file.': '; |
|
| 167 | + fix_depricated($dir.'/'.$file, $replace_file); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | - echo "\r".str_repeat(' ',100)."\r"; |
|
| 170 | + echo "\r".str_repeat(' ', 100)."\r"; |
|
| 171 | 171 | return true; |
| 172 | 172 | } |
| 173 | 173 | |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @param string $error=null |
| 178 | 178 | */ |
| 179 | -function usage($error=null) |
|
| 179 | +function usage($error = null) |
|
| 180 | 180 | { |
| 181 | 181 | global $prog; |
| 182 | 182 | echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n"; |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | if (!$args) usage(); |
| 191 | 191 | |
| 192 | 192 | $replace_file = false; |
| 193 | -while(($arg = array_shift($args))) |
|
| 193 | +while (($arg = array_shift($args))) |
|
| 194 | 194 | { |
| 195 | - switch($arg) |
|
| 195 | + switch ($arg) |
|
| 196 | 196 | { |
| 197 | 197 | case '-h': |
| 198 | 198 | case '--help': |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | if (!is_dir($arg)) |
| 218 | 218 | { |
| 219 | - fix_depricated($arg,$replace_file); |
|
| 219 | + fix_depricated($arg, $replace_file); |
|
| 220 | 220 | } |
| 221 | 221 | else |
| 222 | 222 | { |
| 223 | - fix_depricated_recursive($arg,$replace_file); |
|
| 223 | + fix_depricated_recursive($arg, $replace_file); |
|
| 224 | 224 | } |
| 225 | 225 | \ No newline at end of file |
@@ -14,10 +14,13 @@ discard block |
||
| 14 | 14 | * @version $Id$ |
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling as web-page |
|
| 17 | +if (php_sapi_name() !== 'cli') |
|
| 18 | +{ |
|
| 19 | + // security precaution: forbit calling as web-page |
|
| 18 | 20 | { |
| 19 | 21 | die('<h1>fix_depricated.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 20 | 22 | } |
| 23 | +} |
|
| 21 | 24 | |
| 22 | 25 | /** |
| 23 | 26 | * Fix depricated stuff in a given file |
@@ -29,9 +32,16 @@ discard block |
||
| 29 | 32 | function fix_depricated($file,$replace_file=false) |
| 30 | 33 | { |
| 31 | 34 | $orig = $lines = file_get_contents($file); |
| 32 | - if ($lines === false) return false; |
|
| 35 | + if ($lines === false) |
|
| 36 | + { |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 33 | 39 | global $prog; |
| 34 | - if (basename($file) == $prog) return true; // dont fix ourself ;-) |
|
| 40 | + if (basename($file) == $prog) |
|
| 41 | + { |
|
| 42 | + return true; |
|
| 43 | + } |
|
| 44 | + // dont fix ourself ;-) |
|
| 35 | 45 | |
| 36 | 46 | // PHP Deprecated: Assigning the return value of new by reference is deprecated |
| 37 | 47 | if (preg_match('/= *& *new /m',$lines)) |
@@ -54,7 +64,10 @@ discard block |
||
| 54 | 64 | else |
| 55 | 65 | { |
| 56 | 66 | $preg_pattern = $pattern[0].'/'.str_replace('/','\\\\/',substr($pattern,1,-1)).'/'.$pattern[0]; |
| 57 | - if (strpos($full_pattern,'spliti')) $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
| 67 | + if (strpos($full_pattern,'spliti')) |
|
| 68 | + { |
|
| 69 | + $preg_pattern = substr($preg_pattern,0,-1).'i'.$pattern[0]; |
|
| 70 | + } |
|
| 58 | 71 | $replace[$full_pattern] = str_replace(array('spliti','split',$pattern),array('preg_split','preg_split',$preg_pattern),$full_pattern); |
| 59 | 72 | } |
| 60 | 73 | } |
@@ -151,11 +164,17 @@ discard block |
||
| 151 | 164 | */ |
| 152 | 165 | function fix_depricated_recursive($dir,$replace_file=false) |
| 153 | 166 | { |
| 154 | - if (!is_dir($dir)) return false; |
|
| 167 | + if (!is_dir($dir)) |
|
| 168 | + { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 155 | 171 | |
| 156 | 172 | foreach(scandir($dir) as $file) |
| 157 | 173 | { |
| 158 | - if ($file == '.' || $file == '..') continue; |
|
| 174 | + if ($file == '.' || $file == '..') |
|
| 175 | + { |
|
| 176 | + continue; |
|
| 177 | + } |
|
| 159 | 178 | |
| 160 | 179 | if (is_dir($dir.'/'.$file)) |
| 161 | 180 | { |
@@ -180,14 +199,20 @@ discard block |
||
| 180 | 199 | { |
| 181 | 200 | global $prog; |
| 182 | 201 | echo "Usage: $prog [--replace] [-h|--help] file or dir\n\n"; |
| 183 | - if ($error) echo $error."\n\n"; |
|
| 202 | + if ($error) |
|
| 203 | + { |
|
| 204 | + echo $error."\n\n"; |
|
| 205 | + } |
|
| 184 | 206 | exit($error ? 1 : 0); |
| 185 | 207 | } |
| 186 | 208 | |
| 187 | 209 | $args = $_SERVER['argv']; |
| 188 | 210 | $prog = basename(array_shift($args)); |
| 189 | 211 | |
| 190 | -if (!$args) usage(); |
|
| 212 | +if (!$args) |
|
| 213 | +{ |
|
| 214 | + usage(); |
|
| 215 | +} |
|
| 191 | 216 | |
| 192 | 217 | $replace_file = false; |
| 193 | 218 | while(($arg = array_shift($args))) |
@@ -204,15 +229,21 @@ discard block |
||
| 204 | 229 | break; |
| 205 | 230 | |
| 206 | 231 | default: |
| 207 | - if ($args) // not last argument |
|
| 232 | + if ($args) |
|
| 233 | + { |
|
| 234 | + // not last argument |
|
| 208 | 235 | { |
| 209 | 236 | usage("Unknown argument '$arg'!"); |
| 210 | 237 | } |
| 238 | + } |
|
| 211 | 239 | break 2; |
| 212 | 240 | } |
| 213 | 241 | } |
| 214 | 242 | |
| 215 | -if (!file_exists($arg)) usage("Error: $arg not found!"); |
|
| 243 | +if (!file_exists($arg)) |
|
| 244 | +{ |
|
| 245 | + usage("Error: $arg not found!"); |
|
| 246 | +} |
|
| 216 | 247 | |
| 217 | 248 | if (!is_dir($arg)) |
| 218 | 249 | { |
@@ -464,6 +464,7 @@ discard block |
||
| 464 | 464 | * |
| 465 | 465 | * @param string $name |
| 466 | 466 | * @param string $value =null value to use, default $config[$name] |
| 467 | + * @return string |
|
| 467 | 468 | */ |
| 468 | 469 | function config_translate($name, $value=null) |
| 469 | 470 | { |
@@ -1194,7 +1195,7 @@ discard block |
||
| 1194 | 1195 | * Runs given shell command, exists with error-code after echoing the output of the failed command (if not already running verbose) |
| 1195 | 1196 | * |
| 1196 | 1197 | * @param string $cmd |
| 1197 | - * @param array& $output=null $output of command, only if !$verbose !!! |
|
| 1198 | + * @param array& $output $output of command, only if !$verbose !!! |
|
| 1198 | 1199 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
| 1199 | 1200 | * @return int exit code of $cmd |
| 1200 | 1201 | */ |
@@ -10,10 +10,13 @@ discard block |
||
| 10 | 10 | * @version $Id$ |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling setup-cli as web-page |
|
| 13 | +if (php_sapi_name() !== 'cli') |
|
| 14 | +{ |
|
| 15 | + // security precaution: forbit calling setup-cli as web-page |
|
| 14 | 16 | { |
| 15 | 17 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 16 | 18 | } |
| 19 | +} |
|
| 17 | 20 | date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
| 18 | 21 | |
| 19 | 22 | $verbose = 0; |
@@ -137,7 +140,10 @@ discard block |
||
| 137 | 140 | case 'release': |
| 138 | 141 | case 'copychangelog': |
| 139 | 142 | $config[$name] = $value; |
| 140 | - if ($value) array_unshift($config['run'],$name); |
|
| 143 | + if ($value) |
|
| 144 | + { |
|
| 145 | + array_unshift($config['run'],$name); |
|
| 146 | + } |
|
| 141 | 147 | break; |
| 142 | 148 | |
| 143 | 149 | case 'editchangelog': |
@@ -153,7 +159,10 @@ discard block |
||
| 153 | 159 | { |
| 154 | 160 | usage("Path '$value' not found!"); |
| 155 | 161 | } |
| 156 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
| 162 | + if (!in_array('obs',$config['run'])) |
|
| 163 | + { |
|
| 164 | + $config['run'][] = 'obs'; |
|
| 165 | + } |
|
| 157 | 166 | // fall through |
| 158 | 167 | default: |
| 159 | 168 | $config[$name] = $value; |
@@ -211,7 +220,10 @@ discard block |
||
| 211 | 220 | } |
| 212 | 221 | |
| 213 | 222 | $cmd = $config['git'].' log '.escapeshellarg($last_tag.'..HEAD'); |
| 214 | - if (getcwd() != $path) $cmd = 'cd '.$path.'; '.$cmd; |
|
| 223 | + if (getcwd() != $path) |
|
| 224 | + { |
|
| 225 | + $cmd = 'cd '.$path.'; '.$cmd; |
|
| 226 | + } |
|
| 215 | 227 | $output = null; |
| 216 | 228 | run_cmd($cmd, $output); |
| 217 | 229 | |
@@ -242,7 +254,10 @@ discard block |
||
| 242 | 254 | { |
| 243 | 255 | global $config, $verbose; |
| 244 | 256 | |
| 245 | - if ($verbose) echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
| 257 | + if ($verbose) |
|
| 258 | + { |
|
| 259 | + echo "Get modules from .mrconfig in checkoutdir $config[checkoutdir]\n"; |
|
| 260 | + } |
|
| 246 | 261 | |
| 247 | 262 | if (!is_dir($config['checkoutdir'])) |
| 248 | 263 | { |
@@ -273,12 +288,21 @@ discard block |
||
| 273 | 288 | elseif (isset($module) && preg_match('/^checkout\s*=\s*(git\s+clone\s+(-b\s+[0-9.]+\s+)?((git|http)[^ ]+)|svn\s+checkout\s+((svn|http)[^ ]+))/', $line, $matches)) |
| 274 | 289 | { |
| 275 | 290 | $repo = $url = substr($matches[1], 0, 3) == 'svn' ? $matches[5] : $matches[3]; |
| 276 | - if (substr($matches[1], 0, 3) == 'svn') $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
| 291 | + if (substr($matches[1], 0, 3) == 'svn') |
|
| 292 | + { |
|
| 293 | + $repo = preg_replace('#/(trunk|branches)/.*$#', '', $repo); |
|
| 294 | + } |
|
| 277 | 295 | $modules[$repo][$config['aliasdir'].($module ? '/'.$module : '')] = $url; |
| 278 | - if ($module === '' && !isset($baseurl)) $baseurl = str_replace('/egroupware.git', '', $url); |
|
| 296 | + if ($module === '' && !isset($baseurl)) |
|
| 297 | + { |
|
| 298 | + $baseurl = str_replace('/egroupware.git', '', $url); |
|
| 299 | + } |
|
| 279 | 300 | } |
| 280 | 301 | } |
| 281 | - if ($verbose) print_r($modules); |
|
| 302 | + if ($verbose) |
|
| 303 | + { |
|
| 304 | + print_r($modules); |
|
| 305 | + } |
|
| 282 | 306 | return $modules; |
| 283 | 307 | } |
| 284 | 308 | |
@@ -345,7 +369,11 @@ discard block |
||
| 345 | 369 | |
| 346 | 370 | $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
| 347 | 371 | |
| 348 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
| 372 | + if (empty($config['tag'])) |
|
| 373 | + { |
|
| 374 | + return; |
|
| 375 | + } |
|
| 376 | + // otherwise we copy everything in svn root! |
|
| 349 | 377 | |
| 350 | 378 | echo "Creating tag $config[tag]\n"; |
| 351 | 379 | |
@@ -361,7 +389,10 @@ discard block |
||
| 361 | 389 | global $config,$verbose; |
| 362 | 390 | |
| 363 | 391 | // push local changes to Github incl. tags |
| 364 | - if ($verbose) echo "Pushing changes and tags\n"; |
|
| 392 | + if ($verbose) |
|
| 393 | + { |
|
| 394 | + echo "Pushing changes and tags\n"; |
|
| 395 | + } |
|
| 365 | 396 | chdir($config['checkoutdir']); |
| 366 | 397 | run_cmd($config['mr']. ' up'); // in case someone else pushed something |
| 367 | 398 | chdir($config['checkoutdir']); |
@@ -429,7 +460,10 @@ discard block |
||
| 429 | 460 | { |
| 430 | 461 | continue; |
| 431 | 462 | } |
| 432 | - if ($verbose) echo "Uploading $path as $content_type\n"; |
|
| 463 | + if ($verbose) |
|
| 464 | + { |
|
| 465 | + echo "Uploading $path as $content_type\n"; |
|
| 466 | + } |
|
| 433 | 467 | $name = basename($path); |
| 434 | 468 | github_api($config['upload_url'], array( |
| 435 | 469 | 'name' => $name, |
@@ -441,7 +475,10 @@ discard block |
||
| 441 | 475 | { |
| 442 | 476 | $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
| 443 | 477 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
| 444 | - if ($verbose) echo $cmd."\n"; |
|
| 478 | + if ($verbose) |
|
| 479 | + { |
|
| 480 | + echo $cmd."\n"; |
|
| 481 | + } |
|
| 445 | 482 | passthru($cmd); |
| 446 | 483 | } |
| 447 | 484 | } |
@@ -474,25 +511,40 @@ discard block |
||
| 474 | 511 | { |
| 475 | 512 | case 'POST': |
| 476 | 513 | curl_setopt($c, CURLOPT_POST, true); |
| 477 | - if (is_array($data)) $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 514 | + if (is_array($data)) |
|
| 515 | + { |
|
| 516 | + $data = json_encode($data, JSON_FORCE_OBJECT); |
|
| 517 | + } |
|
| 478 | 518 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 479 | 519 | break; |
| 480 | 520 | case 'GET': |
| 481 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 521 | + if(count($data)) |
|
| 522 | + { |
|
| 523 | + $url .= '?' . http_build_query($data); |
|
| 524 | + } |
|
| 482 | 525 | break; |
| 483 | 526 | case 'FILE': |
| 484 | 527 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 485 | 528 | curl_setopt($c, CURLOPT_POST, true); |
| 486 | 529 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 487 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 530 | + if(count($data)) |
|
| 531 | + { |
|
| 532 | + $url .= '?' . http_build_query($data); |
|
| 533 | + } |
|
| 488 | 534 | break; |
| 489 | 535 | default: |
| 490 | 536 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
| 491 | 537 | } |
| 492 | 538 | curl_setopt($c, CURLOPT_URL, $url); |
| 493 | 539 | |
| 494 | - if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 540 | + if (is_string($data)) |
|
| 541 | + { |
|
| 542 | + $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
|
| 543 | + } |
|
| 544 | + if ($verbose) |
|
| 545 | + { |
|
| 546 | + echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 547 | + } |
|
| 496 | 548 | |
| 497 | 549 | if (($response = curl_exec($c)) === false) |
| 498 | 550 | { |
@@ -503,7 +555,10 @@ discard block |
||
| 503 | 555 | throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
| 504 | 556 | } |
| 505 | 557 | |
| 506 | - if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 558 | + if ($verbose) |
|
| 559 | + { |
|
| 560 | + echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
|
| 561 | + } |
|
| 507 | 562 | |
| 508 | 563 | curl_close($c); |
| 509 | 564 | |
@@ -520,13 +575,19 @@ discard block |
||
| 520 | 575 | { |
| 521 | 576 | global $config; |
| 522 | 577 | |
| 523 | - if (!isset($value)) $value = $config[$name]; |
|
| 578 | + if (!isset($value)) |
|
| 579 | + { |
|
| 580 | + $value = $config[$name]; |
|
| 581 | + } |
|
| 524 | 582 | if (is_string($value) && strpos($value, '$') !== false) |
| 525 | 583 | { |
| 526 | 584 | $translate = array(); |
| 527 | 585 | foreach($config as $n => $val) |
| 528 | 586 | { |
| 529 | - if (is_string($val)) $translate['$'.$n] = $val; |
|
| 587 | + if (is_string($val)) |
|
| 588 | + { |
|
| 589 | + $translate['$'.$n] = $val; |
|
| 590 | + } |
|
| 530 | 591 | } |
| 531 | 592 | $value = strtr($value, $translate); |
| 532 | 593 | } |
@@ -628,7 +689,10 @@ discard block |
||
| 628 | 689 | if (is_null($revision)) |
| 629 | 690 | { |
| 630 | 691 | list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
| 631 | - if (empty($branch)) $branch = $config['version']; |
|
| 692 | + if (empty($branch)) |
|
| 693 | + { |
|
| 694 | + $branch = $config['version']; |
|
| 695 | + } |
|
| 632 | 696 | $tags_url .= '/tags'; |
| 633 | 697 | $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
| 634 | 698 | $matches = null; |
@@ -654,11 +718,18 @@ discard block |
||
| 654 | 718 | $message = ''; |
| 655 | 719 | foreach($xml as $log) |
| 656 | 720 | { |
| 657 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
| 721 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) |
|
| 722 | + { |
|
| 723 | + continue; |
|
| 724 | + } |
|
| 725 | + // no match --> ignore |
|
| 658 | 726 | |
| 659 | 727 | $message .= $msg."\n"; |
| 660 | 728 | } |
| 661 | - if ($verbose) echo $message; |
|
| 729 | + if ($verbose) |
|
| 730 | + { |
|
| 731 | + echo $message; |
|
| 732 | + } |
|
| 662 | 733 | |
| 663 | 734 | return $message; |
| 664 | 735 | } |
@@ -689,7 +760,10 @@ discard block |
||
| 689 | 760 | { |
| 690 | 761 | return null; |
| 691 | 762 | } |
| 692 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
| 763 | + if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) |
|
| 764 | + { |
|
| 765 | + $msg = $prefix.$msg; |
|
| 766 | + } |
|
| 693 | 767 | |
| 694 | 768 | return $msg; |
| 695 | 769 | } |
@@ -726,7 +800,10 @@ discard block |
||
| 726 | 800 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
| 727 | 801 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
| 728 | 802 | { |
| 729 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 803 | + if ($verbose) |
|
| 804 | + { |
|
| 805 | + echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 806 | + } |
|
| 730 | 807 | return (int)$log['revision']; |
| 731 | 808 | } |
| 732 | 809 | } |
@@ -746,7 +823,10 @@ discard block |
||
| 746 | 823 | { |
| 747 | 824 | usage("Path '$config[obs]' not found!"); |
| 748 | 825 | } |
| 749 | - if ($verbose) echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
| 826 | + if ($verbose) |
|
| 827 | + { |
|
| 828 | + echo $only_update_changelog ? "Updating OBS changelogs\n" : "Updating OBS checkout\n"; |
|
| 829 | + } |
|
| 750 | 830 | run_cmd('osc up '.$config['obs']); |
| 751 | 831 | |
| 752 | 832 | $n = 0; |
@@ -766,10 +846,16 @@ discard block |
||
| 766 | 846 | if (basename($path) != basename($new_name)) |
| 767 | 847 | { |
| 768 | 848 | unlink($path); |
| 769 | - if ($verbose) echo "rm $path\n"; |
|
| 849 | + if ($verbose) |
|
| 850 | + { |
|
| 851 | + echo "rm $path\n"; |
|
| 852 | + } |
|
| 770 | 853 | } |
| 771 | 854 | copy($new_name,dirname($path).'/'.basename($new_name)); |
| 772 | - if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
|
| 855 | + if ($verbose) |
|
| 856 | + { |
|
| 857 | + echo "cp $new_name ".dirname($path)."/\n"; |
|
| 858 | + } |
|
| 773 | 859 | ++$n; |
| 774 | 860 | } |
| 775 | 861 | // if we have no changelog (eg. because commands run separate), try parsing it from changelog file |
@@ -807,7 +893,10 @@ discard block |
||
| 807 | 893 | if ($content != $content_was) |
| 808 | 894 | { |
| 809 | 895 | file_put_contents($path,$content); |
| 810 | - if ($verbose) echo "Updated $path\n"; |
|
| 896 | + if ($verbose) |
|
| 897 | + { |
|
| 898 | + echo "Updated $path\n"; |
|
| 899 | + } |
|
| 811 | 900 | ++$n; |
| 812 | 901 | } |
| 813 | 902 | } |
@@ -845,9 +934,12 @@ discard block |
||
| 845 | 934 | } |
| 846 | 935 | $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
| 847 | 936 | $logentry = ''; |
| 848 | - while($lines[$n]) // entry is terminated by empty line |
|
| 937 | + while($lines[$n]) |
|
| 938 | + { |
|
| 939 | + // entry is terminated by empty line |
|
| 849 | 940 | { |
| 850 | 941 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
| 942 | + } |
|
| 851 | 943 | ++$n; |
| 852 | 944 | } |
| 853 | 945 | return substr($logentry, 0, -1); // remove training "\n" |
@@ -868,7 +960,10 @@ discard block |
||
| 868 | 960 | |
| 869 | 961 | list($header) = explode("\n", $content); |
| 870 | 962 | $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
| 871 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
| 963 | + if (substr($config['changelog'],0,2) != ' ') |
|
| 964 | + { |
|
| 965 | + $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
| 966 | + } |
|
| 872 | 967 | $content = $new_header."\n\n".$config['changelog']. |
| 873 | 968 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
| 874 | 969 | |
@@ -882,10 +977,13 @@ discard block |
||
| 882 | 977 | { |
| 883 | 978 | global $config; |
| 884 | 979 | |
| 885 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 980 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
| 981 | + { |
|
| 982 | + // sha1_file cant deal with '~/rpm' |
|
| 886 | 983 | { |
| 887 | 984 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
| 888 | 985 | } |
| 986 | + } |
|
| 889 | 987 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 890 | 988 | |
| 891 | 989 | if (!file_exists($sumsfile)) |
@@ -896,11 +994,17 @@ discard block |
||
| 896 | 994 | // signing it |
| 897 | 995 | if (empty($config['gpg']) || !file_exists($config['gpg'])) |
| 898 | 996 | { |
| 899 | - if (!empty($config['gpg'])) echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
| 997 | + if (!empty($config['gpg'])) |
|
| 998 | + { |
|
| 999 | + echo "{$config['gpg']} not found --> skipping signing sha1sum file!\n"; |
|
| 1000 | + } |
|
| 900 | 1001 | return; |
| 901 | 1002 | } |
| 902 | 1003 | echo "Signing sha1sum file:\n"; |
| 903 | - if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
|
| 1004 | + if (file_exists($sumsfile.'.asc')) |
|
| 1005 | + { |
|
| 1006 | + unlink($sumsfile.'.asc'); |
|
| 1007 | + } |
|
| 904 | 1008 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
| 905 | 1009 | run_cmd($cmd); |
| 906 | 1010 | unlink($sumsfile); // delete the unsigned file |
@@ -913,11 +1017,17 @@ discard block |
||
| 913 | 1017 | { |
| 914 | 1018 | global $config; |
| 915 | 1019 | |
| 916 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
| 917 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 1020 | + if (!file_exists($config['sourcedir'])) |
|
| 1021 | + { |
|
| 1022 | + mkdir($config['sourcedir'],0755,true); |
|
| 1023 | + } |
|
| 1024 | + if (substr($config['sourcedir'],0,2) == '~/') |
|
| 1025 | + { |
|
| 1026 | + // sha1_file cant deal with '~/rpm' |
|
| 918 | 1027 | { |
| 919 | 1028 | $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
| 920 | 1029 | } |
| 1030 | + } |
|
| 921 | 1031 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 922 | 1032 | $sums = ''; |
| 923 | 1033 | |
@@ -955,12 +1065,22 @@ discard block |
||
| 955 | 1065 | { |
| 956 | 1066 | foreach((array)$config['all-add'] as $add) |
| 957 | 1067 | { |
| 958 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
| 959 | - if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
|
| 1068 | + if (substr($add, -4) != '.tar') |
|
| 1069 | + { |
|
| 1070 | + continue; |
|
| 1071 | + } |
|
| 1072 | + // probably a module |
|
| 1073 | + if (!($tar = realpath($add))) |
|
| 1074 | + { |
|
| 1075 | + throw new Exception("File '$add' not found!"); |
|
| 1076 | + } |
|
| 960 | 1077 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
| 961 | 1078 | } |
| 962 | 1079 | } |
| 963 | - if (file_exists($file.'.bz2')) $cmd .= '; rm -f '.$file.'.bz2'; |
|
| 1080 | + if (file_exists($file.'.bz2')) |
|
| 1081 | + { |
|
| 1082 | + $cmd .= '; rm -f '.$file.'.bz2'; |
|
| 1083 | + } |
|
| 964 | 1084 | $cmd .= '; '.$config['bzip2'].' '.$file; |
| 965 | 1085 | // run cmd now and continue without adding all tar-ball to sums, as we dont want to publish it |
| 966 | 1086 | run_cmd($cmd); |
@@ -981,7 +1101,10 @@ discard block |
||
| 981 | 1101 | |
| 982 | 1102 | foreach($config['extra'] as $name => $modules) |
| 983 | 1103 | { |
| 984 | - if (is_numeric($name)) $name = $modules; |
|
| 1104 | + if (is_numeric($name)) |
|
| 1105 | + { |
|
| 1106 | + $name = $modules; |
|
| 1107 | + } |
|
| 985 | 1108 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
| 986 | 1109 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
| 987 | 1110 | switch($type) |
@@ -1022,7 +1145,10 @@ discard block |
||
| 1022 | 1145 | { |
| 1023 | 1146 | echo "Updating virus signatures\n"; |
| 1024 | 1147 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
| 1025 | - if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
|
| 1148 | + if (!$verbose && function_exists('posix_getuid') && posix_getuid()) |
|
| 1149 | + { |
|
| 1150 | + echo $cmd."\n"; |
|
| 1151 | + } |
|
| 1026 | 1152 | $output = null; |
| 1027 | 1153 | run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
| 1028 | 1154 | } |
@@ -1050,7 +1176,10 @@ discard block |
||
| 1050 | 1176 | } |
| 1051 | 1177 | |
| 1052 | 1178 | // we need to stash uncommited changes like .mrconfig, before copying |
| 1053 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("cd $config[checkoutdir]; git stash"); |
|
| 1179 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
| 1180 | + { |
|
| 1181 | + run_cmd("cd $config[checkoutdir]; git stash"); |
|
| 1182 | + } |
|
| 1054 | 1183 | |
| 1055 | 1184 | try { |
| 1056 | 1185 | $cmd = '/usr/bin/rsync -r --delete --delete-excluded --exclude .svn --exclude .git\* --exclude .mrconfig --exclude node_modules/ '.$config['checkoutdir'].'/ '.$config['egw_buildroot'].'/'.$config['aliasdir'].'/'; |
@@ -1059,8 +1188,14 @@ discard block |
||
| 1059 | 1188 | catch (Exception $e) { |
| 1060 | 1189 | // catch failures to pop stash, before throwing exception |
| 1061 | 1190 | } |
| 1062 | - if (file_exists($config['checkoutdir'].'/.git')) run_cmd("git stash pop"); |
|
| 1063 | - if (isset($e)) throw $e; |
|
| 1191 | + if (file_exists($config['checkoutdir'].'/.git')) |
|
| 1192 | + { |
|
| 1193 | + run_cmd("git stash pop"); |
|
| 1194 | + } |
|
| 1195 | + if (isset($e)) |
|
| 1196 | + { |
|
| 1197 | + throw $e; |
|
| 1198 | + } |
|
| 1064 | 1199 | |
| 1065 | 1200 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
| 1066 | 1201 | { |
@@ -1145,9 +1280,12 @@ discard block |
||
| 1145 | 1280 | if ($ret || substr($line,0,5) == 'URL: ') |
| 1146 | 1281 | { |
| 1147 | 1282 | $url = substr($line,5); |
| 1148 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
| 1283 | + if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) |
|
| 1284 | + { |
|
| 1285 | + // wrong branch (or no svn dir) |
|
| 1149 | 1286 | { |
| 1150 | 1287 | echo "Checkout is of wrong branch --> deleting it\n"; |
| 1288 | + } |
|
| 1151 | 1289 | system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
| 1152 | 1290 | clearstatcache(); |
| 1153 | 1291 | } |
@@ -1194,19 +1332,31 @@ discard block |
||
| 1194 | 1332 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
| 1195 | 1333 | $url = $svnbranch.'/'.$config['svnalias']; |
| 1196 | 1334 | $cmd = $svn.' propget svn:externals --strict '.$url; |
| 1197 | - if ($verbose) echo $cmd."\n"; |
|
| 1335 | + if ($verbose) |
|
| 1336 | + { |
|
| 1337 | + echo $cmd."\n"; |
|
| 1338 | + } |
|
| 1198 | 1339 | $output = $ret = null; |
| 1199 | 1340 | exec($cmd,$output,$ret); |
| 1200 | 1341 | $config['modules'] = array(); |
| 1201 | 1342 | foreach($output as $line) |
| 1202 | 1343 | { |
| 1203 | 1344 | $line = trim($line); |
| 1204 | - if (empty($line) || $line[0] == '#') continue; |
|
| 1345 | + if (empty($line) || $line[0] == '#') |
|
| 1346 | + { |
|
| 1347 | + continue; |
|
| 1348 | + } |
|
| 1205 | 1349 | list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
| 1206 | 1350 | $matches = null; |
| 1207 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1351 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
| 1352 | + { |
|
| 1353 | + die("Invalid SVN URL: $url\n"); |
|
| 1354 | + } |
|
| 1208 | 1355 | $repo = $matches[1]; |
| 1209 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1356 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
| 1357 | + { |
|
| 1358 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1359 | + } |
|
| 1210 | 1360 | $config['modules'][$repo][$path] = $url; |
| 1211 | 1361 | } |
| 1212 | 1362 | // process extra modules |
@@ -1215,13 +1365,25 @@ discard block |
||
| 1215 | 1365 | $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
| 1216 | 1366 | $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
| 1217 | 1367 | $url .= $module; |
| 1218 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
| 1219 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1368 | + if (strpos($module,'://') !== false) |
|
| 1369 | + { |
|
| 1370 | + $module = basename($module); |
|
| 1371 | + } |
|
| 1372 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) |
|
| 1373 | + { |
|
| 1374 | + die("Invalid SVN URL: $url\n"); |
|
| 1375 | + } |
|
| 1220 | 1376 | $repo = $matches[1]; |
| 1221 | - if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1377 | + if ($repo == 'http://svn.egroupware.org/egroupware') |
|
| 1378 | + { |
|
| 1379 | + $repo = 'svn+ssh://[email protected]/egroupware'; |
|
| 1380 | + } |
|
| 1222 | 1381 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
| 1223 | 1382 | } |
| 1224 | - if ($verbose) print_r($config['modules']); |
|
| 1383 | + if ($verbose) |
|
| 1384 | + { |
|
| 1385 | + print_r($config['modules']); |
|
| 1386 | + } |
|
| 1225 | 1387 | return $config['modules']; |
| 1226 | 1388 | } |
| 1227 | 1389 | |
@@ -1232,7 +1394,11 @@ discard block |
||
| 1232 | 1394 | { |
| 1233 | 1395 | global $config,$svn; |
| 1234 | 1396 | |
| 1235 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
| 1397 | + if (empty($config['svntag'])) |
|
| 1398 | + { |
|
| 1399 | + return; |
|
| 1400 | + } |
|
| 1401 | + // otherwise we copy everything in svn root! |
|
| 1236 | 1402 | |
| 1237 | 1403 | $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
| 1238 | 1404 | |
@@ -1271,11 +1437,17 @@ discard block |
||
| 1271 | 1437 | { |
| 1272 | 1438 | $output[] = $cmd; |
| 1273 | 1439 | exec($cmd,$output,$ret); |
| 1274 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
| 1440 | + if ($verbose) |
|
| 1441 | + { |
|
| 1442 | + echo implode("\n",$output)."\n"; |
|
| 1443 | + } |
|
| 1275 | 1444 | } |
| 1276 | 1445 | if ($ret && !in_array($ret,(array)$no_bailout)) |
| 1277 | 1446 | { |
| 1278 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
| 1447 | + if (!$verbose) |
|
| 1448 | + { |
|
| 1449 | + echo implode("\n",$output)."\n"; |
|
| 1450 | + } |
|
| 1279 | 1451 | throw new Exception("Error during '$cmd' --> aborting",$ret); |
| 1280 | 1452 | } |
| 1281 | 1453 | return $ret; |
@@ -1321,7 +1493,10 @@ discard block |
||
| 1321 | 1493 | echo "options and their defaults:\n"; |
| 1322 | 1494 | if ($verbose) |
| 1323 | 1495 | { |
| 1324 | - if (!isset($config['modules'])) $config['modules'] = get_modules_per_repo(); |
|
| 1496 | + if (!isset($config['modules'])) |
|
| 1497 | + { |
|
| 1498 | + $config['modules'] = get_modules_per_repo(); |
|
| 1499 | + } |
|
| 1325 | 1500 | } |
| 1326 | 1501 | else |
| 1327 | 1502 | { |
@@ -1329,7 +1504,10 @@ discard block |
||
| 1329 | 1504 | } |
| 1330 | 1505 | foreach($config as $name => $default) |
| 1331 | 1506 | { |
| 1332 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
| 1507 | + if (is_array($default)) |
|
| 1508 | + { |
|
| 1509 | + $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
| 1510 | + } |
|
| 1333 | 1511 | echo '--'.str_pad($name,20).$default."\n"; |
| 1334 | 1512 | } |
| 1335 | 1513 | if ($error) |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $archives = config_translate('upload'); |
| 406 | - echo "Uploading $archives to $config[upload_url]\n"; |
|
| 406 | + echo "uploading $archives to $config[upload_url]\n"; |
|
| 407 | 407 | |
| 408 | 408 | foreach(glob($archives, GLOB_BRACE) as $path) |
| 409 | 409 | { |
@@ -429,7 +429,7 @@ discard block |
||
| 429 | 429 | { |
| 430 | 430 | continue; |
| 431 | 431 | } |
| 432 | - if ($verbose) echo "Uploading $path as $content_type\n"; |
|
| 432 | + if ($verbose) echo "uploading $path as $content_type\n"; |
|
| 433 | 433 | $name = basename($path); |
| 434 | 434 | github_api($config['upload_url'], array( |
| 435 | 435 | 'name' => $name, |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | curl_setopt($c, CURLOPT_URL, $url); |
| 493 | 493 | |
| 494 | 494 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 495 | + if ($verbose) echo "sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 496 | 496 | |
| 497 | 497 | if (($response = curl_exec($c)) === false) |
| 498 | 498 | { |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
| 727 | 727 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
| 728 | 728 | { |
| 729 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 729 | + if ($verbose) echo "revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 730 | 730 | return (int)$log['revision']; |
| 731 | 731 | } |
| 732 | 732 | } |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | if ($content != $content_was) |
| 808 | 808 | { |
| 809 | 809 | file_put_contents($path,$content); |
| 810 | - if ($verbose) echo "Updated $path\n"; |
|
| 810 | + if ($verbose) echo "updated $path\n"; |
|
| 811 | 811 | ++$n; |
| 812 | 812 | } |
| 813 | 813 | } |
@@ -942,7 +942,7 @@ discard block |
||
| 942 | 942 | } |
| 943 | 943 | foreach($config['types'] as $type) |
| 944 | 944 | { |
| 945 | - echo "Creating $type archives\n"; |
|
| 945 | + echo "creating $type archives\n"; |
|
| 946 | 946 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
| 947 | 947 | |
| 948 | 948 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
@@ -1064,7 +1064,7 @@ discard block |
||
| 1064 | 1064 | |
| 1065 | 1065 | if (($cmd = config_translate('patchCmd')) && $cmd[0] != '#') |
| 1066 | 1066 | { |
| 1067 | - echo "Running $cmd\n"; |
|
| 1067 | + echo "running $cmd\n"; |
|
| 1068 | 1068 | run_cmd($cmd); |
| 1069 | 1069 | } |
| 1070 | 1070 | // fix permissions |
@@ -14,15 +14,15 @@ discard block |
||
| 14 | 14 | { |
| 15 | 15 | die('<h1>checkout-build-archives.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 16 | 16 | } |
| 17 | -date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
| 17 | +date_default_timezone_set('Europe/Berlin'); // to get ride of 5.3 warnings |
|
| 18 | 18 | |
| 19 | 19 | $verbose = 0; |
| 20 | 20 | $config = array( |
| 21 | 21 | 'packagename' => 'egroupware-epl', |
| 22 | - 'version' => '16.1', // '14.3' |
|
| 22 | + 'version' => '16.1', // '14.3' |
|
| 23 | 23 | 'packaging' => date('Ymd'), // '20160520' |
| 24 | - 'branch' => 'master', // checked out branch |
|
| 25 | - 'tag' => '$version.$packaging', // name of tag |
|
| 24 | + 'branch' => 'master', // checked out branch |
|
| 25 | + 'tag' => '$version.$packaging', // name of tag |
|
| 26 | 26 | 'checkoutdir' => realpath(__DIR__.'/../..'), |
| 27 | 27 | 'egw_buildroot' => '/tmp/build_root/epl_16.1_buildroot', |
| 28 | 28 | 'sourcedir' => '/home/download/stylite-epl/egroupware-epl-16.1', |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | 'svnalias' => 'aliases/default-ssh', // default alias |
| 35 | 35 | 'extra' => array('$stylitebase/$svnbranch/stylite', '$stylitebase/$svnbranch/esyncpro', '$stylitebase/trunk/archive'),//, '$stylitebase/$svnbranch/groups'), //,'svn+ssh://[email protected]/stylite/trunk/eventmgr'), |
| 36 | 36 | */ |
| 37 | - 'extra' => array('stylite', 'esyncpro', 'archive', // create an extra archive for given apps |
|
| 37 | + 'extra' => array('stylite', 'esyncpro', 'archive', // create an extra archive for given apps |
|
| 38 | 38 | // these apps are placed in egroupware-epl-contrib archive |
| 39 | 39 | 'contrib' => array('phpgwapi', 'etemplate', 'jdots', 'phpbrain', 'wiki', 'sambaadmin', 'sitemgr', 'phpfreechat')), |
| 40 | - 'aliasdir' => 'egroupware', // directory created by the alias |
|
| 41 | - 'types' => array('tar.bz2','tar.gz','zip','all.tar.bz2'), |
|
| 40 | + 'aliasdir' => 'egroupware', // directory created by the alias |
|
| 41 | + 'types' => array('tar.bz2', 'tar.gz', 'zip', 'all.tar.bz2'), |
|
| 42 | 42 | // add given extra-apps or (uncompressed!) archives to above all.tar.bz2 archive |
| 43 | 43 | 'all-add' => array('contrib', '/home/stylite/epl-16.1/phpfreechat_data_public.tar'), |
| 44 | 44 | // diverse binaries we need |
@@ -55,12 +55,12 @@ discard block |
||
| 55 | 55 | 'gpg' => trim(`which gpg`), |
| 56 | 56 | 'editor' => trim(`which vi`), |
| 57 | 57 | 'rsync' => trim(`which rsync`).' --progress -e ssh --exclude "*-stylite-*" --exclude "*-esyncpro-*"', |
| 58 | - 'composer' => ($composer=trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs --no-dev' : '', |
|
| 58 | + 'composer' => ($composer = trim(`which composer.phar`)) ? $composer.' install --ignore-platform-reqs --no-dev' : '', |
|
| 59 | 59 | 'after-checkout' => 'rm -rf */source */templates/*/source', |
| 60 | 60 | 'packager' => '[email protected]', |
| 61 | 61 | 'obs' => '/home/stylite/obs/stylite-epl', |
| 62 | - 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
| 63 | - 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
| 62 | + 'obs_package_alias' => '', // name used in obs package, if different from packagename |
|
| 63 | + 'changelog' => false, // eg. '* 1. Zeile\n* 2. Zeile' for debian.changes |
|
| 64 | 64 | 'changelog_packager' => 'Ralf Becker <[email protected]>', |
| 65 | 65 | 'editchangelog' => '* ', |
| 66 | 66 | //'sfuser' => 'ralfbecker', |
@@ -69,23 +69,23 @@ discard block |
||
| 69 | 69 | 'upload' => '$sourcedir/*egroupware-epl{,-contrib}-$version.$packaging*', |
| 70 | 70 | 'copychangelog' => '$sourcedir/README', //'$sfuser,[email protected]:/home/frs/project/e/eg/egroupware/README', |
| 71 | 71 | 'skip' => array(), |
| 72 | - 'run' => array('checkout','editchangelog','tag','copy','virusscan','create','sign','obs','copychangelog'), |
|
| 72 | + 'run' => array('checkout', 'editchangelog', 'tag', 'copy', 'virusscan', 'create', 'sign', 'obs', 'copychangelog'), |
|
| 73 | 73 | 'patchCmd' => '# run cmd after copy eg. "cd $egw_buildroot; patch -p1 /path/to/patch"', |
| 74 | - 'github_user' => 'ralfbecker', // Github user for following token |
|
| 75 | - 'github_token' => '', // Github repo personal access token from above user |
|
| 74 | + 'github_user' => 'ralfbecker', // Github user for following token |
|
| 75 | + 'github_token' => '', // Github repo personal access token from above user |
|
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | 78 | // process config from command line |
| 79 | 79 | $argv = $_SERVER['argv']; |
| 80 | 80 | $prog = array_shift($argv); |
| 81 | 81 | |
| 82 | -while(($arg = array_shift($argv))) |
|
| 82 | +while (($arg = array_shift($argv))) |
|
| 83 | 83 | { |
| 84 | 84 | if ($arg == '-v' || $arg == '--verbose') |
| 85 | 85 | { |
| 86 | 86 | ++$verbose; |
| 87 | 87 | } |
| 88 | - elseif($arg == '-h' || $arg == '--help') |
|
| 88 | + elseif ($arg == '-h' || $arg == '--help') |
|
| 89 | 89 | { |
| 90 | 90 | if (in_array('editchangelog', $config['skip']) || !in_array('editchangelog', $config['run'])) |
| 91 | 91 | { |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | usage(); |
| 95 | 95 | } |
| 96 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
| 96 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
| 97 | 97 | { |
| 98 | 98 | $value = array_shift($argv); |
| 99 | - switch($name) |
|
| 99 | + switch ($name) |
|
| 100 | 100 | { |
| 101 | 101 | case 'extra': // stored as array and allow to add/delete items with +/- prefix |
| 102 | 102 | case 'types': |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | $value = array_unique(preg_split('/[ ,]+/', $value)); |
| 121 | 121 | } |
| 122 | - switch($op) |
|
| 122 | + switch ($op) |
|
| 123 | 123 | { |
| 124 | 124 | case '+': |
| 125 | 125 | $config[$name] = array_unique(array_merge($config[$name], $value)); |
@@ -137,14 +137,14 @@ discard block |
||
| 137 | 137 | case 'release': |
| 138 | 138 | case 'copychangelog': |
| 139 | 139 | $config[$name] = $value; |
| 140 | - if ($value) array_unshift($config['run'],$name); |
|
| 140 | + if ($value) array_unshift($config['run'], $name); |
|
| 141 | 141 | break; |
| 142 | 142 | |
| 143 | 143 | case 'editchangelog': |
| 144 | 144 | $config[$name] = $value ? $value : true; |
| 145 | - if (!in_array('editchangelog',$config['run'])) |
|
| 145 | + if (!in_array('editchangelog', $config['run'])) |
|
| 146 | 146 | { |
| 147 | - array_unshift($config['run'],'editchangelog'); |
|
| 147 | + array_unshift($config['run'], 'editchangelog'); |
|
| 148 | 148 | } |
| 149 | 149 | break; |
| 150 | 150 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | usage("Path '$value' not found!"); |
| 155 | 155 | } |
| 156 | - if (!in_array('obs',$config['run'])) $config['run'][] = 'obs'; |
|
| 156 | + if (!in_array('obs', $config['run'])) $config['run'][] = 'obs'; |
|
| 157 | 157 | // fall through |
| 158 | 158 | default: |
| 159 | 159 | $config[$name] = $value; |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | $svn = $config['svn']; |
| 173 | 173 | |
| 174 | -$run = array_diff($config['run'],$config['skip']); |
|
| 174 | +$run = array_diff($config['run'], $config['skip']); |
|
| 175 | 175 | |
| 176 | 176 | // if we dont edit the changelog, set packaging from changelog |
| 177 | 177 | if (!in_array('editchangelog', $run)) |
| 178 | 178 | { |
| 179 | 179 | parse_current_changelog(true); |
| 180 | 180 | } |
| 181 | -foreach($run as $func) |
|
| 181 | +foreach ($run as $func) |
|
| 182 | 182 | { |
| 183 | - chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
| 183 | + chdir(dirname(__FILE__)); // make relative filenames work, if other command changes dir |
|
| 184 | 184 | call_user_func('do_'.$func); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
| 196 | 196 | * @return string with changelog |
| 197 | 197 | */ |
| 198 | -function get_changelog_from_git($_path, $log_pattern=null, &$last_tag=null, $prefix='* ') |
|
| 198 | +function get_changelog_from_git($_path, $log_pattern = null, &$last_tag = null, $prefix = '* ') |
|
| 199 | 199 | { |
| 200 | 200 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
| 201 | 201 | global $config; |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | run_cmd($cmd, $output); |
| 217 | 217 | |
| 218 | 218 | $changelog = ''; |
| 219 | - foreach($output as $line) |
|
| 219 | + foreach ($output as $line) |
|
| 220 | 220 | { |
| 221 | 221 | if (substr($line, 0, 4) == " " && ($msg = _match_log_pattern(substr($line, 4), $log_pattern, $prefix))) |
| 222 | 222 | { |
@@ -248,13 +248,13 @@ discard block |
||
| 248 | 248 | { |
| 249 | 249 | throw new Exception("checkout directory '{$config['checkoutdir']} does NOT exists or is NO directory!"); |
| 250 | 250 | } |
| 251 | - if (!($mrconfig = file_get_contents($path=$config['checkoutdir'].'/.mrconfig'))) |
|
| 251 | + if (!($mrconfig = file_get_contents($path = $config['checkoutdir'].'/.mrconfig'))) |
|
| 252 | 252 | { |
| 253 | 253 | throw new Exception("$path not found!"); |
| 254 | 254 | } |
| 255 | 255 | $module = $baseurl = null; |
| 256 | 256 | $modules = array(); |
| 257 | - foreach(explode("\n", $mrconfig) as $line) |
|
| 257 | + foreach (explode("\n", $mrconfig) as $line) |
|
| 258 | 258 | { |
| 259 | 259 | $matches = null; |
| 260 | 260 | if (isset($baseurl)) |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | $cmd = $config['git'].' clone '.(!empty($config['branch']) ? ' -b '.$config['branch'] : ''). |
| 320 | 320 | ' [email protected]:EGroupware/egroupware.git '.$config['checkoutdir']; |
| 321 | 321 | run_cmd($cmd); |
| 322 | - run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
| 322 | + run_cmd('mr up'); // need to run mr up twice for new checkout, because chained .mrconfig wont run first time (because not there yet!) |
|
| 323 | 323 | } |
| 324 | 324 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
| 325 | 325 | { |
@@ -343,9 +343,9 @@ discard block |
||
| 343 | 343 | } |
| 344 | 344 | chdir($config['checkoutdir']); |
| 345 | 345 | |
| 346 | - $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
| 346 | + $config['tag'] = config_translate('tag'); // allow to use config vars like $version in tag |
|
| 347 | 347 | |
| 348 | - if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
| 348 | + if (empty($config['tag'])) return; // otherwise we copy everything in svn root! |
|
| 349 | 349 | |
| 350 | 350 | echo "Creating tag $config[tag]\n"; |
| 351 | 351 | |
@@ -358,16 +358,16 @@ discard block |
||
| 358 | 358 | */ |
| 359 | 359 | function do_release() |
| 360 | 360 | { |
| 361 | - global $config,$verbose; |
|
| 361 | + global $config, $verbose; |
|
| 362 | 362 | |
| 363 | 363 | // push local changes to Github incl. tags |
| 364 | 364 | if ($verbose) echo "Pushing changes and tags\n"; |
| 365 | 365 | chdir($config['checkoutdir']); |
| 366 | - run_cmd($config['mr']. ' up'); // in case someone else pushed something |
|
| 366 | + run_cmd($config['mr'].' up'); // in case someone else pushed something |
|
| 367 | 367 | chdir($config['checkoutdir']); |
| 368 | - run_cmd($config['git'].' push'); // regular commits like changelog |
|
| 368 | + run_cmd($config['git'].' push'); // regular commits like changelog |
|
| 369 | 369 | $tag = config_translate('tag'); |
| 370 | - run_cmd($config['mr']. ' push origin '.$tag); // pushing tags in all apps |
|
| 370 | + run_cmd($config['mr'].' push origin '.$tag); // pushing tags in all apps |
|
| 371 | 371 | |
| 372 | 372 | if (empty($config['github_user']) || empty($config['github_token'])) |
| 373 | 373 | { |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | 'body' => $config['changelog'], |
| 385 | 385 | ); |
| 386 | 386 | $response = github_api("/repos/EGroupware/egroupware/releases", $data); |
| 387 | - $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
| 387 | + $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response['upload_url']); // remove {?name,label} template |
|
| 388 | 388 | |
| 389 | 389 | do_upload(); |
| 390 | 390 | } |
@@ -394,33 +394,33 @@ discard block |
||
| 394 | 394 | */ |
| 395 | 395 | function do_upload() |
| 396 | 396 | { |
| 397 | - global $config,$verbose; |
|
| 397 | + global $config, $verbose; |
|
| 398 | 398 | |
| 399 | 399 | if (empty($config['upload_url'])) |
| 400 | 400 | { |
| 401 | 401 | $response = github_api("/repos/EGroupware/egroupware/releases", array(), 'GET'); |
| 402 | - $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response[0]['upload_url']); // remove {?name,label} template |
|
| 402 | + $config['upload_url'] = preg_replace('/{\?[^}]+}$/', '', $response[0]['upload_url']); // remove {?name,label} template |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | $archives = config_translate('upload'); |
| 406 | 406 | echo "Uploading $archives to $config[upload_url]\n"; |
| 407 | 407 | |
| 408 | - foreach(glob($archives, GLOB_BRACE) as $path) |
|
| 408 | + foreach (glob($archives, GLOB_BRACE) as $path) |
|
| 409 | 409 | { |
| 410 | 410 | $label = null; |
| 411 | 411 | if (substr($path, -4) == '.zip') |
| 412 | 412 | { |
| 413 | 413 | $content_type = 'application/zip'; |
| 414 | 414 | } |
| 415 | - elseif(substr($path, -7) == '.tar.gz') |
|
| 415 | + elseif (substr($path, -7) == '.tar.gz') |
|
| 416 | 416 | { |
| 417 | 417 | $content_type = 'application/x-gzip'; |
| 418 | 418 | } |
| 419 | - elseif(substr($path, -8) == '.tar.bz2') |
|
| 419 | + elseif (substr($path, -8) == '.tar.bz2') |
|
| 420 | 420 | { |
| 421 | 421 | $content_type = 'application/x-bzip2'; |
| 422 | 422 | } |
| 423 | - elseif(substr($path, -8) == '.txt.asc') |
|
| 423 | + elseif (substr($path, -8) == '.txt.asc') |
|
| 424 | 424 | { |
| 425 | 425 | $content_type = 'text/plain'; |
| 426 | 426 | $label = 'Signed hashes of downloads'; |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | if (!empty($config['release'])) |
| 441 | 441 | { |
| 442 | - $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
| 442 | + $target = config_translate('release'); // allow to use config vars like $svnbranch in module |
|
| 443 | 443 | $cmd = $config['rsync'].' '.$archives.' '.$target; |
| 444 | 444 | if ($verbose) echo $cmd."\n"; |
| 445 | 445 | passthru($cmd); |
@@ -457,7 +457,7 @@ discard block |
||
| 457 | 457 | * @throws Exception |
| 458 | 458 | * @return array with response |
| 459 | 459 | */ |
| 460 | -function github_api($_url, $data, $method='POST', $upload=null, $content_type=null) |
|
| 460 | +function github_api($_url, $data, $method = 'POST', $upload = null, $content_type = null) |
|
| 461 | 461 | { |
| 462 | 462 | global $config, $verbose; |
| 463 | 463 | |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | curl_setopt($c, CURLOPT_TIMEOUT, 240); |
| 471 | 471 | curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); |
| 472 | 472 | |
| 473 | - switch($method) |
|
| 473 | + switch ($method) |
|
| 474 | 474 | { |
| 475 | 475 | case 'POST': |
| 476 | 476 | curl_setopt($c, CURLOPT_POST, true); |
@@ -478,13 +478,13 @@ discard block |
||
| 478 | 478 | curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
| 479 | 479 | break; |
| 480 | 480 | case 'GET': |
| 481 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 481 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 482 | 482 | break; |
| 483 | 483 | case 'FILE': |
| 484 | 484 | curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: $content_type")); |
| 485 | 485 | curl_setopt($c, CURLOPT_POST, true); |
| 486 | 486 | curl_setopt($c, CURLOPT_POSTFIELDS, file_get_contents($upload)); |
| 487 | - if(count($data)) $url .= '?' . http_build_query($data); |
|
| 487 | + if (count($data)) $url .= '?'.http_build_query($data); |
|
| 488 | 488 | break; |
| 489 | 489 | default: |
| 490 | 490 | throw new Exception(__FUNCTION__.": Unknown/unimplemented method=$method!"); |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | curl_setopt($c, CURLOPT_URL, $url); |
| 493 | 493 | |
| 494 | 494 | if (is_string($data)) $short_data = strlen($data) > 100 ? substr($data, 0, 100).' ...' : $data; |
| 495 | - if ($verbose) echo "Sending $method request to $url ".(isset($short_data)&&$method!='GET'?$short_data:'')."\n"; |
|
| 495 | + if ($verbose) echo "Sending $method request to $url ".(isset($short_data) && $method != 'GET' ? $short_data : '')."\n"; |
|
| 496 | 496 | |
| 497 | 497 | if (($response = curl_exec($c)) === false) |
| 498 | 498 | { |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | curl_setopt($c, CURLOPT_HEADER, true); |
| 501 | 501 | curl_setopt($c, CURLOPT_RETURNTRANSFER, false); |
| 502 | 502 | curl_exec($c); |
| 503 | - throw new Exception("$method request to $url failed ".(isset($short_data)&&$method!='GET'?$short_data:'')); |
|
| 503 | + throw new Exception("$method request to $url failed ".(isset($short_data) && $method != 'GET' ? $short_data : '')); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | if ($verbose) echo (strlen($response) > 200 ? substr($response, 0, 200).' ...' : $response)."\n"; |
@@ -516,7 +516,7 @@ discard block |
||
| 516 | 516 | * @param string $name |
| 517 | 517 | * @param string $value =null value to use, default $config[$name] |
| 518 | 518 | */ |
| 519 | -function config_translate($name, $value=null) |
|
| 519 | +function config_translate($name, $value = null) |
|
| 520 | 520 | { |
| 521 | 521 | global $config; |
| 522 | 522 | |
@@ -524,7 +524,7 @@ discard block |
||
| 524 | 524 | if (is_string($value) && strpos($value, '$') !== false) |
| 525 | 525 | { |
| 526 | 526 | $translate = array(); |
| 527 | - foreach($config as $n => $val) |
|
| 527 | + foreach ($config as $n => $val) |
|
| 528 | 528 | { |
| 529 | 529 | if (is_string($val)) $translate['$'.$n] = $val; |
| 530 | 530 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | */ |
| 551 | 551 | function do_editchangelog() |
| 552 | 552 | { |
| 553 | - global $config,$svn; |
|
| 553 | + global $config, $svn; |
|
| 554 | 554 | |
| 555 | 555 | echo "Querying changelog from Git/SVN\n"; |
| 556 | 556 | if (!isset($config['modules'])) |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | // query changelog per repo |
| 561 | 561 | $changelog = ''; |
| 562 | 562 | $last_tag = null; |
| 563 | - foreach($config['modules'] as $branch_url => $modules) |
|
| 563 | + foreach ($config['modules'] as $branch_url => $modules) |
|
| 564 | 564 | { |
| 565 | 565 | $revision = null; |
| 566 | 566 | if (substr($branch_url, -4) == '.git') |
@@ -573,15 +573,15 @@ discard block |
||
| 573 | 573 | $changelog .= get_changelog_from_svn($branch_url, $config['editchangelog'], $revision); |
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | - $logfile = tempnam('/tmp','checkout-build-archives'); |
|
| 577 | - file_put_contents($logfile,$changelog); |
|
| 576 | + $logfile = tempnam('/tmp', 'checkout-build-archives'); |
|
| 577 | + file_put_contents($logfile, $changelog); |
|
| 578 | 578 | $cmd = $config['editor'].' '.escapeshellarg($logfile); |
| 579 | 579 | passthru($cmd); |
| 580 | 580 | $config['changelog'] = file_get_contents($logfile); |
| 581 | 581 | // remove trailing newlines |
| 582 | - while (substr($config['changelog'],-1) == "\n") |
|
| 582 | + while (substr($config['changelog'], -1) == "\n") |
|
| 583 | 583 | { |
| 584 | - $config['changelog'] = substr($config['changelog'],0,-1); |
|
| 584 | + $config['changelog'] = substr($config['changelog'], 0, -1); |
|
| 585 | 585 | } |
| 586 | 586 | // allow user to abort, by deleting the changelog |
| 587 | 587 | if (strlen($config['changelog']) <= 2) |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | } |
| 597 | 597 | file_put_contents($changelog, update_changelog(file_get_contents($changelog))); |
| 598 | 598 | |
| 599 | - update_api_setup($api_setup=$config['checkoutdir'].'/api/setup/setup.inc.php'); |
|
| 599 | + update_api_setup($api_setup = $config['checkoutdir'].'/api/setup/setup.inc.php'); |
|
| 600 | 600 | |
| 601 | 601 | if (file_exists($config['checkoutdir'].'/.git')) |
| 602 | 602 | { |
@@ -609,7 +609,7 @@ discard block |
||
| 609 | 609 | run_cmd($cmd); |
| 610 | 610 | |
| 611 | 611 | // update obs changelogs (so all changlogs are updated in case of a later error and changelog step can be skiped) |
| 612 | - do_obs(true); // true: only update debian.changes in obs checkouts |
|
| 612 | + do_obs(true); // true: only update debian.changes in obs checkouts |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -623,41 +623,41 @@ discard block |
||
| 623 | 623 | * @param string $prefix ='* ' prefix, which if not presend should be added to all log messages |
| 624 | 624 | * @return string with changelog |
| 625 | 625 | */ |
| 626 | -function get_changelog_from_svn($branch_url, $log_pattern=null, &$revision=null, $prefix='* ') |
|
| 626 | +function get_changelog_from_svn($branch_url, $log_pattern = null, &$revision = null, $prefix = '* ') |
|
| 627 | 627 | { |
| 628 | 628 | //echo __FUNCTION__."('$branch_url','$log_pattern','$revision','$prefix')\n"; |
| 629 | - global $config,$verbose,$svn; |
|
| 629 | + global $config, $verbose, $svn; |
|
| 630 | 630 | |
| 631 | 631 | if (is_null($revision)) |
| 632 | 632 | { |
| 633 | - list($tags_url,$branch) = preg_split('#/(branches/|trunk)#',$branch_url); |
|
| 633 | + list($tags_url, $branch) = preg_split('#/(branches/|trunk)#', $branch_url); |
|
| 634 | 634 | if (empty($branch)) $branch = $config['version']; |
| 635 | 635 | $tags_url .= '/tags'; |
| 636 | - $pattern='|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
| 636 | + $pattern = '|/tags/('.preg_quote($config['version'], '|').'\.[0-9.]+)|'; |
|
| 637 | 637 | $matches = null; |
| 638 | - $revision = get_last_svn_tag($tags_url,$pattern,$matches); |
|
| 638 | + $revision = get_last_svn_tag($tags_url, $pattern, $matches); |
|
| 639 | 639 | $tag = $matches[1]; |
| 640 | 640 | } |
| 641 | - elseif(!is_numeric($revision)) |
|
| 641 | + elseif (!is_numeric($revision)) |
|
| 642 | 642 | { |
| 643 | - $revision = get_last_svn_tag($tags_url,$tag=$revision); |
|
| 643 | + $revision = get_last_svn_tag($tags_url, $tag = $revision); |
|
| 644 | 644 | } |
| 645 | 645 | $cmd = $svn.' log --xml -r '.escapeshellarg($revision.':HEAD').' '.escapeshellarg($branch_url); |
| 646 | 646 | if (($v = $verbose)) |
| 647 | 647 | { |
| 648 | 648 | echo "Querying SVN for log from r$revision".($tag ? " ($tag)" : '').":\n$cmd\n"; |
| 649 | - $verbose = false; // otherwise no $output! |
|
| 649 | + $verbose = false; // otherwise no $output! |
|
| 650 | 650 | } |
| 651 | 651 | $output = array(); |
| 652 | - run_cmd($cmd,$output); |
|
| 652 | + run_cmd($cmd, $output); |
|
| 653 | 653 | $verbose = $v; |
| 654 | - array_shift($output); // remove the command |
|
| 654 | + array_shift($output); // remove the command |
|
| 655 | 655 | |
| 656 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
| 656 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
| 657 | 657 | $message = ''; |
| 658 | - foreach($xml as $log) |
|
| 658 | + foreach ($xml as $log) |
|
| 659 | 659 | { |
| 660 | - if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
| 660 | + if (!($msg = _match_log_pattern($log->msg, $log_pattern, $prefix))) continue; // no match --> ignore |
|
| 661 | 661 | |
| 662 | 662 | $message .= $msg."\n"; |
| 663 | 663 | } |
@@ -674,25 +674,25 @@ discard block |
||
| 674 | 674 | * @param string $prefix ='* ' |
| 675 | 675 | * @return string |
| 676 | 676 | */ |
| 677 | -function _match_log_pattern($msg, $log_pattern, $prefix='* ') |
|
| 677 | +function _match_log_pattern($msg, $log_pattern, $prefix = '* ') |
|
| 678 | 678 | { |
| 679 | 679 | $pattern_len = strlen($log_pattern); |
| 680 | 680 | $prefix_len = strlen($prefix); |
| 681 | 681 | |
| 682 | 682 | $matches = null; |
| 683 | - if ($log_pattern[0] == '/' && preg_match($log_pattern,$msg,$matches)) |
|
| 683 | + if ($log_pattern[0] == '/' && preg_match($log_pattern, $msg, $matches)) |
|
| 684 | 684 | { |
| 685 | 685 | $msg = $matches[1]; |
| 686 | 686 | } |
| 687 | - elseif($log_pattern && $log_pattern[0] != '/' && substr($msg,0,$pattern_len) == $log_pattern) |
|
| 687 | + elseif ($log_pattern && $log_pattern[0] != '/' && substr($msg, 0, $pattern_len) == $log_pattern) |
|
| 688 | 688 | { |
| 689 | - list($msg) = explode("\n",$msg); |
|
| 689 | + list($msg) = explode("\n", $msg); |
|
| 690 | 690 | } |
| 691 | - elseif($log_pattern) |
|
| 691 | + elseif ($log_pattern) |
|
| 692 | 692 | { |
| 693 | 693 | return null; |
| 694 | 694 | } |
| 695 | - if ($prefix_len && substr($msg,0,$prefix_len) != $prefix) $msg = $prefix.$msg; |
|
| 695 | + if ($prefix_len && substr($msg, 0, $prefix_len) != $prefix) $msg = $prefix.$msg; |
|
| 696 | 696 | |
| 697 | 697 | return $msg; |
| 698 | 698 | } |
@@ -706,30 +706,30 @@ discard block |
||
| 706 | 706 | * @param array &$matches=null on return matches of preg_match |
| 707 | 707 | * @return int revision of last svn tag matching pattern |
| 708 | 708 | */ |
| 709 | -function get_last_svn_tag($tags_url,$pattern,&$matches=null) |
|
| 709 | +function get_last_svn_tag($tags_url, $pattern, &$matches = null) |
|
| 710 | 710 | { |
| 711 | - global $verbose,$svn; |
|
| 711 | + global $verbose, $svn; |
|
| 712 | 712 | |
| 713 | 713 | $cmd = $svn.' log --xml --limit 40 -v '.escapeshellarg($tags_url); |
| 714 | 714 | if (($v = $verbose)) |
| 715 | 715 | { |
| 716 | 716 | echo "Querying SVN for last tags\n$cmd\n"; |
| 717 | - $verbose = false; // otherwise no $output! |
|
| 717 | + $verbose = false; // otherwise no $output! |
|
| 718 | 718 | } |
| 719 | 719 | $output = array(); |
| 720 | - run_cmd($cmd,$output); |
|
| 720 | + run_cmd($cmd, $output); |
|
| 721 | 721 | $verbose = $v; |
| 722 | - array_shift($output); // remove the command |
|
| 722 | + array_shift($output); // remove the command |
|
| 723 | 723 | |
| 724 | - $xml = simplexml_load_string($output=implode("\n",$output)); |
|
| 724 | + $xml = simplexml_load_string($output = implode("\n", $output)); |
|
| 725 | 725 | $is_regexp = $pattern[0] == substr($pattern, -1); |
| 726 | - foreach($xml as $log) |
|
| 726 | + foreach ($xml as $log) |
|
| 727 | 727 | { |
| 728 | 728 | //print_r($log); |
| 729 | 729 | if (!$is_regexp && strpos($log->paths->path, $pattern) !== false || |
| 730 | 730 | $is_regexp && preg_match($pattern, $log->paths->path, $matches)) |
| 731 | 731 | { |
| 732 | - if ($verbose) echo "Revision {$log['revision']} matches".($matches?': '.$matches[1] : '')."\n"; |
|
| 732 | + if ($verbose) echo "Revision {$log['revision']} matches".($matches ? ': '.$matches[1] : '')."\n"; |
|
| 733 | 733 | return (int)$log['revision']; |
| 734 | 734 | } |
| 735 | 735 | } |
@@ -741,9 +741,9 @@ discard block |
||
| 741 | 741 | * |
| 742 | 742 | * @param boolean $only_update_changelog =false true update debian.changes, but nothing else, nor commit it |
| 743 | 743 | */ |
| 744 | -function do_obs($only_update_changelog=false) |
|
| 744 | +function do_obs($only_update_changelog = false) |
|
| 745 | 745 | { |
| 746 | - global $config,$verbose; |
|
| 746 | + global $config, $verbose; |
|
| 747 | 747 | |
| 748 | 748 | if (!is_dir($config['obs'])) |
| 749 | 749 | { |
@@ -753,25 +753,25 @@ discard block |
||
| 753 | 753 | run_cmd('osc up '.$config['obs']); |
| 754 | 754 | |
| 755 | 755 | $n = 0; |
| 756 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
| 756 | + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($config['obs'])) as $path) |
|
| 757 | 757 | { |
| 758 | 758 | if (basename(dirname($path)) == '.osc' || |
| 759 | 759 | !preg_match('/\/('.preg_quote($config['packagename']). |
| 760 | 760 | ($config['obs_package_alias'] ? '|'.preg_quote($config['obs_package_alias']) : ''). |
| 761 | - ')[a-z-]*-('.preg_quote($config['version']).'|trunk)/',$path)) |
|
| 761 | + ')[a-z-]*-('.preg_quote($config['version']).'|trunk)/', $path)) |
|
| 762 | 762 | { |
| 763 | 763 | continue; |
| 764 | 764 | } |
| 765 | 765 | $matches = null; |
| 766 | - if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/',$path,$matches) && |
|
| 767 | - file_exists($new_name=$config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
| 766 | + if (preg_match('/\/('.preg_quote($config['packagename']).'[a-z-]*)-'.preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/', $path, $matches) && |
|
| 767 | + file_exists($new_name = $config['sourcedir'].'/'.$matches[1].'-'.$config['version'].'.'.$config['packaging'].$matches[2])) |
|
| 768 | 768 | { |
| 769 | 769 | if (basename($path) != basename($new_name)) |
| 770 | 770 | { |
| 771 | 771 | unlink($path); |
| 772 | 772 | if ($verbose) echo "rm $path\n"; |
| 773 | 773 | } |
| 774 | - copy($new_name,dirname($path).'/'.basename($new_name)); |
|
| 774 | + copy($new_name, dirname($path).'/'.basename($new_name)); |
|
| 775 | 775 | if ($verbose) echo "cp $new_name ".dirname($path)."/\n"; |
| 776 | 776 | ++$n; |
| 777 | 777 | } |
@@ -781,35 +781,35 @@ discard block |
||
| 781 | 781 | $config['changelog'] = parse_current_changelog(); |
| 782 | 782 | } |
| 783 | 783 | // updating dsc, spec and changelog files |
| 784 | - if (!$only_update_changelog && (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') || |
|
| 784 | + if (!$only_update_changelog && (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') || |
|
| 785 | 785 | !empty($config['changelog']) && basename($path) == 'debian.changes') |
| 786 | 786 | { |
| 787 | 787 | $content = $content_was = file_get_contents($path); |
| 788 | 788 | |
| 789 | - if (substr($path,-4) == '.dsc' || substr($path,-5) == '.spec') |
|
| 789 | + if (substr($path, -4) == '.dsc' || substr($path, -5) == '.spec') |
|
| 790 | 790 | { |
| 791 | - $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m','Version: '.$config['version'].'.'.$config['packaging'],$content); |
|
| 791 | + $content = preg_replace('/^Version: '.preg_quote($config['version']).'\.[0-9.]+[0-9]/m', 'Version: '.$config['version'].'.'.$config['packaging'], $content); |
|
| 792 | 792 | } |
| 793 | - if (substr($path,-4) == '.dsc') |
|
| 793 | + if (substr($path, -4) == '.dsc') |
|
| 794 | 794 | { |
| 795 | 795 | $content = preg_replace('/^(Debtransform-Tar: '.preg_quote($config['packagename']).'[a-z-]*)-'. |
| 796 | 796 | preg_quote($config['version']).'\.[0-9.]+[0-9](\.tar\.(gz|bz2))$/m', |
| 797 | - '\\1-'.$config['version'].'.'.$config['packaging'].'\\2',$content); |
|
| 797 | + '\\1-'.$config['version'].'.'.$config['packaging'].'\\2', $content); |
|
| 798 | 798 | } |
| 799 | - if (basename($path) == 'debian.changes' && strpos($content,$config['version'].'.'.$config['packaging']) === false) |
|
| 799 | + if (basename($path) == 'debian.changes' && strpos($content, $config['version'].'.'.$config['packaging']) === false) |
|
| 800 | 800 | { |
| 801 | 801 | $content = update_changelog($content); |
| 802 | 802 | } |
| 803 | - if (!empty($config['changelog']) && substr($path,-5) == '.spec' && |
|
| 804 | - ($pos_changelog = strpos($content,'%changelog')) !== false) |
|
| 803 | + if (!empty($config['changelog']) && substr($path, -5) == '.spec' && |
|
| 804 | + ($pos_changelog = strpos($content, '%changelog')) !== false) |
|
| 805 | 805 | { |
| 806 | 806 | $pos_changelog += strlen("%changelog\n"); |
| 807 | - $content = substr($content,0,$pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
| 808 | - $config['changelog']."\n".substr($content,$pos_changelog); |
|
| 807 | + $content = substr($content, 0, $pos_changelog).' *'.date('D M d Y').' '.$config['changelog_packager']."\n". |
|
| 808 | + $config['changelog']."\n".substr($content, $pos_changelog); |
|
| 809 | 809 | } |
| 810 | 810 | if ($content != $content_was) |
| 811 | 811 | { |
| 812 | - file_put_contents($path,$content); |
|
| 812 | + file_put_contents($path, $content); |
|
| 813 | 813 | if ($verbose) echo "Updated $path\n"; |
| 814 | 814 | ++$n; |
| 815 | 815 | } |
@@ -830,33 +830,33 @@ discard block |
||
| 830 | 830 | * @param boolean $set_packaging =false true: set packaging from last changelog entry |
| 831 | 831 | * @return string changelog entries without header and footer lines |
| 832 | 832 | */ |
| 833 | -function parse_current_changelog($set_packaging=false) |
|
| 833 | +function parse_current_changelog($set_packaging = false) |
|
| 834 | 834 | { |
| 835 | 835 | global $config; |
| 836 | 836 | |
| 837 | 837 | $changelog = file_get_contents($config['checkoutdir'].'/doc/rpm-build/debian.changes'); |
| 838 | 838 | $lines = explode("\n", $changelog, 100); |
| 839 | 839 | $matches = null; |
| 840 | - foreach($lines as $n => $line) |
|
| 840 | + foreach ($lines as $n => $line) |
|
| 841 | 841 | { |
| 842 | - if (preg_match($preg='/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
| 842 | + if (preg_match($preg = '/^'.preg_quote($config['packagename']).' \('.preg_quote($config['version']).'\.'. |
|
| 843 | 843 | ($set_packaging ? '([0-9]+)' : preg_quote($config['packaging'])).'/', $line, $matches)) |
| 844 | 844 | { |
| 845 | 845 | if ($set_packaging) |
| 846 | 846 | { |
| 847 | 847 | $config['packaging'] = $matches[1]; |
| 848 | 848 | } |
| 849 | - $n += empty($lines[$n+1]) ? 2 : 1; // overead empty line behind header |
|
| 849 | + $n += empty($lines[$n + 1]) ? 2 : 1; // overead empty line behind header |
|
| 850 | 850 | $logentry = ''; |
| 851 | - while($lines[$n]) // entry is terminated by empty line |
|
| 851 | + while ($lines[$n]) // entry is terminated by empty line |
|
| 852 | 852 | { |
| 853 | 853 | $logentry .= (substr($lines[$n], 0, 2) == ' ' ? substr($lines[$n], 2) : $lines[$n])."\n"; |
| 854 | 854 | ++$n; |
| 855 | 855 | } |
| 856 | - return substr($logentry, 0, -1); // remove training "\n" |
|
| 856 | + return substr($logentry, 0, -1); // remove training "\n" |
|
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | - return null; // paragraph for current version NOT found |
|
| 859 | + return null; // paragraph for current version NOT found |
|
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | /** |
@@ -870,8 +870,8 @@ discard block |
||
| 870 | 870 | global $config; |
| 871 | 871 | |
| 872 | 872 | list($header) = explode("\n", $content); |
| 873 | - $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/','('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
| 874 | - if (substr($config['changelog'],0,2) != ' ') $config['changelog'] = ' '.implode("\n ",explode("\n",$config['changelog'])); |
|
| 873 | + $new_header = preg_replace('/\('.preg_quote($config['version']).'\.[0-9.]+[0-9](.*)\)/', '('.$config['version'].'.'.$config['packaging'].'\\1)', $header); |
|
| 874 | + if (substr($config['changelog'], 0, 2) != ' ') $config['changelog'] = ' '.implode("\n ", explode("\n", $config['changelog'])); |
|
| 875 | 875 | $content = $new_header."\n\n".$config['changelog']. |
| 876 | 876 | "\n\n -- ".$config['changelog_packager'].' '.date('r')."\n\n".$content; |
| 877 | 877 | |
@@ -909,9 +909,9 @@ discard block |
||
| 909 | 909 | { |
| 910 | 910 | global $config; |
| 911 | 911 | |
| 912 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 912 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 913 | 913 | { |
| 914 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
| 914 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
| 915 | 915 | } |
| 916 | 916 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 917 | 917 | |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | if (file_exists($sumsfile.'.asc')) unlink($sumsfile.'.asc'); |
| 931 | 931 | $cmd = $config['gpg'].' --local-user '.$config['packager'].' --clearsign '.$sumsfile; |
| 932 | 932 | run_cmd($cmd); |
| 933 | - unlink($sumsfile); // delete the unsigned file |
|
| 933 | + unlink($sumsfile); // delete the unsigned file |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -940,22 +940,22 @@ discard block |
||
| 940 | 940 | { |
| 941 | 941 | global $config; |
| 942 | 942 | |
| 943 | - if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'],0755,true); |
|
| 944 | - if (substr($config['sourcedir'],0,2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 943 | + if (!file_exists($config['sourcedir'])) mkdir($config['sourcedir'], 0755, true); |
|
| 944 | + if (substr($config['sourcedir'], 0, 2) == '~/') // sha1_file cant deal with '~/rpm' |
|
| 945 | 945 | { |
| 946 | - $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'],1); |
|
| 946 | + $config['sourcedir'] = getenv('HOME').substr($config['sourcedir'], 1); |
|
| 947 | 947 | } |
| 948 | 948 | $sumsfile = $config['sourcedir'].'/sha1sum-'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.txt'; |
| 949 | 949 | $sums = ''; |
| 950 | 950 | |
| 951 | 951 | chdir($config['egw_buildroot']); |
| 952 | 952 | |
| 953 | - if($config['extra']) |
|
| 953 | + if ($config['extra']) |
|
| 954 | 954 | { |
| 955 | 955 | $exclude = $exclude_all = array(); |
| 956 | - foreach($config['extra'] as $name => $modules) |
|
| 956 | + foreach ($config['extra'] as $name => $modules) |
|
| 957 | 957 | { |
| 958 | - foreach((array)$modules as $module) |
|
| 958 | + foreach ((array)$modules as $module) |
|
| 959 | 959 | { |
| 960 | 960 | $exclude[] = basename($module); |
| 961 | 961 | if (!empty($config['all-add']) && !in_array($module, $config['all-add']) && (is_int($name) || !in_array($name, $config['all-add']))) |
@@ -965,24 +965,24 @@ discard block |
||
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | $exclude_extra = ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude); |
| 968 | - $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
| 968 | + $exclude_all_extra = $exclude_all ? ' --exclude=egroupware/'.implode(' --exclude=egroupware/', $exclude_all) : ''; |
|
| 969 | 969 | } |
| 970 | - foreach($config['types'] as $type) |
|
| 970 | + foreach ($config['types'] as $type) |
|
| 971 | 971 | { |
| 972 | 972 | echo "Creating $type archives\n"; |
| 973 | 973 | $tar_type = $type == 'tar.bz2' ? 'j' : 'z'; |
| 974 | 974 | |
| 975 | 975 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
| 976 | - switch($type) |
|
| 976 | + switch ($type) |
|
| 977 | 977 | { |
| 978 | 978 | case 'all.tar.bz2': // single tar-ball for debian builds not easily supporting to use multiple |
| 979 | 979 | $file = $config['sourcedir'].'/'.$config['packagename'].'-all-'.$config['version'].'.'.$config['packaging'].'.tar'; |
| 980 | 980 | $cmd = $config['tar'].' --owner=root --group=root -cf '.$file.$exclude_all_extra.' egroupware'; |
| 981 | 981 | if (!empty($config['all-add'])) |
| 982 | 982 | { |
| 983 | - foreach((array)$config['all-add'] as $add) |
|
| 983 | + foreach ((array)$config['all-add'] as $add) |
|
| 984 | 984 | { |
| 985 | - if (substr($add, -4) != '.tar') continue; // probably a module |
|
| 985 | + if (substr($add, -4) != '.tar') continue; // probably a module |
|
| 986 | 986 | if (!($tar = realpath($add))) throw new Exception("File '$add' not found!"); |
| 987 | 987 | $cmd .= '; '.$config['tar'].' --owner=root --group=root -Af '.$file.' '.$tar; |
| 988 | 988 | } |
@@ -1006,15 +1006,15 @@ discard block |
||
| 1006 | 1006 | run_cmd($cmd); |
| 1007 | 1007 | $sums .= sha1_file($file)."\t".basename($file)."\n"; |
| 1008 | 1008 | |
| 1009 | - foreach($config['extra'] as $name => $modules) |
|
| 1009 | + foreach ($config['extra'] as $name => $modules) |
|
| 1010 | 1010 | { |
| 1011 | 1011 | if (is_numeric($name)) $name = $modules; |
| 1012 | 1012 | $dirs = ' egroupware/'.implode(' egroupware/', (array)$modules); |
| 1013 | 1013 | $file = $config['sourcedir'].'/'.$config['packagename'].'-'.$name.'-'.$config['version'].'.'.$config['packaging'].'.'.$type; |
| 1014 | - switch($type) |
|
| 1014 | + switch ($type) |
|
| 1015 | 1015 | { |
| 1016 | 1016 | case 'all.tar.bz2': |
| 1017 | - break; // nothing to do |
|
| 1017 | + break; // nothing to do |
|
| 1018 | 1018 | case 'tar.bz2': |
| 1019 | 1019 | case 'tar.gz': |
| 1020 | 1020 | $cmd = $config['tar'].' --owner=root --group=root -c'.$tar_type.'f '.$file.$dirs; |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | // writing sha1sum file |
| 1032 | - file_put_contents($sumsfile,$sums); |
|
| 1032 | + file_put_contents($sumsfile, $sums); |
|
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | 1035 | /** |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | */ |
| 1038 | 1038 | function do_virusscan() |
| 1039 | 1039 | { |
| 1040 | - global $config,$verbose; |
|
| 1040 | + global $config, $verbose; |
|
| 1041 | 1041 | |
| 1042 | 1042 | if (!file_exists($config['clamscan']) || !is_executable($config['clamscan'])) |
| 1043 | 1043 | { |
@@ -1051,7 +1051,7 @@ discard block |
||
| 1051 | 1051 | $cmd = '/usr/bin/sudo '.$config['freshclam']; |
| 1052 | 1052 | if (!$verbose && function_exists('posix_getuid') && posix_getuid()) echo $cmd."\n"; |
| 1053 | 1053 | $output = null; |
| 1054 | - run_cmd($cmd,$output,1); // 1 = ignore already up to date database |
|
| 1054 | + run_cmd($cmd, $output, 1); // 1 = ignore already up to date database |
|
| 1055 | 1055 | } |
| 1056 | 1056 | echo "Starting virusscan\n"; |
| 1057 | 1057 | $cmd = $config['clamscan'].' --quiet -r '.$config['egw_buildroot']; |
@@ -1108,12 +1108,12 @@ discard block |
||
| 1108 | 1108 | */ |
| 1109 | 1109 | function do_svncheckout() |
| 1110 | 1110 | { |
| 1111 | - global $config,$svn; |
|
| 1111 | + global $config, $svn; |
|
| 1112 | 1112 | |
| 1113 | 1113 | echo "Starting svn checkout/update\n"; |
| 1114 | 1114 | if (!file_exists($config['checkoutdir'])) |
| 1115 | 1115 | { |
| 1116 | - mkdir($config['checkoutdir'],0755,true); |
|
| 1116 | + mkdir($config['checkoutdir'], 0755, true); |
|
| 1117 | 1117 | } |
| 1118 | 1118 | elseif (!is_dir($config['checkoutdir']) || !is_writable($config['checkoutdir'])) |
| 1119 | 1119 | { |
@@ -1128,17 +1128,17 @@ discard block |
||
| 1128 | 1128 | { |
| 1129 | 1129 | get_modules_per_repo(); |
| 1130 | 1130 | } |
| 1131 | - $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
| 1131 | + $config['svntag'] = config_translate('svntag'); // in case svntag command did not run, translate tag name |
|
| 1132 | 1132 | |
| 1133 | 1133 | if (file_exists($config['aliasdir'])) |
| 1134 | 1134 | { |
| 1135 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
| 1135 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout, as we dont implement switching tags |
|
| 1136 | 1136 | clearstatcache(); |
| 1137 | 1137 | } |
| 1138 | - foreach($config['modules'] as $repo => $modules) |
|
| 1138 | + foreach ($config['modules'] as $repo => $modules) |
|
| 1139 | 1139 | { |
| 1140 | 1140 | $cmd = $svn.' co '; |
| 1141 | - foreach($modules as $path => $url) |
|
| 1141 | + foreach ($modules as $path => $url) |
|
| 1142 | 1142 | { |
| 1143 | 1143 | if ($path == $config['aliasdir']) |
| 1144 | 1144 | { |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | $cmd = $svn.' co '; |
| 1149 | 1149 | continue; |
| 1150 | 1150 | } |
| 1151 | - if(file_exists($config['aliasdir'])) |
|
| 1151 | + if (file_exists($config['aliasdir'])) |
|
| 1152 | 1152 | { |
| 1153 | 1153 | die("'egroupware' applications must be first one in externals!\n"); |
| 1154 | 1154 | } |
@@ -1166,16 +1166,16 @@ discard block |
||
| 1166 | 1166 | // check if correct branch |
| 1167 | 1167 | $cmd = 'LANG=C '.$svn.' info'; |
| 1168 | 1168 | $output = $ret = null; |
| 1169 | - exec($cmd,$output,$ret); |
|
| 1170 | - foreach($output as $line) |
|
| 1169 | + exec($cmd, $output, $ret); |
|
| 1170 | + foreach ($output as $line) |
|
| 1171 | 1171 | { |
| 1172 | - if ($ret || substr($line,0,5) == 'URL: ') |
|
| 1172 | + if ($ret || substr($line, 0, 5) == 'URL: ') |
|
| 1173 | 1173 | { |
| 1174 | - $url = substr($line,5); |
|
| 1175 | - if ($ret || substr($url,0,strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
| 1174 | + $url = substr($line, 5); |
|
| 1175 | + if ($ret || substr($url, 0, strlen($svnbranch)) != $svnbranch) // wrong branch (or no svn dir) |
|
| 1176 | 1176 | { |
| 1177 | 1177 | echo "Checkout is of wrong branch --> deleting it\n"; |
| 1178 | - system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
| 1178 | + system('/bin/rm -rf .svn '.$config['aliasdir']); // --> remove the whole checkout |
|
| 1179 | 1179 | clearstatcache(); |
| 1180 | 1180 | } |
| 1181 | 1181 | break; |
@@ -1187,10 +1187,10 @@ discard block |
||
| 1187 | 1187 | run_cmd($cmd); |
| 1188 | 1188 | |
| 1189 | 1189 | chdir($config['aliasdir']); |
| 1190 | - foreach($config['extra'] as $module) |
|
| 1190 | + foreach ($config['extra'] as $module) |
|
| 1191 | 1191 | { |
| 1192 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
| 1193 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
| 1192 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
| 1193 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
| 1194 | 1194 | $url .= $module; |
| 1195 | 1195 | $cmd = $svn.' co '.$url; |
| 1196 | 1196 | run_cmd($cmd); |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | */ |
| 1216 | 1216 | function get_modules_per_svn_repo() |
| 1217 | 1217 | { |
| 1218 | - global $config,$svn,$verbose; |
|
| 1218 | + global $config, $svn, $verbose; |
|
| 1219 | 1219 | |
| 1220 | 1220 | // process alias/externals |
| 1221 | 1221 | $svnbranch = $config['svnbase'].'/'.$config['svnbranch']; |
@@ -1223,27 +1223,27 @@ discard block |
||
| 1223 | 1223 | $cmd = $svn.' propget svn:externals --strict '.$url; |
| 1224 | 1224 | if ($verbose) echo $cmd."\n"; |
| 1225 | 1225 | $output = $ret = null; |
| 1226 | - exec($cmd,$output,$ret); |
|
| 1226 | + exec($cmd, $output, $ret); |
|
| 1227 | 1227 | $config['modules'] = array(); |
| 1228 | - foreach($output as $line) |
|
| 1228 | + foreach ($output as $line) |
|
| 1229 | 1229 | { |
| 1230 | 1230 | $line = trim($line); |
| 1231 | 1231 | if (empty($line) || $line[0] == '#') continue; |
| 1232 | - list($path,$url) = preg_split('/[ \t\r\n]+/',$line); |
|
| 1232 | + list($path, $url) = preg_split('/[ \t\r\n]+/', $line); |
|
| 1233 | 1233 | $matches = null; |
| 1234 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1234 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
| 1235 | 1235 | $repo = $matches[1]; |
| 1236 | 1236 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
| 1237 | 1237 | $config['modules'][$repo][$path] = $url; |
| 1238 | 1238 | } |
| 1239 | 1239 | // process extra modules |
| 1240 | - foreach($config['extra'] as $module) |
|
| 1240 | + foreach ($config['extra'] as $module) |
|
| 1241 | 1241 | { |
| 1242 | - $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
| 1243 | - $url = strpos($module,'://') === false ? $svnbranch.'/' : ''; |
|
| 1242 | + $module = config_translate(null, $module); // allow to use config vars like $svnbranch in module |
|
| 1243 | + $url = strpos($module, '://') === false ? $svnbranch.'/' : ''; |
|
| 1244 | 1244 | $url .= $module; |
| 1245 | - if (strpos($module,'://') !== false) $module = basename($module); |
|
| 1246 | - if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/',$url,$matches)) die("Invalid SVN URL: $url\n"); |
|
| 1245 | + if (strpos($module, '://') !== false) $module = basename($module); |
|
| 1246 | + if (!preg_match('/([a-z+]+:\/\/[a-z@.]+\/[a-z]+)\/(branches|tags|trunk)/', $url, $matches)) die("Invalid SVN URL: $url\n"); |
|
| 1247 | 1247 | $repo = $matches[1]; |
| 1248 | 1248 | if ($repo == 'http://svn.egroupware.org/egroupware') $repo = 'svn+ssh://[email protected]/egroupware'; |
| 1249 | 1249 | $config['modules'][$repo][$config['aliasdir'].'/'.$module] = $url; |
@@ -1257,11 +1257,11 @@ discard block |
||
| 1257 | 1257 | */ |
| 1258 | 1258 | function do_svntag() |
| 1259 | 1259 | { |
| 1260 | - global $config,$svn; |
|
| 1260 | + global $config, $svn; |
|
| 1261 | 1261 | |
| 1262 | - if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
| 1262 | + if (empty($config['svntag'])) return; // otherwise we copy everything in svn root! |
|
| 1263 | 1263 | |
| 1264 | - $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
| 1264 | + $config['svntag'] = config_translate('svntag'); // allow to use config vars like $version in tag |
|
| 1265 | 1265 | |
| 1266 | 1266 | echo "Creating SVN tag $config[svntag]\n"; |
| 1267 | 1267 | if (!isset($config['modules'])) |
@@ -1269,9 +1269,9 @@ discard block |
||
| 1269 | 1269 | get_modules_per_repo(); |
| 1270 | 1270 | } |
| 1271 | 1271 | // create tags (per repo) |
| 1272 | - foreach($config['modules'] as $repo => $modules) |
|
| 1272 | + foreach ($config['modules'] as $repo => $modules) |
|
| 1273 | 1273 | { |
| 1274 | - $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ',$modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
| 1274 | + $cmd = $svn.' cp --parents -m '.escapeshellarg('Creating '.$config['svntag']).' '.implode(' ', $modules).' '.$repo.'/'.$config['svntag'].'/'; |
|
| 1275 | 1275 | run_cmd($cmd); |
| 1276 | 1276 | } |
| 1277 | 1277 | } |
@@ -1284,7 +1284,7 @@ discard block |
||
| 1284 | 1284 | * @param int|array $no_bailout =null exit code(s) to NOT bail out |
| 1285 | 1285 | * @return int exit code of $cmd |
| 1286 | 1286 | */ |
| 1287 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
| 1287 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
| 1288 | 1288 | { |
| 1289 | 1289 | global $verbose; |
| 1290 | 1290 | |
@@ -1292,18 +1292,18 @@ discard block |
||
| 1292 | 1292 | { |
| 1293 | 1293 | echo $cmd."\n"; |
| 1294 | 1294 | $ret = null; |
| 1295 | - system($cmd,$ret); |
|
| 1295 | + system($cmd, $ret); |
|
| 1296 | 1296 | } |
| 1297 | 1297 | else |
| 1298 | 1298 | { |
| 1299 | 1299 | $output[] = $cmd; |
| 1300 | - exec($cmd,$output,$ret); |
|
| 1301 | - if ($verbose) echo implode("\n",$output)."\n"; |
|
| 1300 | + exec($cmd, $output, $ret); |
|
| 1301 | + if ($verbose) echo implode("\n", $output)."\n"; |
|
| 1302 | 1302 | } |
| 1303 | - if ($ret && !in_array($ret,(array)$no_bailout)) |
|
| 1303 | + if ($ret && !in_array($ret, (array)$no_bailout)) |
|
| 1304 | 1304 | { |
| 1305 | - if (!$verbose) echo implode("\n",$output)."\n"; |
|
| 1306 | - throw new Exception("Error during '$cmd' --> aborting",$ret); |
|
| 1305 | + if (!$verbose) echo implode("\n", $output)."\n"; |
|
| 1306 | + throw new Exception("Error during '$cmd' --> aborting", $ret); |
|
| 1307 | 1307 | } |
| 1308 | 1308 | return $ret; |
| 1309 | 1309 | } |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | return 'NULL'; |
| 1331 | 1331 | case 'object': |
| 1332 | 1332 | case 'array': |
| 1333 | - return str_replace(array("\n",' '/*,'Array'*/),'',print_r($var,true)); |
|
| 1333 | + return str_replace(array("\n", ' '/*,'Array'*/), '', print_r($var, true)); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | return 'UNKNOWN TYPE!'; |
| 1336 | 1336 | } |
@@ -1340,9 +1340,9 @@ discard block |
||
| 1340 | 1340 | * |
| 1341 | 1341 | * @param string $error =null optional error-message |
| 1342 | 1342 | */ |
| 1343 | -function usage($error=null) |
|
| 1343 | +function usage($error = null) |
|
| 1344 | 1344 | { |
| 1345 | - global $prog,$config,$verbose; |
|
| 1345 | + global $prog, $config, $verbose; |
|
| 1346 | 1346 | |
| 1347 | 1347 | echo "Usage: $prog [-h|--help] [-v|--verbose] [options, ...]\n\n"; |
| 1348 | 1348 | echo "options and their defaults:\n"; |
@@ -1352,12 +1352,12 @@ discard block |
||
| 1352 | 1352 | } |
| 1353 | 1353 | else |
| 1354 | 1354 | { |
| 1355 | - unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
| 1355 | + unset($config['modules']); // they give an error, because of nested array and are quite lengthy |
|
| 1356 | 1356 | } |
| 1357 | - foreach($config as $name => $default) |
|
| 1357 | + foreach ($config as $name => $default) |
|
| 1358 | 1358 | { |
| 1359 | - if (is_array($default)) $default = json_encode ($default, JSON_UNESCAPED_SLASHES); |
|
| 1360 | - echo '--'.str_pad($name,20).$default."\n"; |
|
| 1359 | + if (is_array($default)) $default = json_encode($default, JSON_UNESCAPED_SLASHES); |
|
| 1360 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
| 1361 | 1361 | } |
| 1362 | 1362 | if ($error) |
| 1363 | 1363 | { |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * |
| 486 | 486 | * @param string $cmd |
| 487 | 487 | * @param array &$output=null $output of command |
| 488 | - * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
|
| 488 | + * @param integer $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
|
| 489 | 489 | * @return int exit code of $cmd |
| 490 | 490 | */ |
| 491 | 491 | function run_cmd($cmd,array &$output=null,$no_bailout=null) |
@@ -712,7 +712,7 @@ discard block |
||
| 712 | 712 | * Read one Univention secret/password eg. _ucr_secret('mysql') |
| 713 | 713 | * |
| 714 | 714 | * @param string $name |
| 715 | - * @return string|boolean |
|
| 715 | + * @return false|string |
|
| 716 | 716 | */ |
| 717 | 717 | function _ucr_secret($name) |
| 718 | 718 | { |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | 'php' => PHP_BINARY, |
| 19 | 19 | 'source_dir' => realpath(__DIR__.'/../..'), |
| 20 | 20 | 'data_dir' => '/var/lib/egroupware', |
| 21 | - 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
| 21 | + 'header' => '$data_dir/header.inc.php', // symlinked to source_dir by rpm |
|
| 22 | 22 | 'setup-cli' => '$source_dir/setup/setup-cli.php', |
| 23 | 23 | 'domain' => 'default', |
| 24 | 24 | 'config_user' => 'admin', |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | 'db_user' => 'egroupware', |
| 31 | 31 | 'db_pass' => randomstring(), |
| 32 | 32 | 'db_grant_host' => 'localhost', |
| 33 | - 'db_root' => 'root', // mysql root user/pw to create database |
|
| 33 | + 'db_root' => 'root', // mysql root user/pw to create database |
|
| 34 | 34 | 'db_root_pw' => '', |
| 35 | 35 | 'backup' => '', |
| 36 | 36 | 'admin_user' => 'sysop', |
| 37 | 37 | 'admin_passwd'=> randomstring(), |
| 38 | 38 | 'admin_email' => '', |
| 39 | - 'lang' => 'en', // languages for admin user and extra lang to install |
|
| 39 | + 'lang' => 'en', // languages for admin user and extra lang to install |
|
| 40 | 40 | 'charset' => 'utf-8', |
| 41 | 41 | 'start_db' => '/sbin/service mysqld', |
| 42 | 42 | 'autostart_db' => '/sbin/chkconfig --level 345 mysqld on', |
@@ -56,23 +56,23 @@ discard block |
||
| 56 | 56 | 'ldap_search_filter' => '(uid=%user)', |
| 57 | 57 | 'ldap_group_context' => 'ou=groups,$base', |
| 58 | 58 | 'ldap_encryption_type' => '', |
| 59 | - 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
| 59 | + 'sambaadmin/sambasid'=> '', // SID for sambaadmin |
|
| 60 | 60 | 'mailserver' => '', |
| 61 | 61 | 'smtpserver' => 'localhost,25', |
| 62 | - 'smtp' => '', // see setup-cli.php --help config |
|
| 62 | + 'smtp' => '', // see setup-cli.php --help config |
|
| 63 | 63 | 'imap' => '', |
| 64 | 64 | 'sieve' => '', |
| 65 | 65 | 'folder' => '', |
| 66 | - 'install-update-app' => '', // install or update a single (non-default) app |
|
| 67 | - 'webserver_user'=> 'apache', // required to fix permissions |
|
| 66 | + 'install-update-app' => '', // install or update a single (non-default) app |
|
| 67 | + 'webserver_user'=> 'apache', // required to fix permissions |
|
| 68 | 68 | 'php5enmod' => '', |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | // read language from LANG enviroment variable |
| 72 | 72 | if (($lang = isset($_ENV['LANG']) ? $_ENV['LANG'] : (isset($_SERVER['LANG']) ? $_SERVER['LANG'] : null))) |
| 73 | 73 | { |
| 74 | - @list($lang,$nat) = preg_split('/[_.]/',$lang); |
|
| 75 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
| 74 | + @list($lang, $nat) = preg_split('/[_.]/', $lang); |
|
| 75 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
| 76 | 76 | { |
| 77 | 77 | $lang .= '-'.strtolower($nat); |
| 78 | 78 | } |
@@ -85,16 +85,13 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param string $distro =null default autodetect |
| 87 | 87 | */ |
| 88 | -function set_distro_defaults($distro=null) |
|
| 88 | +function set_distro_defaults($distro = null) |
|
| 89 | 89 | { |
| 90 | 90 | global $config; |
| 91 | 91 | if (is_null($distro)) |
| 92 | 92 | { |
| 93 | - $distro = file_exists('/etc/SuSE-release') ? 'suse' : |
|
| 94 | - (file_exists('/etc/mandriva-release') ? 'mandriva' : |
|
| 95 | - (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
| 96 | - file_get_contents('/etc/lsb-release')) ? 'univention' : |
|
| 97 | - (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
| 93 | + $distro = file_exists('/etc/SuSE-release') ? 'suse' : (file_exists('/etc/mandriva-release') ? 'mandriva' : (file_exists('/etc/lsb-release') && preg_match('/^DISTRIB_ID="?Univention"?$/mi', |
|
| 94 | + file_get_contents('/etc/lsb-release')) ? 'univention' : (file_exists('/etc/debian_version') ? 'debian' : 'rh'))); |
|
| 98 | 95 | } |
| 99 | 96 | switch (($config['distro'] = $distro)) |
| 100 | 97 | { |
@@ -154,9 +151,9 @@ discard block |
||
| 154 | 151 | } |
| 155 | 152 | elseif (!file_exists('/etc/init.d/mysqld') && file_exists('/etc/init.d/mysql')) |
| 156 | 153 | { |
| 157 | - foreach(array('start_db','autostart_db') as $name) |
|
| 154 | + foreach (array('start_db', 'autostart_db') as $name) |
|
| 158 | 155 | { |
| 159 | - $config[$name] = str_replace('mysqld','mysql',$config[$name]); |
|
| 156 | + $config[$name] = str_replace('mysqld', 'mysql', $config[$name]); |
|
| 160 | 157 | } |
| 161 | 158 | } |
| 162 | 159 | break; |
@@ -172,48 +169,48 @@ discard block |
||
| 172 | 169 | if (($config_set = isset($_ENV['EGW_POST_INSTALL']) ? $_ENV['EGW_POST_INSTALL'] : @$_SERVER['EGW_POST_INSTALL'])) |
| 173 | 170 | { |
| 174 | 171 | $conf = array(); |
| 175 | - $config_set = preg_split('/[ \t]+/',trim($config_set)); |
|
| 176 | - while($config_set) |
|
| 172 | + $config_set = preg_split('/[ \t]+/', trim($config_set)); |
|
| 173 | + while ($config_set) |
|
| 177 | 174 | { |
| 178 | 175 | $val = array_shift($config_set); |
| 179 | 176 | if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
| 180 | 177 | { |
| 181 | - while (substr($val,-1) != $quote) |
|
| 178 | + while (substr($val, -1) != $quote) |
|
| 182 | 179 | { |
| 183 | 180 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
| 184 | 181 | $val .= ' '.array_shift($config_set); |
| 185 | 182 | } |
| 186 | - $val = substr($val,1,-1); |
|
| 183 | + $val = substr($val, 1, -1); |
|
| 187 | 184 | } |
| 188 | 185 | $conf[] = $val; |
| 189 | 186 | } |
| 190 | - $argv = array_merge($conf,$argv); |
|
| 187 | + $argv = array_merge($conf, $argv); |
|
| 191 | 188 | } |
| 192 | 189 | |
| 193 | 190 | $auth_type_given = false; |
| 194 | -while(($arg = array_shift($argv))) |
|
| 191 | +while (($arg = array_shift($argv))) |
|
| 195 | 192 | { |
| 196 | 193 | if ($arg == '-v' || $arg == '--verbose') |
| 197 | 194 | { |
| 198 | 195 | $verbose = true; |
| 199 | 196 | } |
| 200 | - elseif($arg == '-h' || $arg == '--help') |
|
| 197 | + elseif ($arg == '-h' || $arg == '--help') |
|
| 201 | 198 | { |
| 202 | 199 | usage(); |
| 203 | 200 | } |
| 204 | - elseif($arg == '--suse') |
|
| 201 | + elseif ($arg == '--suse') |
|
| 205 | 202 | { |
| 206 | 203 | set_distro_defaults('suse'); |
| 207 | 204 | } |
| 208 | - elseif($arg == '--distro') |
|
| 205 | + elseif ($arg == '--distro') |
|
| 209 | 206 | { |
| 210 | 207 | set_distro_defaults(array_shift($argv)); |
| 211 | 208 | } |
| 212 | - elseif(substr($arg,0,2) == '--' && isset($config[$name=substr($arg,2)])) |
|
| 209 | + elseif (substr($arg, 0, 2) == '--' && isset($config[$name = substr($arg, 2)])) |
|
| 213 | 210 | { |
| 214 | 211 | $config[$name] = array_shift($argv); |
| 215 | 212 | |
| 216 | - switch($name) |
|
| 213 | + switch ($name) |
|
| 217 | 214 | { |
| 218 | 215 | case 'auth_type': |
| 219 | 216 | $auth_type_given = true; |
@@ -234,18 +231,18 @@ discard block |
||
| 234 | 231 | } |
| 235 | 232 | |
| 236 | 233 | $replace = array(); |
| 237 | -foreach($config as $name => $value) |
|
| 234 | +foreach ($config as $name => $value) |
|
| 238 | 235 | { |
| 239 | 236 | $replace['$'.$name] = $value; |
| 240 | - if (strpos($value,'$') !== false) |
|
| 237 | + if (strpos($value, '$') !== false) |
|
| 241 | 238 | { |
| 242 | - $config[$name] = strtr($value,$replace); |
|
| 239 | + $config[$name] = strtr($value, $replace); |
|
| 243 | 240 | } |
| 244 | 241 | } |
| 245 | 242 | // basic config checks |
| 246 | -foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
|
| 243 | +foreach (array('php', 'source_dir', 'data_dir', 'setup-cli') as $name) |
|
| 247 | 244 | { |
| 248 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
| 245 | + if (!file_exists($config[$name])) bail_out(1, $config[$name].' not found!'); |
|
| 249 | 246 | } |
| 250 | 247 | |
| 251 | 248 | // fix important php.ini and conf.d/*.ini settings |
@@ -260,13 +257,13 @@ discard block |
||
| 260 | 257 | $GLOBALS['egw_info'] = array( |
| 261 | 258 | 'flags' => array( |
| 262 | 259 | 'noapi' => true, |
| 263 | - 'currentapp' => 'login', // stop PHP Notice: Undefined index "currentapp" in pre 16.1 header |
|
| 260 | + 'currentapp' => 'login', // stop PHP Notice: Undefined index "currentapp" in pre 16.1 header |
|
| 264 | 261 | ) |
| 265 | 262 | ); |
| 266 | 263 | include $config['header']; |
| 267 | 264 | |
| 268 | 265 | // get user from header and replace password, as we dont know it |
| 269 | - $old_password = patch_header($config['header'],$config['config_user'],$config['config_passwd']); |
|
| 266 | + $old_password = patch_header($config['header'], $config['config_user'], $config['config_passwd']); |
|
| 270 | 267 | // register a shutdown function to put old password back in any case |
| 271 | 268 | register_shutdown_function(function() use (&$config, $old_password) |
| 272 | 269 | { |
@@ -274,7 +271,7 @@ discard block |
||
| 274 | 271 | }); |
| 275 | 272 | } |
| 276 | 273 | // new header or does not include requested domain (!= "default") --> new install |
| 277 | -if (!isset($GLOBALS['egw_domain']) || $config['domain'] !== 'default' && !isset($GLOBALS['egw_domain'][$config['domain']])) |
|
| 274 | +if (!isset($GLOBALS['egw_domain']) || $config['domain'] !== 'default' && !isset($GLOBALS['egw_domain'][$config['domain']])) |
|
| 278 | 275 | { |
| 279 | 276 | // --> new install |
| 280 | 277 | $extra_config = ''; |
@@ -291,7 +288,7 @@ discard block |
||
| 291 | 288 | } |
| 292 | 289 | // create database |
| 293 | 290 | $setup_db = $setup_cli.' --setup-cmd-database sub_command=create_db'; |
| 294 | - foreach(array('domain','db_type','db_host','db_port','db_name','db_user','db_pass','db_root','db_root_pw','db_grant_host') as $name) |
|
| 291 | + foreach (array('domain', 'db_type', 'db_host', 'db_port', 'db_name', 'db_user', 'db_pass', 'db_root', 'db_root_pw', 'db_grant_host') as $name) |
|
| 295 | 292 | { |
| 296 | 293 | $setup_db .= ' '.escapeshellarg($name.'='.$config[$name]); |
| 297 | 294 | } |
@@ -299,7 +296,7 @@ discard block |
||
| 299 | 296 | |
| 300 | 297 | // check if ldap is required and initialise it |
| 301 | 298 | // we need to specify account_repository and auth_type to --install as extra config, otherwise install happens for sql! |
| 302 | - @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
|
| 299 | + @list($config['account_repository'], $config['auth_type'], $rest) = explode(',', $config['account-auth'], 3); |
|
| 303 | 300 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
| 304 | 301 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
| 305 | 302 | if (empty($rest)) unset($config['account-auth']); |
@@ -310,15 +307,15 @@ discard block |
||
| 310 | 307 | |
| 311 | 308 | $setup_ldap = $setup_cli.' --setup-cmd-ldap sub_command='. |
| 312 | 309 | ($config['account_repository'] == 'ldap' ? 'create_ldap' : 'test_ldap'); |
| 313 | - foreach(array( |
|
| 314 | - 'domain','ldap_suffix','ldap_host','ldap_admin','ldap_admin_pw', // non-egw params: only used for create |
|
| 315 | - 'ldap_base','ldap_root_dn','ldap_root_pw','ldap_context','ldap_search_filter','ldap_group_context', // egw params |
|
| 310 | + foreach (array( |
|
| 311 | + 'domain', 'ldap_suffix', 'ldap_host', 'ldap_admin', 'ldap_admin_pw', // non-egw params: only used for create |
|
| 312 | + 'ldap_base', 'ldap_root_dn', 'ldap_root_pw', 'ldap_context', 'ldap_search_filter', 'ldap_group_context', // egw params |
|
| 316 | 313 | 'ldap_encryption_type', 'sambaadmin/sambasid', |
| 317 | 314 | ) as $name) |
| 318 | 315 | { |
| 319 | - if (strpos($value=$config[$name],'$') !== false) |
|
| 316 | + if (strpos($value = $config[$name], '$') !== false) |
|
| 320 | 317 | { |
| 321 | - $config[$name] = $value = strtr($value,array( |
|
| 318 | + $config[$name] = $value = strtr($value, array( |
|
| 322 | 319 | '$suffix' => $config['ldap_suffix'], |
| 323 | 320 | '$base' => $config['ldap_base'], |
| 324 | 321 | '$admin_pw' => $config['ldap_admin_pw'], |
@@ -326,7 +323,7 @@ discard block |
||
| 326 | 323 | } |
| 327 | 324 | $setup_ldap .= ' '.escapeshellarg($name.'='.$value); |
| 328 | 325 | |
| 329 | - if (!in_array($name,array('domain','ldap_suffix','ldap_admin','ldap_admin_pw'))) |
|
| 326 | + if (!in_array($name, array('domain', 'ldap_suffix', 'ldap_admin', 'ldap_admin_pw'))) |
|
| 330 | 327 | { |
| 331 | 328 | $extra_config .= ' '.escapeshellarg($name.'='.$value); |
| 332 | 329 | } |
@@ -360,7 +357,7 @@ discard block |
||
| 360 | 357 | } |
| 361 | 358 | // create mailserver config (fmail requires at least minimal config given as default, otherwise fatal error) |
| 362 | 359 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
| 363 | - foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
|
| 360 | + foreach (array('account-auth', 'smtpserver', 'smtp', 'postfix', 'mailserver', 'imap', 'cyrus', 'sieve', 'folder') as $name) |
|
| 364 | 361 | { |
| 365 | 362 | if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
| 366 | 363 | } |
@@ -374,7 +371,7 @@ discard block |
||
| 374 | 371 | // check if webserver is started and start it (permanent) if not |
| 375 | 372 | if ($config['start_webserver']) |
| 376 | 373 | { |
| 377 | - exec(build_cmd('start_webserver', 'status'),$dummy,$ret); |
|
| 374 | + exec(build_cmd('start_webserver', 'status'), $dummy, $ret); |
|
| 378 | 375 | if ($ret) |
| 379 | 376 | { |
| 380 | 377 | system(build_cmd('start_webserver', 'start')); |
@@ -416,18 +413,18 @@ discard block |
||
| 416 | 413 | // update egroupware, or single app(s), in later case skip backup |
| 417 | 414 | $setup_update = $setup_cli.' --update '.escapeshellarg('all,'.$config['config_user'].','.$config['config_passwd']. |
| 418 | 415 | (empty($config['install-update-app']) ? '' : ',no,'.$config['install-update-app'])); |
| 419 | - $ret = run_cmd($setup_update,$output,array(4,15)); |
|
| 416 | + $ret = run_cmd($setup_update, $output, array(4, 15)); |
|
| 420 | 417 | |
| 421 | - switch($ret) |
|
| 418 | + switch ($ret) |
|
| 422 | 419 | { |
| 423 | 420 | case 4: // header needs an update |
| 424 | 421 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
| 425 | 422 | run_cmd($header_update); |
| 426 | - $ret = run_cmd($setup_update,$output,15); |
|
| 423 | + $ret = run_cmd($setup_update, $output, 15); |
|
| 427 | 424 | if ($ret != 15) break; |
| 428 | 425 | // fall through |
| 429 | 426 | case 15: // missing configuration (eg. mailserver) |
| 430 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
| 427 | + if (!$verbose) echo implode("\n", (array)$output)."\n"; |
|
| 431 | 428 | break; |
| 432 | 429 | |
| 433 | 430 | case 0: |
@@ -472,18 +469,18 @@ discard block |
||
| 472 | 469 | * @param string $password new password |
| 473 | 470 | * @return string old password |
| 474 | 471 | */ |
| 475 | -function patch_header($filename,&$user,$password) |
|
| 472 | +function patch_header($filename, &$user, $password) |
|
| 476 | 473 | { |
| 477 | 474 | $header = file_get_contents($filename); |
| 478 | 475 | |
| 479 | 476 | $umatches = $pmatches = null; |
| 480 | - if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m",$header,$umatches) || |
|
| 481 | - !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m",$header,$pmatches)) |
|
| 477 | + if (!preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_user'] = '", '/')."([^']+)';/m", $header, $umatches) || |
|
| 478 | + !preg_match('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", $header, $pmatches)) |
|
| 482 | 479 | { |
| 483 | - bail_out(99,"$filename is no regular EGroupware header.inc.php!"); |
|
| 480 | + bail_out(99, "$filename is no regular EGroupware header.inc.php!"); |
|
| 484 | 481 | } |
| 485 | - file_put_contents($filename,preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
| 486 | - "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';",$header)); |
|
| 482 | + file_put_contents($filename, preg_replace('/'.preg_quote("\$GLOBALS['egw_info']['server']['header_admin_password'] = '", '/')."([^']*)';/m", |
|
| 483 | + "\$GLOBALS['egw_info']['server']['header_admin_password'] = '".$password."';", $header)); |
|
| 487 | 484 | |
| 488 | 485 | $user = $umatches[1]; |
| 489 | 486 | |
@@ -498,7 +495,7 @@ discard block |
||
| 498 | 495 | * @param int|array|true $no_bailout =null exit code(s) to NOT bail out, or true to never bail out |
| 499 | 496 | * @return int exit code of $cmd |
| 500 | 497 | */ |
| 501 | -function run_cmd($cmd,array &$output=null,$no_bailout=null) |
|
| 498 | +function run_cmd($cmd, array &$output = null, $no_bailout = null) |
|
| 502 | 499 | { |
| 503 | 500 | global $verbose; |
| 504 | 501 | |
@@ -506,16 +503,16 @@ discard block |
||
| 506 | 503 | { |
| 507 | 504 | echo $cmd."\n"; |
| 508 | 505 | $ret = null; |
| 509 | - system($cmd,$ret); |
|
| 506 | + system($cmd, $ret); |
|
| 510 | 507 | } |
| 511 | 508 | else |
| 512 | 509 | { |
| 513 | 510 | $output[] = $cmd; |
| 514 | - exec($cmd,$output,$ret); |
|
| 511 | + exec($cmd, $output, $ret); |
|
| 515 | 512 | } |
| 516 | - if ($ret && $no_bailout !== true && !in_array($ret,(array)$no_bailout)) |
|
| 513 | + if ($ret && $no_bailout !== true && !in_array($ret, (array)$no_bailout)) |
|
| 517 | 514 | { |
| 518 | - bail_out($ret,$verbose?null:$output); |
|
| 515 | + bail_out($ret, $verbose ? null : $output); |
|
| 519 | 516 | } |
| 520 | 517 | return $ret; |
| 521 | 518 | } |
@@ -526,9 +523,9 @@ discard block |
||
| 526 | 523 | * @param int $ret =1 |
| 527 | 524 | * @param array|string $output line(s) to output before temination notice |
| 528 | 525 | */ |
| 529 | -function bail_out($ret=1,$output=null) |
|
| 526 | +function bail_out($ret = 1, $output = null) |
|
| 530 | 527 | { |
| 531 | - if ($output) echo implode("\n",(array)$output); |
|
| 528 | + if ($output) echo implode("\n", (array)$output); |
|
| 532 | 529 | echo "\n\nInstallation failed --> exiting!\n\n"; |
| 533 | 530 | exit($ret); |
| 534 | 531 | } |
@@ -539,24 +536,24 @@ discard block |
||
| 539 | 536 | * @param int $len =16 |
| 540 | 537 | * @return string |
| 541 | 538 | */ |
| 542 | -function randomstring($len=16) |
|
| 539 | +function randomstring($len = 16) |
|
| 543 | 540 | { |
| 544 | 541 | static $usedchars = array( |
| 545 | - '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f', |
|
| 546 | - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', |
|
| 547 | - 'w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L', |
|
| 548 | - 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', |
|
| 549 | - '@','!','%','&','(',')','=','?',';',':','#','_','-','<', |
|
| 550 | - '>','|','[',']','}', // dont add /\,'"{ as we have problems dealing with them |
|
| 542 | + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', |
|
| 543 | + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', |
|
| 544 | + 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', |
|
| 545 | + 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', |
|
| 546 | + '@', '!', '%', '&', '(', ')', '=', '?', ';', ':', '#', '_', '-', '<', |
|
| 547 | + '>', '|', '[', ']', '}', // dont add /\,'"{ as we have problems dealing with them |
|
| 551 | 548 | ); |
| 552 | 549 | |
| 553 | 550 | // use cryptographically secure random_int available in PHP 7+ |
| 554 | 551 | $func = function_exists('random_int') ? 'random_int' : 'mt_rand'; |
| 555 | 552 | |
| 556 | 553 | $str = ''; |
| 557 | - for($i=0; $i < $len; $i++) |
|
| 554 | + for ($i = 0; $i < $len; $i++) |
|
| 558 | 555 | { |
| 559 | - $str .= $usedchars[$func(0,count($usedchars)-1)]; |
|
| 556 | + $str .= $usedchars[$func(0, count($usedchars) - 1)]; |
|
| 560 | 557 | } |
| 561 | 558 | return $str; |
| 562 | 559 | } |
@@ -566,20 +563,20 @@ discard block |
||
| 566 | 563 | * |
| 567 | 564 | * @param string $error =null optional error-message |
| 568 | 565 | */ |
| 569 | -function usage($error=null) |
|
| 566 | +function usage($error = null) |
|
| 570 | 567 | { |
| 571 | - global $prog,$config; |
|
| 568 | + global $prog, $config; |
|
| 572 | 569 | |
| 573 | 570 | echo "Usage: $prog [-h|--help] [-v|--verbose] [--distro=(suse|rh|debian)] [options, ...]\n\n"; |
| 574 | 571 | echo "options and their defaults:\n"; |
| 575 | - foreach($config as $name => $default) |
|
| 572 | + foreach ($config as $name => $default) |
|
| 576 | 573 | { |
| 577 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
| 578 | - if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
|
| 574 | + if (in_array($name, array('postfix', 'cyrus'))) continue; // do NOT report deprecated options |
|
| 575 | + if (in_array($name, array('config_passwd', 'db_pass', 'admin_passwd', 'ldap_root_pw')) && strlen($config[$name]) == 16) |
|
| 579 | 576 | { |
| 580 | 577 | $default = '<16 char random string>'; |
| 581 | 578 | } |
| 582 | - echo '--'.str_pad($name,20).$default."\n"; |
|
| 579 | + echo '--'.str_pad($name, 20).$default."\n"; |
|
| 583 | 580 | } |
| 584 | 581 | if ($error) |
| 585 | 582 | { |
@@ -629,8 +626,8 @@ discard block |
||
| 629 | 626 | $config['distro'] = 'univention'; |
| 630 | 627 | |
| 631 | 628 | // set lang from ucr locale, as cloud-config at least never has anything but EN set in enviroment |
| 632 | - @list($lang,$nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
| 633 | - if (in_array($lang.'-'.strtolower($nat),array('es-es','pt-br','zh-tw'))) |
|
| 629 | + @list($lang, $nat) = preg_split('/[_.]/', _ucr_get('locale/default')); |
|
| 630 | + if (in_array($lang.'-'.strtolower($nat), array('es-es', 'pt-br', 'zh-tw'))) |
|
| 634 | 631 | { |
| 635 | 632 | $lang .= '-'.strtolower($nat); |
| 636 | 633 | } |
@@ -655,7 +652,7 @@ discard block |
||
| 655 | 652 | // ldap password hash (our default blowfish_crypt seems not to work) |
| 656 | 653 | $config['ldap_encryption_type'] = 'sha512_crypt'; |
| 657 | 654 | |
| 658 | - $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
| 655 | + $config['account_min_id'] = 1200; // UCS use 11xx for internal users/groups |
|
| 659 | 656 | |
| 660 | 657 | $config['account-auth'] = 'univention,ldap'; |
| 661 | 658 | |
@@ -665,7 +662,7 @@ discard block |
||
| 665 | 662 | // mailserver, see setup-cli.php --help config |
| 666 | 663 | if (($mailserver = exec('/usr/bin/univention-ldapsearch -x "(univentionAppID=mailserver_*)" univentionAppInstalledOnServer|sed -n "s/univentionAppInstalledOnServer: \(.*\)/\1/p"')) && |
| 667 | 664 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
| 668 | - ($domains=_ucr_get('mail/hosteddomains'))) |
|
| 665 | + ($domains = _ucr_get('mail/hosteddomains'))) |
|
| 669 | 666 | { |
| 670 | 667 | if (!is_array($domains)) $domains = explode("\n", $domains); |
| 671 | 668 | $domain = array_shift($domains); |
@@ -714,12 +711,12 @@ discard block |
||
| 714 | 711 | */ |
| 715 | 712 | function _ucr_get($name) |
| 716 | 713 | { |
| 717 | - static $values=null; |
|
| 714 | + static $values = null; |
|
| 718 | 715 | if (!isset($values)) |
| 719 | 716 | { |
| 720 | 717 | $output = $matches = null; |
| 721 | 718 | exec('/usr/sbin/ucr dump', $output); |
| 722 | - foreach($output as $line) |
|
| 719 | + foreach ($output as $line) |
|
| 723 | 720 | { |
| 724 | 721 | if (preg_match("/^([^:]+): (.*)\n?$/", $line, $matches)) |
| 725 | 722 | { |
@@ -795,7 +792,7 @@ discard block |
||
| 795 | 792 | */ |
| 796 | 793 | function _size_with_unit($size) |
| 797 | 794 | { |
| 798 | - switch(strtoupper(substr($size, -1))) |
|
| 795 | + switch (strtoupper(substr($size, -1))) |
|
| 799 | 796 | { |
| 800 | 797 | case 'G': |
| 801 | 798 | $size *= 1024; |
@@ -9,10 +9,13 @@ discard block |
||
| 9 | 9 | * @version $Id$ |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -if (php_sapi_name() !== 'cli') // security precaution: forbit calling post_install as web-page |
|
| 12 | +if (php_sapi_name() !== 'cli') |
|
| 13 | +{ |
|
| 14 | + // security precaution: forbit calling post_install as web-page |
|
| 13 | 15 | { |
| 14 | 16 | die('<h1>post_install.php must NOT be called as web-page --> exiting !!!</h1>'); |
| 15 | 17 | } |
| 18 | +} |
|
| 16 | 19 | $verbose = false; |
| 17 | 20 | $config = array( |
| 18 | 21 | 'php' => PHP_BINARY, |
@@ -100,7 +103,10 @@ discard block |
||
| 100 | 103 | { |
| 101 | 104 | case 'suse': |
| 102 | 105 | // openSUSE 12.1+ no longer uses php5 |
| 103 | - if (file_exists('/usr/bin/php5')) $config['php'] = '/usr/bin/php5'; |
|
| 106 | + if (file_exists('/usr/bin/php5')) |
|
| 107 | + { |
|
| 108 | + $config['php'] = '/usr/bin/php5'; |
|
| 109 | + } |
|
| 104 | 110 | $config['start_db'] = '/sbin/service mysql'; |
| 105 | 111 | $config['autostart_db'] = '/sbin/chkconfig --level 345 mysql on'; |
| 106 | 112 | $config['start_webserver'] = '/sbin/service apache2'; |
@@ -145,9 +151,12 @@ discard block |
||
| 145 | 151 | // fall through |
| 146 | 152 | case 'rh': |
| 147 | 153 | // some MySQL packages (mysql.com, MariaDB, ...) use "mysql" as service name instead of RH default "mysqld" |
| 148 | - if (file_exists('/usr/bin/systemctl')) // RHEL 7 |
|
| 154 | + if (file_exists('/usr/bin/systemctl')) |
|
| 155 | + { |
|
| 156 | + // RHEL 7 |
|
| 149 | 157 | { |
| 150 | 158 | $config['start_db'] = '/usr/bin/systemctl %s mariadb'; |
| 159 | + } |
|
| 151 | 160 | $config['autostart_db'] = build_cmd('start_db', 'enable'); |
| 152 | 161 | $config['start_webserver'] = '/usr/bin/systemctl %s httpd'; |
| 153 | 162 | $config['autostart_webserver'] = build_cmd('start_webserver', 'enable'); |
@@ -176,11 +185,14 @@ discard block |
||
| 176 | 185 | while($config_set) |
| 177 | 186 | { |
| 178 | 187 | $val = array_shift($config_set); |
| 179 | - if (($quote = $val[0]) == "'" || $quote == '"') // arguments might be quoted with ' or " |
|
| 188 | + if (($quote = $val[0]) == "'" || $quote == '"') |
|
| 189 | + { |
|
| 190 | + // arguments might be quoted with ' or " |
|
| 180 | 191 | { |
| 181 | 192 | while (substr($val,-1) != $quote) |
| 182 | 193 | { |
| 183 | 194 | if (!$config_set) throw new Exception('Invalid EGW_POST_INSTALL enviroment variable!'); |
| 195 | + } |
|
| 184 | 196 | $val .= ' '.array_shift($config_set); |
| 185 | 197 | } |
| 186 | 198 | $val = substr($val,1,-1); |
@@ -245,8 +257,11 @@ discard block |
||
| 245 | 257 | // basic config checks |
| 246 | 258 | foreach(array('php','source_dir','data_dir','setup-cli') as $name) |
| 247 | 259 | { |
| 248 | - if (!file_exists($config[$name])) bail_out(1,$config[$name].' not found!'); |
|
| 249 | -} |
|
| 260 | + if (!file_exists($config[$name])) |
|
| 261 | + { |
|
| 262 | + bail_out(1,$config[$name].' not found!'); |
|
| 263 | + } |
|
| 264 | + } |
|
| 250 | 265 | |
| 251 | 266 | // fix important php.ini and conf.d/*.ini settings |
| 252 | 267 | check_fix_php_apc_ini(); |
@@ -255,7 +270,9 @@ discard block |
||
| 255 | 270 | $setup_cli = $config['php'].' -d memory_limit=-1 '.$config['setup-cli']; |
| 256 | 271 | |
| 257 | 272 | // if we have a header, include it |
| 258 | -if (file_exists($config['header']) && filesize($config['header']) >= 200) // default header redirecting to setup is 147 bytes |
|
| 273 | +if (file_exists($config['header']) && filesize($config['header']) >= 200) |
|
| 274 | +{ |
|
| 275 | + // default header redirecting to setup is 147 bytes |
|
| 259 | 276 | { |
| 260 | 277 | $GLOBALS['egw_info'] = array( |
| 261 | 278 | 'flags' => array( |
@@ -263,6 +280,7 @@ discard block |
||
| 263 | 280 | 'currentapp' => 'login', // stop PHP Notice: Undefined index "currentapp" in pre 16.1 header |
| 264 | 281 | ) |
| 265 | 282 | ); |
| 283 | +} |
|
| 266 | 284 | include $config['header']; |
| 267 | 285 | |
| 268 | 286 | // get user from header and replace password, as we dont know it |
@@ -286,7 +304,10 @@ discard block |
||
| 286 | 304 | if ($ret) |
| 287 | 305 | { |
| 288 | 306 | system(build_cmd('start_db', 'start')); |
| 289 | - if (!empty($config['autostart_db'])) system($config['autostart_db']); |
|
| 307 | + if (!empty($config['autostart_db'])) |
|
| 308 | + { |
|
| 309 | + system($config['autostart_db']); |
|
| 310 | + } |
|
| 290 | 311 | } |
| 291 | 312 | } |
| 292 | 313 | // create database |
@@ -302,7 +323,10 @@ discard block |
||
| 302 | 323 | @list($config['account_repository'],$config['auth_type'],$rest) = explode(',',$config['account-auth'],3); |
| 303 | 324 | $extra_config .= ' '.escapeshellarg('account_repository='.$config['account_repository']); |
| 304 | 325 | $extra_config .= ' '.escapeshellarg('auth_type='.(empty($config['auth_type']) ? $config['account_repository'] : $config['auth_type'])); |
| 305 | - if (empty($rest)) unset($config['account-auth']); |
|
| 326 | + if (empty($rest)) |
|
| 327 | + { |
|
| 328 | + unset($config['account-auth']); |
|
| 329 | + } |
|
| 306 | 330 | if ($config['account_repository'] == 'ldap' || $config['auth_type'] == 'ldap') |
| 307 | 331 | { |
| 308 | 332 | // set account_min_id to 1100 if not specified to NOT clash with system accounts |
@@ -362,7 +386,10 @@ discard block |
||
| 362 | 386 | $setup_mailserver = $setup_cli.' --config '.escapeshellarg($config['domain'].','.$config['config_user'].','.$config['config_passwd']); |
| 363 | 387 | foreach(array('account-auth','smtpserver','smtp','postfix','mailserver','imap','cyrus','sieve','folder') as $name) |
| 364 | 388 | { |
| 365 | - if (!empty($config[$name])) $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
| 389 | + if (!empty($config[$name])) |
|
| 390 | + { |
|
| 391 | + $setup_mailserver .= ' --'.$name.' '.escapeshellarg($config[$name]); |
|
| 392 | + } |
|
| 366 | 393 | } |
| 367 | 394 | run_cmd($setup_mailserver); |
| 368 | 395 | |
@@ -378,7 +405,10 @@ discard block |
||
| 378 | 405 | if ($ret) |
| 379 | 406 | { |
| 380 | 407 | system(build_cmd('start_webserver', 'start')); |
| 381 | - if (!empty($config['autostart_webserver'])) system($config['autostart_webserver']); |
|
| 408 | + if (!empty($config['autostart_webserver'])) |
|
| 409 | + { |
|
| 410 | + system($config['autostart_webserver']); |
|
| 411 | + } |
|
| 382 | 412 | } |
| 383 | 413 | else |
| 384 | 414 | { |
@@ -424,10 +454,16 @@ discard block |
||
| 424 | 454 | $header_update = $setup_cli.' --update-header '.escapeshellarg($config['config_passwd'].','.$config['config_user']); |
| 425 | 455 | run_cmd($header_update); |
| 426 | 456 | $ret = run_cmd($setup_update,$output,15); |
| 427 | - if ($ret != 15) break; |
|
| 457 | + if ($ret != 15) |
|
| 458 | + { |
|
| 459 | + break; |
|
| 460 | + } |
|
| 428 | 461 | // fall through |
| 429 | 462 | case 15: // missing configuration (eg. mailserver) |
| 430 | - if (!$verbose) echo implode("\n",(array)$output)."\n"; |
|
| 463 | + if (!$verbose) |
|
| 464 | + { |
|
| 465 | + echo implode("\n",(array)$output)."\n"; |
|
| 466 | + } |
|
| 431 | 467 | break; |
| 432 | 468 | |
| 433 | 469 | case 0: |
@@ -457,9 +493,15 @@ discard block |
||
| 457 | 493 | { |
| 458 | 494 | global $config; |
| 459 | 495 | |
| 460 | - if (isset($config[$cmd])) $cmd = $config[$cmd]; |
|
| 496 | + if (isset($config[$cmd])) |
|
| 497 | + { |
|
| 498 | + $cmd = $config[$cmd]; |
|
| 499 | + } |
|
| 461 | 500 | |
| 462 | - if (strpos($cmd, '%s')) return str_replace('%s', $arg, $cmd); |
|
| 501 | + if (strpos($cmd, '%s')) |
|
| 502 | + { |
|
| 503 | + return str_replace('%s', $arg, $cmd); |
|
| 504 | + } |
|
| 463 | 505 | |
| 464 | 506 | return $cmd.' '.$arg; |
| 465 | 507 | } |
@@ -528,7 +570,10 @@ discard block |
||
| 528 | 570 | */ |
| 529 | 571 | function bail_out($ret=1,$output=null) |
| 530 | 572 | { |
| 531 | - if ($output) echo implode("\n",(array)$output); |
|
| 573 | + if ($output) |
|
| 574 | + { |
|
| 575 | + echo implode("\n",(array)$output); |
|
| 576 | + } |
|
| 532 | 577 | echo "\n\nInstallation failed --> exiting!\n\n"; |
| 533 | 578 | exit($ret); |
| 534 | 579 | } |
@@ -574,7 +619,11 @@ discard block |
||
| 574 | 619 | echo "options and their defaults:\n"; |
| 575 | 620 | foreach($config as $name => $default) |
| 576 | 621 | { |
| 577 | - if (in_array($name, array('postfix','cyrus'))) continue; // do NOT report deprecated options |
|
| 622 | + if (in_array($name, array('postfix','cyrus'))) |
|
| 623 | + { |
|
| 624 | + continue; |
|
| 625 | + } |
|
| 626 | + // do NOT report deprecated options |
|
| 578 | 627 | if (in_array($name,array('config_passwd','db_pass','admin_passwd','ldap_root_pw')) && strlen($config[$name]) == 16) |
| 579 | 628 | { |
| 580 | 629 | $default = '<16 char random string>'; |
@@ -667,7 +716,10 @@ discard block |
||
| 667 | 716 | // only set on host mailserver app is installed: _ucr_get('mail/cyrus/imap') == 'yes' && |
| 668 | 717 | ($domains=_ucr_get('mail/hosteddomains'))) |
| 669 | 718 | { |
| 670 | - if (!is_array($domains)) $domains = explode("\n", $domains); |
|
| 719 | + if (!is_array($domains)) |
|
| 720 | + { |
|
| 721 | + $domains = explode("\n", $domains); |
|
| 722 | + } |
|
| 671 | 723 | $domain = array_shift($domains); |
| 672 | 724 | // set "use auth with session credentials",tls,"not user editable","further identities" |
| 673 | 725 | $config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes"; |
@@ -686,13 +738,19 @@ discard block |
||
| 686 | 738 | $config['imap'] = ',,Imap\\Dovecot'; |
| 687 | 739 | } |
| 688 | 740 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
| 689 | - if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190; |
|
| 741 | + if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) |
|
| 742 | + { |
|
| 743 | + $sieve_port = 4190; |
|
| 744 | + } |
|
| 690 | 745 | } |
| 691 | 746 | else |
| 692 | 747 | { |
| 693 | 748 | $config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',Imap\\Cyrus'; |
| 694 | 749 | // default with sieve port to 4190, as config is only available on host mailserver app is installed |
| 695 | - if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190; |
|
| 750 | + if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) |
|
| 751 | + { |
|
| 752 | + $sieve_port = 4190; |
|
| 753 | + } |
|
| 696 | 754 | } |
| 697 | 755 | // set folders so mail creates them on first login, UCS does not automatic |
| 698 | 756 | $config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,Spam,,Ham'; |
@@ -757,7 +815,10 @@ discard block |
||
| 757 | 815 | $shm_size = ini_get('apc.shm_size'); |
| 758 | 816 | $shm_segments = ini_get('apc.shm_segments'); |
| 759 | 817 | // ancent APC (3.1.3) in Debian 6/Squezze has size in MB without a unit |
| 760 | - if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) $shm_size .= 'M'; |
|
| 818 | + if (($numeric_size = is_numeric($shm_size) && $shm_size <= 1048576)) |
|
| 819 | + { |
|
| 820 | + $shm_size .= 'M'; |
|
| 821 | + } |
|
| 761 | 822 | |
| 762 | 823 | $size = _size_with_unit($shm_size) * $shm_segments; |
| 763 | 824 | //echo "shm_size=$shm_size, shm_segments=$shm_segments --> $size, numeric_size=$numeric_size\n"; |
@@ -773,7 +834,10 @@ discard block |
||
| 773 | 834 | file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path))) |
| 774 | 835 | { |
| 775 | 836 | $new_shm_size = 128 / $shm_segments; |
| 776 | - if (!$numeric_size) $new_shm_size .= 'M'; |
|
| 837 | + if (!$numeric_size) |
|
| 838 | + { |
|
| 839 | + $new_shm_size .= 'M'; |
|
| 840 | + } |
|
| 777 | 841 | if (preg_match('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', $apc_ini)) |
| 778 | 842 | { |
| 779 | 843 | file_put_contents($path, preg_replace('|^apc.shm_size\s*=\s*(\d+[KMG]?)$|m', 'apc.shm_size='.$new_shm_size, $apc_ini)); |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | /** |
| 76 | 76 | * Mount GUI |
| 77 | 77 | * |
| 78 | - * @param array $content=null |
|
| 79 | - * @param string $msg='' |
|
| 78 | + * @param array $content |
|
| 80 | 79 | */ |
| 81 | 80 | public function index(array $content=null, $msg='', $msg_type=null) |
| 82 | 81 | { |
@@ -131,7 +131,10 @@ discard block |
||
| 131 | 131 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
| 132 | 132 | { |
| 133 | 133 | $url = str_replace('$path',$path,$content['mounts']['url']); |
| 134 | - if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
|
| 134 | + if (empty($url) && $this->versioning) |
|
| 135 | + { |
|
| 136 | + $url = Versioning\StreamWrapper::PREFIX.$path; |
|
| 137 | + } |
|
| 135 | 138 | |
| 136 | 139 | if ($content['mounts']['enable'] && !$this->versioning) |
| 137 | 140 | { |
@@ -227,16 +230,25 @@ discard block |
||
| 227 | 230 | $content['versionedpath'] = '/'; |
| 228 | 231 | $content['mtime'] = 100; |
| 229 | 232 | } |
| 230 | - if (true) $content = array( |
|
| 233 | + if (true) |
|
| 234 | + { |
|
| 235 | + $content = array( |
|
| 231 | 236 | 'versionedpath' => $content['versionedpath'], |
| 232 | 237 | 'mtime' => $content['mtime'], |
| 233 | 238 | ); |
| 239 | + } |
|
| 234 | 240 | if ($this->versioning) |
| 235 | 241 | { |
| 236 | 242 | // statistical information |
| 237 | 243 | $content += Versioning\StreamWrapper::summary(); |
| 238 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
| 239 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
| 244 | + if ($content['total_files']) |
|
| 245 | + { |
|
| 246 | + $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
| 247 | + } |
|
| 248 | + if ($content['total_size']) |
|
| 249 | + { |
|
| 250 | + $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
| 251 | + } |
|
| 240 | 252 | } |
| 241 | 253 | if (!($content['is_root']=Vfs::$is_root)) |
| 242 | 254 | { |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | * @param array $content=null |
| 79 | 79 | * @param string $msg='' |
| 80 | 80 | */ |
| 81 | - public function index(array $content=null, $msg='', $msg_type=null) |
|
| 81 | + public function index(array $content = null, $msg = '', $msg_type = null) |
|
| 82 | 82 | { |
| 83 | 83 | if (is_array($content)) |
| 84 | 84 | { |
| 85 | 85 | //_debug_array($content); |
| 86 | 86 | if ($content['sudo']) |
| 87 | 87 | { |
| 88 | - $msg = $this->sudo($content['user'],$content['password'],self::$is_setup) ? |
|
| 88 | + $msg = $this->sudo($content['user'], $content['password'], self::$is_setup) ? |
|
| 89 | 89 | lang('Root access granted.') : lang('Wrong username or password!'); |
| 90 | 90 | $msg_type = Vfs::$is_root ? 'success' : 'error'; |
| 91 | 91 | } |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | Vfs::chgrp($path, 'Admins'); |
| 100 | 100 | Vfs::chmod($path, 075); |
| 101 | 101 | $msg = Vfs::mount($url, $path) ? |
| 102 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 102 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 103 | 103 | Vfs::$is_root = $backup; |
| 104 | 104 | } |
| 105 | 105 | elseif (Vfs::$is_root) |
| 106 | 106 | { |
| 107 | 107 | if ($content['logout']) |
| 108 | 108 | { |
| 109 | - $msg = $this->sudo('','',self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
| 109 | + $msg = $this->sudo('', '', self::$is_setup) ? 'Logout failed!' : lang('Root access stopped.'); |
|
| 110 | 110 | $msg_type = !Vfs::$is_root ? 'success' : 'error'; |
| 111 | 111 | } |
| 112 | 112 | if ($content['mounts']['disable'] || self::$is_setup && $content['mounts']['umount']) |
@@ -122,18 +122,18 @@ discard block |
||
| 122 | 122 | if (!in_array($path, self::$protected_path) && $path != '/') |
| 123 | 123 | { |
| 124 | 124 | $msg = Vfs::umount($path) ? |
| 125 | - lang('%1 successful unmounted.',$path) : lang('Error unmounting %1!',$path); |
|
| 125 | + lang('%1 successful unmounted.', $path) : lang('Error unmounting %1!', $path); |
|
| 126 | 126 | } |
| 127 | 127 | else // re-mount / with sqlFS, to disable versioning |
| 128 | 128 | { |
| 129 | - $msg = Vfs::mount($url=Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path,$path) ? |
|
| 130 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 129 | + $msg = Vfs::mount($url = Vfs\Sqlfs\StreamWrapper::SCHEME.'://default'.$path, $path) ? |
|
| 130 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | if (($path = $content['mounts']['path']) && |
| 134 | 134 | ($content['mounts']['enable'] || self::$is_setup && $content['mounts']['mount'])) |
| 135 | 135 | { |
| 136 | - $url = str_replace('$path',$path,$content['mounts']['url']); |
|
| 136 | + $url = str_replace('$path', $path, $content['mounts']['url']); |
|
| 137 | 137 | if (empty($url) && $this->versioning) $url = Versioning\StreamWrapper::PREFIX.$path; |
| 138 | 138 | |
| 139 | 139 | if ($content['mounts']['enable'] && !$this->versioning) |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | elseif (!Vfs::file_exists($path) || !Vfs::is_dir($path)) |
| 145 | 145 | { |
| 146 | - $msg = lang('Path %1 not found or not a directory!',$path); |
|
| 146 | + $msg = lang('Path %1 not found or not a directory!', $path); |
|
| 147 | 147 | $msg_type = 'error'; |
| 148 | 148 | } |
| 149 | 149 | // dont allow to change mount of /apps or /templates (eg. switching on versioning) |
@@ -154,8 +154,8 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | else |
| 156 | 156 | { |
| 157 | - $msg = Vfs::mount($url,$path) ? |
|
| 158 | - lang('Successful mounted %1 on %2.',$url,$path) : lang('Error mounting %1 on %2!',$url,$path); |
|
| 157 | + $msg = Vfs::mount($url, $path) ? |
|
| 158 | + lang('Successful mounted %1 on %2.', $url, $path) : lang('Error mounting %1 on %2!', $url, $path); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | if ($content['allow_delete_versions'] != $GLOBALS['egw_info']['server']['allow_delete_versions']) |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | 'hidden' => true, |
| 201 | 201 | 'depth' => true, |
| 202 | 202 | 'path_preg' => '#/\.(attic|versions)/#', |
| 203 | - )+(!(int)$content['mtime'] ? array() : array( |
|
| 204 | - 'mtime' => ($content['mtime']<0?'-':'+').(int)$content['mtime'], |
|
| 203 | + ) + (!(int)$content['mtime'] ? array() : array( |
|
| 204 | + 'mtime' => ($content['mtime'] < 0 ? '-' : '+').(int)$content['mtime'], |
|
| 205 | 205 | )), function($path) use (&$deleted, &$errors) |
| 206 | 206 | { |
| 207 | 207 | if (($is_dir = Vfs::is_dir($path)) && Vfs::rmdir($path) || |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | }); |
| 217 | 217 | } |
| 218 | - $time = number_format(microtime(true)-$starttime, 1); |
|
| 218 | + $time = number_format(microtime(true) - $starttime, 1); |
|
| 219 | 219 | $msg = ($errors ? lang('%1 errors deleting!', $errors)."\n\n" : ''). |
| 220 | 220 | lang('%1 files or directories deleted in %2 seconds.', $deleted, $time); |
| 221 | 221 | $msg_type = $errors ? 'error' : 'info'; |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | { |
| 239 | 239 | // statistical information |
| 240 | 240 | $content += Versioning\StreamWrapper::summary(); |
| 241 | - if ($content['total_files']) $content['percent_files'] = number_format(100.0*$content['version_files']/$content['total_files'],1).'%'; |
|
| 242 | - if ($content['total_size']) $content['percent_size'] = number_format(100.0*$content['version_size']/$content['total_size'],1).'%'; |
|
| 241 | + if ($content['total_files']) $content['percent_files'] = number_format(100.0 * $content['version_files'] / $content['total_files'], 1).'%'; |
|
| 242 | + if ($content['total_size']) $content['percent_size'] = number_format(100.0 * $content['version_size'] / $content['total_size'], 1).'%'; |
|
| 243 | 243 | } |
| 244 | - if (!($content['is_root']=Vfs::$is_root)) |
|
| 244 | + if (!($content['is_root'] = Vfs::$is_root)) |
|
| 245 | 245 | { |
| 246 | 246 | if (empty($msg)) |
| 247 | 247 | { |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $n = 2; |
| 259 | 259 | $content['mounts'] = array(); |
| 260 | - foreach(Vfs::mount() as $path => $url) |
|
| 260 | + foreach (Vfs::mount() as $path => $url) |
|
| 261 | 261 | { |
| 262 | 262 | $content['mounts'][$n++] = array( |
| 263 | 263 | 'path' => $path, |
| 264 | 264 | 'url' => $url, |
| 265 | 265 | ); |
| 266 | 266 | $readonlys["disable[$path]"] = !$this->versioning || !Vfs::$is_root || |
| 267 | - Vfs::parse_url($url,PHP_URL_SCHEME) != $this->versioning; |
|
| 267 | + Vfs::parse_url($url, PHP_URL_SCHEME) != $this->versioning; |
|
| 268 | 268 | } |
| 269 | - $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
| 269 | + $readonlys['umount[/]'] = $readonlys['umount[/apps]'] = true; // do not allow to unmount / or /apps |
|
| 270 | 270 | $readonlys['url'] = !self::$is_setup; |
| 271 | 271 | |
| 272 | 272 | $sel_options['allow_delete_versions'] = array( |
@@ -276,13 +276,13 @@ discard block |
||
| 276 | 276 | ); |
| 277 | 277 | // show [Mount /etemplates] button for admin, if not already mounted and available |
| 278 | 278 | $readonlys['etemplates'] = !class_exists('\EGroupware\Stylite\Vfs\Merge\StreamWrapper') || |
| 279 | - ($fs_tab=Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
| 279 | + ($fs_tab = Vfs::mount($url)) && isset($fs_tab['/etemplates']) || |
|
| 280 | 280 | !isset($GLOBALS['egw_info']['user']['apps']['admin']); |
| 281 | 281 | //_debug_array($content); |
| 282 | 282 | |
| 283 | 283 | $tpl = new Etemplate('filemanager.admin'); |
| 284 | 284 | $GLOBALS['egw_info']['flags']['app_header'] = lang('VFS mounts and versioning'); |
| 285 | - $tpl->exec('filemanager.filemanager_admin.index',$content,$sel_options,$readonlys); |
|
| 285 | + $tpl->exec('filemanager.filemanager_admin.index', $content, $sel_options, $readonlys); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -302,10 +302,10 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | $content = '<p>'.implode("</p>\n<p>", (array)$msgs)."</p>\n"; |
| 304 | 304 | |
| 305 | - $content .= Api\Html::form('<p>'.($check_only&&is_array($msgs) ? |
|
| 305 | + $content .= Api\Html::form('<p>'.($check_only && is_array($msgs) ? |
|
| 306 | 306 | Api\Html::submit_button('fix', lang('Fix reported problems')) : ''). |
| 307 | 307 | Api\Html::submit_button('cancel', lang('Cancel')).'</p>', |
| 308 | - '','/index.php',array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
| 308 | + '', '/index.php', array('menuaction'=>'filemanager.filemanager_admin.fsck')); |
|
| 309 | 309 | |
| 310 | 310 | $GLOBALS['egw']->framework->render($content, lang('Admin').' - '.lang('Check virtual filesystem'), true); |
| 311 | 311 | } |