Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-07-31-15-53-16
[civicrm-core.git] / api / v3 / examples / ActivityGetfields.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 ID',
44 'required' => true,
45 'import' => true,
46 'where' => 'civicrm_activity.activity_type_id',
47 'headerPattern' => '/(activity.)?type(.id$)/i',
48 'pseudoconstant' => array(
49 'optionGroupName' => 'activity_type',
50 ),
51 ),
52 'activity_date_time' => array(
53 'name' => 'activity_date_time',
54 'type' => 12,
55 'title' => 'Activity Date',
56 'import' => true,
57 'where' => 'civicrm_activity.activity_date_time',
58 'headerPattern' => '/(activity.)?date(.time$)?/i',
59 'export' => true,
60 ),
61 'phone_id' => array(
62 'name' => 'phone_id',
63 'type' => 1,
64 'title' => 'Phone (called) ID',
65 'FKClassName' => 'CRM_Core_DAO_Phone',
66 ),
67 'phone_number' => array(
68 'name' => 'phone_number',
69 'type' => 2,
70 'title' => 'Phone (called) Number',
71 'maxlength' => 64,
72 'size' => 30,
73 ),
74 'priority_id' => array(
75 'name' => 'priority_id',
76 'type' => 1,
77 'title' => 'Priority',
78 'pseudoconstant' => array(
79 'optionGroupName' => 'priority',
80 ),
81 ),
82 'parent_id' => array(
83 'name' => 'parent_id',
84 'type' => 1,
85 'title' => 'Parent Activity Id',
86 'FKClassName' => 'CRM_Activity_DAO_Activity',
87 ),
88 'is_auto' => array(
89 'name' => 'is_auto',
90 'type' => 16,
91 'title' => 'Auto',
92 ),
93 'relationship_id' => array(
94 'name' => 'relationship_id',
95 'type' => 1,
96 'title' => 'Relationship Id',
97 'default' => 'UL',
98 'FKClassName' => 'CRM_Contact_DAO_Relationship',
99 ),
100 'is_current_revision' => array(
101 'name' => 'is_current_revision',
102 'type' => 16,
103 'title' => 'Is this activity a current revision in versioning chain?',
104 'import' => true,
105 'where' => 'civicrm_activity.is_current_revision',
106 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
107 'export' => true,
108 ),
109 'original_id' => array(
110 'name' => 'original_id',
111 'type' => 1,
112 'title' => 'Original Activity ID ',
113 'FKClassName' => 'CRM_Activity_DAO_Activity',
114 ),
115 'weight' => array(
116 'name' => 'weight',
117 'type' => 1,
118 'title' => 'Weight',
119 ),
120 'id' => array(
121 'name' => 'id',
122 'type' => 1,
123 'title' => 'Activity ID',
124 'required' => true,
125 'import' => true,
126 'where' => 'civicrm_activity.id',
127 'export' => true,
128 'uniqueName' => 'activity_id',
129 'api.aliases' => array(
130 '0' => 'activity_id',
131 ),
132 ),
133 'subject' => array(
134 'name' => 'subject',
135 'type' => 2,
136 'title' => 'Subject',
137 'maxlength' => 255,
138 'size' => 45,
139 'import' => true,
140 'where' => 'civicrm_activity.subject',
141 'headerPattern' => '/(activity.)?subject/i',
142 'export' => true,
143 'uniqueName' => 'activity_subject',
144 ),
145 'duration' => array(
146 'name' => 'duration',
147 'type' => 1,
148 'title' => 'Duration',
149 'import' => true,
150 'where' => 'civicrm_activity.duration',
151 'headerPattern' => '/(activity.)?duration(s)?$/i',
152 'export' => true,
153 'uniqueName' => 'activity_duration',
154 ),
155 'location' => array(
156 'name' => 'location',
157 'type' => 2,
158 'title' => 'Location',
159 'maxlength' => 255,
160 'size' => 45,
161 'import' => true,
162 'where' => 'civicrm_activity.location',
163 'headerPattern' => '/(activity.)?location$/i',
164 'export' => true,
165 'uniqueName' => 'activity_location',
166 ),
167 'details' => array(
168 'name' => 'details',
169 'type' => 32,
170 'title' => 'Details',
171 'rows' => 8,
172 'cols' => 60,
173 'import' => true,
174 'where' => 'civicrm_activity.details',
175 'headerPattern' => '/(activity.)?detail(s)?$/i',
176 'export' => true,
177 'uniqueName' => 'activity_details',
178 ),
179 'status_id' => array(
180 'name' => 'status_id',
181 'type' => 1,
182 'title' => 'Activity Status Id',
183 'import' => true,
184 'where' => 'civicrm_activity.status_id',
185 'headerPattern' => '/(activity.)?status(.label$)?/i',
186 'pseudoconstant' => array(
187 'optionGroupName' => 'activity_status',
188 ),
189 'uniqueName' => 'activity_status_id',
190 ),
191 'is_test' => array(
192 'name' => 'is_test',
193 'type' => 16,
194 'title' => 'Test',
195 'import' => true,
196 'where' => 'civicrm_activity.is_test',
197 'headerPattern' => '/(is.)?test(.activity)?/i',
198 'export' => true,
199 'uniqueName' => 'activity_is_test',
200 ),
201 'medium_id' => array(
202 'name' => 'medium_id',
203 'type' => 1,
204 'title' => 'Activity Medium',
205 'default' => 'UL',
206 'pseudoconstant' => array(
207 'optionGroupName' => 'encounter_medium',
208 ),
209 'uniqueName' => 'activity_medium_id',
210 ),
211 'result' => array(
212 'name' => 'result',
213 'type' => 2,
214 'title' => 'Result',
215 'maxlength' => 255,
216 'size' => 45,
217 'uniqueName' => 'activity_result',
218 ),
219 'is_deleted' => array(
220 'name' => 'is_deleted',
221 'type' => 16,
222 'title' => 'Activity is in the Trash',
223 'import' => true,
224 'where' => 'civicrm_activity.is_deleted',
225 'headerPattern' => '/(activity.)?(trash|deleted)/i',
226 'export' => true,
227 'uniqueName' => 'activity_is_deleted',
228 ),
229 'campaign_id' => array(
230 'name' => 'campaign_id',
231 'type' => 1,
232 'title' => 'Campaign ID',
233 'import' => true,
234 'where' => 'civicrm_activity.campaign_id',
235 'export' => true,
236 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
237 'uniqueName' => 'activity_campaign_id',
238 ),
239 'engagement_level' => array(
240 'name' => 'engagement_level',
241 'type' => 1,
242 'title' => 'Engagement Index',
243 'import' => true,
244 'where' => 'civicrm_activity.engagement_level',
245 'export' => true,
246 'pseudoconstant' => array(
247 'optionGroupName' => 'engagement_index',
248 ),
249 'uniqueName' => 'activity_engagement_level',
250 ),
251 'source_contact_id' => array(
252 'name' => 'source_contact_id',
253 'title' => 'Activity Source Contact',
254 'type' => 1,
255 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
256 'api.default' => 'user_contact_id',
257 ),
258 'assignee_contact_id' => array(
259 'name' => 'assignee_id',
260 'title' => 'assigned to',
261 'type' => 1,
262 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
263 ),
264 'target_contact_id' => array(
265 'name' => 'target_id',
266 'title' => 'Activity Target',
267 'type' => 1,
268 'FKClassName' => 'CRM_Activity_DAO_ActivityContact',
269 ),
270 ),
271 );
272
273 return $expectedResult;
274 }
275
276
277 /*
278 * This example has been generated from the API test suite. The test that created it is called
279 *
280 * testGetFields and can be found in
281 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
282 *
283 * You can see the outcome of the API tests at
284 * http://tests.dev.civicrm.org/trunk/results-api_v3
285 *
286 * To Learn about the API read
287 * http://book.civicrm.org/developer/current/techniques/api/
288 *
289 * and review the wiki at
290 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
291 *
292 * Read more about testing here
293 * http://wiki.civicrm.org/confluence/display/CRM/Testing
294 *
295 * API Standards documentation:
296 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
297 */