mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-13 17:00:45 +01:00
Fix egw_ical iterator issues
This commit is contained in:
parent
ae351b22fc
commit
e4d0b6737c
@ -1072,8 +1072,21 @@ class calendar_ical extends calendar_boupdate
|
|||||||
{
|
{
|
||||||
calendar_groupdav::fix_series($events);
|
calendar_groupdav::fix_series($events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->tzid)
|
||||||
|
{
|
||||||
|
$tzid = $this->tzid;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$tzid = egw_time::$user_timezone->getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
date_default_timezone_set($tzid);
|
||||||
|
|
||||||
foreach ($events as $event)
|
foreach ($events as $event)
|
||||||
{
|
{
|
||||||
|
if (!is_array($event)) continue; // the iterator may return false
|
||||||
++$this->events_imported;
|
++$this->events_imported;
|
||||||
|
|
||||||
if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
|
if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
|
||||||
@ -1291,6 +1304,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
||||||
return 0; // no permission
|
return 0; // no permission
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1702,10 +1716,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
array2string($event_info['stored_event'])."\n",3,$this->logfile);
|
array2string($event_info['stored_event'])."\n",3,$this->logfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_resource($_vcalData))
|
|
||||||
{
|
|
||||||
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
||||||
}
|
|
||||||
return $return_id;
|
return $return_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2098,6 +2109,14 @@ class calendar_ical extends calendar_boupdate
|
|||||||
array2string($_vcalData)."\n",3,$this->logfile);
|
array2string($_vcalData)."\n",3,$this->logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_array($this->supportedFields)) $this->setSupportedFields();
|
||||||
|
|
||||||
|
// we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
|
||||||
|
if (is_resource($_vcalData))
|
||||||
|
{
|
||||||
|
return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL));
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->tzid)
|
if ($this->tzid)
|
||||||
{
|
{
|
||||||
$tzid = $this->tzid;
|
$tzid = $this->tzid;
|
||||||
@ -2109,13 +2128,6 @@ class calendar_ical extends calendar_boupdate
|
|||||||
|
|
||||||
date_default_timezone_set($tzid);
|
date_default_timezone_set($tzid);
|
||||||
|
|
||||||
if (!is_array($this->supportedFields)) $this->setSupportedFields();
|
|
||||||
|
|
||||||
// we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
|
|
||||||
if (is_resource($_vcalData))
|
|
||||||
{
|
|
||||||
return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($tzid,$principalURL));
|
|
||||||
}
|
|
||||||
$events = array();
|
$events = array();
|
||||||
$vcal = new Horde_iCalendar;
|
$vcal = new Horde_iCalendar;
|
||||||
if (!$vcal->parsevCalendar($_vcalData, 'VCALENDAR', $charset))
|
if (!$vcal->parsevCalendar($_vcalData, 'VCALENDAR', $charset))
|
||||||
@ -2125,17 +2137,14 @@ class calendar_ical extends calendar_boupdate
|
|||||||
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
|
||||||
"(): No vCalendar Container found!\n",3,$this->logfile);
|
"(): No vCalendar Container found!\n",3,$this->logfile);
|
||||||
}
|
}
|
||||||
if ($this->tzid)
|
|
||||||
{
|
|
||||||
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$version = $vcal->getAttribute('VERSION');
|
$version = $vcal->getAttribute('VERSION');
|
||||||
|
|
||||||
foreach ($vcal->getComponents() as $n => $component)
|
foreach ($vcal->getComponents() as $n => $component)
|
||||||
{
|
{
|
||||||
if (($event = $this->_ical2egw_callback($component,$tzid,$principalURL)))
|
if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL)))
|
||||||
{
|
{
|
||||||
$events[] = $event;
|
$events[] = $event;
|
||||||
}
|
}
|
||||||
@ -2153,17 +2162,18 @@ class calendar_ical extends calendar_boupdate
|
|||||||
* @param string $principalURL='' Used for CalDAV imports
|
* @param string $principalURL='' Used for CalDAV imports
|
||||||
* @return array|boolean event array or false if $component is no Horde_iCalendar_vevent
|
* @return array|boolean event array or false if $component is no Horde_iCalendar_vevent
|
||||||
*/
|
*/
|
||||||
function _ical2egw_callback(Horde_iCalendar $component,$tzid,$principalURL='')
|
function _ical2egw_callback(Horde_iCalendar &$component, $tzid, $principalURL='')
|
||||||
{
|
{
|
||||||
//unset($component->_container); _debug_array($component);
|
//unset($component->_container); _debug_array($component);
|
||||||
|
|
||||||
if (!is_a($component, 'Horde_iCalendar_vevent') ||
|
|
||||||
!($event = $this->vevent2egw($component, $component->getAttribute('VERSION'), $this->supportedFields, $principalURL)))
|
|
||||||
{
|
|
||||||
if ($this->log)
|
if ($this->log)
|
||||||
{
|
{
|
||||||
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
|
error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_a($component, 'Horde_iCalendar_vevent') ||
|
||||||
|
!($event = $this->vevent2egw($component, $component->getAttribute('VERSION'), $this->supportedFields, $principalURL)))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//common adjustments
|
//common adjustments
|
||||||
@ -2188,7 +2198,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$event['alarm'] = $alarms;
|
$event['alarm'] = $alarms;
|
||||||
if ($this->tzid || empty($event['tzid']))
|
if ($tzid || empty($event['tzid']))
|
||||||
{
|
{
|
||||||
$event['tzid'] = $tzid;
|
$event['tzid'] = $tzid;
|
||||||
}
|
}
|
||||||
@ -2218,7 +2228,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mozillaACK = $component->getAttribute('X-MOZ-LASTACK');
|
$mozillaACK = $component->getAttribute('X-MOZ-LASTACK');
|
||||||
if (!is_a($mozillaACK, 'PEAR_Error'))
|
if ($this->productName == 'lightning' && !is_a($mozillaACK, 'PEAR_Error'))
|
||||||
{
|
{
|
||||||
if ($this->log)
|
if ($this->log)
|
||||||
{
|
{
|
||||||
|
@ -1739,6 +1739,7 @@ function replace_eTemplate_onsubmit()
|
|||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
$calendar_ical = new calendar_ical;
|
$calendar_ical = new calendar_ical;
|
||||||
|
$calendar_ical->setSupportedFields('file', '');
|
||||||
if (!$calendar_ical->importVCal($f=fopen($content['ical_file']['tmp_name'],'r')))
|
if (!$calendar_ical->importVCal($f=fopen($content['ical_file']['tmp_name'],'r')))
|
||||||
{
|
{
|
||||||
$msg = lang('Error: importing the iCal');
|
$msg = lang('Error: importing the iCal');
|
||||||
|
@ -193,8 +193,10 @@ class egw_ical_iterator extends Horde_iCalendar implements Iterator
|
|||||||
//error_log(__METHOD__."() returning a ".gettype($this->component));
|
//error_log(__METHOD__."() returning a ".gettype($this->component));
|
||||||
if ($this->callback)
|
if ($this->callback)
|
||||||
{
|
{
|
||||||
|
$ret = is_a($this->component,'Horde_iCalendar');
|
||||||
do {
|
do {
|
||||||
if ($ret === false) $this->next();
|
if ($ret === false) $this->next();
|
||||||
|
if (!is_a($this->component,'Horde_iCalendar')) return false;
|
||||||
$params = $this->callback_params;
|
$params = $this->callback_params;
|
||||||
array_unshift($params,$this->component);
|
array_unshift($params,$this->component);
|
||||||
}
|
}
|
||||||
@ -248,6 +250,7 @@ class egw_ical_iterator extends Horde_iCalendar implements Iterator
|
|||||||
if ($this->component === false)
|
if ($this->component === false)
|
||||||
{
|
{
|
||||||
error_log(__METHOD__."() Horde_iCalendar::newComponent('$type', \$this) returned FALSE");
|
error_log(__METHOD__."() Horde_iCalendar::newComponent('$type', \$this) returned FALSE");
|
||||||
|
return;
|
||||||
//return PEAR::raiseError("Unable to create object for type $type");
|
//return PEAR::raiseError("Unable to create object for type $type");
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__."() about to call parsevCalendar('".substr($data,0,100)."...','$type','$this->charset')");
|
//error_log(__METHOD__."() about to call parsevCalendar('".substr($data,0,100)."...','$type','$this->charset')");
|
||||||
@ -292,7 +295,7 @@ class egw_ical_iterator extends Horde_iCalendar implements Iterator
|
|||||||
}
|
}
|
||||||
$data .= $line;
|
$data .= $line;
|
||||||
}
|
}
|
||||||
// fake end of container, to get it parsed by Horde code
|
// fake end of container to get it parsed by Horde code
|
||||||
if ($this->container)
|
if ($this->container)
|
||||||
{
|
{
|
||||||
$data .= "END:$this->base\n";
|
$data .= "END:$this->base\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user