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