Changeset 566b142 in github for program/include/rcube_contacts.php
- Timestamp:
- Apr 22, 2010 8:56:24 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 356a797b
- Parents:
- 3e696da
- File:
-
- 1 edited
-
program/include/rcube_contacts.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_contacts.php
r3e696da r566b142 35 35 private $search_fields; 36 36 private $search_string; 37 private $cache; 37 38 private $table_cols = array('name', 'email', 'firstname', 'surname', 'vcard'); 38 39 … … 70 71 { 71 72 $this->filter = $filter; 73 $this->cache = null; 72 74 } 73 75 … … 91 93 { 92 94 $this->group_id = $gid; 95 $this->cache = null; 93 96 } 94 97 … … 103 106 $this->search_fields = null; 104 107 $this->search_string = null; 108 $this->cache = null; 105 109 } 106 110 … … 166 170 "SELECT * FROM ".$this->db_name." AS c ".$join . 167 171 " WHERE c.del<>1" . 168 " AND c.user_id=?" .169 ($this->group_id ? " AND m.contactgroup_id=?" : "").170 ($this->filter ? " AND (".$this->filter.")" : "") .172 " AND c.user_id=?" . 173 ($this->group_id ? " AND m.contactgroup_id=?" : ""). 174 ($this->filter ? " AND (".$this->filter.")" : "") . 171 175 " ORDER BY c.name", 172 176 $start_row, … … 213 217 if (!is_array($fields)) 214 218 $fields = array($fields); 215 219 216 220 $add_where = array(); 217 221 foreach ($fields as $col) { 218 222 if ($col == 'ID' || $col == $this->primary_key) { 219 223 $ids = !is_array($value) ? explode(',', $value) : $value; 220 $add_where[] = 'c.' . $this->primary_key.' IN ('.join(',', $ids).')'; 224 $ids = join(',', array_map(array($this->db, 'quote'), $ids)); 225 $add_where[] = 'c.' . $this->primary_key.' IN ('.$ids.')'; 221 226 } 222 227 else if ($strict) … … 245 250 function count() 246 251 { 247 return new rcube_result_set($this->_count(), ($this->list_page-1) * $this->page_size); 252 $count = isset($this->cache['count']) ? $this->cache['count'] : $this->_count(); 253 254 return new rcube_result_set($count, ($this->list_page-1) * $this->page_size); 248 255 } 249 256 … … 273 280 274 281 $sql_arr = $this->db->fetch_assoc($sql_result); 275 return (int) $sql_arr['rows']; 282 283 $this->cache['count'] = (int) $sql_arr['rows']; 284 285 return $this->cache['count']; 276 286 } 277 287 … … 357 367 $this->add_to_group($this->group_id, $insert_id); 358 368 369 $this->cache = null; 370 359 371 return $insert_id; 360 372 } … … 417 429 function delete($ids) 418 430 { 419 if ( is_array($ids))420 $ids = join(',', $ids);431 if (!is_array($ids)) 432 $ids = explode(',', $ids); 421 433 422 434 $ids = join(',', array_map(array($this->db, 'quote'), $ids)); … … 431 443 ); 432 444 445 $this->cache = null; 446 433 447 return $this->db->affected_rows(); 434 448 } … … 441 455 { 442 456 $this->db->query("DELETE FROM {$this->db_name} WHERE user_id=?", $this->user_id); 457 $this->cache = null; 443 458 return $this->db->affected_rows(); 444 459 } … … 486 501 $gid 487 502 ); 503 504 $this->cache = null; 488 505 489 506 return $this->db->affected_rows();
Note: See TracChangeset
for help on using the changeset viewer.
