Regenerate DAO
[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
c5451052 9 * (GenCodeChecksum:7cc1ab1ede682626c34db52967f627c8)
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
449c4e6b
CW
163 /**
164 * Returns localized title of this entity.
165 */
166 public static function getEntityTitle() {
167 return ts('Option Values');
168 }
169
e501603b 170 /**
f41f0342 171 * Returns foreign keys and entity references.
e501603b
TO
172 *
173 * @return array
174 * [CRM_Core_Reference_Interface]
175 */
c3fc2621 176 public static function getReferenceColumns() {
346aaaba 177 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 178 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
179 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
180 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id');
181 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
346aaaba 182 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 183 }
346aaaba 184 return Civi::$statics[__CLASS__]['links'];
e501603b 185 }
c3fc2621 186
e501603b
TO
187 /**
188 * Returns all the column names of this table
189 *
190 * @return array
191 */
c3fc2621 192 public static function &fields() {
346aaaba 193 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
194 Civi::$statics[__CLASS__]['fields'] = [
195 'id' => [
e501603b
TO
196 'name' => 'id',
197 'type' => CRM_Utils_Type::T_INT,
c3fc2621 198 'title' => ts('Option Value ID'),
215b423e 199 'description' => ts('Option ID'),
c3fc2621 200 'required' => TRUE,
a36434b9 201 'where' => 'civicrm_option_value.id',
522a26c9 202 'table_name' => 'civicrm_option_value',
203 'entity' => 'OptionValue',
204 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 205 'localizable' => 0,
c3fc2621
CW
206 ],
207 'option_group_id' => [
e501603b
TO
208 'name' => 'option_group_id',
209 'type' => CRM_Utils_Type::T_INT,
c3fc2621 210 'title' => ts('Option Group ID'),
215b423e 211 'description' => ts('Group which this option belongs to.'),
c3fc2621 212 'required' => TRUE,
a36434b9 213 'where' => 'civicrm_option_value.option_group_id',
522a26c9 214 'table_name' => 'civicrm_option_value',
215 'entity' => 'OptionValue',
216 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 217 'localizable' => 0,
e501603b 218 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
c3fc2621 219 'html' => [
e501603b 220 'type' => 'Select',
c3fc2621
CW
221 ],
222 'pseudoconstant' => [
e501603b
TO
223 'table' => 'civicrm_option_group',
224 'keyColumn' => 'id',
17f78bae
CW
225 'labelColumn' => 'title',
226 'nameColumn' => 'name',
e6ca0a57 227 ],
c3fc2621
CW
228 ],
229 'label' => [
e501603b
TO
230 'name' => 'label',
231 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 232 'title' => ts('Option Label'),
215b423e 233 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
c3fc2621 234 'required' => TRUE,
e501603b
TO
235 'maxlength' => 512,
236 'size' => CRM_Utils_Type::HUGE,
a36434b9 237 'where' => 'civicrm_option_value.label',
522a26c9 238 'table_name' => 'civicrm_option_value',
239 'entity' => 'OptionValue',
240 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 241 'localizable' => 1,
c3fc2621
CW
242 ],
243 'value' => [
e501603b
TO
244 'name' => 'value',
245 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 246 'title' => ts('Option Value'),
215b423e 247 '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 248 'required' => TRUE,
e501603b
TO
249 'maxlength' => 512,
250 'size' => CRM_Utils_Type::HUGE,
a36434b9 251 'where' => 'civicrm_option_value.value',
522a26c9 252 'table_name' => 'civicrm_option_value',
253 'entity' => 'OptionValue',
254 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 255 'localizable' => 0,
c3fc2621
CW
256 ],
257 'name' => [
e501603b
TO
258 'name' => 'name',
259 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 260 'title' => ts('Option Name'),
215b423e 261 '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
262 'maxlength' => 255,
263 'size' => CRM_Utils_Type::HUGE,
c3fc2621 264 'import' => TRUE,
e501603b 265 'where' => 'civicrm_option_value.name',
c3fc2621 266 'export' => TRUE,
522a26c9 267 'table_name' => 'civicrm_option_value',
268 'entity' => 'OptionValue',
269 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 270 'localizable' => 0,
c3fc2621
CW
271 ],
272 'grouping' => [
e501603b
TO
273 'name' => 'grouping',
274 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 275 'title' => ts('Option Grouping Name'),
215b423e 276 '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
277 'maxlength' => 255,
278 'size' => CRM_Utils_Type::HUGE,
a36434b9 279 'where' => 'civicrm_option_value.grouping',
522a26c9 280 'table_name' => 'civicrm_option_value',
281 'entity' => 'OptionValue',
282 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 283 'localizable' => 0,
c3fc2621
CW
284 ],
285 'filter' => [
e501603b
TO
286 'name' => 'filter',
287 'type' => CRM_Utils_Type::T_INT,
c3fc2621 288 'title' => ts('Filter'),
215b423e 289 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
a36434b9 290 'where' => 'civicrm_option_value.filter',
b8be3222 291 'default' => '0',
522a26c9 292 'table_name' => 'civicrm_option_value',
293 'entity' => 'OptionValue',
294 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 295 'localizable' => 0,
c3fc2621
CW
296 ],
297 'is_default' => [
e501603b
TO
298 'name' => 'is_default',
299 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 300 'title' => ts('Option is Default?'),
215b423e 301 'description' => ts('Is this the default option for the group?'),
a36434b9 302 'where' => 'civicrm_option_value.is_default',
45a83e42 303 'default' => '0',
522a26c9 304 'table_name' => 'civicrm_option_value',
305 'entity' => 'OptionValue',
306 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 307 'localizable' => 0,
c3fc2621
CW
308 ],
309 'weight' => [
e501603b
TO
310 'name' => 'weight',
311 'type' => CRM_Utils_Type::T_INT,
c3fc2621 312 'title' => ts('Order'),
215b423e 313 'description' => ts('Controls display sort order.'),
c3fc2621 314 'required' => TRUE,
a36434b9 315 'where' => 'civicrm_option_value.weight',
522a26c9 316 'table_name' => 'civicrm_option_value',
317 'entity' => 'OptionValue',
318 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 319 'localizable' => 0,
c3fc2621
CW
320 ],
321 'description' => [
e501603b
TO
322 'name' => 'description',
323 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 324 'title' => ts('Option Description'),
215b423e 325 'description' => ts('Optional description.'),
e501603b
TO
326 'rows' => 8,
327 'cols' => 60,
a36434b9 328 'where' => 'civicrm_option_value.description',
522a26c9 329 'table_name' => 'civicrm_option_value',
330 'entity' => 'OptionValue',
331 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 332 'localizable' => 1,
c3fc2621 333 'html' => [
e501603b 334 'type' => 'TextArea',
c3fc2621
CW
335 ],
336 ],
337 'is_optgroup' => [
e501603b
TO
338 'name' => 'is_optgroup',
339 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 340 'title' => ts('Option is Header?'),
215b423e 341 '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 342 'where' => 'civicrm_option_value.is_optgroup',
45a83e42 343 'default' => '0',
522a26c9 344 'table_name' => 'civicrm_option_value',
345 'entity' => 'OptionValue',
346 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 347 'localizable' => 0,
c3fc2621
CW
348 ],
349 'is_reserved' => [
e501603b
TO
350 'name' => 'is_reserved',
351 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 352 'title' => ts('Option Is Reserved?'),
215b423e 353 'description' => ts('Is this a predefined system object?'),
a36434b9 354 'where' => 'civicrm_option_value.is_reserved',
45a83e42 355 'default' => '0',
522a26c9 356 'table_name' => 'civicrm_option_value',
357 'entity' => 'OptionValue',
358 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 359 'localizable' => 0,
c3fc2621
CW
360 ],
361 'is_active' => [
e501603b
TO
362 'name' => 'is_active',
363 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 364 'title' => ts('Option Is Active'),
215b423e 365 'description' => ts('Is this option active?'),
a36434b9 366 'where' => 'civicrm_option_value.is_active',
e501603b 367 'default' => '1',
522a26c9 368 'table_name' => 'civicrm_option_value',
369 'entity' => 'OptionValue',
370 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 371 'localizable' => 0,
c3fc2621
CW
372 ],
373 'component_id' => [
e501603b
TO
374 'name' => 'component_id',
375 'type' => CRM_Utils_Type::T_INT,
c3fc2621 376 'title' => ts('Option Component'),
215b423e 377 'description' => ts('Component that this option value belongs/caters to.'),
a36434b9 378 'where' => 'civicrm_option_value.component_id',
522a26c9 379 'table_name' => 'civicrm_option_value',
380 'entity' => 'OptionValue',
381 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 382 'localizable' => 0,
e501603b 383 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 384 'html' => [
e501603b 385 'type' => 'Select',
c3fc2621
CW
386 ],
387 'pseudoconstant' => [
e501603b
TO
388 'table' => 'civicrm_component',
389 'keyColumn' => 'id',
390 'labelColumn' => 'name',
e6ca0a57 391 ],
c3fc2621
CW
392 ],
393 'domain_id' => [
e501603b
TO
394 'name' => 'domain_id',
395 'type' => CRM_Utils_Type::T_INT,
c3fc2621 396 'title' => ts('Option Domain'),
215b423e 397 'description' => ts('Which Domain is this option value for'),
a36434b9 398 'where' => 'civicrm_option_value.domain_id',
522a26c9 399 'table_name' => 'civicrm_option_value',
400 'entity' => 'OptionValue',
401 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 402 'localizable' => 0,
e501603b 403 'FKClassName' => 'CRM_Core_DAO_Domain',
c3fc2621 404 'pseudoconstant' => [
e501603b
TO
405 'table' => 'civicrm_domain',
406 'keyColumn' => 'id',
407 'labelColumn' => 'name',
e6ca0a57 408 ],
c3fc2621
CW
409 ],
410 'visibility_id' => [
e501603b
TO
411 'name' => 'visibility_id',
412 'type' => CRM_Utils_Type::T_INT,
c3fc2621 413 'title' => ts('Option Visibility'),
a36434b9 414 'where' => 'civicrm_option_value.visibility_id',
e501603b 415 'default' => 'NULL',
522a26c9 416 'table_name' => 'civicrm_option_value',
417 'entity' => 'OptionValue',
418 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 419 'localizable' => 0,
e78e618d
PN
420 'pseudoconstant' => [
421 'optionGroupName' => 'visibility',
422 'optionEditPath' => 'civicrm/admin/options/visibility',
e6ca0a57 423 ],
c3fc2621
CW
424 ],
425 'icon' => [
b412f764
CW
426 'name' => 'icon',
427 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 428 'title' => ts('Icon'),
215b423e 429 'description' => ts('crm-i icon class'),
b412f764
CW
430 'maxlength' => 255,
431 'size' => CRM_Utils_Type::HUGE,
a36434b9 432 'where' => 'civicrm_option_value.icon',
b412f764 433 'default' => 'NULL',
522a26c9 434 'table_name' => 'civicrm_option_value',
435 'entity' => 'OptionValue',
436 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 437 'localizable' => 0,
c3fc2621
CW
438 ],
439 'color' => [
d73974ac
CW
440 'name' => 'color',
441 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 442 'title' => ts('Color'),
215b423e 443 'description' => ts('Hex color value e.g. #ffffff'),
d73974ac
CW
444 'maxlength' => 255,
445 'size' => CRM_Utils_Type::HUGE,
a36434b9 446 'where' => 'civicrm_option_value.color',
d73974ac 447 'default' => 'NULL',
522a26c9 448 'table_name' => 'civicrm_option_value',
449 'entity' => 'OptionValue',
450 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 451 'localizable' => 0,
c3fc2621
CW
452 ],
453 ];
346aaaba 454 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 455 }
346aaaba 456 return Civi::$statics[__CLASS__]['fields'];
e501603b 457 }
c3fc2621 458
e501603b 459 /**
bd8e0b14 460 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
461 *
462 * @return array
bd8e0b14 463 * Array(string $name => string $uniqueName).
e501603b 464 */
c3fc2621 465 public static function &fieldKeys() {
bd8e0b14
TO
466 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
467 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 468 }
bd8e0b14 469 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 470 }
c3fc2621 471
e501603b
TO
472 /**
473 * Returns the names of this table
474 *
475 * @return string
476 */
c3fc2621 477 public static function getTableName() {
e501603b
TO
478 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
479 }
c3fc2621 480
e501603b
TO
481 /**
482 * Returns if this table needs to be logged
483 *
c3fc2621 484 * @return bool
e501603b 485 */
c3fc2621 486 public function getLog() {
e501603b
TO
487 return self::$_log;
488 }
c3fc2621 489
e501603b
TO
490 /**
491 * Returns the list of fields that can be imported
492 *
493 * @param bool $prefix
494 *
495 * @return array
496 */
c3fc2621
CW
497 public static function &import($prefix = FALSE) {
498 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, []);
60808919 499 return $r;
e501603b 500 }
c3fc2621 501
e501603b
TO
502 /**
503 * Returns the list of fields that can be exported
504 *
505 * @param bool $prefix
506 *
507 * @return array
508 */
c3fc2621
CW
509 public static function &export($prefix = FALSE) {
510 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, []);
60808919 511 return $r;
e501603b 512 }
c3fc2621 513
e7a6b91a
AS
514 /**
515 * Returns the list of indices
c3fc2621
CW
516 *
517 * @param bool $localize
518 *
519 * @return array
e7a6b91a
AS
520 */
521 public static function indices($localize = TRUE) {
c3fc2621
CW
522 $indices = [
523 'index_option_group_id_value' => [
e7a6b91a 524 'name' => 'index_option_group_id_value',
c3fc2621 525 'field' => [
e7a6b91a
AS
526 0 => 'value(128)',
527 1 => 'option_group_id',
c3fc2621
CW
528 ],
529 'localizable' => FALSE,
e7a6b91a 530 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
c3fc2621
CW
531 ],
532 'index_option_group_id_name' => [
e7a6b91a 533 'name' => 'index_option_group_id_name',
c3fc2621 534 'field' => [
e7a6b91a
AS
535 0 => 'name(128)',
536 1 => 'option_group_id',
c3fc2621
CW
537 ],
538 'localizable' => FALSE,
e7a6b91a 539 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
c3fc2621
CW
540 ],
541 ];
e7a6b91a
AS
542 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
543 }
c3fc2621 544
e501603b 545}