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:9d3fc8fbc20e3b8068d5989828341c66)
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.
181 public function __construct() {
182 $this->__table
= 'civicrm_group';
183 parent
::__construct();
187 * Returns localized title of this entity.
189 * @param bool $plural
190 * Whether to return the plural version of the title.
192 public static function getEntityTitle($plural = FALSE) {
193 return $plural ?
ts('Groups') : ts('Group');
197 * Returns foreign keys and entity references.
200 * [CRM_Core_Reference_Interface]
202 public static function getReferenceColumns() {
203 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
204 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
205 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
206 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
207 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
208 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
210 return Civi
::$statics[__CLASS__
]['links'];
214 * Returns all the column names of this table
218 public static function &fields() {
219 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
220 Civi
::$statics[__CLASS__
]['fields'] = [
223 'type' => CRM_Utils_Type
::T_INT
,
224 'title' => ts('Group ID'),
225 'description' => ts('Group ID'),
227 'where' => 'civicrm_group.id',
228 'table_name' => 'civicrm_group',
230 'bao' => 'CRM_Contact_BAO_Group',
236 'type' => CRM_Utils_Type
::T_STRING
,
237 'title' => ts('Group Name'),
238 'description' => ts('Internal name of Group.'),
240 'size' => CRM_Utils_Type
::BIG
,
241 'where' => 'civicrm_group.name',
242 'table_name' => 'civicrm_group',
244 'bao' => 'CRM_Contact_BAO_Group',
250 'type' => CRM_Utils_Type
::T_STRING
,
251 'title' => ts('Group Title'),
252 'description' => ts('Name of Group.'),
254 'size' => CRM_Utils_Type
::BIG
,
255 'where' => 'civicrm_group.title',
256 'table_name' => 'civicrm_group',
258 'bao' => 'CRM_Contact_BAO_Group',
266 'name' => 'description',
267 'type' => CRM_Utils_Type
::T_TEXT
,
268 'title' => ts('Group Description'),
269 'description' => ts('Optional verbose description of the group.'),
272 'where' => 'civicrm_group.description',
273 'table_name' => 'civicrm_group',
275 'bao' => 'CRM_Contact_BAO_Group',
278 'type' => 'TextArea',
284 'type' => CRM_Utils_Type
::T_STRING
,
285 'title' => ts('Group Source'),
286 'description' => ts('Module or process which created this group.'),
288 'size' => CRM_Utils_Type
::BIG
,
289 'where' => 'civicrm_group.source',
290 'table_name' => 'civicrm_group',
292 'bao' => 'CRM_Contact_BAO_Group',
296 'saved_search_id' => [
297 'name' => 'saved_search_id',
298 'type' => CRM_Utils_Type
::T_INT
,
299 'title' => ts('Saved Search ID'),
300 'description' => ts('FK to saved search table.'),
301 'where' => 'civicrm_group.saved_search_id',
302 'table_name' => 'civicrm_group',
304 'bao' => 'CRM_Contact_BAO_Group',
306 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
310 'name' => 'is_active',
311 'type' => CRM_Utils_Type
::T_BOOLEAN
,
312 'title' => ts('Group Enabled'),
313 'description' => ts('Is this entry active?'),
314 'where' => 'civicrm_group.is_active',
315 'table_name' => 'civicrm_group',
317 'bao' => 'CRM_Contact_BAO_Group',
322 'name' => 'visibility',
323 'type' => CRM_Utils_Type
::T_STRING
,
324 'title' => ts('Group Visibility Setting'),
325 'description' => ts('In what context(s) is this field visible.'),
327 'size' => CRM_Utils_Type
::MEDIUM
,
328 'where' => 'civicrm_group.visibility',
329 'default' => 'User and User Admin Only',
330 'table_name' => 'civicrm_group',
332 'bao' => 'CRM_Contact_BAO_Group',
337 'pseudoconstant' => [
338 'callback' => 'CRM_Core_SelectValues::groupVisibility',
343 'name' => 'where_clause',
344 'type' => CRM_Utils_Type
::T_TEXT
,
345 'title' => ts('Group Where Clause'),
346 'description' => ts('the sql where clause if a saved search acl'),
347 'where' => 'civicrm_group.where_clause',
348 'table_name' => 'civicrm_group',
350 'bao' => 'CRM_Contact_BAO_Group',
355 'name' => 'select_tables',
356 'type' => CRM_Utils_Type
::T_TEXT
,
357 'title' => ts('Tables For Select Clause'),
358 'description' => ts('the tables to be included in a select data'),
359 'where' => 'civicrm_group.select_tables',
360 'table_name' => 'civicrm_group',
362 'bao' => 'CRM_Contact_BAO_Group',
364 'serialize' => self
::SERIALIZE_PHP
,
368 'name' => 'where_tables',
369 'type' => CRM_Utils_Type
::T_TEXT
,
370 'title' => ts('Tables For Where Clause'),
371 'description' => ts('the tables to be included in the count statement'),
372 'where' => 'civicrm_group.where_tables',
373 'table_name' => 'civicrm_group',
375 'bao' => 'CRM_Contact_BAO_Group',
377 'serialize' => self
::SERIALIZE_PHP
,
381 'name' => 'group_type',
382 'type' => CRM_Utils_Type
::T_STRING
,
383 'title' => ts('Group Type'),
384 'description' => ts('FK to group type'),
386 'size' => CRM_Utils_Type
::HUGE
,
387 'where' => 'civicrm_group.group_type',
388 'table_name' => 'civicrm_group',
390 'bao' => 'CRM_Contact_BAO_Group',
392 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
393 'pseudoconstant' => [
394 'optionGroupName' => 'group_type',
395 'optionEditPath' => 'civicrm/admin/options/group_type',
400 'name' => 'cache_date',
401 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
402 'title' => ts('Group Cache Date'),
403 'description' => ts('Date when we created the cache for a smart group'),
405 'where' => 'civicrm_group.cache_date',
406 'table_name' => 'civicrm_group',
408 'bao' => 'CRM_Contact_BAO_Group',
413 'name' => 'refresh_date',
414 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
415 'title' => ts('Next Group Refresh Time'),
416 'description' => ts('Date and time when we need to refresh the cache next.'),
418 'where' => 'civicrm_group.refresh_date',
419 'table_name' => 'civicrm_group',
421 'bao' => 'CRM_Contact_BAO_Group',
427 'type' => CRM_Utils_Type
::T_TEXT
,
428 'title' => ts('Group Parents'),
429 'description' => ts('IDs of the parent(s)'),
430 'where' => 'civicrm_group.parents',
431 'table_name' => 'civicrm_group',
433 'bao' => 'CRM_Contact_BAO_Group',
435 'serialize' => self
::SERIALIZE_COMMA
,
436 'pseudoconstant' => [
437 'callback' => 'CRM_Core_PseudoConstant::allGroup',
442 'name' => 'children',
443 'type' => CRM_Utils_Type
::T_TEXT
,
444 'title' => ts('Group Children'),
445 'description' => ts('IDs of the child(ren)'),
446 'where' => 'civicrm_group.children',
447 'table_name' => 'civicrm_group',
449 'bao' => 'CRM_Contact_BAO_Group',
454 'name' => 'is_hidden',
455 'type' => CRM_Utils_Type
::T_BOOLEAN
,
456 'title' => ts('Group is Hidden'),
457 'description' => ts('Is this group hidden?'),
458 'where' => 'civicrm_group.is_hidden',
460 'table_name' => 'civicrm_group',
462 'bao' => 'CRM_Contact_BAO_Group',
467 'name' => 'is_reserved',
468 'type' => CRM_Utils_Type
::T_BOOLEAN
,
469 'title' => ts('Group is Reserved'),
470 'where' => 'civicrm_group.is_reserved',
472 'table_name' => 'civicrm_group',
474 'bao' => 'CRM_Contact_BAO_Group',
479 'name' => 'created_id',
480 'type' => CRM_Utils_Type
::T_INT
,
481 'title' => ts('Group Created By'),
482 'description' => ts('FK to contact table.'),
483 'where' => 'civicrm_group.created_id',
484 'table_name' => 'civicrm_group',
486 'bao' => 'CRM_Contact_BAO_Group',
488 'FKClassName' => 'CRM_Contact_DAO_Contact',
492 'name' => 'modified_id',
493 'type' => CRM_Utils_Type
::T_INT
,
494 'title' => ts('Group Modified By'),
495 'description' => ts('FK to contact table.'),
496 'where' => 'civicrm_group.modified_id',
497 'table_name' => 'civicrm_group',
499 'bao' => 'CRM_Contact_BAO_Group',
501 'FKClassName' => 'CRM_Contact_DAO_Contact',
505 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
507 return Civi
::$statics[__CLASS__
]['fields'];
511 * Return a mapping from field-name to the corresponding key (as used in fields()).
514 * Array(string $name => string $uniqueName).
516 public static function &fieldKeys() {
517 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
518 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
520 return Civi
::$statics[__CLASS__
]['fieldKeys'];
524 * Returns the names of this table
528 public static function getTableName() {
529 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
533 * Returns if this table needs to be logged
537 public function getLog() {
542 * Returns the list of fields that can be imported
544 * @param bool $prefix
548 public static function &import($prefix = FALSE) {
549 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
554 * Returns the list of fields that can be exported
556 * @param bool $prefix
560 public static function &export($prefix = FALSE) {
561 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
566 * Returns the list of indices
568 * @param bool $localize
572 public static function indices($localize = TRUE) {
574 'index_group_type' => [
575 'name' => 'index_group_type',
579 'localizable' => FALSE,
580 'sig' => 'civicrm_group::0::group_type',
583 'name' => 'UI_title',
587 'localizable' => TRUE,
589 'sig' => 'civicrm_group::1::title',
596 'localizable' => FALSE,
598 'sig' => 'civicrm_group::1::name',
601 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;