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