This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
*/
class contacts extends db
{
function contacts()
{
$this->db();
}
function search($user_id, $query)
{
$sql = "SELECT * FROM contacts WHERE user_id='$user_id' AND name LIKE '".smart_addslashes($query)."'";
$this->query($sql);
return $this->num_rows();
}
function get_contacts($user_id, $sort = "name", $direction = "ASC")
{
$this->query("SELECT * FROM contacts WHERE user_id='$user_id' ORDER BY ".$sort." ".$direction);
return $this->num_rows();
}
function get_contacts_with_group($user_id)
{
$this->query("SELECT contacts.*, contact_groups.name AS group_name FROM contacts LEFT JOIN contact_groups ON (contacts.group_id=contact_groups.id) WHERE contacts.user_id='$user_id'");
return $this->num_rows();
}
function get_contacts_group($user_id, $group_id, $sort = "name", $direction = "ASC")
{
$this->query("SELECT * FROM contacts WHERE group_id='$group_id' AND user_id='$user_id' ORDER BY ".$sort." ".$direction);
return $this->num_rows();
}
function get_contact($contact_id)
{
$this->query("SELECT * FROM contacts WHERE id='$contact_id'");