Branch 'dev/kolab3' - 3 commits - plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Tue May 15 19:08:23 CEST 2012
plugins/libkolab/lib/kolab_format.php | 20 ++++++++++++++++++++
plugins/libkolab/lib/kolab_format_contact.php | 21 ++++++++++++++++++++-
plugins/libkolab/lib/kolab_storage_cache.php | 13 +++++++++----
3 files changed, 49 insertions(+), 5 deletions(-)
New commits:
commit dadf00f1a646bb3a5142d14b2365788477d3d4bf
Merge: e602722 d08cb11
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue May 15 19:08:16 2012 +0200
Merge branch 'dev/kolab3' of ssh://git.kolabsys.com/git/roundcube into dev/kolab3
commit e602722064cb28a0f1e7ea42aa009581d924adad
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue May 15 19:08:01 2012 +0200
Save object words for fulltext searching in caching table
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 9f9431c..a9e688b 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -200,8 +200,8 @@ class kolab_storage_cache
$result = $this->db->query(
"INSERT INTO kolab_cache ".
- " (resource, type, msguid, uid, data, xml, dtstart, dtend)".
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
+ " (resource, type, msguid, uid, data, xml, dtstart, dtend, tags, words)".
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
$this->resource_uri,
$objtype,
$msguid,
@@ -209,7 +209,9 @@ class kolab_storage_cache
$sql_data['data'],
$sql_data['xml'],
$sql_data['dtstart'],
- $sql_data['dtend']
+ $sql_data['dtend'],
+ $sql_data['tags'],
+ $sql_data['words']
);
if (!$this->db->affected_rows($result)) {
@@ -426,8 +428,11 @@ class kolab_storage_cache
}
}
- if ($object['_formatobj'])
+ if ($object['_formatobj']) {
$sql_data['xml'] = (string)$object['_formatobj']->write();
+ $sql_data['tags'] = join(' ', $object['_formatobj']->get_tags());
+ $sql_data['words'] = join(' ', $object['_formatobj']->get_words());
+ }
// extract object data
$data = array();
commit ab69f4909165d20fcf09cb1d361370a26c6ad987
Author: Thomas Bruederli <thomas at roundcube.net>
Date: Tue May 15 19:05:46 2012 +0200
Prepare for fulltext indexing in kolab_storage_cache; fix saving contacts with no address data (#769)
diff --git a/plugins/libkolab/lib/kolab_format.php b/plugins/libkolab/lib/kolab_format.php
index 134df85..4c8e363 100644
--- a/plugins/libkolab/lib/kolab_format.php
+++ b/plugins/libkolab/lib/kolab_format.php
@@ -232,4 +232,24 @@ abstract class kolab_format
* @param array Hash array with object properties (produced by Horde Kolab_Format classes)
*/
abstract public function fromkolab2($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()
+ {
+ return array();
+ }
+
+ /**
+ * 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()
+ {
+ return array();
+ }
}
diff --git a/plugins/libkolab/lib/kolab_format_contact.php b/plugins/libkolab/lib/kolab_format_contact.php
index 59a6e0a..646f6ca 100644
--- a/plugins/libkolab/lib/kolab_format_contact.php
+++ b/plugins/libkolab/lib/kolab_format_contact.php
@@ -26,6 +26,8 @@ class kolab_format_contact extends kolab_format
{
public $CTYPE = 'application/vcard+xml';
+ public static $fulltext_cols = array('name', 'firstname', 'surname', 'middlename', 'email');
+
public $phonetypes = array(
'home' => Telephone::Home,
'work' => Telephone::Work,
@@ -207,7 +209,7 @@ class kolab_format_contact extends kolab_format
// addresses
$adrs = new vectoraddress;
- foreach ($object['address'] as $address) {
+ foreach ((array)$object['address'] as $address) {
$adr = new Address;
$type = $this->addresstypes[$address['type']];
if (isset($type))
@@ -417,6 +419,23 @@ class kolab_format_contact extends kolab_format
}
/**
+ * 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 $col) {
+ $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
*
* @param array Hash array with object properties
More information about the commits
mailing list