Fixes around contact_id, addressbook backend has issues with importing a record with a contact_id in it, it only works for matching for updates.

This commit is contained in:
Nathan Gray 2010-03-01 23:08:50 +00:00
parent a7d4af0ab1
commit b390965803
2 changed files with 8 additions and 1 deletions

View File

@ -147,6 +147,8 @@ class import_contacts_csv implements iface_import_plugin {
// don't import empty contacts // don't import empty contacts
if( count( array_unique( $record ) ) < 2 ) continue; if( count( array_unique( $record ) ) < 2 ) continue;
$record['owner'] = $_definition->plugin_options['contact_owner'];
if ( $_definition->plugin_options['conditions'] ) { if ( $_definition->plugin_options['conditions'] ) {
foreach ( $_definition->plugin_options['conditions'] as $condition ) { foreach ( $_definition->plugin_options['conditions'] as $condition ) {
switch ( $condition['type'] ) { switch ( $condition['type'] ) {
@ -214,6 +216,10 @@ class import_contacts_csv implements iface_import_plugin {
} }
// Fall through // Fall through
case 'insert' : case 'insert' :
if($_action == 'insert') {
// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
unset($_data['id']);
}
if ( $this->dry_run ) { if ( $this->dry_run ) {
print_r($_data); print_r($_data);
return true; return true;

View File

@ -189,8 +189,9 @@ class wizzard_import_contacts_csv extends import_contacts_csv
foreach($bocontacts->customfields as $name => $data) { foreach($bocontacts->customfields as $name => $data) {
$contact_fields['#'.$name] = $data['label']; $contact_fields['#'.$name] = $data['label'];
} }
unset($addr_names['jpegphoto']); // can't cvs import that unset($contact_fields['jpegphoto']); // can't cvs import that
$sel_options['field_mapping'] = array('' => lang('none')) + $contact_fields; $sel_options['field_mapping'] = array('' => lang('none')) + $contact_fields;
$content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import');
$preserv = $content; $preserv = $content;
unset ($preserv['button']); unset ($preserv['button']);
return 'addressbook.importexport_wizzard_fieldmaping'; return 'addressbook.importexport_wizzard_fieldmaping';