Add "labelField" metadata to entities
[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:3e3cc05b51da1e0e51ac5dcbbedde392)
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 group.
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 'add' => '1.1',
311 ],
312 'custom_group_id' => [
313 'name' => 'custom_group_id',
314 'type' => CRM_Utils_Type::T_INT,
315 'title' => ts('Custom Group'),
316 'description' => ts('FK to civicrm_custom_group.'),
317 'required' => TRUE,
318 'where' => 'civicrm_custom_field.custom_group_id',
319 'table_name' => 'civicrm_custom_field',
320 'entity' => 'CustomField',
321 'bao' => 'CRM_Core_BAO_CustomField',
322 'localizable' => 0,
323 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
324 'html' => [
325 'type' => 'Select',
326 ],
327 'pseudoconstant' => [
328 'table' => 'civicrm_custom_group',
329 'keyColumn' => 'id',
330 'labelColumn' => 'title',
331 ],
332 'add' => '1.1',
333 ],
334 'name' => [
335 'name' => 'name',
336 'type' => CRM_Utils_Type::T_STRING,
337 'title' => ts('Custom Field Name'),
338 'description' => ts('Variable name/programmatic handle for this group.'),
339 'maxlength' => 64,
340 'size' => CRM_Utils_Type::BIG,
341 'where' => 'civicrm_custom_field.name',
342 'table_name' => 'civicrm_custom_field',
343 'entity' => 'CustomField',
344 'bao' => 'CRM_Core_BAO_CustomField',
345 'localizable' => 0,
346 'add' => '3.3',
347 ],
348 'label' => [
349 'name' => 'label',
350 'type' => CRM_Utils_Type::T_STRING,
351 'title' => ts('Custom Field Label'),
352 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
353 'required' => TRUE,
354 'maxlength' => 255,
355 'size' => CRM_Utils_Type::HUGE,
356 'where' => 'civicrm_custom_field.label',
357 'table_name' => 'civicrm_custom_field',
358 'entity' => 'CustomField',
359 'bao' => 'CRM_Core_BAO_CustomField',
360 'localizable' => 1,
361 'add' => '1.1',
362 ],
363 'data_type' => [
364 'name' => 'data_type',
365 'type' => CRM_Utils_Type::T_STRING,
366 'title' => ts('Custom Field Data Type'),
367 'description' => ts('Controls location of data storage in extended_data table.'),
368 'required' => TRUE,
369 'maxlength' => 16,
370 'size' => CRM_Utils_Type::TWELVE,
371 'where' => 'civicrm_custom_field.data_type',
372 'table_name' => 'civicrm_custom_field',
373 'entity' => 'CustomField',
374 'bao' => 'CRM_Core_BAO_CustomField',
375 'localizable' => 0,
376 'html' => [
377 'type' => 'Select',
378 'label' => ts("Data Type"),
379 ],
380 'pseudoconstant' => [
381 'callback' => 'CRM_Core_BAO_CustomField::dataType',
382 ],
383 'add' => '1.1',
384 ],
385 'html_type' => [
386 'name' => 'html_type',
387 'type' => CRM_Utils_Type::T_STRING,
388 'title' => ts('Custom Field HTML Type'),
389 'description' => ts('HTML types plus several built-in extended types.'),
390 'required' => TRUE,
391 'maxlength' => 32,
392 'size' => CRM_Utils_Type::MEDIUM,
393 'where' => 'civicrm_custom_field.html_type',
394 'table_name' => 'civicrm_custom_field',
395 'entity' => 'CustomField',
396 'bao' => 'CRM_Core_BAO_CustomField',
397 'localizable' => 0,
398 'html' => [
399 'type' => 'Select',
400 'label' => ts("Field Input Type"),
401 ],
402 'pseudoconstant' => [
403 'callback' => 'CRM_Core_SelectValues::customHtmlType',
404 ],
405 'add' => '1.1',
406 ],
407 'default_value' => [
408 'name' => 'default_value',
409 'type' => CRM_Utils_Type::T_STRING,
410 'title' => ts('Custom Field Default'),
411 'description' => ts('Use form_options.is_default for field_types which use options.'),
412 'maxlength' => 255,
413 'size' => CRM_Utils_Type::HUGE,
414 'where' => 'civicrm_custom_field.default_value',
415 'table_name' => 'civicrm_custom_field',
416 'entity' => 'CustomField',
417 'bao' => 'CRM_Core_BAO_CustomField',
418 'localizable' => 0,
419 'add' => '1.1',
420 ],
421 'is_required' => [
422 'name' => 'is_required',
423 'type' => CRM_Utils_Type::T_BOOLEAN,
424 'title' => ts('Custom Field Is Required?'),
425 'description' => ts('Is a value required for this property.'),
426 'where' => 'civicrm_custom_field.is_required',
427 'default' => '0',
428 'table_name' => 'civicrm_custom_field',
429 'entity' => 'CustomField',
430 'bao' => 'CRM_Core_BAO_CustomField',
431 'localizable' => 0,
432 'add' => '1.1',
433 ],
434 'is_searchable' => [
435 'name' => 'is_searchable',
436 'type' => CRM_Utils_Type::T_BOOLEAN,
437 'title' => ts('Allow Searching on Field?'),
438 'description' => ts('Is this property searchable.'),
439 'where' => 'civicrm_custom_field.is_searchable',
440 'default' => '0',
441 'table_name' => 'civicrm_custom_field',
442 'entity' => 'CustomField',
443 'bao' => 'CRM_Core_BAO_CustomField',
444 'localizable' => 0,
445 'add' => '1.1',
446 ],
447 'is_search_range' => [
448 'name' => 'is_search_range',
449 'type' => CRM_Utils_Type::T_BOOLEAN,
450 'title' => ts('Search as a Range'),
451 'description' => ts('Is this property range searchable.'),
452 'where' => 'civicrm_custom_field.is_search_range',
453 'default' => '0',
454 'table_name' => 'civicrm_custom_field',
455 'entity' => 'CustomField',
456 'bao' => 'CRM_Core_BAO_CustomField',
457 'localizable' => 0,
458 'add' => '1.4',
459 ],
460 'weight' => [
461 'name' => 'weight',
462 'type' => CRM_Utils_Type::T_INT,
463 'title' => ts('Order'),
464 'description' => ts('Controls field display order within an extended property group.'),
465 'required' => TRUE,
466 'where' => 'civicrm_custom_field.weight',
467 'default' => '1',
468 'table_name' => 'civicrm_custom_field',
469 'entity' => 'CustomField',
470 'bao' => 'CRM_Core_BAO_CustomField',
471 'localizable' => 0,
472 'add' => '1.1',
473 ],
474 'help_pre' => [
475 'name' => 'help_pre',
476 'type' => CRM_Utils_Type::T_TEXT,
477 'title' => ts('Custom Field Pre Text'),
478 'description' => ts('Description and/or help text to display before this field.'),
479 'where' => 'civicrm_custom_field.help_pre',
480 'table_name' => 'civicrm_custom_field',
481 'entity' => 'CustomField',
482 'bao' => 'CRM_Core_BAO_CustomField',
483 'localizable' => 1,
484 'add' => '1.1',
485 ],
486 'help_post' => [
487 'name' => 'help_post',
488 'type' => CRM_Utils_Type::T_TEXT,
489 'title' => ts('Custom Field Post Text'),
490 'description' => ts('Description and/or help text to display after this field.'),
491 'where' => 'civicrm_custom_field.help_post',
492 'table_name' => 'civicrm_custom_field',
493 'entity' => 'CustomField',
494 'bao' => 'CRM_Core_BAO_CustomField',
495 'localizable' => 1,
496 'add' => '1.1',
497 ],
498 'mask' => [
499 'name' => 'mask',
500 'type' => CRM_Utils_Type::T_STRING,
501 'title' => ts('Custom Field Formatting'),
502 'description' => ts('Optional format instructions for specific field types, like date types.'),
503 'maxlength' => 64,
504 'size' => CRM_Utils_Type::BIG,
505 'where' => 'civicrm_custom_field.mask',
506 'table_name' => 'civicrm_custom_field',
507 'entity' => 'CustomField',
508 'bao' => 'CRM_Core_BAO_CustomField',
509 'localizable' => 0,
510 'add' => '1.1',
511 ],
512 'attributes' => [
513 'name' => 'attributes',
514 'type' => CRM_Utils_Type::T_STRING,
515 'title' => ts('Custom Field Attributes'),
516 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
517 'maxlength' => 255,
518 'size' => CRM_Utils_Type::HUGE,
519 'where' => 'civicrm_custom_field.attributes',
520 'table_name' => 'civicrm_custom_field',
521 'entity' => 'CustomField',
522 'bao' => 'CRM_Core_BAO_CustomField',
523 'localizable' => 0,
524 'add' => '1.1',
525 ],
526 'javascript' => [
527 'name' => 'javascript',
528 'type' => CRM_Utils_Type::T_STRING,
529 'title' => ts('Custom Field Javascript'),
530 'description' => ts('Optional scripting attributes for field.'),
531 'maxlength' => 255,
532 'size' => CRM_Utils_Type::HUGE,
533 'where' => 'civicrm_custom_field.javascript',
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
537 'localizable' => 0,
538 'add' => '1.1',
539 ],
540 'is_active' => [
541 'name' => 'is_active',
542 'type' => CRM_Utils_Type::T_BOOLEAN,
543 'title' => ts('Custom Field Is Active?'),
544 'description' => ts('Is this property active?'),
545 'where' => 'civicrm_custom_field.is_active',
546 'default' => '1',
547 'table_name' => 'civicrm_custom_field',
548 'entity' => 'CustomField',
549 'bao' => 'CRM_Core_BAO_CustomField',
550 'localizable' => 0,
551 'add' => '1.1',
552 ],
553 'is_view' => [
554 'name' => 'is_view',
555 'type' => CRM_Utils_Type::T_BOOLEAN,
556 'title' => ts('Field is Viewable'),
557 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
558 'where' => 'civicrm_custom_field.is_view',
559 'default' => '0',
560 'table_name' => 'civicrm_custom_field',
561 'entity' => 'CustomField',
562 'bao' => 'CRM_Core_BAO_CustomField',
563 'localizable' => 0,
564 'add' => '1.1',
565 ],
566 'options_per_line' => [
567 'name' => 'options_per_line',
568 'type' => CRM_Utils_Type::T_INT,
569 'title' => ts('Field Options Per Line'),
570 'description' => ts('number of options per line for checkbox and radio'),
571 'where' => 'civicrm_custom_field.options_per_line',
572 'table_name' => 'civicrm_custom_field',
573 'entity' => 'CustomField',
574 'bao' => 'CRM_Core_BAO_CustomField',
575 'localizable' => 0,
576 'add' => NULL,
577 ],
578 'text_length' => [
579 'name' => 'text_length',
580 'type' => CRM_Utils_Type::T_INT,
581 'title' => ts('Field Length'),
582 'description' => ts('field length if alphanumeric'),
583 'where' => 'civicrm_custom_field.text_length',
584 'table_name' => 'civicrm_custom_field',
585 'entity' => 'CustomField',
586 'bao' => 'CRM_Core_BAO_CustomField',
587 'localizable' => 0,
588 'add' => '2.2',
589 ],
590 'start_date_years' => [
591 'name' => 'start_date_years',
592 'type' => CRM_Utils_Type::T_INT,
593 'title' => ts('Field Start Date'),
594 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
595 'where' => 'civicrm_custom_field.start_date_years',
596 'table_name' => 'civicrm_custom_field',
597 'entity' => 'CustomField',
598 'bao' => 'CRM_Core_BAO_CustomField',
599 'localizable' => 0,
600 'add' => '1.4',
601 ],
602 'end_date_years' => [
603 'name' => 'end_date_years',
604 'type' => CRM_Utils_Type::T_INT,
605 'title' => ts('Field End Date'),
606 'description' => ts('Date may be up to end_date_years years after the current date.'),
607 'where' => 'civicrm_custom_field.end_date_years',
608 'table_name' => 'civicrm_custom_field',
609 'entity' => 'CustomField',
610 'bao' => 'CRM_Core_BAO_CustomField',
611 'localizable' => 0,
612 'add' => '1.4',
613 ],
614 'date_format' => [
615 'name' => 'date_format',
616 'type' => CRM_Utils_Type::T_STRING,
617 'title' => ts('Field Data Format'),
618 'description' => ts('date format for custom date'),
619 'maxlength' => 64,
620 'size' => CRM_Utils_Type::BIG,
621 'where' => 'civicrm_custom_field.date_format',
622 'table_name' => 'civicrm_custom_field',
623 'entity' => 'CustomField',
624 'bao' => 'CRM_Core_BAO_CustomField',
625 'localizable' => 0,
626 'pseudoconstant' => [
627 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
628 ],
629 'add' => '3.1',
630 ],
631 'time_format' => [
632 'name' => 'time_format',
633 'type' => CRM_Utils_Type::T_INT,
634 'title' => ts('Field Time Format'),
635 'description' => ts('time format for custom date'),
636 'where' => 'civicrm_custom_field.time_format',
637 'table_name' => 'civicrm_custom_field',
638 'entity' => 'CustomField',
639 'bao' => 'CRM_Core_BAO_CustomField',
640 'localizable' => 0,
641 'pseudoconstant' => [
642 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
643 ],
644 'add' => '3.1',
645 ],
646 'note_columns' => [
647 'name' => 'note_columns',
648 'type' => CRM_Utils_Type::T_INT,
649 'title' => ts('Field Note Columns'),
650 'description' => ts('Number of columns in Note Field'),
651 'where' => 'civicrm_custom_field.note_columns',
652 'table_name' => 'civicrm_custom_field',
653 'entity' => 'CustomField',
654 'bao' => 'CRM_Core_BAO_CustomField',
655 'localizable' => 0,
656 'add' => '1.4',
657 ],
658 'note_rows' => [
659 'name' => 'note_rows',
660 'type' => CRM_Utils_Type::T_INT,
661 'title' => ts('Field Note Rows'),
662 'description' => ts('Number of rows in Note Field'),
663 'where' => 'civicrm_custom_field.note_rows',
664 'table_name' => 'civicrm_custom_field',
665 'entity' => 'CustomField',
666 'bao' => 'CRM_Core_BAO_CustomField',
667 'localizable' => 0,
668 'add' => '1.4',
669 ],
670 'column_name' => [
671 'name' => 'column_name',
672 'type' => CRM_Utils_Type::T_STRING,
673 'title' => ts('Field Column Name'),
674 'description' => ts('Name of the column that holds the values for this field.'),
675 'maxlength' => 255,
676 'size' => CRM_Utils_Type::HUGE,
677 'where' => 'civicrm_custom_field.column_name',
678 'table_name' => 'civicrm_custom_field',
679 'entity' => 'CustomField',
680 'bao' => 'CRM_Core_BAO_CustomField',
681 'localizable' => 0,
682 'add' => '2.0',
683 ],
684 'option_group_id' => [
685 'name' => 'option_group_id',
686 'type' => CRM_Utils_Type::T_INT,
687 'title' => ts('Field Option Group'),
688 'description' => ts('For elements with options, the option group id that is used'),
689 'where' => 'civicrm_custom_field.option_group_id',
690 'table_name' => 'civicrm_custom_field',
691 'entity' => 'CustomField',
692 'bao' => 'CRM_Core_BAO_CustomField',
693 'localizable' => 0,
694 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
695 'pseudoconstant' => [
696 'table' => 'civicrm_option_group',
697 'keyColumn' => 'id',
698 'labelColumn' => 'title',
699 ],
700 'add' => '1.4',
701 ],
702 'serialize' => [
703 'name' => 'serialize',
704 'type' => CRM_Utils_Type::T_INT,
705 'title' => ts('Serialize'),
706 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
707 'required' => TRUE,
708 'where' => 'civicrm_custom_field.serialize',
709 'default' => '0',
710 'table_name' => 'civicrm_custom_field',
711 'entity' => 'CustomField',
712 'bao' => 'CRM_Core_BAO_CustomField',
713 'localizable' => 0,
714 'pseudoconstant' => [
715 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
716 ],
717 'add' => '5.27',
718 ],
719 'filter' => [
720 'name' => 'filter',
721 'type' => CRM_Utils_Type::T_STRING,
722 'title' => ts('Field Filter'),
723 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
724 'maxlength' => 255,
725 'size' => CRM_Utils_Type::HUGE,
726 'where' => 'civicrm_custom_field.filter',
727 'table_name' => 'civicrm_custom_field',
728 'entity' => 'CustomField',
729 'bao' => 'CRM_Core_BAO_CustomField',
730 'localizable' => 0,
731 'add' => '4.1',
732 ],
733 'in_selector' => [
734 'name' => 'in_selector',
735 'type' => CRM_Utils_Type::T_BOOLEAN,
736 'title' => ts('Field Display'),
737 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
738 'where' => 'civicrm_custom_field.in_selector',
739 'default' => '0',
740 'table_name' => 'civicrm_custom_field',
741 'entity' => 'CustomField',
742 'bao' => 'CRM_Core_BAO_CustomField',
743 'localizable' => 0,
744 'add' => '4.5',
745 ],
746 ];
747 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
748 }
749 return Civi::$statics[__CLASS__]['fields'];
750 }
751
752 /**
753 * Return a mapping from field-name to the corresponding key (as used in fields()).
754 *
755 * @return array
756 * Array(string $name => string $uniqueName).
757 */
758 public static function &fieldKeys() {
759 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
760 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
761 }
762 return Civi::$statics[__CLASS__]['fieldKeys'];
763 }
764
765 /**
766 * Returns the names of this table
767 *
768 * @return string
769 */
770 public static function getTableName() {
771 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
772 }
773
774 /**
775 * Returns if this table needs to be logged
776 *
777 * @return bool
778 */
779 public function getLog() {
780 return self::$_log;
781 }
782
783 /**
784 * Returns the list of fields that can be imported
785 *
786 * @param bool $prefix
787 *
788 * @return array
789 */
790 public static function &import($prefix = FALSE) {
791 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, []);
792 return $r;
793 }
794
795 /**
796 * Returns the list of fields that can be exported
797 *
798 * @param bool $prefix
799 *
800 * @return array
801 */
802 public static function &export($prefix = FALSE) {
803 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, []);
804 return $r;
805 }
806
807 /**
808 * Returns the list of indices
809 *
810 * @param bool $localize
811 *
812 * @return array
813 */
814 public static function indices($localize = TRUE) {
815 $indices = [
816 'UI_label_custom_group_id' => [
817 'name' => 'UI_label_custom_group_id',
818 'field' => [
819 0 => 'label',
820 1 => 'custom_group_id',
821 ],
822 'localizable' => TRUE,
823 'unique' => TRUE,
824 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
825 ],
826 'UI_name_custom_group_id' => [
827 'name' => 'UI_name_custom_group_id',
828 'field' => [
829 0 => 'name',
830 1 => 'custom_group_id',
831 ],
832 'localizable' => FALSE,
833 'unique' => TRUE,
834 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
835 ],
836 ];
837 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
838 }
839
840 }