Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / Activity / GetFields.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Activity.getfields API.
4 *
5 * @return array
6 * API result array
7 */
8 function activity_getfields_example() {
9 $params = [
10 'action' => 'create',
11 ];
12
13 try{
14 $result = civicrm_api3('Activity', 'getfields', $params);
15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // Handle error here.
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return [
22 'is_error' => 1,
23 'error_message' => $errorMessage,
24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 ];
27 }
28
29 return $result;
30 }
31
32 /**
33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
37 */
38 function activity_getfields_expectedresult() {
39
40 $expectedResult = [
41 'is_error' => 0,
42 'version' => 3,
43 'count' => 29,
44 'values' => [
45 'source_record_id' => [
46 'name' => 'source_record_id',
47 'type' => 1,
48 'title' => 'Source Record',
49 'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
50 'table_name' => 'civicrm_activity',
51 'entity' => 'Activity',
52 'bao' => 'CRM_Activity_BAO_Activity',
53 ],
54 'activity_type_id' => [
55 'name' => 'activity_type_id',
56 'type' => 1,
57 'title' => 'Activity Type ID',
58 'description' => 'FK to civicrm_option_value.id, that has to be valid, registered activity type.',
59 'required' => TRUE,
60 'import' => TRUE,
61 'where' => 'civicrm_activity.activity_type_id',
62 'headerPattern' => '/(activity.)?type(.id$)/i',
63 'export' => TRUE,
64 'default' => '1',
65 'table_name' => 'civicrm_activity',
66 'entity' => 'Activity',
67 'bao' => 'CRM_Activity_BAO_Activity',
68 'html' => [
69 'type' => 'Select',
70 'size' => 6,
71 'maxlength' => 14,
72 ],
73 'pseudoconstant' => [
74 'optionGroupName' => 'activity_type',
75 'optionEditPath' => 'civicrm/admin/options/activity_type',
76 ],
77 ],
78 'activity_date_time' => [
79 'name' => 'activity_date_time',
80 'type' => 12,
81 'title' => 'Activity Date',
82 'description' => 'Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.',
83 'import' => TRUE,
84 'where' => 'civicrm_activity.activity_date_time',
85 'headerPattern' => '/(activity.)?date(.time$)?/i',
86 'export' => TRUE,
87 'table_name' => 'civicrm_activity',
88 'entity' => 'Activity',
89 'bao' => 'CRM_Activity_BAO_Activity',
90 'html' => [
91 'type' => 'Select Date',
92 'format' => 'activityDateTime',
93 ],
94 ],
95 'phone_id' => [
96 'name' => 'phone_id',
97 'type' => 1,
98 'title' => 'Phone (called) ID',
99 'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
100 'table_name' => 'civicrm_activity',
101 'entity' => 'Activity',
102 'bao' => 'CRM_Activity_BAO_Activity',
103 'FKClassName' => 'CRM_Core_DAO_Phone',
104 'html' => [
105 'type' => 'EntityRef',
106 'size' => 6,
107 'maxlength' => 14,
108 ],
109 'FKApiName' => 'Phone',
110 ],
111 'phone_number' => [
112 'name' => 'phone_number',
113 'type' => 2,
114 'title' => 'Phone (called) Number',
115 'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
116 'maxlength' => 64,
117 'size' => 30,
118 'table_name' => 'civicrm_activity',
119 'entity' => 'Activity',
120 'bao' => 'CRM_Activity_BAO_Activity',
121 'html' => [
122 'type' => 'Text',
123 'maxlength' => 64,
124 'size' => 30,
125 ],
126 ],
127 'priority_id' => [
128 'name' => 'priority_id',
129 'type' => 1,
130 'title' => 'Priority',
131 'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
132 'table_name' => 'civicrm_activity',
133 'entity' => 'Activity',
134 'bao' => 'CRM_Activity_BAO_Activity',
135 'html' => [
136 'type' => 'Select',
137 'size' => 6,
138 'maxlength' => 14,
139 ],
140 'pseudoconstant' => [
141 'optionGroupName' => 'priority',
142 'optionEditPath' => 'civicrm/admin/options/priority',
143 ],
144 ],
145 'parent_id' => [
146 'name' => 'parent_id',
147 'type' => 1,
148 'title' => 'Parent Activity Id',
149 'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
150 'table_name' => 'civicrm_activity',
151 'entity' => 'Activity',
152 'bao' => 'CRM_Activity_BAO_Activity',
153 'FKClassName' => 'CRM_Activity_DAO_Activity',
154 'FKApiName' => 'Activity',
155 ],
156 'is_auto' => [
157 'name' => 'is_auto',
158 'type' => 16,
159 'title' => 'Auto',
160 'table_name' => 'civicrm_activity',
161 'entity' => 'Activity',
162 'bao' => 'CRM_Activity_BAO_Activity',
163 ],
164 'relationship_id' => [
165 'name' => 'relationship_id',
166 'type' => 1,
167 'title' => 'Relationship Id',
168 'description' => 'FK to Relationship ID',
169 'default' => 'NULL',
170 'table_name' => 'civicrm_activity',
171 'entity' => 'Activity',
172 'bao' => 'CRM_Activity_BAO_Activity',
173 'FKClassName' => 'CRM_Contact_DAO_Relationship',
174 'FKApiName' => 'Relationship',
175 ],
176 'is_current_revision' => [
177 'name' => 'is_current_revision',
178 'type' => 16,
179 'title' => 'Is this activity a current revision in versioning chain?',
180 'import' => TRUE,
181 'where' => 'civicrm_activity.is_current_revision',
182 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
183 'export' => TRUE,
184 'default' => '1',
185 'table_name' => 'civicrm_activity',
186 'entity' => 'Activity',
187 'bao' => 'CRM_Activity_BAO_Activity',
188 'html' => [
189 'type' => 'CheckBox',
190 ],
191 ],
192 'original_id' => [
193 'name' => 'original_id',
194 'type' => 1,
195 'title' => 'Original Activity ID ',
196 'description' => 'Activity ID of the first activity record in versioning chain.',
197 'table_name' => 'civicrm_activity',
198 'entity' => 'Activity',
199 'bao' => 'CRM_Activity_BAO_Activity',
200 'FKClassName' => 'CRM_Activity_DAO_Activity',
201 'FKApiName' => 'Activity',
202 ],
203 'weight' => [
204 'name' => 'weight',
205 'type' => 1,
206 'title' => 'Order',
207 'table_name' => 'civicrm_activity',
208 'entity' => 'Activity',
209 'bao' => 'CRM_Activity_BAO_Activity',
210 'html' => [
211 'type' => 'Text',
212 'size' => 6,
213 'maxlength' => 14,
214 ],
215 ],
216 'is_star' => [
217 'name' => 'is_star',
218 'type' => 16,
219 'title' => 'Is Starred',
220 'description' => 'Activity marked as favorite.',
221 'import' => TRUE,
222 'where' => 'civicrm_activity.is_star',
223 'headerPattern' => '/(activity.)?(star|favorite)/i',
224 'export' => TRUE,
225 'table_name' => 'civicrm_activity',
226 'entity' => 'Activity',
227 'bao' => 'CRM_Activity_BAO_Activity',
228 ],
229 'id' => [
230 'name' => 'id',
231 'type' => 1,
232 'title' => 'Activity ID',
233 'description' => 'Unique Other Activity ID',
234 'required' => TRUE,
235 'import' => TRUE,
236 'where' => 'civicrm_activity.id',
237 'export' => TRUE,
238 'table_name' => 'civicrm_activity',
239 'entity' => 'Activity',
240 'bao' => 'CRM_Activity_BAO_Activity',
241 'uniqueName' => 'activity_id',
242 'api.aliases' => [
243 '0' => 'activity_id',
244 ],
245 ],
246 'subject' => [
247 'name' => 'subject',
248 'type' => 2,
249 'title' => 'Subject',
250 'description' => 'The subject/purpose/short description of the activity.',
251 'maxlength' => 255,
252 'size' => 45,
253 'import' => TRUE,
254 'where' => 'civicrm_activity.subject',
255 'headerPattern' => '/(activity.)?subject/i',
256 'export' => TRUE,
257 'table_name' => 'civicrm_activity',
258 'entity' => 'Activity',
259 'bao' => 'CRM_Activity_BAO_Activity',
260 'html' => [
261 'type' => 'Text',
262 'maxlength' => 255,
263 'size' => 45,
264 ],
265 'uniqueName' => 'activity_subject',
266 ],
267 'duration' => [
268 'name' => 'duration',
269 'type' => 1,
270 'title' => 'Duration',
271 'description' => 'Planned or actual duration of activity expressed in minutes. Conglomerate of former duration_hours and duration_minutes.',
272 'import' => TRUE,
273 'where' => 'civicrm_activity.duration',
274 'headerPattern' => '/(activity.)?duration(s)?$/i',
275 'export' => TRUE,
276 'table_name' => 'civicrm_activity',
277 'entity' => 'Activity',
278 'bao' => 'CRM_Activity_BAO_Activity',
279 'html' => [
280 'type' => 'Text',
281 'size' => 6,
282 'maxlength' => 14,
283 ],
284 'uniqueName' => 'activity_duration',
285 ],
286 'location' => [
287 'name' => 'location',
288 'type' => 2,
289 'title' => 'Location',
290 'description' => 'Location of the activity (optional, open text).',
291 'maxlength' => 255,
292 'size' => 45,
293 'import' => TRUE,
294 'where' => 'civicrm_activity.location',
295 'headerPattern' => '/(activity.)?location$/i',
296 'export' => TRUE,
297 'table_name' => 'civicrm_activity',
298 'entity' => 'Activity',
299 'bao' => 'CRM_Activity_BAO_Activity',
300 'html' => [
301 'type' => 'Text',
302 'maxlength' => 255,
303 'size' => 45,
304 ],
305 'uniqueName' => 'activity_location',
306 ],
307 'details' => [
308 'name' => 'details',
309 'type' => 32,
310 'title' => 'Details',
311 'description' => 'Details about the activity (agenda, notes, etc).',
312 'import' => TRUE,
313 'where' => 'civicrm_activity.details',
314 'headerPattern' => '/(activity.)?detail(s)?$/i',
315 'export' => TRUE,
316 'table_name' => 'civicrm_activity',
317 'entity' => 'Activity',
318 'bao' => 'CRM_Activity_BAO_Activity',
319 'html' => [
320 'type' => 'RichTextEditor',
321 'rows' => 2,
322 'cols' => 80,
323 ],
324 'uniqueName' => 'activity_details',
325 ],
326 'status_id' => [
327 'name' => 'status_id',
328 'type' => 1,
329 'title' => 'Activity Status',
330 'description' => 'ID of the status this activity is currently in. Foreign key to civicrm_option_value.',
331 'import' => TRUE,
332 'where' => 'civicrm_activity.status_id',
333 'headerPattern' => '/(activity.)?status(.label$)?/i',
334 'table_name' => 'civicrm_activity',
335 'entity' => 'Activity',
336 'bao' => 'CRM_Activity_BAO_Activity',
337 'html' => [
338 'type' => 'Select',
339 'size' => 6,
340 'maxlength' => 14,
341 ],
342 'pseudoconstant' => [
343 'optionGroupName' => 'activity_status',
344 'optionEditPath' => 'civicrm/admin/options/activity_status',
345 ],
346 'uniqueName' => 'activity_status_id',
347 'api.aliases' => [
348 '0' => 'activity_status',
349 ],
350 ],
351 'is_test' => [
352 'name' => 'is_test',
353 'type' => 16,
354 'title' => 'Test',
355 'import' => TRUE,
356 'where' => 'civicrm_activity.is_test',
357 'headerPattern' => '/(is.)?test(.activity)?/i',
358 'export' => TRUE,
359 'table_name' => 'civicrm_activity',
360 'entity' => 'Activity',
361 'bao' => 'CRM_Activity_BAO_Activity',
362 'html' => [
363 'type' => 'Select',
364 ],
365 'uniqueName' => 'activity_is_test',
366 ],
367 'medium_id' => [
368 'name' => 'medium_id',
369 'type' => 1,
370 'title' => 'Activity Medium',
371 'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
372 'default' => 'NULL',
373 'table_name' => 'civicrm_activity',
374 'entity' => 'Activity',
375 'bao' => 'CRM_Activity_BAO_Activity',
376 'html' => [
377 'type' => 'Select',
378 'size' => 6,
379 'maxlength' => 14,
380 ],
381 'pseudoconstant' => [
382 'optionGroupName' => 'encounter_medium',
383 'optionEditPath' => 'civicrm/admin/options/encounter_medium',
384 ],
385 'uniqueName' => 'activity_medium_id',
386 ],
387 'result' => [
388 'name' => 'result',
389 'type' => 2,
390 'title' => 'Result',
391 'description' => 'Currently being used to store result id for survey activity, FK to option value.',
392 'maxlength' => 255,
393 'size' => 45,
394 'table_name' => 'civicrm_activity',
395 'entity' => 'Activity',
396 'bao' => 'CRM_Activity_BAO_Activity',
397 'html' => [
398 'type' => 'Text',
399 'maxlength' => 255,
400 'size' => 45,
401 ],
402 'uniqueName' => 'activity_result',
403 ],
404 'is_deleted' => [
405 'name' => 'is_deleted',
406 'type' => 16,
407 'title' => 'Activity is in the Trash',
408 'import' => TRUE,
409 'where' => 'civicrm_activity.is_deleted',
410 'headerPattern' => '/(activity.)?(trash|deleted)/i',
411 'export' => TRUE,
412 'table_name' => 'civicrm_activity',
413 'entity' => 'Activity',
414 'bao' => 'CRM_Activity_BAO_Activity',
415 'html' => [
416 'type' => 'Text',
417 ],
418 'uniqueName' => 'activity_is_deleted',
419 ],
420 'campaign_id' => [
421 'name' => 'campaign_id',
422 'type' => 1,
423 'title' => 'Campaign',
424 'description' => 'The campaign for which this activity has been triggered.',
425 'import' => TRUE,
426 'where' => 'civicrm_activity.campaign_id',
427 'export' => TRUE,
428 'table_name' => 'civicrm_activity',
429 'entity' => 'Activity',
430 'bao' => 'CRM_Activity_BAO_Activity',
431 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
432 'html' => [
433 'type' => 'CheckBox',
434 'size' => 6,
435 'maxlength' => 14,
436 ],
437 'pseudoconstant' => [
438 'table' => 'civicrm_campaign',
439 'keyColumn' => 'id',
440 'labelColumn' => 'title',
441 ],
442 'uniqueName' => 'activity_campaign_id',
443 'FKApiName' => 'Campaign',
444 ],
445 'engagement_level' => [
446 'name' => 'engagement_level',
447 'type' => 1,
448 'title' => 'Engagement Index',
449 'description' => 'Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.',
450 'import' => TRUE,
451 'where' => 'civicrm_activity.engagement_level',
452 'export' => TRUE,
453 'table_name' => 'civicrm_activity',
454 'entity' => 'Activity',
455 'bao' => 'CRM_Activity_BAO_Activity',
456 'html' => [
457 'type' => 'Select',
458 'size' => 6,
459 'maxlength' => 14,
460 ],
461 'pseudoconstant' => [
462 'optionGroupName' => 'engagement_index',
463 'optionEditPath' => 'civicrm/admin/options/engagement_index',
464 ],
465 'uniqueName' => 'activity_engagement_level',
466 ],
467 'source_contact_id' => [
468 'name' => 'source_contact_id',
469 'title' => 'Activity Source Contact',
470 'description' => 'Person who created this activity. Defaults to current user.',
471 'type' => 1,
472 'FKClassName' => 'CRM_Contact_DAO_Contact',
473 'api.default' => 'user_contact_id',
474 'FKApiName' => 'Contact',
475 ],
476 'assignee_contact_id' => [
477 'name' => 'assignee_id',
478 'title' => 'Activity Assignee',
479 'description' => 'Contact(s) assigned to this activity.',
480 'type' => 1,
481 'FKClassName' => 'CRM_Contact_DAO_Contact',
482 'FKApiName' => 'Contact',
483 ],
484 'target_contact_id' => [
485 'name' => 'target_id',
486 'title' => 'Activity Target',
487 'description' => 'Contact(s) participating in this activity.',
488 'type' => 1,
489 'FKClassName' => 'CRM_Contact_DAO_Contact',
490 'FKApiName' => 'Contact',
491 ],
492 'case_id' => [
493 'name' => 'case_id',
494 'title' => 'Case ID',
495 'description' => 'For creating an activity as part of a case.',
496 'type' => 1,
497 'FKClassName' => 'CRM_Case_DAO_Case',
498 'FKApiName' => 'Case',
499 ],
500 ],
501 ];
502
503 return $expectedResult;
504 }
505
506 /*
507 * This example has been generated from the API test suite.
508 * The test that created it is called "testGetFields"
509 * and can be found at:
510 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
511 *
512 * You can see the outcome of the API tests at
513 * https://test.civicrm.org/job/CiviCRM-master-git/
514 *
515 * To Learn about the API read
516 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
517 *
518 * Browse the api on your own site with the api explorer
519 * http://MYSITE.ORG/path/to/civicrm/api
520 *
521 * Read more about testing here
522 * http://wiki.civicrm.org/confluence/display/CRM/Testing
523 *
524 * API Standards documentation:
525 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
526 */