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