5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/Group.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:25bcea958ed3b88317a2bbb89169b0a6)
13 * Database access object for the Group entity.
15 class CRM_Contact_DAO_Group
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_group';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-users';
34 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
48 * Internal name of Group.
62 * Optional verbose description of the group.
69 * Module or process which created this group.
76 * FK to saved search table.
80 public $saved_search_id;
83 * Is this entry active?
90 * In what context(s) is this field visible.
97 * the sql where clause if a saved search acl
101 public $where_clause;
104 * the tables to be included in a select data
108 public $select_tables;
111 * the tables to be included in the count statement
115 public $where_tables;
125 * Date when we created the cache for a smart group
132 * Date and time when we need to refresh the cache next.
136 public $refresh_date;
139 * IDs of the parent(s)
146 * IDs of the child(ren)
153 * Is this group hidden?
165 * FK to contact table.
172 * FK to contact table.
179 * Alternative public title for this Group.
183 public $frontend_title;
186 * Alternative public description of the group.
190 public $frontend_description;
195 public function __construct() {
196 $this->__table
= 'civicrm_group';
197 parent
::__construct();
201 * Returns localized title of this entity.
203 * @param bool $plural
204 * Whether to return the plural version of the title.
206 public static function getEntityTitle($plural = FALSE) {
207 return $plural ?
ts('Groups') : ts('Group');
211 * Returns foreign keys and entity references.
214 * [CRM_Core_Reference_Interface]
216 public static function getReferenceColumns() {
217 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
218 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
219 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
220 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
221 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
222 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
224 return Civi
::$statics[__CLASS__
]['links'];
228 * Returns all the column names of this table
232 public static function &fields() {
233 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
234 Civi
::$statics[__CLASS__
]['fields'] = [
237 'type' => CRM_Utils_Type
::T_INT
,
238 'title' => ts('Group ID'),
239 'description' => ts('Group ID'),
241 'where' => 'civicrm_group.id',
242 'table_name' => 'civicrm_group',
244 'bao' => 'CRM_Contact_BAO_Group',
250 'type' => CRM_Utils_Type
::T_STRING
,
251 'title' => ts('Group Name'),
252 'description' => ts('Internal name of Group.'),
254 'size' => CRM_Utils_Type
::BIG
,
255 'where' => 'civicrm_group.name',
256 'table_name' => 'civicrm_group',
258 'bao' => 'CRM_Contact_BAO_Group',
264 'type' => CRM_Utils_Type
::T_STRING
,
265 'title' => ts('Group Title'),
266 'description' => ts('Name of Group.'),
269 'size' => CRM_Utils_Type
::HUGE
,
270 'where' => 'civicrm_group.title',
271 'table_name' => 'civicrm_group',
273 'bao' => 'CRM_Contact_BAO_Group',
281 'name' => 'description',
282 'type' => CRM_Utils_Type
::T_TEXT
,
283 'title' => ts('Group Description'),
284 'description' => ts('Optional verbose description of the group.'),
287 'where' => 'civicrm_group.description',
288 'table_name' => 'civicrm_group',
290 'bao' => 'CRM_Contact_BAO_Group',
293 'type' => 'TextArea',
299 'type' => CRM_Utils_Type
::T_STRING
,
300 'title' => ts('Group Source'),
301 'description' => ts('Module or process which created this group.'),
303 'size' => CRM_Utils_Type
::BIG
,
304 'where' => 'civicrm_group.source',
305 'table_name' => 'civicrm_group',
307 'bao' => 'CRM_Contact_BAO_Group',
311 'saved_search_id' => [
312 'name' => 'saved_search_id',
313 'type' => CRM_Utils_Type
::T_INT
,
314 'title' => ts('Saved Search ID'),
315 'description' => ts('FK to saved search table.'),
316 'where' => 'civicrm_group.saved_search_id',
317 'table_name' => 'civicrm_group',
319 'bao' => 'CRM_Contact_BAO_Group',
321 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
325 'name' => 'is_active',
326 'type' => CRM_Utils_Type
::T_BOOLEAN
,
327 'title' => ts('Group Enabled'),
328 'description' => ts('Is this entry active?'),
329 'where' => 'civicrm_group.is_active',
330 'table_name' => 'civicrm_group',
332 'bao' => 'CRM_Contact_BAO_Group',
337 'name' => 'visibility',
338 'type' => CRM_Utils_Type
::T_STRING
,
339 'title' => ts('Group Visibility Setting'),
340 'description' => ts('In what context(s) is this field visible.'),
342 'size' => CRM_Utils_Type
::MEDIUM
,
343 'where' => 'civicrm_group.visibility',
344 'default' => 'User and User Admin Only',
345 'table_name' => 'civicrm_group',
347 'bao' => 'CRM_Contact_BAO_Group',
352 'pseudoconstant' => [
353 'callback' => 'CRM_Core_SelectValues::groupVisibility',
358 'name' => 'where_clause',
359 'type' => CRM_Utils_Type
::T_TEXT
,
360 'title' => ts('Group Where Clause'),
361 'description' => ts('the sql where clause if a saved search acl'),
362 'where' => 'civicrm_group.where_clause',
363 'table_name' => 'civicrm_group',
365 'bao' => 'CRM_Contact_BAO_Group',
370 'name' => 'select_tables',
371 'type' => CRM_Utils_Type
::T_TEXT
,
372 'title' => ts('Tables For Select Clause'),
373 'description' => ts('the tables to be included in a select data'),
374 'where' => 'civicrm_group.select_tables',
375 'table_name' => 'civicrm_group',
377 'bao' => 'CRM_Contact_BAO_Group',
379 'serialize' => self
::SERIALIZE_PHP
,
383 'name' => 'where_tables',
384 'type' => CRM_Utils_Type
::T_TEXT
,
385 'title' => ts('Tables For Where Clause'),
386 'description' => ts('the tables to be included in the count statement'),
387 'where' => 'civicrm_group.where_tables',
388 'table_name' => 'civicrm_group',
390 'bao' => 'CRM_Contact_BAO_Group',
392 'serialize' => self
::SERIALIZE_PHP
,
396 'name' => 'group_type',
397 'type' => CRM_Utils_Type
::T_STRING
,
398 'title' => ts('Group Type'),
399 'description' => ts('FK to group type'),
401 'size' => CRM_Utils_Type
::HUGE
,
402 'where' => 'civicrm_group.group_type',
403 'table_name' => 'civicrm_group',
405 'bao' => 'CRM_Contact_BAO_Group',
407 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
408 'pseudoconstant' => [
409 'optionGroupName' => 'group_type',
410 'optionEditPath' => 'civicrm/admin/options/group_type',
415 'name' => 'cache_date',
416 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
417 'title' => ts('Group Cache Date'),
418 'description' => ts('Date when we created the cache for a smart group'),
420 'where' => 'civicrm_group.cache_date',
421 'table_name' => 'civicrm_group',
423 'bao' => 'CRM_Contact_BAO_Group',
428 'name' => 'refresh_date',
429 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
430 'title' => ts('Next Group Refresh Time'),
431 'description' => ts('Date and time when we need to refresh the cache next.'),
433 'where' => 'civicrm_group.refresh_date',
434 'table_name' => 'civicrm_group',
436 'bao' => 'CRM_Contact_BAO_Group',
442 'type' => CRM_Utils_Type
::T_TEXT
,
443 'title' => ts('Group Parents'),
444 'description' => ts('IDs of the parent(s)'),
445 'where' => 'civicrm_group.parents',
446 'table_name' => 'civicrm_group',
448 'bao' => 'CRM_Contact_BAO_Group',
450 'serialize' => self
::SERIALIZE_COMMA
,
451 'pseudoconstant' => [
452 'callback' => 'CRM_Core_PseudoConstant::allGroup',
457 'name' => 'children',
458 'type' => CRM_Utils_Type
::T_TEXT
,
459 'title' => ts('Group Children'),
460 'description' => ts('IDs of the child(ren)'),
461 'where' => 'civicrm_group.children',
462 'table_name' => 'civicrm_group',
464 'bao' => 'CRM_Contact_BAO_Group',
469 'name' => 'is_hidden',
470 'type' => CRM_Utils_Type
::T_BOOLEAN
,
471 'title' => ts('Group is Hidden'),
472 'description' => ts('Is this group hidden?'),
473 'where' => 'civicrm_group.is_hidden',
475 'table_name' => 'civicrm_group',
477 'bao' => 'CRM_Contact_BAO_Group',
482 'name' => 'is_reserved',
483 'type' => CRM_Utils_Type
::T_BOOLEAN
,
484 'title' => ts('Group is Reserved'),
485 'where' => 'civicrm_group.is_reserved',
487 'table_name' => 'civicrm_group',
489 'bao' => 'CRM_Contact_BAO_Group',
494 'name' => 'created_id',
495 'type' => CRM_Utils_Type
::T_INT
,
496 'title' => ts('Group Created By'),
497 'description' => ts('FK to contact table.'),
498 'where' => 'civicrm_group.created_id',
499 'table_name' => 'civicrm_group',
501 'bao' => 'CRM_Contact_BAO_Group',
503 'FKClassName' => 'CRM_Contact_DAO_Contact',
507 'name' => 'modified_id',
508 'type' => CRM_Utils_Type
::T_INT
,
509 'title' => ts('Group Modified By'),
510 'description' => ts('FK to contact table.'),
511 'where' => 'civicrm_group.modified_id',
512 'table_name' => 'civicrm_group',
514 'bao' => 'CRM_Contact_BAO_Group',
516 'FKClassName' => 'CRM_Contact_DAO_Contact',
519 'frontend_title' => [
520 'name' => 'frontend_title',
521 'type' => CRM_Utils_Type
::T_STRING
,
522 'title' => ts('Public Group Title'),
523 'description' => ts('Alternative public title for this Group.'),
525 'size' => CRM_Utils_Type
::HUGE
,
526 'where' => 'civicrm_group.frontend_title',
528 'table_name' => 'civicrm_group',
530 'bao' => 'CRM_Contact_BAO_Group',
537 'frontend_description' => [
538 'name' => 'frontend_description',
539 'type' => CRM_Utils_Type
::T_TEXT
,
540 'title' => ts('Public Group Description'),
541 'description' => ts('Alternative public description of the group.'),
544 'where' => 'civicrm_group.frontend_description',
546 'table_name' => 'civicrm_group',
548 'bao' => 'CRM_Contact_BAO_Group',
551 'type' => 'TextArea',
556 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
558 return Civi
::$statics[__CLASS__
]['fields'];
562 * Return a mapping from field-name to the corresponding key (as used in fields()).
565 * Array(string $name => string $uniqueName).
567 public static function &fieldKeys() {
568 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
569 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
571 return Civi
::$statics[__CLASS__
]['fieldKeys'];
575 * Returns the names of this table
579 public static function getTableName() {
580 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
584 * Returns if this table needs to be logged
588 public function getLog() {
593 * Returns the list of fields that can be imported
595 * @param bool $prefix
599 public static function &import($prefix = FALSE) {
600 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
605 * Returns the list of fields that can be exported
607 * @param bool $prefix
611 public static function &export($prefix = FALSE) {
612 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
617 * Returns the list of indices
619 * @param bool $localize
623 public static function indices($localize = TRUE) {
625 'index_group_type' => [
626 'name' => 'index_group_type',
630 'localizable' => FALSE,
631 'sig' => 'civicrm_group::0::group_type',
634 'name' => 'UI_title',
638 'localizable' => TRUE,
640 'sig' => 'civicrm_group::1::title',
647 'localizable' => FALSE,
649 'sig' => 'civicrm_group::1::name',
652 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;