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