Merge pull request #18930 from MegaphoneJon/financial-156
[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:49027c63bf6fd142e79220b39f84056d)
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 'required' => TRUE,
277 'maxlength' => 255,
278 'size' => CRM_Utils_Type::HUGE,
279 'where' => 'civicrm_group.title',
280 'table_name' => 'civicrm_group',
281 'entity' => 'Group',
282 'bao' => 'CRM_Contact_BAO_Group',
283 'localizable' => 1,
284 'html' => [
285 'type' => 'Text',
286 ],
287 'add' => '1.1',
288 ],
289 'description' => [
290 'name' => 'description',
291 'type' => CRM_Utils_Type::T_TEXT,
292 'title' => ts('Group Description'),
293 'description' => ts('Optional verbose description of the group.'),
294 'rows' => 2,
295 'cols' => 60,
296 'where' => 'civicrm_group.description',
297 'table_name' => 'civicrm_group',
298 'entity' => 'Group',
299 'bao' => 'CRM_Contact_BAO_Group',
300 'localizable' => 0,
301 'html' => [
302 'type' => 'TextArea',
303 ],
304 'add' => '1.1',
305 ],
306 'source' => [
307 'name' => 'source',
308 'type' => CRM_Utils_Type::T_STRING,
309 'title' => ts('Group Source'),
310 'description' => ts('Module or process which created this group.'),
311 'maxlength' => 64,
312 'size' => CRM_Utils_Type::BIG,
313 'where' => 'civicrm_group.source',
314 'table_name' => 'civicrm_group',
315 'entity' => 'Group',
316 'bao' => 'CRM_Contact_BAO_Group',
317 'localizable' => 0,
318 'add' => '1.1',
319 ],
320 'saved_search_id' => [
321 'name' => 'saved_search_id',
322 'type' => CRM_Utils_Type::T_INT,
323 'title' => ts('Saved Search ID'),
324 'description' => ts('FK to saved search table.'),
325 'where' => 'civicrm_group.saved_search_id',
326 'table_name' => 'civicrm_group',
327 'entity' => 'Group',
328 'bao' => 'CRM_Contact_BAO_Group',
329 'localizable' => 0,
330 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
331 'add' => '1.1',
332 ],
333 'is_active' => [
334 'name' => 'is_active',
335 'type' => CRM_Utils_Type::T_BOOLEAN,
336 'title' => ts('Group Enabled'),
337 'description' => ts('Is this entry active?'),
338 'where' => 'civicrm_group.is_active',
339 'table_name' => 'civicrm_group',
340 'entity' => 'Group',
341 'bao' => 'CRM_Contact_BAO_Group',
342 'localizable' => 0,
343 'add' => '1.1',
344 ],
345 'visibility' => [
346 'name' => 'visibility',
347 'type' => CRM_Utils_Type::T_STRING,
348 'title' => ts('Group Visibility Setting'),
349 'description' => ts('In what context(s) is this field visible.'),
350 'maxlength' => 24,
351 'size' => CRM_Utils_Type::MEDIUM,
352 'where' => 'civicrm_group.visibility',
353 'default' => 'User and User Admin Only',
354 'table_name' => 'civicrm_group',
355 'entity' => 'Group',
356 'bao' => 'CRM_Contact_BAO_Group',
357 'localizable' => 0,
358 'html' => [
359 'type' => 'Select',
360 ],
361 'pseudoconstant' => [
362 'callback' => 'CRM_Core_SelectValues::groupVisibility',
363 ],
364 'add' => '1.2',
365 ],
366 'where_clause' => [
367 'name' => 'where_clause',
368 'type' => CRM_Utils_Type::T_TEXT,
369 'title' => ts('Group Where Clause'),
370 'description' => ts('the sql where clause if a saved search acl'),
371 'where' => 'civicrm_group.where_clause',
372 'table_name' => 'civicrm_group',
373 'entity' => 'Group',
374 'bao' => 'CRM_Contact_BAO_Group',
375 'localizable' => 0,
376 'add' => '1.6',
377 ],
378 'select_tables' => [
379 'name' => 'select_tables',
380 'type' => CRM_Utils_Type::T_TEXT,
381 'title' => ts('Tables For Select Clause'),
382 'description' => ts('the tables to be included in a select data'),
383 'where' => 'civicrm_group.select_tables',
384 'table_name' => 'civicrm_group',
385 'entity' => 'Group',
386 'bao' => 'CRM_Contact_BAO_Group',
387 'localizable' => 0,
388 'serialize' => self::SERIALIZE_PHP,
389 'add' => '1.6',
390 ],
391 'where_tables' => [
392 'name' => 'where_tables',
393 'type' => CRM_Utils_Type::T_TEXT,
394 'title' => ts('Tables For Where Clause'),
395 'description' => ts('the tables to be included in the count statement'),
396 'where' => 'civicrm_group.where_tables',
397 'table_name' => 'civicrm_group',
398 'entity' => 'Group',
399 'bao' => 'CRM_Contact_BAO_Group',
400 'localizable' => 0,
401 'serialize' => self::SERIALIZE_PHP,
402 'add' => '1.6',
403 ],
404 'group_type' => [
405 'name' => 'group_type',
406 'type' => CRM_Utils_Type::T_STRING,
407 'title' => ts('Group Type'),
408 'description' => ts('FK to group type'),
409 'maxlength' => 128,
410 'size' => CRM_Utils_Type::HUGE,
411 'where' => 'civicrm_group.group_type',
412 'table_name' => 'civicrm_group',
413 'entity' => 'Group',
414 'bao' => 'CRM_Contact_BAO_Group',
415 'localizable' => 0,
416 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
417 'pseudoconstant' => [
418 'optionGroupName' => 'group_type',
419 'optionEditPath' => 'civicrm/admin/options/group_type',
420 ],
421 'add' => '1.9',
422 ],
423 'cache_date' => [
424 'name' => 'cache_date',
425 'type' => CRM_Utils_Type::T_TIMESTAMP,
426 'title' => ts('Group Cache Date'),
427 'description' => ts('Date when we created the cache for a smart group'),
428 'required' => FALSE,
429 'where' => 'civicrm_group.cache_date',
430 'table_name' => 'civicrm_group',
431 'entity' => 'Group',
432 'bao' => 'CRM_Contact_BAO_Group',
433 'localizable' => 0,
434 'add' => '2.1',
435 ],
436 'refresh_date' => [
437 'name' => 'refresh_date',
438 'type' => CRM_Utils_Type::T_TIMESTAMP,
439 'title' => ts('Next Group Refresh Time'),
440 'description' => ts('Date and time when we need to refresh the cache next.'),
441 'required' => FALSE,
442 'where' => 'civicrm_group.refresh_date',
443 'table_name' => 'civicrm_group',
444 'entity' => 'Group',
445 'bao' => 'CRM_Contact_BAO_Group',
446 'localizable' => 0,
447 'add' => '4.3',
448 ],
449 'parents' => [
450 'name' => 'parents',
451 'type' => CRM_Utils_Type::T_TEXT,
452 'title' => ts('Group Parents'),
453 'description' => ts('IDs of the parent(s)'),
454 'where' => 'civicrm_group.parents',
455 'table_name' => 'civicrm_group',
456 'entity' => 'Group',
457 'bao' => 'CRM_Contact_BAO_Group',
458 'localizable' => 0,
459 'serialize' => self::SERIALIZE_COMMA,
460 'pseudoconstant' => [
461 'callback' => 'CRM_Core_PseudoConstant::allGroup',
462 ],
463 'add' => '2.1',
464 ],
465 'children' => [
466 'name' => 'children',
467 'type' => CRM_Utils_Type::T_TEXT,
468 'title' => ts('Group Children'),
469 'description' => ts('IDs of the child(ren)'),
470 'where' => 'civicrm_group.children',
471 'table_name' => 'civicrm_group',
472 'entity' => 'Group',
473 'bao' => 'CRM_Contact_BAO_Group',
474 'localizable' => 0,
475 'add' => '2.1',
476 ],
477 'is_hidden' => [
478 'name' => 'is_hidden',
479 'type' => CRM_Utils_Type::T_BOOLEAN,
480 'title' => ts('Group is Hidden'),
481 'description' => ts('Is this group hidden?'),
482 'where' => 'civicrm_group.is_hidden',
483 'default' => '0',
484 'table_name' => 'civicrm_group',
485 'entity' => 'Group',
486 'bao' => 'CRM_Contact_BAO_Group',
487 'localizable' => 0,
488 'add' => '2.2',
489 ],
490 'is_reserved' => [
491 'name' => 'is_reserved',
492 'type' => CRM_Utils_Type::T_BOOLEAN,
493 'title' => ts('Group is Reserved'),
494 'where' => 'civicrm_group.is_reserved',
495 'default' => '0',
496 'table_name' => 'civicrm_group',
497 'entity' => 'Group',
498 'bao' => 'CRM_Contact_BAO_Group',
499 'localizable' => 0,
500 'add' => '4.2',
501 ],
502 'created_id' => [
503 'name' => 'created_id',
504 'type' => CRM_Utils_Type::T_INT,
505 'title' => ts('Group Created By'),
506 'description' => ts('FK to contact table.'),
507 'where' => 'civicrm_group.created_id',
508 'table_name' => 'civicrm_group',
509 'entity' => 'Group',
510 'bao' => 'CRM_Contact_BAO_Group',
511 'localizable' => 0,
512 'FKClassName' => 'CRM_Contact_DAO_Contact',
513 'add' => '4.3',
514 ],
515 'modified_id' => [
516 'name' => 'modified_id',
517 'type' => CRM_Utils_Type::T_INT,
518 'title' => ts('Group Modified By'),
519 'description' => ts('FK to contact table.'),
520 'where' => 'civicrm_group.modified_id',
521 'table_name' => 'civicrm_group',
522 'entity' => 'Group',
523 'bao' => 'CRM_Contact_BAO_Group',
524 'localizable' => 0,
525 'FKClassName' => 'CRM_Contact_DAO_Contact',
526 'add' => '4.5',
527 ],
528 'frontend_title' => [
529 'name' => 'frontend_title',
530 'type' => CRM_Utils_Type::T_STRING,
531 'title' => ts('Public Group Title'),
532 'description' => ts('Alternative public title for this Group.'),
533 'maxlength' => 255,
534 'size' => CRM_Utils_Type::HUGE,
535 'where' => 'civicrm_group.frontend_title',
536 'default' => 'NULL',
537 'table_name' => 'civicrm_group',
538 'entity' => 'Group',
539 'bao' => 'CRM_Contact_BAO_Group',
540 'localizable' => 1,
541 'html' => [
542 'type' => 'Text',
543 ],
544 'add' => '5.31',
545 ],
546 'frontend_description' => [
547 'name' => 'frontend_description',
548 'type' => CRM_Utils_Type::T_TEXT,
549 'title' => ts('Public Group Description'),
550 'description' => ts('Alternative public description of the group.'),
551 'rows' => 2,
552 'cols' => 60,
553 'where' => 'civicrm_group.frontend_description',
554 'default' => 'NULL',
555 'table_name' => 'civicrm_group',
556 'entity' => 'Group',
557 'bao' => 'CRM_Contact_BAO_Group',
558 'localizable' => 1,
559 'html' => [
560 'type' => 'TextArea',
561 ],
562 'add' => '5.31',
563 ],
564 ];
565 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
566 }
567 return Civi::$statics[__CLASS__]['fields'];
568 }
569
570 /**
571 * Return a mapping from field-name to the corresponding key (as used in fields()).
572 *
573 * @return array
574 * Array(string $name => string $uniqueName).
575 */
576 public static function &fieldKeys() {
577 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
578 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
579 }
580 return Civi::$statics[__CLASS__]['fieldKeys'];
581 }
582
583 /**
584 * Returns the names of this table
585 *
586 * @return string
587 */
588 public static function getTableName() {
589 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
590 }
591
592 /**
593 * Returns if this table needs to be logged
594 *
595 * @return bool
596 */
597 public function getLog() {
598 return self::$_log;
599 }
600
601 /**
602 * Returns the list of fields that can be imported
603 *
604 * @param bool $prefix
605 *
606 * @return array
607 */
608 public static function &import($prefix = FALSE) {
609 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
610 return $r;
611 }
612
613 /**
614 * Returns the list of fields that can be exported
615 *
616 * @param bool $prefix
617 *
618 * @return array
619 */
620 public static function &export($prefix = FALSE) {
621 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
622 return $r;
623 }
624
625 /**
626 * Returns the list of indices
627 *
628 * @param bool $localize
629 *
630 * @return array
631 */
632 public static function indices($localize = TRUE) {
633 $indices = [
634 'index_group_type' => [
635 'name' => 'index_group_type',
636 'field' => [
637 0 => 'group_type',
638 ],
639 'localizable' => FALSE,
640 'sig' => 'civicrm_group::0::group_type',
641 ],
642 'UI_title' => [
643 'name' => 'UI_title',
644 'field' => [
645 0 => 'title',
646 ],
647 'localizable' => TRUE,
648 'unique' => TRUE,
649 'sig' => 'civicrm_group::1::title',
650 ],
651 'UI_name' => [
652 'name' => 'UI_name',
653 'field' => [
654 0 => 'name',
655 ],
656 'localizable' => FALSE,
657 'unique' => TRUE,
658 'sig' => 'civicrm_group::1::name',
659 ],
660 ];
661 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
662 }
663
664 }