| | |
| | | protected $db_groups = 'contactgroups'; |
| | | protected $db_groupmembers = 'contactgroupmembers'; |
| | | |
| | | /** |
| | | * Store database connection. |
| | | * |
| | | * @var rcube_mdb2 |
| | | */ |
| | | private $db = null; |
| | | private $user_id = 0; |
| | | private $filter = null; |
| | |
| | | /** |
| | | * Return the last result set |
| | | * |
| | | * @return Result array or NULL if nothing selected yet |
| | | * @return mixed Result array or NULL if nothing selected yet |
| | | */ |
| | | function get_result() |
| | | { |
| | |
| | | * Get a specific contact record |
| | | * |
| | | * @param mixed record identifier(s) |
| | | * @return Result object with all record fields or False if not found |
| | | * @return mixed Result object with all record fields or False if not found |
| | | */ |
| | | function get_record($id, $assoc=false) |
| | | { |
| | |
| | | |
| | | |
| | | /** |
| | | * Get group assignments of a specific contact record |
| | | * |
| | | * @param mixed Record identifier |
| | | * @return 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 |
| | | * |
| | | * @param array Assoziative array with save data |
| | | * @return The created record ID on success, False on error |
| | | * @param array Associative array with save data |
| | | * @return integer|boolean The created record ID on success, False on error |
| | | */ |
| | | function insert($save_data, $check=false) |
| | | { |
| | |
| | | * |
| | | * @param mixed Record identifier |
| | | * @param array Assoziative array with save data |
| | | * @return True on success, False on error |
| | | * @return boolean True on success, False on error |
| | | */ |
| | | function update($id, $save_cols) |
| | | { |
| | |
| | | * Create a contact group with the given name |
| | | * |
| | | * @param string The group name |
| | | * @return False on error, array with record props in success |
| | | * @return mixed False on error, array with record props in success |
| | | */ |
| | | function create_group($name) |
| | | { |