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:
Nathan Gray 2015-03-02 18:38:37 +00:00
parent 20c7fee595
commit 6d39bb4802
3 changed files with 14 additions and 3 deletions

View File

@ -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;
@ -121,8 +125,13 @@ 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])
{
// 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';
}

View File

@ -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

View File

@ -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'];