Merge pull request #18222 from civicrm/5.29
[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:6a2a222c5fa5b461727bb95379723b08)
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 * Class constructor.
180 */
181 public function __construct() {
182 $this->__table = 'civicrm_group';
183 parent::__construct();
184 }
185
186 /**
187 * Returns localized title of this entity.
188 */
189 public static function getEntityTitle() {
190 return ts('Groups');
191 }
192
193 /**
194 * Returns foreign keys and entity references.
195 *
196 * @return array
197 * [CRM_Core_Reference_Interface]
198 */
199 public static function getReferenceColumns() {
200 if (!isset(Civi::$statics[__CLASS__]['links'])) {
201 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
202 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
203 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
204 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id');
205 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
206 }
207 return Civi::$statics[__CLASS__]['links'];
208 }
209
210 /**
211 * Returns all the column names of this table
212 *
213 * @return array
214 */
215 public static function &fields() {
216 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
217 Civi::$statics[__CLASS__]['fields'] = [
218 'id' => [
219 'name' => 'id',
220 'type' => CRM_Utils_Type::T_INT,
221 'title' => ts('Group ID'),
222 'description' => ts('Group ID'),
223 'required' => TRUE,
224 'where' => 'civicrm_group.id',
225 'table_name' => 'civicrm_group',
226 'entity' => 'Group',
227 'bao' => 'CRM_Contact_BAO_Group',
228 'localizable' => 0,
229 'add' => '1.1',
230 ],
231 'name' => [
232 'name' => 'name',
233 'type' => CRM_Utils_Type::T_STRING,
234 'title' => ts('Group Name'),
235 'description' => ts('Internal name of Group.'),
236 'maxlength' => 64,
237 'size' => CRM_Utils_Type::BIG,
238 'where' => 'civicrm_group.name',
239 'table_name' => 'civicrm_group',
240 'entity' => 'Group',
241 'bao' => 'CRM_Contact_BAO_Group',
242 'localizable' => 0,
243 'add' => '1.1',
244 ],
245 'title' => [
246 'name' => 'title',
247 'type' => CRM_Utils_Type::T_STRING,
248 'title' => ts('Group Title'),
249 'description' => ts('Name of Group.'),
250 'maxlength' => 64,
251 'size' => CRM_Utils_Type::BIG,
252 'where' => 'civicrm_group.title',
253 'table_name' => 'civicrm_group',
254 'entity' => 'Group',
255 'bao' => 'CRM_Contact_BAO_Group',
256 'localizable' => 1,
257 'html' => [
258 'type' => 'Text',
259 ],
260 'add' => '1.1',
261 ],
262 'description' => [
263 'name' => 'description',
264 'type' => CRM_Utils_Type::T_TEXT,
265 'title' => ts('Group Description'),
266 'description' => ts('Optional verbose description of the group.'),
267 'rows' => 2,
268 'cols' => 60,
269 'where' => 'civicrm_group.description',
270 'table_name' => 'civicrm_group',
271 'entity' => 'Group',
272 'bao' => 'CRM_Contact_BAO_Group',
273 'localizable' => 0,
274 'html' => [
275 'type' => 'TextArea',
276 ],
277 'add' => '1.1',
278 ],
279 'source' => [
280 'name' => 'source',
281 'type' => CRM_Utils_Type::T_STRING,
282 'title' => ts('Group Source'),
283 'description' => ts('Module or process which created this group.'),
284 'maxlength' => 64,
285 'size' => CRM_Utils_Type::BIG,
286 'where' => 'civicrm_group.source',
287 'table_name' => 'civicrm_group',
288 'entity' => 'Group',
289 'bao' => 'CRM_Contact_BAO_Group',
290 'localizable' => 0,
291 'add' => '1.1',
292 ],
293 'saved_search_id' => [
294 'name' => 'saved_search_id',
295 'type' => CRM_Utils_Type::T_INT,
296 'title' => ts('Saved Search ID'),
297 'description' => ts('FK to saved search table.'),
298 'where' => 'civicrm_group.saved_search_id',
299 'table_name' => 'civicrm_group',
300 'entity' => 'Group',
301 'bao' => 'CRM_Contact_BAO_Group',
302 'localizable' => 0,
303 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
304 'add' => '1.1',
305 ],
306 'is_active' => [
307 'name' => 'is_active',
308 'type' => CRM_Utils_Type::T_BOOLEAN,
309 'title' => ts('Group Enabled'),
310 'description' => ts('Is this entry active?'),
311 'where' => 'civicrm_group.is_active',
312 'table_name' => 'civicrm_group',
313 'entity' => 'Group',
314 'bao' => 'CRM_Contact_BAO_Group',
315 'localizable' => 0,
316 'add' => '1.1',
317 ],
318 'visibility' => [
319 'name' => 'visibility',
320 'type' => CRM_Utils_Type::T_STRING,
321 'title' => ts('Group Visibility Setting'),
322 'description' => ts('In what context(s) is this field visible.'),
323 'maxlength' => 24,
324 'size' => CRM_Utils_Type::MEDIUM,
325 'where' => 'civicrm_group.visibility',
326 'default' => 'User and User Admin Only',
327 'table_name' => 'civicrm_group',
328 'entity' => 'Group',
329 'bao' => 'CRM_Contact_BAO_Group',
330 'localizable' => 0,
331 'html' => [
332 'type' => 'Select',
333 ],
334 'pseudoconstant' => [
335 'callback' => 'CRM_Core_SelectValues::groupVisibility',
336 ],
337 'add' => '1.2',
338 ],
339 'where_clause' => [
340 'name' => 'where_clause',
341 'type' => CRM_Utils_Type::T_TEXT,
342 'title' => ts('Group Where Clause'),
343 'description' => ts('the sql where clause if a saved search acl'),
344 'where' => 'civicrm_group.where_clause',
345 'table_name' => 'civicrm_group',
346 'entity' => 'Group',
347 'bao' => 'CRM_Contact_BAO_Group',
348 'localizable' => 0,
349 'add' => '1.6',
350 ],
351 'select_tables' => [
352 'name' => 'select_tables',
353 'type' => CRM_Utils_Type::T_TEXT,
354 'title' => ts('Tables For Select Clause'),
355 'description' => ts('the tables to be included in a select data'),
356 'where' => 'civicrm_group.select_tables',
357 'table_name' => 'civicrm_group',
358 'entity' => 'Group',
359 'bao' => 'CRM_Contact_BAO_Group',
360 'localizable' => 0,
361 'serialize' => self::SERIALIZE_PHP,
362 'add' => '1.6',
363 ],
364 'where_tables' => [
365 'name' => 'where_tables',
366 'type' => CRM_Utils_Type::T_TEXT,
367 'title' => ts('Tables For Where Clause'),
368 'description' => ts('the tables to be included in the count statement'),
369 'where' => 'civicrm_group.where_tables',
370 'table_name' => 'civicrm_group',
371 'entity' => 'Group',
372 'bao' => 'CRM_Contact_BAO_Group',
373 'localizable' => 0,
374 'serialize' => self::SERIALIZE_PHP,
375 'add' => '1.6',
376 ],
377 'group_type' => [
378 'name' => 'group_type',
379 'type' => CRM_Utils_Type::T_STRING,
380 'title' => ts('Group Type'),
381 'description' => ts('FK to group type'),
382 'maxlength' => 128,
383 'size' => CRM_Utils_Type::HUGE,
384 'where' => 'civicrm_group.group_type',
385 'table_name' => 'civicrm_group',
386 'entity' => 'Group',
387 'bao' => 'CRM_Contact_BAO_Group',
388 'localizable' => 0,
389 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
390 'pseudoconstant' => [
391 'optionGroupName' => 'group_type',
392 'optionEditPath' => 'civicrm/admin/options/group_type',
393 ],
394 'add' => '1.9',
395 ],
396 'cache_date' => [
397 'name' => 'cache_date',
398 'type' => CRM_Utils_Type::T_TIMESTAMP,
399 'title' => ts('Group Cache Date'),
400 'description' => ts('Date when we created the cache for a smart group'),
401 'required' => FALSE,
402 'where' => 'civicrm_group.cache_date',
403 'table_name' => 'civicrm_group',
404 'entity' => 'Group',
405 'bao' => 'CRM_Contact_BAO_Group',
406 'localizable' => 0,
407 'add' => '2.1',
408 ],
409 'refresh_date' => [
410 'name' => 'refresh_date',
411 'type' => CRM_Utils_Type::T_TIMESTAMP,
412 'title' => ts('Next Group Refresh Time'),
413 'description' => ts('Date and time when we need to refresh the cache next.'),
414 'required' => FALSE,
415 'where' => 'civicrm_group.refresh_date',
416 'table_name' => 'civicrm_group',
417 'entity' => 'Group',
418 'bao' => 'CRM_Contact_BAO_Group',
419 'localizable' => 0,
420 'add' => '4.3',
421 ],
422 'parents' => [
423 'name' => 'parents',
424 'type' => CRM_Utils_Type::T_TEXT,
425 'title' => ts('Group Parents'),
426 'description' => ts('IDs of the parent(s)'),
427 'where' => 'civicrm_group.parents',
428 'table_name' => 'civicrm_group',
429 'entity' => 'Group',
430 'bao' => 'CRM_Contact_BAO_Group',
431 'localizable' => 0,
432 'serialize' => self::SERIALIZE_COMMA,
433 'pseudoconstant' => [
434 'callback' => 'CRM_Core_PseudoConstant::allGroup',
435 ],
436 'add' => '2.1',
437 ],
438 'children' => [
439 'name' => 'children',
440 'type' => CRM_Utils_Type::T_TEXT,
441 'title' => ts('Group Children'),
442 'description' => ts('IDs of the child(ren)'),
443 'where' => 'civicrm_group.children',
444 'table_name' => 'civicrm_group',
445 'entity' => 'Group',
446 'bao' => 'CRM_Contact_BAO_Group',
447 'localizable' => 0,
448 'add' => '2.1',
449 ],
450 'is_hidden' => [
451 'name' => 'is_hidden',
452 'type' => CRM_Utils_Type::T_BOOLEAN,
453 'title' => ts('Group is Hidden'),
454 'description' => ts('Is this group hidden?'),
455 'where' => 'civicrm_group.is_hidden',
456 'default' => '0',
457 'table_name' => 'civicrm_group',
458 'entity' => 'Group',
459 'bao' => 'CRM_Contact_BAO_Group',
460 'localizable' => 0,
461 'add' => '2.2',
462 ],
463 'is_reserved' => [
464 'name' => 'is_reserved',
465 'type' => CRM_Utils_Type::T_BOOLEAN,
466 'title' => ts('Group is Reserved'),
467 'where' => 'civicrm_group.is_reserved',
468 'default' => '0',
469 'table_name' => 'civicrm_group',
470 'entity' => 'Group',
471 'bao' => 'CRM_Contact_BAO_Group',
472 'localizable' => 0,
473 'add' => '4.2',
474 ],
475 'created_id' => [
476 'name' => 'created_id',
477 'type' => CRM_Utils_Type::T_INT,
478 'title' => ts('Group Created By'),
479 'description' => ts('FK to contact table.'),
480 'where' => 'civicrm_group.created_id',
481 'table_name' => 'civicrm_group',
482 'entity' => 'Group',
483 'bao' => 'CRM_Contact_BAO_Group',
484 'localizable' => 0,
485 'FKClassName' => 'CRM_Contact_DAO_Contact',
486 'add' => '4.3',
487 ],
488 'modified_id' => [
489 'name' => 'modified_id',
490 'type' => CRM_Utils_Type::T_INT,
491 'title' => ts('Group Modified By'),
492 'description' => ts('FK to contact table.'),
493 'where' => 'civicrm_group.modified_id',
494 'table_name' => 'civicrm_group',
495 'entity' => 'Group',
496 'bao' => 'CRM_Contact_BAO_Group',
497 'localizable' => 0,
498 'FKClassName' => 'CRM_Contact_DAO_Contact',
499 'add' => '4.5',
500 ],
501 ];
502 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
503 }
504 return Civi::$statics[__CLASS__]['fields'];
505 }
506
507 /**
508 * Return a mapping from field-name to the corresponding key (as used in fields()).
509 *
510 * @return array
511 * Array(string $name => string $uniqueName).
512 */
513 public static function &fieldKeys() {
514 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
515 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
516 }
517 return Civi::$statics[__CLASS__]['fieldKeys'];
518 }
519
520 /**
521 * Returns the names of this table
522 *
523 * @return string
524 */
525 public static function getTableName() {
526 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
527 }
528
529 /**
530 * Returns if this table needs to be logged
531 *
532 * @return bool
533 */
534 public function getLog() {
535 return self::$_log;
536 }
537
538 /**
539 * Returns the list of fields that can be imported
540 *
541 * @param bool $prefix
542 *
543 * @return array
544 */
545 public static function &import($prefix = FALSE) {
546 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
547 return $r;
548 }
549
550 /**
551 * Returns the list of fields that can be exported
552 *
553 * @param bool $prefix
554 *
555 * @return array
556 */
557 public static function &export($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
559 return $r;
560 }
561
562 /**
563 * Returns the list of indices
564 *
565 * @param bool $localize
566 *
567 * @return array
568 */
569 public static function indices($localize = TRUE) {
570 $indices = [
571 'index_group_type' => [
572 'name' => 'index_group_type',
573 'field' => [
574 0 => 'group_type',
575 ],
576 'localizable' => FALSE,
577 'sig' => 'civicrm_group::0::group_type',
578 ],
579 'UI_title' => [
580 'name' => 'UI_title',
581 'field' => [
582 0 => 'title',
583 ],
584 'localizable' => TRUE,
585 'unique' => TRUE,
586 'sig' => 'civicrm_group::1::title',
587 ],
588 'UI_name' => [
589 'name' => 'UI_name',
590 'field' => [
591 0 => 'name',
592 ],
593 'localizable' => FALSE,
594 'unique' => TRUE,
595 'sig' => 'civicrm_group::1::name',
596 ],
597 ];
598 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
599 }
600
601 }