Merge pull request #19030 from civicrm/5.32
[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
828c6915 9 * (GenCodeChecksum:ea7c012e774a203b869e0fadec080cab)
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 *
e6ca0a57 36 * @var int
e501603b
TO
37 */
38 public $id;
c3fc2621 39
e501603b
TO
40 /**
41 * FK to civicrm_group
42 *
e6ca0a57 43 * @var int
e501603b
TO
44 */
45 public $group_id;
c3fc2621 46
e501603b
TO
47 /**
48 * FK to civicrm_contact
49 *
e6ca0a57 50 * @var int
e501603b
TO
51 */
52 public $contact_id;
c3fc2621 53
e501603b
TO
54 /**
55 * status of contact relative to membership in group
56 *
57 * @var string
58 */
59 public $status;
c3fc2621 60
e501603b
TO
61 /**
62 * Optional location to associate with this membership
63 *
e6ca0a57 64 * @var int
e501603b
TO
65 */
66 public $location_id;
c3fc2621 67
e501603b
TO
68 /**
69 * Optional email to associate with this membership
70 *
e6ca0a57 71 * @var int
e501603b
TO
72 */
73 public $email_id;
c3fc2621 74
e501603b 75 /**
f41f0342 76 * Class constructor.
e501603b 77 */
c3fc2621 78 public function __construct() {
e501603b
TO
79 $this->__table = 'civicrm_group_contact';
80 parent::__construct();
81 }
c3fc2621 82
449c4e6b
CW
83 /**
84 * Returns localized title of this entity.
7b66c3b5
AH
85 *
86 * @param bool $plural
87 * Whether to return the plural version of the title.
449c4e6b 88 */
7b66c3b5
AH
89 public static function getEntityTitle($plural = FALSE) {
90 return $plural ? ts('Group Contacts') : ts('Group Contact');
449c4e6b
CW
91 }
92
e501603b 93 /**
f41f0342 94 * Returns foreign keys and entity references.
e501603b
TO
95 *
96 * @return array
97 * [CRM_Core_Reference_Interface]
98 */
c3fc2621 99 public static function getReferenceColumns() {
346aaaba 100 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 101 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
102 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
103 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_id', 'civicrm_loc_block', 'id');
105 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
346aaaba 106 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 107 }
346aaaba 108 return Civi::$statics[__CLASS__]['links'];
e501603b 109 }
c3fc2621 110
e501603b
TO
111 /**
112 * Returns all the column names of this table
113 *
114 * @return array
115 */
c3fc2621 116 public static function &fields() {
346aaaba 117 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
118 Civi::$statics[__CLASS__]['fields'] = [
119 'id' => [
e501603b
TO
120 'name' => 'id',
121 'type' => CRM_Utils_Type::T_INT,
c3fc2621 122 'title' => ts('Group Contact ID'),
215b423e 123 'description' => ts('primary key'),
c3fc2621 124 'required' => TRUE,
a36434b9 125 'where' => 'civicrm_group_contact.id',
522a26c9 126 'table_name' => 'civicrm_group_contact',
127 'entity' => 'GroupContact',
128 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 129 'localizable' => 0,
a9d0587b 130 'add' => '1.1',
c3fc2621
CW
131 ],
132 'group_id' => [
e501603b
TO
133 'name' => 'group_id',
134 'type' => CRM_Utils_Type::T_INT,
c3fc2621 135 'title' => ts('Group ID'),
215b423e 136 'description' => ts('FK to civicrm_group'),
c3fc2621 137 'required' => TRUE,
a36434b9 138 'where' => 'civicrm_group_contact.group_id',
522a26c9 139 'table_name' => 'civicrm_group_contact',
140 'entity' => 'GroupContact',
141 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 142 'localizable' => 0,
e501603b 143 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 144 'html' => [
e501603b 145 'type' => 'Select',
c3fc2621
CW
146 ],
147 'pseudoconstant' => [
e501603b
TO
148 'table' => 'civicrm_group',
149 'keyColumn' => 'id',
150 'labelColumn' => 'title',
e6ca0a57 151 ],
a9d0587b 152 'add' => '1.1',
c3fc2621
CW
153 ],
154 'contact_id' => [
e501603b
TO
155 'name' => 'contact_id',
156 'type' => CRM_Utils_Type::T_INT,
c3fc2621 157 'title' => ts('Contact ID'),
215b423e 158 'description' => ts('FK to civicrm_contact'),
c3fc2621 159 'required' => TRUE,
a36434b9 160 'where' => 'civicrm_group_contact.contact_id',
522a26c9 161 'table_name' => 'civicrm_group_contact',
162 'entity' => 'GroupContact',
163 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 164 'localizable' => 0,
e501603b 165 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 166 'add' => '1.1',
c3fc2621
CW
167 ],
168 'status' => [
e501603b
TO
169 'name' => 'status',
170 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 171 'title' => ts('Group Contact Status'),
215b423e 172 'description' => ts('status of contact relative to membership in group'),
e501603b
TO
173 'maxlength' => 8,
174 'size' => CRM_Utils_Type::EIGHT,
a36434b9 175 'where' => 'civicrm_group_contact.status',
522a26c9 176 'table_name' => 'civicrm_group_contact',
177 'entity' => 'GroupContact',
178 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 179 'localizable' => 0,
c3fc2621 180 'html' => [
e501603b 181 'type' => 'Select',
c3fc2621
CW
182 ],
183 'pseudoconstant' => [
e501603b 184 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
e6ca0a57 185 ],
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'location_id' => [
e501603b
TO
189 'name' => 'location_id',
190 'type' => CRM_Utils_Type::T_INT,
c3fc2621 191 'title' => ts('Group Contact Location'),
215b423e 192 'description' => ts('Optional location to associate with this membership'),
a36434b9 193 'where' => 'civicrm_group_contact.location_id',
522a26c9 194 'table_name' => 'civicrm_group_contact',
195 'entity' => 'GroupContact',
196 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 197 'localizable' => 0,
e501603b 198 'FKClassName' => 'CRM_Core_DAO_LocBlock',
a9d0587b 199 'add' => '1.1',
c3fc2621
CW
200 ],
201 'email_id' => [
e501603b
TO
202 'name' => 'email_id',
203 'type' => CRM_Utils_Type::T_INT,
c3fc2621 204 'title' => ts('Group Contact Email'),
215b423e 205 'description' => ts('Optional email to associate with this membership'),
a36434b9 206 'where' => 'civicrm_group_contact.email_id',
522a26c9 207 'table_name' => 'civicrm_group_contact',
208 'entity' => 'GroupContact',
209 'bao' => 'CRM_Contact_BAO_GroupContact',
6a7e5e5d 210 'localizable' => 0,
e501603b 211 'FKClassName' => 'CRM_Core_DAO_Email',
a9d0587b 212 'add' => '1.1',
c3fc2621
CW
213 ],
214 ];
346aaaba 215 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 216 }
346aaaba 217 return Civi::$statics[__CLASS__]['fields'];
e501603b 218 }
c3fc2621 219
e501603b 220 /**
bd8e0b14 221 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
222 *
223 * @return array
bd8e0b14 224 * Array(string $name => string $uniqueName).
e501603b 225 */
c3fc2621 226 public static function &fieldKeys() {
bd8e0b14
TO
227 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
228 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 229 }
bd8e0b14 230 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 231 }
c3fc2621 232
e501603b
TO
233 /**
234 * Returns the names of this table
235 *
236 * @return string
237 */
c3fc2621 238 public static function getTableName() {
e501603b
TO
239 return self::$_tableName;
240 }
c3fc2621 241
e501603b
TO
242 /**
243 * Returns if this table needs to be logged
244 *
c3fc2621 245 * @return bool
e501603b 246 */
c3fc2621 247 public function getLog() {
e501603b
TO
248 return self::$_log;
249 }
c3fc2621 250
e501603b
TO
251 /**
252 * Returns the list of fields that can be imported
253 *
254 * @param bool $prefix
255 *
256 * @return array
257 */
c3fc2621
CW
258 public static function &import($prefix = FALSE) {
259 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact', $prefix, []);
60808919 260 return $r;
e501603b 261 }
c3fc2621 262
e501603b
TO
263 /**
264 * Returns the list of fields that can be exported
265 *
266 * @param bool $prefix
267 *
268 * @return array
269 */
c3fc2621
CW
270 public static function &export($prefix = FALSE) {
271 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact', $prefix, []);
60808919 272 return $r;
e501603b 273 }
c3fc2621 274
e7a6b91a
AS
275 /**
276 * Returns the list of indices
c3fc2621
CW
277 *
278 * @param bool $localize
279 *
280 * @return array
e7a6b91a
AS
281 */
282 public static function indices($localize = TRUE) {
c3fc2621
CW
283 $indices = [
284 'UI_contact_group' => [
e7a6b91a 285 'name' => 'UI_contact_group',
c3fc2621 286 'field' => [
e7a6b91a
AS
287 0 => 'contact_id',
288 1 => 'group_id',
c3fc2621
CW
289 ],
290 'localizable' => FALSE,
291 'unique' => TRUE,
e7a6b91a 292 'sig' => 'civicrm_group_contact::1::contact_id::group_id',
c3fc2621
CW
293 ],
294 ];
e7a6b91a
AS
295 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
296 }
c3fc2621 297
e501603b 298}