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