Merge pull request #12818 from mattwire/contributionsearch_byrecurtrxnprocessor
[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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('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' => ts('Is this group hidden?'),
404 'default' => '0',
405 'table_name' => 'civicrm_group',
406 'entity' => 'Group',
407 'bao' => 'CRM_Contact_BAO_Group',
408 'localizable' => 0,
409 ],
410 'is_reserved' => [
411 'name' => 'is_reserved',
412 'type' => CRM_Utils_Type::T_BOOLEAN,
413 'title' => ts('Group is Reserved'),
414 'default' => '0',
415 'table_name' => 'civicrm_group',
416 'entity' => 'Group',
417 'bao' => 'CRM_Contact_BAO_Group',
418 'localizable' => 0,
419 ],
420 'created_id' => [
421 'name' => 'created_id',
422 'type' => CRM_Utils_Type::T_INT,
423 'title' => ts('Group Created By'),
424 'description' => ts('FK to contact table.'),
425 'table_name' => 'civicrm_group',
426 'entity' => 'Group',
427 'bao' => 'CRM_Contact_BAO_Group',
428 'localizable' => 0,
429 'FKClassName' => 'CRM_Contact_DAO_Contact',
430 ],
431 'modified_id' => [
432 'name' => 'modified_id',
433 'type' => CRM_Utils_Type::T_INT,
434 'title' => ts('Group Modified By'),
435 'description' => ts('FK to contact table.'),
436 'table_name' => 'civicrm_group',
437 'entity' => 'Group',
438 'bao' => 'CRM_Contact_BAO_Group',
439 'localizable' => 0,
440 'FKClassName' => 'CRM_Contact_DAO_Contact',
441 ],
442 ];
443 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
444 }
445 return Civi::$statics[__CLASS__]['fields'];
446 }
447
448 /**
449 * Return a mapping from field-name to the corresponding key (as used in fields()).
450 *
451 * @return array
452 * Array(string $name => string $uniqueName).
453 */
454 public static function &fieldKeys() {
455 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
456 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
457 }
458 return Civi::$statics[__CLASS__]['fieldKeys'];
459 }
460
461 /**
462 * Returns the names of this table
463 *
464 * @return string
465 */
466 public static function getTableName() {
467 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
468 }
469
470 /**
471 * Returns if this table needs to be logged
472 *
473 * @return bool
474 */
475 public function getLog() {
476 return self::$_log;
477 }
478
479 /**
480 * Returns the list of fields that can be imported
481 *
482 * @param bool $prefix
483 *
484 * @return array
485 */
486 public static function &import($prefix = FALSE) {
487 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, []);
488 return $r;
489 }
490
491 /**
492 * Returns the list of fields that can be exported
493 *
494 * @param bool $prefix
495 *
496 * @return array
497 */
498 public static function &export($prefix = FALSE) {
499 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, []);
500 return $r;
501 }
502
503 /**
504 * Returns the list of indices
505 *
506 * @param bool $localize
507 *
508 * @return array
509 */
510 public static function indices($localize = TRUE) {
511 $indices = [
512 'index_group_type' => [
513 'name' => 'index_group_type',
514 'field' => [
515 0 => 'group_type',
516 ],
517 'localizable' => FALSE,
518 'sig' => 'civicrm_group::0::group_type',
519 ],
520 'UI_title' => [
521 'name' => 'UI_title',
522 'field' => [
523 0 => 'title',
524 ],
525 'localizable' => TRUE,
526 'unique' => TRUE,
527 'sig' => 'civicrm_group::1::title',
528 ],
529 'UI_name' => [
530 'name' => 'UI_name',
531 'field' => [
532 0 => 'name',
533 ],
534 'localizable' => FALSE,
535 'unique' => TRUE,
536 'sig' => 'civicrm_group::1::name',
537 ],
538 ];
539 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
540 }
541
542 }