mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
Calendar: Add ability to choose target calendar when importing
This commit is contained in:
parent
8540977872
commit
8a43d88ffe
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
use EGroupware\Api\Framework;
|
||||
use EGroupware\Api\Link;
|
||||
|
||||
/**
|
||||
@ -49,22 +50,22 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
protected function init(importexport_definition $definition, importexport_import_csv $import_csv=NULL)
|
||||
{
|
||||
// fetch the addressbook bo
|
||||
$this->bo= new calendar_boupdate();
|
||||
$this->bo = new calendar_boupdate();
|
||||
|
||||
// Get the tracker for changes
|
||||
$this->tracking = new calendar_tracking();
|
||||
|
||||
// Used for participants
|
||||
$this->status_map = array_flip(array_map('lang',$this->bo->verbose_status));
|
||||
$this->status_map = array_flip(array_map('lang', $this->bo->verbose_status));
|
||||
$this->role_map = array_flip($this->bo->roles);
|
||||
|
||||
$this->lookups = array(
|
||||
'priority' => Array(
|
||||
'priority' => array(
|
||||
0 => lang('None'),
|
||||
1 => lang('Low'),
|
||||
2 => lang('Normal'),
|
||||
3 => lang('High')
|
||||
),
|
||||
),
|
||||
'recurrence' => $this->bo->recur_types
|
||||
);
|
||||
}
|
||||
@ -80,14 +81,30 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
*/
|
||||
public function import_record(importexport_iface_egw_record &$record, &$import_csv)
|
||||
{
|
||||
if (!is_a($record, calendar_egw_record::class)) throw new TypeError();
|
||||
if(!is_a($record, calendar_egw_record::class))
|
||||
{
|
||||
throw new TypeError();
|
||||
}
|
||||
// set eventOwner
|
||||
$options =& $this->definition->plugin_options;
|
||||
$options['owner'] = $options['owner'] ? $options['owner'] : $this->user;
|
||||
|
||||
// Check options & set target calendar
|
||||
// Make sure Owner from import dialog is not array
|
||||
if(is_array($options['owner']))
|
||||
{
|
||||
$options['owner'] = array_pop($options['owner']);
|
||||
}
|
||||
if($options['owner'] == '')
|
||||
{
|
||||
$options['owner_from_csv'] = true;
|
||||
}
|
||||
$options['owner'] = $options['owner'] ?? $this->user;
|
||||
|
||||
// Set owner, unless it's supposed to come from CSV file
|
||||
if($options['owner_from_csv']) {
|
||||
if(!is_numeric($record['owner'])) {
|
||||
if($options['owner_from_csv'])
|
||||
{
|
||||
if(!is_numeric($record->owner))
|
||||
{
|
||||
$this->errors[$import_csv->get_current_position()] = lang(
|
||||
'Invalid owner ID: %1. Might be a bad field translation. Used %2 instead.',
|
||||
$record->owner,
|
||||
@ -430,7 +447,36 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
*/
|
||||
protected function row_preview(importexport_iface_egw_record &$row_entry)
|
||||
{
|
||||
$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants),true));
|
||||
$row_entry->participants = implode('<br />', $this->bo->participants(array('participants' => $row_entry->participants), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return etemplate components for options.
|
||||
* @abstract We can't deal with etemplate objects here, as an uietemplate
|
||||
* objects itself are scipt orientated and not "dialog objects"
|
||||
*
|
||||
* @return array (
|
||||
* name => string,
|
||||
* content => array,
|
||||
* sel_options => array,
|
||||
* preserv => array,
|
||||
* )
|
||||
*/
|
||||
public function get_options_etpl(importexport_definition &$definition = null)
|
||||
{
|
||||
$owner = $definition->plugin_options['owner'] ?? $GLOBALS['egw_info']['user']['account_id'];
|
||||
// Make sure Owner from import dialog is not array
|
||||
if(is_array($owner))
|
||||
{
|
||||
$owner = array_pop($owner);
|
||||
}
|
||||
$options = array(
|
||||
'name' => 'calendar.import_csv',
|
||||
'content' => array(
|
||||
'owner' => $owner ? $owner : null
|
||||
)
|
||||
);
|
||||
return $options;
|
||||
}
|
||||
}
|
9
calendar/templates/default/import_csv.xet
Normal file
9
calendar/templates/default/import_csv.xet
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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"
|
||||
class="et2-label-fixed"></calendar-owner>
|
||||
<template id="importexport.import_dialog.csv"/>
|
||||
</template>
|
||||
</overlay>
|
@ -249,9 +249,13 @@ use EGroupware\Api\Etemplate;
|
||||
}
|
||||
|
||||
$data['message'] = $this->message;
|
||||
Framework::includeJS('.','importexport','importexport');
|
||||
Framework::includeJS('.', 'importexport', 'importexport');
|
||||
Framework::includeJS('.', 'app', $data['appname']);
|
||||
|
||||
if($_GET['appname']) $readonlys['appname'] = true;
|
||||
if($_GET['appname'])
|
||||
{
|
||||
$readonlys['appname'] = true;
|
||||
}
|
||||
|
||||
$template->exec('importexport.importexport_import_ui.import_dialog', $data, $sel_options, $readonlys, $preserve, 2);
|
||||
}
|
||||
|
@ -9,12 +9,13 @@
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<et2-description value="Delimiter"></et2-description>
|
||||
<et2-hbox cellpadding="0" cellspacing="0" noLang="1" >
|
||||
<et2-select id="delimiter" onchange="var _this = jQuery(this); var text = _this.parent().parent().find('input'); if(_this.val() =='other') {text.val('');text.show(); text.focus();} else {text.hide();}" noLang="1"></et2-select>
|
||||
<et2-textbox id="other_delimiter" maxlength="1" class="hide"></et2-textbox>
|
||||
</et2-hbox>
|
||||
</row>
|
||||
<et2-hbox cellpadding="0" cellspacing="0" noLang="1">
|
||||
<et2-select id="delimiter" label="Delimiter" class="et2-label-fixed"
|
||||
onchange="let text = widget.getParent().getWidgetById('other_delimiter'); if(widget.value =='other') {text.value ='';text.classList.remove('hide'); text.focus();} else {text.classList.add('hide');}"
|
||||
noLang="1"></et2-select>
|
||||
<et2-textbox id="other_delimiter" maxlength="1" class="hide"></et2-textbox>
|
||||
</et2-hbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user