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