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