Merge pull request #1046 from colemanw/showHide
[civicrm-core.git] / api / v3 / examples / Group / getfields.php
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 'api.aliases' => array(
33 '0' => 'group_id',
34 ),
35 ),
36 'name' => array(
37 'name' => 'name',
38 'type' => 2,
39 'title' => 'Group Name',
40 'maxlength' => 64,
41 'size' => 30,
42 ),
43 'title' => array(
44 'name' => 'title',
45 'type' => 2,
46 'title' => 'Group Title',
47 'maxlength' => 64,
48 'size' => 30,
49 'api.required' => 1,
50 ),
51 'description' => array(
52 'name' => 'description',
53 'type' => 32,
54 'title' => 'Group Description',
55 'rows' => 2,
56 'cols' => 60,
57 ),
58 'source' => array(
59 'name' => 'source',
60 'type' => 2,
61 'title' => 'Group Source',
62 'maxlength' => 64,
63 'size' => 30,
64 ),
65 'saved_search_id' => array(
66 'name' => 'saved_search_id',
67 'type' => 1,
68 'title' => 'Saved Search ID',
69 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
70 ),
71 'is_active' => array(
72 'name' => 'is_active',
73 'type' => 16,
74 'title' => 'Group Enabled',
75 'api.default' => 1,
76 ),
77 'visibility' => array(
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',
83 ),
84 'where_clause' => array(
85 'name' => 'where_clause',
86 'type' => 32,
87 'title' => 'Group Where Clause',
88 ),
89 'select_tables' => array(
90 'name' => 'select_tables',
91 'type' => 32,
92 'title' => 'Tables For Select Clause',
93 ),
94 'where_tables' => array(
95 'name' => 'where_tables',
96 'type' => 32,
97 'title' => 'Tables For Where Clause',
98 ),
99 'group_type' => array(
100 'name' => 'group_type',
101 'type' => 2,
102 'title' => 'Group Type',
103 'maxlength' => 128,
104 'size' => 45,
105 ),
106 'cache_date' => array(
107 'name' => 'cache_date',
108 'type' => 12,
109 'title' => 'Group Cache Date',
110 ),
111 'refresh_date' => array(
112 'name' => 'refresh_date',
113 'type' => 12,
114 'title' => 'Next Group Refresh Time',
115 ),
116 'parents' => array(
117 'name' => 'parents',
118 'type' => 32,
119 'title' => 'Group Parents',
120 ),
121 'children' => array(
122 'name' => 'children',
123 'type' => 32,
124 'title' => 'Group Children',
125 ),
126 'is_hidden' => array(
127 'name' => 'is_hidden',
128 'type' => 16,
129 'title' => 'Group is Hidden',
130 ),
131 'is_reserved' => array(
132 'name' => 'is_reserved',
133 'type' => 16,
134 'title' => 'Group is Reserved',
135 ),
136 'created_id' => array(
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 */