From f21a04c024e57d2396c6a8ab78b055de098217ee Mon Sep 17 00:00:00 2001 From: alecpl Date: Thu, 10 Nov 2011 07:57:56 +0000 Subject: - Add option to define matching method for addressbook search (#1486564, #1487907) --- program/steps/mail/addcontact.inc | 6 +++--- program/steps/mail/autocomplete.inc | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'program/steps/mail') diff --git a/program/steps/mail/addcontact.inc b/program/steps/mail/addcontact.inc index dafb2763c..a4feb7b58 100644 --- a/program/steps/mail/addcontact.inc +++ b/program/steps/mail/addcontact.inc @@ -50,7 +50,7 @@ if (!empty($_POST['_address']) && is_object($CONTACTS)) $OUTPUT->show_message('errorsavingcontact', 'error'); $OUTPUT->send(); } - + $email = rcube_idn_to_ascii($contact['email']); if (!check_email($email, false)) { $OUTPUT->show_message('emailformaterror', 'error', array('email' => $contact['email'])); @@ -65,13 +65,13 @@ if (!empty($_POST['_address']) && is_object($CONTACTS)) $error = $CONTACTS->get_error(); // TODO: show dialog to complete record // if ($error['type'] == rcube_addressbook::ERROR_VALIDATE) { } - + $OUTPUT->show_message($error['message'] ? $error['message'] : 'errorsavingcontact', 'error'); $OUTPUT->send(); } // check for existing contacts - $existing = $CONTACTS->search('email', $contact['email'], true, false); + $existing = $CONTACTS->search('email', $contact['email'], 1, false); if ($done = $existing->count) $OUTPUT->show_message('contactexists', 'warning'); diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc index 8b13f574d..c2df0b79c 100644 --- a/program/steps/mail/autocomplete.inc +++ b/program/steps/mail/autocomplete.inc @@ -41,6 +41,7 @@ if ($RCMAIL->action == 'group-expand') { $MAXNUM = (int)$RCMAIL->config->get('autocomplete_max', 15); +$mode = (int) $RCMAIL->config->get('addressbook_search_mode'); $search = get_input_value('_search', RCUBE_INPUT_GPC, true); $source = get_input_value('_source', RCUBE_INPUT_GPC); $sid = get_input_value('_id', RCUBE_INPUT_GPC); @@ -58,7 +59,7 @@ if (!empty($book_types) && strlen($search)) { $abook = $RCMAIL->get_address_book($id); $abook->set_pagesize($MAXNUM); - if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) { + if ($result = $abook->search(array('email','name'), $search, $mode, true, true, 'email')) { while ($sql_arr = $result->iterate()) { // Contact can have more than one e-mail address $email_arr = (array)$abook->get_col_values('email', $sql_arr, true); @@ -82,7 +83,7 @@ if (!empty($book_types) && strlen($search)) { } // also list matching contact groups - if ($abook->groups) { + if ($abook->groups && count($contacts) < $MAXNUM) { foreach ($abook->list_groups($search) as $group) { $abook->reset(); $abook->set_group($group['ID']); -- cgit v1.2.3