Merge pull request #23612 from civicrm/5.50
[civicrm-core.git] / CRM / Contact / DAO / GroupContact.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/GroupContact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:f7c8513020809cc974eec784b983a75d)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the GroupContact entity.
f41f0342 14 */
e501603b 15class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_group_contact';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = TRUE;
c3fc2621 32
e501603b
TO
33 /**
34 * primary key
35 *
28979d65
CW
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
e501603b
TO
39 */
40 public $id;
c3fc2621 41
e501603b
TO
42 /**
43 * FK to civicrm_group
44 *
28979d65
CW
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
e501603b
TO
48 */
49 public $group_id;
c3fc2621 50
e501603b
TO
51 /**
52 * FK to civicrm_contact
53 *
28979d65
CW
54 * @var int|string
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
e501603b
TO
57 */
58 public $contact_id;
c3fc2621 59
e501603b
TO
60 /**
61 * status of contact relative to membership in group
62 *
28979d65
CW
63 * @var string|null
64 * (SQL type: varchar(8))
65 * Note that values will be retrieved from the database as a string.
e501603b
TO
66 */
67 public $status;
c3fc2621 68
e501603b
TO
69 /**
70 * Optional location to associate with this membership
71 *
28979d65
CW
72 * @var int|string|null
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
e501603b
TO
75 */
76 public $location_id;
c3fc2621 77
e501603b
TO
78 /**
79 * Optional email to associate with this membership
80 *
28979d65
CW
81 * @var int|string|null
82 * (SQL type: int unsigned)
83 * Note that values will be retrieved from the database as a string.
e501603b
TO
84 */
85 public $email_id;
c3fc2621 86
e501603b 87 /**
f41f0342 88 * Class constructor.
e501603b 89 */
c3fc2621 90 public function __construct() {
e501603b
TO
91 $this->__table = 'civicrm_group_contact';
92 parent::__construct();
93 }
c3fc2621 94
449c4e6b
CW
95 /**
96 * Returns localized title of this entity.
7b66c3b5
AH
97 *
98 * @param bool $plural
99 * Whether to return the plural version of the title.
449c4e6b 100 */
7b66c3b5
AH
101 public static function getEntityTitle($plural = FALSE) {
102 return $plural ? ts('Group Contacts') : ts('Group Contact');
449c4e6b
CW
103 }
104
e501603b 105 /**
f41f0342 106 * Returns foreign keys and entity references.
e501603b
TO
107 *
108 * @return array
109 * [CRM_Core_Reference_Interface]
110 */
c3fc2621 111 public static function getReferenceColumns() {
346aaaba 112 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 113 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
114 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
115 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
116 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_id', 'civicrm_loc_block', 'id');
117 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
346aaaba 118 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 119 }
346aaaba 120 return Civi::$statics[__CLASS__]['links'];
e501603b 121 }
c3fc2621 122
e501603b
TO
123 /**
124 * Returns all the column names of this table
125 *
126 * @return array
127 */
c3fc2621 128 public static function &fields() {
346aaaba 129 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
130 Civi::$statics[__CLASS__]['fields'] = [
131 'id' => [
e501603b
TO
132 'name' => 'id',
133 'type' => CRM_Utils_Type::T_INT,
c3fc2621 134 'title' => ts('Group Contact ID'),
215b423e 135 'description' => ts('primary key'),
c3fc2621 136 'required' => TRUE,
a36434b9 137 'where' => 'civicrm_group_contact.id',
522a26c9 138 'table_name' => 'civicrm_group_contact',
139 'entity' => 'GroupContact',
140 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 141 'localizable' => 0,
2cbbebe8
A
142 'html' => [
143 'type' => 'Number',
144 ],
1fe423d6 145 'readonly' => TRUE,
a9d0587b 146 'add' => '1.1',
c3fc2621
CW
147 ],
148 'group_id' => [
e501603b
TO
149 'name' => 'group_id',
150 'type' => CRM_Utils_Type::T_INT,
c3fc2621 151 'title' => ts('Group ID'),
215b423e 152 'description' => ts('FK to civicrm_group'),
c3fc2621 153 'required' => TRUE,
a36434b9 154 'where' => 'civicrm_group_contact.group_id',
522a26c9 155 'table_name' => 'civicrm_group_contact',
156 'entity' => 'GroupContact',
157 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 158 'localizable' => 0,
e501603b 159 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 160 'html' => [
e501603b 161 'type' => 'Select',
2cbbebe8 162 'label' => ts("Group"),
c3fc2621
CW
163 ],
164 'pseudoconstant' => [
e501603b
TO
165 'table' => 'civicrm_group',
166 'keyColumn' => 'id',
167 'labelColumn' => 'title',
e6ca0a57 168 ],
a9d0587b 169 'add' => '1.1',
c3fc2621
CW
170 ],
171 'contact_id' => [
e501603b
TO
172 'name' => 'contact_id',
173 'type' => CRM_Utils_Type::T_INT,
c3fc2621 174 'title' => ts('Contact ID'),
215b423e 175 'description' => ts('FK to civicrm_contact'),
c3fc2621 176 'required' => TRUE,
a36434b9 177 'where' => 'civicrm_group_contact.contact_id',
522a26c9 178 'table_name' => 'civicrm_group_contact',
179 'entity' => 'GroupContact',
180 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 181 'localizable' => 0,
e501603b 182 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
183 'html' => [
184 'label' => ts("Contact"),
185 ],
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'status' => [
e501603b
TO
189 'name' => 'status',
190 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 191 'title' => ts('Group Contact Status'),
215b423e 192 'description' => ts('status of contact relative to membership in group'),
e501603b
TO
193 'maxlength' => 8,
194 'size' => CRM_Utils_Type::EIGHT,
a36434b9 195 'where' => 'civicrm_group_contact.status',
522a26c9 196 'table_name' => 'civicrm_group_contact',
197 'entity' => 'GroupContact',
198 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 199 'localizable' => 0,
c3fc2621 200 'html' => [
e501603b 201 'type' => 'Select',
c3fc2621
CW
202 ],
203 'pseudoconstant' => [
e501603b 204 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
e6ca0a57 205 ],
a9d0587b 206 'add' => '1.1',
c3fc2621
CW
207 ],
208 'location_id' => [
e501603b
TO
209 'name' => 'location_id',
210 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 211 'title' => ts('Location ID'),
215b423e 212 'description' => ts('Optional location to associate with this membership'),
a36434b9 213 'where' => 'civicrm_group_contact.location_id',
522a26c9 214 'table_name' => 'civicrm_group_contact',
215 'entity' => 'GroupContact',
216 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 217 'localizable' => 0,
e501603b 218 'FKClassName' => 'CRM_Core_DAO_LocBlock',
2cbbebe8
A
219 'html' => [
220 'label' => ts("Location"),
221 ],
a9d0587b 222 'add' => '1.1',
c3fc2621
CW
223 ],
224 'email_id' => [
e501603b
TO
225 'name' => 'email_id',
226 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 227 'title' => ts('Email ID'),
215b423e 228 'description' => ts('Optional email to associate with this membership'),
a36434b9 229 'where' => 'civicrm_group_contact.email_id',
522a26c9 230 'table_name' => 'civicrm_group_contact',
231 'entity' => 'GroupContact',
232 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 233 'localizable' => 0,
e501603b 234 'FKClassName' => 'CRM_Core_DAO_Email',
2cbbebe8
A
235 'html' => [
236 'label' => ts("Email"),
237 ],
a9d0587b 238 'add' => '1.1',
c3fc2621
CW
239 ],
240 ];
346aaaba 241 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 242 }
346aaaba 243 return Civi::$statics[__CLASS__]['fields'];
e501603b 244 }
c3fc2621 245
e501603b 246 /**
bd8e0b14 247 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
248 *
249 * @return array
bd8e0b14 250 * Array(string $name => string $uniqueName).
e501603b 251 */
c3fc2621 252 public static function &fieldKeys() {
bd8e0b14
TO
253 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
254 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 255 }
bd8e0b14 256 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 257 }
c3fc2621 258
e501603b
TO
259 /**
260 * Returns the names of this table
261 *
262 * @return string
263 */
c3fc2621 264 public static function getTableName() {
e501603b
TO
265 return self::$_tableName;
266 }
c3fc2621 267
e501603b
TO
268 /**
269 * Returns if this table needs to be logged
270 *
c3fc2621 271 * @return bool
e501603b 272 */
c3fc2621 273 public function getLog() {
e501603b
TO
274 return self::$_log;
275 }
c3fc2621 276
e501603b
TO
277 /**
278 * Returns the list of fields that can be imported
279 *
280 * @param bool $prefix
281 *
282 * @return array
283 */
c3fc2621
CW
284 public static function &import($prefix = FALSE) {
285 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact', $prefix, []);
60808919 286 return $r;
e501603b 287 }
c3fc2621 288
e501603b
TO
289 /**
290 * Returns the list of fields that can be exported
291 *
292 * @param bool $prefix
293 *
294 * @return array
295 */
c3fc2621
CW
296 public static function &export($prefix = FALSE) {
297 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact', $prefix, []);
60808919 298 return $r;
e501603b 299 }
c3fc2621 300
e7a6b91a
AS
301 /**
302 * Returns the list of indices
c3fc2621
CW
303 *
304 * @param bool $localize
305 *
306 * @return array
e7a6b91a
AS
307 */
308 public static function indices($localize = TRUE) {
c3fc2621
CW
309 $indices = [
310 'UI_contact_group' => [
e7a6b91a 311 'name' => 'UI_contact_group',
c3fc2621 312 'field' => [
e7a6b91a
AS
313 0 => 'contact_id',
314 1 => 'group_id',
c3fc2621
CW
315 ],
316 'localizable' => FALSE,
317 'unique' => TRUE,
e7a6b91a 318 'sig' => 'civicrm_group_contact::1::contact_id::group_id',
c3fc2621
CW
319 ],
320 ];
e7a6b91a
AS
321 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
322 }
c3fc2621 323
e501603b 324}