From 84ea251b592ea1d31779e8af0f2a80eac6524150 Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 6 Feb 2018 13:07:50 -0700 Subject: [PATCH] * Import/Export - Better matching on accounts to handle prefixes & suffixes --- ...class.importexport_helper_functions.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/importexport/inc/class.importexport_helper_functions.inc.php b/importexport/inc/class.importexport_helper_functions.inc.php index 492b93b257..fcb59f58a6 100755 --- a/importexport/inc/class.importexport_helper_functions.inc.php +++ b/importexport/inc/class.importexport_helper_functions.inc.php @@ -157,11 +157,19 @@ class importexport_helper_functions { // Handle users listed as Lastname, Firstname instead of login ID // Do this first, in case their first name matches a username - if ( $account_lids[$key+1][0] == ' ' && $account_id = $GLOBALS['egw']->accounts->name2id( trim($account_lids[$key+1]).' ' .$account_lid, 'account_fullname')) { - $account_ids[] = $account_id; - unset($account_lids[$key]); - $skip = true; // Skip the next one, it's the first name - continue ; + if ( $account_lids[$key+1][0] == ' ') + { + $query = array('type' => 'accounts', 'query_type' => 'exact'); + $given = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lids[$key+1]))); + $family = $GLOBALS['egw']->accounts->search($query + array('query' => trim($account_lid))); + $ids = array_intersect_key($family, $given); + if($ids) + { + $account_ids[] = key($ids); + unset($account_lids[$key]); + $skip = true; // Skip the next one, it's the first name + continue ; + } } // Deal with groups listed as Group, remove the Group