1 | /**************************************************************************\ |
---|
2 | * eGroupWare API - Contacts class documentation * |
---|
3 | * This file written by Miles Lott <milosch@groupwhare.org> * |
---|
4 | * -------------------------------------------------------------------------* |
---|
5 | * This library is free software; you can redistribute it and/or modify it * |
---|
6 | * under the terms of the GNU Lesser General Public License as published by * |
---|
7 | * the Free Software Foundation; either version 2.1 of the License, * |
---|
8 | * or any later version. * |
---|
9 | * This library is distributed in the hope that it will be useful, but * |
---|
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
---|
12 | * See the GNU Lesser General Public License for more details. * |
---|
13 | * You should have received a copy of the GNU Lesser General Public License * |
---|
14 | * along with this library; if not, write to the Free Software Foundation, * |
---|
15 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * |
---|
16 | \**************************************************************************/ |
---|
17 | |
---|
18 | |
---|
19 | |
---|
20 | Starting with the most cumbersome function: |
---|
21 | |
---|
22 | function read($start,$offset,$fields,$query="",$filter="",$sort="",$order="") |
---|
23 | |
---|
24 | Purpose: |
---|
25 | Returns a list of contacts based on limits, query, and filter, |
---|
26 | in an array of name/values, e.g.: |
---|
27 | |
---|
28 | $fields[0]["id"] => "354", |
---|
29 | $fields[0]["email"] => "name@domain.com", ... |
---|
30 | |
---|
31 | $fields[1]["id"] => "355", |
---|
32 | $fields[1]["email"] => "othername@otherdomain.com", ... |
---|
33 | |
---|
34 | Inputs: |
---|
35 | |
---|
36 | $start = start of list, e.g. 1,16,31 |
---|
37 | $offset = numrows, e.g. 15,30,etc. from nextmatchs, usually |
---|
38 | $fields = simple array of fields to return: |
---|
39 | |
---|
40 | $qfields = array( |
---|
41 | 'id' => 'id', |
---|
42 | 'n_given' => 'n_given |
---|
43 | ); |
---|
44 | |
---|
45 | $query = simple string to search for, e.g. "milosch" or "555" |
---|
46 | |
---|
47 | $filter = for 'accounting' fields other than id (use read_single_entry for |
---|
48 | that): |
---|
49 | |
---|
50 | owner = account_id of record owner |
---|
51 | access = public/private |
---|
52 | cat_id = category id for the record |
---|
53 | lid = account_lid for account records stored here, if any |
---|
54 | tid = type id: |
---|
55 | n = normal contact - almost always use this |
---|
56 | p = profiles for hr, tied to account records |
---|
57 | u = user account, if stored in contacts class |
---|
58 | g = group account, "" |
---|
59 | |
---|
60 | Filters should be in the format: |
---|
61 | |
---|
62 | example 1: 'tid=n' filter for normal contacts |
---|
63 | example 2: 'tid=u,lid=milosch' filter user accounts for lid |
---|
64 | 'milosch' |
---|
65 | etc... |
---|
66 | |
---|
67 | $sort = ASC, DESC, or "" (defaults to ASC) |
---|
68 | |
---|
69 | $order = sort on this field, e.g. n_given |
---|
70 | |
---|
71 | |
---|
72 | function read_single_entry($id,$fields) |
---|
73 | |
---|
74 | Purpose: |
---|
75 | returns a single array of name/value based on id |
---|
76 | and field selection, e.g.: |
---|
77 | |
---|
78 | $fields[0]["email"] => "name@domain.com" |
---|
79 | $fields[0]["n_given"] => "Bob" |
---|
80 | |
---|
81 | Inputs: |
---|
82 | |
---|
83 | $id = id of entry you want to return |
---|
84 | |
---|
85 | $fields = simple array of fields to return |
---|
86 | |
---|
87 | $qfields = array( |
---|
88 | 'id' => 'id', |
---|
89 | 'n_given' => 'n_given |
---|
90 | ); |
---|
91 | |
---|
92 | |
---|
93 | function add($owner,$fields,$access='',$cat_id='',$tid='n') |
---|
94 | |
---|
95 | Purpose: |
---|
96 | |
---|
97 | Add a new contact record of the type, category and access sent |
---|
98 | with a field list. |
---|
99 | |
---|
100 | Inputs: |
---|
101 | |
---|
102 | $owner = id of user adding this data |
---|
103 | |
---|
104 | $fields = simple array of fields to write into the new record |
---|
105 | |
---|
106 | $access = public/private |
---|
107 | |
---|
108 | $cat_id = category id for the record, if desired |
---|
109 | |
---|
110 | $tid = type id ( see read() above ), defaults to 'n' |
---|
111 | |
---|
112 | |
---|
113 | function update($id,$owner,$fields,$access='',$cat_id='',$tid='') |
---|
114 | |
---|
115 | Purpose: |
---|
116 | |
---|
117 | Update an entry already in the contacts list |
---|
118 | |
---|
119 | Inputs: |
---|
120 | |
---|
121 | $id = id of entry you want to update |
---|
122 | |
---|
123 | $owner = id of user modifying this data |
---|
124 | |
---|
125 | $fields = simple array of fields to update in the record |
---|
126 | (see examples above) |
---|
127 | |
---|
128 | $access = public/private |
---|
129 | |
---|
130 | $cat_id = category id for the record, if desired |
---|
131 | |
---|
132 | |
---|
133 | $tid = type id ( see read() above ), defaults to 'n' |
---|
134 | |
---|
135 | |
---|
136 | function delete_($id) |
---|
137 | |
---|
138 | Purpose: |
---|
139 | |
---|
140 | Delete an entry already in the contacts list |
---|
141 | |
---|
142 | Inputs: |
---|
143 | |
---|
144 | $id = id of entry you want to delete |
---|
145 | |
---|
146 | |
---|
147 | Stock contact fields, other than accounting fields mentioned above: |
---|
148 | |
---|
149 | $this->stock_contact_fields = array( |
---|
150 | "fn" => "fn", // 'prefix given middle family suffix' |
---|
151 | "n_given" => "n_given", // firstname |
---|
152 | "n_family" => "n_family", // lastname |
---|
153 | "n_middle" => "n_middle", |
---|
154 | "n_prefix" => "n_prefix", |
---|
155 | "n_suffix" => "n_suffix", |
---|
156 | "sound" => "sound", |
---|
157 | "bday" => "bday", // Birthday (12/31/1969) |
---|
158 | "note" => "note", // Note, description, etc. |
---|
159 | "tz" => "tz", // Hours offset from phpgw install |
---|
160 | "geo" => "geo", // Not used |
---|
161 | "url" => "url", |
---|
162 | "pubkey" => "pubkey", // Similar to note, but for public encryption key |
---|
163 | |
---|
164 | "org_name" => "org_name", // company |
---|
165 | "org_unit" => "org_unit", // division |
---|
166 | "title" => "title", |
---|
167 | |
---|
168 | "adr_one_street" => "adr_one_street", // Business address entry |
---|
169 | "adr_one_locality" => "adr_one_locality", |
---|
170 | "adr_one_region" => "adr_one_region", |
---|
171 | "adr_one_postalcode" => "adr_one_postalcode", |
---|
172 | "adr_one_countryname" => "adr_one_countryname", |
---|
173 | "adr_one_type" => "adr_one_type", // address is domestic/intl/postal/parcel/work/home |
---|
174 | "label" => "label", // address label |
---|
175 | |
---|
176 | "adr_two_street" => "adr_two_street", // Home address entry |
---|
177 | "adr_two_locality" => "adr_two_locality", |
---|
178 | "adr_two_region" => "adr_two_region", |
---|
179 | "adr_two_postalcode" => "adr_two_postalcode", |
---|
180 | "adr_two_countryname" => "adr_two_countryname", |
---|
181 | "adr_two_type" => "adr_two_type", // address is domestic/intl/postal/parcel/work/home |
---|
182 | |
---|
183 | "tel_work" => "tel_work", |
---|
184 | "tel_home" => "tel_home", |
---|
185 | "tel_voice" => "tel_voice", |
---|
186 | "tel_fax" => "tel_fax", |
---|
187 | "tel_msg" => "tel_msg", |
---|
188 | "tel_cell" => "tel_cell", |
---|
189 | "tel_pager" => "tel_pager", |
---|
190 | "tel_bbs" => "tel_bbs", |
---|
191 | "tel_modem" => "tel_modem", |
---|
192 | "tel_car" => "tel_car", |
---|
193 | "tel_isdn" => "tel_isdn", |
---|
194 | "tel_video" => "tel_video", |
---|
195 | "tel_prefer" => "tel_prefer", // home;work;voice |
---|
196 | "email" => "email", |
---|
197 | "email_type" => "email_type", //'INTERNET','CompuServe',etc... |
---|
198 | "email_home" => "email_home", |
---|
199 | "email_home_type" => "email_home_type" //'INTERNET','CompuServe',etc... |
---|
200 | ); |
---|
201 | |
---|
202 | Other useful arrays for setting option dialogs, etc. |
---|
203 | |
---|
204 | // Used to set adr_one_type/adr_two_type, e.g. 'intl;work' |
---|
205 | $this->adr_types = array( |
---|
206 | "dom" => lang("Domestic"), |
---|
207 | "intl" => lang("International"), |
---|
208 | "parcel" => lang("Parcel"), |
---|
209 | "postal" => lang("Postal") |
---|
210 | ); |
---|
211 | |
---|
212 | // Used to set preferred number field, e.g. 'cell' or 'work' |
---|
213 | $this->tel_types = array( |
---|
214 | "work" => "work", |
---|
215 | "home" => "home", |
---|
216 | "voice" => "voice", |
---|
217 | "fax" => "fax", |
---|
218 | "msg" => "msg", |
---|
219 | "cell" => "cell", |
---|
220 | "pager" => "pager", |
---|
221 | "bbs" => "bbs", |
---|
222 | "modem" => "modem", |
---|
223 | "car" => "car", |
---|
224 | "isdn" => "isdn", |
---|
225 | "video" => "video" |
---|
226 | ); |
---|
227 | |
---|
228 | $this->email_types = array( |
---|
229 | "INTERNET" => "INTERNET", |
---|
230 | "CompuServe" => "CompuServe", |
---|
231 | "AOL" => "AOL", |
---|
232 | "Prodigy" => "Prodigy", |
---|
233 | "eWorld" => "eWorld", |
---|
234 | "AppleLink" => "AppleLink", |
---|
235 | "AppleTalk" => "AppleTalk", |
---|
236 | "PowerShare" => "PowerShare", |
---|
237 | "IBMMail" => "IBMMail", |
---|
238 | "ATTMail" => "ATTMail", |
---|
239 | "MCIMail" => "MCIMail", |
---|
240 | "X.400" => "X.400", |
---|
241 | "TLX" => "TLX" |
---|
242 | ); |
---|
243 | |
---|