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