From a5d1e6f6ff83ac74fdebe355ff223dccd367a738 Mon Sep 17 00:00:00 2001 From: thomasb Date: Fri, 22 Oct 2010 15:24:39 +0000 Subject: List groups in address detail view and allow to subscribe/unsubscribe from there (#1486753) git-svn-id: https://svn.roundcube.net/trunk@4121 208e9e7b-5314-0410-a742-e7e81cd9613c --- roundcubemail/program/include/rcube_contacts.php | 27 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'roundcubemail/program/include/rcube_contacts.php') diff --git a/roundcubemail/program/include/rcube_contacts.php b/roundcubemail/program/include/rcube_contacts.php index 16e39fc7e..e1dc7c535 100644 --- a/roundcubemail/program/include/rcube_contacts.php +++ b/roundcubemail/program/include/rcube_contacts.php @@ -354,6 +354,33 @@ class rcube_contacts extends rcube_addressbook } + /** + * Get group assignments of a specific contacr record + * + * @param mixed Record identifier + * @param array List of assigned groups as ID=>Name pairs + */ + function get_record_groups($id) + { + $results = array(); + + if (!$this->groups) + return $results; + + $sql_result = $this->db->query( + "SELECT cgm.contactgroup_id, cg.name FROM " . get_table_name($this->db_groupmembers) . " AS cgm" . + " LEFT JOIN " . get_table_name($this->db_groups) . " AS cg ON (cgm.contactgroup_id = cg.contactgroup_id AND cg.del<>1)" . + " WHERE cgm.contact_id=?", + $id + ); + while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) { + $results[$sql_arr['contactgroup_id']] = $sql_arr['name']; + } + + return $results; + } + + /** * Create a new contact record * -- cgit v1.2.3