dev/core#117 Replace use of Deprecated function each in CRM/Member/BAO/Membership...
[civicrm-core.git] / CRM / Contact / DAO / Group.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/Group.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
cb594601 9 * (GenCodeChecksum:6db3c227371b68fadd9eb82c6e96ebfe)
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'),
e501603b 206 'description' => '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'),
e501603b
TO
217 'description' => 'Internal name of Group.',
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'),
e501603b
TO
229 'description' => 'Name of Group.',
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'),
e501603b
TO
241 'description' => 'Optional verbose description of the group.',
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'),
e501603b
TO
256 'description' => 'Module or process which created this group.',
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'),
e501603b 268 'description' => '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'),
e501603b 279 'description' => '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'),
e501603b
TO
289 'description' => 'In what context(s) is this field visible.',
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'),
e501603b 308 'description' => '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'),
e501603b 318 'description' => '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'),
e501603b 329 'description' => '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'),
e501603b
TO
340 'description' => 'FK to group type',
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'),
e501603b 357 'description' => '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'),
e501603b 368 'description' => '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'),
e501603b 379 'description' => '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'),
e501603b 393 'description' => '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'),
e501603b 403 'description' => 'Is this group hidden?',
522a26c9 404 'table_name' => 'civicrm_group',
405 'entity' => 'Group',
406 'bao' => 'CRM_Contact_BAO_Group',
6a7e5e5d 407 'localizable' => 0,
c3fc2621
CW
408 ],
409 'is_reserved' => [
e501603b
TO
410 'name' => 'is_reserved',
411 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 412 'title' => ts('Group is Reserved'),
522a26c9 413 'table_name' => 'civicrm_group',
414 'entity' => 'Group',
415 'bao' => 'CRM_Contact_BAO_Group',
6a7e5e5d 416 'localizable' => 0,
c3fc2621
CW
417 ],
418 'created_id' => [
e501603b
TO
419 'name' => 'created_id',
420 'type' => CRM_Utils_Type::T_INT,
c3fc2621 421 'title' => ts('Group Created By'),
e501603b 422 'description' => 'FK to contact table.',
522a26c9 423 'table_name' => 'civicrm_group',
424 'entity' => 'Group',
425 'bao' => 'CRM_Contact_BAO_Group',
6a7e5e5d 426 'localizable' => 0,
e501603b 427 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
428 ],
429 'modified_id' => [
e501603b
TO
430 'name' => 'modified_id',
431 'type' => CRM_Utils_Type::T_INT,
c3fc2621 432 'title' => ts('Group Modified By'),
e501603b 433 'description' => 'FK to contact table.',
522a26c9 434 'table_name' => 'civicrm_group',
435 'entity' => 'Group',
436 'bao' => 'CRM_Contact_BAO_Group',
6a7e5e5d 437 'localizable' => 0,
e501603b 438 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
439 ],
440 ];
346aaaba 441 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 442 }
346aaaba 443 return Civi::$statics[__CLASS__]['fields'];
e501603b 444 }
c3fc2621 445
e501603b 446 /**
bd8e0b14 447 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
448 *
449 * @return array
bd8e0b14 450 * Array(string $name => string $uniqueName).
e501603b 451 */
c3fc2621 452 public static function &fieldKeys() {
bd8e0b14
TO
453 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
454 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 455 }
bd8e0b14 456 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 457 }
c3fc2621 458
e501603b
TO
459 /**
460 * Returns the names of this table
461 *
462 * @return string
463 */
c3fc2621 464 public static function getTableName() {
e501603b
TO
465 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
466 }
c3fc2621 467
e501603b
TO
468 /**
469 * Returns if this table needs to be logged
470 *
c3fc2621 471 * @return bool
e501603b 472 */
c3fc2621 473 public function getLog() {
e501603b
TO
474 return self::$_log;
475 }
c3fc2621 476
e501603b
TO
477 /**
478 * Returns the list of fields that can be imported
479 *
480 * @param bool $prefix
481 *
482 * @return array
483 */
c3fc2621
CW
484 public static function &import($prefix = FALSE) {
485 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
60808919 486 return $r;
e501603b 487 }
c3fc2621 488
e501603b
TO
489 /**
490 * Returns the list of fields that can be exported
491 *
492 * @param bool $prefix
493 *
494 * @return array
495 */
c3fc2621
CW
496 public static function &export($prefix = FALSE) {
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
60808919 498 return $r;
e501603b 499 }
c3fc2621 500
e7a6b91a
AS
501 /**
502 * Returns the list of indices
c3fc2621
CW
503 *
504 * @param bool $localize
505 *
506 * @return array
e7a6b91a
AS
507 */
508 public static function indices($localize = TRUE) {
c3fc2621
CW
509 $indices = [
510 'index_group_type' => [
e7a6b91a 511 'name' => 'index_group_type',
c3fc2621 512 'field' => [
e7a6b91a 513 0 => 'group_type',
c3fc2621
CW
514 ],
515 'localizable' => FALSE,
e7a6b91a 516 'sig' => 'civicrm_group::0::group_type',
c3fc2621
CW
517 ],
518 'UI_title' => [
e7a6b91a 519 'name' => 'UI_title',
c3fc2621 520 'field' => [
e7a6b91a 521 0 => 'title',
c3fc2621
CW
522 ],
523 'localizable' => TRUE,
524 'unique' => TRUE,
e7a6b91a 525 'sig' => 'civicrm_group::1::title',
c3fc2621
CW
526 ],
527 'UI_name' => [
e7a6b91a 528 'name' => 'UI_name',
c3fc2621 529 'field' => [
e7a6b91a 530 0 => 'name',
c3fc2621
CW
531 ],
532 'localizable' => FALSE,
533 'unique' => TRUE,
e7a6b91a 534 'sig' => 'civicrm_group::1::name',
c3fc2621
CW
535 ],
536 ];
e7a6b91a
AS
537 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
538 }
c3fc2621 539
e501603b 540}