Merge pull request #11813 from seanmadsen/add-survey-pre-post-hooks
[civicrm-core.git] / CRM / Contact / DAO / Group.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2018
6 *
7 * Generated from xml/schema/CRM/Contact/Group.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:6db3c227371b68fadd9eb82c6e96ebfe)
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 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 static $_log = TRUE;
30
31 /**
32 * Group ID
33 *
34 * @var int unsigned
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 unsigned
70 */
71 public $saved_search_id;
72
73 /**
74 * Is this entry active?
75 *
76 * @var boolean
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 boolean
147 */
148 public $is_hidden;
149
150 /**
151 * @var boolean
152 */
153 public $is_reserved;
154
155 /**
156 * FK to contact table.
157 *
158 * @var int unsigned
159 */
160 public $created_id;
161
162 /**
163 * FK to contact table.
164 *
165 * @var int unsigned
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' => 'Group ID',
207 'required' => TRUE,
208 'table_name' => 'civicrm_group',
209 'entity' => 'Group',
210 'bao' => 'CRM_Contact_BAO_Group',
211 'localizable' => 0,
212 ],
213 'name' => [
214 'name' => 'name',
215 'type' => CRM_Utils_Type::T_STRING,
216 'title' => ts('Group Name'),
217 'description' => 'Internal name of Group.',
218 'maxlength' => 64,
219 'size' => CRM_Utils_Type::BIG,
220 'table_name' => 'civicrm_group',
221 'entity' => 'Group',
222 'bao' => 'CRM_Contact_BAO_Group',
223 'localizable' => 0,
224 ],
225 'title' => [
226 'name' => 'title',
227 'type' => CRM_Utils_Type::T_STRING,
228 'title' => ts('Group Title'),
229 'description' => 'Name of Group.',
230 'maxlength' => 64,
231 'size' => CRM_Utils_Type::BIG,
232 'table_name' => 'civicrm_group',
233 'entity' => 'Group',
234 'bao' => 'CRM_Contact_BAO_Group',
235 'localizable' => 1,
236 ],
237 'description' => [
238 'name' => 'description',
239 'type' => CRM_Utils_Type::T_TEXT,
240 'title' => ts('Group Description'),
241 'description' => 'Optional verbose description of the group.',
242 'rows' => 2,
243 'cols' => 60,
244 'table_name' => 'civicrm_group',
245 'entity' => 'Group',
246 'bao' => 'CRM_Contact_BAO_Group',
247 'localizable' => 0,
248 'html' => [
249 'type' => 'TextArea',
250 ],
251 ],
252 'source' => [
253 'name' => 'source',
254 'type' => CRM_Utils_Type::T_STRING,
255 'title' => ts('Group Source'),
256 'description' => 'Module or process which created this group.',
257 'maxlength' => 64,
258 'size' => CRM_Utils_Type::BIG,
259 'table_name' => 'civicrm_group',
260 'entity' => 'Group',
261 'bao' => 'CRM_Contact_BAO_Group',
262 'localizable' => 0,
263 ],
264 'saved_search_id' => [
265 'name' => 'saved_search_id',
266 'type' => CRM_Utils_Type::T_INT,
267 'title' => ts('Saved Search ID'),
268 'description' => 'FK to saved search table.',
269 'table_name' => 'civicrm_group',
270 'entity' => 'Group',
271 'bao' => 'CRM_Contact_BAO_Group',
272 'localizable' => 0,
273 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
274 ],
275 'is_active' => [
276 'name' => 'is_active',
277 'type' => CRM_Utils_Type::T_BOOLEAN,
278 'title' => ts('Group Enabled'),
279 'description' => 'Is this entry active?',
280 'table_name' => 'civicrm_group',
281 'entity' => 'Group',
282 'bao' => 'CRM_Contact_BAO_Group',
283 'localizable' => 0,
284 ],
285 'visibility' => [
286 'name' => 'visibility',
287 'type' => CRM_Utils_Type::T_STRING,
288 'title' => ts('Group Visibility Setting'),
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',
293 'table_name' => 'civicrm_group',
294 'entity' => 'Group',
295 'bao' => 'CRM_Contact_BAO_Group',
296 'localizable' => 0,
297 'html' => [
298 'type' => 'Select',
299 ],
300 'pseudoconstant' => [
301 'callback' => 'CRM_Core_SelectValues::groupVisibility',
302 ]
303 ],
304 'where_clause' => [
305 'name' => 'where_clause',
306 'type' => CRM_Utils_Type::T_TEXT,
307 'title' => ts('Group Where Clause'),
308 'description' => 'the sql where clause if a saved search acl',
309 'table_name' => 'civicrm_group',
310 'entity' => 'Group',
311 'bao' => 'CRM_Contact_BAO_Group',
312 'localizable' => 0,
313 ],
314 'select_tables' => [
315 'name' => 'select_tables',
316 'type' => CRM_Utils_Type::T_TEXT,
317 'title' => ts('Tables For Select Clause'),
318 'description' => 'the tables to be included in a select data',
319 'table_name' => 'civicrm_group',
320 'entity' => 'Group',
321 'bao' => 'CRM_Contact_BAO_Group',
322 'localizable' => 0,
323 'serialize' => self::SERIALIZE_PHP,
324 ],
325 'where_tables' => [
326 'name' => 'where_tables',
327 'type' => CRM_Utils_Type::T_TEXT,
328 'title' => ts('Tables For Where Clause'),
329 'description' => 'the tables to be included in the count statement',
330 'table_name' => 'civicrm_group',
331 'entity' => 'Group',
332 'bao' => 'CRM_Contact_BAO_Group',
333 'localizable' => 0,
334 'serialize' => self::SERIALIZE_PHP,
335 ],
336 'group_type' => [
337 'name' => 'group_type',
338 'type' => CRM_Utils_Type::T_STRING,
339 'title' => ts('Group Type'),
340 'description' => 'FK to group type',
341 'maxlength' => 128,
342 'size' => CRM_Utils_Type::HUGE,
343 'table_name' => 'civicrm_group',
344 'entity' => 'Group',
345 'bao' => 'CRM_Contact_BAO_Group',
346 'localizable' => 0,
347 'serialize' => self::SERIALIZE_SEPARATOR_BOOKEND,
348 'pseudoconstant' => [
349 'optionGroupName' => 'group_type',
350 'optionEditPath' => 'civicrm/admin/options/group_type',
351 ]
352 ],
353 'cache_date' => [
354 'name' => 'cache_date',
355 'type' => CRM_Utils_Type::T_TIMESTAMP,
356 'title' => ts('Group Cache Date'),
357 'description' => 'Date when we created the cache for a smart group',
358 'required' => FALSE,
359 'table_name' => 'civicrm_group',
360 'entity' => 'Group',
361 'bao' => 'CRM_Contact_BAO_Group',
362 'localizable' => 0,
363 ],
364 'refresh_date' => [
365 'name' => 'refresh_date',
366 'type' => CRM_Utils_Type::T_TIMESTAMP,
367 'title' => ts('Next Group Refresh Time'),
368 'description' => 'Date and time when we need to refresh the cache next.',
369 'required' => FALSE,
370 'table_name' => 'civicrm_group',
371 'entity' => 'Group',
372 'bao' => 'CRM_Contact_BAO_Group',
373 'localizable' => 0,
374 ],
375 'parents' => [
376 'name' => 'parents',
377 'type' => CRM_Utils_Type::T_TEXT,
378 'title' => ts('Group Parents'),
379 'description' => 'IDs of the parent(s)',
380 'table_name' => 'civicrm_group',
381 'entity' => 'Group',
382 'bao' => 'CRM_Contact_BAO_Group',
383 'localizable' => 0,
384 'serialize' => self::SERIALIZE_COMMA,
385 'pseudoconstant' => [
386 'callback' => 'CRM_Core_PseudoConstant::allGroup',
387 ]
388 ],
389 'children' => [
390 'name' => 'children',
391 'type' => CRM_Utils_Type::T_TEXT,
392 'title' => ts('Group Children'),
393 'description' => 'IDs of the child(ren)',
394 'table_name' => 'civicrm_group',
395 'entity' => 'Group',
396 'bao' => 'CRM_Contact_BAO_Group',
397 'localizable' => 0,
398 ],
399 'is_hidden' => [
400 'name' => 'is_hidden',
401 'type' => CRM_Utils_Type::T_BOOLEAN,
402 'title' => ts('Group is Hidden'),
403 'description' => 'Is this group hidden?',
404 'table_name' => 'civicrm_group',
405 'entity' => 'Group',
406 'bao' => 'CRM_Contact_BAO_Group',
407 'localizable' => 0,
408 ],
409 'is_reserved' => [
410 'name' => 'is_reserved',
411 'type' => CRM_Utils_Type::T_BOOLEAN,
412 'title' => ts('Group is Reserved'),
413 'table_name' => 'civicrm_group',
414 'entity' => 'Group',
415 'bao' => 'CRM_Contact_BAO_Group',
416 'localizable' => 0,
417 ],
418 'created_id' => [
419 'name' => 'created_id',
420 'type' => CRM_Utils_Type::T_INT,
421 'title' => ts('Group Created By'),
422 'description' => 'FK to contact table.',
423 'table_name' => 'civicrm_group',
424 'entity' => 'Group',
425 'bao' => 'CRM_Contact_BAO_Group',
426 'localizable' => 0,
427 'FKClassName' => 'CRM_Contact_DAO_Contact',
428 ],
429 'modified_id' => [
430 'name' => 'modified_id',
431 'type' => CRM_Utils_Type::T_INT,
432 'title' => ts('Group Modified By'),
433 'description' => 'FK to contact table.',
434 'table_name' => 'civicrm_group',
435 'entity' => 'Group',
436 'bao' => 'CRM_Contact_BAO_Group',
437 'localizable' => 0,
438 'FKClassName' => 'CRM_Contact_DAO_Contact',
439 ],
440 ];
441 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
442 }
443 return Civi::$statics[__CLASS__]['fields'];
444 }
445
446 /**
447 * Return a mapping from field-name to the corresponding key (as used in fields()).
448 *
449 * @return array
450 * Array(string $name => string $uniqueName).
451 */
452 public static function &fieldKeys() {
453 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
454 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
455 }
456 return Civi::$statics[__CLASS__]['fieldKeys'];
457 }
458
459 /**
460 * Returns the names of this table
461 *
462 * @return string
463 */
464 public static function getTableName() {
465 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
466 }
467
468 /**
469 * Returns if this table needs to be logged
470 *
471 * @return bool
472 */
473 public function getLog() {
474 return self::$_log;
475 }
476
477 /**
478 * Returns the list of fields that can be imported
479 *
480 * @param bool $prefix
481 *
482 * @return array
483 */
484 public static function &import($prefix = FALSE) {
485 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
486 return $r;
487 }
488
489 /**
490 * Returns the list of fields that can be exported
491 *
492 * @param bool $prefix
493 *
494 * @return array
495 */
496 public static function &export($prefix = FALSE) {
497 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
498 return $r;
499 }
500
501 /**
502 * Returns the list of indices
503 *
504 * @param bool $localize
505 *
506 * @return array
507 */
508 public static function indices($localize = TRUE) {
509 $indices = [
510 'index_group_type' => [
511 'name' => 'index_group_type',
512 'field' => [
513 0 => 'group_type',
514 ],
515 'localizable' => FALSE,
516 'sig' => 'civicrm_group::0::group_type',
517 ],
518 'UI_title' => [
519 'name' => 'UI_title',
520 'field' => [
521 0 => 'title',
522 ],
523 'localizable' => TRUE,
524 'unique' => TRUE,
525 'sig' => 'civicrm_group::1::title',
526 ],
527 'UI_name' => [
528 'name' => 'UI_name',
529 'field' => [
530 0 => 'name',
531 ],
532 'localizable' => FALSE,
533 'unique' => TRUE,
534 'sig' => 'civicrm_group::1::name',
535 ],
536 ];
537 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
538 }
539
540 }