Merge pull request #21943 from mattwire/gccacheignore
[civicrm-core.git] / CRM / Contact / DAO / Group.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/Group.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:8b5d08ec2b844a6b9167fa80a590a58c)
10 */
11
12 /**
13 * Database access object for the Group entity.
14 */
15 class CRM_Contact_DAO_Group 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_group';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-users';
32
33 /**
34 * Field to show when displaying a record.
35 *
36 * @var string
37 */
38 public static $_labelField = 'title';
39
40 /**
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
42 *
43 * @var bool
44 */
45 public static $_log = TRUE;
46
47 /**
48 * Paths for accessing this entity in the UI.
49 *
50 * @var string[]
51 */
52 protected static $_paths = [
53 'add' => 'civicrm/group/add?reset=1',
54 'view' => 'civicrm/group/search?force=1&context=smog&gid=[id]&component_mode=1',
55 'update' => 'civicrm/group?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/group?reset=1&action=delete&id=[id]',
57 ];
58
59 /**
60 * Group ID
61 *
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
65 */
66 public $id;
67
68 /**
69 * Internal name of Group.
70 *
71 * @var string|null
72 * (SQL type: varchar(64))
73 * Note that values will be retrieved from the database as a string.
74 */
75 public $name;
76
77 /**
78 * Name of Group.
79 *
80 * @var string|null
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
83 */
84 public $title;
85
86 /**
87 * Optional verbose description of the group.
88 *
89 * @var string|null
90 * (SQL type: text)
91 * Note that values will be retrieved from the database as a string.
92 */
93 public $description;
94
95 /**
96 * Module or process which created this group.
97 *
98 * @var string|null
99 * (SQL type: varchar(64))
100 * Note that values will be retrieved from the database as a string.
101 */
102 public $source;
103
104 /**
105 * FK to saved search table.
106 *
107 * @var int|string|null
108 * (SQL type: int unsigned)
109 * Note that values will be retrieved from the database as a string.
110 */
111 public $saved_search_id;
112
113 /**
114 * Is this entry active?
115 *
116 * @var bool|string
117 * (SQL type: tinyint)
118 * Note that values will be retrieved from the database as a string.
119 */
120 public $is_active;
121
122 /**
123 * In what context(s) is this field visible.
124 *
125 * @var string|null
126 * (SQL type: varchar(24))
127 * Note that values will be retrieved from the database as a string.
128 */
129 public $visibility;
130
131 /**
132 * the sql where clause if a saved search acl
133 *
134 * @var string|null
135 * (SQL type: text)
136 * Note that values will be retrieved from the database as a string.
137 */
138 public $where_clause;
139
140 /**
141 * the tables to be included in a select data
142 *
143 * @var string|null
144 * (SQL type: text)
145 * Note that values will be retrieved from the database as a string.
146 */
147 public $select_tables;
148
149 /**
150 * the tables to be included in the count statement
151 *
152 * @var string|null
153 * (SQL type: text)
154 * Note that values will be retrieved from the database as a string.
155 */
156 public $where_tables;
157
158 /**
159 * FK to group type
160 *
161 * @var string|null
162 * (SQL type: varchar(128))
163 * Note that values will be retrieved from the database as a string.
164 */
165 public $group_type;
166
167 /**
168 * Date when we created the cache for a smart group
169 *
170 * @var string
171 * (SQL type: timestamp)
172 * Note that values will be retrieved from the database as a string.
173 */
174 public $cache_date;
175
176 /**
177 * Date and time when we need to refresh the cache next.
178 *
179 * @var string
180 * (SQL type: timestamp)
181 * Note that values will be retrieved from the database as a string.
182 */
183 public $refresh_date;
184
185 /**
186 * IDs of the parent(s)
187 *
188 * @var string|null
189 * (SQL type: text)
190 * Note that values will be retrieved from the database as a string.
191 */
192 public $parents;
193
194 /**
195 * IDs of the child(ren)
196 *
197 * @var string|null
198 * (SQL type: text)
199 * Note that values will be retrieved from the database as a string.
200 */
201 public $children;
202
203 /**
204 * Is this group hidden?
205 *
206 * @var bool|string
207 * (SQL type: tinyint)
208 * Note that values will be retrieved from the database as a string.
209 */
210 public $is_hidden;
211
212 /**
213 * @var bool|string
214 * (SQL type: tinyint)
215 * Note that values will be retrieved from the database as a string.
216 */
217 public $is_reserved;
218
219 /**
220 * FK to contact table.
221 *
222 * @var int|string|null
223 * (SQL type: int unsigned)
224 * Note that values will be retrieved from the database as a string.
225 */
226 public $created_id;
227
228 /**
229 * FK to contact table.
230 *
231 * @var int|string|null
232 * (SQL type: int unsigned)
233 * Note that values will be retrieved from the database as a string.
234 */
235 public $modified_id;
236
237 /**
238 * Alternative public title for this Group.
239 *
240 * @var string|null
241 * (SQL type: varchar(255))
242 * Note that values will be retrieved from the database as a string.
243 */
244 public $frontend_title;
245
246 /**
247 * Alternative public description of the group.
248 *
249 * @var string|null
250 * (SQL type: text)
251 * Note that values will be retrieved from the database as a string.
252 */
253 public $frontend_description;
254
255 /**
256 * Class constructor.
257 */
258 public function __construct() {
259 $this->__table = 'civicrm_group';
260 parent::__construct();
261 }
262
263 /**
264 * Returns localized title of this entity.
265 *
266 * @param bool $plural
267 * Whether to return the plural version of the title.
268 */
269 public static function getEntityTitle($plural = FALSE) {
270 return $plural ? ts('Groups') : ts('Group');
271 }
272
273 /**
274 * Returns foreign keys and entity references.
275 *
276 * @return array
277 * [CRM_Core_Reference_Interface]
278 */
279 public static function getReferenceColumns() {
280 if (!isset(Civi::$statics[__CLASS__]['links'])) {
281 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
282 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
283 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
284 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
285 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
286 }
287 return Civi::$statics[__CLASS__]['links'];
288 }
289
290 /**
291 * Returns all the column names of this table
292 *
293 * @return array
294 */
295 public static function &fields() {
296 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
297 Civi::$statics[__CLASS__]['fields'] = [
298 'id' => [
299 'name' => 'id',
300 'type' => CRM_Utils_Type::T_INT,
301 'title' => ts('Group ID'),
302 'description' => ts('Group ID'),
303 'required' => TRUE,
304 'where' => 'civicrm_group.id',
305 'table_name' => 'civicrm_group',
306 'entity' => 'Group',
307 'bao' => 'CRM_Contact_BAO_Group',
308 'localizable' => 0,
309 'html' => [
310 'type' => 'Number',
311 ],
312 'readonly' => TRUE,
313 'add' => '1.1',
314 ],
315 'name' => [
316 'name' => 'name',
317 'type' => CRM_Utils_Type::T_STRING,
318 'title' => ts('Group Name'),
319 'description' => ts('Internal name of Group.'),
320 'maxlength' => 64,
321 'size' => CRM_Utils_Type::BIG,
322 'where' => 'civicrm_group.name',
323 'table_name' => 'civicrm_group',
324 'entity' => 'Group',
325 'bao' => 'CRM_Contact_BAO_Group',
326 'localizable' => 0,
327 'add' => '1.1',
328 ],
329 'title' => [
330 'name' => 'title',
331 'type' => CRM_Utils_Type::T_STRING,
332 'title' => ts('Group Title'),
333 'description' => ts('Name of Group.'),
334 'maxlength' => 255,
335 'size' => CRM_Utils_Type::HUGE,
336 'where' => 'civicrm_group.title',
337 'table_name' => 'civicrm_group',
338 'entity' => 'Group',
339 'bao' => 'CRM_Contact_BAO_Group',
340 'localizable' => 1,
341 'html' => [
342 'type' => 'Text',
343 ],
344 'add' => '1.1',
345 ],
346 'description' => [
347 'name' => 'description',
348 'type' => CRM_Utils_Type::T_TEXT,
349 'title' => ts('Group Description'),
350 'description' => ts('Optional verbose description of the group.'),
351 'rows' => 2,
352 'cols' => 60,
353 'where' => 'civicrm_group.description',
354 'table_name' => 'civicrm_group',
355 'entity' => 'Group',
356 'bao' => 'CRM_Contact_BAO_Group',
357 'localizable' => 0,
358 'html' => [
359 'type' => 'TextArea',
360 ],
361 'add' => '1.1',
362 ],
363 'source' => [
364 'name' => 'source',
365 'type' => CRM_Utils_Type::T_STRING,
366 'title' => ts('Group Source'),
367 'description' => ts('Module or process which created this group.'),
368 'maxlength' => 64,
369 'size' => CRM_Utils_Type::BIG,
370 'where' => 'civicrm_group.source',
371 'table_name' => 'civicrm_group',
372 'entity' => 'Group',
373 'bao' => 'CRM_Contact_BAO_Group',
374 'localizable' => 0,
375 'add' => '1.1',
376 ],
377 'saved_search_id' => [
378 'name' => 'saved_search_id',
379 'type' => CRM_Utils_Type::T_INT,
380 'title' => ts('Saved Search ID'),
381 'description' => ts('FK to saved search table.'),
382 'where' => 'civicrm_group.saved_search_id',
383 'table_name' => 'civicrm_group',
384 'entity' => 'Group',
385 'bao' => 'CRM_Contact_BAO_Group',
386 'localizable' => 0,
387 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
388 'html' => [
389 'label' => ts("Saved Search"),
390 ],
391 'add' => '1.1',
392 ],
393 'is_active' => [
394 'name' => 'is_active',
395 'type' => CRM_Utils_Type::T_BOOLEAN,
396 'title' => ts('Group Enabled'),
397 'description' => ts('Is this entry active?'),
398 'required' => TRUE,
399 'where' => 'civicrm_group.is_active',
400 'default' => '1',
401 'table_name' => 'civicrm_group',
402 'entity' => 'Group',
403 'bao' => 'CRM_Contact_BAO_Group',
404 'localizable' => 0,
405 'add' => '1.1',
406 ],
407 'visibility' => [
408 'name' => 'visibility',
409 'type' => CRM_Utils_Type::T_STRING,
410 'title' => ts('Group Visibility Setting'),
411 'description' => ts('In what context(s) is this field visible.'),
412 'maxlength' => 24,
413 'size' => CRM_Utils_Type::MEDIUM,
414 'where' => 'civicrm_group.visibility',
415 'default' => 'User and User Admin Only',
416 'table_name' => 'civicrm_group',
417 'entity' => 'Group',
418 'bao' => 'CRM_Contact_BAO_Group',
419 'localizable' => 0,
420 'html' => [
421 'type' => 'Select',
422 ],
423 'pseudoconstant' => [
424 'callback' => 'CRM_Core_SelectValues::groupVisibility',
425 ],
426 'add' => '1.2',
427 ],
428 'where_clause' => [
429 'name' => 'where_clause',
430 'type' => CRM_Utils_Type::T_TEXT,
431 'title' => ts('Group Where Clause'),
432 'description' => ts('the sql where clause if a saved search acl'),
433 'where' => 'civicrm_group.where_clause',
434 'table_name' => 'civicrm_group',
435 'entity' => 'Group',
436 'bao' => 'CRM_Contact_BAO_Group',
437 'localizable' => 0,
438 'readonly' => TRUE,
439 'add' => '1.6',
440 ],
441 'select_tables' => [
442 'name' => 'select_tables',
443 'type' => CRM_Utils_Type::T_TEXT,
444 'title' => ts('Tables For Select Clause'),
445 'description' => ts('the tables to be included in a select data'),
446 'where' => 'civicrm_group.select_tables',
447 'table_name' => 'civicrm_group',
448 'entity' => 'Group',
449 'bao' => 'CRM_Contact_BAO_Group',
450 'localizable' => 0,
451 'serialize' => self::SERIALIZE_PHP,
452 'readonly' => TRUE,
453 'add' => '1.6',
454 ],
455 'where_tables' => [
456 'name' => 'where_tables',
457 'type' => CRM_Utils_Type::T_TEXT,
458 'title' => ts('Tables For Where Clause'),
459 'description' => ts('the tables to be included in the count statement'),
460 'where' => 'civicrm_group.where_tables',
461 'table_name' => 'civicrm_group',
462 'entity' => 'Group',
463 'bao' => 'CRM_Contact_BAO_Group',
464 'localizable' => 0,
465 'serialize' => self::SERIALIZE_PHP,
466 'readonly' => TRUE,
467 'add' => '1.6',
468 ],
469 'group_type' => [
470 'name' => 'group_type',
471 'type' => CRM_Utils_Type::T_STRING,
472 'title' => ts('Group Type'),
473 'description' => ts('FK to group type'),
474 'maxlength' => 128,
475 'size' => CRM_Utils_Type::HUGE,
476 'where' => 'civicrm_group.group_type',
477 'table_name' => 'civicrm_group',
478 'entity' => 'Group',
479 'bao' => 'CRM_Contact_BAO_Group',
480 'localizable' => 0,
481 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
482 'pseudoconstant' => [
483 'optionGroupName' => 'group_type',
484 'optionEditPath' => 'civicrm/admin/options/group_type',
485 ],
486 'add' => '1.9',
487 ],
488 'cache_date' => [
489 'name' => 'cache_date',
490 'type' => CRM_Utils_Type::T_TIMESTAMP,
491 'title' => ts('Group Cache Date'),
492 'description' => ts('Date when we created the cache for a smart group'),
493 'required' => FALSE,
494 'where' => 'civicrm_group.cache_date',
495 'table_name' => 'civicrm_group',
496 'entity' => 'Group',
497 'bao' => 'CRM_Contact_BAO_Group',
498 'localizable' => 0,
499 'readonly' => TRUE,
500 'add' => '2.1',
501 ],
502 'refresh_date' => [
503 'name' => 'refresh_date',
504 'type' => CRM_Utils_Type::T_TIMESTAMP,
505 'title' => ts('Next Group Refresh Time'),
506 'description' => ts('Date and time when we need to refresh the cache next.'),
507 'required' => FALSE,
508 'where' => 'civicrm_group.refresh_date',
509 'table_name' => 'civicrm_group',
510 'entity' => 'Group',
511 'bao' => 'CRM_Contact_BAO_Group',
512 'localizable' => 0,
513 'readonly' => TRUE,
514 'add' => '4.3',
515 ],
516 'parents' => [
517 'name' => 'parents',
518 'type' => CRM_Utils_Type::T_TEXT,
519 'title' => ts('Group Parents'),
520 'description' => ts('IDs of the parent(s)'),
521 'where' => 'civicrm_group.parents',
522 'table_name' => 'civicrm_group',
523 'entity' => 'Group',
524 'bao' => 'CRM_Contact_BAO_Group',
525 'localizable' => 0,
526 'serialize' => self::SERIALIZE_COMMA,
527 'pseudoconstant' => [
528 'callback' => 'CRM_Core_PseudoConstant::allGroup',
529 ],
530 'add' => '2.1',
531 ],
532 'children' => [
533 'name' => 'children',
534 'type' => CRM_Utils_Type::T_TEXT,
535 'title' => ts('Group Children'),
536 'description' => ts('IDs of the child(ren)'),
537 'where' => 'civicrm_group.children',
538 'table_name' => 'civicrm_group',
539 'entity' => 'Group',
540 'bao' => 'CRM_Contact_BAO_Group',
541 'localizable' => 0,
542 'add' => '2.1',
543 ],
544 'is_hidden' => [
545 'name' => 'is_hidden',
546 'type' => CRM_Utils_Type::T_BOOLEAN,
547 'title' => ts('Group is Hidden'),
548 'description' => ts('Is this group hidden?'),
549 'required' => TRUE,
550 'where' => 'civicrm_group.is_hidden',
551 'default' => '0',
552 'table_name' => 'civicrm_group',
553 'entity' => 'Group',
554 'bao' => 'CRM_Contact_BAO_Group',
555 'localizable' => 0,
556 'add' => '2.2',
557 ],
558 'is_reserved' => [
559 'name' => 'is_reserved',
560 'type' => CRM_Utils_Type::T_BOOLEAN,
561 'title' => ts('Group is Reserved'),
562 'required' => TRUE,
563 'where' => 'civicrm_group.is_reserved',
564 'default' => '0',
565 'table_name' => 'civicrm_group',
566 'entity' => 'Group',
567 'bao' => 'CRM_Contact_BAO_Group',
568 'localizable' => 0,
569 'add' => '4.2',
570 ],
571 'created_id' => [
572 'name' => 'created_id',
573 'type' => CRM_Utils_Type::T_INT,
574 'title' => ts('Created By Contact ID'),
575 'description' => ts('FK to contact table.'),
576 'where' => 'civicrm_group.created_id',
577 'table_name' => 'civicrm_group',
578 'entity' => 'Group',
579 'bao' => 'CRM_Contact_BAO_Group',
580 'localizable' => 0,
581 'FKClassName' => 'CRM_Contact_DAO_Contact',
582 'html' => [
583 'label' => ts("Created By"),
584 ],
585 'add' => '4.3',
586 ],
587 'modified_id' => [
588 'name' => 'modified_id',
589 'type' => CRM_Utils_Type::T_INT,
590 'title' => ts('Modified By Contact ID'),
591 'description' => ts('FK to contact table.'),
592 'where' => 'civicrm_group.modified_id',
593 'table_name' => 'civicrm_group',
594 'entity' => 'Group',
595 'bao' => 'CRM_Contact_BAO_Group',
596 'localizable' => 0,
597 'FKClassName' => 'CRM_Contact_DAO_Contact',
598 'html' => [
599 'label' => ts("Modified By"),
600 ],
601 'readonly' => TRUE,
602 'add' => '4.5',
603 ],
604 'frontend_title' => [
605 'name' => 'frontend_title',
606 'type' => CRM_Utils_Type::T_STRING,
607 'title' => ts('Public Group Title'),
608 'description' => ts('Alternative public title for this Group.'),
609 'maxlength' => 255,
610 'size' => CRM_Utils_Type::HUGE,
611 'where' => 'civicrm_group.frontend_title',
612 'default' => NULL,
613 'table_name' => 'civicrm_group',
614 'entity' => 'Group',
615 'bao' => 'CRM_Contact_BAO_Group',
616 'localizable' => 1,
617 'html' => [
618 'type' => 'Text',
619 ],
620 'add' => '5.31',
621 ],
622 'frontend_description' => [
623 'name' => 'frontend_description',
624 'type' => CRM_Utils_Type::T_TEXT,
625 'title' => ts('Public Group Description'),
626 'description' => ts('Alternative public description of the group.'),
627 'rows' => 2,
628 'cols' => 60,
629 'where' => 'civicrm_group.frontend_description',
630 'default' => NULL,
631 'table_name' => 'civicrm_group',
632 'entity' => 'Group',
633 'bao' => 'CRM_Contact_BAO_Group',
634 'localizable' => 1,
635 'html' => [
636 'type' => 'TextArea',
637 ],
638 'add' => '5.31',
639 ],
640 ];
641 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
642 }
643 return Civi::$statics[__CLASS__]['fields'];
644 }
645
646 /**
647 * Return a mapping from field-name to the corresponding key (as used in fields()).
648 *
649 * @return array
650 * Array(string $name => string $uniqueName).
651 */
652 public static function &fieldKeys() {
653 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
654 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
655 }
656 return Civi::$statics[__CLASS__]['fieldKeys'];
657 }
658
659 /**
660 * Returns the names of this table
661 *
662 * @return string
663 */
664 public static function getTableName() {
665 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
666 }
667
668 /**
669 * Returns if this table needs to be logged
670 *
671 * @return bool
672 */
673 public function getLog() {
674 return self::$_log;
675 }
676
677 /**
678 * Returns the list of fields that can be imported
679 *
680 * @param bool $prefix
681 *
682 * @return array
683 */
684 public static function &import($prefix = FALSE) {
685 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
686 return $r;
687 }
688
689 /**
690 * Returns the list of fields that can be exported
691 *
692 * @param bool $prefix
693 *
694 * @return array
695 */
696 public static function &export($prefix = FALSE) {
697 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
698 return $r;
699 }
700
701 /**
702 * Returns the list of indices
703 *
704 * @param bool $localize
705 *
706 * @return array
707 */
708 public static function indices($localize = TRUE) {
709 $indices = [
710 'UI_cache_date' => [
711 'name' => 'UI_cache_date',
712 'field' => [
713 0 => 'cache_date',
714 ],
715 'localizable' => FALSE,
716 'sig' => 'civicrm_group::0::cache_date',
717 ],
718 'index_group_type' => [
719 'name' => 'index_group_type',
720 'field' => [
721 0 => 'group_type',
722 ],
723 'localizable' => FALSE,
724 'sig' => 'civicrm_group::0::group_type',
725 ],
726 'UI_title' => [
727 'name' => 'UI_title',
728 'field' => [
729 0 => 'title',
730 ],
731 'localizable' => TRUE,
732 'unique' => TRUE,
733 'sig' => 'civicrm_group::1::title',
734 ],
735 'UI_name' => [
736 'name' => 'UI_name',
737 'field' => [
738 0 => 'name',
739 ],
740 'localizable' => FALSE,
741 'unique' => TRUE,
742 'sig' => 'civicrm_group::1::name',
743 ],
744 ];
745 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
746 }
747
748 }