mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-25 08:09:02 +01:00
Improve human friendly value handling
This commit is contained in:
parent
927528e2ad
commit
cdf246b0dc
@ -22,6 +22,14 @@ class calendar_egw_record implements importexport_iface_egw_record
|
||||
private $record = array();
|
||||
private static $bo;
|
||||
|
||||
public static $types = array(
|
||||
'select-cat' => array('category'),
|
||||
'select-account'=> array('owner','creator', 'modifier'),
|
||||
'date-time' => array('modified', 'created','start','end','recur_date'),
|
||||
'select-bool' => array('public', 'non_blocking'),
|
||||
'select' => array('priority'),
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* reads record from backend if identifier is given.
|
||||
|
@ -48,13 +48,19 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
$export_object = new importexport_export_csv($_stream, (array)$options);
|
||||
$export_object->set_mapping($options['mapping']);
|
||||
$convert_fields = importexport_export_csv::$types;
|
||||
$convert_fields['select-account'][] = 'owner';
|
||||
$convert_fields['date-time'][] = 'start';
|
||||
$convert_fields['date-time'][] = 'end';
|
||||
$convert_fields = calendar_egw_record::$types;
|
||||
|
||||
$recurrence = $this->bo->recur_types;
|
||||
|
||||
$lookups = array(
|
||||
'priority' => Array(
|
||||
0 => '',
|
||||
1 => lang('Low'),
|
||||
2 => lang('Normal'),
|
||||
3 => lang('High')
|
||||
),
|
||||
);
|
||||
|
||||
// $options['selection'] is array of identifiers as this plugin doesn't
|
||||
// support other selectors atm.
|
||||
$record = new calendar_egw_record();
|
||||
@ -72,7 +78,7 @@ class calendar_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
// Standard stuff
|
||||
if($options['convert']) {
|
||||
importexport_export_csv::convert($record, $convert_fields, 'calendar');
|
||||
importexport_export_csv::convert($record, $convert_fields, 'calendar', $lookups);
|
||||
} else {
|
||||
// Implode arrays, so they don't say 'Array'
|
||||
foreach($record->get_record_array() as $key => $value) {
|
||||
|
@ -149,12 +149,24 @@ class calendar_import_csv implements importexport_iface_import_plugin {
|
||||
$status_map = array_flip($this->bo->verbose_status);
|
||||
$role_map = array_flip($this->bo->roles);
|
||||
|
||||
$lookups = array(
|
||||
'priority' => Array(
|
||||
0 => '',
|
||||
1 => lang('Low'),
|
||||
2 => lang('Normal'),
|
||||
3 => lang('High')
|
||||
),
|
||||
);
|
||||
|
||||
while ( $record = $import_csv->get_record() ) {
|
||||
$success = false;
|
||||
|
||||
// don't import empty records
|
||||
if( count( array_unique( $record ) ) < 2 ) continue;
|
||||
|
||||
// Automatic conversions
|
||||
importexport_import_csv::convert($record, calendar_egw_record::$types, 'calendar', $lookups);
|
||||
|
||||
// Set owner, unless it's supposed to come from CSV file
|
||||
if($_definition->plugin_options['owner_from_csv']) {
|
||||
if(!is_numeric($record['owner'])) {
|
||||
@ -169,9 +181,6 @@ class calendar_import_csv implements importexport_iface_import_plugin {
|
||||
$record['owner'] = $_definition->plugin_options['owner'];
|
||||
}
|
||||
|
||||
// Automatically handle text categories without explicit translation
|
||||
$record['cat_id'] = importexport_helper_functions::cat_name2id($record['cat_id']);
|
||||
|
||||
if ($record['participants'] && !is_array($record['participants'])) {
|
||||
// Importing participants in human friendly format
|
||||
preg_match_all('/(([^(]+?)( \(([0-9]+)\))? \((.+?)\) ([^,]+)),?/',$record['participants'],$participants);
|
||||
|
Loading…
Reference in New Issue
Block a user