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