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:49027c63bf6fd142e79220b39f84056d)
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.'),
278 'size' => CRM_Utils_Type
::HUGE
,
279 'where' => 'civicrm_group.title',
280 'table_name' => 'civicrm_group',
282 'bao' => 'CRM_Contact_BAO_Group',
290 'name' => 'description',
291 'type' => CRM_Utils_Type
::T_TEXT
,
292 'title' => ts('Group Description'),
293 'description' => ts('Optional verbose description of the group.'),
296 'where' => 'civicrm_group.description',
297 'table_name' => 'civicrm_group',
299 'bao' => 'CRM_Contact_BAO_Group',
302 'type' => 'TextArea',
308 'type' => CRM_Utils_Type
::T_STRING
,
309 'title' => ts('Group Source'),
310 'description' => ts('Module or process which created this group.'),
312 'size' => CRM_Utils_Type
::BIG
,
313 'where' => 'civicrm_group.source',
314 'table_name' => 'civicrm_group',
316 'bao' => 'CRM_Contact_BAO_Group',
320 'saved_search_id' => [
321 'name' => 'saved_search_id',
322 'type' => CRM_Utils_Type
::T_INT
,
323 'title' => ts('Saved Search ID'),
324 'description' => ts('FK to saved search table.'),
325 'where' => 'civicrm_group.saved_search_id',
326 'table_name' => 'civicrm_group',
328 'bao' => 'CRM_Contact_BAO_Group',
330 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
334 'name' => 'is_active',
335 'type' => CRM_Utils_Type
::T_BOOLEAN
,
336 'title' => ts('Group Enabled'),
337 'description' => ts('Is this entry active?'),
338 'where' => 'civicrm_group.is_active',
339 'table_name' => 'civicrm_group',
341 'bao' => 'CRM_Contact_BAO_Group',
346 'name' => 'visibility',
347 'type' => CRM_Utils_Type
::T_STRING
,
348 'title' => ts('Group Visibility Setting'),
349 'description' => ts('In what context(s) is this field visible.'),
351 'size' => CRM_Utils_Type
::MEDIUM
,
352 'where' => 'civicrm_group.visibility',
353 'default' => 'User and User Admin Only',
354 'table_name' => 'civicrm_group',
356 'bao' => 'CRM_Contact_BAO_Group',
361 'pseudoconstant' => [
362 'callback' => 'CRM_Core_SelectValues::groupVisibility',
367 'name' => 'where_clause',
368 'type' => CRM_Utils_Type
::T_TEXT
,
369 'title' => ts('Group Where Clause'),
370 'description' => ts('the sql where clause if a saved search acl'),
371 'where' => 'civicrm_group.where_clause',
372 'table_name' => 'civicrm_group',
374 'bao' => 'CRM_Contact_BAO_Group',
379 'name' => 'select_tables',
380 'type' => CRM_Utils_Type
::T_TEXT
,
381 'title' => ts('Tables For Select Clause'),
382 'description' => ts('the tables to be included in a select data'),
383 'where' => 'civicrm_group.select_tables',
384 'table_name' => 'civicrm_group',
386 'bao' => 'CRM_Contact_BAO_Group',
388 'serialize' => self
::SERIALIZE_PHP
,
392 'name' => 'where_tables',
393 'type' => CRM_Utils_Type
::T_TEXT
,
394 'title' => ts('Tables For Where Clause'),
395 'description' => ts('the tables to be included in the count statement'),
396 'where' => 'civicrm_group.where_tables',
397 'table_name' => 'civicrm_group',
399 'bao' => 'CRM_Contact_BAO_Group',
401 'serialize' => self
::SERIALIZE_PHP
,
405 'name' => 'group_type',
406 'type' => CRM_Utils_Type
::T_STRING
,
407 'title' => ts('Group Type'),
408 'description' => ts('FK to group type'),
410 'size' => CRM_Utils_Type
::HUGE
,
411 'where' => 'civicrm_group.group_type',
412 'table_name' => 'civicrm_group',
414 'bao' => 'CRM_Contact_BAO_Group',
416 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
417 'pseudoconstant' => [
418 'optionGroupName' => 'group_type',
419 'optionEditPath' => 'civicrm/admin/options/group_type',
424 'name' => 'cache_date',
425 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
426 'title' => ts('Group Cache Date'),
427 'description' => ts('Date when we created the cache for a smart group'),
429 'where' => 'civicrm_group.cache_date',
430 'table_name' => 'civicrm_group',
432 'bao' => 'CRM_Contact_BAO_Group',
437 'name' => 'refresh_date',
438 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
439 'title' => ts('Next Group Refresh Time'),
440 'description' => ts('Date and time when we need to refresh the cache next.'),
442 'where' => 'civicrm_group.refresh_date',
443 'table_name' => 'civicrm_group',
445 'bao' => 'CRM_Contact_BAO_Group',
451 'type' => CRM_Utils_Type
::T_TEXT
,
452 'title' => ts('Group Parents'),
453 'description' => ts('IDs of the parent(s)'),
454 'where' => 'civicrm_group.parents',
455 'table_name' => 'civicrm_group',
457 'bao' => 'CRM_Contact_BAO_Group',
459 'serialize' => self
::SERIALIZE_COMMA
,
460 'pseudoconstant' => [
461 'callback' => 'CRM_Core_PseudoConstant::allGroup',
466 'name' => 'children',
467 'type' => CRM_Utils_Type
::T_TEXT
,
468 'title' => ts('Group Children'),
469 'description' => ts('IDs of the child(ren)'),
470 'where' => 'civicrm_group.children',
471 'table_name' => 'civicrm_group',
473 'bao' => 'CRM_Contact_BAO_Group',
478 'name' => 'is_hidden',
479 'type' => CRM_Utils_Type
::T_BOOLEAN
,
480 'title' => ts('Group is Hidden'),
481 'description' => ts('Is this group hidden?'),
482 'where' => 'civicrm_group.is_hidden',
484 'table_name' => 'civicrm_group',
486 'bao' => 'CRM_Contact_BAO_Group',
491 'name' => 'is_reserved',
492 'type' => CRM_Utils_Type
::T_BOOLEAN
,
493 'title' => ts('Group is Reserved'),
494 'where' => 'civicrm_group.is_reserved',
496 'table_name' => 'civicrm_group',
498 'bao' => 'CRM_Contact_BAO_Group',
503 'name' => 'created_id',
504 'type' => CRM_Utils_Type
::T_INT
,
505 'title' => ts('Group Created By'),
506 'description' => ts('FK to contact table.'),
507 'where' => 'civicrm_group.created_id',
508 'table_name' => 'civicrm_group',
510 'bao' => 'CRM_Contact_BAO_Group',
512 'FKClassName' => 'CRM_Contact_DAO_Contact',
516 'name' => 'modified_id',
517 'type' => CRM_Utils_Type
::T_INT
,
518 'title' => ts('Group Modified By'),
519 'description' => ts('FK to contact table.'),
520 'where' => 'civicrm_group.modified_id',
521 'table_name' => 'civicrm_group',
523 'bao' => 'CRM_Contact_BAO_Group',
525 'FKClassName' => 'CRM_Contact_DAO_Contact',
528 'frontend_title' => [
529 'name' => 'frontend_title',
530 'type' => CRM_Utils_Type
::T_STRING
,
531 'title' => ts('Public Group Title'),
532 'description' => ts('Alternative public title for this Group.'),
534 'size' => CRM_Utils_Type
::HUGE
,
535 'where' => 'civicrm_group.frontend_title',
537 'table_name' => 'civicrm_group',
539 'bao' => 'CRM_Contact_BAO_Group',
546 'frontend_description' => [
547 'name' => 'frontend_description',
548 'type' => CRM_Utils_Type
::T_TEXT
,
549 'title' => ts('Public Group Description'),
550 'description' => ts('Alternative public description of the group.'),
553 'where' => 'civicrm_group.frontend_description',
555 'table_name' => 'civicrm_group',
557 'bao' => 'CRM_Contact_BAO_Group',
560 'type' => 'TextArea',
565 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
567 return Civi
::$statics[__CLASS__
]['fields'];
571 * Return a mapping from field-name to the corresponding key (as used in fields()).
574 * Array(string $name => string $uniqueName).
576 public static function &fieldKeys() {
577 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
578 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
580 return Civi
::$statics[__CLASS__
]['fieldKeys'];
584 * Returns the names of this table
588 public static function getTableName() {
589 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
593 * Returns if this table needs to be logged
597 public function getLog() {
602 * Returns the list of fields that can be imported
604 * @param bool $prefix
608 public static function &import($prefix = FALSE) {
609 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
614 * Returns the list of fields that can be exported
616 * @param bool $prefix
620 public static function &export($prefix = FALSE) {
621 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
626 * Returns the list of indices
628 * @param bool $localize
632 public static function indices($localize = TRUE) {
634 'index_group_type' => [
635 'name' => 'index_group_type',
639 'localizable' => FALSE,
640 'sig' => 'civicrm_group::0::group_type',
643 'name' => 'UI_title',
647 'localizable' => TRUE,
649 'sig' => 'civicrm_group::1::title',
656 'localizable' => FALSE,
658 'sig' => 'civicrm_group::1::name',
661 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;