Commit | Line | Data |
---|---|---|
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 | */ | |
8 | function activity_getfields_example() { | |
9 | $params = array( | |
10 | 'action' => 'create', | |
11 | ); | |
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(); | |
21 | return array( | |
22 | 'error' => $errorMessage, | |
23 | 'error_code' => $errorCode, | |
24 | 'error_data' => $errorData, | |
25 | ); | |
26 | } | |
22fd1690 | 27 | |
50fb255d | 28 | return $result; |
22fd1690 ARW |
29 | } |
30 | ||
fb32de45 | 31 | /** |
50fb255d | 32 | * Function returns array of result expected from previous function. |
33 | * | |
34 | * @return array | |
35 | * API result array | |
22fd1690 | 36 | */ |
50fb255d | 37 | function activity_getfields_expectedresult() { |
22fd1690 | 38 | |
feb2a730 | 39 | $expectedResult = array( |
50fb255d | 40 | 'is_error' => 0, |
41 | 'version' => 3, | |
42 | 'count' => 27, | |
43 | 'values' => array( | |
feb2a730 | 44 | 'source_record_id' => array( |
50fb255d | 45 | 'name' => 'source_record_id', |
46 | 'type' => 1, | |
47 | 'title' => 'Source Record', | |
48 | ), | |
feb2a730 | 49 | 'activity_type_id' => array( |
50fb255d | 50 | 'name' => 'activity_type_id', |
51 | 'type' => 1, | |
5c49fee0 | 52 | 'title' => 'Activity Type ID', |
50fb255d | 53 | 'required' => TRUE, |
54 | 'import' => TRUE, | |
55 | 'where' => 'civicrm_activity.activity_type_id', | |
56 | 'headerPattern' => '/(activity.)?type(.id$)/i', | |
5c49fee0 | 57 | 'export' => TRUE, |
50fb255d | 58 | 'default' => '1', |
59 | 'html' => array( | |
60 | 'type' => 'Select', | |
22fd1690 | 61 | ), |
50fb255d | 62 | 'pseudoconstant' => array( |
63 | 'optionGroupName' => 'activity_type', | |
64 | ), | |
65 | ), | |
feb2a730 | 66 | 'activity_date_time' => array( |
50fb255d | 67 | 'name' => 'activity_date_time', |
68 | 'type' => 12, | |
69 | 'title' => 'Activity Date', | |
70 | 'import' => TRUE, | |
71 | 'where' => 'civicrm_activity.activity_date_time', | |
72 | 'headerPattern' => '/(activity.)?date(.time$)?/i', | |
73 | 'export' => TRUE, | |
74 | 'html' => array( | |
75 | 'type' => 'Select Date', | |
22fd1690 | 76 | ), |
50fb255d | 77 | ), |
feb2a730 | 78 | 'phone_id' => array( |
50fb255d | 79 | 'name' => 'phone_id', |
80 | 'type' => 1, | |
81 | 'title' => 'Phone (called) ID', | |
82 | 'FKClassName' => 'CRM_Core_DAO_Phone', | |
83 | 'html' => array( | |
84 | 'type' => 'Autocomplete-Select', | |
22fd1690 | 85 | ), |
50fb255d | 86 | 'FKApiName' => 'Phone', |
87 | ), | |
feb2a730 | 88 | 'phone_number' => array( |
50fb255d | 89 | 'name' => 'phone_number', |
90 | 'type' => 2, | |
91 | 'title' => 'Phone (called) Number', | |
92 | 'maxlength' => 64, | |
93 | 'size' => 30, | |
94 | 'html' => array( | |
95 | 'type' => 'Text', | |
22fd1690 | 96 | ), |
50fb255d | 97 | ), |
feb2a730 | 98 | 'priority_id' => array( |
50fb255d | 99 | 'name' => 'priority_id', |
100 | 'type' => 1, | |
101 | 'title' => 'Priority', | |
102 | 'html' => array( | |
103 | 'type' => 'Select', | |
22fd1690 | 104 | ), |
50fb255d | 105 | 'pseudoconstant' => array( |
106 | 'optionGroupName' => 'priority', | |
22fd1690 | 107 | ), |
50fb255d | 108 | ), |
109 | 'parent_id' => array( | |
110 | 'name' => 'parent_id', | |
111 | 'type' => 1, | |
112 | 'title' => 'Parent Activity Id', | |
113 | 'FKClassName' => 'CRM_Activity_DAO_Activity', | |
114 | 'FKApiName' => 'Activity', | |
115 | ), | |
feb2a730 | 116 | 'is_auto' => array( |
50fb255d | 117 | 'name' => 'is_auto', |
118 | 'type' => 16, | |
119 | 'title' => 'Auto', | |
120 | ), | |
feb2a730 | 121 | 'relationship_id' => array( |
50fb255d | 122 | 'name' => 'relationship_id', |
123 | 'type' => 1, | |
124 | 'title' => 'Relationship Id', | |
125 | 'default' => 'NULL', | |
126 | 'FKClassName' => 'CRM_Contact_DAO_Relationship', | |
127 | 'FKApiName' => 'Relationship', | |
128 | ), | |
feb2a730 | 129 | 'is_current_revision' => array( |
50fb255d | 130 | 'name' => 'is_current_revision', |
131 | 'type' => 16, | |
132 | 'title' => 'Is this activity a current revision in versioning chain?', | |
133 | 'import' => TRUE, | |
134 | 'where' => 'civicrm_activity.is_current_revision', | |
135 | 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i', | |
136 | 'export' => TRUE, | |
137 | 'default' => '1', | |
138 | 'html' => array( | |
139 | 'type' => 'CheckBox', | |
22fd1690 | 140 | ), |
50fb255d | 141 | ), |
feb2a730 | 142 | 'original_id' => array( |
50fb255d | 143 | 'name' => 'original_id', |
144 | 'type' => 1, | |
145 | 'title' => 'Original Activity ID ', | |
146 | 'FKClassName' => 'CRM_Activity_DAO_Activity', | |
147 | 'FKApiName' => 'Activity', | |
148 | ), | |
feb2a730 | 149 | 'weight' => array( |
50fb255d | 150 | 'name' => 'weight', |
151 | 'type' => 1, | |
5c49fee0 | 152 | 'title' => 'Order', |
50fb255d | 153 | 'html' => array( |
154 | 'type' => 'Text', | |
22fd1690 | 155 | ), |
50fb255d | 156 | ), |
feb2a730 | 157 | 'id' => array( |
50fb255d | 158 | 'name' => 'id', |
159 | 'type' => 1, | |
160 | 'title' => 'Activity ID', | |
161 | 'required' => TRUE, | |
162 | 'import' => TRUE, | |
163 | 'where' => 'civicrm_activity.id', | |
164 | 'export' => TRUE, | |
165 | 'uniqueName' => 'activity_id', | |
166 | 'api.aliases' => array( | |
167 | '0' => 'activity_id', | |
22fd1690 | 168 | ), |
50fb255d | 169 | ), |
feb2a730 | 170 | 'subject' => array( |
50fb255d | 171 | 'name' => 'subject', |
172 | 'type' => 2, | |
173 | 'title' => 'Subject', | |
174 | 'maxlength' => 255, | |
175 | 'size' => 45, | |
176 | 'import' => TRUE, | |
177 | 'where' => 'civicrm_activity.subject', | |
178 | 'headerPattern' => '/(activity.)?subject/i', | |
179 | 'export' => TRUE, | |
180 | 'html' => array( | |
181 | 'type' => 'Text', | |
22fd1690 | 182 | ), |
50fb255d | 183 | 'uniqueName' => 'activity_subject', |
184 | ), | |
feb2a730 | 185 | 'duration' => array( |
50fb255d | 186 | 'name' => 'duration', |
187 | 'type' => 1, | |
188 | 'title' => 'Duration', | |
189 | 'import' => TRUE, | |
190 | 'where' => 'civicrm_activity.duration', | |
191 | 'headerPattern' => '/(activity.)?duration(s)?$/i', | |
192 | 'export' => TRUE, | |
193 | 'html' => array( | |
194 | 'type' => 'Text', | |
22fd1690 | 195 | ), |
50fb255d | 196 | 'uniqueName' => 'activity_duration', |
197 | ), | |
feb2a730 | 198 | 'location' => array( |
50fb255d | 199 | 'name' => 'location', |
200 | 'type' => 2, | |
201 | 'title' => 'Location', | |
202 | 'maxlength' => 255, | |
203 | 'size' => 45, | |
204 | 'import' => TRUE, | |
205 | 'where' => 'civicrm_activity.location', | |
206 | 'headerPattern' => '/(activity.)?location$/i', | |
207 | 'export' => TRUE, | |
208 | 'html' => array( | |
209 | 'type' => 'Text', | |
22fd1690 | 210 | ), |
50fb255d | 211 | 'uniqueName' => 'activity_location', |
212 | ), | |
feb2a730 | 213 | 'details' => array( |
50fb255d | 214 | 'name' => 'details', |
215 | 'type' => 32, | |
216 | 'title' => 'Details', | |
217 | 'rows' => 8, | |
218 | 'cols' => 60, | |
219 | 'import' => TRUE, | |
220 | 'where' => 'civicrm_activity.details', | |
221 | 'headerPattern' => '/(activity.)?detail(s)?$/i', | |
222 | 'export' => TRUE, | |
223 | 'html' => array( | |
224 | 'type' => 'RichTextEditor', | |
22fd1690 | 225 | ), |
50fb255d | 226 | 'uniqueName' => 'activity_details', |
227 | ), | |
feb2a730 | 228 | 'status_id' => array( |
50fb255d | 229 | 'name' => 'status_id', |
230 | 'type' => 1, | |
231 | 'title' => 'Activity Status', | |
232 | 'import' => TRUE, | |
233 | 'where' => 'civicrm_activity.status_id', | |
234 | 'headerPattern' => '/(activity.)?status(.label$)?/i', | |
235 | 'html' => array( | |
236 | 'type' => 'Select', | |
22fd1690 | 237 | ), |
50fb255d | 238 | 'pseudoconstant' => array( |
239 | 'optionGroupName' => 'activity_status', | |
240 | ), | |
241 | 'uniqueName' => 'activity_status_id', | |
242 | 'api.aliases' => array( | |
243 | '0' => 'activity_status', | |
244 | ), | |
245 | ), | |
feb2a730 | 246 | 'is_test' => array( |
50fb255d | 247 | 'name' => 'is_test', |
248 | 'type' => 16, | |
249 | 'title' => 'Test', | |
250 | 'import' => TRUE, | |
251 | 'where' => 'civicrm_activity.is_test', | |
252 | 'headerPattern' => '/(is.)?test(.activity)?/i', | |
253 | 'export' => TRUE, | |
254 | 'html' => array( | |
255 | 'type' => 'Select', | |
22fd1690 | 256 | ), |
50fb255d | 257 | 'uniqueName' => 'activity_is_test', |
258 | ), | |
feb2a730 | 259 | 'medium_id' => array( |
50fb255d | 260 | 'name' => 'medium_id', |
261 | 'type' => 1, | |
262 | 'title' => 'Activity Medium', | |
263 | 'default' => 'NULL', | |
264 | 'html' => array( | |
265 | 'type' => 'Select', | |
266 | ), | |
267 | 'pseudoconstant' => array( | |
268 | 'optionGroupName' => 'encounter_medium', | |
22fd1690 | 269 | ), |
50fb255d | 270 | 'uniqueName' => 'activity_medium_id', |
271 | ), | |
feb2a730 | 272 | 'result' => array( |
50fb255d | 273 | 'name' => 'result', |
274 | 'type' => 2, | |
275 | 'title' => 'Result', | |
276 | 'maxlength' => 255, | |
277 | 'size' => 45, | |
278 | 'html' => array( | |
279 | 'type' => 'Text', | |
22fd1690 | 280 | ), |
50fb255d | 281 | 'uniqueName' => 'activity_result', |
282 | ), | |
feb2a730 | 283 | 'is_deleted' => array( |
50fb255d | 284 | 'name' => 'is_deleted', |
285 | 'type' => 16, | |
286 | 'title' => 'Activity is in the Trash', | |
287 | 'import' => TRUE, | |
288 | 'where' => 'civicrm_activity.is_deleted', | |
289 | 'headerPattern' => '/(activity.)?(trash|deleted)/i', | |
290 | 'export' => TRUE, | |
291 | 'html' => array( | |
292 | 'type' => 'Text', | |
22fd1690 | 293 | ), |
50fb255d | 294 | 'uniqueName' => 'activity_is_deleted', |
295 | ), | |
feb2a730 | 296 | 'campaign_id' => array( |
50fb255d | 297 | 'name' => 'campaign_id', |
298 | 'type' => 1, | |
299 | 'title' => 'Campaign', | |
300 | 'import' => TRUE, | |
301 | 'where' => 'civicrm_activity.campaign_id', | |
302 | 'export' => TRUE, | |
303 | 'FKClassName' => 'CRM_Campaign_DAO_Campaign', | |
304 | 'html' => array( | |
305 | 'type' => 'CheckBox', | |
22fd1690 | 306 | ), |
50fb255d | 307 | 'pseudoconstant' => array( |
308 | 'table' => 'civicrm_campaign', | |
309 | 'keyColumn' => 'id', | |
310 | 'labelColumn' => 'title', | |
311 | ), | |
312 | 'uniqueName' => 'activity_campaign_id', | |
313 | 'FKApiName' => 'Campaign', | |
314 | ), | |
feb2a730 | 315 | 'engagement_level' => array( |
50fb255d | 316 | 'name' => 'engagement_level', |
317 | 'type' => 1, | |
318 | 'title' => 'Engagement Index', | |
319 | 'import' => TRUE, | |
320 | 'where' => 'civicrm_activity.engagement_level', | |
321 | 'export' => TRUE, | |
322 | 'html' => array( | |
323 | 'type' => 'Select', | |
22fd1690 | 324 | ), |
50fb255d | 325 | 'pseudoconstant' => array( |
326 | 'optionGroupName' => 'engagement_index', | |
22fd1690 | 327 | ), |
50fb255d | 328 | 'uniqueName' => 'activity_engagement_level', |
329 | ), | |
330 | 'source_contact_id' => array( | |
331 | 'name' => 'source_contact_id', | |
332 | 'title' => 'Activity Source Contact', | |
333 | 'type' => 1, | |
334 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', | |
335 | 'api.default' => 'user_contact_id', | |
336 | ), | |
feb2a730 | 337 | 'assignee_contact_id' => array( |
50fb255d | 338 | 'name' => 'assignee_id', |
339 | 'title' => 'assigned to', | |
340 | 'type' => 1, | |
341 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', | |
342 | ), | |
feb2a730 | 343 | 'target_contact_id' => array( |
50fb255d | 344 | 'name' => 'target_id', |
345 | 'title' => 'Activity Target', | |
346 | 'type' => 1, | |
347 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', | |
348 | ), | |
22fd1690 | 349 | ), |
50fb255d | 350 | ); |
22fd1690 | 351 | |
fb32de45 | 352 | return $expectedResult; |
22fd1690 ARW |
353 | } |
354 | ||
a828d7b8 | 355 | /* |
50fb255d | 356 | * This example has been generated from the API test suite. |
a828d7b8 CW |
357 | * The test that created it is called "testGetFields" |
358 | * and can be found at: | |
69d79249 | 359 | * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php |
22fd1690 ARW |
360 | * |
361 | * You can see the outcome of the API tests at | |
69d79249 | 362 | * https://test.civicrm.org/job/CiviCRM-master-git/ |
22fd1690 ARW |
363 | * |
364 | * To Learn about the API read | |
69d79249 | 365 | * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API |
22fd1690 | 366 | * |
69d79249 | 367 | * Browse the api on your own site with the api explorer |
41d4d31f | 368 | * http://MYSITE.ORG/path/to/civicrm/api |
22fd1690 ARW |
369 | * |
370 | * Read more about testing here | |
371 | * http://wiki.civicrm.org/confluence/display/CRM/Testing | |
372 | * | |
373 | * API Standards documentation: | |
374 | * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards | |
b259a4ab | 375 | */ |