diff options
author | alecpl <alec@alec.pl> | 2010-04-22 13:58:41 +0000 |
---|---|---|
committer | alecpl <alec@alec.pl> | 2010-04-22 13:58:41 +0000 |
commit | 821a560f19543424344f3d75ff1eacc8c27e7ce7 (patch) | |
tree | bf39fb7d61752f4e47d13d26db59317bf72b26cc | |
parent | b80a97adb0fe49d705acb5d8f12bf36f782ef068 (diff) |
- one improvement more
-rw-r--r-- | program/include/rcube_contacts.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php index cc610bcef..7014415ed 100644 --- a/program/include/rcube_contacts.php +++ b/program/include/rcube_contacts.php @@ -163,11 +163,12 @@ class rcube_contacts extends rcube_addressbook $length = $subset != 0 ? abs($subset) : $this->page_size; if ($this->group_id) - $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". + $join = " LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". " ON (m.contact_id = c.".$this->primary_key.")"; $sql_result = $this->db->limitquery( - "SELECT * FROM ".$this->db_name." AS c ".$join . + "SELECT * FROM ".$this->db_name." AS c" . + $join . " WHERE c.del<>1" . " AND c.user_id=?" . ($this->group_id ? " AND m.contactgroup_id=?" : ""). @@ -194,6 +195,8 @@ class rcube_contacts extends rcube_addressbook else if ($this->list_page <= 1) { if ($cnt < $this->page_size && $subset == 0) $this->result->count = $cnt; + else if (isset($this->cache['count'])) + $this->result->count = $this->cache['count']; else $this->result->count = $this->_count(); } @@ -263,14 +266,15 @@ class rcube_contacts extends rcube_addressbook private function _count() { if ($this->group_id) - $join = "LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". + $join = " LEFT JOIN ".get_table_name('contactgroupmembers')." AS m". " ON (m.contact_id=c.".$this->primary_key.")"; // count contacts for this user $sql_result = $this->db->query( "SELECT COUNT(c.contact_id) AS rows". - " FROM ".$this->db_name." AS c ".$join. - " WHERE c.del<>1". + " FROM ".$this->db_name." AS c". + $join. + " WHERE c.del<>1". " AND c.user_id=?". ($this->group_id ? " AND m.contactgroup_id=?" : ""). ($this->filter ? " AND (".$this->filter.")" : ""), |