Infolog: When importing into info_contact or info_from, try to find & link the contact

This commit is contained in:
nathangray 2020-12-01 11:14:15 -07:00
parent c0fc66d51f
commit c3ae524ed6

View File

@ -260,10 +260,12 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin
$record['info_contact'] = $record['info_link_id']; $record['info_contact'] = $record['info_link_id'];
unset($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 contact or from is set and not an ID, find it. Use quotes for exact match.
if($record['info_contact'] && !is_numeric($record['info_contact'])) foreach(['info_from','info_contact'] as $field)
{ {
$contacts = Link::query('addressbook','"'.$record['info_contact'].'"'); if ($record[$field] && is_string($record[$field]))
{
$contacts = Link::query('addressbook', '"' . $record[$field] . '"');
if ($contacts) if ($contacts)
{ {
$record['info_contact'] = array( $record['info_contact'] = array(
@ -272,6 +274,7 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin
); );
} }
} }
}
// Special values // Special values
if ($record['addressbook'] && !is_numeric($record['addressbook'])) if ($record['addressbook'] && !is_numeric($record['addressbook']))
{ {