| program/include/rcube_contacts.php |
| |
| This file is part of the RoundCube Webmail client |
- | Copyright (C) 2006-2008, RoundCube Dev. - Switzerland |
+ | Copyright (C) 2006-2009, RoundCube Dev. - Switzerland |
| Licensed under the GNU GPL |
| |
| PURPOSE: |
*
* @package Addressbook
*/
-class rcube_contacts
+class rcube_contacts extends rcube_addressbook
{
var $db = null;
var $db_name = '';
var $result = null;
var $search_fields;
var $search_string;
- var $table_cols = array('name', 'email', 'firstname', 'surname');
+ var $table_cols = array('name', 'email', 'firstname', 'surname', 'vcard');
/** public properties */
var $primary_key = 'contact_id';
$this->ready = $this->db && !$this->db->is_error();
}
- /**
- * PHP 4 object constructor
- *
- * @see rcube_contacts::__construct()
- */
- function rcube_contacts($dbconn, $user)
- {
- $this->__construct($dbconn, $user);
- }
-
-
- /**
- * Set internal list page
- *
- * @param number Page number to list
- * @access public
- */
- function set_page($page)
- {
- $this->list_page = (int)$page;
- }
-
-
- /**
- * Set internal page size
- *
- * @param number Number of messages to display on one page
- * @access public
- */
- function set_pagesize($size)
- {
- $this->page_size = (int)$size;
- }
-
/**
* Save a search string for future listings
}
- /**
- * Close connection to source
- * Called on script shutdown
- */
- function close(){}
-
-
/**
* List the current set of contact records
*
{
if ($col == 'ID' || $col == $this->primary_key)
{
- $ids = !is_array($value) ? split(',', $value) : $value;
- $add_where[] = $this->primary_key." IN (".join(',', $ids).")";
+ $ids = !is_array($value) ? explode(',', $value) : $value;
+ $add_where[] = $this->primary_key.' IN ('.join(',', $ids).')';
}
else if ($strict)
- $add_where[] = $this->db->quoteIdentifier($col)."=".$this->db->quote($value);
+ $add_where[] = $this->db->quoteIdentifier($col).'='.$this->db->quote($value);
else
- $add_where[] = $this->db->quoteIdentifier($col)." LIKE ".$this->db->quote(strlen($value)>2 ? "%$value%" : "$value%");
+ $add_where[] = $this->db->ilike($col, '%'.$value.'%');
}
if (!empty($add_where))
*
* @return Result array or NULL if nothing selected yet
*/
- function get_result($as_res=true)
+ function get_result()
{
return $this->result;
}
$a_insert_cols[] = $this->db->quoteIdentifier($col);
$a_insert_values[] = $this->db->quote($save_data[$col]);
}
-
+
if (!$existing->count && !empty($a_insert_cols))
{
$this->db->query(
"INSERT INTO ".$this->db_name."
(user_id, changed, del, ".join(', ', $a_insert_cols).")
- VALUES (?, ".$this->db->now().", 0, ".join(', ', $a_insert_values).")",
- $this->user_id);
+ VALUES (".intval($this->user_id).", ".$this->db->now().", 0, ".join(', ', $a_insert_values).")"
+ );
- $insert_id = $this->db->insert_id(get_sequence_name('contacts'));
+ $insert_id = $this->db->insert_id('contacts');
}
-
+
return $insert_id;
}