Add ability to choose target calendar & addressbook when importing ical/vcard

This commit is contained in:
nathan 2023-01-19 15:48:35 -07:00
parent 802a312839
commit 48008f4e96
6 changed files with 48 additions and 53 deletions

View File

@ -352,16 +352,21 @@ class addressbook_import_vcard implements importexport_iface_import_plugin {
*/
public function get_options_etpl(importexport_definition &$definition=null)
{
$contacts = new EGroupware\Api\Contacts();
$charset = $definition->plugin_options['charset'];
if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
return array(
'name' => 'addressbook.import_vcard',
'content' => array(
'file_type' => 'vcard,ical,vcf',
'charset' => $charset
'charset' => $charset,
'contact_owner' => $definition->plugin_options['contact_owner'] == 'personal' ?
$GLOBALS['egw_info']['user']['account_id'] :
$definition->plugin_options['contact_owner']
),
'sel_options' => array(
'charset' => Api\Translation::get_installed_charsets()
'charset' => Api\Translation::get_installed_charsets(),
'contact_owner' => $contacts->get_addressbooks(Api\Acl::ADD)
),
'preserv' => array()
);

View File

@ -2,20 +2,14 @@
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
<overlay>
<template id="addressbook.import_vcard" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column width="180px"/>
</columns>
<rows>
<row>
<et2-description value="Charset of file"></et2-description>
<et2-select class="width180" id="charset" noLang="1"></et2-select>
</row>
</rows>
</grid>
<et2-vbox>
<et2-select id="contact_owner" label="Import into" class="et2-label-fixed"></et2-select>
<et2-select class="et2-label-fixed" id="charset" noLang="1" label="Charset of file"></et2-select>
</et2-vbox>
<styles>
.width180 select { width:150px;}
.et2-label-fixed {
--label-width: 180px;
}
</styles>
</template>
</overlay>

View File

@ -142,6 +142,10 @@ class calendar_import_ical implements importexport_iface_import_plugin {
// Set owner, if not set will be null (current user)
$owner = $plugin_options['cal_owner'];
if(is_array($owner))
{
$owner = array_pop($owner);
}
// Purge
if($plugin_options['empty_before_import'])
@ -295,10 +299,11 @@ class calendar_import_ical implements importexport_iface_import_plugin {
public function get_options_etpl(importexport_definition &$definition=null)
{
return array(
'name' => 'addressbook.import_vcard',
'name' => 'calendar.import_ical',
'content' => array(
'file_type' => 'ical',
'charset' => $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset']
'charset' => $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'],
'cal_owner' => $definition->plugin_options['cal_owner'] ?? $GLOBALS['egw_info']['user']['account_id']
),
'sel_options' => array(
'charset' => Api\Translation::get_installed_charsets()

View File

@ -307,6 +307,7 @@ how much entries to skip calendar en How much entries to skip?
html link to the current record calendar en HTML link to the current record
ical calendar en iCal
ical / rfc2445 calendar en iCal / rfc2445
iCal cannot change the owner of an existing event. This applies to new events only. calendar en iCal cannot change the owner of an existing event. This applies to new events only.
ical export calendar en iCal export
ical file calendar en iCal file
ical import calendar en iCal import

View File

@ -2,7 +2,7 @@
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
<overlay>
<template id="calendar.import_csv" template="" lang="" group="0" version="1.9.001">
<calendar-owner id="owner" label="Import into" emptyLabel="From file" multiple="false"
<calendar-owner id="cal_owner" label="Import into" emptyLabel="From file" multiple="false"
class="et2-label-fixed"></calendar-owner>
<template id="importexport.import_dialog.csv"/>
</template>

View File

@ -2,20 +2,10 @@
<!DOCTYPE overlay PUBLIC "-//EGroupware GmbH//eTemplate 2.0//EN" "https://www.egroupware.org/etemplate2.0.dtd">
<overlay>
<template id="calendar.import_ical" template="" lang="" group="0" version="1.9.001">
<grid>
<columns>
<column/>
<column width="180px"/>
</columns>
<rows>
<row>
<et2-description value="Charset of file"></et2-description>
<et2-select class="width180" id="charset" noLang="1"></et2-select>
</row>
</rows>
</grid>
<styles>
.width180 select { width:150px;}
</styles>
<et2-select class="et2-label-fixed" id="charset" noLang="1" label="Charset of file"></et2-select>
<calendar-owner id="cal_owner" label="Import into" emptyLabel="From file" multiple="false"
class="et2-label-fixed"
helpText="iCal cannot change the owner of an existing event. This applies to new events only.">
</calendar-owner>
</template>
</overlay>