[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squirrelmail-cvs
Subject:    [SM-CVS] SF.net SVN: squirrelmail:[14241]
From:       pdontthink () users ! sourceforge ! net
Date:       2011-12-28 2:58:30
Message-ID: E1Rfjio-0002Jn-56 () sfp-svn-2 ! v30 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 14241
          http://squirrelmail.svn.sourceforge.net/squirrelmail/?rev=14241&view=rev
Author:   pdontthink
Date:     2011-12-28 02:58:29 +0000 (Wed, 28 Dec 2011)
Log Message:
-----------
Unify address book searches.  See ChangeLog comments.  Also, fixed bug wherein file \
backend wasn't escaping regular expression correctly and bug where LDAP backend was \
allowing multiple * in a row.  File based backend used to search all fields at once, \
concatenated by spaces, which 'worked', but is misleading and nothing like the other \
backends.

Modified Paths:
--------------
    branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog
    branches/SM-1_4-STABLE/squirrelmail/functions/abook_database.php
    branches/SM-1_4-STABLE/squirrelmail/functions/abook_ldap_server.php
    branches/SM-1_4-STABLE/squirrelmail/functions/abook_local_file.php

Modified: branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog	2011-12-21 13:27:54 UTC (rev \
                14240)
+++ branches/SM-1_4-STABLE/squirrelmail/doc/ChangeLog	2011-12-28 02:58:29 UTC (rev \
14241) @@ -19,6 +19,11 @@
   - Fixed issue with Noselect mailboxes being clickable in folder list
   - Made performance improvements in mailbox listing
   - Attachment filename extensions changed from ".msg" to ".eml"
+  - Unified address book searches somewhat: file-backed address books now
+    search in each field individually; database-backed address books now
+    search in fields other than first/last name (nickname, email); LDAP-
+    backed address books now search in common name fields as well as by
+    email address (cn, sn, givenname, mail)
 
 Version 1.4.22 - 12 July 2011
 -----------------------------

Modified: branches/SM-1_4-STABLE/squirrelmail/functions/abook_database.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/abook_database.php	2011-12-21 \
                13:27:54 UTC (rev 14240)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/abook_database.php	2011-12-28 \
02:58:29 UTC (rev 14241) @@ -247,8 +247,12 @@
         $escape = 'ESCAPE \'' . $this->dbh->quoteString('\\') . '\'';
 
         $query = sprintf("SELECT * FROM %s WHERE owner='%s' AND " .
-                         "(LOWER(firstname) LIKE '%s' %s OR LOWER(lastname) LIKE \
                '%s' %s)",
-                         $this->table, $this->owner, $expr, $escape, $expr, \
$escape); +                         "(LOWER(firstname) LIKE '%s' %s " .
+                         "OR LOWER(lastname) LIKE '%s' %s " .
+                         "OR LOWER(email) LIKE '%s' %s " .
+                         "OR LOWER(nickname) LIKE '%s' %s)",
+                         $this->table, $this->owner, $expr, $escape, $expr, $escape,
+                                                     $expr, $escape, $expr, \
$escape);  $res = $this->dbh->query($query);
 
         if (DB::isError($res)) {

Modified: branches/SM-1_4-STABLE/squirrelmail/functions/abook_ldap_server.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/abook_ldap_server.php	2011-12-21 \
                13:27:54 UTC (rev 14240)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/abook_ldap_server.php	2011-12-28 \
02:58:29 UTC (rev 14241) @@ -272,7 +272,8 @@
             /* Undo sanitizing of * symbol */
             $expr = str_replace('\2a','*',$expr);
         }
-        $expression = "cn=$expr";
+        $expr = preg_replace('/\*+/', '*', $expr); // LDAP chokes on more than one *
+        $expression = "(|(cn=$expr)(sn=$expr)(givenname=$expr)(mail=$expr))";
 
         /* Make sure connection is there */
         if(!$this->open()) {

Modified: branches/SM-1_4-STABLE/squirrelmail/functions/abook_local_file.php
===================================================================
--- branches/SM-1_4-STABLE/squirrelmail/functions/abook_local_file.php	2011-12-21 \
                13:27:54 UTC (rev 14240)
+++ branches/SM-1_4-STABLE/squirrelmail/functions/abook_local_file.php	2011-12-28 \
02:58:29 UTC (rev 14241) @@ -276,10 +276,9 @@
         if ($expr=='*' && ! $this->listing)
             return array();
 
-        /* Make regexp from glob'ed expression
-         * May want to quote other special characters like (, ), -, [, ], etc. */
-        $expr = str_replace('?', '.', $expr);
-        $expr = str_replace('*', '.*', $expr);
+        // Make regexp from glob'ed expression
+        $expr = preg_quote($expr);
+        $expr = str_replace(array('\\?', '\\*'), array('.', '.*'), $expr);
 
         $res = array();
         if(!$this->open()) {
@@ -294,9 +293,11 @@
                 error_box(_("Address book is corrupted. Required fields are \
missing."),$color);  die('</body></html>');
             } else {
-                $line = join(' ', $row);
                 // errors on preg_match call are suppressed in order to prevent \
                display of regexp compilation errors
-                if(@preg_match('/' . $expr . '/i', $line)) {
+                if (@preg_match('/' . $expr . '/i', $row[0])    // nickname
+                 || @preg_match('/' . $expr . '/i', $row[1])    // firstname
+                 || @preg_match('/' . $expr . '/i', $row[2])    // lastname
+                 || @preg_match('/' . $expr . '/i', $row[3])) { // email
                     array_push($res, array('nickname'  => $row[0],
                                            'name'      => $row[1] . ' ' . $row[2],
                                            'firstname' => $row[1],

This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
-----
squirrelmail-cvs mailing list
List address: squirrelmail-cvs@lists.sourceforge.net
List info (subscribe/unsubscribe/change options): \
                https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
Repository: http://squirrelmail.org/svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic