curious
[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:171565168517add49222893871a84e43)
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 'readonly' => TRUE,
212 'add' => '1.5',
213 ],
214 'option_group_id' => [
215 'name' => 'option_group_id',
216 'type' => CRM_Utils_Type::T_INT,
217 'title' => ts('Option Group ID'),
218 'description' => ts('Group which this option belongs to.'),
219 'required' => TRUE,
220 'where' => 'civicrm_option_value.option_group_id',
221 'table_name' => 'civicrm_option_value',
222 'entity' => 'OptionValue',
223 'bao' => 'CRM_Core_BAO_OptionValue',
224 'localizable' => 0,
225 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
226 'html' => [
227 'type' => 'Select',
228 'label' => ts("Option Group"),
229 ],
230 'pseudoconstant' => [
231 'table' => 'civicrm_option_group',
232 'keyColumn' => 'id',
233 'labelColumn' => 'title',
234 'nameColumn' => 'name',
235 ],
236 'add' => '1.5',
237 ],
238 'label' => [
239 'name' => 'label',
240 'type' => CRM_Utils_Type::T_STRING,
241 'title' => ts('Option Label'),
242 'description' => ts('Option string as displayed to users - e.g. the label in an HTML OPTION tag.'),
243 'required' => TRUE,
244 'maxlength' => 512,
245 'size' => CRM_Utils_Type::HUGE,
246 'where' => 'civicrm_option_value.label',
247 'table_name' => 'civicrm_option_value',
248 'entity' => 'OptionValue',
249 'bao' => 'CRM_Core_BAO_OptionValue',
250 'localizable' => 1,
251 'add' => '1.5',
252 ],
253 'value' => [
254 'name' => 'value',
255 'type' => CRM_Utils_Type::T_STRING,
256 'title' => ts('Option Value'),
257 '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.'),
258 'required' => TRUE,
259 'maxlength' => 512,
260 'size' => CRM_Utils_Type::HUGE,
261 'where' => 'civicrm_option_value.value',
262 'table_name' => 'civicrm_option_value',
263 'entity' => 'OptionValue',
264 'bao' => 'CRM_Core_BAO_OptionValue',
265 'localizable' => 0,
266 'add' => '1.5',
267 ],
268 'name' => [
269 'name' => 'name',
270 'type' => CRM_Utils_Type::T_STRING,
271 'title' => ts('Option Name'),
272 '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.'),
273 'maxlength' => 255,
274 'size' => CRM_Utils_Type::HUGE,
275 'import' => TRUE,
276 'where' => 'civicrm_option_value.name',
277 'export' => TRUE,
278 'table_name' => 'civicrm_option_value',
279 'entity' => 'OptionValue',
280 'bao' => 'CRM_Core_BAO_OptionValue',
281 'localizable' => 0,
282 'add' => '1.5',
283 ],
284 'grouping' => [
285 'name' => 'grouping',
286 'type' => CRM_Utils_Type::T_STRING,
287 'title' => ts('Option Grouping Name'),
288 '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.'),
289 'maxlength' => 255,
290 'size' => CRM_Utils_Type::HUGE,
291 'where' => 'civicrm_option_value.grouping',
292 'table_name' => 'civicrm_option_value',
293 'entity' => 'OptionValue',
294 'bao' => 'CRM_Core_BAO_OptionValue',
295 'localizable' => 0,
296 'add' => '1.5',
297 ],
298 'filter' => [
299 'name' => 'filter',
300 'type' => CRM_Utils_Type::T_INT,
301 'title' => ts('Filter'),
302 'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
303 'where' => 'civicrm_option_value.filter',
304 'default' => '0',
305 'table_name' => 'civicrm_option_value',
306 'entity' => 'OptionValue',
307 'bao' => 'CRM_Core_BAO_OptionValue',
308 'localizable' => 0,
309 'html' => [
310 'label' => ts("Filter"),
311 ],
312 'add' => '1.5',
313 ],
314 'is_default' => [
315 'name' => 'is_default',
316 'type' => CRM_Utils_Type::T_BOOLEAN,
317 'title' => ts('Option is Default?'),
318 'description' => ts('Is this the default option for the group?'),
319 'where' => 'civicrm_option_value.is_default',
320 'default' => '0',
321 'table_name' => 'civicrm_option_value',
322 'entity' => 'OptionValue',
323 'bao' => 'CRM_Core_BAO_OptionValue',
324 'localizable' => 0,
325 'add' => '1.5',
326 ],
327 'weight' => [
328 'name' => 'weight',
329 'type' => CRM_Utils_Type::T_INT,
330 'title' => ts('Order'),
331 'description' => ts('Controls display sort order.'),
332 'required' => TRUE,
333 'where' => 'civicrm_option_value.weight',
334 'table_name' => 'civicrm_option_value',
335 'entity' => 'OptionValue',
336 'bao' => 'CRM_Core_BAO_OptionValue',
337 'localizable' => 0,
338 'add' => '1.5',
339 ],
340 'description' => [
341 'name' => 'description',
342 'type' => CRM_Utils_Type::T_TEXT,
343 'title' => ts('Option Description'),
344 'description' => ts('Optional description.'),
345 'rows' => 8,
346 'cols' => 60,
347 'where' => 'civicrm_option_value.description',
348 'table_name' => 'civicrm_option_value',
349 'entity' => 'OptionValue',
350 'bao' => 'CRM_Core_BAO_OptionValue',
351 'localizable' => 1,
352 'html' => [
353 'type' => 'TextArea',
354 ],
355 'add' => '1.5',
356 ],
357 'is_optgroup' => [
358 'name' => 'is_optgroup',
359 'type' => CRM_Utils_Type::T_BOOLEAN,
360 'title' => ts('Option is Header?'),
361 '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?'),
362 'where' => 'civicrm_option_value.is_optgroup',
363 'default' => '0',
364 'table_name' => 'civicrm_option_value',
365 'entity' => 'OptionValue',
366 'bao' => 'CRM_Core_BAO_OptionValue',
367 'localizable' => 0,
368 'add' => '1.5',
369 ],
370 'is_reserved' => [
371 'name' => 'is_reserved',
372 'type' => CRM_Utils_Type::T_BOOLEAN,
373 'title' => ts('Option Is Reserved?'),
374 'description' => ts('Is this a predefined system object?'),
375 'where' => 'civicrm_option_value.is_reserved',
376 'default' => '0',
377 'table_name' => 'civicrm_option_value',
378 'entity' => 'OptionValue',
379 'bao' => 'CRM_Core_BAO_OptionValue',
380 'localizable' => 0,
381 'add' => '1.5',
382 ],
383 'is_active' => [
384 'name' => 'is_active',
385 'type' => CRM_Utils_Type::T_BOOLEAN,
386 'title' => ts('Option Is Active'),
387 'description' => ts('Is this option active?'),
388 'where' => 'civicrm_option_value.is_active',
389 'default' => '1',
390 'table_name' => 'civicrm_option_value',
391 'entity' => 'OptionValue',
392 'bao' => 'CRM_Core_BAO_OptionValue',
393 'localizable' => 0,
394 'add' => '1.5',
395 ],
396 'component_id' => [
397 'name' => 'component_id',
398 'type' => CRM_Utils_Type::T_INT,
399 'title' => ts('Component ID'),
400 'description' => ts('Component that this option value belongs/caters to.'),
401 'where' => 'civicrm_option_value.component_id',
402 'table_name' => 'civicrm_option_value',
403 'entity' => 'OptionValue',
404 'bao' => 'CRM_Core_BAO_OptionValue',
405 'localizable' => 0,
406 'FKClassName' => 'CRM_Core_DAO_Component',
407 'html' => [
408 'type' => 'Select',
409 'label' => ts("Component"),
410 ],
411 'pseudoconstant' => [
412 'table' => 'civicrm_component',
413 'keyColumn' => 'id',
414 'labelColumn' => 'name',
415 ],
416 'add' => '2.0',
417 ],
418 'domain_id' => [
419 'name' => 'domain_id',
420 'type' => CRM_Utils_Type::T_INT,
421 'title' => ts('Domain ID'),
422 'description' => ts('Which Domain is this option value for'),
423 'where' => 'civicrm_option_value.domain_id',
424 'table_name' => 'civicrm_option_value',
425 'entity' => 'OptionValue',
426 'bao' => 'CRM_Core_BAO_OptionValue',
427 'localizable' => 0,
428 'FKClassName' => 'CRM_Core_DAO_Domain',
429 'html' => [
430 'label' => ts("Domain"),
431 ],
432 'pseudoconstant' => [
433 'table' => 'civicrm_domain',
434 'keyColumn' => 'id',
435 'labelColumn' => 'name',
436 ],
437 'add' => '3.1',
438 ],
439 'visibility_id' => [
440 'name' => 'visibility_id',
441 'type' => CRM_Utils_Type::T_INT,
442 'title' => ts('Option Visibility'),
443 'where' => 'civicrm_option_value.visibility_id',
444 'default' => NULL,
445 'table_name' => 'civicrm_option_value',
446 'entity' => 'OptionValue',
447 'bao' => 'CRM_Core_BAO_OptionValue',
448 'localizable' => 0,
449 'pseudoconstant' => [
450 'optionGroupName' => 'visibility',
451 'optionEditPath' => 'civicrm/admin/options/visibility',
452 ],
453 'add' => '2.2',
454 ],
455 'icon' => [
456 'name' => 'icon',
457 'type' => CRM_Utils_Type::T_STRING,
458 'title' => ts('Icon'),
459 'description' => ts('crm-i icon class'),
460 'maxlength' => 255,
461 'size' => CRM_Utils_Type::HUGE,
462 'where' => 'civicrm_option_value.icon',
463 'default' => NULL,
464 'table_name' => 'civicrm_option_value',
465 'entity' => 'OptionValue',
466 'bao' => 'CRM_Core_BAO_OptionValue',
467 'localizable' => 0,
468 'add' => '4.7',
469 ],
470 'color' => [
471 'name' => 'color',
472 'type' => CRM_Utils_Type::T_STRING,
473 'title' => ts('Color'),
474 'description' => ts('Hex color value e.g. #ffffff'),
475 'maxlength' => 255,
476 'size' => CRM_Utils_Type::HUGE,
477 'where' => 'civicrm_option_value.color',
478 'default' => NULL,
479 'table_name' => 'civicrm_option_value',
480 'entity' => 'OptionValue',
481 'bao' => 'CRM_Core_BAO_OptionValue',
482 'localizable' => 0,
483 'add' => '4.7',
484 ],
485 ];
486 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
487 }
488 return Civi::$statics[__CLASS__]['fields'];
489 }
490
491 /**
492 * Return a mapping from field-name to the corresponding key (as used in fields()).
493 *
494 * @return array
495 * Array(string $name => string $uniqueName).
496 */
497 public static function &fieldKeys() {
498 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
499 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
500 }
501 return Civi::$statics[__CLASS__]['fieldKeys'];
502 }
503
504 /**
505 * Returns the names of this table
506 *
507 * @return string
508 */
509 public static function getTableName() {
510 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
511 }
512
513 /**
514 * Returns if this table needs to be logged
515 *
516 * @return bool
517 */
518 public function getLog() {
519 return self::$_log;
520 }
521
522 /**
523 * Returns the list of fields that can be imported
524 *
525 * @param bool $prefix
526 *
527 * @return array
528 */
529 public static function &import($prefix = FALSE) {
530 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'option_value', $prefix, []);
531 return $r;
532 }
533
534 /**
535 * Returns the list of fields that can be exported
536 *
537 * @param bool $prefix
538 *
539 * @return array
540 */
541 public static function &export($prefix = FALSE) {
542 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'option_value', $prefix, []);
543 return $r;
544 }
545
546 /**
547 * Returns the list of indices
548 *
549 * @param bool $localize
550 *
551 * @return array
552 */
553 public static function indices($localize = TRUE) {
554 $indices = [
555 'index_option_group_id_value' => [
556 'name' => 'index_option_group_id_value',
557 'field' => [
558 0 => 'value(128)',
559 1 => 'option_group_id',
560 ],
561 'localizable' => FALSE,
562 'sig' => 'civicrm_option_value::0::value(128)::option_group_id',
563 ],
564 'index_option_group_id_name' => [
565 'name' => 'index_option_group_id_name',
566 'field' => [
567 0 => 'name(128)',
568 1 => 'option_group_id',
569 ],
570 'localizable' => FALSE,
571 'sig' => 'civicrm_option_value::0::name(128)::option_group_id',
572 ],
573 ];
574 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
575 }
576
577 }