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