mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Calendar - import ical Add additional option to select category for iCal import.
iCal.
This commit is contained in:
parent
07793d87a7
commit
484ec5aaa7
@ -158,6 +158,16 @@ class calendar_ical extends calendar_boupdate
|
|||||||
var $log = false;
|
var $log = false;
|
||||||
var $logfile="/tmp/log-vcal";
|
var $logfile="/tmp/log-vcal";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event callback
|
||||||
|
* If set, this will be called on each discovered event so it can be
|
||||||
|
* modified. Event is passed by reference, return true to keep the event
|
||||||
|
* or false to skip it.
|
||||||
|
*
|
||||||
|
* @var callable
|
||||||
|
*/
|
||||||
|
var $event_callback = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conflict callback
|
* Conflict callback
|
||||||
* If set, conflict checking will be enabled, and the event as well as
|
* If set, conflict checking will be enabled, and the event as well as
|
||||||
@ -1177,6 +1187,16 @@ class calendar_ical extends calendar_boupdate
|
|||||||
foreach ($events as $event)
|
foreach ($events as $event)
|
||||||
{
|
{
|
||||||
if (!is_array($event)) continue; // the iterator may return false
|
if (!is_array($event)) continue; // the iterator may return false
|
||||||
|
|
||||||
|
// Run event through callback
|
||||||
|
if($this->event_callback && is_callable($this->event_callback))
|
||||||
|
{
|
||||||
|
if(!call_user_func_array($this->event_callback, array(&$event)))
|
||||||
|
{
|
||||||
|
// Callback cancelled event
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
++$this->events_imported;
|
++$this->events_imported;
|
||||||
|
|
||||||
if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
|
if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
|
||||||
|
@ -160,6 +160,8 @@ class calendar_import_ical implements importexport_iface_import_plugin {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$calendar_ical->event_callback = array($this, 'event_callback');
|
||||||
|
|
||||||
// User wants conflicting events to not be imported
|
// User wants conflicting events to not be imported
|
||||||
if($_definition->plugin_options['skip_conflicts'])
|
if($_definition->plugin_options['skip_conflicts'])
|
||||||
{
|
{
|
||||||
@ -177,6 +179,18 @@ class calendar_import_ical implements importexport_iface_import_plugin {
|
|||||||
return $calendar_ical->events_imported;
|
return $calendar_ical->events_imported;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do some modification on each event
|
||||||
|
*/
|
||||||
|
public function event_callback(&$event)
|
||||||
|
{
|
||||||
|
// Check & apply value overrides
|
||||||
|
foreach((array)$this->definition->plugin_options['override_values'] as $field => $settings)
|
||||||
|
{
|
||||||
|
$event[$field] = $settings['value'];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a warning message about conflicting events
|
* Add a warning message about conflicting events
|
||||||
|
@ -70,7 +70,7 @@ class calendar_wizard_import_ical
|
|||||||
{
|
{
|
||||||
$content['text'] = $this->steps['wizard_step55'];
|
$content['text'] = $this->steps['wizard_step55'];
|
||||||
$content['step'] = 'wizard_step55';
|
$content['step'] = 'wizard_step55';
|
||||||
foreach(array('skip_conflicts','empty_before_import','remove_past','remove_future') as $field)
|
foreach(array('skip_conflicts','empty_before_import','remove_past','remove_future','override_values') as $field)
|
||||||
{
|
{
|
||||||
if(!$content[$field] && array_key_exists($field, $content['plugin_options']))
|
if(!$content[$field] && array_key_exists($field, $content['plugin_options']))
|
||||||
{
|
{
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
</hbox>
|
</hbox>
|
||||||
<integer label="How many days to be removed in the past (default 100)" id="remove_past" disabled="!@empty_before_import"/>
|
<integer label="How many days to be removed in the past (default 100)" id="remove_past" disabled="!@empty_before_import"/>
|
||||||
<integer label="How many days to be removed in the future (default 365)" id="remove_future" disabled="!@empty_before_import"/>
|
<integer label="How many days to be removed in the future (default 365)" id="remove_future" disabled="!@empty_before_import"/>
|
||||||
|
<select-cat id="override_values[category][value]" label="Category" empty_label="From file" options=",,,@application"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
<styles>
|
<styles>
|
||||||
#importexport-wizardbox_delete_title {
|
#importexport-wizardbox_delete_title {
|
||||||
|
Loading…
Reference in New Issue
Block a user