Merge pull request #19159 from colemanw/api4DynamicJoinFix
[civicrm-core.git] / CRM / Core / DAO / OptionGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/OptionGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:0892af5a47aecaeaa04a82c6f9875348)
10 */
11
12 /**
13 * Database access object for the OptionGroup entity.
14 */
15 class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_option_group';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Option Group ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Option Group title.
49 *
50 * @var string
51 */
52 public $title;
53
54 /**
55 * Option group description.
56 *
57 * @var string
58 */
59 public $description;
60
61 /**
62 * Option group description.
63 *
64 * @var string
65 */
66 public $data_type;
67
68 /**
69 * Is this a predefined system option group (i.e. it can not be deleted)?
70 *
71 * @var bool
72 */
73 public $is_reserved;
74
75 /**
76 * Is this option group active?
77 *
78 * @var bool
79 */
80 public $is_active;
81
82 /**
83 * A lock to remove the ability to add new options via the UI.
84 *
85 * @var bool
86 */
87 public $is_locked;
88
89 /**
90 * Class constructor.
91 */
92 public function __construct() {
93 $this->__table = 'civicrm_option_group';
94 parent::__construct();
95 }
96
97 /**
98 * Returns localized title of this entity.
99 *
100 * @param bool $plural
101 * Whether to return the plural version of the title.
102 */
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ? ts('Option Groups') : ts('Option Group');
105 }
106
107 /**
108 * Returns all the column names of this table
109 *
110 * @return array
111 */
112 public static function &fields() {
113 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
114 Civi::$statics[__CLASS__]['fields'] = [
115 'id' => [
116 'name' => 'id',
117 'type' => CRM_Utils_Type::T_INT,
118 'title' => ts('Option Group ID'),
119 'description' => ts('Option Group ID'),
120 'required' => TRUE,
121 'where' => 'civicrm_option_group.id',
122 'table_name' => 'civicrm_option_group',
123 'entity' => 'OptionGroup',
124 'bao' => 'CRM_Core_BAO_OptionGroup',
125 'localizable' => 0,
126 'add' => '1.5',
127 ],
128 'name' => [
129 'name' => 'name',
130 'type' => CRM_Utils_Type::T_STRING,
131 'title' => ts('Option Group Name'),
132 'description' => ts('Option group name. Used as selection key by class properties which lookup options in civicrm_option_value.'),
133 'required' => TRUE,
134 'maxlength' => 64,
135 'size' => CRM_Utils_Type::BIG,
136 'where' => 'civicrm_option_group.name',
137 'table_name' => 'civicrm_option_group',
138 'entity' => 'OptionGroup',
139 'bao' => 'CRM_Core_BAO_OptionGroup',
140 'localizable' => 0,
141 'add' => '1.5',
142 ],
143 'title' => [
144 'name' => 'title',
145 'type' => CRM_Utils_Type::T_STRING,
146 'title' => ts('Option Group title'),
147 'description' => ts('Option Group title.'),
148 'maxlength' => 255,
149 'size' => CRM_Utils_Type::HUGE,
150 'where' => 'civicrm_option_group.title',
151 'table_name' => 'civicrm_option_group',
152 'entity' => 'OptionGroup',
153 'bao' => 'CRM_Core_BAO_OptionGroup',
154 'localizable' => 1,
155 'add' => '1.5',
156 ],
157 'description' => [
158 'name' => 'description',
159 'type' => CRM_Utils_Type::T_STRING,
160 'title' => ts('Option Group Description'),
161 'description' => ts('Option group description.'),
162 'maxlength' => 255,
163 'size' => CRM_Utils_Type::HUGE,
164 'where' => 'civicrm_option_group.description',
165 'table_name' => 'civicrm_option_group',
166 'entity' => 'OptionGroup',
167 'bao' => 'CRM_Core_BAO_OptionGroup',
168 'localizable' => 1,
169 'add' => '1.5',
170 ],
171 'data_type' => [
172 'name' => 'data_type',
173 'type' => CRM_Utils_Type::T_STRING,
174 'title' => ts('Data Type for this option group'),
175 'description' => ts('Option group description.'),
176 'maxlength' => 128,
177 'size' => CRM_Utils_Type::HUGE,
178 'where' => 'civicrm_option_group.data_type',
179 'table_name' => 'civicrm_option_group',
180 'entity' => 'OptionGroup',
181 'bao' => 'CRM_Core_BAO_OptionGroup',
182 'localizable' => 0,
183 'pseudoconstant' => [
184 'callback' => 'CRM_Utils_Type::dataTypes',
185 ],
186 'add' => '4.7',
187 ],
188 'is_reserved' => [
189 'name' => 'is_reserved',
190 'type' => CRM_Utils_Type::T_BOOLEAN,
191 'title' => ts('Option Group Is Reserved?'),
192 'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'),
193 'required' => TRUE,
194 'where' => 'civicrm_option_group.is_reserved',
195 'default' => '1',
196 'table_name' => 'civicrm_option_group',
197 'entity' => 'OptionGroup',
198 'bao' => 'CRM_Core_BAO_OptionGroup',
199 'localizable' => 0,
200 'add' => '1.5',
201 ],
202 'is_active' => [
203 'name' => 'is_active',
204 'type' => CRM_Utils_Type::T_BOOLEAN,
205 'title' => ts('Option Group Is Active?'),
206 'description' => ts('Is this option group active?'),
207 'required' => TRUE,
208 'where' => 'civicrm_option_group.is_active',
209 'default' => '1',
210 'table_name' => 'civicrm_option_group',
211 'entity' => 'OptionGroup',
212 'bao' => 'CRM_Core_BAO_OptionGroup',
213 'localizable' => 0,
214 'add' => '1.5',
215 ],
216 'is_locked' => [
217 'name' => 'is_locked',
218 'type' => CRM_Utils_Type::T_BOOLEAN,
219 'title' => ts('Option Group Is Locked'),
220 'description' => ts('A lock to remove the ability to add new options via the UI.'),
221 'required' => TRUE,
222 'where' => 'civicrm_option_group.is_locked',
223 'default' => '0',
224 'table_name' => 'civicrm_option_group',
225 'entity' => 'OptionGroup',
226 'bao' => 'CRM_Core_BAO_OptionGroup',
227 'localizable' => 0,
228 'add' => '4.5',
229 ],
230 ];
231 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
232 }
233 return Civi::$statics[__CLASS__]['fields'];
234 }
235
236 /**
237 * Return a mapping from field-name to the corresponding key (as used in fields()).
238 *
239 * @return array
240 * Array(string $name => string $uniqueName).
241 */
242 public static function &fieldKeys() {
243 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
244 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
245 }
246 return Civi::$statics[__CLASS__]['fieldKeys'];
247 }
248
249 /**
250 * Returns the names of this table
251 *
252 * @return string
253 */
254 public static function getTableName() {
255 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
256 }
257
258 /**
259 * Returns if this table needs to be logged
260 *
261 * @return bool
262 */
263 public function getLog() {
264 return self::$_log;
265 }
266
267 /**
268 * Returns the list of fields that can be imported
269 *
270 * @param bool $prefix
271 *
272 * @return array
273 */
274 public static function &import($prefix = FALSE) {
275 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_group', $prefix, []);
276 return $r;
277 }
278
279 /**
280 * Returns the list of fields that can be exported
281 *
282 * @param bool $prefix
283 *
284 * @return array
285 */
286 public static function &export($prefix = FALSE) {
287 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_group', $prefix, []);
288 return $r;
289 }
290
291 /**
292 * Returns the list of indices
293 *
294 * @param bool $localize
295 *
296 * @return array
297 */
298 public static function indices($localize = TRUE) {
299 $indices = [
300 'UI_name' => [
301 'name' => 'UI_name',
302 'field' => [
303 0 => 'name',
304 ],
305 'localizable' => FALSE,
306 'unique' => TRUE,
307 'sig' => 'civicrm_option_group::1::name',
308 ],
309 ];
310 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
311 }
312
313 }