4 +-----------------------------------------------------------------------+
5 | program/include/rcube_addressbook.php |
7 | This file is part of the Roundcube Webmail client |
8 | Copyright (C) 2006-2009, Roundcube Dev. - Switzerland |
9 | Licensed under the GNU GPL |
12 | Interface to the local address book database |
14 +-----------------------------------------------------------------------+
15 | Author: Thomas Bruederli <roundcube@gmail.com> |
16 +-----------------------------------------------------------------------+
18 $Id: rcube_addressbook.php 4145 2010-10-27 07:23:57Z alec $
24 * Abstract skeleton of an address book/repository
26 * @package Addressbook
28 abstract class rcube_addressbook
30 /** public properties */
39 * Save a search string for future listings
41 * @param mixed Search params to use in listing method, obtained by get_search_set()
43 abstract function set_search_set($filter);
46 * Getter for saved search properties
48 * @return mixed Search properties used by this class
50 abstract function get_search_set();
53 * Reset saved results and search parameters
55 abstract function reset();
58 * List the current set of contact records
60 * @param array List of cols to show
61 * @param int Only return this number of records, use negative values for tail
62 * @return array Indexed list of contact records, each a hash array
64 abstract function list_records($cols=null, $subset=0);
69 * @param array List of fields to search in
70 * @param string Search value
71 * @param boolean True if results are requested, False if count only
72 * @return Indexed list of contact records and 'count' value
74 abstract function search($fields, $value, $strict=false, $select=true);
77 * Count number of available contacts in database
79 * @return rcube_result_set Result set with values for 'count' and 'first'
81 abstract function count();
84 * Return the last result set
86 * @return rcube_result_set Current result set or NULL if nothing selected yet
88 abstract function get_result();
91 * Get a specific contact record
93 * @param mixed record identifier(s)
94 * @param boolean True to return record as associative array, otherwise a result set is returned
96 * @return mixed Result object with all record fields or False if not found
98 abstract function get_record($id, $assoc=false);
101 * Close connection to source
102 * Called on script shutdown
107 * Set internal list page
109 * @param number Page number to list
112 function set_page($page)
114 $this->list_page = (int)$page;
118 * Set internal page size
120 * @param number Number of messages to display on one page
123 function set_pagesize($size)
125 $this->page_size = (int)$size;
129 * Create a new contact record
131 * @param array Assoziative array with save data
132 * @param boolean True to check for duplicates first
133 * @return mixed The created record ID on success, False on error
135 function insert($save_data, $check=false)
137 /* empty for read-only address books */
141 * Update a specific contact record
143 * @param mixed Record identifier
144 * @param array Assoziative array with save data
145 * @return boolean True on success, False on error
147 function update($id, $save_cols)
149 /* empty for read-only address books */
153 * Mark one or more contact records as deleted
155 * @param array Record identifiers
157 function delete($ids)
159 /* empty for read-only address books */
163 * Remove all records from the database
165 function delete_all()
167 /* empty for read-only address books */
171 * Setter for the current group
172 * (empty, has to be re-implemented by extending class)
174 function set_group($gid) { }
177 * List all active contact groups of this source
179 * @return array Indexed list of contact groups, each a hash array
181 function list_groups()
183 /* empty for address books don't supporting groups */
188 * Create a contact group with the given name
190 * @param string The group name
191 * @return mixed False on error, array with record props in success
193 function create_group($name)
195 /* empty for address books don't supporting groups */
200 * Delete the given group and all linked group members
202 * @param string Group identifier
203 * @return boolean True on success, false if no data was changed
205 function delete_group($gid)
207 /* empty for address books don't supporting groups */
212 * Rename a specific contact group
214 * @param string Group identifier
215 * @param string New name to set for this group
216 * @return boolean New name on success, false if no data was changed
218 function rename_group($gid, $newname)
220 /* empty for address books don't supporting groups */
225 * Add the given contact records the a certain group
227 * @param string Group identifier
228 * @param array List of contact identifiers to be added
229 * @return int Number of contacts added
231 function add_to_group($group_id, $ids)
233 /* empty for address books don't supporting groups */
238 * Remove the given contact records from a certain group
240 * @param string Group identifier
241 * @param array List of contact identifiers to be removed
242 * @return int Number of deleted group members
244 function remove_from_group($group_id, $ids)
246 /* empty for address books don't supporting groups */
251 * Get group assignments of a specific contact record
253 * @param mixed Record identifier
255 * @return array List of assigned groups as ID=>Name pairs
258 function get_record_groups($id)
260 /* empty for address books don't supporting groups */