Merge pull request #23213 from eileenmcnaughton/post
[civicrm-core.git] / CRM / Core / DAO / UFField.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/UFField.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:4d8ac7c59b6f2301cc22fe7966e8fc91)
10 */
11
12 /**
13 * Database access object for the UFField entity.
14 */
15 class CRM_Core_DAO_UFField extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_uf_field';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Unique table ID
35 *
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
39 */
40 public $id;
41
42 /**
43 * Which form does this field belong to.
44 *
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $uf_group_id;
50
51 /**
52 * Name for CiviCRM field which is being exposed for sharing.
53 *
54 * @var string
55 * (SQL type: varchar(64))
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $field_name;
59
60 /**
61 * Is this field currently shareable? If false, hide the field for all sharing contexts.
62 *
63 * @var bool|string
64 * (SQL type: tinyint)
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $is_active;
68
69 /**
70 * the field is view only and not editable in user forms.
71 *
72 * @var bool|string
73 * (SQL type: tinyint)
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $is_view;
77
78 /**
79 * Is this field required when included in a user or registration form?
80 *
81 * @var bool|string
82 * (SQL type: tinyint)
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $is_required;
86
87 /**
88 * Controls field display order when user framework fields are displayed in registration and account editing forms.
89 *
90 * @var int|string
91 * (SQL type: int)
92 * Note that values will be retrieved from the database as a string.
93 */
94 public $weight;
95
96 /**
97 * Description and/or help text to display after this field.
98 *
99 * @var string|null
100 * (SQL type: text)
101 * Note that values will be retrieved from the database as a string.
102 */
103 public $help_post;
104
105 /**
106 * Description and/or help text to display before this field.
107 *
108 * @var string|null
109 * (SQL type: text)
110 * Note that values will be retrieved from the database as a string.
111 */
112 public $help_pre;
113
114 /**
115 * In what context(s) is this field visible.
116 *
117 * @var string|null
118 * (SQL type: varchar(32))
119 * Note that values will be retrieved from the database as a string.
120 */
121 public $visibility;
122
123 /**
124 * Is this field included as a column in the selector table?
125 *
126 * @var bool|string
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
129 */
130 public $in_selector;
131
132 /**
133 * Is this field included search form of profile?
134 *
135 * @var bool|string
136 * (SQL type: tinyint)
137 * Note that values will be retrieved from the database as a string.
138 */
139 public $is_searchable;
140
141 /**
142 * Location type of this mapping, if required
143 *
144 * @var int|string|null
145 * (SQL type: int unsigned)
146 * Note that values will be retrieved from the database as a string.
147 */
148 public $location_type_id;
149
150 /**
151 * Phone Type ID, if required
152 *
153 * @var int|string|null
154 * (SQL type: int unsigned)
155 * Note that values will be retrieved from the database as a string.
156 */
157 public $phone_type_id;
158
159 /**
160 * Website Type ID, if required
161 *
162 * @var int|string|null
163 * (SQL type: int unsigned)
164 * Note that values will be retrieved from the database as a string.
165 */
166 public $website_type_id;
167
168 /**
169 * To save label for fields.
170 *
171 * @var string
172 * (SQL type: varchar(255))
173 * Note that values will be retrieved from the database as a string.
174 */
175 public $label;
176
177 /**
178 * This field saves field type (ie individual,household.. field etc).
179 *
180 * @var string|null
181 * (SQL type: varchar(255))
182 * Note that values will be retrieved from the database as a string.
183 */
184 public $field_type;
185
186 /**
187 * Is this field reserved for use by some other CiviCRM functionality?
188 *
189 * @var bool|string
190 * (SQL type: tinyint)
191 * Note that values will be retrieved from the database as a string.
192 */
193 public $is_reserved;
194
195 /**
196 * Include in multi-record listing?
197 *
198 * @var bool|string
199 * (SQL type: tinyint)
200 * Note that values will be retrieved from the database as a string.
201 */
202 public $is_multi_summary;
203
204 /**
205 * Class constructor.
206 */
207 public function __construct() {
208 $this->__table = 'civicrm_uf_field';
209 parent::__construct();
210 }
211
212 /**
213 * Returns localized title of this entity.
214 *
215 * @param bool $plural
216 * Whether to return the plural version of the title.
217 */
218 public static function getEntityTitle($plural = FALSE) {
219 return $plural ? ts('UFFields') : ts('UFField');
220 }
221
222 /**
223 * Returns foreign keys and entity references.
224 *
225 * @return array
226 * [CRM_Core_Reference_Interface]
227 */
228 public static function getReferenceColumns() {
229 if (!isset(Civi::$statics[__CLASS__]['links'])) {
230 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
231 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'uf_group_id', 'civicrm_uf_group', 'id');
232 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id');
233 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
234 }
235 return Civi::$statics[__CLASS__]['links'];
236 }
237
238 /**
239 * Returns all the column names of this table
240 *
241 * @return array
242 */
243 public static function &fields() {
244 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
245 Civi::$statics[__CLASS__]['fields'] = [
246 'id' => [
247 'name' => 'id',
248 'type' => CRM_Utils_Type::T_INT,
249 'title' => ts('Profile Field ID'),
250 'description' => ts('Unique table ID'),
251 'required' => TRUE,
252 'where' => 'civicrm_uf_field.id',
253 'table_name' => 'civicrm_uf_field',
254 'entity' => 'UFField',
255 'bao' => 'CRM_Core_BAO_UFField',
256 'localizable' => 0,
257 'html' => [
258 'type' => 'Number',
259 ],
260 'readonly' => TRUE,
261 'add' => '1.1',
262 ],
263 'uf_group_id' => [
264 'name' => 'uf_group_id',
265 'type' => CRM_Utils_Type::T_INT,
266 'title' => ts('Profile ID'),
267 'description' => ts('Which form does this field belong to.'),
268 'required' => TRUE,
269 'where' => 'civicrm_uf_field.uf_group_id',
270 'table_name' => 'civicrm_uf_field',
271 'entity' => 'UFField',
272 'bao' => 'CRM_Core_BAO_UFField',
273 'localizable' => 0,
274 'FKClassName' => 'CRM_Core_DAO_UFGroup',
275 'html' => [
276 'type' => 'Select',
277 'label' => ts("Profile"),
278 ],
279 'pseudoconstant' => [
280 'table' => 'civicrm_uf_group',
281 'keyColumn' => 'id',
282 'labelColumn' => 'title',
283 ],
284 'add' => '1.1',
285 ],
286 'field_name' => [
287 'name' => 'field_name',
288 'type' => CRM_Utils_Type::T_STRING,
289 'title' => ts('Profile Field Name'),
290 'description' => ts('Name for CiviCRM field which is being exposed for sharing.'),
291 'required' => TRUE,
292 'maxlength' => 64,
293 'size' => CRM_Utils_Type::BIG,
294 'where' => 'civicrm_uf_field.field_name',
295 'table_name' => 'civicrm_uf_field',
296 'entity' => 'UFField',
297 'bao' => 'CRM_Core_BAO_UFField',
298 'localizable' => 0,
299 'pseudoconstant' => [
300 'callback' => 'CRM_Core_BAO_UFField::getAvailableFieldTitles',
301 ],
302 'add' => '1.1',
303 ],
304 'is_active' => [
305 'name' => 'is_active',
306 'type' => CRM_Utils_Type::T_BOOLEAN,
307 'title' => ts('Profile Field Is Active'),
308 'description' => ts('Is this field currently shareable? If false, hide the field for all sharing contexts.'),
309 'required' => TRUE,
310 'where' => 'civicrm_uf_field.is_active',
311 'default' => '1',
312 'table_name' => 'civicrm_uf_field',
313 'entity' => 'UFField',
314 'bao' => 'CRM_Core_BAO_UFField',
315 'localizable' => 0,
316 'add' => '1.1',
317 ],
318 'is_view' => [
319 'name' => 'is_view',
320 'type' => CRM_Utils_Type::T_BOOLEAN,
321 'title' => ts('Profile Is View Only'),
322 'description' => ts('the field is view only and not editable in user forms.'),
323 'required' => TRUE,
324 'where' => 'civicrm_uf_field.is_view',
325 'default' => '0',
326 'table_name' => 'civicrm_uf_field',
327 'entity' => 'UFField',
328 'bao' => 'CRM_Core_BAO_UFField',
329 'localizable' => 0,
330 'add' => '1.1',
331 ],
332 'is_required' => [
333 'name' => 'is_required',
334 'type' => CRM_Utils_Type::T_BOOLEAN,
335 'title' => ts('Profile Field Is Required'),
336 'description' => ts('Is this field required when included in a user or registration form?'),
337 'required' => TRUE,
338 'where' => 'civicrm_uf_field.is_required',
339 'default' => '0',
340 'table_name' => 'civicrm_uf_field',
341 'entity' => 'UFField',
342 'bao' => 'CRM_Core_BAO_UFField',
343 'localizable' => 0,
344 'add' => '1.1',
345 ],
346 'weight' => [
347 'name' => 'weight',
348 'type' => CRM_Utils_Type::T_INT,
349 'title' => ts('Order'),
350 'description' => ts('Controls field display order when user framework fields are displayed in registration and account editing forms.'),
351 'required' => TRUE,
352 'where' => 'civicrm_uf_field.weight',
353 'default' => '1',
354 'table_name' => 'civicrm_uf_field',
355 'entity' => 'UFField',
356 'bao' => 'CRM_Core_BAO_UFField',
357 'localizable' => 0,
358 'add' => '1.1',
359 ],
360 'help_post' => [
361 'name' => 'help_post',
362 'type' => CRM_Utils_Type::T_TEXT,
363 'title' => ts('Profile Field Post Help'),
364 'description' => ts('Description and/or help text to display after this field.'),
365 'where' => 'civicrm_uf_field.help_post',
366 'table_name' => 'civicrm_uf_field',
367 'entity' => 'UFField',
368 'bao' => 'CRM_Core_BAO_UFField',
369 'localizable' => 1,
370 'add' => '1.1',
371 ],
372 'help_pre' => [
373 'name' => 'help_pre',
374 'type' => CRM_Utils_Type::T_TEXT,
375 'title' => ts('Profile Field Pre Help'),
376 'description' => ts('Description and/or help text to display before this field.'),
377 'where' => 'civicrm_uf_field.help_pre',
378 'table_name' => 'civicrm_uf_field',
379 'entity' => 'UFField',
380 'bao' => 'CRM_Core_BAO_UFField',
381 'localizable' => 1,
382 'add' => '3.2',
383 ],
384 'visibility' => [
385 'name' => 'visibility',
386 'type' => CRM_Utils_Type::T_STRING,
387 'title' => ts('Profile Field Visibility'),
388 'description' => ts('In what context(s) is this field visible.'),
389 'maxlength' => 32,
390 'size' => CRM_Utils_Type::MEDIUM,
391 'where' => 'civicrm_uf_field.visibility',
392 'default' => 'User and User Admin Only',
393 'table_name' => 'civicrm_uf_field',
394 'entity' => 'UFField',
395 'bao' => 'CRM_Core_BAO_UFField',
396 'localizable' => 0,
397 'html' => [
398 'type' => 'Select',
399 ],
400 'pseudoconstant' => [
401 'callback' => 'CRM_Core_SelectValues::ufVisibility',
402 ],
403 'add' => '1.1',
404 ],
405 'in_selector' => [
406 'name' => 'in_selector',
407 'type' => CRM_Utils_Type::T_BOOLEAN,
408 'title' => ts('Profile Field Is a Filter'),
409 'description' => ts('Is this field included as a column in the selector table?'),
410 'required' => TRUE,
411 'where' => 'civicrm_uf_field.in_selector',
412 'default' => '0',
413 'table_name' => 'civicrm_uf_field',
414 'entity' => 'UFField',
415 'bao' => 'CRM_Core_BAO_UFField',
416 'localizable' => 0,
417 'add' => '1.2',
418 ],
419 'is_searchable' => [
420 'name' => 'is_searchable',
421 'type' => CRM_Utils_Type::T_BOOLEAN,
422 'title' => ts('Profile Field Is Searchable'),
423 'description' => ts('Is this field included search form of profile?'),
424 'required' => TRUE,
425 'where' => 'civicrm_uf_field.is_searchable',
426 'default' => '0',
427 'table_name' => 'civicrm_uf_field',
428 'entity' => 'UFField',
429 'bao' => 'CRM_Core_BAO_UFField',
430 'localizable' => 0,
431 'add' => '1.4',
432 ],
433 'location_type_id' => [
434 'name' => 'location_type_id',
435 'type' => CRM_Utils_Type::T_INT,
436 'title' => ts('Location Type ID'),
437 'description' => ts('Location type of this mapping, if required'),
438 'where' => 'civicrm_uf_field.location_type_id',
439 'table_name' => 'civicrm_uf_field',
440 'entity' => 'UFField',
441 'bao' => 'CRM_Core_BAO_UFField',
442 'localizable' => 0,
443 'FKClassName' => 'CRM_Core_DAO_LocationType',
444 'html' => [
445 'label' => ts("Location Type"),
446 ],
447 'add' => '1.3',
448 ],
449 'phone_type_id' => [
450 'name' => 'phone_type_id',
451 'type' => CRM_Utils_Type::T_INT,
452 'title' => ts('Profile Field Phone Type'),
453 'description' => ts('Phone Type ID, if required'),
454 'where' => 'civicrm_uf_field.phone_type_id',
455 'table_name' => 'civicrm_uf_field',
456 'entity' => 'UFField',
457 'bao' => 'CRM_Core_BAO_UFField',
458 'localizable' => 0,
459 'pseudoconstant' => [
460 'optionGroupName' => 'phone_type',
461 'optionEditPath' => 'civicrm/admin/options/phone_type',
462 ],
463 'add' => '2.2',
464 ],
465 'website_type_id' => [
466 'name' => 'website_type_id',
467 'type' => CRM_Utils_Type::T_INT,
468 'title' => ts('Profile Field Website Type'),
469 'description' => ts('Website Type ID, if required'),
470 'where' => 'civicrm_uf_field.website_type_id',
471 'table_name' => 'civicrm_uf_field',
472 'entity' => 'UFField',
473 'bao' => 'CRM_Core_BAO_UFField',
474 'localizable' => 0,
475 'pseudoconstant' => [
476 'optionGroupName' => 'website_type',
477 'optionEditPath' => 'civicrm/admin/options/website_type',
478 ],
479 'add' => '4.5',
480 ],
481 'label' => [
482 'name' => 'label',
483 'type' => CRM_Utils_Type::T_STRING,
484 'title' => ts('Profile Field Label'),
485 'description' => ts('To save label for fields.'),
486 'required' => TRUE,
487 'maxlength' => 255,
488 'size' => CRM_Utils_Type::HUGE,
489 'where' => 'civicrm_uf_field.label',
490 'table_name' => 'civicrm_uf_field',
491 'entity' => 'UFField',
492 'bao' => 'CRM_Core_BAO_UFField',
493 'localizable' => 1,
494 'add' => '1.4',
495 ],
496 'field_type' => [
497 'name' => 'field_type',
498 'type' => CRM_Utils_Type::T_STRING,
499 'title' => ts('Profile Field Type'),
500 'description' => ts('This field saves field type (ie individual,household.. field etc).'),
501 'maxlength' => 255,
502 'size' => CRM_Utils_Type::HUGE,
503 'where' => 'civicrm_uf_field.field_type',
504 'table_name' => 'civicrm_uf_field',
505 'entity' => 'UFField',
506 'bao' => 'CRM_Core_BAO_UFField',
507 'localizable' => 0,
508 'add' => '1.4',
509 ],
510 'is_reserved' => [
511 'name' => 'is_reserved',
512 'type' => CRM_Utils_Type::T_BOOLEAN,
513 'title' => ts('Profile Field Is Reserved'),
514 'description' => ts('Is this field reserved for use by some other CiviCRM functionality?'),
515 'required' => TRUE,
516 'where' => 'civicrm_uf_field.is_reserved',
517 'default' => '0',
518 'table_name' => 'civicrm_uf_field',
519 'entity' => 'UFField',
520 'bao' => 'CRM_Core_BAO_UFField',
521 'localizable' => 0,
522 'add' => '3.0',
523 ],
524 'is_multi_summary' => [
525 'name' => 'is_multi_summary',
526 'type' => CRM_Utils_Type::T_BOOLEAN,
527 'title' => ts('Profile Field Supports Multiple'),
528 'description' => ts('Include in multi-record listing?'),
529 'required' => TRUE,
530 'where' => 'civicrm_uf_field.is_multi_summary',
531 'default' => '0',
532 'table_name' => 'civicrm_uf_field',
533 'entity' => 'UFField',
534 'bao' => 'CRM_Core_BAO_UFField',
535 'localizable' => 0,
536 'add' => '4.3',
537 ],
538 ];
539 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
540 }
541 return Civi::$statics[__CLASS__]['fields'];
542 }
543
544 /**
545 * Return a mapping from field-name to the corresponding key (as used in fields()).
546 *
547 * @return array
548 * Array(string $name => string $uniqueName).
549 */
550 public static function &fieldKeys() {
551 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
552 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
553 }
554 return Civi::$statics[__CLASS__]['fieldKeys'];
555 }
556
557 /**
558 * Returns the names of this table
559 *
560 * @return string
561 */
562 public static function getTableName() {
563 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
564 }
565
566 /**
567 * Returns if this table needs to be logged
568 *
569 * @return bool
570 */
571 public function getLog() {
572 return self::$_log;
573 }
574
575 /**
576 * Returns the list of fields that can be imported
577 *
578 * @param bool $prefix
579 *
580 * @return array
581 */
582 public static function &import($prefix = FALSE) {
583 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'uf_field', $prefix, []);
584 return $r;
585 }
586
587 /**
588 * Returns the list of fields that can be exported
589 *
590 * @param bool $prefix
591 *
592 * @return array
593 */
594 public static function &export($prefix = FALSE) {
595 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'uf_field', $prefix, []);
596 return $r;
597 }
598
599 /**
600 * Returns the list of indices
601 *
602 * @param bool $localize
603 *
604 * @return array
605 */
606 public static function indices($localize = TRUE) {
607 $indices = [
608 'IX_website_type_id' => [
609 'name' => 'IX_website_type_id',
610 'field' => [
611 0 => 'website_type_id',
612 ],
613 'localizable' => FALSE,
614 'sig' => 'civicrm_uf_field::0::website_type_id',
615 ],
616 ];
617 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
618 }
619
620 }