Branch 'dev/kolab3' - plugins/kolab_addressbook plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed May 16 10:50:15 CEST 2012
plugins/kolab_addressbook/lib/rcube_kolab_contacts.php | 11 ++++++++---
plugins/libkolab/lib/kolab_storage_cache.php | 12 ++++++++++--
2 files changed, 18 insertions(+), 5 deletions(-)
New commits:
commit c3cfc084a7309bd63c38f90b37fed95ffc71132b
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed May 16 10:49:53 2012 +0200
Improve fetching contacts with new kolab_storage/cache backend
diff --git a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
index 5b7fd8d..5702a0c 100644
--- a/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
+++ b/plugins/kolab_addressbook/lib/rcube_kolab_contacts.php
@@ -246,13 +246,12 @@ class rcube_kolab_contacts extends rcube_addressbook
*/
public function list_records($cols=null, $subset=0)
{
- $this->result = $this->count();
+ $this->result = new rcube_result_set(0, ($this->list_page-1) * $this->page_size);;
// list member of the selected group
if ($this->gid) {
$this->_fetch_groups();
$seen = array();
- $this->result->count = 0;
foreach ((array)$this->distlists[$this->gid]['member'] as $member) {
// skip member that don't match the search filter
if (is_array($this->filter['ids']) && array_search($member['ID'], $this->filter['ids']) === false)
@@ -269,9 +268,15 @@ class rcube_kolab_contacts extends rcube_addressbook
}
$ids = array_keys($seen);
}
+ else if (is_array($this->filter['ids'])) {
+ $ids = $this->filter['ids'];
+ if ($this->result->count = count($ids))
+ $this->_fetch_contacts(array(array('uid', '=', $ids)));
+ }
else {
$this->_fetch_contacts();
- $ids = is_array($this->filter['ids']) ? $this->filter['ids'] : array_keys($this->contacts);
+ $ids = array_keys($this->contacts);
+ $this->result->count = count($ids);
}
// sort data arrays according to desired list sorting
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index afe4dc1..4c822f6 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -326,7 +326,7 @@ class kolab_storage_cache
/**
* Get number of objects mathing the given query
*
- * @param string $type Object type (e.g. contact, event, todo, journal, note, configuration)
+ * @param array $query Pseudo-SQL query as list of filter parameter triplets
* @return integer The number of objects of the given type
*/
public function count($query = array())
@@ -363,10 +363,18 @@ class kolab_storage_cache
{
$sql_where = '';
foreach ($query as $param) {
+ if ($param[1] == '=' && is_array($param[2])) {
+ $qvalue = '(' . join(',', array_map(array($this->db, 'quote'), $param[2])) . ')';
+ $param[1] = 'IN';
+ }
+ else {
+ $qvalue = $this->db->quote($param[2]);
+ }
+
$sql_where .= sprintf(' AND %s %s %s',
$this->db->quote_identifier($param[0]),
$param[1],
- $this->db->quote($param[2])
+ $qvalue
);
}
More information about the commits
mailing list