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