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