diff --git a/infolog/inc/class.infolog_export_ical.inc.php b/infolog/inc/class.infolog_export_ical.inc.php index 419aec0bc8..213aa0f29a 100644 --- a/infolog/inc/class.infolog_export_ical.inc.php +++ b/infolog/inc/class.infolog_export_ical.inc.php @@ -24,8 +24,6 @@ class infolog_export_ical extends infolog_export_csv { public function export( $_stream, importexport_definition $_definition) { $options = $_definition->plugin_options; $this->bo = new infolog_bo(); - $boical = new infolog_ical(); - $horde = new Horde_iCalendar(); $limit_exception = bo_merge::is_export_limit_excepted(); if (!$limit_exception) $export_limit = bo_merge::getExportLimit('infolog'); @@ -48,17 +46,8 @@ class infolog_export_ical extends infolog_export_csv { break; } - $horde->clear(); - foreach($selection as $_selection) { - $result = $boical->exportVTODO($_selection,'2.0','PUBLISH',false); - - // infolog_ical doesn't allow a nice call to get just the VTODO - if($result) - { - $horde->parsevCalendar($result, 'VCALENDAR', 'utf-8', false); - } - } - fwrite($_stream, $horde->exportvCalendar()); + $boical = new infolog_ical(); + fwrite($_stream, $boical->exportvCalendar($selection)); } /** diff --git a/infolog/inc/class.infolog_ical.inc.php b/infolog/inc/class.infolog_ical.inc.php index 1b69305d00..4deb474e97 100644 --- a/infolog/inc/class.infolog_ical.inc.php +++ b/infolog/inc/class.infolog_ical.inc.php @@ -108,6 +108,29 @@ class infolog_ical extends infolog_bo $this->clientProperties = $_clientProperties; } + /** + * Exports multiple InfoLogs + * + * @param array $tasks array of info_ids or task arrays + * @param string $_version='2.0' + * @param string $_method=null only set for iTip messages + * @param string $charset='UTF-8' + * @return string|boolean string with vCal or false on error (eg. no permission to read the event) + */ + function exportVCalendar(array $tasks, $_version='2.0', $_method=null, $charset='UTF-8') + { + $vcal = new Horde_iCalendar; + + foreach($tasks as $task) + { + if (!$this->exportVTODO($task, $_version, $_method, $charset, $vcal)) + { + return false; + } + } + return $vcal->exportVCalendar(); + } + /** * Exports one InfoLog tast to an iCalendar VTODO * @@ -115,10 +138,11 @@ class infolog_ical extends infolog_bo * @param string $_version='2.0' could be '1.0' too * @param string $_method='PUBLISH' * @param string $charset='UTF-8' encoding of the vcalendar, default UTF-8 + * @param Horde_iCalendar $vcal=null optional iCalendar object to add vtodo to * * @return string|boolean string with vCal or false on error (eg. no permission to read the event) */ - function exportVTODO($task, $_version='2.0',$_method='PUBLISH', $charset='UTF-8') + function exportVTODO($task, $_version='2.0',$_method='PUBLISH', $charset='UTF-8',Horde_iCalendar $vcal=null) { if (is_array($task)) { @@ -166,11 +190,11 @@ class infolog_ical extends infolog_bo array2string($taskData)."\n",3,$this->logfile); } - $vcal = new Horde_iCalendar; + if (!isset($vcal)) $vcal = new Horde_iCalendar; $vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'. - strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang'])); - $vcal->setAttribute('VERSION',$_version); - if ($_method) $vcal->setAttribute('METHOD',$_method); + strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']),array(),false); + $vcal->setAttribute('VERSION',$_version,array(),false); + if ($_method) $vcal->setAttribute('METHOD',$_method,array(),false); $tzid = $this->tzid; if ($tzid && $tzid != 'UTC') diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 166b2b9c48..95084fc2ea 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -1224,20 +1224,10 @@ class infolog_ui case 'ical': // infolog_ical lets horde be auto-loaded, so it must go first $boical = new infolog_ical(); - $horde = new Horde_iCalendar(); - foreach($checked as $_selection) { - $result = $boical->exportVTODO($_selection,'2.0','PUBLISH',false); - - // infolog_ical doesn't allow a nice call to get just the VTODO - if($result) - { - $horde->parsevCalendar($result, 'VCALENDAR', 'utf-8', false); - } - } ExecMethod2('phpgwapi.browser.content_header','todo.ics','text/calendar'); - echo $horde->exportvCalendar(); + echo $boical->exportvCalendar($checked); common::egw_exit(); - + } // Actions that need to loop