Merge pull request #12503 from eileenmcnaughton/strtolower_1
[civicrm-core.git] / CRM / Core / DAO / CustomField.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Core/CustomField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:7f096c92af68ef9564675e3d708fbbe1)
10 */
11
12 /**
13 * Database access object for the CustomField entity.
14 */
15 class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 static $_tableName = 'civicrm_custom_field';
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 * Unique Custom Field ID
33 *
34 * @var int unsigned
35 */
36 public $id;
37
38 /**
39 * FK to civicrm_custom_group.
40 *
41 * @var int unsigned
42 */
43 public $custom_group_id;
44
45 /**
46 * Variable name/programmatic handle for this group.
47 *
48 * @var string
49 */
50 public $name;
51
52 /**
53 * Text for form field label (also friendly name for administering this custom property).
54 *
55 * @var string
56 */
57 public $label;
58
59 /**
60 * Controls location of data storage in extended_data table.
61 *
62 * @var string
63 */
64 public $data_type;
65
66 /**
67 * HTML types plus several built-in extended types.
68 *
69 * @var string
70 */
71 public $html_type;
72
73 /**
74 * Use form_options.is_default for field_types which use options.
75 *
76 * @var string
77 */
78 public $default_value;
79
80 /**
81 * Is a value required for this property.
82 *
83 * @var boolean
84 */
85 public $is_required;
86
87 /**
88 * Is this property searchable.
89 *
90 * @var boolean
91 */
92 public $is_searchable;
93
94 /**
95 * Is this property range searchable.
96 *
97 * @var boolean
98 */
99 public $is_search_range;
100
101 /**
102 * Controls field display order within an extended property group.
103 *
104 * @var int
105 */
106 public $weight;
107
108 /**
109 * Description and/or help text to display before this field.
110 *
111 * @var text
112 */
113 public $help_pre;
114
115 /**
116 * Description and/or help text to display after this field.
117 *
118 * @var text
119 */
120 public $help_post;
121
122 /**
123 * Optional format instructions for specific field types, like date types.
124 *
125 * @var string
126 */
127 public $mask;
128
129 /**
130 * Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes
131 *
132 * @var string
133 */
134 public $attributes;
135
136 /**
137 * Optional scripting attributes for field.
138 *
139 * @var string
140 */
141 public $javascript;
142
143 /**
144 * Is this property active?
145 *
146 * @var boolean
147 */
148 public $is_active;
149
150 /**
151 * Is this property set by PHP Code? A code field is viewable but not editable
152 *
153 * @var boolean
154 */
155 public $is_view;
156
157 /**
158 * number of options per line for checkbox and radio
159 *
160 * @var int unsigned
161 */
162 public $options_per_line;
163
164 /**
165 * field length if alphanumeric
166 *
167 * @var int unsigned
168 */
169 public $text_length;
170
171 /**
172 * Date may be up to start_date_years years prior to the current date.
173 *
174 * @var int
175 */
176 public $start_date_years;
177
178 /**
179 * Date may be up to end_date_years years after the current date.
180 *
181 * @var int
182 */
183 public $end_date_years;
184
185 /**
186 * date format for custom date
187 *
188 * @var string
189 */
190 public $date_format;
191
192 /**
193 * time format for custom date
194 *
195 * @var int unsigned
196 */
197 public $time_format;
198
199 /**
200 * Number of columns in Note Field
201 *
202 * @var int unsigned
203 */
204 public $note_columns;
205
206 /**
207 * Number of rows in Note Field
208 *
209 * @var int unsigned
210 */
211 public $note_rows;
212
213 /**
214 * Name of the column that holds the values for this field.
215 *
216 * @var string
217 */
218 public $column_name;
219
220 /**
221 * For elements with options, the option group id that is used
222 *
223 * @var int unsigned
224 */
225 public $option_group_id;
226
227 /**
228 * Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.
229 *
230 * @var string
231 */
232 public $filter;
233
234 /**
235 * Should the multi-record custom field values be displayed in tab table listing
236 *
237 * @var boolean
238 */
239 public $in_selector;
240
241 /**
242 * Class constructor.
243 */
244 public function __construct() {
245 $this->__table = 'civicrm_custom_field';
246 parent::__construct();
247 }
248
249 /**
250 * Returns foreign keys and entity references.
251 *
252 * @return array
253 * [CRM_Core_Reference_Interface]
254 */
255 public static function getReferenceColumns() {
256 if (!isset(Civi::$statics[__CLASS__]['links'])) {
257 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
258 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
259 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
260 }
261 return Civi::$statics[__CLASS__]['links'];
262 }
263
264 /**
265 * Returns all the column names of this table
266 *
267 * @return array
268 */
269 public static function &fields() {
270 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
271 Civi::$statics[__CLASS__]['fields'] = [
272 'id' => [
273 'name' => 'id',
274 'type' => CRM_Utils_Type::T_INT,
275 'title' => ts('Custom Field ID'),
276 'description' => 'Unique Custom Field ID',
277 'required' => TRUE,
278 'table_name' => 'civicrm_custom_field',
279 'entity' => 'CustomField',
280 'bao' => 'CRM_Core_BAO_CustomField',
281 'localizable' => 0,
282 ],
283 'custom_group_id' => [
284 'name' => 'custom_group_id',
285 'type' => CRM_Utils_Type::T_INT,
286 'title' => ts('Custom Group'),
287 'description' => 'FK to civicrm_custom_group.',
288 'required' => TRUE,
289 'table_name' => 'civicrm_custom_field',
290 'entity' => 'CustomField',
291 'bao' => 'CRM_Core_BAO_CustomField',
292 'localizable' => 0,
293 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
294 'html' => [
295 'type' => 'Select',
296 ],
297 'pseudoconstant' => [
298 'table' => 'civicrm_custom_group',
299 'keyColumn' => 'id',
300 'labelColumn' => 'title',
301 ]
302 ],
303 'name' => [
304 'name' => 'name',
305 'type' => CRM_Utils_Type::T_STRING,
306 'title' => ts('Custom Field Name'),
307 'description' => 'Variable name/programmatic handle for this group.',
308 'maxlength' => 64,
309 'size' => CRM_Utils_Type::BIG,
310 'table_name' => 'civicrm_custom_field',
311 'entity' => 'CustomField',
312 'bao' => 'CRM_Core_BAO_CustomField',
313 'localizable' => 0,
314 ],
315 'label' => [
316 'name' => 'label',
317 'type' => CRM_Utils_Type::T_STRING,
318 'title' => ts('Custom Field Label'),
319 'description' => 'Text for form field label (also friendly name for administering this custom property).',
320 'required' => TRUE,
321 'maxlength' => 255,
322 'size' => CRM_Utils_Type::HUGE,
323 'table_name' => 'civicrm_custom_field',
324 'entity' => 'CustomField',
325 'bao' => 'CRM_Core_BAO_CustomField',
326 'localizable' => 1,
327 ],
328 'data_type' => [
329 'name' => 'data_type',
330 'type' => CRM_Utils_Type::T_STRING,
331 'title' => ts('Custom Field Data Type'),
332 'description' => 'Controls location of data storage in extended_data table.',
333 'required' => TRUE,
334 'maxlength' => 16,
335 'size' => CRM_Utils_Type::TWELVE,
336 'table_name' => 'civicrm_custom_field',
337 'entity' => 'CustomField',
338 'bao' => 'CRM_Core_BAO_CustomField',
339 'localizable' => 0,
340 'html' => [
341 'type' => 'Select',
342 ],
343 'pseudoconstant' => [
344 'callback' => 'CRM_Core_BAO_CustomField::dataType',
345 ]
346 ],
347 'html_type' => [
348 'name' => 'html_type',
349 'type' => CRM_Utils_Type::T_STRING,
350 'title' => ts('Custom Field HTML Type'),
351 'description' => 'HTML types plus several built-in extended types.',
352 'required' => TRUE,
353 'maxlength' => 32,
354 'size' => CRM_Utils_Type::MEDIUM,
355 'table_name' => 'civicrm_custom_field',
356 'entity' => 'CustomField',
357 'bao' => 'CRM_Core_BAO_CustomField',
358 'localizable' => 0,
359 'pseudoconstant' => [
360 'callback' => 'CRM_Core_SelectValues::customHtmlType',
361 ]
362 ],
363 'default_value' => [
364 'name' => 'default_value',
365 'type' => CRM_Utils_Type::T_STRING,
366 'title' => ts('Custom Field Default'),
367 'description' => 'Use form_options.is_default for field_types which use options.',
368 'maxlength' => 255,
369 'size' => CRM_Utils_Type::HUGE,
370 'table_name' => 'civicrm_custom_field',
371 'entity' => 'CustomField',
372 'bao' => 'CRM_Core_BAO_CustomField',
373 'localizable' => 0,
374 ],
375 'is_required' => [
376 'name' => 'is_required',
377 'type' => CRM_Utils_Type::T_BOOLEAN,
378 'title' => ts('Custom Field Is Required?'),
379 'description' => 'Is a value required for this property.',
380 'default' => '0',
381 'table_name' => 'civicrm_custom_field',
382 'entity' => 'CustomField',
383 'bao' => 'CRM_Core_BAO_CustomField',
384 'localizable' => 0,
385 ],
386 'is_searchable' => [
387 'name' => 'is_searchable',
388 'type' => CRM_Utils_Type::T_BOOLEAN,
389 'title' => ts('Allow Searching on Field?'),
390 'description' => 'Is this property searchable.',
391 'default' => '0',
392 'table_name' => 'civicrm_custom_field',
393 'entity' => 'CustomField',
394 'bao' => 'CRM_Core_BAO_CustomField',
395 'localizable' => 0,
396 ],
397 'is_search_range' => [
398 'name' => 'is_search_range',
399 'type' => CRM_Utils_Type::T_BOOLEAN,
400 'title' => ts('Search as a Range'),
401 'description' => 'Is this property range searchable.',
402 'default' => '0',
403 'table_name' => 'civicrm_custom_field',
404 'entity' => 'CustomField',
405 'bao' => 'CRM_Core_BAO_CustomField',
406 'localizable' => 0,
407 ],
408 'weight' => [
409 'name' => 'weight',
410 'type' => CRM_Utils_Type::T_INT,
411 'title' => ts('Order'),
412 'description' => 'Controls field display order within an extended property group.',
413 'required' => TRUE,
414 'default' => '1',
415 'table_name' => 'civicrm_custom_field',
416 'entity' => 'CustomField',
417 'bao' => 'CRM_Core_BAO_CustomField',
418 'localizable' => 0,
419 ],
420 'help_pre' => [
421 'name' => 'help_pre',
422 'type' => CRM_Utils_Type::T_TEXT,
423 'title' => ts('Custom Field Pre Text'),
424 'description' => 'Description and/or help text to display before this field.',
425 'table_name' => 'civicrm_custom_field',
426 'entity' => 'CustomField',
427 'bao' => 'CRM_Core_BAO_CustomField',
428 'localizable' => 1,
429 ],
430 'help_post' => [
431 'name' => 'help_post',
432 'type' => CRM_Utils_Type::T_TEXT,
433 'title' => ts('Custom Field Post Text'),
434 'description' => 'Description and/or help text to display after this field.',
435 'table_name' => 'civicrm_custom_field',
436 'entity' => 'CustomField',
437 'bao' => 'CRM_Core_BAO_CustomField',
438 'localizable' => 1,
439 ],
440 'mask' => [
441 'name' => 'mask',
442 'type' => CRM_Utils_Type::T_STRING,
443 'title' => ts('Custom Field Formatting'),
444 'description' => 'Optional format instructions for specific field types, like date types.',
445 'maxlength' => 64,
446 'size' => CRM_Utils_Type::BIG,
447 'table_name' => 'civicrm_custom_field',
448 'entity' => 'CustomField',
449 'bao' => 'CRM_Core_BAO_CustomField',
450 'localizable' => 0,
451 ],
452 'attributes' => [
453 'name' => 'attributes',
454 'type' => CRM_Utils_Type::T_STRING,
455 'title' => ts('Custom Field Attributes'),
456 'description' => 'Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes',
457 'maxlength' => 255,
458 'size' => CRM_Utils_Type::HUGE,
459 'table_name' => 'civicrm_custom_field',
460 'entity' => 'CustomField',
461 'bao' => 'CRM_Core_BAO_CustomField',
462 'localizable' => 0,
463 ],
464 'javascript' => [
465 'name' => 'javascript',
466 'type' => CRM_Utils_Type::T_STRING,
467 'title' => ts('Custom Field Javascript'),
468 'description' => 'Optional scripting attributes for field.',
469 'maxlength' => 255,
470 'size' => CRM_Utils_Type::HUGE,
471 'table_name' => 'civicrm_custom_field',
472 'entity' => 'CustomField',
473 'bao' => 'CRM_Core_BAO_CustomField',
474 'localizable' => 0,
475 ],
476 'is_active' => [
477 'name' => 'is_active',
478 'type' => CRM_Utils_Type::T_BOOLEAN,
479 'title' => ts('Custom Field Is Active?'),
480 'description' => 'Is this property active?',
481 'default' => '1',
482 'table_name' => 'civicrm_custom_field',
483 'entity' => 'CustomField',
484 'bao' => 'CRM_Core_BAO_CustomField',
485 'localizable' => 0,
486 ],
487 'is_view' => [
488 'name' => 'is_view',
489 'type' => CRM_Utils_Type::T_BOOLEAN,
490 'title' => ts('Field is Viewable'),
491 'description' => 'Is this property set by PHP Code? A code field is viewable but not editable',
492 'default' => '0',
493 'table_name' => 'civicrm_custom_field',
494 'entity' => 'CustomField',
495 'bao' => 'CRM_Core_BAO_CustomField',
496 'localizable' => 0,
497 ],
498 'options_per_line' => [
499 'name' => 'options_per_line',
500 'type' => CRM_Utils_Type::T_INT,
501 'title' => ts('Field Options Per Line'),
502 'description' => 'number of options per line for checkbox and radio',
503 'table_name' => 'civicrm_custom_field',
504 'entity' => 'CustomField',
505 'bao' => 'CRM_Core_BAO_CustomField',
506 'localizable' => 0,
507 ],
508 'text_length' => [
509 'name' => 'text_length',
510 'type' => CRM_Utils_Type::T_INT,
511 'title' => ts('Field Length'),
512 'description' => 'field length if alphanumeric',
513 'table_name' => 'civicrm_custom_field',
514 'entity' => 'CustomField',
515 'bao' => 'CRM_Core_BAO_CustomField',
516 'localizable' => 0,
517 ],
518 'start_date_years' => [
519 'name' => 'start_date_years',
520 'type' => CRM_Utils_Type::T_INT,
521 'title' => ts('Field Start Date'),
522 'description' => 'Date may be up to start_date_years years prior to the current date.',
523 'table_name' => 'civicrm_custom_field',
524 'entity' => 'CustomField',
525 'bao' => 'CRM_Core_BAO_CustomField',
526 'localizable' => 0,
527 ],
528 'end_date_years' => [
529 'name' => 'end_date_years',
530 'type' => CRM_Utils_Type::T_INT,
531 'title' => ts('Field End Date'),
532 'description' => 'Date may be up to end_date_years years after the current date.',
533 'table_name' => 'civicrm_custom_field',
534 'entity' => 'CustomField',
535 'bao' => 'CRM_Core_BAO_CustomField',
536 'localizable' => 0,
537 ],
538 'date_format' => [
539 'name' => 'date_format',
540 'type' => CRM_Utils_Type::T_STRING,
541 'title' => ts('Field Data Format'),
542 'description' => 'date format for custom date',
543 'maxlength' => 64,
544 'size' => CRM_Utils_Type::BIG,
545 'table_name' => 'civicrm_custom_field',
546 'entity' => 'CustomField',
547 'bao' => 'CRM_Core_BAO_CustomField',
548 'localizable' => 0,
549 ],
550 'time_format' => [
551 'name' => 'time_format',
552 'type' => CRM_Utils_Type::T_INT,
553 'title' => ts('Field Time Format'),
554 'description' => 'time format for custom date',
555 'table_name' => 'civicrm_custom_field',
556 'entity' => 'CustomField',
557 'bao' => 'CRM_Core_BAO_CustomField',
558 'localizable' => 0,
559 ],
560 'note_columns' => [
561 'name' => 'note_columns',
562 'type' => CRM_Utils_Type::T_INT,
563 'title' => ts('Field Note Columns'),
564 'description' => ' Number of columns in Note Field ',
565 'table_name' => 'civicrm_custom_field',
566 'entity' => 'CustomField',
567 'bao' => 'CRM_Core_BAO_CustomField',
568 'localizable' => 0,
569 ],
570 'note_rows' => [
571 'name' => 'note_rows',
572 'type' => CRM_Utils_Type::T_INT,
573 'title' => ts('Field Note Rows'),
574 'description' => ' Number of rows in Note Field ',
575 'table_name' => 'civicrm_custom_field',
576 'entity' => 'CustomField',
577 'bao' => 'CRM_Core_BAO_CustomField',
578 'localizable' => 0,
579 ],
580 'column_name' => [
581 'name' => 'column_name',
582 'type' => CRM_Utils_Type::T_STRING,
583 'title' => ts('Field Column Name'),
584 'description' => 'Name of the column that holds the values for this field.',
585 'maxlength' => 255,
586 'size' => CRM_Utils_Type::HUGE,
587 'table_name' => 'civicrm_custom_field',
588 'entity' => 'CustomField',
589 'bao' => 'CRM_Core_BAO_CustomField',
590 'localizable' => 0,
591 ],
592 'option_group_id' => [
593 'name' => 'option_group_id',
594 'type' => CRM_Utils_Type::T_INT,
595 'title' => ts('Field Option Group'),
596 'description' => 'For elements with options, the option group id that is used',
597 'table_name' => 'civicrm_custom_field',
598 'entity' => 'CustomField',
599 'bao' => 'CRM_Core_BAO_CustomField',
600 'localizable' => 0,
601 'pseudoconstant' => [
602 'table' => 'civicrm_option_group',
603 'keyColumn' => 'id',
604 'labelColumn' => 'title',
605 ]
606 ],
607 'filter' => [
608 'name' => 'filter',
609 'type' => CRM_Utils_Type::T_STRING,
610 'title' => ts('Field Filter'),
611 'description' => 'Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.',
612 'maxlength' => 255,
613 'size' => CRM_Utils_Type::HUGE,
614 'table_name' => 'civicrm_custom_field',
615 'entity' => 'CustomField',
616 'bao' => 'CRM_Core_BAO_CustomField',
617 'localizable' => 0,
618 ],
619 'in_selector' => [
620 'name' => 'in_selector',
621 'type' => CRM_Utils_Type::T_BOOLEAN,
622 'title' => ts('Field Display'),
623 'description' => 'Should the multi-record custom field values be displayed in tab table listing',
624 'default' => '0',
625 'table_name' => 'civicrm_custom_field',
626 'entity' => 'CustomField',
627 'bao' => 'CRM_Core_BAO_CustomField',
628 'localizable' => 0,
629 ],
630 ];
631 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
632 }
633 return Civi::$statics[__CLASS__]['fields'];
634 }
635
636 /**
637 * Return a mapping from field-name to the corresponding key (as used in fields()).
638 *
639 * @return array
640 * Array(string $name => string $uniqueName).
641 */
642 public static function &fieldKeys() {
643 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
644 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
645 }
646 return Civi::$statics[__CLASS__]['fieldKeys'];
647 }
648
649 /**
650 * Returns the names of this table
651 *
652 * @return string
653 */
654 public static function getTableName() {
655 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
656 }
657
658 /**
659 * Returns if this table needs to be logged
660 *
661 * @return bool
662 */
663 public function getLog() {
664 return self::$_log;
665 }
666
667 /**
668 * Returns the list of fields that can be imported
669 *
670 * @param bool $prefix
671 *
672 * @return array
673 */
674 public static function &import($prefix = FALSE) {
675 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, []);
676 return $r;
677 }
678
679 /**
680 * Returns the list of fields that can be exported
681 *
682 * @param bool $prefix
683 *
684 * @return array
685 */
686 public static function &export($prefix = FALSE) {
687 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, []);
688 return $r;
689 }
690
691 /**
692 * Returns the list of indices
693 *
694 * @param bool $localize
695 *
696 * @return array
697 */
698 public static function indices($localize = TRUE) {
699 $indices = [
700 'UI_label_custom_group_id' => [
701 'name' => 'UI_label_custom_group_id',
702 'field' => [
703 0 => 'label',
704 1 => 'custom_group_id',
705 ],
706 'localizable' => TRUE,
707 'unique' => TRUE,
708 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
709 ],
710 'UI_name_custom_group_id' => [
711 'name' => 'UI_name_custom_group_id',
712 'field' => [
713 0 => 'name',
714 1 => 'custom_group_id',
715 ],
716 'localizable' => FALSE,
717 'unique' => TRUE,
718 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
719 ],
720 ];
721 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
722 }
723
724 }