Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
50fb255d | 2 | /** |
a828d7b8 | 3 | * Test Generated example demonstrating the Contact.getfields API. |
50fb255d | 4 | * |
5c49fee0 | 5 | * Demonstrates retrieving metadata with custom field options. |
50fb255d | 6 | * |
7 | * @return array | |
8 | * API result array | |
9 | */ | |
10 | function contact_getfields_example() { | |
11 | $params = array( | |
12 | 'options' => array( | |
6a488035 TO |
13 | 'get_options' => 'custom_1', |
14 | ), | |
50fb255d | 15 | 'action' => 'create', |
16 | ); | |
6a488035 | 17 | |
50fb255d | 18 | try{ |
a828d7b8 | 19 | $result = civicrm_api3('Contact', 'getfields', $params); |
50fb255d | 20 | } |
21 | catch (CiviCRM_API3_Exception $e) { | |
22 | // Handle error here. | |
23 | $errorMessage = $e->getMessage(); | |
24 | $errorCode = $e->getErrorCode(); | |
25 | $errorData = $e->getExtraParams(); | |
26 | return array( | |
27 | 'error' => $errorMessage, | |
28 | 'error_code' => $errorCode, | |
29 | 'error_data' => $errorData, | |
30 | ); | |
31 | } | |
6a488035 | 32 | |
50fb255d | 33 | return $result; |
6a488035 TO |
34 | } |
35 | ||
fb32de45 | 36 | /** |
50fb255d | 37 | * Function returns array of result expected from previous function. |
38 | * | |
39 | * @return array | |
40 | * API result array | |
6a488035 | 41 | */ |
50fb255d | 42 | function contact_getfields_expectedresult() { |
6a488035 | 43 | |
7a7cc10b | 44 | $expectedResult = array( |
50fb255d | 45 | 'is_error' => 0, |
46 | 'version' => 3, | |
47 | 'count' => 55, | |
48 | 'values' => array( | |
7a7cc10b | 49 | 'id' => array( |
50fb255d | 50 | 'name' => 'id', |
51 | 'type' => 1, | |
52 | 'title' => 'Internal Contact ID', | |
53 | 'required' => TRUE, | |
54 | 'import' => TRUE, | |
55 | 'where' => 'civicrm_contact.id', | |
56 | 'headerPattern' => '/internal|contact?|id$/i', | |
57 | 'export' => TRUE, | |
58 | 'api.aliases' => array( | |
59 | '0' => 'contact_id', | |
60 | ), | |
61 | ), | |
7a7cc10b | 62 | 'contact_type' => array( |
50fb255d | 63 | 'name' => 'contact_type', |
64 | 'type' => 2, | |
65 | 'title' => 'Contact Type', | |
66 | 'maxlength' => 64, | |
67 | 'size' => 30, | |
68 | 'export' => TRUE, | |
69 | 'where' => 'civicrm_contact.contact_type', | |
70 | 'html' => array( | |
71 | 'type' => 'Select', | |
72 | ), | |
73 | 'pseudoconstant' => array( | |
74 | 'table' => 'civicrm_contact_type', | |
75 | 'keyColumn' => 'name', | |
76 | 'labelColumn' => 'label', | |
77 | 'condition' => 'parent_id IS NULL', | |
78 | ), | |
79 | 'api.required' => 1, | |
80 | ), | |
7a7cc10b | 81 | 'contact_sub_type' => array( |
50fb255d | 82 | 'name' => 'contact_sub_type', |
83 | 'type' => 2, | |
84 | 'title' => 'Contact Subtype', | |
85 | 'maxlength' => 255, | |
86 | 'size' => 45, | |
87 | 'import' => TRUE, | |
88 | 'where' => 'civicrm_contact.contact_sub_type', | |
89 | 'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i', | |
90 | 'export' => TRUE, | |
91 | 'html' => array( | |
92 | 'type' => 'Multi-Select', | |
93 | ), | |
94 | 'pseudoconstant' => array( | |
95 | 'table' => 'civicrm_contact_type', | |
96 | 'keyColumn' => 'name', | |
97 | 'labelColumn' => 'label', | |
98 | 'condition' => 'parent_id IS NOT NULL', | |
99 | ), | |
100 | ), | |
7a7cc10b | 101 | 'do_not_email' => array( |
50fb255d | 102 | 'name' => 'do_not_email', |
103 | 'type' => 16, | |
104 | 'title' => 'Do Not Email', | |
105 | 'import' => TRUE, | |
106 | 'where' => 'civicrm_contact.do_not_email', | |
107 | 'headerPattern' => '/d(o )?(not )?(email)/i', | |
108 | 'dataPattern' => '/^\\d{1,}$/', | |
109 | 'export' => TRUE, | |
110 | 'html' => array( | |
111 | 'type' => 'CheckBox', | |
112 | ), | |
113 | ), | |
7a7cc10b | 114 | 'do_not_phone' => array( |
50fb255d | 115 | 'name' => 'do_not_phone', |
116 | 'type' => 16, | |
117 | 'title' => 'Do Not Phone', | |
118 | 'import' => TRUE, | |
119 | 'where' => 'civicrm_contact.do_not_phone', | |
120 | 'headerPattern' => '/d(o )?(not )?(call|phone)/i', | |
121 | 'dataPattern' => '/^\\d{1,}$/', | |
122 | 'export' => TRUE, | |
123 | 'html' => array( | |
124 | 'type' => 'CheckBox', | |
125 | ), | |
126 | ), | |
7a7cc10b | 127 | 'do_not_mail' => array( |
50fb255d | 128 | 'name' => 'do_not_mail', |
129 | 'type' => 16, | |
130 | 'title' => 'Do Not Mail', | |
131 | 'import' => TRUE, | |
132 | 'where' => 'civicrm_contact.do_not_mail', | |
133 | 'headerPattern' => '/^(d(o\\s)?n(ot\\s)?mail)|(\\w*)?bulk\\s?(\\w*)$/i', | |
134 | 'dataPattern' => '/^\\d{1,}$/', | |
135 | 'export' => TRUE, | |
136 | 'html' => array( | |
137 | 'type' => 'CheckBox', | |
138 | ), | |
139 | ), | |
7a7cc10b | 140 | 'do_not_sms' => array( |
50fb255d | 141 | 'name' => 'do_not_sms', |
142 | 'type' => 16, | |
143 | 'title' => 'Do Not Sms', | |
144 | 'import' => TRUE, | |
145 | 'where' => 'civicrm_contact.do_not_sms', | |
146 | 'headerPattern' => '/d(o )?(not )?(sms)/i', | |
147 | 'dataPattern' => '/^\\d{1,}$/', | |
148 | 'export' => TRUE, | |
149 | 'html' => array( | |
150 | 'type' => 'CheckBox', | |
151 | ), | |
152 | ), | |
7a7cc10b | 153 | 'do_not_trade' => array( |
50fb255d | 154 | 'name' => 'do_not_trade', |
155 | 'type' => 16, | |
156 | 'title' => 'Do Not Trade', | |
157 | 'import' => TRUE, | |
158 | 'where' => 'civicrm_contact.do_not_trade', | |
159 | 'headerPattern' => '/d(o )?(not )?(trade)/i', | |
160 | 'dataPattern' => '/^\\d{1,}$/', | |
161 | 'export' => TRUE, | |
162 | 'html' => array( | |
163 | 'type' => 'CheckBox', | |
164 | ), | |
165 | ), | |
7a7cc10b | 166 | 'is_opt_out' => array( |
50fb255d | 167 | 'name' => 'is_opt_out', |
168 | 'type' => 16, | |
169 | 'title' => 'No Bulk Emails (User Opt Out)', | |
170 | 'required' => TRUE, | |
171 | 'import' => TRUE, | |
172 | 'where' => 'civicrm_contact.is_opt_out', | |
173 | 'export' => TRUE, | |
174 | 'html' => array( | |
175 | 'type' => 'CheckBox', | |
176 | ), | |
177 | ), | |
7a7cc10b | 178 | 'legal_identifier' => array( |
50fb255d | 179 | 'name' => 'legal_identifier', |
180 | 'type' => 2, | |
181 | 'title' => 'Legal Identifier', | |
182 | 'maxlength' => 32, | |
183 | 'size' => 20, | |
184 | 'import' => TRUE, | |
185 | 'where' => 'civicrm_contact.legal_identifier', | |
186 | 'headerPattern' => '/legal\\s?id/i', | |
187 | 'dataPattern' => '/\\w+?\\d{5,}/', | |
188 | 'export' => TRUE, | |
189 | 'html' => array( | |
190 | 'type' => 'Text', | |
191 | ), | |
192 | ), | |
7a7cc10b | 193 | 'external_identifier' => array( |
50fb255d | 194 | 'name' => 'external_identifier', |
195 | 'type' => 2, | |
196 | 'title' => 'External Identifier', | |
5c49fee0 | 197 | 'maxlength' => 64, |
50fb255d | 198 | 'size' => 8, |
199 | 'import' => TRUE, | |
200 | 'where' => 'civicrm_contact.external_identifier', | |
201 | 'headerPattern' => '/external\\s?id/i', | |
202 | 'dataPattern' => '/^\\d{11,}$/', | |
203 | 'export' => TRUE, | |
204 | 'html' => array( | |
205 | 'type' => 'Text', | |
206 | ), | |
207 | ), | |
7a7cc10b | 208 | 'sort_name' => array( |
50fb255d | 209 | 'name' => 'sort_name', |
210 | 'type' => 2, | |
211 | 'title' => 'Sort Name', | |
212 | 'maxlength' => 128, | |
213 | 'size' => 30, | |
214 | 'export' => TRUE, | |
215 | 'where' => 'civicrm_contact.sort_name', | |
216 | 'html' => array( | |
217 | 'type' => 'Text', | |
218 | ), | |
219 | ), | |
7a7cc10b | 220 | 'display_name' => array( |
50fb255d | 221 | 'name' => 'display_name', |
222 | 'type' => 2, | |
223 | 'title' => 'Display Name', | |
224 | 'maxlength' => 128, | |
225 | 'size' => 30, | |
226 | 'export' => TRUE, | |
227 | 'where' => 'civicrm_contact.display_name', | |
228 | 'html' => array( | |
229 | 'type' => 'Text', | |
230 | ), | |
231 | ), | |
7a7cc10b | 232 | 'nick_name' => array( |
50fb255d | 233 | 'name' => 'nick_name', |
234 | 'type' => 2, | |
235 | 'title' => 'Nickname', | |
236 | 'maxlength' => 128, | |
237 | 'size' => 30, | |
238 | 'import' => TRUE, | |
239 | 'where' => 'civicrm_contact.nick_name', | |
240 | 'headerPattern' => '/n(ick\\s)name|nick$/i', | |
241 | 'dataPattern' => '/^\\w+$/', | |
242 | 'export' => TRUE, | |
243 | 'html' => array( | |
244 | 'type' => 'Text', | |
245 | ), | |
246 | ), | |
7a7cc10b | 247 | 'legal_name' => array( |
50fb255d | 248 | 'name' => 'legal_name', |
249 | 'type' => 2, | |
250 | 'title' => 'Legal Name', | |
251 | 'maxlength' => 128, | |
252 | 'size' => 30, | |
253 | 'import' => TRUE, | |
254 | 'where' => 'civicrm_contact.legal_name', | |
255 | 'headerPattern' => '/^legal|(l(egal\\s)?name)$/i', | |
256 | 'export' => TRUE, | |
257 | 'html' => array( | |
258 | 'type' => 'Text', | |
259 | ), | |
260 | ), | |
7a7cc10b | 261 | 'image_URL' => array( |
50fb255d | 262 | 'name' => 'image_URL', |
263 | 'type' => 2, | |
264 | 'title' => 'Image Url', | |
265 | 'maxlength' => 255, | |
266 | 'size' => 45, | |
267 | 'import' => TRUE, | |
268 | 'where' => 'civicrm_contact.image_URL', | |
269 | 'export' => TRUE, | |
270 | 'html' => array( | |
271 | 'type' => 'Text', | |
272 | ), | |
273 | ), | |
7a7cc10b | 274 | 'preferred_communication_method' => array( |
50fb255d | 275 | 'name' => 'preferred_communication_method', |
276 | 'type' => 2, | |
277 | 'title' => 'Preferred Communication Method', | |
278 | 'maxlength' => 255, | |
279 | 'size' => 45, | |
280 | 'import' => TRUE, | |
281 | 'where' => 'civicrm_contact.preferred_communication_method', | |
282 | 'headerPattern' => '/^p(ref\\w*\\s)?c(omm\\w*)|( meth\\w*)$/i', | |
283 | 'dataPattern' => '/^\\w+$/', | |
284 | 'export' => TRUE, | |
285 | 'html' => array( | |
286 | 'type' => 'Select', | |
287 | ), | |
288 | 'pseudoconstant' => array( | |
289 | 'optionGroupName' => 'preferred_communication_method', | |
290 | ), | |
291 | ), | |
7a7cc10b | 292 | 'preferred_language' => array( |
50fb255d | 293 | 'name' => 'preferred_language', |
294 | 'type' => 2, | |
295 | 'title' => 'Preferred Language', | |
296 | 'maxlength' => 5, | |
297 | 'size' => 6, | |
298 | 'import' => TRUE, | |
299 | 'where' => 'civicrm_contact.preferred_language', | |
300 | 'headerPattern' => '/^lang/i', | |
301 | 'export' => TRUE, | |
302 | 'html' => array( | |
303 | 'type' => 'Select', | |
304 | ), | |
305 | 'pseudoconstant' => array( | |
306 | 'optionGroupName' => 'languages', | |
307 | 'keyColumn' => 'name', | |
308 | ), | |
309 | ), | |
7a7cc10b | 310 | 'preferred_mail_format' => array( |
50fb255d | 311 | 'name' => 'preferred_mail_format', |
312 | 'type' => 2, | |
313 | 'title' => 'Preferred Mail Format', | |
314 | 'maxlength' => 8, | |
315 | 'size' => 8, | |
316 | 'import' => TRUE, | |
317 | 'where' => 'civicrm_contact.preferred_mail_format', | |
318 | 'headerPattern' => '/^p(ref\\w*\\s)?m(ail\\s)?f(orm\\w*)$/i', | |
319 | 'export' => TRUE, | |
320 | 'default' => 'Both', | |
321 | 'html' => array( | |
322 | 'type' => 'Select', | |
323 | ), | |
324 | 'pseudoconstant' => array( | |
325 | 'callback' => 'CRM_Core_SelectValues::pmf', | |
326 | ), | |
327 | ), | |
7a7cc10b | 328 | 'hash' => array( |
50fb255d | 329 | 'name' => 'hash', |
330 | 'type' => 2, | |
331 | 'title' => 'Contact Hash', | |
332 | 'maxlength' => 32, | |
333 | 'size' => 20, | |
334 | 'export' => TRUE, | |
335 | 'where' => 'civicrm_contact.hash', | |
336 | ), | |
7a7cc10b | 337 | 'api_key' => array( |
50fb255d | 338 | 'name' => 'api_key', |
339 | 'type' => 2, | |
340 | 'title' => 'Api Key', | |
341 | 'maxlength' => 32, | |
342 | 'size' => 20, | |
343 | ), | |
7a7cc10b | 344 | 'first_name' => array( |
50fb255d | 345 | 'name' => 'first_name', |
346 | 'type' => 2, | |
347 | 'title' => 'First Name', | |
348 | 'maxlength' => 64, | |
349 | 'size' => 30, | |
350 | 'import' => TRUE, | |
351 | 'where' => 'civicrm_contact.first_name', | |
352 | 'headerPattern' => '/^first|(f(irst\\s)?name)$/i', | |
353 | 'dataPattern' => '/^\\w+$/', | |
354 | 'export' => TRUE, | |
355 | 'html' => array( | |
356 | 'type' => 'Text', | |
357 | ), | |
358 | ), | |
7a7cc10b | 359 | 'middle_name' => array( |
50fb255d | 360 | 'name' => 'middle_name', |
361 | 'type' => 2, | |
362 | 'title' => 'Middle Name', | |
363 | 'maxlength' => 64, | |
364 | 'size' => 20, | |
365 | 'import' => TRUE, | |
366 | 'where' => 'civicrm_contact.middle_name', | |
367 | 'headerPattern' => '/^middle|(m(iddle\\s)?name)$/i', | |
368 | 'dataPattern' => '/^\\w+$/', | |
369 | 'export' => TRUE, | |
370 | 'html' => array( | |
371 | 'type' => 'Text', | |
372 | ), | |
373 | ), | |
7a7cc10b | 374 | 'last_name' => array( |
50fb255d | 375 | 'name' => 'last_name', |
376 | 'type' => 2, | |
377 | 'title' => 'Last Name', | |
378 | 'maxlength' => 64, | |
379 | 'size' => 30, | |
380 | 'import' => TRUE, | |
381 | 'where' => 'civicrm_contact.last_name', | |
382 | 'headerPattern' => '/^last|(l(ast\\s)?name)$/i', | |
383 | 'dataPattern' => '/^\\w+(\\s\\w+)?+$/', | |
384 | 'export' => TRUE, | |
385 | 'html' => array( | |
386 | 'type' => 'Text', | |
387 | ), | |
388 | ), | |
9f1b81e0 | 389 | 'prefix_id' => array( |
50fb255d | 390 | 'name' => 'prefix_id', |
391 | 'type' => 1, | |
392 | 'title' => 'Individual Prefix', | |
393 | 'import' => TRUE, | |
394 | 'where' => 'civicrm_contact.prefix_id', | |
395 | 'headerPattern' => '/^(prefix|title)/i', | |
396 | 'dataPattern' => '/^(mr|ms|mrs|sir|dr)\\.?$/i', | |
397 | 'export' => TRUE, | |
398 | 'html' => array( | |
399 | 'type' => 'Select', | |
400 | ), | |
401 | 'pseudoconstant' => array( | |
402 | 'optionGroupName' => 'individual_prefix', | |
403 | ), | |
404 | 'api.aliases' => array( | |
405 | '0' => 'individual_prefix', | |
406 | '1' => 'individual_prefix_id', | |
407 | ), | |
408 | ), | |
9f1b81e0 | 409 | 'suffix_id' => array( |
50fb255d | 410 | 'name' => 'suffix_id', |
411 | 'type' => 1, | |
412 | 'title' => 'Individual Suffix', | |
413 | 'import' => TRUE, | |
414 | 'where' => 'civicrm_contact.suffix_id', | |
415 | 'headerPattern' => '/^suffix$/i', | |
416 | 'dataPattern' => '/^(sr|jr)\\.?|i{2,}$/', | |
417 | 'export' => TRUE, | |
418 | 'html' => array( | |
419 | 'type' => 'Select', | |
420 | ), | |
421 | 'pseudoconstant' => array( | |
422 | 'optionGroupName' => 'individual_suffix', | |
423 | ), | |
424 | 'api.aliases' => array( | |
425 | '0' => 'individual_suffix', | |
426 | '1' => 'individual_suffix_id', | |
427 | ), | |
428 | ), | |
89bf81b4 | 429 | 'formal_title' => array( |
50fb255d | 430 | 'name' => 'formal_title', |
431 | 'type' => 2, | |
432 | 'title' => 'Formal Title', | |
433 | 'maxlength' => 64, | |
434 | 'size' => 30, | |
435 | 'import' => TRUE, | |
436 | 'where' => 'civicrm_contact.formal_title', | |
437 | 'headerPattern' => '/^title/i', | |
438 | 'export' => TRUE, | |
439 | ), | |
89bf81b4 | 440 | 'communication_style_id' => array( |
50fb255d | 441 | 'name' => 'communication_style_id', |
442 | 'type' => 1, | |
443 | 'title' => 'Communication Style', | |
444 | 'export' => TRUE, | |
445 | 'where' => 'civicrm_contact.communication_style_id', | |
446 | 'pseudoconstant' => array( | |
447 | 'optionGroupName' => 'communication_style', | |
448 | ), | |
449 | ), | |
7a7cc10b | 450 | 'email_greeting_id' => array( |
50fb255d | 451 | 'name' => 'email_greeting_id', |
452 | 'type' => 1, | |
453 | 'title' => 'Email Greeting ID', | |
454 | ), | |
7a7cc10b | 455 | 'email_greeting_custom' => array( |
50fb255d | 456 | 'name' => 'email_greeting_custom', |
457 | 'type' => 2, | |
458 | 'title' => 'Email Greeting Custom', | |
459 | 'maxlength' => 128, | |
460 | 'size' => 45, | |
461 | 'import' => TRUE, | |
462 | 'where' => 'civicrm_contact.email_greeting_custom', | |
463 | 'html' => array( | |
464 | 'type' => 'Text', | |
465 | ), | |
466 | ), | |
7a7cc10b | 467 | 'email_greeting_display' => array( |
50fb255d | 468 | 'name' => 'email_greeting_display', |
469 | 'type' => 2, | |
470 | 'title' => 'Email Greeting', | |
471 | 'maxlength' => 255, | |
472 | 'size' => 45, | |
473 | 'html' => array( | |
474 | 'type' => 'Text', | |
475 | ), | |
476 | ), | |
7a7cc10b | 477 | 'postal_greeting_id' => array( |
50fb255d | 478 | 'name' => 'postal_greeting_id', |
479 | 'type' => 1, | |
480 | 'title' => 'Postal Greeting ID', | |
481 | 'html' => array( | |
482 | 'type' => 'Text', | |
6a488035 | 483 | ), |
50fb255d | 484 | ), |
7a7cc10b | 485 | 'postal_greeting_custom' => array( |
50fb255d | 486 | 'name' => 'postal_greeting_custom', |
487 | 'type' => 2, | |
488 | 'title' => 'Postal Greeting Custom', | |
489 | 'maxlength' => 128, | |
490 | 'size' => 45, | |
491 | 'import' => TRUE, | |
492 | 'where' => 'civicrm_contact.postal_greeting_custom', | |
493 | 'html' => array( | |
494 | 'type' => 'Text', | |
495 | ), | |
496 | ), | |
7a7cc10b | 497 | 'postal_greeting_display' => array( |
50fb255d | 498 | 'name' => 'postal_greeting_display', |
499 | 'type' => 2, | |
500 | 'title' => 'Postal Greeting', | |
501 | 'maxlength' => 255, | |
502 | 'size' => 45, | |
503 | 'html' => array( | |
504 | 'type' => 'Text', | |
505 | ), | |
506 | ), | |
7a7cc10b | 507 | 'addressee_id' => array( |
50fb255d | 508 | 'name' => 'addressee_id', |
509 | 'type' => 1, | |
510 | 'title' => 'Addressee ID', | |
511 | ), | |
7a7cc10b | 512 | 'addressee_custom' => array( |
50fb255d | 513 | 'name' => 'addressee_custom', |
514 | 'type' => 2, | |
515 | 'title' => 'Addressee Custom', | |
516 | 'maxlength' => 128, | |
517 | 'size' => 45, | |
518 | 'import' => TRUE, | |
519 | 'where' => 'civicrm_contact.addressee_custom', | |
520 | 'html' => array( | |
521 | 'type' => 'Text', | |
522 | ), | |
523 | ), | |
7a7cc10b | 524 | 'addressee_display' => array( |
50fb255d | 525 | 'name' => 'addressee_display', |
526 | 'type' => 2, | |
527 | 'title' => 'Addressee', | |
528 | 'maxlength' => 255, | |
529 | 'size' => 45, | |
530 | 'html' => array( | |
531 | 'type' => 'Text', | |
532 | ), | |
533 | ), | |
7a7cc10b | 534 | 'job_title' => array( |
50fb255d | 535 | 'name' => 'job_title', |
536 | 'type' => 2, | |
537 | 'title' => 'Job Title', | |
538 | 'maxlength' => 255, | |
539 | 'size' => 20, | |
540 | 'import' => TRUE, | |
541 | 'where' => 'civicrm_contact.job_title', | |
542 | 'headerPattern' => '/^job|(j(ob\\s)?title)$/i', | |
543 | 'dataPattern' => '//', | |
544 | 'export' => TRUE, | |
545 | 'html' => array( | |
546 | 'type' => 'Text', | |
547 | ), | |
548 | ), | |
7a7cc10b | 549 | 'gender_id' => array( |
50fb255d | 550 | 'name' => 'gender_id', |
551 | 'type' => 1, | |
552 | 'title' => 'Gender', | |
553 | 'import' => TRUE, | |
554 | 'where' => 'civicrm_contact.gender_id', | |
555 | 'headerPattern' => '/^gender$/i', | |
556 | 'export' => TRUE, | |
557 | 'html' => array( | |
558 | 'type' => 'Select', | |
559 | ), | |
560 | 'pseudoconstant' => array( | |
561 | 'optionGroupName' => 'gender', | |
562 | ), | |
563 | ), | |
7a7cc10b | 564 | 'birth_date' => array( |
50fb255d | 565 | 'name' => 'birth_date', |
566 | 'type' => 4, | |
567 | 'title' => 'Birth Date', | |
568 | 'import' => TRUE, | |
569 | 'where' => 'civicrm_contact.birth_date', | |
570 | 'headerPattern' => '/^birth|(b(irth\\s)?date)|D(\\W*)O(\\W*)B(\\W*)$/i', | |
571 | 'dataPattern' => '/\\d{4}-?\\d{2}-?\\d{2}/', | |
572 | 'export' => TRUE, | |
573 | 'html' => array( | |
574 | 'type' => 'Select Date', | |
575 | ), | |
576 | ), | |
7a7cc10b | 577 | 'is_deceased' => array( |
50fb255d | 578 | 'name' => 'is_deceased', |
579 | 'type' => 16, | |
580 | 'title' => 'Is Deceased', | |
581 | 'import' => TRUE, | |
582 | 'where' => 'civicrm_contact.is_deceased', | |
583 | 'headerPattern' => '/i(s\\s)?d(eceased)$/i', | |
584 | 'export' => TRUE, | |
585 | 'html' => array( | |
586 | 'type' => 'CheckBox', | |
587 | ), | |
588 | ), | |
7a7cc10b | 589 | 'deceased_date' => array( |
50fb255d | 590 | 'name' => 'deceased_date', |
591 | 'type' => 4, | |
592 | 'title' => 'Deceased Date', | |
593 | 'import' => TRUE, | |
594 | 'where' => 'civicrm_contact.deceased_date', | |
595 | 'headerPattern' => '/^deceased|(d(eceased\\s)?date)$/i', | |
596 | 'export' => TRUE, | |
597 | 'html' => array( | |
598 | 'type' => 'Select Date', | |
599 | ), | |
600 | ), | |
7a7cc10b | 601 | 'household_name' => array( |
50fb255d | 602 | 'name' => 'household_name', |
603 | 'type' => 2, | |
604 | 'title' => 'Household Name', | |
605 | 'maxlength' => 128, | |
606 | 'size' => 30, | |
607 | 'import' => TRUE, | |
608 | 'where' => 'civicrm_contact.household_name', | |
609 | 'headerPattern' => '/^household|(h(ousehold\\s)?name)$/i', | |
610 | 'dataPattern' => '/^\\w+$/', | |
611 | 'export' => TRUE, | |
612 | 'html' => array( | |
613 | 'type' => 'Text', | |
614 | ), | |
615 | ), | |
7a7cc10b | 616 | 'primary_contact_id' => array( |
50fb255d | 617 | 'name' => 'primary_contact_id', |
618 | 'type' => 1, | |
619 | 'title' => 'Household Primary Contact ID', | |
620 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
621 | 'html' => array( | |
622 | 'type' => 'Select', | |
623 | ), | |
624 | 'FKApiName' => 'Contact', | |
625 | ), | |
7a7cc10b | 626 | 'organization_name' => array( |
50fb255d | 627 | 'name' => 'organization_name', |
628 | 'type' => 2, | |
629 | 'title' => 'Organization Name', | |
630 | 'maxlength' => 128, | |
631 | 'size' => 30, | |
632 | 'import' => TRUE, | |
633 | 'where' => 'civicrm_contact.organization_name', | |
634 | 'headerPattern' => '/^organization|(o(rganization\\s)?name)$/i', | |
635 | 'dataPattern' => '/^\\w+$/', | |
636 | 'export' => TRUE, | |
637 | 'html' => array( | |
638 | 'type' => 'Text', | |
639 | ), | |
640 | ), | |
7a7cc10b | 641 | 'sic_code' => array( |
50fb255d | 642 | 'name' => 'sic_code', |
643 | 'type' => 2, | |
644 | 'title' => 'Sic Code', | |
645 | 'maxlength' => 8, | |
646 | 'size' => 8, | |
647 | 'import' => TRUE, | |
648 | 'where' => 'civicrm_contact.sic_code', | |
649 | 'headerPattern' => '/^sic|(s(ic\\s)?code)$/i', | |
650 | 'export' => TRUE, | |
651 | 'html' => array( | |
652 | 'type' => 'Text', | |
653 | ), | |
654 | ), | |
7a7cc10b | 655 | 'user_unique_id' => array( |
50fb255d | 656 | 'name' => 'user_unique_id', |
657 | 'type' => 2, | |
658 | 'title' => 'Unique ID (OpenID)', | |
659 | 'maxlength' => 255, | |
660 | 'size' => 45, | |
661 | 'import' => TRUE, | |
662 | 'where' => 'civicrm_contact.user_unique_id', | |
663 | 'headerPattern' => '/^Open\\s?ID|u(niq\\w*)?\\s?ID/i', | |
664 | 'dataPattern' => '/^[\\w\\/\\:\\.]+$/', | |
665 | 'export' => TRUE, | |
666 | 'rule' => 'url', | |
667 | 'html' => array( | |
668 | 'type' => 'Text', | |
669 | ), | |
670 | ), | |
7a7cc10b | 671 | 'created_date' => array( |
50fb255d | 672 | 'name' => 'created_date', |
673 | 'type' => 256, | |
674 | 'title' => 'Created Date', | |
675 | 'required' => '', | |
676 | 'export' => TRUE, | |
677 | 'where' => 'civicrm_contact.created_date', | |
678 | 'default' => 'NULL', | |
679 | ), | |
7a7cc10b | 680 | 'modified_date' => array( |
50fb255d | 681 | 'name' => 'modified_date', |
682 | 'type' => 256, | |
683 | 'title' => 'Modified Date', | |
684 | 'required' => '', | |
685 | 'export' => TRUE, | |
686 | 'where' => 'civicrm_contact.modified_date', | |
687 | 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', | |
688 | ), | |
7a7cc10b | 689 | 'source' => array( |
50fb255d | 690 | 'name' => 'source', |
691 | 'type' => 2, | |
692 | 'title' => 'Source of Contact Data', | |
693 | 'maxlength' => 255, | |
694 | 'size' => 30, | |
695 | 'import' => TRUE, | |
696 | 'where' => 'civicrm_contact.source', | |
697 | 'headerPattern' => '/(S(ource\\s)?o(f\\s)?C(ontact\\s)?Data)$/i', | |
698 | 'export' => TRUE, | |
699 | 'html' => array( | |
700 | 'type' => 'Text', | |
701 | ), | |
702 | 'uniqueName' => 'contact_source', | |
703 | ), | |
7a7cc10b | 704 | 'employer_id' => array( |
50fb255d | 705 | 'name' => 'employer_id', |
706 | 'type' => 1, | |
707 | 'title' => 'Current Employer ID', | |
708 | 'export' => TRUE, | |
709 | 'where' => 'civicrm_contact.employer_id', | |
710 | 'FKClassName' => 'CRM_Contact_DAO_Contact', | |
711 | 'html' => array( | |
712 | 'type' => 'Autocomplete-Select', | |
713 | ), | |
714 | 'uniqueName' => 'current_employer_id', | |
715 | 'FKApiName' => 'Contact', | |
716 | ), | |
7a7cc10b | 717 | 'is_deleted' => array( |
50fb255d | 718 | 'name' => 'is_deleted', |
719 | 'type' => 16, | |
720 | 'title' => 'Contact is in Trash', | |
721 | 'required' => TRUE, | |
722 | 'export' => TRUE, | |
723 | 'where' => 'civicrm_contact.is_deleted', | |
724 | 'html' => array( | |
725 | 'type' => 'CheckBox', | |
726 | ), | |
727 | 'uniqueName' => 'contact_is_deleted', | |
728 | ), | |
7a7cc10b | 729 | 'custom_1' => array( |
50fb255d | 730 | 'label' => 'Our special field', |
731 | 'groupTitle' => 'select_test_g', | |
732 | 'data_type' => 'String', | |
733 | 'html_type' => 'Select', | |
734 | 'default_value' => '', | |
735 | 'text_length' => '', | |
736 | 'options_per_line' => '', | |
737 | 'custom_group_id' => '1', | |
738 | 'extends' => 'Contact', | |
739 | 'is_search_range' => 0, | |
740 | 'extends_entity_column_value' => '', | |
741 | 'extends_entity_column_id' => '', | |
742 | 'is_view' => 0, | |
743 | 'is_multiple' => 0, | |
5c49fee0 | 744 | 'option_group_id' => '106', |
50fb255d | 745 | 'date_format' => '', |
746 | 'time_format' => '', | |
747 | 'is_required' => '1', | |
748 | 'name' => 'custom_1', | |
749 | 'title' => 'Our special field', | |
750 | 'type' => 2, | |
751 | 'options' => array( | |
752 | '1' => 'Label1', | |
753 | '2' => 'Label2', | |
754 | ), | |
755 | ), | |
7a7cc10b | 756 | 'current_employer' => array( |
50fb255d | 757 | 'title' => 'Current Employer', |
758 | 'description' => 'Name of Current Employer', | |
759 | 'type' => 2, | |
5c49fee0 | 760 | 'name' => 'current_employer', |
50fb255d | 761 | ), |
7a7cc10b | 762 | 'dupe_check' => array( |
50fb255d | 763 | 'title' => 'Check for Duplicates', |
764 | 'description' => 'Throw error if contact create matches dedupe rule', | |
5c49fee0 | 765 | 'name' => 'dupe_check', |
50fb255d | 766 | ), |
6a488035 | 767 | ), |
50fb255d | 768 | ); |
6a488035 | 769 | |
fb32de45 | 770 | return $expectedResult; |
6a488035 TO |
771 | } |
772 | ||
a828d7b8 | 773 | /* |
50fb255d | 774 | * This example has been generated from the API test suite. |
a828d7b8 CW |
775 | * The test that created it is called "testCustomFieldCreateWithOptionValues" |
776 | * and can be found at: | |
69d79249 | 777 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php |
6a488035 TO |
778 | * |
779 | * You can see the outcome of the API tests at | |
69d79249 | 780 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
6a488035 TO |
781 | * |
782 | * To Learn about the API read | |
69d79249 | 783 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
6a488035 | 784 | * |
69d79249 | 785 | * Browse the api on your own site with the api explorer |
41d4d31f | 786 | * http://MYSITE.ORG/path/to/civicrm/api |
6a488035 TO |
787 | * |
788 | * Read more about testing here | |
789 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
790 | * | |
791 | * API Standards documentation: | |
792 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 793 | */ |