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