summaryrefslogtreecommitdiff
path: root/plugins/libkolab/lib/kolab_storage_cache_contact.php
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-02-10 10:46:50 (GMT)
committerThomas Bruederli <thomas@roundcube.net>2014-02-10 10:46:50 (GMT)
commitaf6d366a1f8c7761aaabd53c6ab80f4b6a75face (patch)
tree4027d4e9d75ab02075563f36375fc7de69ecb915 /plugins/libkolab/lib/kolab_storage_cache_contact.php
parentacbd45001c60186bebc2b8ad02ee99857f1215a0 (diff)
downloadroundcubemail-plugins-kolab-af6d366a1f8c7761aaabd53c6ab80f4b6a75face.tar.gz
Optimize access to kolab contacts using a sorted and limited query (#2828)
- Add columns for sorting in kolab_cache_contact - Extend bin/modcache.sh script to update existing cache records - Add setters for ORDER BY and LIMIT clauses - Adapt the kolab_addressbook plugin to fetch contacts page-wise ATTENTION: This changeset contains database schema changes! Run `bin/updatedb.sh --dir plugins/libkolab/SQL --package libkolab` Afterwards, the cached data needs to be updated. To do so, either run `plugins/libkolab/bin/modcache.sh update --type=contact` or execute the following query DELETE FROM `kolab_folders` WHERE `type`='contact';
Diffstat (limited to 'plugins/libkolab/lib/kolab_storage_cache_contact.php')
-rw-r--r--plugins/libkolab/lib/kolab_storage_cache_contact.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/plugins/libkolab/lib/kolab_storage_cache_contact.php b/plugins/libkolab/lib/kolab_storage_cache_contact.php
index e17923d..fde27bc 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_contact.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_contact.php
@@ -23,7 +23,7 @@
class kolab_storage_cache_contact extends kolab_storage_cache
{
- protected $extra_cols = array('type');
+ protected $extra_cols = array('type','name','firstname','surname','email');
protected $binary_items = array(
'photo' => '|<photo><uri>[^;]+;base64,([^<]+)</uri></photo>|i',
'pgppublickey' => '|<key><uri>date:application/pgp-keys;base64,([^<]+)</uri></key>|i',
@@ -40,6 +40,16 @@ class kolab_storage_cache_contact extends kolab_storage_cache
$sql_data = parent::_serialize($object);
$sql_data['type'] = $object['_type'];
+ // columns for sorting
+ $sql_data['name'] = $object['name'] . $object['prefix'];
+ $sql_data['firstname'] = $object['firstname'] . $object['middlename'] . $object['surname'];
+ $sql_data['surname'] = $object['surname'] . $object['firstname'] . $object['middlename'];
+ $sql_data['email'] = is_array($object['email']) ? $object['email'][0] : $object['email'];
+
+ if (is_array($sql_data['email'])) {
+ $sql_data['email'] = $sql_data['email']['address'];
+ }
+
return $sql_data;
}
} \ No newline at end of file