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