mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
- Move around field types into egw_record class
- Add Infolog ID field to importexport - Fix import condition matching
This commit is contained in:
parent
02d8b86d7e
commit
f192583f58
@ -22,6 +22,15 @@ class infolog_egw_record implements importexport_iface_egw_record
|
||||
private $record = array();
|
||||
private $bo;
|
||||
|
||||
// Used in conversions
|
||||
static $types = array(
|
||||
'select-account' => array('info_owner','info_responsible','modifier'),
|
||||
'date-time' => array('info_datecompleted', 'info_datemodified','created','last_event','next_event'),
|
||||
'date' => array('info_startdate', 'info_enddate'),
|
||||
'select-cat' => array('info_cat', 'cat_id'),
|
||||
'links' => array('info_link_id'),
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor
|
||||
* reads record from backend if identifier is given.
|
||||
|
@ -16,14 +16,6 @@
|
||||
*/
|
||||
class infolog_export_csv implements importexport_iface_export_plugin {
|
||||
|
||||
// Used in conversions
|
||||
static $types = array(
|
||||
'select-account' => array('info_owner','info_responsible','modifier'),
|
||||
'date-time' => array('info_datecompleted', 'info_datemodified','created','last_event','next_event'),
|
||||
'date' => array('info_startdate', 'info_enddate'),
|
||||
'select-cat' => array('info_cat', 'cat_id'),
|
||||
'links' => array('info_link_id'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Exports records as defined in $_definition
|
||||
@ -66,7 +58,7 @@ class infolog_export_csv implements importexport_iface_export_plugin {
|
||||
}
|
||||
// Some conversion
|
||||
if($options['convert']) {
|
||||
importexport_export_csv::convert($record, self::$types, 'infolog');
|
||||
importexport_export_csv::convert($record, infolog_egw_record::$types, 'infolog');
|
||||
$this->convert($record);
|
||||
} else {
|
||||
// Implode arrays, so they don't say 'Array'
|
||||
|
@ -138,8 +138,14 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
||||
}
|
||||
|
||||
// set Owner
|
||||
$_definition->plugin_options['record_owner'] = isset( $_definition->plugin_options['record_owner'] ) ?
|
||||
$_definition->plugin_options['record_owner'] = $_definition->plugin_options['record_owner'] ?
|
||||
$_definition->plugin_options['record_owner'] : $this->user;
|
||||
$_definition->plugin_options['record_owner'] = $this->user;
|
||||
|
||||
$_lookups = array(
|
||||
'info_type' => $this->boinfolog->enums['types'],
|
||||
'info_status' => $this->boinfolog->status['task']
|
||||
);
|
||||
|
||||
// Start counting successes
|
||||
$count = 0;
|
||||
@ -154,6 +160,13 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
||||
// don't import empty records
|
||||
if( count( array_unique( $record ) ) < 2 ) continue;
|
||||
|
||||
$lookups = $_lookups;
|
||||
if($record['info_type'] && $this->boinfolog->status[$record['info_type']]) {
|
||||
$lookups['info_status'] = $this->boinfolog->status[$record['info_type']];
|
||||
}
|
||||
|
||||
importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups);
|
||||
|
||||
// Set owner, unless it's supposed to come from CSV file
|
||||
if($_definition->plugin_options['owner_from_csv']) {
|
||||
if(!is_numeric($record['info_owner'])) {
|
||||
@ -168,9 +181,6 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
||||
$record['info_owner'] = $_definition->plugin_options['record_owner'];
|
||||
}
|
||||
|
||||
// Automatically handle text categories without explicit translation
|
||||
$record['cat_id'] = importexport_helper_functions::cat_name2id($record['cat_id']);
|
||||
|
||||
// Special values
|
||||
if ($record['addressbook'] && !is_numeric($record['addressbook']))
|
||||
{
|
||||
@ -189,13 +199,8 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
||||
// exists
|
||||
case 'exists' :
|
||||
if($record[$condition['string']]) {
|
||||
$results = $this->boinfolog->search(
|
||||
//array( $condition['string'] => $record[$condition['string']],),
|
||||
'',
|
||||
$_definition->plugin_options['update_cats'] == 'add' ? false : true,
|
||||
'', '', '', false, 'AND', false,
|
||||
array( $condition['string'] => $record[$condition['string']],)
|
||||
);
|
||||
$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
|
||||
$results = $this->boinfolog->search($query);
|
||||
}
|
||||
|
||||
if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
|
||||
@ -246,7 +251,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
|
||||
return true;
|
||||
case 'update' :
|
||||
// Only update if there are changes
|
||||
$old = $this->boinfolog->read($_data['id']);
|
||||
$old = $this->boinfolog->read($_data['info_id']);
|
||||
|
||||
if(!$this->definition->plugin_options['change_owner']) {
|
||||
// Don't change addressbook of an existing contact
|
||||
|
@ -79,7 +79,7 @@ class infolog_merge extends bo_merge
|
||||
$info = array();
|
||||
|
||||
// Convert to human friendly values
|
||||
$types = infolog_export_csv::$types;
|
||||
$types = infolog_egw_record::$types;
|
||||
$_selects = $this->bo->enums + array('status' => $this->bo->status[$record->info_type]);
|
||||
foreach($_selects as $name => $value)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ class infolog_wizard_export_csv extends importexport_wizard_basic_export_csv
|
||||
|
||||
// Field mapping
|
||||
$bo = new infolog_tracking();
|
||||
$this->export_fields = $bo->field2label;
|
||||
$this->export_fields = array('info_id' => 'Infolog ID') + $bo->field2label;
|
||||
|
||||
// Custom fields
|
||||
unset($this->export_fields['custom']); // Heading, not a real field
|
||||
|
@ -27,7 +27,7 @@ class infolog_wizard_import_infologs_csv extends importexport_wizard_basic_impor
|
||||
|
||||
// Field mapping
|
||||
$tracking = new infolog_tracking();
|
||||
$this->mapping_fields = $tracking->field2label + infolog_import_infologs_csv::$special_fields;
|
||||
$this->mapping_fields = array('info_id' => 'Infolog ID') + $tracking->field2label + infolog_import_infologs_csv::$special_fields;
|
||||
// List each custom field
|
||||
unset($this->mapping_fields['custom']);
|
||||
$custom = config::get_customfields('infolog');
|
||||
|
Loading…
Reference in New Issue
Block a user