mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
move egw_ical_iterator to Api\CalDAV\IcalIterator
This commit is contained in:
parent
ca1bf71361
commit
fc9c345930
@ -10,6 +10,7 @@
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use EGroupware\Api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin to import vCard files
|
* Plugin to import vCard files
|
||||||
@ -17,7 +18,7 @@
|
|||||||
class addressbook_import_vcard implements importexport_iface_import_plugin {
|
class addressbook_import_vcard implements importexport_iface_import_plugin {
|
||||||
|
|
||||||
private static $plugin_options = array(
|
private static $plugin_options = array(
|
||||||
|
|
||||||
'contact_owner'
|
'contact_owner'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
// Fix for Apple Addressbook
|
// Fix for Apple Addressbook
|
||||||
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
|
$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
|
||||||
|
|
||||||
$contacts = new egw_ical_iterator($vCard, '', $charset, array($this, '_vcard'),array(
|
$contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'),array(
|
||||||
// Owner (addressbook)
|
// Owner (addressbook)
|
||||||
$contact_owner
|
$contact_owner
|
||||||
));
|
));
|
||||||
@ -147,7 +148,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
$count++;
|
$count++;
|
||||||
$contacts->next();
|
$contacts->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,8 +167,8 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
if(!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks()))
|
if(!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks()))
|
||||||
{
|
{
|
||||||
$this->errors[$this->current] = lang("Unable to import into %1, using %2",
|
$this->errors[$this->current] = lang("Unable to import into %1, using %2",
|
||||||
common::grab_owner_name($record['owner']),
|
Api\Accounts::username($record['owner']),
|
||||||
common::grab_owner_name($this->user)
|
Api\Accounts::username($this->user)
|
||||||
);
|
);
|
||||||
$record['owner'] = $this->user;
|
$record['owner'] = $this->user;
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
} else {
|
} else {
|
||||||
//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
|
//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure n_fn gets updated
|
// Make sure n_fn gets updated
|
||||||
unset($_data['n_fn']);
|
unset($_data['n_fn']);
|
||||||
|
|
||||||
@ -249,8 +250,8 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new egw_exception('Unsupported action: '. $_action);
|
throw new Api\Exception('Unsupported action: '. $_action);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +290,7 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
$row += $record;
|
$row += $record;
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
return html::table($rows);
|
return Api\Html::table($rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -380,4 +381,3 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
|||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
}
|
||||||
} // end of iface_export_plugin
|
} // end of iface_export_plugin
|
||||||
?>
|
|
||||||
|
@ -5,12 +5,17 @@
|
|||||||
* @link http://www.egroupware.org
|
* @link http://www.egroupware.org
|
||||||
* @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 api
|
* @package api
|
||||||
* @subpackage groupdav
|
* @subpackage caldav
|
||||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
* @copyright (c) 2010-15 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
* @copyright (c) 2010-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace EGroupware\Api\CalDAV;
|
||||||
|
|
||||||
|
use EGroupware\Api;
|
||||||
|
use Horde_Icalendar;
|
||||||
|
|
||||||
// required for tests at the end of this file (run if file called directly)
|
// required for tests at the end of this file (run if file called directly)
|
||||||
if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
|
if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
|
||||||
{
|
{
|
||||||
@ -20,7 +25,7 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_
|
|||||||
'nonavbar' => 'true',
|
'nonavbar' => 'true',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
include('../../header.inc.php');
|
include('../../../header.inc.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +33,7 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_
|
|||||||
*
|
*
|
||||||
* try {
|
* try {
|
||||||
* $ical_file = fopen($path,'r');
|
* $ical_file = fopen($path,'r');
|
||||||
* $ical_it = new egw_ical_iterator($ical_file,'VCALENDAR');
|
* $ical_it = new Api\CalDAV\IcalIterator($ical_file,'VCALENDAR');
|
||||||
* }
|
* }
|
||||||
* catch (Exception $e)
|
* catch (Exception $e)
|
||||||
* {
|
* {
|
||||||
@ -40,7 +45,7 @@ if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE_
|
|||||||
* }
|
* }
|
||||||
* fclose($ical_file)
|
* fclose($ical_file)
|
||||||
*/
|
*/
|
||||||
class egw_ical_iterator extends Horde_Icalendar implements Iterator
|
class IcalIterator extends Horde_Icalendar implements \Iterator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* File we work on
|
* File we work on
|
||||||
@ -124,7 +129,7 @@ class egw_ical_iterator extends Horde_Icalendar implements Iterator
|
|||||||
}
|
}
|
||||||
if (!is_resource($this->ical_file))
|
if (!is_resource($this->ical_file))
|
||||||
{
|
{
|
||||||
throw new egw_exception_wrong_parameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file),0,100));
|
throw new Api\Exception\WrongParameter(__METHOD__.'($ical_file, ...) NO resource! $ical_file='.substr(array2string($ical_file),0,100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,12 +430,12 @@ X-MS-OLK-CONFTYPE:0
|
|||||||
END:VEVENT
|
END:VEVENT
|
||||||
END:VCALENDAR
|
END:VCALENDAR
|
||||||
';
|
';
|
||||||
common::egw_header();
|
$GLOBALS['egw']->framework->header();
|
||||||
//$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics');
|
//$ical_file = fopen('/tmp/KalenderFelicitasKubala.ics');
|
||||||
if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n";
|
if (!is_resource($ical_file)) echo "<pre>$ical_file</pre>\n";
|
||||||
//$calendar_ical = new calendar_ical();
|
//$calendar_ical = new calendar_ical();
|
||||||
//$calendar_ical->setSupportedFields('file');
|
//$calendar_ical->setSupportedFields('file');
|
||||||
$ical_it = new egw_ical_iterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
|
$ical_it = new IcalIterator($ical_file);//,'VCALENDAR','iso-8859-1',array($calendar_ical,'_ical2egw_callback'),array('Europe/Berlin'));
|
||||||
foreach($ical_it as $uid => $vevent)
|
foreach($ical_it as $uid => $vevent)
|
||||||
{
|
{
|
||||||
echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n";
|
echo "$uid<pre>".print_r($vevent->toHash(), true)."</pre>\n";
|
@ -2249,10 +2249,10 @@ class calendar_ical extends calendar_boupdate
|
|||||||
|
|
||||||
if (!is_array($this->supportedFields)) $this->setSupportedFields();
|
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])
|
// we use Api\CalDAV\IcalIterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
|
||||||
if (is_resource($_vcalData))
|
if (is_resource($_vcalData))
|
||||||
{
|
{
|
||||||
return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL));
|
return new Api\CalDAV\IcalIterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->tzid)
|
if ($this->tzid)
|
||||||
@ -2317,7 +2317,7 @@ class calendar_ical extends calendar_boupdate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for egw_ical_iterator to convert Horde_iCalendar_Vevent to EGw event array
|
* Callback for Api\CalDAV\IcalIterator to convert Horde_iCalendar_Vevent to EGw event array
|
||||||
*
|
*
|
||||||
* @param Horde_iCalendar $component
|
* @param Horde_iCalendar $component
|
||||||
* @param string $tzid timezone
|
* @param string $tzid timezone
|
||||||
|
Loading…
Reference in New Issue
Block a user