Better fix to handle non-exact search matching

This commit is contained in:
Nathan Gray 2012-01-25 19:25:47 +00:00
parent 0482bfb898
commit 7c50df4d57
2 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -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 {