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:8b5d08ec2b844a6b9167fa80a590a58c)
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 * Field to show when displaying a record.
38 public static $_labelField = 'title';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
48 * Paths for accessing this entity in the UI.
52 protected static $_paths = [
53 'add' => 'civicrm/group/add?reset=1',
54 'view' => 'civicrm/group/search?force=1&context=smog&gid=[id]&component_mode=1',
55 'update' => 'civicrm/group?reset=1&action=update&id=[id]',
56 'delete' => 'civicrm/group?reset=1&action=delete&id=[id]',
62 * @var int|string|null
63 * (SQL type: int unsigned)
64 * Note that values will be retrieved from the database as a string.
69 * Internal name of Group.
72 * (SQL type: varchar(64))
73 * Note that values will be retrieved from the database as a string.
81 * (SQL type: varchar(255))
82 * Note that values will be retrieved from the database as a string.
87 * Optional verbose description of the group.
91 * Note that values will be retrieved from the database as a string.
96 * Module or process which created this group.
99 * (SQL type: varchar(64))
100 * Note that values will be retrieved from the database as a string.
105 * FK to saved search table.
107 * @var int|string|null
108 * (SQL type: int unsigned)
109 * Note that values will be retrieved from the database as a string.
111 public $saved_search_id;
114 * Is this entry active?
117 * (SQL type: tinyint)
118 * Note that values will be retrieved from the database as a string.
123 * In what context(s) is this field visible.
126 * (SQL type: varchar(24))
127 * Note that values will be retrieved from the database as a string.
132 * the sql where clause if a saved search acl
136 * Note that values will be retrieved from the database as a string.
138 public $where_clause;
141 * the tables to be included in a select data
145 * Note that values will be retrieved from the database as a string.
147 public $select_tables;
150 * the tables to be included in the count statement
154 * Note that values will be retrieved from the database as a string.
156 public $where_tables;
162 * (SQL type: varchar(128))
163 * Note that values will be retrieved from the database as a string.
168 * Date when we created the cache for a smart group
171 * (SQL type: timestamp)
172 * Note that values will be retrieved from the database as a string.
177 * Date and time when we need to refresh the cache next.
180 * (SQL type: timestamp)
181 * Note that values will be retrieved from the database as a string.
183 public $refresh_date;
186 * IDs of the parent(s)
190 * Note that values will be retrieved from the database as a string.
195 * IDs of the child(ren)
199 * Note that values will be retrieved from the database as a string.
204 * Is this group hidden?
207 * (SQL type: tinyint)
208 * Note that values will be retrieved from the database as a string.
214 * (SQL type: tinyint)
215 * Note that values will be retrieved from the database as a string.
220 * FK to contact table.
222 * @var int|string|null
223 * (SQL type: int unsigned)
224 * Note that values will be retrieved from the database as a string.
229 * FK to contact table.
231 * @var int|string|null
232 * (SQL type: int unsigned)
233 * Note that values will be retrieved from the database as a string.
238 * Alternative public title for this Group.
241 * (SQL type: varchar(255))
242 * Note that values will be retrieved from the database as a string.
244 public $frontend_title;
247 * Alternative public description of the group.
251 * Note that values will be retrieved from the database as a string.
253 public $frontend_description;
258 public function __construct() {
259 $this->__table
= 'civicrm_group';
260 parent
::__construct();
264 * Returns localized title of this entity.
266 * @param bool $plural
267 * Whether to return the plural version of the title.
269 public static function getEntityTitle($plural = FALSE) {
270 return $plural ?
ts('Groups') : ts('Group');
274 * Returns foreign keys and entity references.
277 * [CRM_Core_Reference_Interface]
279 public static function getReferenceColumns() {
280 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
281 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
282 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
283 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
284 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
285 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
287 return Civi
::$statics[__CLASS__
]['links'];
291 * Returns all the column names of this table
295 public static function &fields() {
296 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
297 Civi
::$statics[__CLASS__
]['fields'] = [
300 'type' => CRM_Utils_Type
::T_INT
,
301 'title' => ts('Group ID'),
302 'description' => ts('Group ID'),
304 'where' => 'civicrm_group.id',
305 'table_name' => 'civicrm_group',
307 'bao' => 'CRM_Contact_BAO_Group',
317 'type' => CRM_Utils_Type
::T_STRING
,
318 'title' => ts('Group Name'),
319 'description' => ts('Internal name of Group.'),
321 'size' => CRM_Utils_Type
::BIG
,
322 'where' => 'civicrm_group.name',
323 'table_name' => 'civicrm_group',
325 'bao' => 'CRM_Contact_BAO_Group',
331 'type' => CRM_Utils_Type
::T_STRING
,
332 'title' => ts('Group Title'),
333 'description' => ts('Name of Group.'),
335 'size' => CRM_Utils_Type
::HUGE
,
336 'where' => 'civicrm_group.title',
337 'table_name' => 'civicrm_group',
339 'bao' => 'CRM_Contact_BAO_Group',
347 'name' => 'description',
348 'type' => CRM_Utils_Type
::T_TEXT
,
349 'title' => ts('Group Description'),
350 'description' => ts('Optional verbose description of the group.'),
353 'where' => 'civicrm_group.description',
354 'table_name' => 'civicrm_group',
356 'bao' => 'CRM_Contact_BAO_Group',
359 'type' => 'TextArea',
365 'type' => CRM_Utils_Type
::T_STRING
,
366 'title' => ts('Group Source'),
367 'description' => ts('Module or process which created this group.'),
369 'size' => CRM_Utils_Type
::BIG
,
370 'where' => 'civicrm_group.source',
371 'table_name' => 'civicrm_group',
373 'bao' => 'CRM_Contact_BAO_Group',
377 'saved_search_id' => [
378 'name' => 'saved_search_id',
379 'type' => CRM_Utils_Type
::T_INT
,
380 'title' => ts('Saved Search ID'),
381 'description' => ts('FK to saved search table.'),
382 'where' => 'civicrm_group.saved_search_id',
383 'table_name' => 'civicrm_group',
385 'bao' => 'CRM_Contact_BAO_Group',
387 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
389 'label' => ts("Saved Search"),
394 'name' => 'is_active',
395 'type' => CRM_Utils_Type
::T_BOOLEAN
,
396 'title' => ts('Group Enabled'),
397 'description' => ts('Is this entry active?'),
399 'where' => 'civicrm_group.is_active',
401 'table_name' => 'civicrm_group',
403 'bao' => 'CRM_Contact_BAO_Group',
408 'name' => 'visibility',
409 'type' => CRM_Utils_Type
::T_STRING
,
410 'title' => ts('Group Visibility Setting'),
411 'description' => ts('In what context(s) is this field visible.'),
413 'size' => CRM_Utils_Type
::MEDIUM
,
414 'where' => 'civicrm_group.visibility',
415 'default' => 'User and User Admin Only',
416 'table_name' => 'civicrm_group',
418 'bao' => 'CRM_Contact_BAO_Group',
423 'pseudoconstant' => [
424 'callback' => 'CRM_Core_SelectValues::groupVisibility',
429 'name' => 'where_clause',
430 'type' => CRM_Utils_Type
::T_TEXT
,
431 'title' => ts('Group Where Clause'),
432 'description' => ts('the sql where clause if a saved search acl'),
433 'where' => 'civicrm_group.where_clause',
434 'table_name' => 'civicrm_group',
436 'bao' => 'CRM_Contact_BAO_Group',
442 'name' => 'select_tables',
443 'type' => CRM_Utils_Type
::T_TEXT
,
444 'title' => ts('Tables For Select Clause'),
445 'description' => ts('the tables to be included in a select data'),
446 'where' => 'civicrm_group.select_tables',
447 'table_name' => 'civicrm_group',
449 'bao' => 'CRM_Contact_BAO_Group',
451 'serialize' => self
::SERIALIZE_PHP
,
456 'name' => 'where_tables',
457 'type' => CRM_Utils_Type
::T_TEXT
,
458 'title' => ts('Tables For Where Clause'),
459 'description' => ts('the tables to be included in the count statement'),
460 'where' => 'civicrm_group.where_tables',
461 'table_name' => 'civicrm_group',
463 'bao' => 'CRM_Contact_BAO_Group',
465 'serialize' => self
::SERIALIZE_PHP
,
470 'name' => 'group_type',
471 'type' => CRM_Utils_Type
::T_STRING
,
472 'title' => ts('Group Type'),
473 'description' => ts('FK to group type'),
475 'size' => CRM_Utils_Type
::HUGE
,
476 'where' => 'civicrm_group.group_type',
477 'table_name' => 'civicrm_group',
479 'bao' => 'CRM_Contact_BAO_Group',
481 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
482 'pseudoconstant' => [
483 'optionGroupName' => 'group_type',
484 'optionEditPath' => 'civicrm/admin/options/group_type',
489 'name' => 'cache_date',
490 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
491 'title' => ts('Group Cache Date'),
492 'description' => ts('Date when we created the cache for a smart group'),
494 'where' => 'civicrm_group.cache_date',
495 'table_name' => 'civicrm_group',
497 'bao' => 'CRM_Contact_BAO_Group',
503 'name' => 'refresh_date',
504 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
505 'title' => ts('Next Group Refresh Time'),
506 'description' => ts('Date and time when we need to refresh the cache next.'),
508 'where' => 'civicrm_group.refresh_date',
509 'table_name' => 'civicrm_group',
511 'bao' => 'CRM_Contact_BAO_Group',
518 'type' => CRM_Utils_Type
::T_TEXT
,
519 'title' => ts('Group Parents'),
520 'description' => ts('IDs of the parent(s)'),
521 'where' => 'civicrm_group.parents',
522 'table_name' => 'civicrm_group',
524 'bao' => 'CRM_Contact_BAO_Group',
526 'serialize' => self
::SERIALIZE_COMMA
,
527 'pseudoconstant' => [
528 'callback' => 'CRM_Core_PseudoConstant::allGroup',
533 'name' => 'children',
534 'type' => CRM_Utils_Type
::T_TEXT
,
535 'title' => ts('Group Children'),
536 'description' => ts('IDs of the child(ren)'),
537 'where' => 'civicrm_group.children',
538 'table_name' => 'civicrm_group',
540 'bao' => 'CRM_Contact_BAO_Group',
545 'name' => 'is_hidden',
546 'type' => CRM_Utils_Type
::T_BOOLEAN
,
547 'title' => ts('Group is Hidden'),
548 'description' => ts('Is this group hidden?'),
550 'where' => 'civicrm_group.is_hidden',
552 'table_name' => 'civicrm_group',
554 'bao' => 'CRM_Contact_BAO_Group',
559 'name' => 'is_reserved',
560 'type' => CRM_Utils_Type
::T_BOOLEAN
,
561 'title' => ts('Group is Reserved'),
563 'where' => 'civicrm_group.is_reserved',
565 'table_name' => 'civicrm_group',
567 'bao' => 'CRM_Contact_BAO_Group',
572 'name' => 'created_id',
573 'type' => CRM_Utils_Type
::T_INT
,
574 'title' => ts('Created By Contact ID'),
575 'description' => ts('FK to contact table.'),
576 'where' => 'civicrm_group.created_id',
577 'table_name' => 'civicrm_group',
579 'bao' => 'CRM_Contact_BAO_Group',
581 'FKClassName' => 'CRM_Contact_DAO_Contact',
583 'label' => ts("Created By"),
588 'name' => 'modified_id',
589 'type' => CRM_Utils_Type
::T_INT
,
590 'title' => ts('Modified By Contact ID'),
591 'description' => ts('FK to contact table.'),
592 'where' => 'civicrm_group.modified_id',
593 'table_name' => 'civicrm_group',
595 'bao' => 'CRM_Contact_BAO_Group',
597 'FKClassName' => 'CRM_Contact_DAO_Contact',
599 'label' => ts("Modified By"),
604 'frontend_title' => [
605 'name' => 'frontend_title',
606 'type' => CRM_Utils_Type
::T_STRING
,
607 'title' => ts('Public Group Title'),
608 'description' => ts('Alternative public title for this Group.'),
610 'size' => CRM_Utils_Type
::HUGE
,
611 'where' => 'civicrm_group.frontend_title',
613 'table_name' => 'civicrm_group',
615 'bao' => 'CRM_Contact_BAO_Group',
622 'frontend_description' => [
623 'name' => 'frontend_description',
624 'type' => CRM_Utils_Type
::T_TEXT
,
625 'title' => ts('Public Group Description'),
626 'description' => ts('Alternative public description of the group.'),
629 'where' => 'civicrm_group.frontend_description',
631 'table_name' => 'civicrm_group',
633 'bao' => 'CRM_Contact_BAO_Group',
636 'type' => 'TextArea',
641 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
643 return Civi
::$statics[__CLASS__
]['fields'];
647 * Return a mapping from field-name to the corresponding key (as used in fields()).
650 * Array(string $name => string $uniqueName).
652 public static function &fieldKeys() {
653 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
654 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
656 return Civi
::$statics[__CLASS__
]['fieldKeys'];
660 * Returns the names of this table
664 public static function getTableName() {
665 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
669 * Returns if this table needs to be logged
673 public function getLog() {
678 * Returns the list of fields that can be imported
680 * @param bool $prefix
684 public static function &import($prefix = FALSE) {
685 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
690 * Returns the list of fields that can be exported
692 * @param bool $prefix
696 public static function &export($prefix = FALSE) {
697 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
702 * Returns the list of indices
704 * @param bool $localize
708 public static function indices($localize = TRUE) {
711 'name' => 'UI_cache_date',
715 'localizable' => FALSE,
716 'sig' => 'civicrm_group::0::cache_date',
718 'index_group_type' => [
719 'name' => 'index_group_type',
723 'localizable' => FALSE,
724 'sig' => 'civicrm_group::0::group_type',
727 'name' => 'UI_title',
731 'localizable' => TRUE,
733 'sig' => 'civicrm_group::1::title',
740 'localizable' => FALSE,
742 'sig' => 'civicrm_group::1::name',
745 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;