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:6a2a222c5fa5b461727bb95379723b08)
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 public static function getEntityTitle() {
194 * Returns foreign keys and entity references.
197 * [CRM_Core_Reference_Interface]
199 public static function getReferenceColumns() {
200 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
201 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
202 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
203 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
204 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
205 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
207 return Civi
::$statics[__CLASS__
]['links'];
211 * Returns all the column names of this table
215 public static function &fields() {
216 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
217 Civi
::$statics[__CLASS__
]['fields'] = [
220 'type' => CRM_Utils_Type
::T_INT
,
221 'title' => ts('Group ID'),
222 'description' => ts('Group ID'),
224 'where' => 'civicrm_group.id',
225 'table_name' => 'civicrm_group',
227 'bao' => 'CRM_Contact_BAO_Group',
233 'type' => CRM_Utils_Type
::T_STRING
,
234 'title' => ts('Group Name'),
235 'description' => ts('Internal name of Group.'),
237 'size' => CRM_Utils_Type
::BIG
,
238 'where' => 'civicrm_group.name',
239 'table_name' => 'civicrm_group',
241 'bao' => 'CRM_Contact_BAO_Group',
247 'type' => CRM_Utils_Type
::T_STRING
,
248 'title' => ts('Group Title'),
249 'description' => ts('Name of Group.'),
251 'size' => CRM_Utils_Type
::BIG
,
252 'where' => 'civicrm_group.title',
253 'table_name' => 'civicrm_group',
255 'bao' => 'CRM_Contact_BAO_Group',
263 'name' => 'description',
264 'type' => CRM_Utils_Type
::T_TEXT
,
265 'title' => ts('Group Description'),
266 'description' => ts('Optional verbose description of the group.'),
269 'where' => 'civicrm_group.description',
270 'table_name' => 'civicrm_group',
272 'bao' => 'CRM_Contact_BAO_Group',
275 'type' => 'TextArea',
281 'type' => CRM_Utils_Type
::T_STRING
,
282 'title' => ts('Group Source'),
283 'description' => ts('Module or process which created this group.'),
285 'size' => CRM_Utils_Type
::BIG
,
286 'where' => 'civicrm_group.source',
287 'table_name' => 'civicrm_group',
289 'bao' => 'CRM_Contact_BAO_Group',
293 'saved_search_id' => [
294 'name' => 'saved_search_id',
295 'type' => CRM_Utils_Type
::T_INT
,
296 'title' => ts('Saved Search ID'),
297 'description' => ts('FK to saved search table.'),
298 'where' => 'civicrm_group.saved_search_id',
299 'table_name' => 'civicrm_group',
301 'bao' => 'CRM_Contact_BAO_Group',
303 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
307 'name' => 'is_active',
308 'type' => CRM_Utils_Type
::T_BOOLEAN
,
309 'title' => ts('Group Enabled'),
310 'description' => ts('Is this entry active?'),
311 'where' => 'civicrm_group.is_active',
312 'table_name' => 'civicrm_group',
314 'bao' => 'CRM_Contact_BAO_Group',
319 'name' => 'visibility',
320 'type' => CRM_Utils_Type
::T_STRING
,
321 'title' => ts('Group Visibility Setting'),
322 'description' => ts('In what context(s) is this field visible.'),
324 'size' => CRM_Utils_Type
::MEDIUM
,
325 'where' => 'civicrm_group.visibility',
326 'default' => 'User and User Admin Only',
327 'table_name' => 'civicrm_group',
329 'bao' => 'CRM_Contact_BAO_Group',
334 'pseudoconstant' => [
335 'callback' => 'CRM_Core_SelectValues::groupVisibility',
340 'name' => 'where_clause',
341 'type' => CRM_Utils_Type
::T_TEXT
,
342 'title' => ts('Group Where Clause'),
343 'description' => ts('the sql where clause if a saved search acl'),
344 'where' => 'civicrm_group.where_clause',
345 'table_name' => 'civicrm_group',
347 'bao' => 'CRM_Contact_BAO_Group',
352 'name' => 'select_tables',
353 'type' => CRM_Utils_Type
::T_TEXT
,
354 'title' => ts('Tables For Select Clause'),
355 'description' => ts('the tables to be included in a select data'),
356 'where' => 'civicrm_group.select_tables',
357 'table_name' => 'civicrm_group',
359 'bao' => 'CRM_Contact_BAO_Group',
361 'serialize' => self
::SERIALIZE_PHP
,
365 'name' => 'where_tables',
366 'type' => CRM_Utils_Type
::T_TEXT
,
367 'title' => ts('Tables For Where Clause'),
368 'description' => ts('the tables to be included in the count statement'),
369 'where' => 'civicrm_group.where_tables',
370 'table_name' => 'civicrm_group',
372 'bao' => 'CRM_Contact_BAO_Group',
374 'serialize' => self
::SERIALIZE_PHP
,
378 'name' => 'group_type',
379 'type' => CRM_Utils_Type
::T_STRING
,
380 'title' => ts('Group Type'),
381 'description' => ts('FK to group type'),
383 'size' => CRM_Utils_Type
::HUGE
,
384 'where' => 'civicrm_group.group_type',
385 'table_name' => 'civicrm_group',
387 'bao' => 'CRM_Contact_BAO_Group',
389 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
390 'pseudoconstant' => [
391 'optionGroupName' => 'group_type',
392 'optionEditPath' => 'civicrm/admin/options/group_type',
397 'name' => 'cache_date',
398 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
399 'title' => ts('Group Cache Date'),
400 'description' => ts('Date when we created the cache for a smart group'),
402 'where' => 'civicrm_group.cache_date',
403 'table_name' => 'civicrm_group',
405 'bao' => 'CRM_Contact_BAO_Group',
410 'name' => 'refresh_date',
411 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
412 'title' => ts('Next Group Refresh Time'),
413 'description' => ts('Date and time when we need to refresh the cache next.'),
415 'where' => 'civicrm_group.refresh_date',
416 'table_name' => 'civicrm_group',
418 'bao' => 'CRM_Contact_BAO_Group',
424 'type' => CRM_Utils_Type
::T_TEXT
,
425 'title' => ts('Group Parents'),
426 'description' => ts('IDs of the parent(s)'),
427 'where' => 'civicrm_group.parents',
428 'table_name' => 'civicrm_group',
430 'bao' => 'CRM_Contact_BAO_Group',
432 'serialize' => self
::SERIALIZE_COMMA
,
433 'pseudoconstant' => [
434 'callback' => 'CRM_Core_PseudoConstant::allGroup',
439 'name' => 'children',
440 'type' => CRM_Utils_Type
::T_TEXT
,
441 'title' => ts('Group Children'),
442 'description' => ts('IDs of the child(ren)'),
443 'where' => 'civicrm_group.children',
444 'table_name' => 'civicrm_group',
446 'bao' => 'CRM_Contact_BAO_Group',
451 'name' => 'is_hidden',
452 'type' => CRM_Utils_Type
::T_BOOLEAN
,
453 'title' => ts('Group is Hidden'),
454 'description' => ts('Is this group hidden?'),
455 'where' => 'civicrm_group.is_hidden',
457 'table_name' => 'civicrm_group',
459 'bao' => 'CRM_Contact_BAO_Group',
464 'name' => 'is_reserved',
465 'type' => CRM_Utils_Type
::T_BOOLEAN
,
466 'title' => ts('Group is Reserved'),
467 'where' => 'civicrm_group.is_reserved',
469 'table_name' => 'civicrm_group',
471 'bao' => 'CRM_Contact_BAO_Group',
476 'name' => 'created_id',
477 'type' => CRM_Utils_Type
::T_INT
,
478 'title' => ts('Group Created By'),
479 'description' => ts('FK to contact table.'),
480 'where' => 'civicrm_group.created_id',
481 'table_name' => 'civicrm_group',
483 'bao' => 'CRM_Contact_BAO_Group',
485 'FKClassName' => 'CRM_Contact_DAO_Contact',
489 'name' => 'modified_id',
490 'type' => CRM_Utils_Type
::T_INT
,
491 'title' => ts('Group Modified By'),
492 'description' => ts('FK to contact table.'),
493 'where' => 'civicrm_group.modified_id',
494 'table_name' => 'civicrm_group',
496 'bao' => 'CRM_Contact_BAO_Group',
498 'FKClassName' => 'CRM_Contact_DAO_Contact',
502 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
504 return Civi
::$statics[__CLASS__
]['fields'];
508 * Return a mapping from field-name to the corresponding key (as used in fields()).
511 * Array(string $name => string $uniqueName).
513 public static function &fieldKeys() {
514 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
515 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
517 return Civi
::$statics[__CLASS__
]['fieldKeys'];
521 * Returns the names of this table
525 public static function getTableName() {
526 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
530 * Returns if this table needs to be logged
534 public function getLog() {
539 * Returns the list of fields that can be imported
541 * @param bool $prefix
545 public static function &import($prefix = FALSE) {
546 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
551 * Returns the list of fields that can be exported
553 * @param bool $prefix
557 public static function &export($prefix = FALSE) {
558 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
563 * Returns the list of indices
565 * @param bool $localize
569 public static function indices($localize = TRUE) {
571 'index_group_type' => [
572 'name' => 'index_group_type',
576 'localizable' => FALSE,
577 'sig' => 'civicrm_group::0::group_type',
580 'name' => 'UI_title',
584 'localizable' => TRUE,
586 'sig' => 'civicrm_group::1::title',
593 'localizable' => FALSE,
595 'sig' => 'civicrm_group::1::name',
598 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;