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