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