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