Merge branch 4.5 into master
[civicrm-core.git] / api / v3 / examples / Activity / Getfields.php
1 <?php
2 /**
3 * Test Generated example of using activity getfields API
4 * *
5 */
6 function activity_getfields_example(){
7 $params = array(
8 'action' => 'create',
9 );
10
11 try{
12 $result = civicrm_api3('activity', 'getfields', $params);
13 }
14 catch (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 }
21
22 return $result;
23 }
24
25 /**
26 * Function returns array of result expected from previous function
27 */
28 function activity_getfields_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 27,
34 'values' => array(
35 'source_record_id' => array(
36 'name' => 'source_record_id',
37 'type' => 1,
38 'title' => 'Source Record',
39 ),
40 'activity_type_id' => array(
41 'name' => 'activity_type_id',
42 'type' => 1,
43 'title' => 'Activity Type',
44 'required' => true,
45 'import' => true,
46 'where' => 'civicrm_activity.activity_type_id',
47 'headerPattern' => '/(activity.)?type(.id$)/i',
48 'default' => '1',
49 'html' => array(
50 'type' => 'Select',
51 ),
52 'pseudoconstant' => array(
53 'optionGroupName' => 'activity_type',
54 ),
55 ),
56 'activity_date_time' => array(
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,
64 'html' => array(
65 'type' => 'Select Date',
66 ),
67 ),
68 'phone_id' => array(
69 'name' => 'phone_id',
70 'type' => 1,
71 'title' => 'Phone (called) ID',
72 'FKClassName' => 'CRM_Core_DAO_Phone',
73 'html' => array(
74 'type' => 'Autocomplete-Select',
75 ),
76 ),
77 'phone_number' => array(
78 'name' => 'phone_number',
79 'type' => 2,
80 'title' => 'Phone (called) Number',
81 'maxlength' => 64,
82 'size' => 30,
83 'html' => array(
84 'type' => 'Text',
85 ),
86 ),
87 'priority_id' => array(
88 'name' => 'priority_id',
89 'type' => 1,
90 'title' => 'Priority',
91 'html' => array(
92 'type' => 'Select',
93 ),
94 'pseudoconstant' => array(
95 'optionGroupName' => 'priority',
96 ),
97 ),
98 'parent_id' => array(
99 'name' => 'parent_id',
100 'type' => 1,
101 'title' => 'Parent Activity Id',
102 'FKClassName' => 'CRM_Activity_DAO_Activity',
103 ),
104 'is_auto' => array(
105 'name' => 'is_auto',
106 'type' => 16,
107 'title' => 'Auto',
108 ),
109 'relationship_id' => array(
110 'name' => 'relationship_id',
111 'type' => 1,
112 'title' => 'Relationship Id',
113 'default' => 'NULL',
114 'FKClassName' => 'CRM_Contact_DAO_Relationship',
115 ),
116 'is_current_revision' => array(
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,
124 'default' => '1',
125 'html' => array(
126 'type' => 'CheckBox',
127 ),
128 ),
129 'original_id' => array(
130 'name' => 'original_id',
131 'type' => 1,
132 'title' => 'Original Activity ID ',
133 'FKClassName' => 'CRM_Activity_DAO_Activity',
134 ),
135 'weight' => array(
136 'name' => 'weight',
137 'type' => 1,
138 'title' => 'Weight',
139 'html' => array(
140 'type' => 'Text',
141 ),
142 ),
143 'id' => array(
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',
152 'api.aliases' => array(
153 '0' => 'activity_id',
154 ),
155 ),
156 'subject' => array(
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,
166 'html' => array(
167 'type' => 'Text',
168 ),
169 'uniqueName' => 'activity_subject',
170 ),
171 'duration' => array(
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,
179 'html' => array(
180 'type' => 'Text',
181 ),
182 'uniqueName' => 'activity_duration',
183 ),
184 'location' => array(
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,
194 'html' => array(
195 'type' => 'Text',
196 ),
197 'uniqueName' => 'activity_location',
198 ),
199 'details' => array(
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,
209 'html' => array(
210 'type' => 'RichTextEditor',
211 ),
212 'uniqueName' => 'activity_details',
213 ),
214 'status_id' => array(
215 'name' => 'status_id',
216 'type' => 1,
217 'title' => 'Activity Status',
218 'import' => true,
219 'where' => 'civicrm_activity.status_id',
220 'headerPattern' => '/(activity.)?status(.label$)?/i',
221 'html' => array(
222 'type' => 'Select',
223 ),
224 'pseudoconstant' => array(
225 'optionGroupName' => 'activity_status',
226 ),
227 'uniqueName' => 'activity_status_id',
228 'api.aliases' => array(
229 '0' => 'activity_status',
230 ),
231 ),
232 'is_test' => array(
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,
240 'html' => array(
241 'type' => 'Select',
242 ),
243 'uniqueName' => 'activity_is_test',
244 ),
245 'medium_id' => array(
246 'name' => 'medium_id',
247 'type' => 1,
248 'title' => 'Activity Medium',
249 'default' => 'NULL',
250 'html' => array(
251 'type' => 'Select',
252 ),
253 'pseudoconstant' => array(
254 'optionGroupName' => 'encounter_medium',
255 ),
256 'uniqueName' => 'activity_medium_id',
257 ),
258 'result' => array(
259 'name' => 'result',
260 'type' => 2,
261 'title' => 'Result',
262 'maxlength' => 255,
263 'size' => 45,
264 'html' => array(
265 'type' => 'Text',
266 ),
267 'uniqueName' => 'activity_result',
268 ),
269 'is_deleted' => array(
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,
277 'html' => array(
278 'type' => 'Text',
279 ),
280 'uniqueName' => 'activity_is_deleted',
281 ),
282 'campaign_id' => array(
283 'name' => 'campaign_id',
284 'type' => 1,
285 'title' => 'Campaign',
286 'import' => true,
287 'where' => 'civicrm_activity.campaign_id',
288 'export' => true,
289 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
290 'html' => array(
291 'type' => 'CheckBox',
292 ),
293 'pseudoconstant' => array(
294 'table' => 'civicrm_campaign',
295 'keyColumn' => 'id',
296 'labelColumn' => 'title',
297 ),
298 'uniqueName' => 'activity_campaign_id',
299 ),
300 'engagement_level' => array(
301 'name' => 'engagement_level',
302 'type' => 1,
303 'title' => 'Engagement Index',
304 'import' => true,
305 'where' => 'civicrm_activity.engagement_level',
306 'export' => true,
307 'html' => array(
308 'type' => 'Select',
309 ),
310 'pseudoconstant' => array(
311 'optionGroupName' => 'engagement_index',
312 ),
313 'uniqueName' => 'activity_engagement_level',
314 ),
315 'source_contact_id' => array(
316 'name' => 'source_contact_id',
317 'title' => 'Activity Source Contact',
318 'type' => 1,
319 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
320 'api.default' => 'user_contact_id',
321 ),
322 'assignee_contact_id' => array(
323 'name' => 'assignee_id',
324 'title' => 'assigned to',
325 'type' => 1,
326 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
327 ),
328 'target_contact_id' => array(
329 'name' => 'target_id',
330 'title' => 'Activity Target',
331 'type' => 1,
332 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
333 ),
334 ),
335 );
336
337 return $expectedResult;
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
345 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
346 *
347 * You can see the outcome of the API tests at
348 * https://test.civicrm.org/job/CiviCRM-master-git/
349 *
350 * To Learn about the API read
351 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
352 *
353 * Browse the api on your own site with the api explorer
354 * http://MYSITE.ORG/path/to/civicrm/api/explorer
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
361 */