From c3ae524ed65070d65eb3307abae9934c15dc6c58 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 1 Dec 2020 11:14:15 -0700 Subject: [PATCH] Infolog: When importing into info_contact or info_from, try to find & link the contact --- .../class.infolog_import_infologs_csv.inc.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/infolog/inc/class.infolog_import_infologs_csv.inc.php b/infolog/inc/class.infolog_import_infologs_csv.inc.php index 7466c77035..8d35078517 100644 --- a/infolog/inc/class.infolog_import_infologs_csv.inc.php +++ b/infolog/inc/class.infolog_import_infologs_csv.inc.php @@ -260,16 +260,19 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin $record['info_contact'] = $record['info_link_id']; unset($record['info_link_id']); } - // If contact is set and not an ID, find it. Use quotes for exact match. - if($record['info_contact'] && !is_numeric($record['info_contact'])) + // If contact or from is set and not an ID, find it. Use quotes for exact match. + foreach(['info_from','info_contact'] as $field) { - $contacts = Link::query('addressbook','"'.$record['info_contact'].'"'); - if($contacts) + if ($record[$field] && is_string($record[$field])) { - $record['info_contact'] = array( - 'id' => array_key_first($contacts), - 'app' => 'addressbook' - ); + $contacts = Link::query('addressbook', '"' . $record[$field] . '"'); + if ($contacts) + { + $record['info_contact'] = array( + 'id' => array_key_first($contacts), + 'app' => 'addressbook' + ); + } } } // Special values