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