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