From b3909658030399222d6a803b144c9232220fb262 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 1 Mar 2010 23:08:50 +0000 Subject: [PATCH] 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. --- addressbook/importexport/class.import_contacts_csv.inc.php | 6 ++++++ .../importexport/class.wizzard_import_contacts_csv.inc.php | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addressbook/importexport/class.import_contacts_csv.inc.php b/addressbook/importexport/class.import_contacts_csv.inc.php index cf8e07555b..8467353bb1 100644 --- a/addressbook/importexport/class.import_contacts_csv.inc.php +++ b/addressbook/importexport/class.import_contacts_csv.inc.php @@ -147,6 +147,8 @@ class import_contacts_csv implements iface_import_plugin { // don't import empty contacts if( count( array_unique( $record ) ) < 2 ) continue; + $record['owner'] = $_definition->plugin_options['contact_owner']; + if ( $_definition->plugin_options['conditions'] ) { foreach ( $_definition->plugin_options['conditions'] as $condition ) { switch ( $condition['type'] ) { @@ -214,6 +216,10 @@ class import_contacts_csv implements iface_import_plugin { } // Fall through 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 ) { print_r($_data); return true; diff --git a/addressbook/importexport/class.wizzard_import_contacts_csv.inc.php b/addressbook/importexport/class.wizzard_import_contacts_csv.inc.php index ad57704b8d..dcca85cf42 100644 --- a/addressbook/importexport/class.wizzard_import_contacts_csv.inc.php +++ b/addressbook/importexport/class.wizzard_import_contacts_csv.inc.php @@ -189,8 +189,9 @@ class wizzard_import_contacts_csv extends import_contacts_csv foreach($bocontacts->customfields as $name => $data) { $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; + $content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import'); $preserv = $content; unset ($preserv['button']); return 'addressbook.importexport_wizzard_fieldmaping';