Merge pull request #520 from dlobo/CRM-12274
[civicrm-core.git] / api / v3 / examples / ActivityGetFields.php
CommitLineData
6a488035
TO
1<?php
2
3/*
4
5 */
6function 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 */
20function activity_getfields_expectedresult(){
21
22 $expectedResult = array(
23 'is_error' => 0,
24 'version' => 3,
25 'count' => 28,
26 'values' => array(
27 'source_contact_id' => array(
28 'name' => 'source_contact_id',
29 'type' => 1,
30 'title' => 'Source Contact',
31 'import' => true,
32 'where' => 'civicrm_activity.source_contact_id',
33 'headerPattern' => '/(activity.)?source(.contact(.id)?)?/i',
34 'export' => true,
35 'FKClassName' => 'CRM_Contact_DAO_Contact',
36 'api.default' => 'user_contact_id',
37 ),
38 'source_record_id' => array(
39 'name' => 'source_record_id',
40 'type' => 1,
41 'title' => 'Source Record',
42 ),
43 'activity_type_id' => array(
44 'name' => 'activity_type_id',
45 'type' => 1,
46 'title' => 'Activity Type ID',
47 'required' => true,
48 'import' => true,
49 'where' => 'civicrm_activity.activity_type_id',
50 'headerPattern' => '/(activity.)?type(.id$)/i',
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 'name' => 'priority',
80 'optionGroupName' => 'priority',
81 ),
82 'api.aliases' => array(
83 '0' => 'priority',
84 ),
85 'options' => array(
86 '1' => 'Urgent',
87 '2' => 'Normal',
88 '3' => 'Low',
89 ),
90 ),
91 'parent_id' => array(
92 'name' => 'parent_id',
93 'type' => 1,
94 'title' => 'Parent Activity Id',
95 'FKClassName' => 'CRM_Activity_DAO_Activity',
96 ),
97 'is_auto' => array(
98 'name' => 'is_auto',
99 'type' => 16,
100 'title' => 'Auto',
101 ),
102 'relationship_id' => array(
103 'name' => 'relationship_id',
104 'type' => 1,
105 'title' => 'Relationship Id',
106 'default' => 'UL',
107 'FKClassName' => 'CRM_Contact_DAO_Relationship',
108 ),
109 'is_current_revision' => array(
110 'name' => 'is_current_revision',
111 'type' => 16,
112 'title' => 'Is this activity a current revision in versioning chain?',
113 'import' => true,
114 'where' => 'civicrm_activity.is_current_revision',
115 'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
116 'export' => true,
117 ),
118 'original_id' => array(
119 'name' => 'original_id',
120 'type' => 1,
121 'title' => 'Original Activity ID ',
122 'FKClassName' => 'CRM_Activity_DAO_Activity',
123 ),
124 'weight' => array(
125 'name' => 'weight',
126 'type' => 1,
127 'title' => 'Weight',
128 ),
129 'id' => array(
130 'name' => 'id',
131 'type' => 1,
132 'title' => 'Activity ID',
133 'required' => true,
134 'import' => true,
135 'where' => 'civicrm_activity.id',
136 'export' => true,
137 'uniqueName' => 'activity_id',
138 ),
139 'subject' => array(
140 'name' => 'subject',
141 'type' => 2,
142 'title' => 'Subject',
143 'maxlength' => 255,
144 'size' => 45,
145 'import' => true,
146 'where' => 'civicrm_activity.subject',
147 'headerPattern' => '/(activity.)?subject/i',
148 'export' => true,
149 'uniqueName' => 'activity_subject',
150 ),
151 'duration' => array(
152 'name' => 'duration',
153 'type' => 1,
154 'title' => 'Duration',
155 'import' => true,
156 'where' => 'civicrm_activity.duration',
157 'headerPattern' => '/(activity.)?duration(s)?$/i',
158 'export' => true,
159 'uniqueName' => 'activity_duration',
160 ),
161 'location' => array(
162 'name' => 'location',
163 'type' => 2,
164 'title' => 'Location',
165 'maxlength' => 255,
166 'size' => 45,
167 'import' => true,
168 'where' => 'civicrm_activity.location',
169 'headerPattern' => '/(activity.)?location$/i',
170 'export' => true,
171 'uniqueName' => 'activity_location',
172 ),
173 'details' => array(
174 'name' => 'details',
175 'type' => 32,
176 'title' => 'Details',
177 'rows' => 8,
178 'cols' => 60,
179 'import' => true,
180 'where' => 'civicrm_activity.details',
181 'headerPattern' => '/(activity.)?detail(s)?$/i',
182 'export' => true,
183 'uniqueName' => 'activity_details',
184 ),
185 'status_id' => array(
186 'name' => 'status_id',
187 'type' => 1,
188 'title' => 'Activity Status Id',
189 'import' => true,
190 'where' => 'civicrm_activity.status_id',
191 'headerPattern' => '/(activity.)?status(.label$)?/i',
192 'uniqueName' => 'activity_status_id',
193 ),
194 'is_test' => array(
195 'name' => 'is_test',
196 'type' => 16,
197 'title' => 'Test',
198 'import' => true,
199 'where' => 'civicrm_activity.is_test',
200 'headerPattern' => '/(is.)?test(.activity)?/i',
201 'export' => true,
202 'uniqueName' => 'activity_is_test',
203 ),
204 'medium_id' => array(
205 'name' => 'medium_id',
206 'type' => 1,
207 'title' => 'Activity Medium',
208 'default' => 'UL',
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 'uniqueName' => 'activity_engagement_level',
247 ),
248 'assignee_contact_id' => array(
249 'name' => 'assignee_id',
250 'title' => 'assigned to',
251 'type' => 1,
252 'FKClassName' => 'CRM_Activity_DAO_ActivityAssignment',
253 ),
254 'target_contact_id' => array(
255 'name' => 'target_id',
256 'title' => 'Activity Target',
257 'type' => 1,
258 'FKClassName' => 'CRM_Activity_DAO_ActivityTarget',
259 ),
260 'activity_status_id' => array(
261 'name' => 'status_id',
262 'title' => 'Status Id',
263 'type' => 1,
264 ),
265 ),
266);
267
268 return $expectedResult ;
269}
270
271
272/*
273* This example has been generated from the API test suite. The test that created it is called
274*
275* testGetFields and can be found in
276* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/ActivityTest.php
277*
278* You can see the outcome of the API tests at
279* http://tests.dev.civicrm.org/trunk/results-api_v3
280*
281* To Learn about the API read
282* http://book.civicrm.org/developer/current/techniques/api/
283*
284* and review the wiki at
285* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
286*
287* Read more about testing here
288* http://wiki.civicrm.org/confluence/display/CRM/Testing
289*
290* API Standards documentation:
291* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
292*/