- Improve owner parsing

- Change error message when owner can't be determined.  Most users don't use translations, so just fallback to plugin setting.
This commit is contained in:
Nathan Gray 2011-03-15 16:20:11 +00:00
parent f3536a72bf
commit ca00d4c69a
2 changed files with 14 additions and 11 deletions

View File

@ -150,18 +150,21 @@ class addressbook_import_contacts_csv implements importexport_iface_import_plugi
// don't import empty contacts
if( count( array_unique( $record ) ) < 2 ) continue;
// Automatically handle text owner without explicit translation
$record['owner'] = importexport_helper_functions::account_name2id($record['owner']);
// Set owner, unless it's supposed to come from CSV file
if($_definition->plugin_options['owner_from_csv']) {
if(!is_numeric($record['owner'])) {
$this->errors[$import_csv->get_current_position()] = lang(
'Invalid addressbook ID: %1. Might be a bad field translation. Used %2 instead.',
$record['owner'],
$_definition->plugin_options['contact_owner']
);
$record['owner'] = $_definition->plugin_options['contact_owner'];
if($record['owner'] && !is_numeric($record['owner'])) {
// Automatically handle text owner without explicit translation
$new_owner = importexport_helper_functions::account_name2id($record['owner']);
if($new_owner == '') {
$this->errors[$import_csv->get_current_position()] = lang(
'Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.',
$record['owner'],
common::grab_owner_name($_definition->plugin_options['contact_owner'])
);
$record['owner'] = $_definition->plugin_options['contact_owner'];
} else {
$record['owner'] = $new_owner;
}
}
} else {
$record['owner'] = $_definition->plugin_options['contact_owner'];

View File

@ -270,7 +270,6 @@ insert in document addressbook en Insert in document
insufficent rights to delete this list! addressbook en Insufficent rights to delete this list!
international addressbook en International
internet addressbook en Internet
invalid addressbook id: %1. might be a bad field translation. used %2 instead. addressbook en Invalid addressbook ID: %1. Might be a bad field translation. Used %2 instead.
label addressbook en Label
last date addressbook en Last date
last modified addressbook en last modified
@ -419,6 +418,7 @@ translation addressbook en Translation
two of: %1 addressbook en two of: %1
type addressbook en Type
un-delete addressbook en Un-delete
unable to convert "%1" to account id. using plugin setting (%2) for owner. addressbook en Unable to convert "%1" to account ID. Using plugin setting (%2) for owner.
unique id (uid) addressbook en Unique ID (UID)
unique id<br />(to update existing records) addressbook en Unique ID<br />(to update existing records)
update a single entry by passing the fields. addressbook en Update a single entry by passing the fields.