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:abbdc0ad43c008e444512d444c537ebf)
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;
41 * Paths for accessing this entity in the UI.
45 protected static $_paths = [
46 'add' => 'civicrm/group/add?reset=1',
57 * Internal name of Group.
71 * Optional verbose description of the group.
78 * Module or process which created this group.
85 * FK to saved search table.
89 public $saved_search_id;
92 * Is this entry active?
99 * In what context(s) is this field visible.
106 * the sql where clause if a saved search acl
110 public $where_clause;
113 * the tables to be included in a select data
117 public $select_tables;
120 * the tables to be included in the count statement
124 public $where_tables;
134 * Date when we created the cache for a smart group
141 * Date and time when we need to refresh the cache next.
145 public $refresh_date;
148 * IDs of the parent(s)
155 * IDs of the child(ren)
162 * Is this group hidden?
174 * FK to contact table.
181 * FK to contact table.
188 * Alternative public title for this Group.
192 public $frontend_title;
195 * Alternative public description of the group.
199 public $frontend_description;
204 public function __construct() {
205 $this->__table
= 'civicrm_group';
206 parent
::__construct();
210 * Returns localized title of this entity.
212 * @param bool $plural
213 * Whether to return the plural version of the title.
215 public static function getEntityTitle($plural = FALSE) {
216 return $plural ?
ts('Groups') : ts('Group');
220 * Returns foreign keys and entity references.
223 * [CRM_Core_Reference_Interface]
225 public static function getReferenceColumns() {
226 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
227 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
228 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
229 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
230 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
231 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
233 return Civi
::$statics[__CLASS__
]['links'];
237 * Returns all the column names of this table
241 public static function &fields() {
242 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
243 Civi
::$statics[__CLASS__
]['fields'] = [
246 'type' => CRM_Utils_Type
::T_INT
,
247 'title' => ts('Group ID'),
248 'description' => ts('Group ID'),
250 'where' => 'civicrm_group.id',
251 'table_name' => 'civicrm_group',
253 'bao' => 'CRM_Contact_BAO_Group',
259 'type' => CRM_Utils_Type
::T_STRING
,
260 'title' => ts('Group Name'),
261 'description' => ts('Internal name of Group.'),
263 'size' => CRM_Utils_Type
::BIG
,
264 'where' => 'civicrm_group.name',
265 'table_name' => 'civicrm_group',
267 'bao' => 'CRM_Contact_BAO_Group',
273 'type' => CRM_Utils_Type
::T_STRING
,
274 'title' => ts('Group Title'),
275 'description' => ts('Name of Group.'),
277 'size' => CRM_Utils_Type
::HUGE
,
278 'where' => 'civicrm_group.title',
279 'table_name' => 'civicrm_group',
281 'bao' => 'CRM_Contact_BAO_Group',
289 'name' => 'description',
290 'type' => CRM_Utils_Type
::T_TEXT
,
291 'title' => ts('Group Description'),
292 'description' => ts('Optional verbose description of the group.'),
295 'where' => 'civicrm_group.description',
296 'table_name' => 'civicrm_group',
298 'bao' => 'CRM_Contact_BAO_Group',
301 'type' => 'TextArea',
307 'type' => CRM_Utils_Type
::T_STRING
,
308 'title' => ts('Group Source'),
309 'description' => ts('Module or process which created this group.'),
311 'size' => CRM_Utils_Type
::BIG
,
312 'where' => 'civicrm_group.source',
313 'table_name' => 'civicrm_group',
315 'bao' => 'CRM_Contact_BAO_Group',
319 'saved_search_id' => [
320 'name' => 'saved_search_id',
321 'type' => CRM_Utils_Type
::T_INT
,
322 'title' => ts('Saved Search ID'),
323 'description' => ts('FK to saved search table.'),
324 'where' => 'civicrm_group.saved_search_id',
325 'table_name' => 'civicrm_group',
327 'bao' => 'CRM_Contact_BAO_Group',
329 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
333 'name' => 'is_active',
334 'type' => CRM_Utils_Type
::T_BOOLEAN
,
335 'title' => ts('Group Enabled'),
336 'description' => ts('Is this entry active?'),
337 'where' => 'civicrm_group.is_active',
338 'table_name' => 'civicrm_group',
340 'bao' => 'CRM_Contact_BAO_Group',
345 'name' => 'visibility',
346 'type' => CRM_Utils_Type
::T_STRING
,
347 'title' => ts('Group Visibility Setting'),
348 'description' => ts('In what context(s) is this field visible.'),
350 'size' => CRM_Utils_Type
::MEDIUM
,
351 'where' => 'civicrm_group.visibility',
352 'default' => 'User and User Admin Only',
353 'table_name' => 'civicrm_group',
355 'bao' => 'CRM_Contact_BAO_Group',
360 'pseudoconstant' => [
361 'callback' => 'CRM_Core_SelectValues::groupVisibility',
366 'name' => 'where_clause',
367 'type' => CRM_Utils_Type
::T_TEXT
,
368 'title' => ts('Group Where Clause'),
369 'description' => ts('the sql where clause if a saved search acl'),
370 'where' => 'civicrm_group.where_clause',
371 'table_name' => 'civicrm_group',
373 'bao' => 'CRM_Contact_BAO_Group',
378 'name' => 'select_tables',
379 'type' => CRM_Utils_Type
::T_TEXT
,
380 'title' => ts('Tables For Select Clause'),
381 'description' => ts('the tables to be included in a select data'),
382 'where' => 'civicrm_group.select_tables',
383 'table_name' => 'civicrm_group',
385 'bao' => 'CRM_Contact_BAO_Group',
387 'serialize' => self
::SERIALIZE_PHP
,
391 'name' => 'where_tables',
392 'type' => CRM_Utils_Type
::T_TEXT
,
393 'title' => ts('Tables For Where Clause'),
394 'description' => ts('the tables to be included in the count statement'),
395 'where' => 'civicrm_group.where_tables',
396 'table_name' => 'civicrm_group',
398 'bao' => 'CRM_Contact_BAO_Group',
400 'serialize' => self
::SERIALIZE_PHP
,
404 'name' => 'group_type',
405 'type' => CRM_Utils_Type
::T_STRING
,
406 'title' => ts('Group Type'),
407 'description' => ts('FK to group type'),
409 'size' => CRM_Utils_Type
::HUGE
,
410 'where' => 'civicrm_group.group_type',
411 'table_name' => 'civicrm_group',
413 'bao' => 'CRM_Contact_BAO_Group',
415 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
416 'pseudoconstant' => [
417 'optionGroupName' => 'group_type',
418 'optionEditPath' => 'civicrm/admin/options/group_type',
423 'name' => 'cache_date',
424 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
425 'title' => ts('Group Cache Date'),
426 'description' => ts('Date when we created the cache for a smart group'),
428 'where' => 'civicrm_group.cache_date',
429 'table_name' => 'civicrm_group',
431 'bao' => 'CRM_Contact_BAO_Group',
436 'name' => 'refresh_date',
437 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
438 'title' => ts('Next Group Refresh Time'),
439 'description' => ts('Date and time when we need to refresh the cache next.'),
441 'where' => 'civicrm_group.refresh_date',
442 'table_name' => 'civicrm_group',
444 'bao' => 'CRM_Contact_BAO_Group',
450 'type' => CRM_Utils_Type
::T_TEXT
,
451 'title' => ts('Group Parents'),
452 'description' => ts('IDs of the parent(s)'),
453 'where' => 'civicrm_group.parents',
454 'table_name' => 'civicrm_group',
456 'bao' => 'CRM_Contact_BAO_Group',
458 'serialize' => self
::SERIALIZE_COMMA
,
459 'pseudoconstant' => [
460 'callback' => 'CRM_Core_PseudoConstant::allGroup',
465 'name' => 'children',
466 'type' => CRM_Utils_Type
::T_TEXT
,
467 'title' => ts('Group Children'),
468 'description' => ts('IDs of the child(ren)'),
469 'where' => 'civicrm_group.children',
470 'table_name' => 'civicrm_group',
472 'bao' => 'CRM_Contact_BAO_Group',
477 'name' => 'is_hidden',
478 'type' => CRM_Utils_Type
::T_BOOLEAN
,
479 'title' => ts('Group is Hidden'),
480 'description' => ts('Is this group hidden?'),
481 'where' => 'civicrm_group.is_hidden',
483 'table_name' => 'civicrm_group',
485 'bao' => 'CRM_Contact_BAO_Group',
490 'name' => 'is_reserved',
491 'type' => CRM_Utils_Type
::T_BOOLEAN
,
492 'title' => ts('Group is Reserved'),
493 'where' => 'civicrm_group.is_reserved',
495 'table_name' => 'civicrm_group',
497 'bao' => 'CRM_Contact_BAO_Group',
502 'name' => 'created_id',
503 'type' => CRM_Utils_Type
::T_INT
,
504 'title' => ts('Group Created By'),
505 'description' => ts('FK to contact table.'),
506 'where' => 'civicrm_group.created_id',
507 'table_name' => 'civicrm_group',
509 'bao' => 'CRM_Contact_BAO_Group',
511 'FKClassName' => 'CRM_Contact_DAO_Contact',
515 'name' => 'modified_id',
516 'type' => CRM_Utils_Type
::T_INT
,
517 'title' => ts('Group Modified By'),
518 'description' => ts('FK to contact table.'),
519 'where' => 'civicrm_group.modified_id',
520 'table_name' => 'civicrm_group',
522 'bao' => 'CRM_Contact_BAO_Group',
524 'FKClassName' => 'CRM_Contact_DAO_Contact',
527 'frontend_title' => [
528 'name' => 'frontend_title',
529 'type' => CRM_Utils_Type
::T_STRING
,
530 'title' => ts('Public Group Title'),
531 'description' => ts('Alternative public title for this Group.'),
533 'size' => CRM_Utils_Type
::HUGE
,
534 'where' => 'civicrm_group.frontend_title',
536 'table_name' => 'civicrm_group',
538 'bao' => 'CRM_Contact_BAO_Group',
545 'frontend_description' => [
546 'name' => 'frontend_description',
547 'type' => CRM_Utils_Type
::T_TEXT
,
548 'title' => ts('Public Group Description'),
549 'description' => ts('Alternative public description of the group.'),
552 'where' => 'civicrm_group.frontend_description',
554 'table_name' => 'civicrm_group',
556 'bao' => 'CRM_Contact_BAO_Group',
559 'type' => 'TextArea',
564 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
566 return Civi
::$statics[__CLASS__
]['fields'];
570 * Return a mapping from field-name to the corresponding key (as used in fields()).
573 * Array(string $name => string $uniqueName).
575 public static function &fieldKeys() {
576 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
577 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
579 return Civi
::$statics[__CLASS__
]['fieldKeys'];
583 * Returns the names of this table
587 public static function getTableName() {
588 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
592 * Returns if this table needs to be logged
596 public function getLog() {
601 * Returns the list of fields that can be imported
603 * @param bool $prefix
607 public static function &import($prefix = FALSE) {
608 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
613 * Returns the list of fields that can be exported
615 * @param bool $prefix
619 public static function &export($prefix = FALSE) {
620 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
625 * Returns the list of indices
627 * @param bool $localize
631 public static function indices($localize = TRUE) {
633 'index_group_type' => [
634 'name' => 'index_group_type',
638 'localizable' => FALSE,
639 'sig' => 'civicrm_group::0::group_type',
642 'name' => 'UI_title',
646 'localizable' => TRUE,
648 'sig' => 'civicrm_group::1::title',
655 'localizable' => FALSE,
657 'sig' => 'civicrm_group::1::name',
660 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;