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