* Calendar: iCal export of list-view contains event series and not recurrences, also fixes wrong timezone, if different between user and server

This commit is contained in:
Ralf Becker 2015-06-19 18:35:57 +00:00
parent 2d63cfb10d
commit 49bf055b33

View File

@ -508,7 +508,7 @@ class calendar_uilist extends calendar_ui
*/ */
function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false) function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
{ {
//echo '<p>' . __METHOD__ . "('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n"; //error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
$success = $failed = 0; $success = $failed = 0;
$msg = null; $msg = null;
@ -542,7 +542,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 // 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'); $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 @set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
@ -558,12 +558,23 @@ class calendar_uilist extends calendar_ui
switch($action) switch($action)
{ {
case 'ical': 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(); $boical = new calendar_ical();
$ical =& $boical->exportVCal($checked,'2.0','PUBLISH',false); $ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
html::content_header($content['file'] ? $content['file'] : 'event.ics','text/calendar',bytes($ical)); html::content_header('event.ics', 'text/calendar', bytes($ical));
echo $ical; echo $ical;
common::egw_exit(); common::egw_exit();
break;
case 'document': case 'document':
if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document']; if (!$settings) $settings = $GLOBALS['egw_info']['user']['preferences']['calendar']['default_document'];