mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 15:33:23 +01:00
Add category override for addressbook vcard & infolog ical import
This commit is contained in:
parent
e93f212d4f
commit
befac35e0b
@ -181,6 +181,14 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
|
||||
$record['owner'] = $this->user;
|
||||
}
|
||||
|
||||
// Check & apply value overrides
|
||||
foreach((array)$this->definition->plugin_options['override_values'] as $field => $settings)
|
||||
{
|
||||
if($settings['value'])
|
||||
{
|
||||
$record[$field] = $settings['value'];
|
||||
}
|
||||
}
|
||||
if (is_array($record['cat_id']))
|
||||
{
|
||||
$record['cat_id'] = implode(',',$this->bocontacts->find_or_add_categories($record['cat_id'], -1));
|
||||
|
@ -93,7 +93,7 @@ class addressbook_wizard_import_vcard extends addressbook_import_vcard
|
||||
// init step60
|
||||
else
|
||||
{
|
||||
$content['msg'] = $this->steps['wizard_step60'];
|
||||
$content['title'] = $this->steps['wizard_step60'];
|
||||
$content['step'] = 'wizard_step60';
|
||||
if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
|
||||
$content['contact_owner'] = $content['plugin_options']['contact_owner'];
|
||||
@ -105,6 +105,13 @@ class addressbook_wizard_import_vcard extends addressbook_import_vcard
|
||||
$bocontacts = new Api\Contacts();
|
||||
$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
|
||||
|
||||
foreach(array('override_values') as $field)
|
||||
{
|
||||
if(!$content[$field] && array_key_exists($field, $content['plugin_options']))
|
||||
{
|
||||
$content[$field] = $content['plugin_options'][$field];
|
||||
}
|
||||
}
|
||||
$preserv = $content;
|
||||
unset ($preserv['button']);
|
||||
return 'addressbook.importexport_wizard_vcard_chooseowner';
|
||||
|
@ -9,7 +9,7 @@
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<description id="msg" no_lang="1"/>
|
||||
<description id="title" no_lang="1"/>
|
||||
</row>
|
||||
<row>
|
||||
<menulist>
|
||||
@ -17,7 +17,7 @@
|
||||
</menulist>
|
||||
</row>
|
||||
<row>
|
||||
<description/>
|
||||
<select-cat id="override_values[cat_id][value]" label="Category" empty_label="From file" options=",,,@application"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
@ -87,6 +87,16 @@ class infolog_ical extends infolog_bo
|
||||
*/
|
||||
var $clientProperties;
|
||||
|
||||
/**
|
||||
* Entry callback
|
||||
* If set, this will be called on each discovered etry so it can be
|
||||
* modified. Entry is passed by reference, return true to keep the event
|
||||
* or false to skip it.
|
||||
*
|
||||
* @var callable
|
||||
*/
|
||||
var $entry_callback = null;
|
||||
|
||||
/**
|
||||
* Set Logging
|
||||
*
|
||||
@ -532,6 +542,14 @@ class infolog_ical extends infolog_bo
|
||||
date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
|
||||
}
|
||||
|
||||
if($this->entry_callback && is_callable($this->entry_callback))
|
||||
{
|
||||
if(!call_user_func_array($this->entry_callback, array(&$taskData)))
|
||||
{
|
||||
// Callback cancelled entry
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!$taskData) return false;
|
||||
|
||||
// keep the dates
|
||||
|
@ -94,6 +94,7 @@ class infolog_import_ical implements importexport_iface_import_plugin {
|
||||
@set_time_limit(0); // try switching execution time limit off
|
||||
|
||||
$infolog_ical = new infolog_ical();
|
||||
$infolog_ical->entry_callback = array($this, 'entry_callback');
|
||||
if (!$infolog_ical->importVTODO(stream_get_contents($_stream)))
|
||||
{
|
||||
$this->errors[] = lang('Error: importing the iCal');
|
||||
@ -107,6 +108,21 @@ class infolog_import_ical implements importexport_iface_import_plugin {
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do some modification on each entry
|
||||
*/
|
||||
public function entry_callback(&$event)
|
||||
{
|
||||
// Check & apply value overrides
|
||||
foreach((array)$this->definition->plugin_options['override_values'] as $field => $settings)
|
||||
{
|
||||
if($settings['value'])
|
||||
{
|
||||
$event[$field] = $settings['value'];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns translated name of plugin
|
||||
|
79
infolog/inc/class.infolog_wizard_import_ical.inc.php
Normal file
79
infolog/inc/class.infolog_wizard_import_ical.inc.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware - Wizard for user CSV import
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package calendar
|
||||
* @subpackage importexport
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
class infolog_wizard_import_ical
|
||||
{
|
||||
/**
|
||||
* List of steps. Key is the function, value is the translated title.
|
||||
*/
|
||||
public $steps;
|
||||
|
||||
/**
|
||||
* List of eTemplates to use for each step. You can override this with your own etemplates steps.
|
||||
*/
|
||||
protected $step_templates = array(
|
||||
'wizard_step55' => 'infolog.import.ical_conditions',
|
||||
);
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
Api\Framework::includeJS('.','et2_widget_owner','calendar');
|
||||
Api\Framework::includeCSS('calendar','calendar');
|
||||
$this->steps = array(
|
||||
'wizard_step55' => lang('Edit conditions'),
|
||||
);
|
||||
}
|
||||
|
||||
// Conditions
|
||||
function wizard_step55(&$content, &$sel_options, &$readonlys, &$preserv)
|
||||
{
|
||||
// return from step55
|
||||
if ($content['step'] == 'wizard_step55')
|
||||
{
|
||||
switch (array_search('pressed', $content['button']))
|
||||
{
|
||||
case 'next':
|
||||
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
|
||||
case 'previous' :
|
||||
return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
|
||||
case 'finish':
|
||||
return 'wizard_finish';
|
||||
default :
|
||||
return $this->wizard_step55($content,$sel_options,$readonlys,$preserv);
|
||||
}
|
||||
}
|
||||
// init step30
|
||||
else
|
||||
{
|
||||
$content['text'] = $this->steps['wizard_step55'];
|
||||
$content['step'] = 'wizard_step55';
|
||||
foreach(array('override_values') as $field)
|
||||
{
|
||||
if(!$content[$field] && array_key_exists($field, $content['plugin_options']))
|
||||
{
|
||||
$content[$field] = $content['plugin_options'][$field];
|
||||
}
|
||||
}
|
||||
$preserv = $content;
|
||||
unset ($preserv['button']);
|
||||
|
||||
// No real conditions, but we share a template
|
||||
$content['no_conditions'] = true;
|
||||
|
||||
return $this->step_templates[$content['step']];
|
||||
}
|
||||
}
|
||||
}
|
17
infolog/templates/default/import.ical_conditions.xet
Normal file
17
infolog/templates/default/import.ical_conditions.xet
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="infolog.import.ical_conditions" template="" lang="" group="0" version="16.1">
|
||||
<vbox>
|
||||
<template id="importexport.wizard_basic_import_csv.conditions" disabled="@no_conditions"/>
|
||||
|
||||
<select-cat id="override_values[cat_id][value]" label="Category" empty_label="From file" options=",,,@application"/>
|
||||
</vbox>
|
||||
<styles>
|
||||
#importexport-wizardbox_delete_title {
|
||||
margin-top: 1em;
|
||||
}
|
||||
</styles>
|
||||
</template>
|
||||
</overlay>
|
Loading…
Reference in New Issue
Block a user