CustomField Admin - Decouple page code from form code
[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:6653fe86552a321a498736c14cabc41d)
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|null
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|null
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|null
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|null
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|null
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 'where' => 'civicrm_custom_field.is_required',
507 'default' => '0',
508 'table_name' => 'civicrm_custom_field',
509 'entity' => 'CustomField',
510 'bao' => 'CRM_Core_BAO_CustomField',
511 'localizable' => 0,
512 'add' => '1.1',
513 ],
514 'is_searchable' => [
515 'name' => 'is_searchable',
516 'type' => CRM_Utils_Type::T_BOOLEAN,
517 'title' => ts('Allow Searching on Field?'),
518 'description' => ts('Is this property searchable.'),
519 'where' => 'civicrm_custom_field.is_searchable',
520 'default' => '0',
521 'table_name' => 'civicrm_custom_field',
522 'entity' => 'CustomField',
523 'bao' => 'CRM_Core_BAO_CustomField',
524 'localizable' => 0,
525 'add' => '1.1',
526 ],
527 'is_search_range' => [
528 'name' => 'is_search_range',
529 'type' => CRM_Utils_Type::T_BOOLEAN,
530 'title' => ts('Search as a Range'),
531 'description' => ts('Is this property range searchable.'),
532 'where' => 'civicrm_custom_field.is_search_range',
533 'default' => '0',
534 'table_name' => 'civicrm_custom_field',
535 'entity' => 'CustomField',
536 'bao' => 'CRM_Core_BAO_CustomField',
537 'localizable' => 0,
538 'add' => '1.4',
539 ],
540 'weight' => [
541 'name' => 'weight',
542 'type' => CRM_Utils_Type::T_INT,
543 'title' => ts('Order'),
544 'description' => ts('Controls field display order within an extended property group.'),
545 'required' => TRUE,
546 'where' => 'civicrm_custom_field.weight',
547 'default' => '1',
548 'table_name' => 'civicrm_custom_field',
549 'entity' => 'CustomField',
550 'bao' => 'CRM_Core_BAO_CustomField',
551 'localizable' => 0,
552 'add' => '1.1',
553 ],
554 'help_pre' => [
555 'name' => 'help_pre',
556 'type' => CRM_Utils_Type::T_TEXT,
557 'title' => ts('Custom Field Pre Text'),
558 'description' => ts('Description and/or help text to display before this field.'),
559 'where' => 'civicrm_custom_field.help_pre',
560 'table_name' => 'civicrm_custom_field',
561 'entity' => 'CustomField',
562 'bao' => 'CRM_Core_BAO_CustomField',
563 'localizable' => 1,
564 'add' => '1.1',
565 ],
566 'help_post' => [
567 'name' => 'help_post',
568 'type' => CRM_Utils_Type::T_TEXT,
569 'title' => ts('Custom Field Post Text'),
570 'description' => ts('Description and/or help text to display after this field.'),
571 'where' => 'civicrm_custom_field.help_post',
572 'table_name' => 'civicrm_custom_field',
573 'entity' => 'CustomField',
574 'bao' => 'CRM_Core_BAO_CustomField',
575 'localizable' => 1,
576 'add' => '1.1',
577 ],
578 'mask' => [
579 'name' => 'mask',
580 'type' => CRM_Utils_Type::T_STRING,
581 'title' => ts('Custom Field Formatting'),
582 'description' => ts('Optional format instructions for specific field types, like date types.'),
583 'maxlength' => 64,
584 'size' => CRM_Utils_Type::BIG,
585 'where' => 'civicrm_custom_field.mask',
586 'table_name' => 'civicrm_custom_field',
587 'entity' => 'CustomField',
588 'bao' => 'CRM_Core_BAO_CustomField',
589 'localizable' => 0,
590 'add' => '1.1',
591 ],
592 'attributes' => [
593 'name' => 'attributes',
594 'type' => CRM_Utils_Type::T_STRING,
595 'title' => ts('Custom Field Attributes'),
596 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
597 'maxlength' => 255,
598 'size' => CRM_Utils_Type::HUGE,
599 'where' => 'civicrm_custom_field.attributes',
600 'table_name' => 'civicrm_custom_field',
601 'entity' => 'CustomField',
602 'bao' => 'CRM_Core_BAO_CustomField',
603 'localizable' => 0,
604 'add' => '1.1',
605 ],
606 'javascript' => [
607 'name' => 'javascript',
608 'type' => CRM_Utils_Type::T_STRING,
609 'title' => ts('Custom Field Javascript'),
610 'description' => ts('Optional scripting attributes for field.'),
611 'maxlength' => 255,
612 'size' => CRM_Utils_Type::HUGE,
613 'where' => 'civicrm_custom_field.javascript',
614 'table_name' => 'civicrm_custom_field',
615 'entity' => 'CustomField',
616 'bao' => 'CRM_Core_BAO_CustomField',
617 'localizable' => 0,
618 'add' => '1.1',
619 ],
620 'is_active' => [
621 'name' => 'is_active',
622 'type' => CRM_Utils_Type::T_BOOLEAN,
623 'title' => ts('Custom Field Is Active?'),
624 'description' => ts('Is this property active?'),
625 'where' => 'civicrm_custom_field.is_active',
626 'default' => '1',
627 'table_name' => 'civicrm_custom_field',
628 'entity' => 'CustomField',
629 'bao' => 'CRM_Core_BAO_CustomField',
630 'localizable' => 0,
631 'add' => '1.1',
632 ],
633 'is_view' => [
634 'name' => 'is_view',
635 'type' => CRM_Utils_Type::T_BOOLEAN,
636 'title' => ts('Field is Viewable'),
637 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
638 'where' => 'civicrm_custom_field.is_view',
639 'default' => '0',
640 'table_name' => 'civicrm_custom_field',
641 'entity' => 'CustomField',
642 'bao' => 'CRM_Core_BAO_CustomField',
643 'localizable' => 0,
644 'add' => '1.1',
645 ],
646 'options_per_line' => [
647 'name' => 'options_per_line',
648 'type' => CRM_Utils_Type::T_INT,
649 'title' => ts('Field Options Per Line'),
650 'description' => ts('number of options per line for checkbox and radio'),
651 'where' => 'civicrm_custom_field.options_per_line',
652 'table_name' => 'civicrm_custom_field',
653 'entity' => 'CustomField',
654 'bao' => 'CRM_Core_BAO_CustomField',
655 'localizable' => 0,
656 'add' => NULL,
657 ],
658 'text_length' => [
659 'name' => 'text_length',
660 'type' => CRM_Utils_Type::T_INT,
661 'title' => ts('Field Length'),
662 'description' => ts('field length if alphanumeric'),
663 'where' => 'civicrm_custom_field.text_length',
664 'table_name' => 'civicrm_custom_field',
665 'entity' => 'CustomField',
666 'bao' => 'CRM_Core_BAO_CustomField',
667 'localizable' => 0,
668 'add' => '2.2',
669 ],
670 'start_date_years' => [
671 'name' => 'start_date_years',
672 'type' => CRM_Utils_Type::T_INT,
673 'title' => ts('Field Start Date'),
674 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
675 'where' => 'civicrm_custom_field.start_date_years',
676 'table_name' => 'civicrm_custom_field',
677 'entity' => 'CustomField',
678 'bao' => 'CRM_Core_BAO_CustomField',
679 'localizable' => 0,
680 'add' => '1.4',
681 ],
682 'end_date_years' => [
683 'name' => 'end_date_years',
684 'type' => CRM_Utils_Type::T_INT,
685 'title' => ts('Field End Date'),
686 'description' => ts('Date may be up to end_date_years years after the current date.'),
687 'where' => 'civicrm_custom_field.end_date_years',
688 'table_name' => 'civicrm_custom_field',
689 'entity' => 'CustomField',
690 'bao' => 'CRM_Core_BAO_CustomField',
691 'localizable' => 0,
692 'add' => '1.4',
693 ],
694 'date_format' => [
695 'name' => 'date_format',
696 'type' => CRM_Utils_Type::T_STRING,
697 'title' => ts('Field Data Format'),
698 'description' => ts('date format for custom date'),
699 'maxlength' => 64,
700 'size' => CRM_Utils_Type::BIG,
701 'where' => 'civicrm_custom_field.date_format',
702 'table_name' => 'civicrm_custom_field',
703 'entity' => 'CustomField',
704 'bao' => 'CRM_Core_BAO_CustomField',
705 'localizable' => 0,
706 'pseudoconstant' => [
707 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
708 ],
709 'add' => '3.1',
710 ],
711 'time_format' => [
712 'name' => 'time_format',
713 'type' => CRM_Utils_Type::T_INT,
714 'title' => ts('Field Time Format'),
715 'description' => ts('time format for custom date'),
716 'where' => 'civicrm_custom_field.time_format',
717 'table_name' => 'civicrm_custom_field',
718 'entity' => 'CustomField',
719 'bao' => 'CRM_Core_BAO_CustomField',
720 'localizable' => 0,
721 'pseudoconstant' => [
722 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
723 ],
724 'add' => '3.1',
725 ],
726 'note_columns' => [
727 'name' => 'note_columns',
728 'type' => CRM_Utils_Type::T_INT,
729 'title' => ts('Field Note Columns'),
730 'description' => ts('Number of columns in Note Field'),
731 'where' => 'civicrm_custom_field.note_columns',
732 'table_name' => 'civicrm_custom_field',
733 'entity' => 'CustomField',
734 'bao' => 'CRM_Core_BAO_CustomField',
735 'localizable' => 0,
736 'add' => '1.4',
737 ],
738 'note_rows' => [
739 'name' => 'note_rows',
740 'type' => CRM_Utils_Type::T_INT,
741 'title' => ts('Field Note Rows'),
742 'description' => ts('Number of rows in Note Field'),
743 'where' => 'civicrm_custom_field.note_rows',
744 'table_name' => 'civicrm_custom_field',
745 'entity' => 'CustomField',
746 'bao' => 'CRM_Core_BAO_CustomField',
747 'localizable' => 0,
748 'add' => '1.4',
749 ],
750 'column_name' => [
751 'name' => 'column_name',
752 'type' => CRM_Utils_Type::T_STRING,
753 'title' => ts('Field Column Name'),
754 'description' => ts('Name of the column that holds the values for this field.'),
755 'maxlength' => 255,
756 'size' => CRM_Utils_Type::HUGE,
757 'where' => 'civicrm_custom_field.column_name',
758 'table_name' => 'civicrm_custom_field',
759 'entity' => 'CustomField',
760 'bao' => 'CRM_Core_BAO_CustomField',
761 'localizable' => 0,
762 'add' => '2.0',
763 ],
764 'option_group_id' => [
765 'name' => 'option_group_id',
766 'type' => CRM_Utils_Type::T_INT,
767 'title' => ts('Field Option Group ID'),
768 'description' => ts('For elements with options, the option group id that is used'),
769 'where' => 'civicrm_custom_field.option_group_id',
770 'table_name' => 'civicrm_custom_field',
771 'entity' => 'CustomField',
772 'bao' => 'CRM_Core_BAO_CustomField',
773 'localizable' => 0,
774 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
775 'html' => [
776 'label' => ts("Field Option Group"),
777 ],
778 'pseudoconstant' => [
779 'table' => 'civicrm_option_group',
780 'keyColumn' => 'id',
781 'labelColumn' => 'title',
782 ],
783 'add' => '1.4',
784 ],
785 'serialize' => [
786 'name' => 'serialize',
787 'type' => CRM_Utils_Type::T_INT,
788 'title' => ts('Serialize'),
789 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
790 'required' => TRUE,
791 'where' => 'civicrm_custom_field.serialize',
792 'default' => '0',
793 'table_name' => 'civicrm_custom_field',
794 'entity' => 'CustomField',
795 'bao' => 'CRM_Core_BAO_CustomField',
796 'localizable' => 0,
797 'pseudoconstant' => [
798 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
799 ],
800 'add' => '5.27',
801 ],
802 'filter' => [
803 'name' => 'filter',
804 'type' => CRM_Utils_Type::T_STRING,
805 'title' => ts('Field Filter'),
806 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
807 'maxlength' => 255,
808 'size' => CRM_Utils_Type::HUGE,
809 'where' => 'civicrm_custom_field.filter',
810 'table_name' => 'civicrm_custom_field',
811 'entity' => 'CustomField',
812 'bao' => 'CRM_Core_BAO_CustomField',
813 'localizable' => 0,
814 'add' => '4.1',
815 ],
816 'in_selector' => [
817 'name' => 'in_selector',
818 'type' => CRM_Utils_Type::T_BOOLEAN,
819 'title' => ts('Field Display'),
820 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
821 'where' => 'civicrm_custom_field.in_selector',
822 'default' => '0',
823 'table_name' => 'civicrm_custom_field',
824 'entity' => 'CustomField',
825 'bao' => 'CRM_Core_BAO_CustomField',
826 'localizable' => 0,
827 'add' => '4.5',
828 ],
829 ];
830 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
831 }
832 return Civi::$statics[__CLASS__]['fields'];
833 }
834
835 /**
836 * Return a mapping from field-name to the corresponding key (as used in fields()).
837 *
838 * @return array
839 * Array(string $name => string $uniqueName).
840 */
841 public static function &fieldKeys() {
842 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
843 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
844 }
845 return Civi::$statics[__CLASS__]['fieldKeys'];
846 }
847
848 /**
849 * Returns the names of this table
850 *
851 * @return string
852 */
853 public static function getTableName() {
854 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
855 }
856
857 /**
858 * Returns if this table needs to be logged
859 *
860 * @return bool
861 */
862 public function getLog() {
863 return self::$_log;
864 }
865
866 /**
867 * Returns the list of fields that can be imported
868 *
869 * @param bool $prefix
870 *
871 * @return array
872 */
873 public static function &import($prefix = FALSE) {
874 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, []);
875 return $r;
876 }
877
878 /**
879 * Returns the list of fields that can be exported
880 *
881 * @param bool $prefix
882 *
883 * @return array
884 */
885 public static function &export($prefix = FALSE) {
886 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, []);
887 return $r;
888 }
889
890 /**
891 * Returns the list of indices
892 *
893 * @param bool $localize
894 *
895 * @return array
896 */
897 public static function indices($localize = TRUE) {
898 $indices = [
899 'UI_label_custom_group_id' => [
900 'name' => 'UI_label_custom_group_id',
901 'field' => [
902 0 => 'label',
903 1 => 'custom_group_id',
904 ],
905 'localizable' => TRUE,
906 'unique' => TRUE,
907 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
908 ],
909 'UI_name_custom_group_id' => [
910 'name' => 'UI_name_custom_group_id',
911 'field' => [
912 0 => 'name',
913 1 => 'custom_group_id',
914 ],
915 'localizable' => FALSE,
916 'unique' => TRUE,
917 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
918 ],
919 ];
920 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
921 }
922
923 }