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:29b3646b12fccdf8a2d561dc483c8980)
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',
270 'type' => CRM_Utils_Type
::T_STRING
,
271 'title' => ts('Group Name'),
272 'description' => ts('Internal name of Group.'),
274 'size' => CRM_Utils_Type
::BIG
,
275 'where' => 'civicrm_group.name',
276 'table_name' => 'civicrm_group',
278 'bao' => 'CRM_Contact_BAO_Group',
284 'type' => CRM_Utils_Type
::T_STRING
,
285 'title' => ts('Group Title'),
286 'description' => ts('Name of Group.'),
288 'size' => CRM_Utils_Type
::HUGE
,
289 'where' => 'civicrm_group.title',
290 'table_name' => 'civicrm_group',
292 'bao' => 'CRM_Contact_BAO_Group',
300 'name' => 'description',
301 'type' => CRM_Utils_Type
::T_TEXT
,
302 'title' => ts('Group Description'),
303 'description' => ts('Optional verbose description of the group.'),
306 'where' => 'civicrm_group.description',
307 'table_name' => 'civicrm_group',
309 'bao' => 'CRM_Contact_BAO_Group',
312 'type' => 'TextArea',
318 'type' => CRM_Utils_Type
::T_STRING
,
319 'title' => ts('Group Source'),
320 'description' => ts('Module or process which created this group.'),
322 'size' => CRM_Utils_Type
::BIG
,
323 'where' => 'civicrm_group.source',
324 'table_name' => 'civicrm_group',
326 'bao' => 'CRM_Contact_BAO_Group',
330 'saved_search_id' => [
331 'name' => 'saved_search_id',
332 'type' => CRM_Utils_Type
::T_INT
,
333 'title' => ts('Saved Search ID'),
334 'description' => ts('FK to saved search table.'),
335 'where' => 'civicrm_group.saved_search_id',
336 'table_name' => 'civicrm_group',
338 'bao' => 'CRM_Contact_BAO_Group',
340 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
342 'label' => ts("Saved Search"),
347 'name' => 'is_active',
348 'type' => CRM_Utils_Type
::T_BOOLEAN
,
349 'title' => ts('Group Enabled'),
350 'description' => ts('Is this entry active?'),
351 'where' => 'civicrm_group.is_active',
352 'table_name' => 'civicrm_group',
354 'bao' => 'CRM_Contact_BAO_Group',
359 'name' => 'visibility',
360 'type' => CRM_Utils_Type
::T_STRING
,
361 'title' => ts('Group Visibility Setting'),
362 'description' => ts('In what context(s) is this field visible.'),
364 'size' => CRM_Utils_Type
::MEDIUM
,
365 'where' => 'civicrm_group.visibility',
366 'default' => 'User and User Admin Only',
367 'table_name' => 'civicrm_group',
369 'bao' => 'CRM_Contact_BAO_Group',
374 'pseudoconstant' => [
375 'callback' => 'CRM_Core_SelectValues::groupVisibility',
380 'name' => 'where_clause',
381 'type' => CRM_Utils_Type
::T_TEXT
,
382 'title' => ts('Group Where Clause'),
383 'description' => ts('the sql where clause if a saved search acl'),
384 'where' => 'civicrm_group.where_clause',
385 'table_name' => 'civicrm_group',
387 'bao' => 'CRM_Contact_BAO_Group',
393 'name' => 'select_tables',
394 'type' => CRM_Utils_Type
::T_TEXT
,
395 'title' => ts('Tables For Select Clause'),
396 'description' => ts('the tables to be included in a select data'),
397 'where' => 'civicrm_group.select_tables',
398 'table_name' => 'civicrm_group',
400 'bao' => 'CRM_Contact_BAO_Group',
402 'serialize' => self
::SERIALIZE_PHP
,
407 'name' => 'where_tables',
408 'type' => CRM_Utils_Type
::T_TEXT
,
409 'title' => ts('Tables For Where Clause'),
410 'description' => ts('the tables to be included in the count statement'),
411 'where' => 'civicrm_group.where_tables',
412 'table_name' => 'civicrm_group',
414 'bao' => 'CRM_Contact_BAO_Group',
416 'serialize' => self
::SERIALIZE_PHP
,
421 'name' => 'group_type',
422 'type' => CRM_Utils_Type
::T_STRING
,
423 'title' => ts('Group Type'),
424 'description' => ts('FK to group type'),
426 'size' => CRM_Utils_Type
::HUGE
,
427 'where' => 'civicrm_group.group_type',
428 'table_name' => 'civicrm_group',
430 'bao' => 'CRM_Contact_BAO_Group',
432 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
433 'pseudoconstant' => [
434 'optionGroupName' => 'group_type',
435 'optionEditPath' => 'civicrm/admin/options/group_type',
440 'name' => 'cache_date',
441 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
442 'title' => ts('Group Cache Date'),
443 'description' => ts('Date when we created the cache for a smart group'),
445 'where' => 'civicrm_group.cache_date',
446 'table_name' => 'civicrm_group',
448 'bao' => 'CRM_Contact_BAO_Group',
454 'name' => 'refresh_date',
455 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
456 'title' => ts('Next Group Refresh Time'),
457 'description' => ts('Date and time when we need to refresh the cache next.'),
459 'where' => 'civicrm_group.refresh_date',
460 'table_name' => 'civicrm_group',
462 'bao' => 'CRM_Contact_BAO_Group',
469 'type' => CRM_Utils_Type
::T_TEXT
,
470 'title' => ts('Group Parents'),
471 'description' => ts('IDs of the parent(s)'),
472 'where' => 'civicrm_group.parents',
473 'table_name' => 'civicrm_group',
475 'bao' => 'CRM_Contact_BAO_Group',
477 'serialize' => self
::SERIALIZE_COMMA
,
478 'pseudoconstant' => [
479 'callback' => 'CRM_Core_PseudoConstant::allGroup',
484 'name' => 'children',
485 'type' => CRM_Utils_Type
::T_TEXT
,
486 'title' => ts('Group Children'),
487 'description' => ts('IDs of the child(ren)'),
488 'where' => 'civicrm_group.children',
489 'table_name' => 'civicrm_group',
491 'bao' => 'CRM_Contact_BAO_Group',
496 'name' => 'is_hidden',
497 'type' => CRM_Utils_Type
::T_BOOLEAN
,
498 'title' => ts('Group is Hidden'),
499 'description' => ts('Is this group hidden?'),
500 'where' => 'civicrm_group.is_hidden',
502 'table_name' => 'civicrm_group',
504 'bao' => 'CRM_Contact_BAO_Group',
509 'name' => 'is_reserved',
510 'type' => CRM_Utils_Type
::T_BOOLEAN
,
511 'title' => ts('Group is Reserved'),
512 'where' => 'civicrm_group.is_reserved',
514 'table_name' => 'civicrm_group',
516 'bao' => 'CRM_Contact_BAO_Group',
521 'name' => 'created_id',
522 'type' => CRM_Utils_Type
::T_INT
,
523 'title' => ts('Created By Contact ID'),
524 'description' => ts('FK to contact table.'),
525 'where' => 'civicrm_group.created_id',
526 'table_name' => 'civicrm_group',
528 'bao' => 'CRM_Contact_BAO_Group',
530 'FKClassName' => 'CRM_Contact_DAO_Contact',
532 'label' => ts("Created By"),
537 'name' => 'modified_id',
538 'type' => CRM_Utils_Type
::T_INT
,
539 'title' => ts('Modified By Contact ID'),
540 'description' => ts('FK to contact table.'),
541 'where' => 'civicrm_group.modified_id',
542 'table_name' => 'civicrm_group',
544 'bao' => 'CRM_Contact_BAO_Group',
546 'FKClassName' => 'CRM_Contact_DAO_Contact',
548 'label' => ts("Modified By"),
553 'frontend_title' => [
554 'name' => 'frontend_title',
555 'type' => CRM_Utils_Type
::T_STRING
,
556 'title' => ts('Public Group Title'),
557 'description' => ts('Alternative public title for this Group.'),
559 'size' => CRM_Utils_Type
::HUGE
,
560 'where' => 'civicrm_group.frontend_title',
562 'table_name' => 'civicrm_group',
564 'bao' => 'CRM_Contact_BAO_Group',
571 'frontend_description' => [
572 'name' => 'frontend_description',
573 'type' => CRM_Utils_Type
::T_TEXT
,
574 'title' => ts('Public Group Description'),
575 'description' => ts('Alternative public description of the group.'),
578 'where' => 'civicrm_group.frontend_description',
580 'table_name' => 'civicrm_group',
582 'bao' => 'CRM_Contact_BAO_Group',
585 'type' => 'TextArea',
590 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
592 return Civi
::$statics[__CLASS__
]['fields'];
596 * Return a mapping from field-name to the corresponding key (as used in fields()).
599 * Array(string $name => string $uniqueName).
601 public static function &fieldKeys() {
602 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
603 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
605 return Civi
::$statics[__CLASS__
]['fieldKeys'];
609 * Returns the names of this table
613 public static function getTableName() {
614 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
618 * Returns if this table needs to be logged
622 public function getLog() {
627 * Returns the list of fields that can be imported
629 * @param bool $prefix
633 public static function &import($prefix = FALSE) {
634 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
639 * Returns the list of fields that can be exported
641 * @param bool $prefix
645 public static function &export($prefix = FALSE) {
646 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
651 * Returns the list of indices
653 * @param bool $localize
657 public static function indices($localize = TRUE) {
660 'name' => 'UI_cache_date',
664 'localizable' => FALSE,
665 'sig' => 'civicrm_group::0::cache_date',
667 'index_group_type' => [
668 'name' => 'index_group_type',
672 'localizable' => FALSE,
673 'sig' => 'civicrm_group::0::group_type',
676 'name' => 'UI_title',
680 'localizable' => TRUE,
682 'sig' => 'civicrm_group::1::title',
689 'localizable' => FALSE,
691 'sig' => 'civicrm_group::1::name',
694 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;