Merge pull request #11304 from JMAConsulting/CRM-21461
[civicrm-core.git] / CRM / Core / DAO / OptionValue.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
0f03f337 5 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/OptionValue.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 9 * (GenCodeChecksum:8cf699b034cbd9d7b8fe0a69250a79ba)
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 */
22 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 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Option ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Group which this option belongs to.
40 *
41 * @var int unsigned
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 *
76 * @var int unsigned
77 */
78 public $filter;
c3fc2621 79
e501603b
TO
80 /**
81 * Is this the default option for the group?
82 *
83 * @var boolean
84 */
85 public $is_default;
c3fc2621 86
e501603b
TO
87 /**
88 * Controls display sort order.
89 *
90 * @var int unsigned
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 *
104 * @var boolean
105 */
106 public $is_optgroup;
c3fc2621 107
e501603b
TO
108 /**
109 * Is this a predefined system object?
110 *
111 * @var boolean
112 */
113 public $is_reserved;
c3fc2621 114
e501603b
TO
115 /**
116 * Is this option active?
117 *
118 * @var boolean
119 */
120 public $is_active;
c3fc2621 121
e501603b
TO
122 /**
123 * Component that this option value belongs/caters to.
124 *
125 * @var int unsigned
126 */
127 public $component_id;
c3fc2621 128
e501603b
TO
129 /**
130 * Which Domain is this option value for
131 *
132 * @var int unsigned
133 */
134 public $domain_id;
c3fc2621 135
e501603b 136 /**
e501603b
TO
137 * @var int unsigned
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
TO
170 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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'),
e501603b 192 'description' => 'Option ID',
c3fc2621 193 'required' => TRUE,
522a26c9 194 'table_name' => 'civicrm_option_value',
195 'entity' => 'OptionValue',
196 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 197 'localizable' => 0,
c3fc2621
CW
198 ],
199 'option_group_id' => [
e501603b
TO
200 'name' => 'option_group_id',
201 'type' => CRM_Utils_Type::T_INT,
c3fc2621 202 'title' => ts('Option Group ID'),
e501603b 203 'description' => 'Group which this option belongs to.',
c3fc2621 204 'required' => TRUE,
522a26c9 205 'table_name' => 'civicrm_option_value',
206 'entity' => 'OptionValue',
207 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 208 'localizable' => 0,
e501603b 209 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
c3fc2621 210 'html' => [
e501603b 211 'type' => 'Select',
c3fc2621
CW
212 ],
213 'pseudoconstant' => [
e501603b
TO
214 'table' => 'civicrm_option_group',
215 'keyColumn' => 'id',
216 'labelColumn' => 'name',
c3fc2621
CW
217 ]
218 ],
219 'label' => [
e501603b
TO
220 'name' => 'label',
221 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 222 'title' => ts('Option Label'),
e501603b 223 'description' => 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.',
c3fc2621 224 'required' => TRUE,
e501603b
TO
225 'maxlength' => 512,
226 'size' => CRM_Utils_Type::HUGE,
522a26c9 227 'table_name' => 'civicrm_option_value',
228 'entity' => 'OptionValue',
229 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 230 'localizable' => 1,
c3fc2621
CW
231 ],
232 'value' => [
e501603b
TO
233 'name' => 'value',
234 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 235 'title' => ts('Option Value'),
e501603b 236 'description' => '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 237 'required' => TRUE,
e501603b
TO
238 'maxlength' => 512,
239 'size' => CRM_Utils_Type::HUGE,
522a26c9 240 'table_name' => 'civicrm_option_value',
241 'entity' => 'OptionValue',
242 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 243 'localizable' => 0,
c3fc2621
CW
244 ],
245 'name' => [
e501603b
TO
246 'name' => 'name',
247 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 248 'title' => ts('Option Name'),
e501603b
TO
249 'description' => 'Stores a fixed (non-translated) name for this option value. Lookup functions should use the name as the key for the option value row.',
250 'maxlength' => 255,
251 'size' => CRM_Utils_Type::HUGE,
c3fc2621 252 'import' => TRUE,
e501603b
TO
253 'where' => 'civicrm_option_value.name',
254 'headerPattern' => '',
255 'dataPattern' => '',
c3fc2621 256 'export' => TRUE,
522a26c9 257 'table_name' => 'civicrm_option_value',
258 'entity' => 'OptionValue',
259 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 260 'localizable' => 0,
c3fc2621
CW
261 ],
262 'grouping' => [
e501603b
TO
263 'name' => 'grouping',
264 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 265 'title' => ts('Option Grouping Name'),
e501603b
TO
266 'description' => '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.',
267 'maxlength' => 255,
268 'size' => CRM_Utils_Type::HUGE,
522a26c9 269 'table_name' => 'civicrm_option_value',
270 'entity' => 'OptionValue',
271 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 272 'localizable' => 0,
c3fc2621
CW
273 ],
274 'filter' => [
e501603b
TO
275 'name' => 'filter',
276 'type' => CRM_Utils_Type::T_INT,
c3fc2621 277 'title' => ts('Filter'),
e501603b 278 'description' => 'Bitwise logic can be used to create subsets of options within an option_group for different uses.',
522a26c9 279 'table_name' => 'civicrm_option_value',
280 'entity' => 'OptionValue',
281 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 282 'localizable' => 0,
c3fc2621
CW
283 ],
284 'is_default' => [
e501603b
TO
285 'name' => 'is_default',
286 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 287 'title' => ts('Option is Default?'),
e501603b 288 'description' => 'Is this the default option for the group?',
522a26c9 289 'table_name' => 'civicrm_option_value',
290 'entity' => 'OptionValue',
291 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 292 'localizable' => 0,
c3fc2621
CW
293 ],
294 'weight' => [
e501603b
TO
295 'name' => 'weight',
296 'type' => CRM_Utils_Type::T_INT,
c3fc2621 297 'title' => ts('Order'),
e501603b 298 'description' => 'Controls display sort order.',
c3fc2621 299 'required' => TRUE,
522a26c9 300 'table_name' => 'civicrm_option_value',
301 'entity' => 'OptionValue',
302 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 303 'localizable' => 0,
c3fc2621
CW
304 ],
305 'description' => [
e501603b
TO
306 'name' => 'description',
307 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 308 'title' => ts('Option Description'),
e501603b
TO
309 'description' => 'Optional description.',
310 'rows' => 8,
311 'cols' => 60,
522a26c9 312 'table_name' => 'civicrm_option_value',
313 'entity' => 'OptionValue',
314 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 315 'localizable' => 1,
c3fc2621 316 'html' => [
e501603b 317 'type' => 'TextArea',
c3fc2621
CW
318 ],
319 ],
320 'is_optgroup' => [
e501603b
TO
321 'name' => 'is_optgroup',
322 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 323 'title' => ts('Option is Header?'),
e501603b 324 'description' => 'Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?',
522a26c9 325 'table_name' => 'civicrm_option_value',
326 'entity' => 'OptionValue',
327 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 328 'localizable' => 0,
c3fc2621
CW
329 ],
330 'is_reserved' => [
e501603b
TO
331 'name' => 'is_reserved',
332 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 333 'title' => ts('Option Is Reserved?'),
e501603b 334 'description' => 'Is this a predefined system object?',
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_active' => [
e501603b
TO
341 'name' => 'is_active',
342 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 343 'title' => ts('Option Is Active'),
e501603b
TO
344 'description' => 'Is this option active?',
345 'default' => '1',
522a26c9 346 'table_name' => 'civicrm_option_value',
347 'entity' => 'OptionValue',
348 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 349 'localizable' => 0,
c3fc2621
CW
350 ],
351 'component_id' => [
e501603b
TO
352 'name' => 'component_id',
353 'type' => CRM_Utils_Type::T_INT,
c3fc2621 354 'title' => ts('Option Component'),
e501603b 355 'description' => 'Component that this option value belongs/caters to.',
522a26c9 356 'table_name' => 'civicrm_option_value',
357 'entity' => 'OptionValue',
358 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 359 'localizable' => 0,
e501603b 360 'FKClassName' => 'CRM_Core_DAO_Component',
c3fc2621 361 'html' => [
e501603b 362 'type' => 'Select',
c3fc2621
CW
363 ],
364 'pseudoconstant' => [
e501603b
TO
365 'table' => 'civicrm_component',
366 'keyColumn' => 'id',
367 'labelColumn' => 'name',
c3fc2621
CW
368 ]
369 ],
370 'domain_id' => [
e501603b
TO
371 'name' => 'domain_id',
372 'type' => CRM_Utils_Type::T_INT,
c3fc2621 373 'title' => ts('Option Domain'),
e501603b 374 'description' => 'Which Domain is this option value for',
522a26c9 375 'table_name' => 'civicrm_option_value',
376 'entity' => 'OptionValue',
377 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 378 'localizable' => 0,
e501603b 379 'FKClassName' => 'CRM_Core_DAO_Domain',
c3fc2621 380 'pseudoconstant' => [
e501603b
TO
381 'table' => 'civicrm_domain',
382 'keyColumn' => 'id',
383 'labelColumn' => 'name',
c3fc2621
CW
384 ]
385 ],
386 'visibility_id' => [
e501603b
TO
387 'name' => 'visibility_id',
388 'type' => CRM_Utils_Type::T_INT,
c3fc2621 389 'title' => ts('Option Visibility'),
e501603b 390 'default' => 'NULL',
522a26c9 391 'table_name' => 'civicrm_option_value',
392 'entity' => 'OptionValue',
393 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 394 'localizable' => 0,
c3fc2621
CW
395 ],
396 'icon' => [
b412f764
CW
397 'name' => 'icon',
398 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 399 'title' => ts('Icon'),
b412f764
CW
400 'description' => 'crm-i icon class',
401 'maxlength' => 255,
402 'size' => CRM_Utils_Type::HUGE,
403 'default' => 'NULL',
522a26c9 404 'table_name' => 'civicrm_option_value',
405 'entity' => 'OptionValue',
406 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 407 'localizable' => 0,
c3fc2621
CW
408 ],
409 'color' => [
d73974ac
CW
410 'name' => 'color',
411 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 412 'title' => ts('Color'),
d73974ac
CW
413 'description' => 'Hex color value e.g. #ffffff',
414 'maxlength' => 255,
415 'size' => CRM_Utils_Type::HUGE,
416 'default' => 'NULL',
522a26c9 417 'table_name' => 'civicrm_option_value',
418 'entity' => 'OptionValue',
419 'bao' => 'CRM_Core_BAO_OptionValue',
6a7e5e5d 420 'localizable' => 0,
c3fc2621
CW
421 ],
422 ];
346aaaba 423 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 424 }
346aaaba 425 return Civi::$statics[__CLASS__]['fields'];
e501603b 426 }
c3fc2621 427
e501603b 428 /**
bd8e0b14 429 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
430 *
431 * @return array
bd8e0b14 432 * Array(string $name => string $uniqueName).
e501603b 433 */
c3fc2621 434 public static function &fieldKeys() {
bd8e0b14
TO
435 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
436 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 437 }
bd8e0b14 438 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 439 }
c3fc2621 440
e501603b
TO
441 /**
442 * Returns the names of this table
443 *
444 * @return string
445 */
c3fc2621 446 public static function getTableName() {
e501603b
TO
447 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
448 }
c3fc2621 449
e501603b
TO
450 /**
451 * Returns if this table needs to be logged
452 *
c3fc2621 453 * @return bool
e501603b 454 */
c3fc2621 455 public function getLog() {
e501603b
TO
456 return self::$_log;
457 }
c3fc2621 458
e501603b
TO
459 /**
460 * Returns the list of fields that can be imported
461 *
462 * @param bool $prefix
463 *
464 * @return array
465 */
c3fc2621
CW
466 public static function &import($prefix = FALSE) {
467 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, []);
60808919 468 return $r;
e501603b 469 }
c3fc2621 470
e501603b
TO
471 /**
472 * Returns the list of fields that can be exported
473 *
474 * @param bool $prefix
475 *
476 * @return array
477 */
c3fc2621
CW
478 public static function &export($prefix = FALSE) {
479 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, []);
60808919 480 return $r;
e501603b 481 }
c3fc2621 482
e7a6b91a
AS
483 /**
484 * Returns the list of indices
c3fc2621
CW
485 *
486 * @param bool $localize
487 *
488 * @return array
e7a6b91a
AS
489 */
490 public static function indices($localize = TRUE) {
c3fc2621
CW
491 $indices = [
492 'index_option_group_id_value' => [
e7a6b91a 493 'name' => 'index_option_group_id_value',
c3fc2621 494 'field' => [
e7a6b91a
AS
495 0 => 'value(128)',
496 1 => 'option_group_id',
c3fc2621
CW
497 ],
498 'localizable' => FALSE,
e7a6b91a 499 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
c3fc2621
CW
500 ],
501 'index_option_group_id_name' => [
e7a6b91a 502 'name' => 'index_option_group_id_name',
c3fc2621 503 'field' => [
e7a6b91a
AS
504 0 => 'name(128)',
505 1 => 'option_group_id',
c3fc2621
CW
506 ],
507 'localizable' => FALSE,
e7a6b91a 508 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
c3fc2621
CW
509 ],
510 ];
e7a6b91a
AS
511 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
512 }
c3fc2621 513
e501603b 514}