From 6be3313d3c6536078863ba091b8fee079ff5bf6a Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 19 Jun 2015 18:35:20 +0000 Subject: [PATCH] * Calendar: iCal export of list-view contains event series and not recurrences, also fixes wrong timezone, if different between user and server --- calendar/inc/class.calendar_uilist.inc.php | 25 ++++++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index bdec76768c..0f614b847d 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -399,7 +399,7 @@ class calendar_uilist extends calendar_ui { $event['class'] .= 'rowDeleted '; } - + $event['recure'] = $this->bo->recure2string($event); if ($params['csv_export']) { @@ -481,7 +481,7 @@ class calendar_uilist extends calendar_ui // set id for grid $event['row_id'] = $event['id'].($event['recur_type'] ? ':'.$event['recur_date'] : ''); - + // Format start and end with timezone foreach(array('start','end') as $time) { @@ -536,7 +536,7 @@ class calendar_uilist extends calendar_ui */ function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) { - //echo '

' . __METHOD__ . "('$action',".print_r($checked,true).','.(int)$use_all.",...)

\n"; + //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)"); $success = $failed = 0; $msg = null; @@ -570,7 +570,7 @@ class calendar_uilist extends calendar_ui } } // for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id - elseif(in_array($action,array('ical','document'))) + elseif($action == 'document') { $query = is_array($session_name) ? $session_name : egw_session::appsession($session_name,'calendar'); @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small @@ -586,12 +586,23 @@ class calendar_uilist extends calendar_ui switch($action) { case 'ical': + // compile list of unique cal_id's, as iCal should contain whole series, not recurrences + // calendar_ical->exportVCal needs to read events again, to get them in server-time + $ids = array(); + foreach($checked as $id) + { + if (is_array($id)) $id = $id['id']; + // get rid of recurrences, doublicate series and calendar-integration events + if (($id = (int)$id)) + { + $ids[$id] = $id; + } + } $boical = new calendar_ical(); - $ical =& $boical->exportVCal($checked,'2.0','PUBLISH',false); - html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); + $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH'); + html::content_header('event.ics', 'text/calendar', bytes($ical)); echo $ical; common::egw_exit(); - break; case 'document': if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];