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