Merge pull request #761 from adamwight/api_autoloaded
[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' => 28,
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 ),
41 'activity_date_time' => array(
42 'name' => 'activity_date_time',
43 'type' => 12,
44 'title' => 'Activity Date',
45 'import' => true,
46 'where' => 'civicrm_activity.activity_date_time',
47 'headerPattern' => '/(activity.)?date(.time$)?/i',
48 'export' => true,
49 ),
50 'phone_id' => array(
51 'name' => 'phone_id',
52 'type' => 1,
53 'title' => 'Phone (called) ID',
54 'FKClassName' => 'CRM_Core_DAO_Phone',
55 ),
56 'phone_number' => array(
57 'name' => 'phone_number',
58 'type' => 2,
59 'title' => 'Phone (called) Number',
60 'maxlength' => 64,
61 'size' => 30,
62 ),
63 'priority_id' => array(
64 'name' => 'priority_id',
65 'type' => 1,
66 'title' => 'Priority',
67 'pseudoconstant' => array(
68 'name' => 'priority',
69 'optionGroupName' => 'priority',
70 ),
71 'api.aliases' => array(
72 '0' => 'priority',
73 ),
74 'options' => array(
75 '1' => 'Urgent',
76 '2' => 'Normal',
77 '3' => 'Low',
78 ),
79 ),
80 'parent_id' => array(
81 'name' => 'parent_id',
82 'type' => 1,
83 'title' => 'Parent Activity Id',
84 'FKClassName' => 'CRM_Activity_DAO_Activity',
85 ),
86 'is_auto' => array(
87 'name' => 'is_auto',
88 'type' => 16,
89 'title' => 'Auto',
90 ),
91 'relationship_id' => array(
92 'name' => 'relationship_id',
93 'type' => 1,
94 'title' => 'Relationship Id',
95 'default' => 'UL',
96 'FKClassName' => 'CRM_Contact_DAO_Relationship',
97 ),
98 'is_current_revision' => array(
99 'name' => 'is_current_revision',
100 'type' => 16,
101 'title' => 'Is this activity a current revision in versioning chain?',
102 'import' => true,
103 'where' => 'civicrm_activity.is_current_revision',
104 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
105 'export' => true,
106 ),
107 'original_id' => array(
108 'name' => 'original_id',
109 'type' => 1,
110 'title' => 'Original Activity ID ',
111 'FKClassName' => 'CRM_Activity_DAO_Activity',
112 ),
113 'weight' => array(
114 'name' => 'weight',
115 'type' => 1,
116 'title' => 'Weight',
117 ),
118 'id' => array(
119 'name' => 'id',
120 'type' => 1,
121 'title' => 'Activity ID',
122 'required' => true,
123 'import' => true,
124 'where' => 'civicrm_activity.id',
125 'export' => true,
126 'uniqueName' => 'activity_id',
127 'api.aliases' => array(
128 '0' => 'activity_id',
129 ),
130 ),
131 'subject' => array(
132 'name' => 'subject',
133 'type' => 2,
134 'title' => 'Subject',
135 'maxlength' => 255,
136 'size' => 45,
137 'import' => true,
138 'where' => 'civicrm_activity.subject',
139 'headerPattern' => '/(activity.)?subject/i',
140 'export' => true,
141 'uniqueName' => 'activity_subject',
142 ),
143 'duration' => array(
144 'name' => 'duration',
145 'type' => 1,
146 'title' => 'Duration',
147 'import' => true,
148 'where' => 'civicrm_activity.duration',
149 'headerPattern' => '/(activity.)?duration(s)?$/i',
150 'export' => true,
151 'uniqueName' => 'activity_duration',
152 ),
153 'location' => array(
154 'name' => 'location',
155 'type' => 2,
156 'title' => 'Location',
157 'maxlength' => 255,
158 'size' => 45,
159 'import' => true,
160 'where' => 'civicrm_activity.location',
161 'headerPattern' => '/(activity.)?location$/i',
162 'export' => true,
163 'uniqueName' => 'activity_location',
164 ),
165 'details' => array(
166 'name' => 'details',
167 'type' => 32,
168 'title' => 'Details',
169 'rows' => 8,
170 'cols' => 60,
171 'import' => true,
172 'where' => 'civicrm_activity.details',
173 'headerPattern' => '/(activity.)?detail(s)?$/i',
174 'export' => true,
175 'uniqueName' => 'activity_details',
176 ),
177 'status_id' => array(
178 'name' => 'status_id',
179 'type' => 1,
180 'title' => 'Activity Status Id',
181 'import' => true,
182 'where' => 'civicrm_activity.status_id',
183 'headerPattern' => '/(activity.)?status(.label$)?/i',
184 'uniqueName' => 'activity_status_id',
185 ),
186 'is_test' => array(
187 'name' => 'is_test',
188 'type' => 16,
189 'title' => 'Test',
190 'import' => true,
191 'where' => 'civicrm_activity.is_test',
192 'headerPattern' => '/(is.)?test(.activity)?/i',
193 'export' => true,
194 'uniqueName' => 'activity_is_test',
195 ),
196 'medium_id' => array(
197 'name' => 'medium_id',
198 'type' => 1,
199 'title' => 'Activity Medium',
200 'default' => 'UL',
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 'uniqueName' => 'activity_engagement_level',
239 ),
240 'source_contact_id' => array(
241 'api.default' => 'user_contact_id',
242 ),
243 'assignee_contact_id' => array(
244 'name' => 'assignee_id',
245 'title' => 'assigned to',
246 'type' => 1,
247 'FKClassName' => 'CRM_Activity_DAO_ActivityAssignment',
248 ),
249 'target_contact_id' => array(
250 'name' => 'target_id',
251 'title' => 'Activity Target',
252 'type' => 1,
253 'FKClassName' => 'CRM_Activity_DAO_ActivityTarget',
254 ),
255 'activity_status_id' => array(
256 'name' => 'status_id',
257 'title' => 'Status Id',
258 'type' => 1,
259 ),
260 ),
261 );
262
263 return $expectedResult ;
264 }
265
266
267 /*
268 * This example has been generated from the API test suite. The test that created it is called
269 *
270 * testGetFields and can be found in
271 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
272 *
273 * You can see the outcome of the API tests at
274 * http://tests.dev.civicrm.org/trunk/results-api_v3
275 *
276 * To Learn about the API read
277 * http://book.civicrm.org/developer/current/techniques/api/
278 *
279 * and review the wiki at
280 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
281 *
282 * Read more about testing here
283 * http://wiki.civicrm.org/confluence/display/CRM/Testing
284 *
285 * API Standards documentation:
286 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
287 */