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