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