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