Commit | Line | Data |
---|---|---|
22fd1690 | 1 | <?php |
fb32de45 | 2 | /** |
3 | * Test Generated example of using activity getfields API | |
4 | * * | |
22fd1690 ARW |
5 | */ |
6 | function activity_getfields_example(){ | |
feb2a730 | 7 | $params = array( |
22fd1690 ARW |
8 | 'action' => 'create', |
9 | ); | |
10 | ||
fb32de45 | 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 | } | |
22fd1690 | 21 | |
fb32de45 | 22 | return $result; |
22fd1690 ARW |
23 | } |
24 | ||
fb32de45 | 25 | /** |
22fd1690 ARW |
26 | * Function returns array of result expected from previous function |
27 | */ | |
28 | function activity_getfields_expectedresult(){ | |
29 | ||
feb2a730 | 30 | $expectedResult = array( |
22fd1690 ARW |
31 | 'is_error' => 0, |
32 | 'version' => 3, | |
feb2a730 | 33 | 'count' => 27, |
34 | 'values' => array( | |
35 | 'source_record_id' => array( | |
22fd1690 ARW |
36 | 'name' => 'source_record_id', |
37 | 'type' => 1, | |
38 | 'title' => 'Source Record', | |
39 | ), | |
feb2a730 | 40 | 'activity_type_id' => array( |
22fd1690 ARW |
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', | |
feb2a730 | 48 | 'pseudoconstant' => array( |
70f7ba9e CW |
49 | 'optionGroupName' => 'activity_type', |
50 | ), | |
22fd1690 | 51 | ), |
feb2a730 | 52 | 'activity_date_time' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 61 | 'phone_id' => array( |
22fd1690 ARW |
62 | 'name' => 'phone_id', |
63 | 'type' => 1, | |
64 | 'title' => 'Phone (called) ID', | |
65 | 'FKClassName' => 'CRM_Core_DAO_Phone', | |
66 | ), | |
feb2a730 | 67 | 'phone_number' => array( |
22fd1690 ARW |
68 | 'name' => 'phone_number', |
69 | 'type' => 2, | |
70 | 'title' => 'Phone (called) Number', | |
71 | 'maxlength' => 64, | |
72 | 'size' => 30, | |
73 | ), | |
feb2a730 | 74 | 'priority_id' => array( |
22fd1690 ARW |
75 | 'name' => 'priority_id', |
76 | 'type' => 1, | |
77 | 'title' => 'Priority', | |
feb2a730 | 78 | 'pseudoconstant' => array( |
22fd1690 ARW |
79 | 'optionGroupName' => 'priority', |
80 | ), | |
22fd1690 | 81 | ), |
feb2a730 | 82 | 'parent_id' => array( |
22fd1690 ARW |
83 | 'name' => 'parent_id', |
84 | 'type' => 1, | |
85 | 'title' => 'Parent Activity Id', | |
86 | 'FKClassName' => 'CRM_Activity_DAO_Activity', | |
87 | ), | |
feb2a730 | 88 | 'is_auto' => array( |
22fd1690 ARW |
89 | 'name' => 'is_auto', |
90 | 'type' => 16, | |
91 | 'title' => 'Auto', | |
92 | ), | |
feb2a730 | 93 | 'relationship_id' => array( |
22fd1690 ARW |
94 | 'name' => 'relationship_id', |
95 | 'type' => 1, | |
96 | 'title' => 'Relationship Id', | |
97 | 'default' => 'UL', | |
98 | 'FKClassName' => 'CRM_Contact_DAO_Relationship', | |
99 | ), | |
feb2a730 | 100 | 'is_current_revision' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 109 | 'original_id' => array( |
22fd1690 ARW |
110 | 'name' => 'original_id', |
111 | 'type' => 1, | |
112 | 'title' => 'Original Activity ID ', | |
113 | 'FKClassName' => 'CRM_Activity_DAO_Activity', | |
114 | ), | |
feb2a730 | 115 | 'weight' => array( |
22fd1690 ARW |
116 | 'name' => 'weight', |
117 | 'type' => 1, | |
118 | 'title' => 'Weight', | |
119 | ), | |
feb2a730 | 120 | 'id' => array( |
22fd1690 ARW |
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', | |
feb2a730 | 129 | 'api.aliases' => array( |
22fd1690 ARW |
130 | '0' => 'activity_id', |
131 | ), | |
132 | ), | |
feb2a730 | 133 | 'subject' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 145 | 'duration' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 155 | 'location' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 167 | 'details' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 179 | 'status_id' => array( |
22fd1690 ARW |
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', | |
feb2a730 | 186 | 'pseudoconstant' => array( |
70f7ba9e CW |
187 | 'optionGroupName' => 'activity_status', |
188 | ), | |
22fd1690 ARW |
189 | 'uniqueName' => 'activity_status_id', |
190 | ), | |
feb2a730 | 191 | 'is_test' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 201 | 'medium_id' => array( |
22fd1690 ARW |
202 | 'name' => 'medium_id', |
203 | 'type' => 1, | |
204 | 'title' => 'Activity Medium', | |
205 | 'default' => 'UL', | |
feb2a730 | 206 | 'pseudoconstant' => array( |
70f7ba9e CW |
207 | 'optionGroupName' => 'encounter_medium', |
208 | ), | |
22fd1690 ARW |
209 | 'uniqueName' => 'activity_medium_id', |
210 | ), | |
feb2a730 | 211 | 'result' => array( |
22fd1690 ARW |
212 | 'name' => 'result', |
213 | 'type' => 2, | |
214 | 'title' => 'Result', | |
215 | 'maxlength' => 255, | |
216 | 'size' => 45, | |
217 | 'uniqueName' => 'activity_result', | |
218 | ), | |
feb2a730 | 219 | 'is_deleted' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 229 | 'campaign_id' => array( |
22fd1690 ARW |
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 | ), | |
feb2a730 | 239 | 'engagement_level' => array( |
22fd1690 ARW |
240 | 'name' => 'engagement_level', |
241 | 'type' => 1, | |
242 | 'title' => 'Engagement Index', | |
243 | 'import' => true, | |
244 | 'where' => 'civicrm_activity.engagement_level', | |
245 | 'export' => true, | |
feb2a730 | 246 | 'pseudoconstant' => array( |
70f7ba9e CW |
247 | 'optionGroupName' => 'engagement_index', |
248 | ), | |
22fd1690 ARW |
249 | 'uniqueName' => 'activity_engagement_level', |
250 | ), | |
feb2a730 | 251 | 'source_contact_id' => array( |
70f7ba9e CW |
252 | 'name' => 'source_contact_id', |
253 | 'title' => 'Activity Source Contact', | |
254 | 'type' => 1, | |
255 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', | |
22fd1690 ARW |
256 | 'api.default' => 'user_contact_id', |
257 | ), | |
feb2a730 | 258 | 'assignee_contact_id' => array( |
22fd1690 ARW |
259 | 'name' => 'assignee_id', |
260 | 'title' => 'assigned to', | |
261 | 'type' => 1, | |
70f7ba9e | 262 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', |
22fd1690 | 263 | ), |
feb2a730 | 264 | 'target_contact_id' => array( |
22fd1690 ARW |
265 | 'name' => 'target_id', |
266 | 'title' => 'Activity Target', | |
267 | 'type' => 1, | |
70f7ba9e | 268 | 'FKClassName' => 'CRM_Activity_DAO_ActivityContact', |
22fd1690 | 269 | ), |
22fd1690 ARW |
270 | ), |
271 | ); | |
272 | ||
fb32de45 | 273 | return $expectedResult; |
22fd1690 ARW |
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 | */ |