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:cab0c1d345870ec17420e9100fe2518f)
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.'),
268 'size' => CRM_Utils_Type
::HUGE
,
269 'where' => 'civicrm_group.title',
270 'table_name' => 'civicrm_group',
272 'bao' => 'CRM_Contact_BAO_Group',
280 'name' => 'description',
281 'type' => CRM_Utils_Type
::T_TEXT
,
282 'title' => ts('Group Description'),
283 'description' => ts('Optional verbose description of the group.'),
286 'where' => 'civicrm_group.description',
287 'table_name' => 'civicrm_group',
289 'bao' => 'CRM_Contact_BAO_Group',
292 'type' => 'TextArea',
298 'type' => CRM_Utils_Type
::T_STRING
,
299 'title' => ts('Group Source'),
300 'description' => ts('Module or process which created this group.'),
302 'size' => CRM_Utils_Type
::BIG
,
303 'where' => 'civicrm_group.source',
304 'table_name' => 'civicrm_group',
306 'bao' => 'CRM_Contact_BAO_Group',
310 'saved_search_id' => [
311 'name' => 'saved_search_id',
312 'type' => CRM_Utils_Type
::T_INT
,
313 'title' => ts('Saved Search ID'),
314 'description' => ts('FK to saved search table.'),
315 'where' => 'civicrm_group.saved_search_id',
316 'table_name' => 'civicrm_group',
318 'bao' => 'CRM_Contact_BAO_Group',
320 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
324 'name' => 'is_active',
325 'type' => CRM_Utils_Type
::T_BOOLEAN
,
326 'title' => ts('Group Enabled'),
327 'description' => ts('Is this entry active?'),
328 'where' => 'civicrm_group.is_active',
329 'table_name' => 'civicrm_group',
331 'bao' => 'CRM_Contact_BAO_Group',
336 'name' => 'visibility',
337 'type' => CRM_Utils_Type
::T_STRING
,
338 'title' => ts('Group Visibility Setting'),
339 'description' => ts('In what context(s) is this field visible.'),
341 'size' => CRM_Utils_Type
::MEDIUM
,
342 'where' => 'civicrm_group.visibility',
343 'default' => 'User and User Admin Only',
344 'table_name' => 'civicrm_group',
346 'bao' => 'CRM_Contact_BAO_Group',
351 'pseudoconstant' => [
352 'callback' => 'CRM_Core_SelectValues::groupVisibility',
357 'name' => 'where_clause',
358 'type' => CRM_Utils_Type
::T_TEXT
,
359 'title' => ts('Group Where Clause'),
360 'description' => ts('the sql where clause if a saved search acl'),
361 'where' => 'civicrm_group.where_clause',
362 'table_name' => 'civicrm_group',
364 'bao' => 'CRM_Contact_BAO_Group',
369 'name' => 'select_tables',
370 'type' => CRM_Utils_Type
::T_TEXT
,
371 'title' => ts('Tables For Select Clause'),
372 'description' => ts('the tables to be included in a select data'),
373 'where' => 'civicrm_group.select_tables',
374 'table_name' => 'civicrm_group',
376 'bao' => 'CRM_Contact_BAO_Group',
378 'serialize' => self
::SERIALIZE_PHP
,
382 'name' => 'where_tables',
383 'type' => CRM_Utils_Type
::T_TEXT
,
384 'title' => ts('Tables For Where Clause'),
385 'description' => ts('the tables to be included in the count statement'),
386 'where' => 'civicrm_group.where_tables',
387 'table_name' => 'civicrm_group',
389 'bao' => 'CRM_Contact_BAO_Group',
391 'serialize' => self
::SERIALIZE_PHP
,
395 'name' => 'group_type',
396 'type' => CRM_Utils_Type
::T_STRING
,
397 'title' => ts('Group Type'),
398 'description' => ts('FK to group type'),
400 'size' => CRM_Utils_Type
::HUGE
,
401 'where' => 'civicrm_group.group_type',
402 'table_name' => 'civicrm_group',
404 'bao' => 'CRM_Contact_BAO_Group',
406 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
407 'pseudoconstant' => [
408 'optionGroupName' => 'group_type',
409 'optionEditPath' => 'civicrm/admin/options/group_type',
414 'name' => 'cache_date',
415 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
416 'title' => ts('Group Cache Date'),
417 'description' => ts('Date when we created the cache for a smart group'),
419 'where' => 'civicrm_group.cache_date',
420 'table_name' => 'civicrm_group',
422 'bao' => 'CRM_Contact_BAO_Group',
427 'name' => 'refresh_date',
428 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
429 'title' => ts('Next Group Refresh Time'),
430 'description' => ts('Date and time when we need to refresh the cache next.'),
432 'where' => 'civicrm_group.refresh_date',
433 'table_name' => 'civicrm_group',
435 'bao' => 'CRM_Contact_BAO_Group',
441 'type' => CRM_Utils_Type
::T_TEXT
,
442 'title' => ts('Group Parents'),
443 'description' => ts('IDs of the parent(s)'),
444 'where' => 'civicrm_group.parents',
445 'table_name' => 'civicrm_group',
447 'bao' => 'CRM_Contact_BAO_Group',
449 'serialize' => self
::SERIALIZE_COMMA
,
450 'pseudoconstant' => [
451 'callback' => 'CRM_Core_PseudoConstant::allGroup',
456 'name' => 'children',
457 'type' => CRM_Utils_Type
::T_TEXT
,
458 'title' => ts('Group Children'),
459 'description' => ts('IDs of the child(ren)'),
460 'where' => 'civicrm_group.children',
461 'table_name' => 'civicrm_group',
463 'bao' => 'CRM_Contact_BAO_Group',
468 'name' => 'is_hidden',
469 'type' => CRM_Utils_Type
::T_BOOLEAN
,
470 'title' => ts('Group is Hidden'),
471 'description' => ts('Is this group hidden?'),
472 'where' => 'civicrm_group.is_hidden',
474 'table_name' => 'civicrm_group',
476 'bao' => 'CRM_Contact_BAO_Group',
481 'name' => 'is_reserved',
482 'type' => CRM_Utils_Type
::T_BOOLEAN
,
483 'title' => ts('Group is Reserved'),
484 'where' => 'civicrm_group.is_reserved',
486 'table_name' => 'civicrm_group',
488 'bao' => 'CRM_Contact_BAO_Group',
493 'name' => 'created_id',
494 'type' => CRM_Utils_Type
::T_INT
,
495 'title' => ts('Group Created By'),
496 'description' => ts('FK to contact table.'),
497 'where' => 'civicrm_group.created_id',
498 'table_name' => 'civicrm_group',
500 'bao' => 'CRM_Contact_BAO_Group',
502 'FKClassName' => 'CRM_Contact_DAO_Contact',
506 'name' => 'modified_id',
507 'type' => CRM_Utils_Type
::T_INT
,
508 'title' => ts('Group Modified By'),
509 'description' => ts('FK to contact table.'),
510 'where' => 'civicrm_group.modified_id',
511 'table_name' => 'civicrm_group',
513 'bao' => 'CRM_Contact_BAO_Group',
515 'FKClassName' => 'CRM_Contact_DAO_Contact',
518 'frontend_title' => [
519 'name' => 'frontend_title',
520 'type' => CRM_Utils_Type
::T_STRING
,
521 'title' => ts('Public Group Title'),
522 'description' => ts('Alternative public title for this Group.'),
524 'size' => CRM_Utils_Type
::HUGE
,
525 'where' => 'civicrm_group.frontend_title',
527 'table_name' => 'civicrm_group',
529 'bao' => 'CRM_Contact_BAO_Group',
536 'frontend_description' => [
537 'name' => 'frontend_description',
538 'type' => CRM_Utils_Type
::T_TEXT
,
539 'title' => ts('Public Group Description'),
540 'description' => ts('Alternative public description of the group.'),
543 'where' => 'civicrm_group.frontend_description',
545 'table_name' => 'civicrm_group',
547 'bao' => 'CRM_Contact_BAO_Group',
550 'type' => 'TextArea',
555 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
557 return Civi
::$statics[__CLASS__
]['fields'];
561 * Return a mapping from field-name to the corresponding key (as used in fields()).
564 * Array(string $name => string $uniqueName).
566 public static function &fieldKeys() {
567 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
568 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
570 return Civi
::$statics[__CLASS__
]['fieldKeys'];
574 * Returns the names of this table
578 public static function getTableName() {
579 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
583 * Returns if this table needs to be logged
587 public function getLog() {
592 * Returns the list of fields that can be imported
594 * @param bool $prefix
598 public static function &import($prefix = FALSE) {
599 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
604 * Returns the list of fields that can be exported
606 * @param bool $prefix
610 public static function &export($prefix = FALSE) {
611 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
616 * Returns the list of indices
618 * @param bool $localize
622 public static function indices($localize = TRUE) {
624 'index_group_type' => [
625 'name' => 'index_group_type',
629 'localizable' => FALSE,
630 'sig' => 'civicrm_group::0::group_type',
633 'name' => 'UI_title',
637 'localizable' => TRUE,
639 'sig' => 'civicrm_group::1::title',
646 'localizable' => FALSE,
648 'sig' => 'civicrm_group::1::name',
651 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;