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