From 7c50df4d579a3aecefde529fad2d4da3f4c9877e Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 25 Jan 2012 19:25:47 +0000 Subject: [PATCH] Better fix to handle non-exact search matching --- admin/inc/class.admin_import_groups_csv.inc.php | 5 +++++ admin/inc/class.admin_import_users_csv.inc.php | 14 ++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/admin/inc/class.admin_import_groups_csv.inc.php b/admin/inc/class.admin_import_groups_csv.inc.php index afed1f6891..d1dde20118 100644 --- a/admin/inc/class.admin_import_groups_csv.inc.php +++ b/admin/inc/class.admin_import_groups_csv.inc.php @@ -134,6 +134,11 @@ class admin_import_groups_csv implements importexport_iface_import_plugin { 'query_type' => $condition['string'] )); } + // Search looks in the given field, but doesn't do an exact match + foreach ( (array)$accounts as $key => $account ) + { + if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); + } if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { $account = current($accounts); // apply action to all contacts matching this exists condition diff --git a/admin/inc/class.admin_import_users_csv.inc.php b/admin/inc/class.admin_import_users_csv.inc.php index 7c3d911031..10fcce3563 100644 --- a/admin/inc/class.admin_import_users_csv.inc.php +++ b/admin/inc/class.admin_import_users_csv.inc.php @@ -152,18 +152,16 @@ class admin_import_users_csv implements importexport_iface_import_plugin { 'query_type' => $condition['string'] )); } + // Search looks in the given field, but doesn't do an exact match + foreach ( (array)$accounts as $key => $account ) + { + if($account[$condition['string']] != $record[$condition['string']]) unset($accounts[$key]); + } if ( is_array( $accounts ) && count( $accounts ) >= 1 ) { // apply action to all contacts matching this exists condition $action = $condition['true']; foreach ( (array)$accounts as $account ) { - if($account[$condition['string']] == $record[$condition['string']]) { - $record['account_id'] = $account['account_id']; - } - else - { - // It didn't match after all - $action = $condition['false']; - } + $record['account_id'] = $account['account_id']; $success = $this->action( $action['action'], $record, $import_csv->get_current_position() ); } } else {