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