3 commits - plugins/calendar plugins/kolab_addressbook plugins/kolab_auth plugins/libkolab

Thomas Brüderli bruederli at kolabsys.com
Tue Mar 3 17:05:34 CET 2015


 plugins/calendar/drivers/kolab/kolab_invitation_calendar.php |    7 +-
 plugins/kolab_addressbook/lib/rcube_kolab_contacts.php       |   20 +++---
 plugins/kolab_auth/kolab_auth_ldap.php                       |   36 ++---------
 plugins/libkolab/lib/kolab_format_xcal.php                   |    4 +
 4 files changed, 28 insertions(+), 39 deletions(-)

New commits:
commit ac96c929dd6650e18f664850dffe1e6f5a2b08da
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Mar 3 17:05:20 2015 +0100

    Improve contacts search by matching words against contact properties instead of the entire search string

diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 1b3ea01..c618b10 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -467,26 +467,26 @@ class rcube_kolab_contacts extends rcube_addressbook
             }
 
             $found = array();
+            $contents = '';
             foreach (preg_grep($regexp, array_keys($contact)) as $col) {
                 $pos     = strpos($col, ':');
                 $colname = $pos ? substr($col, 0, $pos) : $col;
-                $search  = $advanced ? $value[array_search($colname, $fields)] : $value;
 
                 foreach ((array)$contact[$col] as $val) {
-                    if ($this->compare_search_value($colname, $val, $search, $mode)) {
-                        if (!$advanced) {
-                            $this->filter['ids'][] = $id;
-                            break 2;
-                        }
-                        else {
-                            $found[$colname] = true;
-                        }
+                    if ($advanced) {
+                        $found[$colname] = $this->compare_search_value($colname, $val, $value[array_search($colname, $fields)], $mode);
+                    }
+                    else {
+                        $contents .= ' ' . join(' ', (array)$val);
                     }
                 }
             }
 
-            if (count($found) >= $scount) // && $advanced
+            // compare matches
+            if (($advanced && count($found) >= $scount) ||
+                (!$advanced && rcube_utils::words_match(mb_strtolower($contents), $value))) {
                 $this->filter['ids'][] = $id;
+            }
         }
 
         // dummy result with contacts count


commit ae2bd007329ada3384d995017dbf4afe1fa6de1f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Mar 3 15:54:33 2015 +0100

    Improve search for users with a word-based query (#4558)
    
    Attention! This requires the following change in Roundcube core:
    https://github.com/roundcube/roundcubemail/commit/83eeec6c

diff --git a/plugins/kolab_auth/kolab_auth_ldap.php b/plugins/kolab_auth/kolab_auth_ldap.php
index 26624a6..a585abd 100644
--- a/plugins/kolab_auth/kolab_auth_ldap.php
+++ b/plugins/kolab_auth/kolab_auth_ldap.php
@@ -210,7 +210,7 @@ class kolab_auth_ldap extends rcube_ldap_generic
     /**
      * Search records (simplified version of rcube_ldap::search)
      *
-     * @param mixed   $fields   The field name or array of field names to search in
+     * @param string  $fields   The field name or array of field names to search in
      * @param mixed   $value    Search value (or array of values when $fields is array)
      * @param int     $mode     Matching mode:
      *                          0 - partial (*abc*),
@@ -230,35 +230,15 @@ class kolab_auth_ldap extends rcube_ldap_generic
 
         $mode = intval($mode);
 
-        // use AND operator for advanced searches
-        $filter = is_array($value) ? '(&' : '(|';
-
-        // set wildcards
-        $wp = $ws = '';
-        if (!empty($this->config['fuzzy_search']) && $mode != 1) {
-            $ws = '*';
-            if (!$mode) {
-                $wp = '*';
-            }
+        // compose a full-text-search-like filter
+        if (is_array($fields) && (count($fields) > 1 || $mode != 1)) {
+            $filter = self::fulltext_search_filter($value, $fields, $mode);
         }
-
-        foreach ((array)$fields as $idx => $field) {
-            $val   = is_array($value) ? $value[$idx] : $value;
-            $attrs = (array) $this->fieldmap[$field];
-
-            if (empty($attrs)) {
-                $filter .= "($field=$wp" . rcube_ldap_generic::quote_string($val) . "$ws)";
-            }
-            else {
-                if (count($attrs) > 1)
-                    $filter .= '(|';
-                foreach ($attrs as $f)
-                    $filter .= "($f=$wp" . rcube_ldap_generic::quote_string($val) . "$ws)";
-                if (count($attrs) > 1)
-                    $filter .= ')';
-            }
+        // direct search
+        else {
+            $field = is_array($fields) ? $fields[0] : strval($fields);
+            $filter = "($field=" . self::quote_string($value) . ")";
         }
-        $filter .= ')';
 
         // add required (non empty) fields filter
         $req_filter = '';


commit 03dd4b60b3ed9581aba811589d795bd7fd58dc7d
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Mar 2 12:32:40 2015 +0100

    Exclude cancelled events from count query on invitations calendar

diff --git a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
index 0ffdee5..d63a77d 100644
--- a/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_invitation_calendar.php
@@ -284,6 +284,11 @@ class kolab_invitation_calendar
       }
     }
 
+    $filter = array(
+      array('tags','!=','x-status:cancelled'),
+      array($subquery, 'OR')
+    );
+
     // aggregate counts from all calendar folders
     $count = 0;
     foreach (kolab_storage::list_folders('', '*', 'event', null) as $foldername) {
@@ -291,7 +296,7 @@ class kolab_invitation_calendar
       if ($cal->get_namespace() == 'other')
         continue;
 
-      $count += $cal->count_events($start, $end, array(array($subquery, 'OR')));
+      $count += $cal->count_events($start, $end, $filter);
     }
 
     return $count;
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index 605d557..8c63b26 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -635,6 +635,10 @@ abstract class kolab_format_xcal extends kolab_format
             }
         }
 
+        if (!empty($object['status'])) {
+          $tags[] = 'x-status:' . strtolower($object['status']);
+        }
+
         return array_unique($tags);
     }
 




More information about the commits mailing list