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