iCal export should contain only event series and not recurrences, also fixes wrong timezone, if different between user and server

This commit is contained in:
Ralf Becker 2015-06-22 09:16:20 +00:00
parent c409247283
commit 6cc8826732

View File

@ -1,6 +1,6 @@
<?php <?php
/** /**
* eGroupWare * EGroupware: iCal export plugin of calendar
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package calendar * @package calendar
@ -12,7 +12,7 @@
*/ */
/** /**
* export iCal plugin of calendar * iCal export plugin of calendar
*/ */
class calendar_export_ical extends calendar_export_csv { class calendar_export_ical extends calendar_export_csv {
@ -63,6 +63,7 @@ class calendar_export_ical extends calendar_export_csv {
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
} }
$ui = new calendar_uilist(); $ui = new calendar_uilist();
$unused = null;
$ui->get_rows($query, $events, $unused); $ui->get_rows($query, $events, $unused);
} }
else else
@ -75,7 +76,6 @@ class calendar_export_ical extends calendar_export_csv {
$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0 $query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
} }
$events = array();
switch($states['view']) switch($states['view'])
{ {
case 'month': case 'month':
@ -109,8 +109,16 @@ class calendar_export_ical extends calendar_export_csv {
)); ));
} }
} }
// 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($events as $event)
{
$id = is_array($event) ? $event['id'] : $event;
if (($id = (int)$id)) $ids[$id] = $id;
}
$ical =& $boical->exportVCal($events,'2.0','PUBLISH',false); $ical =& $boical->exportVCal($ids,'2.0','PUBLISH',false);
fwrite($_stream, $ical); fwrite($_stream, $ical);
} }