mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-24 17:04:14 +01:00
Import warning improvements:
- Only warn once about missing contact type - Do not try to check header if definition says there is no header
This commit is contained in:
parent
2be34b4b53
commit
1f46ac0516
@ -33,6 +33,11 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv {
|
||||
*/
|
||||
protected $tracking;
|
||||
|
||||
/**
|
||||
* @var boolean If import file has no type, it can generate a lot of warnings.
|
||||
* Users don't like this, so we only warn once.
|
||||
*/
|
||||
private $type_warned = false;
|
||||
|
||||
/**
|
||||
* imports entries according to given definition object.
|
||||
@ -56,7 +61,6 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv {
|
||||
$this->lookups['tid'][$tid] = $data['name'];
|
||||
}
|
||||
|
||||
|
||||
// set contact owner
|
||||
$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
|
||||
$_definition->plugin_options['contact_owner'] : $this->user;
|
||||
@ -122,7 +126,12 @@ class addressbook_import_contacts_csv extends importexport_basic_import_csv {
|
||||
// Do not import into non-existing type, warn and change
|
||||
if(!$record->tid || !$this->lookups['tid'][$record->tid])
|
||||
{
|
||||
$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n']));
|
||||
// Avoid lots of warnings about type (2 types are contact and deleted)
|
||||
if(!$this->type_warned || count($this->lookups['tid']) == 2 )
|
||||
{
|
||||
$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n']));
|
||||
$this->type_warned = true;
|
||||
}
|
||||
$record->tid = 'n';
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,6 @@ abstract class importexport_basic_import_csv implements importexport_iface_impor
|
||||
|
||||
// Set up HTML
|
||||
$rows['h1'] = $labels;
|
||||
error_log("Wow, ".count($this->preview_records) . ' preveiw records');
|
||||
foreach($this->preview_records as $i => $row_data)
|
||||
{
|
||||
// Convert to human-friendly
|
||||
|
@ -359,6 +359,9 @@
|
||||
// Only CSV files
|
||||
if(!$options['csv_fields']) return true;
|
||||
|
||||
// Can't check if definition has no header
|
||||
if($options['num_header_lines'] == 0) return true;
|
||||
|
||||
$preference = $GLOBALS['egw_info']['user']['preferences']['common']['csv_charset'];
|
||||
$charset = $options['charset'] == 'user' || !$options['charset'] ? $preference : $options['charset'];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user