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