From 786bffc4c5c6533d05e8262773d0fd7f67cf1518 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Fri, 26 Jan 2001 04:30:02 +0000 Subject: [PATCH] Add read_single_entry --- phpgwapi/inc/class.contacts.inc.php | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/phpgwapi/inc/class.contacts.inc.php b/phpgwapi/inc/class.contacts.inc.php index 54268f06a7..b0f873d45a 100644 --- a/phpgwapi/inc/class.contacts.inc.php +++ b/phpgwapi/inc/class.contacts.inc.php @@ -61,6 +61,42 @@ return array($ab_fields,$ab_fieldnames,$extra_fields); } + function read_single_entry($id,$fields) + { + list($ab_fields,$ab_fieldnames,$extra_fields) = $this->split_ab_and_extras($fields); + if (count($ab_fieldnames)) { + $t_fields = ",ab_" . implode(",ab_",$ab_fieldnames); + if ($t_fields == ",ab_") { + unset($t_fields); + } + } + + $this->db2 = $this->db; + + $this->db->query("select ab_id,ab_owner,ab_access $t_fields from addressbook WHERE ab_id='$id'"); + $this->db->next_record(); + + $return_fields[0]["id"] = $this->db->f("ab_id"); + $return_fields[0]["owner"] = $this->db->f("ab_owner"); + $return_fields[0]["access"] = $this->db->f("ab_access"); + if (gettype($ab_fieldnames) == "array") { + while (list($f_name) = each($ab_fieldnames)) { + $return_fields[0][$f_name] = $this->db->f("ab_" . $f_name); + } + } + $this->db2->query("select contact_name,contact_value from phpgw_contacts where contact_id='" + . $this->db->f("ab_id") . "'",__LINE__,__FILE__); + while ($this->db2->next_record()) { + // If its not in the list to be return, don't return it. + // This is still quicker then 5(+) seperate querys + if ($extra_fields[$this->db2->f("contact_name")]) { + $return_fields[0][$this->db2->f("contact_name")] = $this->db2->f("contact_value"); + } + } + + return $return_fields; + } + function read($start,$offset,$access,$filters,$fields) { list($ab_fields,$ab_fieldnames,$extra_fields) = $this->split_ab_and_extras($fields);