From 5933d98c8cdee9ef4b04eaf680a7d29cb4928cfc Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 10 May 2010 07:20:52 -0400
Subject: [PATCH] - it_IT update (#1486724)

---
 program/include/rcube_contacts.php |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/program/include/rcube_contacts.php b/program/include/rcube_contacts.php
index cc610bc..c756ada 100644
--- a/program/include/rcube_contacts.php
+++ b/program/include/rcube_contacts.php
@@ -27,8 +27,10 @@
  */
 class rcube_contacts extends rcube_addressbook
 {
+    // protected for backward compat. with some plugins
+    // maybe changed in the future
+    protected $db_name = '';
     private $db = null;
-    private $db_name = '';
     private $user_id = 0;
     private $filter = null;
     private $result = null;
@@ -122,7 +124,7 @@
         if (!$this->groups)
             return $results;
 
-        $sql_filter = $search ? "AND " . $this->db->ilike('name', '%'.$search.'%') : '';
+        $sql_filter = $search ? " AND " . $this->db->ilike('name', '%'.$search.'%') : '';
 
         $sql_result = $this->db->query(
             "SELECT * FROM ".get_table_name('contactgroups').
@@ -163,11 +165,12 @@
         $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 +197,8 @@
         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();
         }
@@ -221,7 +226,7 @@
         foreach ($fields as $col) {
             if ($col == 'ID' || $col == $this->primary_key) {
                 $ids         = !is_array($value) ? explode(',', $value) : $value;
-                $ids         = join(',', array_map(array($this->db, 'quote'), $ids));
+                $ids         = $this->db->array2list($ids, 'integer');
                 $add_where[] = 'c.' . $this->primary_key.' IN ('.$ids.')';
             }
             else if ($strict)
@@ -263,14 +268,15 @@
     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.")" : ""),
@@ -431,7 +437,7 @@
         if (!is_array($ids))
             $ids = explode(',', $ids);
 
-        $ids = join(',', array_map(array($this->db, 'quote'), $ids));
+        $ids = $this->db->array2list($ids, 'integer');
 
         // flag record as deleted
         $this->db->query(
@@ -583,8 +589,8 @@
         if (!is_array($ids))
             $ids = explode(',', $ids);
 
-        $ids = join(',', array_map(array($this->db, 'quote'), $ids));
-    
+        $ids = $this->db->array2list($ids, 'integer');
+
         $sql_result = $this->db->query(
             "DELETE FROM ".get_table_name('contactgroupmembers').
             " WHERE contactgroup_id=?".

--
Gitblit v1.9.1