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