5 * @copyright CiviCRM LLC (c) 2004-2019
7 * Generated from xml/schema/CRM/Contact/Group.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:28c32e7038a2b7aa7ca2c45117660974)
13 * Database access object for the Group entity.
15 class CRM_Contact_DAO_Group
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_group';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
39 * Internal name of Group.
53 * Optional verbose description of the group.
60 * Module or process which created this group.
67 * FK to saved search table.
71 public $saved_search_id;
74 * Is this entry active?
81 * In what context(s) is this field visible.
88 * the sql where clause if a saved search acl
95 * the tables to be included in a select data
99 public $select_tables;
102 * the tables to be included in the count statement
106 public $where_tables;
116 * Date when we created the cache for a smart group
123 * Date and time when we need to refresh the cache next.
127 public $refresh_date;
130 * IDs of the parent(s)
137 * IDs of the child(ren)
144 * Is this group hidden?
156 * FK to contact table.
163 * FK to contact table.
172 public function __construct() {
173 $this->__table
= 'civicrm_group';
174 parent
::__construct();
178 * Returns foreign keys and entity references.
181 * [CRM_Core_Reference_Interface]
183 public static function getReferenceColumns() {
184 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
185 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
186 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id');
187 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'created_id', 'civicrm_contact', 'id');
188 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'modified_id', 'civicrm_contact', 'id');
189 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
191 return Civi
::$statics[__CLASS__
]['links'];
195 * Returns all the column names of this table
199 public static function &fields() {
200 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
201 Civi
::$statics[__CLASS__
]['fields'] = [
204 'type' => CRM_Utils_Type
::T_INT
,
205 'title' => ts('Group ID'),
206 'description' => ts('Group ID'),
208 'where' => 'civicrm_group.id',
209 'table_name' => 'civicrm_group',
211 'bao' => 'CRM_Contact_BAO_Group',
216 'type' => CRM_Utils_Type
::T_STRING
,
217 'title' => ts('Group Name'),
218 'description' => ts('Internal name of Group.'),
220 'size' => CRM_Utils_Type
::BIG
,
221 'where' => 'civicrm_group.name',
222 'table_name' => 'civicrm_group',
224 'bao' => 'CRM_Contact_BAO_Group',
229 'type' => CRM_Utils_Type
::T_STRING
,
230 'title' => ts('Group Title'),
231 'description' => ts('Name of Group.'),
233 'size' => CRM_Utils_Type
::BIG
,
234 'where' => 'civicrm_group.title',
235 'table_name' => 'civicrm_group',
237 'bao' => 'CRM_Contact_BAO_Group',
244 'name' => 'description',
245 'type' => CRM_Utils_Type
::T_TEXT
,
246 'title' => ts('Group Description'),
247 'description' => ts('Optional verbose description of the group.'),
250 'where' => 'civicrm_group.description',
251 'table_name' => 'civicrm_group',
253 'bao' => 'CRM_Contact_BAO_Group',
256 'type' => 'TextArea',
261 'type' => CRM_Utils_Type
::T_STRING
,
262 'title' => ts('Group Source'),
263 'description' => ts('Module or process which created this group.'),
265 'size' => CRM_Utils_Type
::BIG
,
266 'where' => 'civicrm_group.source',
267 'table_name' => 'civicrm_group',
269 'bao' => 'CRM_Contact_BAO_Group',
272 'saved_search_id' => [
273 'name' => 'saved_search_id',
274 'type' => CRM_Utils_Type
::T_INT
,
275 'title' => ts('Saved Search ID'),
276 'description' => ts('FK to saved search table.'),
277 'where' => 'civicrm_group.saved_search_id',
278 'table_name' => 'civicrm_group',
280 'bao' => 'CRM_Contact_BAO_Group',
282 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
285 'name' => 'is_active',
286 'type' => CRM_Utils_Type
::T_BOOLEAN
,
287 'title' => ts('Group Enabled'),
288 'description' => ts('Is this entry active?'),
289 'where' => 'civicrm_group.is_active',
290 'table_name' => 'civicrm_group',
292 'bao' => 'CRM_Contact_BAO_Group',
296 'name' => 'visibility',
297 'type' => CRM_Utils_Type
::T_STRING
,
298 'title' => ts('Group Visibility Setting'),
299 'description' => ts('In what context(s) is this field visible.'),
301 'size' => CRM_Utils_Type
::MEDIUM
,
302 'where' => 'civicrm_group.visibility',
303 'default' => 'User and User Admin Only',
304 'table_name' => 'civicrm_group',
306 'bao' => 'CRM_Contact_BAO_Group',
311 'pseudoconstant' => [
312 'callback' => 'CRM_Core_SelectValues::groupVisibility',
316 'name' => 'where_clause',
317 'type' => CRM_Utils_Type
::T_TEXT
,
318 'title' => ts('Group Where Clause'),
319 'description' => ts('the sql where clause if a saved search acl'),
320 'where' => 'civicrm_group.where_clause',
321 'table_name' => 'civicrm_group',
323 'bao' => 'CRM_Contact_BAO_Group',
327 'name' => 'select_tables',
328 'type' => CRM_Utils_Type
::T_TEXT
,
329 'title' => ts('Tables For Select Clause'),
330 'description' => ts('the tables to be included in a select data'),
331 'where' => 'civicrm_group.select_tables',
332 'table_name' => 'civicrm_group',
334 'bao' => 'CRM_Contact_BAO_Group',
336 'serialize' => self
::SERIALIZE_PHP
,
339 'name' => 'where_tables',
340 'type' => CRM_Utils_Type
::T_TEXT
,
341 'title' => ts('Tables For Where Clause'),
342 'description' => ts('the tables to be included in the count statement'),
343 'where' => 'civicrm_group.where_tables',
344 'table_name' => 'civicrm_group',
346 'bao' => 'CRM_Contact_BAO_Group',
348 'serialize' => self
::SERIALIZE_PHP
,
351 'name' => 'group_type',
352 'type' => CRM_Utils_Type
::T_STRING
,
353 'title' => ts('Group Type'),
354 'description' => ts('FK to group type'),
356 'size' => CRM_Utils_Type
::HUGE
,
357 'where' => 'civicrm_group.group_type',
358 'table_name' => 'civicrm_group',
360 'bao' => 'CRM_Contact_BAO_Group',
362 'serialize' => self
::SERIALIZE_SEPARATOR_BOOKEND
,
363 'pseudoconstant' => [
364 'optionGroupName' => 'group_type',
365 'optionEditPath' => 'civicrm/admin/options/group_type',
369 'name' => 'cache_date',
370 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
371 'title' => ts('Group Cache Date'),
372 'description' => ts('Date when we created the cache for a smart group'),
374 'where' => 'civicrm_group.cache_date',
375 'table_name' => 'civicrm_group',
377 'bao' => 'CRM_Contact_BAO_Group',
381 'name' => 'refresh_date',
382 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
383 'title' => ts('Next Group Refresh Time'),
384 'description' => ts('Date and time when we need to refresh the cache next.'),
386 'where' => 'civicrm_group.refresh_date',
387 'table_name' => 'civicrm_group',
389 'bao' => 'CRM_Contact_BAO_Group',
394 'type' => CRM_Utils_Type
::T_TEXT
,
395 'title' => ts('Group Parents'),
396 'description' => ts('IDs of the parent(s)'),
397 'where' => 'civicrm_group.parents',
398 'table_name' => 'civicrm_group',
400 'bao' => 'CRM_Contact_BAO_Group',
402 'serialize' => self
::SERIALIZE_COMMA
,
403 'pseudoconstant' => [
404 'callback' => 'CRM_Core_PseudoConstant::allGroup',
408 'name' => 'children',
409 'type' => CRM_Utils_Type
::T_TEXT
,
410 'title' => ts('Group Children'),
411 'description' => ts('IDs of the child(ren)'),
412 'where' => 'civicrm_group.children',
413 'table_name' => 'civicrm_group',
415 'bao' => 'CRM_Contact_BAO_Group',
419 'name' => 'is_hidden',
420 'type' => CRM_Utils_Type
::T_BOOLEAN
,
421 'title' => ts('Group is Hidden'),
422 'description' => ts('Is this group hidden?'),
423 'where' => 'civicrm_group.is_hidden',
425 'table_name' => 'civicrm_group',
427 'bao' => 'CRM_Contact_BAO_Group',
431 'name' => 'is_reserved',
432 'type' => CRM_Utils_Type
::T_BOOLEAN
,
433 'title' => ts('Group is Reserved'),
434 'where' => 'civicrm_group.is_reserved',
436 'table_name' => 'civicrm_group',
438 'bao' => 'CRM_Contact_BAO_Group',
442 'name' => 'created_id',
443 'type' => CRM_Utils_Type
::T_INT
,
444 'title' => ts('Group Created By'),
445 'description' => ts('FK to contact table.'),
446 'where' => 'civicrm_group.created_id',
447 'table_name' => 'civicrm_group',
449 'bao' => 'CRM_Contact_BAO_Group',
451 'FKClassName' => 'CRM_Contact_DAO_Contact',
454 'name' => 'modified_id',
455 'type' => CRM_Utils_Type
::T_INT
,
456 'title' => ts('Group Modified By'),
457 'description' => ts('FK to contact table.'),
458 'where' => 'civicrm_group.modified_id',
459 'table_name' => 'civicrm_group',
461 'bao' => 'CRM_Contact_BAO_Group',
463 'FKClassName' => 'CRM_Contact_DAO_Contact',
466 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
468 return Civi
::$statics[__CLASS__
]['fields'];
472 * Return a mapping from field-name to the corresponding key (as used in fields()).
475 * Array(string $name => string $uniqueName).
477 public static function &fieldKeys() {
478 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
479 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
481 return Civi
::$statics[__CLASS__
]['fieldKeys'];
485 * Returns the names of this table
489 public static function getTableName() {
490 return CRM_Core_DAO
::getLocaleTableName(self
::$_tableName);
494 * Returns if this table needs to be logged
498 public function getLog() {
503 * Returns the list of fields that can be imported
505 * @param bool $prefix
509 public static function &import($prefix = FALSE) {
510 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'group', $prefix, []);
515 * Returns the list of fields that can be exported
517 * @param bool $prefix
521 public static function &export($prefix = FALSE) {
522 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'group', $prefix, []);
527 * Returns the list of indices
529 * @param bool $localize
533 public static function indices($localize = TRUE) {
535 'index_group_type' => [
536 'name' => 'index_group_type',
540 'localizable' => FALSE,
541 'sig' => 'civicrm_group::0::group_type',
544 'name' => 'UI_title',
548 'localizable' => TRUE,
550 'sig' => 'civicrm_group::1::title',
557 'localizable' => FALSE,
559 'sig' => 'civicrm_group::1::name',
562 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;