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