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