Merge pull request #19075 from colemanw/searchable
[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
d31fb4e3 9 * (GenCodeChecksum:58c67e6b3ec035823fb7553abb962ab9)
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.
7b66c3b5
AH
260 *
261 * @param bool $plural
262 * Whether to return the plural version of the title.
449c4e6b 263 */
7b66c3b5
AH
264 public static function getEntityTitle($plural = FALSE) {
265 return $plural ? ts('Custom Fields') : ts('Custom Field');
449c4e6b
CW
266 }
267
e501603b 268 /**
f41f0342 269 * Returns foreign keys and entity references.
e501603b
TO
270 *
271 * @return array
272 * [CRM_Core_Reference_Interface]
273 */
c3fc2621 274 public static function getReferenceColumns() {
346aaaba 275 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 276 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 277 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id');
2b216479 278 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id');
346aaaba 279 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 280 }
346aaaba 281 return Civi::$statics[__CLASS__]['links'];
e501603b 282 }
c3fc2621 283
e501603b
TO
284 /**
285 * Returns all the column names of this table
286 *
287 * @return array
288 */
c3fc2621 289 public static function &fields() {
346aaaba 290 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
291 Civi::$statics[__CLASS__]['fields'] = [
292 'id' => [
e501603b
TO
293 'name' => 'id',
294 'type' => CRM_Utils_Type::T_INT,
c3fc2621 295 'title' => ts('Custom Field ID'),
215b423e 296 'description' => ts('Unique Custom Field ID'),
c3fc2621 297 'required' => TRUE,
a36434b9 298 'where' => 'civicrm_custom_field.id',
522a26c9 299 'table_name' => 'civicrm_custom_field',
300 'entity' => 'CustomField',
301 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 302 'localizable' => 0,
a9d0587b 303 'add' => '1.1',
c3fc2621
CW
304 ],
305 'custom_group_id' => [
e501603b
TO
306 'name' => 'custom_group_id',
307 'type' => CRM_Utils_Type::T_INT,
c3fc2621 308 'title' => ts('Custom Group'),
215b423e 309 'description' => ts('FK to civicrm_custom_group.'),
c3fc2621 310 'required' => TRUE,
a36434b9 311 'where' => 'civicrm_custom_field.custom_group_id',
522a26c9 312 'table_name' => 'civicrm_custom_field',
313 'entity' => 'CustomField',
314 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 315 'localizable' => 0,
e501603b 316 'FKClassName' => 'CRM_Core_DAO_CustomGroup',
c3fc2621 317 'html' => [
e501603b 318 'type' => 'Select',
c3fc2621
CW
319 ],
320 'pseudoconstant' => [
e501603b
TO
321 'table' => 'civicrm_custom_group',
322 'keyColumn' => 'id',
323 'labelColumn' => 'title',
e6ca0a57 324 ],
a9d0587b 325 'add' => '1.1',
c3fc2621
CW
326 ],
327 'name' => [
e501603b
TO
328 'name' => 'name',
329 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 330 'title' => ts('Custom Field Name'),
215b423e 331 'description' => ts('Variable name/programmatic handle for this group.'),
e501603b
TO
332 'maxlength' => 64,
333 'size' => CRM_Utils_Type::BIG,
a36434b9 334 'where' => 'civicrm_custom_field.name',
522a26c9 335 'table_name' => 'civicrm_custom_field',
336 'entity' => 'CustomField',
337 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 338 'localizable' => 0,
a9d0587b 339 'add' => '3.3',
c3fc2621
CW
340 ],
341 'label' => [
e501603b
TO
342 'name' => 'label',
343 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 344 'title' => ts('Custom Field Label'),
215b423e 345 'description' => ts('Text for form field label (also friendly name for administering this custom property).'),
c3fc2621 346 'required' => TRUE,
e501603b
TO
347 'maxlength' => 255,
348 'size' => CRM_Utils_Type::HUGE,
a36434b9 349 'where' => 'civicrm_custom_field.label',
522a26c9 350 'table_name' => 'civicrm_custom_field',
351 'entity' => 'CustomField',
352 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 353 'localizable' => 1,
a9d0587b 354 'add' => '1.1',
c3fc2621
CW
355 ],
356 'data_type' => [
e501603b
TO
357 'name' => 'data_type',
358 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 359 'title' => ts('Custom Field Data Type'),
215b423e 360 'description' => ts('Controls location of data storage in extended_data table.'),
c3fc2621 361 'required' => TRUE,
e501603b
TO
362 'maxlength' => 16,
363 'size' => CRM_Utils_Type::TWELVE,
a36434b9 364 'where' => 'civicrm_custom_field.data_type',
522a26c9 365 'table_name' => 'civicrm_custom_field',
366 'entity' => 'CustomField',
367 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 368 'localizable' => 0,
c3fc2621 369 'html' => [
e501603b 370 'type' => 'Select',
9b85cd33 371 'label' => ts("Data Type"),
c3fc2621
CW
372 ],
373 'pseudoconstant' => [
e501603b 374 'callback' => 'CRM_Core_BAO_CustomField::dataType',
e6ca0a57 375 ],
a9d0587b 376 'add' => '1.1',
c3fc2621
CW
377 ],
378 'html_type' => [
e501603b
TO
379 'name' => 'html_type',
380 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 381 'title' => ts('Custom Field HTML Type'),
215b423e 382 'description' => ts('HTML types plus several built-in extended types.'),
c3fc2621 383 'required' => TRUE,
e501603b
TO
384 'maxlength' => 32,
385 'size' => CRM_Utils_Type::MEDIUM,
a36434b9 386 'where' => 'civicrm_custom_field.html_type',
522a26c9 387 'table_name' => 'civicrm_custom_field',
388 'entity' => 'CustomField',
389 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 390 'localizable' => 0,
9b85cd33
CW
391 'html' => [
392 'type' => 'Select',
393 'label' => ts("Field Input Type"),
394 ],
c3fc2621 395 'pseudoconstant' => [
e501603b 396 'callback' => 'CRM_Core_SelectValues::customHtmlType',
e6ca0a57 397 ],
a9d0587b 398 'add' => '1.1',
c3fc2621
CW
399 ],
400 'default_value' => [
e501603b
TO
401 'name' => 'default_value',
402 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 403 'title' => ts('Custom Field Default'),
215b423e 404 'description' => ts('Use form_options.is_default for field_types which use options.'),
e501603b
TO
405 'maxlength' => 255,
406 'size' => CRM_Utils_Type::HUGE,
a36434b9 407 'where' => 'civicrm_custom_field.default_value',
522a26c9 408 'table_name' => 'civicrm_custom_field',
409 'entity' => 'CustomField',
410 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 411 'localizable' => 0,
a9d0587b 412 'add' => '1.1',
c3fc2621
CW
413 ],
414 'is_required' => [
e501603b
TO
415 'name' => 'is_required',
416 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 417 'title' => ts('Custom Field Is Required?'),
215b423e 418 'description' => ts('Is a value required for this property.'),
a36434b9 419 'where' => 'civicrm_custom_field.is_required',
45a83e42 420 'default' => '0',
522a26c9 421 'table_name' => 'civicrm_custom_field',
422 'entity' => 'CustomField',
423 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 424 'localizable' => 0,
a9d0587b 425 'add' => '1.1',
c3fc2621
CW
426 ],
427 'is_searchable' => [
e501603b
TO
428 'name' => 'is_searchable',
429 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 430 'title' => ts('Allow Searching on Field?'),
215b423e 431 'description' => ts('Is this property searchable.'),
a36434b9 432 'where' => 'civicrm_custom_field.is_searchable',
45a83e42 433 'default' => '0',
522a26c9 434 'table_name' => 'civicrm_custom_field',
435 'entity' => 'CustomField',
436 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 437 'localizable' => 0,
a9d0587b 438 'add' => '1.1',
c3fc2621
CW
439 ],
440 'is_search_range' => [
e501603b
TO
441 'name' => 'is_search_range',
442 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 443 'title' => ts('Search as a Range'),
215b423e 444 'description' => ts('Is this property range searchable.'),
a36434b9 445 'where' => 'civicrm_custom_field.is_search_range',
45a83e42 446 'default' => '0',
522a26c9 447 'table_name' => 'civicrm_custom_field',
448 'entity' => 'CustomField',
449 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 450 'localizable' => 0,
a9d0587b 451 'add' => '1.4',
c3fc2621
CW
452 ],
453 'weight' => [
e501603b
TO
454 'name' => 'weight',
455 'type' => CRM_Utils_Type::T_INT,
c3fc2621 456 'title' => ts('Order'),
215b423e 457 'description' => ts('Controls field display order within an extended property group.'),
c3fc2621 458 'required' => TRUE,
a36434b9 459 'where' => 'civicrm_custom_field.weight',
e501603b 460 'default' => '1',
522a26c9 461 'table_name' => 'civicrm_custom_field',
462 'entity' => 'CustomField',
463 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 464 'localizable' => 0,
a9d0587b 465 'add' => '1.1',
c3fc2621
CW
466 ],
467 'help_pre' => [
e501603b
TO
468 'name' => 'help_pre',
469 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 470 'title' => ts('Custom Field Pre Text'),
215b423e 471 'description' => ts('Description and/or help text to display before this field.'),
a36434b9 472 'where' => 'civicrm_custom_field.help_pre',
522a26c9 473 'table_name' => 'civicrm_custom_field',
474 'entity' => 'CustomField',
475 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 476 'localizable' => 1,
a9d0587b 477 'add' => '1.1',
c3fc2621
CW
478 ],
479 'help_post' => [
e501603b
TO
480 'name' => 'help_post',
481 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 482 'title' => ts('Custom Field Post Text'),
215b423e 483 'description' => ts('Description and/or help text to display after this field.'),
a36434b9 484 'where' => 'civicrm_custom_field.help_post',
522a26c9 485 'table_name' => 'civicrm_custom_field',
486 'entity' => 'CustomField',
487 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 488 'localizable' => 1,
a9d0587b 489 'add' => '1.1',
c3fc2621
CW
490 ],
491 'mask' => [
e501603b
TO
492 'name' => 'mask',
493 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 494 'title' => ts('Custom Field Formatting'),
215b423e 495 'description' => ts('Optional format instructions for specific field types, like date types.'),
e501603b
TO
496 'maxlength' => 64,
497 'size' => CRM_Utils_Type::BIG,
a36434b9 498 'where' => 'civicrm_custom_field.mask',
522a26c9 499 'table_name' => 'civicrm_custom_field',
500 'entity' => 'CustomField',
501 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 502 'localizable' => 0,
a9d0587b 503 'add' => '1.1',
c3fc2621
CW
504 ],
505 'attributes' => [
e501603b
TO
506 'name' => 'attributes',
507 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 508 'title' => ts('Custom Field Attributes'),
215b423e 509 'description' => ts('Store collection of type-appropriate attributes, e.g. textarea needs rows/cols attributes'),
e501603b
TO
510 'maxlength' => 255,
511 'size' => CRM_Utils_Type::HUGE,
a36434b9 512 'where' => 'civicrm_custom_field.attributes',
522a26c9 513 'table_name' => 'civicrm_custom_field',
514 'entity' => 'CustomField',
515 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 516 'localizable' => 0,
a9d0587b 517 'add' => '1.1',
c3fc2621
CW
518 ],
519 'javascript' => [
e501603b
TO
520 'name' => 'javascript',
521 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 522 'title' => ts('Custom Field Javascript'),
215b423e 523 'description' => ts('Optional scripting attributes for field.'),
e501603b
TO
524 'maxlength' => 255,
525 'size' => CRM_Utils_Type::HUGE,
a36434b9 526 'where' => 'civicrm_custom_field.javascript',
522a26c9 527 'table_name' => 'civicrm_custom_field',
528 'entity' => 'CustomField',
529 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 530 'localizable' => 0,
a9d0587b 531 'add' => '1.1',
c3fc2621
CW
532 ],
533 'is_active' => [
e501603b
TO
534 'name' => 'is_active',
535 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 536 'title' => ts('Custom Field Is Active?'),
215b423e 537 'description' => ts('Is this property active?'),
a36434b9 538 'where' => 'civicrm_custom_field.is_active',
110f4343 539 'default' => '1',
522a26c9 540 'table_name' => 'civicrm_custom_field',
541 'entity' => 'CustomField',
542 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 543 'localizable' => 0,
a9d0587b 544 'add' => '1.1',
c3fc2621
CW
545 ],
546 'is_view' => [
e501603b
TO
547 'name' => 'is_view',
548 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 549 'title' => ts('Field is Viewable'),
215b423e 550 'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
a36434b9 551 'where' => 'civicrm_custom_field.is_view',
45a83e42 552 'default' => '0',
522a26c9 553 'table_name' => 'civicrm_custom_field',
554 'entity' => 'CustomField',
555 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 556 'localizable' => 0,
a9d0587b 557 'add' => '1.1',
c3fc2621
CW
558 ],
559 'options_per_line' => [
e501603b
TO
560 'name' => 'options_per_line',
561 'type' => CRM_Utils_Type::T_INT,
c3fc2621 562 'title' => ts('Field Options Per Line'),
215b423e 563 'description' => ts('number of options per line for checkbox and radio'),
a36434b9 564 'where' => 'civicrm_custom_field.options_per_line',
522a26c9 565 'table_name' => 'civicrm_custom_field',
566 'entity' => 'CustomField',
567 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 568 'localizable' => 0,
a9d0587b 569 'add' => NULL,
c3fc2621
CW
570 ],
571 'text_length' => [
e501603b
TO
572 'name' => 'text_length',
573 'type' => CRM_Utils_Type::T_INT,
c3fc2621 574 'title' => ts('Field Length'),
215b423e 575 'description' => ts('field length if alphanumeric'),
a36434b9 576 'where' => 'civicrm_custom_field.text_length',
522a26c9 577 'table_name' => 'civicrm_custom_field',
578 'entity' => 'CustomField',
579 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 580 'localizable' => 0,
a9d0587b 581 'add' => '2.2',
c3fc2621
CW
582 ],
583 'start_date_years' => [
e501603b
TO
584 'name' => 'start_date_years',
585 'type' => CRM_Utils_Type::T_INT,
c3fc2621 586 'title' => ts('Field Start Date'),
215b423e 587 'description' => ts('Date may be up to start_date_years years prior to the current date.'),
a36434b9 588 'where' => 'civicrm_custom_field.start_date_years',
522a26c9 589 'table_name' => 'civicrm_custom_field',
590 'entity' => 'CustomField',
591 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 592 'localizable' => 0,
a9d0587b 593 'add' => '1.4',
c3fc2621
CW
594 ],
595 'end_date_years' => [
e501603b
TO
596 'name' => 'end_date_years',
597 'type' => CRM_Utils_Type::T_INT,
c3fc2621 598 'title' => ts('Field End Date'),
215b423e 599 'description' => ts('Date may be up to end_date_years years after the current date.'),
a36434b9 600 'where' => 'civicrm_custom_field.end_date_years',
522a26c9 601 'table_name' => 'civicrm_custom_field',
602 'entity' => 'CustomField',
603 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 604 'localizable' => 0,
a9d0587b 605 'add' => '1.4',
c3fc2621
CW
606 ],
607 'date_format' => [
e501603b
TO
608 'name' => 'date_format',
609 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 610 'title' => ts('Field Data Format'),
215b423e 611 'description' => ts('date format for custom date'),
e501603b
TO
612 'maxlength' => 64,
613 'size' => CRM_Utils_Type::BIG,
a36434b9 614 'where' => 'civicrm_custom_field.date_format',
522a26c9 615 'table_name' => 'civicrm_custom_field',
616 'entity' => 'CustomField',
617 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 618 'localizable' => 0,
72c65bfa
CW
619 'pseudoconstant' => [
620 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
621 ],
a9d0587b 622 'add' => '3.1',
c3fc2621
CW
623 ],
624 'time_format' => [
e501603b
TO
625 'name' => 'time_format',
626 'type' => CRM_Utils_Type::T_INT,
c3fc2621 627 'title' => ts('Field Time Format'),
215b423e 628 'description' => ts('time format for custom date'),
a36434b9 629 'where' => 'civicrm_custom_field.time_format',
522a26c9 630 'table_name' => 'civicrm_custom_field',
631 'entity' => 'CustomField',
632 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 633 'localizable' => 0,
72c65bfa
CW
634 'pseudoconstant' => [
635 'callback' => 'CRM_Core_SelectValues::getTimeFormats',
636 ],
a9d0587b 637 'add' => '3.1',
c3fc2621
CW
638 ],
639 'note_columns' => [
e501603b
TO
640 'name' => 'note_columns',
641 'type' => CRM_Utils_Type::T_INT,
c3fc2621 642 'title' => ts('Field Note Columns'),
1836ab9e 643 'description' => ts('Number of columns in Note Field'),
a36434b9 644 'where' => 'civicrm_custom_field.note_columns',
522a26c9 645 'table_name' => 'civicrm_custom_field',
646 'entity' => 'CustomField',
647 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 648 'localizable' => 0,
a9d0587b 649 'add' => '1.4',
c3fc2621
CW
650 ],
651 'note_rows' => [
e501603b
TO
652 'name' => 'note_rows',
653 'type' => CRM_Utils_Type::T_INT,
c3fc2621 654 'title' => ts('Field Note Rows'),
1836ab9e 655 'description' => ts('Number of rows in Note Field'),
a36434b9 656 'where' => 'civicrm_custom_field.note_rows',
522a26c9 657 'table_name' => 'civicrm_custom_field',
658 'entity' => 'CustomField',
659 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 660 'localizable' => 0,
a9d0587b 661 'add' => '1.4',
c3fc2621
CW
662 ],
663 'column_name' => [
e501603b
TO
664 'name' => 'column_name',
665 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 666 'title' => ts('Field Column Name'),
215b423e 667 'description' => ts('Name of the column that holds the values for this field.'),
e501603b
TO
668 'maxlength' => 255,
669 'size' => CRM_Utils_Type::HUGE,
a36434b9 670 'where' => 'civicrm_custom_field.column_name',
522a26c9 671 'table_name' => 'civicrm_custom_field',
672 'entity' => 'CustomField',
673 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 674 'localizable' => 0,
a9d0587b 675 'add' => '2.0',
c3fc2621
CW
676 ],
677 'option_group_id' => [
e501603b
TO
678 'name' => 'option_group_id',
679 'type' => CRM_Utils_Type::T_INT,
c3fc2621 680 'title' => ts('Field Option Group'),
215b423e 681 'description' => ts('For elements with options, the option group id that is used'),
a36434b9 682 'where' => 'civicrm_custom_field.option_group_id',
522a26c9 683 'table_name' => 'civicrm_custom_field',
684 'entity' => 'CustomField',
685 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 686 'localizable' => 0,
2b216479 687 'FKClassName' => 'CRM_Core_DAO_OptionGroup',
5830940d
MM
688 'pseudoconstant' => [
689 'table' => 'civicrm_option_group',
690 'keyColumn' => 'id',
691 'labelColumn' => 'title',
e6ca0a57 692 ],
a9d0587b 693 'add' => '1.4',
c3fc2621 694 ],
2bcfa9ee
CW
695 'serialize' => [
696 'name' => 'serialize',
697 'type' => CRM_Utils_Type::T_INT,
698 'title' => ts('Serialize'),
49df88a8
CW
699 'description' => ts('Serialization method - a non-zero value indicates a multi-valued field.'),
700 'required' => TRUE,
2bcfa9ee 701 'where' => 'civicrm_custom_field.serialize',
49df88a8 702 'default' => '0',
2bcfa9ee
CW
703 'table_name' => 'civicrm_custom_field',
704 'entity' => 'CustomField',
705 'bao' => 'CRM_Core_BAO_CustomField',
706 'localizable' => 0,
707 'pseudoconstant' => [
708 'callback' => 'CRM_Core_SelectValues::fieldSerialization',
709 ],
d2ff128c 710 'add' => '5.27',
2bcfa9ee 711 ],
c3fc2621 712 'filter' => [
e501603b
TO
713 'name' => 'filter',
714 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 715 'title' => ts('Field Filter'),
215b423e 716 'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
e501603b
TO
717 'maxlength' => 255,
718 'size' => CRM_Utils_Type::HUGE,
a36434b9 719 'where' => 'civicrm_custom_field.filter',
522a26c9 720 'table_name' => 'civicrm_custom_field',
721 'entity' => 'CustomField',
722 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 723 'localizable' => 0,
a9d0587b 724 'add' => '4.1',
c3fc2621
CW
725 ],
726 'in_selector' => [
e501603b
TO
727 'name' => 'in_selector',
728 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 729 'title' => ts('Field Display'),
215b423e 730 'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
a36434b9 731 'where' => 'civicrm_custom_field.in_selector',
45a83e42 732 'default' => '0',
522a26c9 733 'table_name' => 'civicrm_custom_field',
734 'entity' => 'CustomField',
735 'bao' => 'CRM_Core_BAO_CustomField',
6a7e5e5d 736 'localizable' => 0,
a9d0587b 737 'add' => '4.5',
c3fc2621
CW
738 ],
739 ];
346aaaba 740 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 741 }
346aaaba 742 return Civi::$statics[__CLASS__]['fields'];
e501603b 743 }
c3fc2621 744
e501603b 745 /**
bd8e0b14 746 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
747 *
748 * @return array
bd8e0b14 749 * Array(string $name => string $uniqueName).
e501603b 750 */
c3fc2621 751 public static function &fieldKeys() {
bd8e0b14
TO
752 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
753 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 754 }
bd8e0b14 755 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 756 }
c3fc2621 757
e501603b
TO
758 /**
759 * Returns the names of this table
760 *
761 * @return string
762 */
c3fc2621 763 public static function getTableName() {
e501603b
TO
764 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
765 }
c3fc2621 766
e501603b
TO
767 /**
768 * Returns if this table needs to be logged
769 *
c3fc2621 770 * @return bool
e501603b 771 */
c3fc2621 772 public function getLog() {
e501603b
TO
773 return self::$_log;
774 }
c3fc2621 775
e501603b
TO
776 /**
777 * Returns the list of fields that can be imported
778 *
779 * @param bool $prefix
780 *
781 * @return array
782 */
c3fc2621
CW
783 public static function &import($prefix = FALSE) {
784 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_field', $prefix, []);
60808919 785 return $r;
e501603b 786 }
c3fc2621 787
e501603b
TO
788 /**
789 * Returns the list of fields that can be exported
790 *
791 * @param bool $prefix
792 *
793 * @return array
794 */
c3fc2621
CW
795 public static function &export($prefix = FALSE) {
796 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_field', $prefix, []);
60808919 797 return $r;
e501603b 798 }
c3fc2621 799
e7a6b91a
AS
800 /**
801 * Returns the list of indices
c3fc2621
CW
802 *
803 * @param bool $localize
804 *
805 * @return array
e7a6b91a
AS
806 */
807 public static function indices($localize = TRUE) {
c3fc2621
CW
808 $indices = [
809 'UI_label_custom_group_id' => [
e7a6b91a 810 'name' => 'UI_label_custom_group_id',
c3fc2621 811 'field' => [
e7a6b91a
AS
812 0 => 'label',
813 1 => 'custom_group_id',
c3fc2621
CW
814 ],
815 'localizable' => TRUE,
816 'unique' => TRUE,
e7a6b91a 817 'sig' => 'civicrm_custom_field::1::label::custom_group_id',
c3fc2621
CW
818 ],
819 'UI_name_custom_group_id' => [
e7a6b91a 820 'name' => 'UI_name_custom_group_id',
c3fc2621 821 'field' => [
e7a6b91a
AS
822 0 => 'name',
823 1 => 'custom_group_id',
c3fc2621
CW
824 ],
825 'localizable' => FALSE,
826 'unique' => TRUE,
e7a6b91a 827 'sig' => 'civicrm_custom_field::1::name::custom_group_id',
c3fc2621
CW
828 ],
829 ];
e7a6b91a
AS
830 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
831 }
c3fc2621 832
e501603b 833}