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