Changeset 982e0b0 in github for program/include/rcube_contacts.php
- Timestamp:
- May 26, 2010 7:56:47 AM (3 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- d470f97
- Parents:
- e6e2db5
- File:
-
- 1 edited
-
program/include/rcube_contacts.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/include/rcube_contacts.php
r3b67e33 r982e0b0 29 29 { 30 30 // protected for backward compat. with some plugins 31 // deprecated: re-implement $this->get_table_name() instead 32 protected $db_name = ''; 33 protected $db_groups = ''; 34 protected $db_groupmembers = ''; 35 31 protected $db_name = 'contacts'; 32 protected $db_groups = 'contactgroups'; 33 protected $db_groupmembers = 'contactgroupmembers'; 34 36 35 private $db = null; 37 36 private $user_id = 0; … … 43 42 private $table_cols = array('name', 'email', 'firstname', 'surname', 'vcard'); 44 43 45 / ** public properties */44 // public properties 46 45 var $primary_key = 'contact_id'; 47 46 var $readonly = false; … … 62 61 { 63 62 $this->db = $dbconn; 64 $this->db_name = $this->get_table_name('contacts');65 $this->db_groups = $this->get_table_name('contactgroups');66 $this->db_groupmembers = $this->get_table_name('contactgroupmembers');67 68 63 $this->user_id = $user; 69 64 $this->ready = $this->db && !$this->db->is_error(); … … 134 129 135 130 $sql_result = $this->db->query( 136 "SELECT * FROM ". $this->db_groups.131 "SELECT * FROM ".get_table_name($this->db_groups). 137 132 " WHERE del<>1". 138 133 " AND user_id=?". … … 172 167 173 168 if ($this->group_id) 174 $join = " LEFT JOIN ". $this->db_groupmembers." AS m".169 $join = " LEFT JOIN ".get_table_name($this->db_groupmembers)." AS m". 175 170 " ON (m.contact_id = c.".$this->primary_key.")"; 176 171 177 172 $sql_result = $this->db->limitquery( 178 "SELECT * FROM ". $this->db_name." AS c" .173 "SELECT * FROM ".get_table_name($this->db_name)." AS c" . 179 174 $join . 180 175 " WHERE c.del<>1" . … … 289 284 { 290 285 if ($this->group_id) 291 $join = " LEFT JOIN ". $this->db_groupmembers." AS m".286 $join = " LEFT JOIN ".get_table_name($this->db_groupmembers)." AS m". 292 287 " ON (m.contact_id=c.".$this->primary_key.")"; 293 288 … … 295 290 $sql_result = $this->db->query( 296 291 "SELECT COUNT(c.contact_id) AS rows". 297 " FROM ". $this->db_name." AS c".292 " FROM ".get_table_name($this->db_name)." AS c". 298 293 $join. 299 294 " WHERE c.del<>1". … … 337 332 338 333 $this->db->query( 339 "SELECT * FROM ". $this->db_name.334 "SELECT * FROM ".get_table_name($this->db_name). 340 335 " WHERE contact_id=?". 341 336 " AND user_id=?". … … 381 376 if (!$existing->count && !empty($a_insert_cols)) { 382 377 $this->db->query( 383 "INSERT INTO ". $this->db_name.378 "INSERT INTO ".get_table_name($this->db_name). 384 379 " (user_id, changed, del, ".join(', ', $a_insert_cols).")". 385 380 " VALUES (".intval($this->user_id).", ".$this->db->now().", 0, ".join(', ', $a_insert_values).")" 386 381 ); 387 382 388 $insert_id = $this->db->insert_id($this-> get_sequence_name('contacts'));383 $insert_id = $this->db->insert_id($this->db_name); 389 384 } 390 385 … … 432 427 if (!empty($write_sql)) { 433 428 $this->db->query( 434 "UPDATE ". $this->db_name.429 "UPDATE ".get_table_name($this->db_name). 435 430 " SET changed=".$this->db->now().", ".join(', ', $write_sql). 436 431 " WHERE contact_id=?". … … 462 457 // flag record as deleted 463 458 $this->db->query( 464 "UPDATE ". $this->db_name.459 "UPDATE ".get_table_name($this->db_name). 465 460 " SET del=1, changed=".$this->db->now(). 466 461 " WHERE user_id=?". … … 480 475 function delete_all() 481 476 { 482 $this->db->query("DELETE FROM {$this->db_name} WHERE user_id=?", $this->user_id);477 $this->db->query("DELETE FROM ".get_table_name($this->db_name)." WHERE user_id = ?", $this->user_id); 483 478 $this->cache = null; 484 479 return $this->db->affected_rows(); … … 500 495 501 496 $this->db->query( 502 "INSERT INTO ". $this->db_groups.497 "INSERT INTO ".get_table_name($this->db_groups). 503 498 " (user_id, changed, name)". 504 499 " VALUES (".intval($this->user_id).", ".$this->db->now().", ".$this->db->quote($name).")" 505 500 ); 506 501 507 if ($insert_id = $this->db->insert_id($this-> get_sequence_name('contactgroups')))502 if ($insert_id = $this->db->insert_id($this->db_groups)) 508 503 $result = array('id' => $insert_id, 'name' => $name); 509 504 … … 522 517 // flag group record as deleted 523 518 $sql_result = $this->db->query( 524 "UPDATE ". $this->db_groups.519 "UPDATE ".get_table_name($this->db_groups). 525 520 " SET del=1, changed=".$this->db->now(). 526 521 " WHERE contactgroup_id=?", … … 547 542 548 543 $sql_result = $this->db->query( 549 "UPDATE ". $this->db_groups.544 "UPDATE ".get_table_name($this->db_groups). 550 545 " SET name=?, changed=".$this->db->now(). 551 546 " WHERE contactgroup_id=?", … … 573 568 foreach ($ids as $contact_id) { 574 569 $sql_result = $this->db->query( 575 "SELECT 1 FROM ". $this->db_groupmembers.570 "SELECT 1 FROM ".get_table_name($this->db_groupmembers). 576 571 " WHERE contactgroup_id=?". 577 572 " AND contact_id=?", … … 582 577 if (!$this->db->num_rows($sql_result)) { 583 578 $this->db->query( 584 "INSERT INTO ". $this->db_groupmembers.579 "INSERT INTO ".get_table_name($this->db_groupmembers). 585 580 " (contactgroup_id, contact_id, created)". 586 581 " VALUES (?, ?, ".$this->db->now().")", … … 613 608 614 609 $sql_result = $this->db->query( 615 "DELETE FROM ". $this->db_groupmembers.610 "DELETE FROM ".get_table_name($this->db_groupmembers). 616 611 " WHERE contactgroup_id=?". 617 612 " AND contact_id IN ($ids)", … … 636 631 do { 637 632 $sql_result = $this->db->query( 638 "SELECT 1 FROM ". $this->db_groups.633 "SELECT 1 FROM ".get_table_name($this->db_groups). 639 634 " WHERE del<>1". 640 635 " AND user_id=?". … … 651 646 } 652 647 653 654 /**655 * Wrapper for global get_table_name() which can be re-implemented656 * by a derived class657 */658 protected function get_table_name($table)659 {660 return get_table_name($table);661 }662 663 /**664 * Wrapper for global get_sequence_name() which can be re-implemented665 * by a derived class666 */667 protected function get_sequence_name($table)668 {669 return get_sequence_name($table);670 }671 672 648 }
Note: See TracChangeset
for help on using the changeset viewer.
