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:8ac9c70cfe18b05911b2c6d85e8c522d)
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',
64 * Internal name of Group.
78 * Optional verbose description of the group.
85 * Module or process which created this group.
92 * FK to saved search table.
96 public $saved_search_id;
99 * Is this entry active?
106 * In what context(s) is this field visible.
113 * the sql where clause if a saved search acl
117 public $where_clause;
120 * the tables to be included in a select data
124 public $select_tables;
127 * the tables to be included in the count statement
131 public $where_tables;
141 * Date when we created the cache for a smart group
148 * Date and time when we need to refresh the cache next.
152 public $refresh_date;
155 * IDs of the parent(s)
162 * IDs of the child(ren)
169 * Is this group hidden?
181 * FK to contact table.
188 * FK to contact table.
195 * Alternative public title for this Group.
199 public $frontend_title;
202 * Alternative public description of the group.
206 public $frontend_description;
211 public function __construct() {
212 $this->__table
= 'civicrm_group';
213 parent
::__construct();
217 * Returns localized title of this entity.
219 * @param bool $plural
220 * Whether to return the plural version of the title.
222 public static function getEntityTitle($plural = FALSE) {
223 return $plural ?
ts('Groups') : ts('Group');
227 * Returns foreign keys and entity references.
230 * [CRM_Core_Reference_Interface]
232 public static function getReferenceColumns() {
233 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
234 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
235 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
236 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
237 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
238 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
240 return Civi
::$statics[__CLASS__
]['links'];
244 * Returns all the column names of this table
248 public static function &fields() {
249 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
250 Civi
::$statics[__CLASS__
]['fields'] = [
253 'type' => CRM_Utils_Type
::T_INT
,
254 'title' => ts('Group ID'),
255 'description' => ts('Group ID'),
257 'where' => 'civicrm_group.id',
258 'table_name' => 'civicrm_group',
260 'bao' => 'CRM_Contact_BAO_Group',
269 'type' => CRM_Utils_Type
::T_STRING
,
270 'title' => ts('Group Name'),
271 'description' => ts('Internal name of Group.'),
273 'size' => CRM_Utils_Type
::BIG
,
274 'where' => 'civicrm_group.name',
275 'table_name' => 'civicrm_group',
277 'bao' => 'CRM_Contact_BAO_Group',
283 'type' => CRM_Utils_Type
::T_STRING
,
284 'title' => ts('Group Title'),
285 'description' => ts('Name of Group.'),
287 'size' => CRM_Utils_Type
::HUGE
,
288 'where' => 'civicrm_group.title',
289 'table_name' => 'civicrm_group',
291 'bao' => 'CRM_Contact_BAO_Group',
299 'name' => 'description',
300 'type' => CRM_Utils_Type
::T_TEXT
,
301 'title' => ts('Group Description'),
302 'description' => ts('Optional verbose description of the group.'),
305 'where' => 'civicrm_group.description',
306 'table_name' => 'civicrm_group',
308 'bao' => 'CRM_Contact_BAO_Group',
311 'type' => 'TextArea',
317 'type' => CRM_Utils_Type
::T_STRING
,
318 'title' => ts('Group Source'),
319 'description' => ts('Module or process which created this group.'),
321 'size' => CRM_Utils_Type
::BIG
,
322 'where' => 'civicrm_group.source',
323 'table_name' => 'civicrm_group',
325 'bao' => 'CRM_Contact_BAO_Group',
329 'saved_search_id' => [
330 'name' => 'saved_search_id',
331 'type' => CRM_Utils_Type
::T_INT
,
332 'title' => ts('Saved Search ID'),
333 'description' => ts('FK to saved search table.'),
334 'where' => 'civicrm_group.saved_search_id',
335 'table_name' => 'civicrm_group',
337 'bao' => 'CRM_Contact_BAO_Group',
339 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
341 'label' => ts("Saved Search"),
346 'name' => 'is_active',
347 'type' => CRM_Utils_Type
::T_BOOLEAN
,
348 'title' => ts('Group Enabled'),
349 'description' => ts('Is this entry active?'),
350 'where' => 'civicrm_group.is_active',
351 'table_name' => 'civicrm_group',
353 'bao' => 'CRM_Contact_BAO_Group',
358 'name' => 'visibility',
359 'type' => CRM_Utils_Type
::T_STRING
,
360 'title' => ts('Group Visibility Setting'),
361 'description' => ts('In what context(s) is this field visible.'),
363 'size' => CRM_Utils_Type
::MEDIUM
,
364 'where' => 'civicrm_group.visibility',
365 'default' => 'User and User Admin Only',
366 'table_name' => 'civicrm_group',
368 'bao' => 'CRM_Contact_BAO_Group',
373 'pseudoconstant' => [
374 'callback' => 'CRM_Core_SelectValues::groupVisibility',
379 'name' => 'where_clause',
380 'type' => CRM_Utils_Type
::T_TEXT
,
381 'title' => ts('Group Where Clause'),
382 'description' => ts('the sql where clause if a saved search acl'),
383 'where' => 'civicrm_group.where_clause',
384 'table_name' => 'civicrm_group',
386 'bao' => 'CRM_Contact_BAO_Group',
391 'name' => 'select_tables',
392 'type' => CRM_Utils_Type
::T_TEXT
,
393 'title' => ts('Tables For Select Clause'),
394 'description' => ts('the tables to be included in a select data'),
395 'where' => 'civicrm_group.select_tables',
396 'table_name' => 'civicrm_group',
398 'bao' => 'CRM_Contact_BAO_Group',
400 'serialize' => self
::SERIALIZE_PHP
,
404 'name' => 'where_tables',
405 'type' => CRM_Utils_Type
::T_TEXT
,
406 'title' => ts('Tables For Where Clause'),
407 'description' => ts('the tables to be included in the count statement'),
408 'where' => 'civicrm_group.where_tables',
409 'table_name' => 'civicrm_group',
411 'bao' => 'CRM_Contact_BAO_Group',
413 'serialize' => self
::SERIALIZE_PHP
,
417 'name' => 'group_type',
418 'type' => CRM_Utils_Type
::T_STRING
,
419 'title' => ts('Group Type'),
420 'description' => ts('FK to group type'),
422 'size' => CRM_Utils_Type
::HUGE
,
423 'where' => 'civicrm_group.group_type',
424 'table_name' => 'civicrm_group',
426 'bao' => 'CRM_Contact_BAO_Group',
428 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
429 'pseudoconstant' => [
430 'optionGroupName' => 'group_type',
431 'optionEditPath' => 'civicrm/admin/options/group_type',
436 'name' => 'cache_date',
437 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
438 'title' => ts('Group Cache Date'),
439 'description' => ts('Date when we created the cache for a smart group'),
441 'where' => 'civicrm_group.cache_date',
442 'table_name' => 'civicrm_group',
444 'bao' => 'CRM_Contact_BAO_Group',
449 'name' => 'refresh_date',
450 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
451 'title' => ts('Next Group Refresh Time'),
452 'description' => ts('Date and time when we need to refresh the cache next.'),
454 'where' => 'civicrm_group.refresh_date',
455 'table_name' => 'civicrm_group',
457 'bao' => 'CRM_Contact_BAO_Group',
463 'type' => CRM_Utils_Type
::T_TEXT
,
464 'title' => ts('Group Parents'),
465 'description' => ts('IDs of the parent(s)'),
466 'where' => 'civicrm_group.parents',
467 'table_name' => 'civicrm_group',
469 'bao' => 'CRM_Contact_BAO_Group',
471 'serialize' => self
::SERIALIZE_COMMA
,
472 'pseudoconstant' => [
473 'callback' => 'CRM_Core_PseudoConstant::allGroup',
478 'name' => 'children',
479 'type' => CRM_Utils_Type
::T_TEXT
,
480 'title' => ts('Group Children'),
481 'description' => ts('IDs of the child(ren)'),
482 'where' => 'civicrm_group.children',
483 'table_name' => 'civicrm_group',
485 'bao' => 'CRM_Contact_BAO_Group',
490 'name' => 'is_hidden',
491 'type' => CRM_Utils_Type
::T_BOOLEAN
,
492 'title' => ts('Group is Hidden'),
493 'description' => ts('Is this group hidden?'),
494 'where' => 'civicrm_group.is_hidden',
496 'table_name' => 'civicrm_group',
498 'bao' => 'CRM_Contact_BAO_Group',
503 'name' => 'is_reserved',
504 'type' => CRM_Utils_Type
::T_BOOLEAN
,
505 'title' => ts('Group is Reserved'),
506 'where' => 'civicrm_group.is_reserved',
508 'table_name' => 'civicrm_group',
510 'bao' => 'CRM_Contact_BAO_Group',
515 'name' => 'created_id',
516 'type' => CRM_Utils_Type
::T_INT
,
517 'title' => ts('Created By Contact ID'),
518 'description' => ts('FK to contact table.'),
519 'where' => 'civicrm_group.created_id',
520 'table_name' => 'civicrm_group',
522 'bao' => 'CRM_Contact_BAO_Group',
524 'FKClassName' => 'CRM_Contact_DAO_Contact',
526 'label' => ts("Created By"),
531 'name' => 'modified_id',
532 'type' => CRM_Utils_Type
::T_INT
,
533 'title' => ts('Modified By Contact ID'),
534 'description' => ts('FK to contact table.'),
535 'where' => 'civicrm_group.modified_id',
536 'table_name' => 'civicrm_group',
538 'bao' => 'CRM_Contact_BAO_Group',
540 'FKClassName' => 'CRM_Contact_DAO_Contact',
542 'label' => ts("Modified By"),
546 'frontend_title' => [
547 'name' => 'frontend_title',
548 'type' => CRM_Utils_Type
::T_STRING
,
549 'title' => ts('Public Group Title'),
550 'description' => ts('Alternative public title for this Group.'),
552 'size' => CRM_Utils_Type
::HUGE
,
553 'where' => 'civicrm_group.frontend_title',
555 'table_name' => 'civicrm_group',
557 'bao' => 'CRM_Contact_BAO_Group',
564 'frontend_description' => [
565 'name' => 'frontend_description',
566 'type' => CRM_Utils_Type
::T_TEXT
,
567 'title' => ts('Public Group Description'),
568 'description' => ts('Alternative public description of the group.'),
571 'where' => 'civicrm_group.frontend_description',
573 'table_name' => 'civicrm_group',
575 'bao' => 'CRM_Contact_BAO_Group',
578 'type' => 'TextArea',
583 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
585 return Civi
::$statics[__CLASS__
]['fields'];
589 * Return a mapping from field-name to the corresponding key (as used in fields()).
592 * Array(string $name => string $uniqueName).
594 public static function &fieldKeys() {
595 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
596 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
598 return Civi
::$statics[__CLASS__
]['fieldKeys'];
602 * Returns the names of this table
606 public static function getTableName() {
607 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
611 * Returns if this table needs to be logged
615 public function getLog() {
620 * Returns the list of fields that can be imported
622 * @param bool $prefix
626 public static function &import($prefix = FALSE) {
627 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
632 * Returns the list of fields that can be exported
634 * @param bool $prefix
638 public static function &export($prefix = FALSE) {
639 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
644 * Returns the list of indices
646 * @param bool $localize
650 public static function indices($localize = TRUE) {
653 'name' => 'UI_cache_date',
657 'localizable' => FALSE,
658 'sig' => 'civicrm_group::0::cache_date',
660 'index_group_type' => [
661 'name' => 'index_group_type',
665 'localizable' => FALSE,
666 'sig' => 'civicrm_group::0::group_type',
669 'name' => 'UI_title',
673 'localizable' => TRUE,
675 'sig' => 'civicrm_group::1::title',
682 'localizable' => FALSE,
684 'sig' => 'civicrm_group::1::name',
687 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;