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