plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Fri Jun 8 13:16:29 CEST 2012
plugins/libkolab/lib/kolab_format_event.php | 30 ---------------------------
plugins/libkolab/lib/kolab_format_task.php | 20 ++++++++++++++++++
plugins/libkolab/lib/kolab_format_xcal.php | 30 +++++++++++++++++++++++++++
plugins/libkolab/lib/kolab_storage_cache.php | 5 ++--
4 files changed, 53 insertions(+), 32 deletions(-)
New commits:
commit 2ad9e2e1ba3328b45a1ec259616b4d54ce1355a2
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Fri Jun 8 13:15:10 2012 +0200
- Small refactoring: build words index in common kolab_format_xcal class
- Define tags to be cached with task objects
- Allow to query cache with NOT LIKE (!~) queries
diff --git a/plugins/libkolab/lib/kolab_format_event.php b/plugins/libkolab/lib/kolab_format_event.php
index 6af8f0d..c48b63d 100644
--- a/plugins/libkolab/lib/kolab_format_event.php
+++ b/plugins/libkolab/lib/kolab_format_event.php
@@ -27,8 +27,6 @@ class kolab_format_event extends kolab_format_xcal
protected $read_func = 'kolabformat::readEvent';
protected $write_func = 'kolabformat::writeEvent';
- public static $fulltext_cols = array('title', 'description', 'location', 'attendees:name', 'attendees:email');
-
private $kolab2_rolemap = array(
'required' => 'REQ-PARTICIPANT',
'optional' => 'OPT-PARTICIPANT',
@@ -182,34 +180,6 @@ class kolab_format_event extends kolab_format_xcal
}
/**
- * Callback for kolab_storage_cache to get words to index for fulltext search
- *
- * @return array List of words to save in cache
- */
- public function get_words()
- {
- $data = '';
- foreach (self::$fulltext_cols as $colname) {
- list($col, $field) = explode(':', $colname);
-
- if ($field) {
- $a = array();
- foreach ((array)$this->data[$col] as $attr)
- $a[] = $attr[$field];
- $val = join(' ', $a);
- }
- else {
- $val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col];
- }
-
- if (strlen($val))
- $data .= $val . ' ';
- }
-
- return array_unique(rcube_utils::normalize_string($data, true));
- }
-
- /**
* Load data from old Kolab2 format
*/
public function fromkolab2($rec)
diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index d7bb275..477f1b2 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -123,4 +123,24 @@ class kolab_format_task extends kolab_format_xcal
$this->data = $object;
}
+ /**
+ * Callback for kolab_storage_cache to get object specific tags to cache
+ *
+ * @return array List of tags to save in cache
+ */
+ public function get_tags()
+ {
+ $tags = array();
+
+ if ($this->data['status'] == 'COMPLETED' || $this->data['complete'] == 100)
+ $tags[] = 'complete';
+
+ if ($this->data['priority'] == 1)
+ $tags[] = 'flagged';
+
+ if (!empty($this->data['alarms']))
+ $tags[] = 'x-has-alarms';
+
+ return $tags;
+ }
}
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index 19d2921..db2ad3a 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -28,6 +28,8 @@ abstract class kolab_format_xcal extends kolab_format
{
public $CTYPE = 'application/calendar+xml';
+ public static $fulltext_cols = array('title', 'description', 'location', 'attendees:name', 'attendees:email');
+
protected $sensitivity_map = array(
'public' => kolabformat::ClassPublic,
'private' => kolabformat::ClassPrivate,
@@ -358,4 +360,32 @@ abstract class kolab_format_xcal extends kolab_format
$this->obj->setAlarms($valarms);
}
+ /**
+ * Callback for kolab_storage_cache to get words to index for fulltext search
+ *
+ * @return array List of words to save in cache
+ */
+ public function get_words()
+ {
+ $data = '';
+ foreach (self::$fulltext_cols as $colname) {
+ list($col, $field) = explode(':', $colname);
+
+ if ($field) {
+ $a = array();
+ foreach ((array)$this->data[$col] as $attr)
+ $a[] = $attr[$field];
+ $val = join(' ', $a);
+ }
+ else {
+ $val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col];
+ }
+
+ if (strlen($val))
+ $data .= $val . ' ';
+ }
+
+ return array_unique(rcube_utils::normalize_string($data, true));
+ }
+
}
\ No newline at end of file
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index d1ec64e..9d4b37e 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -383,8 +383,9 @@ class kolab_storage_cache
$qvalue = '(' . join(',', array_map(array($this->db, 'quote'), $param[2])) . ')';
$param[1] = 'IN';
}
- else if ($param[1] == '~' || $param[1] == 'LIKE') {
- $param[1] = 'LIKE';
+ else if ($param[1] == '~' || $param[1] == 'LIKE' || $param[1] == '!~' || $param[1] == '!LIKE') {
+ $not = ($param[1] == '!~' || $param[1] == '!LIKE') ? 'NOT ' : '';
+ $param[1] = $not . 'LIKE';
$qvalue = $this->db->quote('%'.preg_replace('/(^\^|\$$)/', ' ', $param[2]).'%');
}
else if ($param[0] == 'tags') {
More information about the commits
mailing list