From 111a6fc31457e0efa8276e58aeb7632a64a32cbf Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 31 Mar 2011 02:07:15 -0400
Subject: [PATCH] - Add info about indexcontacts.sh script in upgrade procedure

---
 program/steps/mail/autocomplete.inc |    9 ++++++++-
 UPGRADING                           |   14 ++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/UPGRADING b/UPGRADING
index f203643..88e9c53 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -3,12 +3,13 @@
 
 Follow these instructions if upgrading from a previous version
 of Roundcube Webmail. We recommend to carefully backup the existing
-installation as well as the database before executig the following steps.
+installation as well as the database before going through the following steps.
 
 Using the update script
 -----------------------
 There is a shell script (for unix based systems) that does the job for you.
-To use it, unpack the archive of the new Roundcube version to a temporary location (don't replace the Roundcube installation you want to update)
+To use it, unpack the archive of the new Roundcube version to a temporary location
+(don't replace the Roundcube installation you want to update)
 and cd into that directory. From there, run the following command in a shell:
 
   ./bin/installto.sh <TARGET-FOLDER>
@@ -18,11 +19,12 @@
 target location and check and update the configuration and database schema.
 After all is done, the temporary folder with the new Roundcube files can be 
 removed again.
+See Post-Upgrade Activities section.
 
 
 Updating manually
 -----------------
-If you don't have shell access to the Roundcube instalaltion or if not running 
+If you don't have shell access to the Roundcube installation or if not running 
 it on a unix system, you need to do the following operations by hand:
 
 1. Replace index.php and all files in
@@ -39,6 +41,10 @@
 3. Let the update script/installer check your configuration and
    update your config files and database schema as suggested by the updater.
 4. Make sure 'enable_installer' is set to false again.
-5. Check .htaccess settings (some php settings could become required)
+5. See Post-Upgrade Activities section.
 
 
+Post-Upgrade Activities
+-----------------------
+1. Check .htaccess settings (some php settings could become required)
+2. If you're using build-in addressbook, run indexing script /bin/indexcontacts.sh.
diff --git a/program/steps/mail/autocomplete.inc b/program/steps/mail/autocomplete.inc
index 36542ca..85f3cf3 100644
--- a/program/steps/mail/autocomplete.inc
+++ b/program/steps/mail/autocomplete.inc
@@ -47,8 +47,15 @@
 
     if ($result = $abook->search(array('email','name'), $search, false, true, true, 'email')) {
       while ($sql_arr = $result->iterate()) {
-        foreach ((array)$abook->get_col_values('email', $sql_arr, true) as $email) {
+        // Contact can have more than one e-mail address
+        $email_arr = (array)$abook->get_col_values('email', $sql_arr, true);
+        $email_cnt = count($email_arr);
+        foreach ($email_arr as $email) {
           $contact = format_email_recipient($email, $sql_arr['name']);
+          // skip entries that don't match
+          if ($email_cnt > 1 && strpos($contact, $search) === false) {
+            continue;
+          }
           // when we've got more than one book, we need to skip duplicates
           if ($books_num == 1 || !in_array($contact, $contacts)) {
             $contacts[] = $contact;

--
Gitblit v1.9.1