From f85e08b942dacfba777cdb64ca14add2f7843f7e Mon Sep 17 00:00:00 2001 From: nathangray Date: Fri, 27 Nov 2020 10:50:28 -0700 Subject: [PATCH] Infolog: When importing into info_contact, try to find & link the contact --- .../class.infolog_import_infologs_csv.inc.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/infolog/inc/class.infolog_import_infologs_csv.inc.php b/infolog/inc/class.infolog_import_infologs_csv.inc.php index 2bee3c767b..7466c77035 100644 --- a/infolog/inc/class.infolog_import_infologs_csv.inc.php +++ b/infolog/inc/class.infolog_import_infologs_csv.inc.php @@ -253,6 +253,25 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin // Responsible has to be an array $record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0; + // Don't let them import into info_link_id unless it's a number + if($record['info_link_id'] && !is_numeric($record['info_link_id'])) + { + // But try to search for it as a contact + $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'])) + { + $contacts = Link::query('addressbook','"'.$record['info_contact'].'"'); + if($contacts) + { + $record['info_contact'] = array( + 'id' => array_key_first($contacts), + 'app' => 'addressbook' + ); + } + } // Special values if ($record['addressbook'] && !is_numeric($record['addressbook'])) {