Merge pull request #17628 from colemanw/customOptionsFallback
[civicrm-core.git] / CRM / Core / DAO / OptionValue.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/OptionValue.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:5997192c77d86867e8d13c353dd02351)
10 */
11
12 /**
13 * Database access object for the OptionValue entity.
14 */
15 class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_option_value';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = TRUE;
30
31 /**
32 * Option ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Group which this option belongs to.
40 *
41 * @var int
42 */
43 public $option_group_id;
44
45 /**
46 * Option string as displayed to users - e.g. the label in an HTML OPTION tag.
47 *
48 * @var string
49 */
50 public $label;
51
52 /**
53 * The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.
54 *
55 * @var string
56 */
57 public $value;
58
59 /**
60 * Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.
61 *
62 * @var string
63 */
64 public $name;
65
66 /**
67 * Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.
68 *
69 * @var string
70 */
71 public $grouping;
72
73 /**
74 * Bitwise logic can be used to create subsets of options within an option_group for different uses.
75 *
76 * @var int
77 */
78 public $filter;
79
80 /**
81 * Is this the default option for the group?
82 *
83 * @var bool
84 */
85 public $is_default;
86
87 /**
88 * Controls display sort order.
89 *
90 * @var int
91 */
92 public $weight;
93
94 /**
95 * Optional description.
96 *
97 * @var text
98 */
99 public $description;
100
101 /**
102 * Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?
103 *
104 * @var bool
105 */
106 public $is_optgroup;
107
108 /**
109 * Is this a predefined system object?
110 *
111 * @var bool
112 */
113 public $is_reserved;
114
115 /**
116 * Is this option active?
117 *
118 * @var bool
119 */
120 public $is_active;
121
122 /**
123 * Component that this option value belongs/caters to.
124 *
125 * @var int
126 */
127 public $component_id;
128
129 /**
130 * Which Domain is this option value for
131 *
132 * @var int
133 */
134 public $domain_id;
135
136 /**
137 * @var int
138 */
139 public $visibility_id;
140
141 /**
142 * crm-i icon class
143 *
144 * @var string
145 */
146 public $icon;
147
148 /**
149 * Hex color value e.g. #ffffff
150 *
151 * @var string
152 */
153 public $color;
154
155 /**
156 * Class constructor.
157 */
158 public function __construct() {
159 $this->__table = 'civicrm_option_value';
160 parent::__construct();
161 }
162
163 /**
164 * Returns foreign keys and entity references.
165 *
166 * @return array
167 * [CRM_Core_Reference_Interface]
168 */
169 public static function getReferenceColumns() {
170 if (!isset(Civi::$statics[__CLASS__]['links'])) {
171 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
172 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
173 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id');
174 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
175 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
176 }
177 return Civi::$statics[__CLASS__]['links'];
178 }
179
180 /**
181 * Returns all the column names of this table
182 *
183 * @return array
184 */
185 public static function &fields() {
186 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
187 Civi::$statics[__CLASS__]['fields'] = [
188 'id' => [
189 'name' => 'id',
190 'type' => CRM_Utils_Type::T_INT,
191 'title' => ts('Option Value ID'),
192 'description' => ts('Option ID'),
193 'required' => TRUE,
194 'where' => 'civicrm_option_value.id',
195 'table_name' => 'civicrm_option_value',
196 'entity' => 'OptionValue',
197 'bao' => 'CRM_Core_BAO_OptionValue',
198 'localizable' => 0,
199 ],
200 'option_group_id' => [
201 'name' => 'option_group_id',
202 'type' => CRM_Utils_Type::T_INT,
203 'title' => ts('Option Group ID'),
204 'description' => ts('Group which this option belongs to.'),
205 'required' => TRUE,
206 'where' => 'civicrm_option_value.option_group_id',
207 'table_name' => 'civicrm_option_value',
208 'entity' => 'OptionValue',
209 'bao' => 'CRM_Core_BAO_OptionValue',
210 'localizable' => 0,
211 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
212 'html' => [
213 'type' => 'Select',
214 ],
215 'pseudoconstant' => [
216 'table' => 'civicrm_option_group',
217 'keyColumn' => 'id',
218 'labelColumn' => 'title',
219 'nameColumn' => 'name',
220 ],
221 ],
222 'label' => [
223 'name' => 'label',
224 'type' => CRM_Utils_Type::T_STRING,
225 'title' => ts('Option Label'),
226 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
227 'required' => TRUE,
228 'maxlength' => 512,
229 'size' => CRM_Utils_Type::HUGE,
230 'where' => 'civicrm_option_value.label',
231 'table_name' => 'civicrm_option_value',
232 'entity' => 'OptionValue',
233 'bao' => 'CRM_Core_BAO_OptionValue',
234 'localizable' => 1,
235 ],
236 'value' => [
237 'name' => 'value',
238 'type' => CRM_Utils_Type::T_STRING,
239 'title' => ts('Option Value'),
240 'description' => ts('The actual value stored (as a foreign key) in the data record. Functions which need lookup option_value.title should use civicrm_option_value.option_group_id plus civicrm_option_value.value as the key.'),
241 'required' => TRUE,
242 'maxlength' => 512,
243 'size' => CRM_Utils_Type::HUGE,
244 'where' => 'civicrm_option_value.value',
245 'table_name' => 'civicrm_option_value',
246 'entity' => 'OptionValue',
247 'bao' => 'CRM_Core_BAO_OptionValue',
248 'localizable' => 0,
249 ],
250 'name' => [
251 'name' => 'name',
252 'type' => CRM_Utils_Type::T_STRING,
253 'title' => ts('Option Name'),
254 'description' => ts('Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.'),
255 'maxlength' => 255,
256 'size' => CRM_Utils_Type::HUGE,
257 'import' => TRUE,
258 'where' => 'civicrm_option_value.name',
259 'export' => TRUE,
260 'table_name' => 'civicrm_option_value',
261 'entity' => 'OptionValue',
262 'bao' => 'CRM_Core_BAO_OptionValue',
263 'localizable' => 0,
264 ],
265 'grouping' => [
266 'name' => 'grouping',
267 'type' => CRM_Utils_Type::T_STRING,
268 'title' => ts('Option Grouping Name'),
269 'description' => ts('Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.'),
270 'maxlength' => 255,
271 'size' => CRM_Utils_Type::HUGE,
272 'where' => 'civicrm_option_value.grouping',
273 'table_name' => 'civicrm_option_value',
274 'entity' => 'OptionValue',
275 'bao' => 'CRM_Core_BAO_OptionValue',
276 'localizable' => 0,
277 ],
278 'filter' => [
279 'name' => 'filter',
280 'type' => CRM_Utils_Type::T_INT,
281 'title' => ts('Filter'),
282 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
283 'where' => 'civicrm_option_value.filter',
284 'default' => '0',
285 'table_name' => 'civicrm_option_value',
286 'entity' => 'OptionValue',
287 'bao' => 'CRM_Core_BAO_OptionValue',
288 'localizable' => 0,
289 ],
290 'is_default' => [
291 'name' => 'is_default',
292 'type' => CRM_Utils_Type::T_BOOLEAN,
293 'title' => ts('Option is Default?'),
294 'description' => ts('Is this the default option for the group?'),
295 'where' => 'civicrm_option_value.is_default',
296 'default' => '0',
297 'table_name' => 'civicrm_option_value',
298 'entity' => 'OptionValue',
299 'bao' => 'CRM_Core_BAO_OptionValue',
300 'localizable' => 0,
301 ],
302 'weight' => [
303 'name' => 'weight',
304 'type' => CRM_Utils_Type::T_INT,
305 'title' => ts('Order'),
306 'description' => ts('Controls display sort order.'),
307 'required' => TRUE,
308 'where' => 'civicrm_option_value.weight',
309 'table_name' => 'civicrm_option_value',
310 'entity' => 'OptionValue',
311 'bao' => 'CRM_Core_BAO_OptionValue',
312 'localizable' => 0,
313 ],
314 'description' => [
315 'name' => 'description',
316 'type' => CRM_Utils_Type::T_TEXT,
317 'title' => ts('Option Description'),
318 'description' => ts('Optional description.'),
319 'rows' => 8,
320 'cols' => 60,
321 'where' => 'civicrm_option_value.description',
322 'table_name' => 'civicrm_option_value',
323 'entity' => 'OptionValue',
324 'bao' => 'CRM_Core_BAO_OptionValue',
325 'localizable' => 1,
326 'html' => [
327 'type' => 'TextArea',
328 ],
329 ],
330 'is_optgroup' => [
331 'name' => 'is_optgroup',
332 'type' => CRM_Utils_Type::T_BOOLEAN,
333 'title' => ts('Option is Header?'),
334 'description' => ts('Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?'),
335 'where' => 'civicrm_option_value.is_optgroup',
336 'default' => '0',
337 'table_name' => 'civicrm_option_value',
338 'entity' => 'OptionValue',
339 'bao' => 'CRM_Core_BAO_OptionValue',
340 'localizable' => 0,
341 ],
342 'is_reserved' => [
343 'name' => 'is_reserved',
344 'type' => CRM_Utils_Type::T_BOOLEAN,
345 'title' => ts('Option Is Reserved?'),
346 'description' => ts('Is this a predefined system object?'),
347 'where' => 'civicrm_option_value.is_reserved',
348 'default' => '0',
349 'table_name' => 'civicrm_option_value',
350 'entity' => 'OptionValue',
351 'bao' => 'CRM_Core_BAO_OptionValue',
352 'localizable' => 0,
353 ],
354 'is_active' => [
355 'name' => 'is_active',
356 'type' => CRM_Utils_Type::T_BOOLEAN,
357 'title' => ts('Option Is Active'),
358 'description' => ts('Is this option active?'),
359 'where' => 'civicrm_option_value.is_active',
360 'default' => '1',
361 'table_name' => 'civicrm_option_value',
362 'entity' => 'OptionValue',
363 'bao' => 'CRM_Core_BAO_OptionValue',
364 'localizable' => 0,
365 ],
366 'component_id' => [
367 'name' => 'component_id',
368 'type' => CRM_Utils_Type::T_INT,
369 'title' => ts('Option Component'),
370 'description' => ts('Component that this option value belongs/caters to.'),
371 'where' => 'civicrm_option_value.component_id',
372 'table_name' => 'civicrm_option_value',
373 'entity' => 'OptionValue',
374 'bao' => 'CRM_Core_BAO_OptionValue',
375 'localizable' => 0,
376 'FKClassName' => 'CRM_Core_DAO_Component',
377 'html' => [
378 'type' => 'Select',
379 ],
380 'pseudoconstant' => [
381 'table' => 'civicrm_component',
382 'keyColumn' => 'id',
383 'labelColumn' => 'name',
384 ],
385 ],
386 'domain_id' => [
387 'name' => 'domain_id',
388 'type' => CRM_Utils_Type::T_INT,
389 'title' => ts('Option Domain'),
390 'description' => ts('Which Domain is this option value for'),
391 'where' => 'civicrm_option_value.domain_id',
392 'table_name' => 'civicrm_option_value',
393 'entity' => 'OptionValue',
394 'bao' => 'CRM_Core_BAO_OptionValue',
395 'localizable' => 0,
396 'FKClassName' => 'CRM_Core_DAO_Domain',
397 'pseudoconstant' => [
398 'table' => 'civicrm_domain',
399 'keyColumn' => 'id',
400 'labelColumn' => 'name',
401 ],
402 ],
403 'visibility_id' => [
404 'name' => 'visibility_id',
405 'type' => CRM_Utils_Type::T_INT,
406 'title' => ts('Option Visibility'),
407 'where' => 'civicrm_option_value.visibility_id',
408 'default' => 'NULL',
409 'table_name' => 'civicrm_option_value',
410 'entity' => 'OptionValue',
411 'bao' => 'CRM_Core_BAO_OptionValue',
412 'localizable' => 0,
413 'pseudoconstant' => [
414 'optionGroupName' => 'visibility',
415 'optionEditPath' => 'civicrm/admin/options/visibility',
416 ],
417 ],
418 'icon' => [
419 'name' => 'icon',
420 'type' => CRM_Utils_Type::T_STRING,
421 'title' => ts('Icon'),
422 'description' => ts('crm-i icon class'),
423 'maxlength' => 255,
424 'size' => CRM_Utils_Type::HUGE,
425 'where' => 'civicrm_option_value.icon',
426 'default' => 'NULL',
427 'table_name' => 'civicrm_option_value',
428 'entity' => 'OptionValue',
429 'bao' => 'CRM_Core_BAO_OptionValue',
430 'localizable' => 0,
431 ],
432 'color' => [
433 'name' => 'color',
434 'type' => CRM_Utils_Type::T_STRING,
435 'title' => ts('Color'),
436 'description' => ts('Hex color value e.g. #ffffff'),
437 'maxlength' => 255,
438 'size' => CRM_Utils_Type::HUGE,
439 'where' => 'civicrm_option_value.color',
440 'default' => 'NULL',
441 'table_name' => 'civicrm_option_value',
442 'entity' => 'OptionValue',
443 'bao' => 'CRM_Core_BAO_OptionValue',
444 'localizable' => 0,
445 ],
446 ];
447 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
448 }
449 return Civi::$statics[__CLASS__]['fields'];
450 }
451
452 /**
453 * Return a mapping from field-name to the corresponding key (as used in fields()).
454 *
455 * @return array
456 * Array(string $name => string $uniqueName).
457 */
458 public static function &fieldKeys() {
459 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
460 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
461 }
462 return Civi::$statics[__CLASS__]['fieldKeys'];
463 }
464
465 /**
466 * Returns the names of this table
467 *
468 * @return string
469 */
470 public static function getTableName() {
471 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
472 }
473
474 /**
475 * Returns if this table needs to be logged
476 *
477 * @return bool
478 */
479 public function getLog() {
480 return self::$_log;
481 }
482
483 /**
484 * Returns the list of fields that can be imported
485 *
486 * @param bool $prefix
487 *
488 * @return array
489 */
490 public static function &import($prefix = FALSE) {
491 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, []);
492 return $r;
493 }
494
495 /**
496 * Returns the list of fields that can be exported
497 *
498 * @param bool $prefix
499 *
500 * @return array
501 */
502 public static function &export($prefix = FALSE) {
503 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, []);
504 return $r;
505 }
506
507 /**
508 * Returns the list of indices
509 *
510 * @param bool $localize
511 *
512 * @return array
513 */
514 public static function indices($localize = TRUE) {
515 $indices = [
516 'index_option_group_id_value' => [
517 'name' => 'index_option_group_id_value',
518 'field' => [
519 0 => 'value(128)',
520 1 => 'option_group_id',
521 ],
522 'localizable' => FALSE,
523 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
524 ],
525 'index_option_group_id_name' => [
526 'name' => 'index_option_group_id_name',
527 'field' => [
528 0 => 'name(128)',
529 1 => 'option_group_id',
530 ],
531 'localizable' => FALSE,
532 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
533 ],
534 ];
535 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
536 }
537
538 }