Merge pull request #19329 from civicrm/5.33
[civicrm-core.git] / CRM / Core / DAO / CustomGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/CustomGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:807040c22af3159cb198becb183444bc)
10 */
11
12 /**
13 * Database access object for the CustomGroup entity.
14 */
15 class CRM_Core_DAO_CustomGroup 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_custom_group';
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 Custom Group ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Variable name/programmatic handle for this group.
42 *
43 * @var string
44 */
45 public $name;
46
47 /**
48 * Friendly Name.
49 *
50 * @var string
51 */
52 public $title;
53
54 /**
55 * Type of object this group extends (can add other options later e.g. contact_address, etc.).
56 *
57 * @var string
58 */
59 public $extends;
60
61 /**
62 * FK to civicrm_option_value.id (for option group custom_data_type.)
63 *
64 * @var int
65 */
66 public $extends_entity_column_id;
67
68 /**
69 * linking custom group for dynamic object
70 *
71 * @var string
72 */
73 public $extends_entity_column_value;
74
75 /**
76 * Visual relationship between this form and its parent.
77 *
78 * @var string
79 */
80 public $style;
81
82 /**
83 * Will this group be in collapsed or expanded mode on initial display ?
84 *
85 * @var bool
86 */
87 public $collapse_display;
88
89 /**
90 * Description and/or help text to display before fields in form.
91 *
92 * @var text
93 */
94 public $help_pre;
95
96 /**
97 * Description and/or help text to display after fields in form.
98 *
99 * @var text
100 */
101 public $help_post;
102
103 /**
104 * Controls display order when multiple extended property groups are setup for the same class.
105 *
106 * @var int
107 */
108 public $weight;
109
110 /**
111 * Is this property active?
112 *
113 * @var bool
114 */
115 public $is_active;
116
117 /**
118 * Name of the table that holds the values for this group.
119 *
120 * @var string
121 */
122 public $table_name;
123
124 /**
125 * Does this group hold multiple values?
126 *
127 * @var bool
128 */
129 public $is_multiple;
130
131 /**
132 * minimum number of multiple records (typically 0?)
133 *
134 * @var int
135 */
136 public $min_multiple;
137
138 /**
139 * maximum number of multiple records, if 0 - no max
140 *
141 * @var int
142 */
143 public $max_multiple;
144
145 /**
146 * Will this group be in collapsed or expanded mode on advanced search display ?
147 *
148 * @var bool
149 */
150 public $collapse_adv_display;
151
152 /**
153 * FK to civicrm_contact, who created this custom group
154 *
155 * @var int
156 */
157 public $created_id;
158
159 /**
160 * Date and time this custom group was created.
161 *
162 * @var datetime
163 */
164 public $created_date;
165
166 /**
167 * Is this a reserved Custom Group?
168 *
169 * @var bool
170 */
171 public $is_reserved;
172
173 /**
174 * Is this property public?
175 *
176 * @var bool
177 */
178 public $is_public;
179
180 /**
181 * crm-i icon class
182 *
183 * @var string
184 */
185 public $icon;
186
187 /**
188 * Class constructor.
189 */
190 public function __construct() {
191 $this->__table = 'civicrm_custom_group';
192 parent::__construct();
193 }
194
195 /**
196 * Returns localized title of this entity.
197 *
198 * @param bool $plural
199 * Whether to return the plural version of the title.
200 */
201 public static function getEntityTitle($plural = FALSE) {
202 return $plural ? ts('Custom Groups') : ts('Custom Group');
203 }
204
205 /**
206 * Returns foreign keys and entity references.
207 *
208 * @return array
209 * [CRM_Core_Reference_Interface]
210 */
211 public static function getReferenceColumns() {
212 if (!isset(Civi::$statics[__CLASS__]['links'])) {
213 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
214 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
215 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
216 }
217 return Civi::$statics[__CLASS__]['links'];
218 }
219
220 /**
221 * Returns all the column names of this table
222 *
223 * @return array
224 */
225 public static function &fields() {
226 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
227 Civi::$statics[__CLASS__]['fields'] = [
228 'id' => [
229 'name' => 'id',
230 'type' => CRM_Utils_Type::T_INT,
231 'title' => ts('Custom Group ID'),
232 'description' => ts('Unique Custom Group ID'),
233 'required' => TRUE,
234 'where' => 'civicrm_custom_group.id',
235 'table_name' => 'civicrm_custom_group',
236 'entity' => 'CustomGroup',
237 'bao' => 'CRM_Core_BAO_CustomGroup',
238 'localizable' => 0,
239 'add' => '1.1',
240 ],
241 'name' => [
242 'name' => 'name',
243 'type' => CRM_Utils_Type::T_STRING,
244 'title' => ts('Custom Group Name'),
245 'description' => ts('Variable name/programmatic handle for this group.'),
246 'maxlength' => 64,
247 'size' => CRM_Utils_Type::BIG,
248 'where' => 'civicrm_custom_group.name',
249 'table_name' => 'civicrm_custom_group',
250 'entity' => 'CustomGroup',
251 'bao' => 'CRM_Core_BAO_CustomGroup',
252 'localizable' => 0,
253 'add' => '1.1',
254 ],
255 'title' => [
256 'name' => 'title',
257 'type' => CRM_Utils_Type::T_STRING,
258 'title' => ts('Custom Group Title'),
259 'description' => ts('Friendly Name.'),
260 'required' => TRUE,
261 'maxlength' => 64,
262 'size' => CRM_Utils_Type::BIG,
263 'where' => 'civicrm_custom_group.title',
264 'table_name' => 'civicrm_custom_group',
265 'entity' => 'CustomGroup',
266 'bao' => 'CRM_Core_BAO_CustomGroup',
267 'localizable' => 1,
268 'add' => '1.1',
269 ],
270 'extends' => [
271 'name' => 'extends',
272 'type' => CRM_Utils_Type::T_STRING,
273 'title' => ts('Custom Group Extends'),
274 'description' => ts('Type of object this group extends (can add other options later e.g. contact_address, etc.).'),
275 'maxlength' => 255,
276 'size' => CRM_Utils_Type::HUGE,
277 'where' => 'civicrm_custom_group.extends',
278 'default' => 'Contact',
279 'table_name' => 'civicrm_custom_group',
280 'entity' => 'CustomGroup',
281 'bao' => 'CRM_Core_BAO_CustomGroup',
282 'localizable' => 0,
283 'add' => '1.1',
284 ],
285 'extends_entity_column_id' => [
286 'name' => 'extends_entity_column_id',
287 'type' => CRM_Utils_Type::T_INT,
288 'title' => ts('Custom Group Subtype List'),
289 'description' => ts('FK to civicrm_option_value.id (for option group custom_data_type.)'),
290 'where' => 'civicrm_custom_group.extends_entity_column_id',
291 'default' => 'NULL',
292 'table_name' => 'civicrm_custom_group',
293 'entity' => 'CustomGroup',
294 'bao' => 'CRM_Core_BAO_CustomGroup',
295 'localizable' => 0,
296 'html' => [
297 'type' => 'Select',
298 ],
299 'pseudoconstant' => [
300 'optionGroupName' => 'custom_data_type',
301 'optionEditPath' => 'civicrm/admin/options/custom_data_type',
302 ],
303 'add' => '2.2',
304 ],
305 'extends_entity_column_value' => [
306 'name' => 'extends_entity_column_value',
307 'type' => CRM_Utils_Type::T_STRING,
308 'title' => ts('Custom Group Subtype'),
309 'description' => ts('linking custom group for dynamic object'),
310 'maxlength' => 255,
311 'size' => CRM_Utils_Type::HUGE,
312 'where' => 'civicrm_custom_group.extends_entity_column_value',
313 'table_name' => 'civicrm_custom_group',
314 'entity' => 'CustomGroup',
315 'bao' => 'CRM_Core_BAO_CustomGroup',
316 'localizable' => 0,
317 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
318 'add' => '1.6',
319 ],
320 'style' => [
321 'name' => 'style',
322 'type' => CRM_Utils_Type::T_STRING,
323 'title' => ts('Custom Group Style'),
324 'description' => ts('Visual relationship between this form and its parent.'),
325 'maxlength' => 15,
326 'size' => CRM_Utils_Type::TWELVE,
327 'where' => 'civicrm_custom_group.style',
328 'table_name' => 'civicrm_custom_group',
329 'entity' => 'CustomGroup',
330 'bao' => 'CRM_Core_BAO_CustomGroup',
331 'localizable' => 0,
332 'html' => [
333 'type' => 'Select',
334 ],
335 'pseudoconstant' => [
336 'callback' => 'CRM_Core_SelectValues::customGroupStyle',
337 ],
338 'add' => '1.1',
339 ],
340 'collapse_display' => [
341 'name' => 'collapse_display',
342 'type' => CRM_Utils_Type::T_BOOLEAN,
343 'title' => ts('Collapse Custom Group?'),
344 'description' => ts('Will this group be in collapsed or expanded mode on initial display ?'),
345 'where' => 'civicrm_custom_group.collapse_display',
346 'default' => '0',
347 'table_name' => 'civicrm_custom_group',
348 'entity' => 'CustomGroup',
349 'bao' => 'CRM_Core_BAO_CustomGroup',
350 'localizable' => 0,
351 'add' => '1.1',
352 ],
353 'help_pre' => [
354 'name' => 'help_pre',
355 'type' => CRM_Utils_Type::T_TEXT,
356 'title' => ts('Custom Group Pre Text'),
357 'description' => ts('Description and/or help text to display before fields in form.'),
358 'rows' => 4,
359 'cols' => 80,
360 'where' => 'civicrm_custom_group.help_pre',
361 'table_name' => 'civicrm_custom_group',
362 'entity' => 'CustomGroup',
363 'bao' => 'CRM_Core_BAO_CustomGroup',
364 'localizable' => 1,
365 'html' => [
366 'type' => 'TextArea',
367 ],
368 'add' => '1.1',
369 ],
370 'help_post' => [
371 'name' => 'help_post',
372 'type' => CRM_Utils_Type::T_TEXT,
373 'title' => ts('Custom Group Post Text'),
374 'description' => ts('Description and/or help text to display after fields in form.'),
375 'rows' => 4,
376 'cols' => 80,
377 'where' => 'civicrm_custom_group.help_post',
378 'table_name' => 'civicrm_custom_group',
379 'entity' => 'CustomGroup',
380 'bao' => 'CRM_Core_BAO_CustomGroup',
381 'localizable' => 1,
382 'html' => [
383 'type' => 'TextArea',
384 ],
385 'add' => '1.1',
386 ],
387 'weight' => [
388 'name' => 'weight',
389 'type' => CRM_Utils_Type::T_INT,
390 'title' => ts('Order'),
391 'description' => ts('Controls display order when multiple extended property groups are setup for the same class.'),
392 'required' => TRUE,
393 'where' => 'civicrm_custom_group.weight',
394 'default' => '1',
395 'table_name' => 'civicrm_custom_group',
396 'entity' => 'CustomGroup',
397 'bao' => 'CRM_Core_BAO_CustomGroup',
398 'localizable' => 0,
399 'add' => '1.1',
400 ],
401 'is_active' => [
402 'name' => 'is_active',
403 'type' => CRM_Utils_Type::T_BOOLEAN,
404 'title' => ts('Custom Group Is Active?'),
405 'description' => ts('Is this property active?'),
406 'where' => 'civicrm_custom_group.is_active',
407 'default' => '1',
408 'table_name' => 'civicrm_custom_group',
409 'entity' => 'CustomGroup',
410 'bao' => 'CRM_Core_BAO_CustomGroup',
411 'localizable' => 0,
412 'add' => '1.1',
413 ],
414 'table_name' => [
415 'name' => 'table_name',
416 'type' => CRM_Utils_Type::T_STRING,
417 'title' => ts('Table Name'),
418 'description' => ts('Name of the table that holds the values for this group.'),
419 'maxlength' => 255,
420 'size' => CRM_Utils_Type::HUGE,
421 'where' => 'civicrm_custom_group.table_name',
422 'table_name' => 'civicrm_custom_group',
423 'entity' => 'CustomGroup',
424 'bao' => 'CRM_Core_BAO_CustomGroup',
425 'localizable' => 0,
426 'add' => '2.0',
427 ],
428 'is_multiple' => [
429 'name' => 'is_multiple',
430 'type' => CRM_Utils_Type::T_BOOLEAN,
431 'title' => ts('Supports Multiple Records'),
432 'description' => ts('Does this group hold multiple values?'),
433 'where' => 'civicrm_custom_group.is_multiple',
434 'default' => '0',
435 'table_name' => 'civicrm_custom_group',
436 'entity' => 'CustomGroup',
437 'bao' => 'CRM_Core_BAO_CustomGroup',
438 'localizable' => 0,
439 'add' => '2.0',
440 ],
441 'min_multiple' => [
442 'name' => 'min_multiple',
443 'type' => CRM_Utils_Type::T_INT,
444 'title' => ts('Minimum Multiple Records'),
445 'description' => ts('minimum number of multiple records (typically 0?)'),
446 'where' => 'civicrm_custom_group.min_multiple',
447 'table_name' => 'civicrm_custom_group',
448 'entity' => 'CustomGroup',
449 'bao' => 'CRM_Core_BAO_CustomGroup',
450 'localizable' => 0,
451 'add' => '2.2',
452 ],
453 'max_multiple' => [
454 'name' => 'max_multiple',
455 'type' => CRM_Utils_Type::T_INT,
456 'title' => ts('Maximum Multiple Records'),
457 'description' => ts('maximum number of multiple records, if 0 - no max'),
458 'where' => 'civicrm_custom_group.max_multiple',
459 'table_name' => 'civicrm_custom_group',
460 'entity' => 'CustomGroup',
461 'bao' => 'CRM_Core_BAO_CustomGroup',
462 'localizable' => 0,
463 'add' => '2.2',
464 ],
465 'collapse_adv_display' => [
466 'name' => 'collapse_adv_display',
467 'type' => CRM_Utils_Type::T_BOOLEAN,
468 'title' => ts('Collapse Group Display'),
469 'description' => ts('Will this group be in collapsed or expanded mode on advanced search display ?'),
470 'where' => 'civicrm_custom_group.collapse_adv_display',
471 'default' => '0',
472 'table_name' => 'civicrm_custom_group',
473 'entity' => 'CustomGroup',
474 'bao' => 'CRM_Core_BAO_CustomGroup',
475 'localizable' => 0,
476 'add' => '3.0',
477 ],
478 'created_id' => [
479 'name' => 'created_id',
480 'type' => CRM_Utils_Type::T_INT,
481 'title' => ts('Custom Group Created By'),
482 'description' => ts('FK to civicrm_contact, who created this custom group'),
483 'where' => 'civicrm_custom_group.created_id',
484 'table_name' => 'civicrm_custom_group',
485 'entity' => 'CustomGroup',
486 'bao' => 'CRM_Core_BAO_CustomGroup',
487 'localizable' => 0,
488 'FKClassName' => 'CRM_Contact_DAO_Contact',
489 'add' => '3.0',
490 ],
491 'created_date' => [
492 'name' => 'created_date',
493 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
494 'title' => ts('Custom Group Created Date'),
495 'description' => ts('Date and time this custom group was created.'),
496 'where' => 'civicrm_custom_group.created_date',
497 'table_name' => 'civicrm_custom_group',
498 'entity' => 'CustomGroup',
499 'bao' => 'CRM_Core_BAO_CustomGroup',
500 'localizable' => 0,
501 'add' => '3.0',
502 ],
503 'is_reserved' => [
504 'name' => 'is_reserved',
505 'type' => CRM_Utils_Type::T_BOOLEAN,
506 'title' => ts('Reserved Group?'),
507 'description' => ts('Is this a reserved Custom Group?'),
508 'where' => 'civicrm_custom_group.is_reserved',
509 'default' => '0',
510 'table_name' => 'civicrm_custom_group',
511 'entity' => 'CustomGroup',
512 'bao' => 'CRM_Core_BAO_CustomGroup',
513 'localizable' => 0,
514 'add' => '4.4',
515 ],
516 'is_public' => [
517 'name' => 'is_public',
518 'type' => CRM_Utils_Type::T_BOOLEAN,
519 'title' => ts('Custom Group Is Public?'),
520 'description' => ts('Is this property public?'),
521 'where' => 'civicrm_custom_group.is_public',
522 'default' => '1',
523 'table_name' => 'civicrm_custom_group',
524 'entity' => 'CustomGroup',
525 'bao' => 'CRM_Core_BAO_CustomGroup',
526 'localizable' => 0,
527 'add' => '4.7',
528 ],
529 'icon' => [
530 'name' => 'icon',
531 'type' => CRM_Utils_Type::T_STRING,
532 'title' => ts('Icon'),
533 'description' => ts('crm-i icon class'),
534 'maxlength' => 255,
535 'size' => CRM_Utils_Type::HUGE,
536 'where' => 'civicrm_custom_group.icon',
537 'default' => 'NULL',
538 'table_name' => 'civicrm_custom_group',
539 'entity' => 'CustomGroup',
540 'bao' => 'CRM_Core_BAO_CustomGroup',
541 'localizable' => 0,
542 'add' => '5.28',
543 ],
544 ];
545 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
546 }
547 return Civi::$statics[__CLASS__]['fields'];
548 }
549
550 /**
551 * Return a mapping from field-name to the corresponding key (as used in fields()).
552 *
553 * @return array
554 * Array(string $name => string $uniqueName).
555 */
556 public static function &fieldKeys() {
557 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
558 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
559 }
560 return Civi::$statics[__CLASS__]['fieldKeys'];
561 }
562
563 /**
564 * Returns the names of this table
565 *
566 * @return string
567 */
568 public static function getTableName() {
569 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
570 }
571
572 /**
573 * Returns if this table needs to be logged
574 *
575 * @return bool
576 */
577 public function getLog() {
578 return self::$_log;
579 }
580
581 /**
582 * Returns the list of fields that can be imported
583 *
584 * @param bool $prefix
585 *
586 * @return array
587 */
588 public static function &import($prefix = FALSE) {
589 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'custom_group', $prefix, []);
590 return $r;
591 }
592
593 /**
594 * Returns the list of fields that can be exported
595 *
596 * @param bool $prefix
597 *
598 * @return array
599 */
600 public static function &export($prefix = FALSE) {
601 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'custom_group', $prefix, []);
602 return $r;
603 }
604
605 /**
606 * Returns the list of indices
607 *
608 * @param bool $localize
609 *
610 * @return array
611 */
612 public static function indices($localize = TRUE) {
613 $indices = [
614 'UI_title_extends' => [
615 'name' => 'UI_title_extends',
616 'field' => [
617 0 => 'title',
618 1 => 'extends',
619 ],
620 'localizable' => TRUE,
621 'unique' => TRUE,
622 'sig' => 'civicrm_custom_group::1::title::extends',
623 ],
624 'UI_name_extends' => [
625 'name' => 'UI_name_extends',
626 'field' => [
627 0 => 'name',
628 1 => 'extends',
629 ],
630 'localizable' => FALSE,
631 'unique' => TRUE,
632 'sig' => 'civicrm_custom_group::1::name::extends',
633 ],
634 ];
635 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
636 }
637
638 }