mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:38 +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;
|
||||
|
||||
/**
|
||||
@ -59,7 +60,7 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
$this->role_map = array_flip($this->bo->roles);
|
||||
|
||||
$this->lookups = array(
|
||||
'priority' => Array(
|
||||
'priority' => array(
|
||||
0 => lang('None'),
|
||||
1 => lang('Low'),
|
||||
2 => lang('Normal'),
|
||||
@ -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,
|
||||
@ -433,4 +450,33 @@ class calendar_import_csv extends importexport_basic_import_csv {
|
||||
$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>
|
@ -250,8 +250,12 @@ use EGroupware\Api\Etemplate;
|
||||
|
||||
$data['message'] = $this->message;
|
||||
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,9 +9,10 @@
|
||||
</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-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>
|
||||
|
Loading…
Reference in New Issue
Block a user