490f2c7f0a83e772eb36cee0efa7689fa9238de5
[civicrm-core.git] / api / v3 / examples / Group / getfields.php
1 <?php
2 /**
3 * Test Generated example of using group getfields API
4 * demonstrate use of getfields to interogate api *
5 */
6 function group_getfields_example(){
7 $params = array(
8 'action' => 'create',
9 );
10
11 try{
12 $result = civicrm_api3('group', '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 group_getfields_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 19,
34 'values' => array(
35 'id' => array(
36 'name' => 'id',
37 'type' => 1,
38 'title' => 'Group ID',
39 'required' => true,
40 'api.aliases' => array(
41 '0' => 'group_id',
42 ),
43 ),
44 'name' => array(
45 'name' => 'name',
46 'type' => 2,
47 'title' => 'Group Name',
48 'maxlength' => 64,
49 'size' => 30,
50 ),
51 'title' => array(
52 'name' => 'title',
53 'type' => 2,
54 'title' => 'Group Title',
55 'maxlength' => 64,
56 'size' => 30,
57 'api.required' => 1,
58 ),
59 'description' => array(
60 'name' => 'description',
61 'type' => 32,
62 'title' => 'Group Description',
63 'rows' => 2,
64 'cols' => 60,
65 ),
66 'source' => array(
67 'name' => 'source',
68 'type' => 2,
69 'title' => 'Group Source',
70 'maxlength' => 64,
71 'size' => 30,
72 ),
73 'saved_search_id' => array(
74 'name' => 'saved_search_id',
75 'type' => 1,
76 'title' => 'Saved Search ID',
77 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
78 ),
79 'is_active' => array(
80 'name' => 'is_active',
81 'type' => 16,
82 'title' => 'Group Enabled',
83 'api.default' => 1,
84 ),
85 'visibility' => array(
86 'name' => 'visibility',
87 'type' => 2,
88 'title' => 'Group Visibility Setting',
89 'default' => 'User and User Admin Only',
90 'enumValues' => 'User and User Admin Only,Public Pages',
91 ),
92 'where_clause' => array(
93 'name' => 'where_clause',
94 'type' => 32,
95 'title' => 'Group Where Clause',
96 ),
97 'select_tables' => array(
98 'name' => 'select_tables',
99 'type' => 32,
100 'title' => 'Tables For Select Clause',
101 ),
102 'where_tables' => array(
103 'name' => 'where_tables',
104 'type' => 32,
105 'title' => 'Tables For Where Clause',
106 ),
107 'group_type' => array(
108 'name' => 'group_type',
109 'type' => 2,
110 'title' => 'Group Type',
111 'maxlength' => 128,
112 'size' => 45,
113 ),
114 'cache_date' => array(
115 'name' => 'cache_date',
116 'type' => 12,
117 'title' => 'Group Cache Date',
118 ),
119 'refresh_date' => array(
120 'name' => 'refresh_date',
121 'type' => 12,
122 'title' => 'Next Group Refresh Time',
123 ),
124 'parents' => array(
125 'name' => 'parents',
126 'type' => 32,
127 'title' => 'Group Parents',
128 ),
129 'children' => array(
130 'name' => 'children',
131 'type' => 32,
132 'title' => 'Group Children',
133 ),
134 'is_hidden' => array(
135 'name' => 'is_hidden',
136 'type' => 16,
137 'title' => 'Group is Hidden',
138 ),
139 'is_reserved' => array(
140 'name' => 'is_reserved',
141 'type' => 16,
142 'title' => 'Group is Reserved',
143 ),
144 'created_id' => array(
145 'name' => 'created_id',
146 'type' => 1,
147 'title' => 'Group Created By',
148 'FKClassName' => 'CRM_Contact_DAO_Contact',
149 ),
150 ),
151 );
152
153 return $expectedResult;
154 }
155
156
157 /*
158 * This example has been generated from the API test suite. The test that created it is called
159 *
160 * testgetfields and can be found in
161 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GroupTest.php
162 *
163 * You can see the outcome of the API tests at
164 * https://test.civicrm.org/job/CiviCRM-master-git/
165 *
166 * To Learn about the API read
167 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
168 *
169 * Browse the api on your own site with the api explorer
170 * http://MYSITE.ORG/path/to/civicrm/api/explorer
171 *
172 * Read more about testing here
173 * http://wiki.civicrm.org/confluence/display/CRM/Testing
174 *
175 * API Standards documentation:
176 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
177 */