Merge pull request #14326 from civicrm/5.14
[civicrm-core.git] / CRM / Contact / DAO / GroupContact.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/GroupContact.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:abb2a96c7fd72f93619b605fbb11b4b5)
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 foreign keys and entity references.
83 *
84 * @return array
85 * [CRM_Core_Reference_Interface]
86 */
87 public static function getReferenceColumns() {
88 if (!isset(Civi::$statics[__CLASS__]['links'])) {
89 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
90 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
91 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
92 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_id', 'civicrm_loc_block', 'id');
93 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
94 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
95 }
96 return Civi::$statics[__CLASS__]['links'];
97 }
98
99 /**
100 * Returns all the column names of this table
101 *
102 * @return array
103 */
104 public static function &fields() {
105 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
106 Civi::$statics[__CLASS__]['fields'] = [
107 'id' => [
108 'name' => 'id',
109 'type' => CRM_Utils_Type::T_INT,
110 'title' => ts('Group Contact ID'),
111 'description' => ts('primary key'),
112 'required' => TRUE,
113 'where' => 'civicrm_group_contact.id',
114 'table_name' => 'civicrm_group_contact',
115 'entity' => 'GroupContact',
116 'bao' => 'CRM_Contact_BAO_GroupContact',
117 'localizable' => 0,
118 ],
119 'group_id' => [
120 'name' => 'group_id',
121 'type' => CRM_Utils_Type::T_INT,
122 'title' => ts('Group ID'),
123 'description' => ts('FK to civicrm_group'),
124 'required' => TRUE,
125 'where' => 'civicrm_group_contact.group_id',
126 'table_name' => 'civicrm_group_contact',
127 'entity' => 'GroupContact',
128 'bao' => 'CRM_Contact_BAO_GroupContact',
129 'localizable' => 0,
130 'FKClassName' => 'CRM_Contact_DAO_Group',
131 'html' => [
132 'type' => 'Select',
133 ],
134 'pseudoconstant' => [
135 'table' => 'civicrm_group',
136 'keyColumn' => 'id',
137 'labelColumn' => 'title',
138 ],
139 ],
140 'contact_id' => [
141 'name' => 'contact_id',
142 'type' => CRM_Utils_Type::T_INT,
143 'title' => ts('Contact ID'),
144 'description' => ts('FK to civicrm_contact'),
145 'required' => TRUE,
146 'where' => 'civicrm_group_contact.contact_id',
147 'table_name' => 'civicrm_group_contact',
148 'entity' => 'GroupContact',
149 'bao' => 'CRM_Contact_BAO_GroupContact',
150 'localizable' => 0,
151 'FKClassName' => 'CRM_Contact_DAO_Contact',
152 ],
153 'status' => [
154 'name' => 'status',
155 'type' => CRM_Utils_Type::T_STRING,
156 'title' => ts('Group Contact Status'),
157 'description' => ts('status of contact relative to membership in group'),
158 'maxlength' => 8,
159 'size' => CRM_Utils_Type::EIGHT,
160 'where' => 'civicrm_group_contact.status',
161 'table_name' => 'civicrm_group_contact',
162 'entity' => 'GroupContact',
163 'bao' => 'CRM_Contact_BAO_GroupContact',
164 'localizable' => 0,
165 'html' => [
166 'type' => 'Select',
167 ],
168 'pseudoconstant' => [
169 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
170 ],
171 ],
172 'location_id' => [
173 'name' => 'location_id',
174 'type' => CRM_Utils_Type::T_INT,
175 'title' => ts('Group Contact Location'),
176 'description' => ts('Optional location to associate with this membership'),
177 'where' => 'civicrm_group_contact.location_id',
178 'table_name' => 'civicrm_group_contact',
179 'entity' => 'GroupContact',
180 'bao' => 'CRM_Contact_BAO_GroupContact',
181 'localizable' => 0,
182 'FKClassName' => 'CRM_Core_DAO_LocBlock',
183 ],
184 'email_id' => [
185 'name' => 'email_id',
186 'type' => CRM_Utils_Type::T_INT,
187 'title' => ts('Group Contact Email'),
188 'description' => ts('Optional email to associate with this membership'),
189 'where' => 'civicrm_group_contact.email_id',
190 'table_name' => 'civicrm_group_contact',
191 'entity' => 'GroupContact',
192 'bao' => 'CRM_Contact_BAO_GroupContact',
193 'localizable' => 0,
194 'FKClassName' => 'CRM_Core_DAO_Email',
195 ],
196 ];
197 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
198 }
199 return Civi::$statics[__CLASS__]['fields'];
200 }
201
202 /**
203 * Return a mapping from field-name to the corresponding key (as used in fields()).
204 *
205 * @return array
206 * Array(string $name => string $uniqueName).
207 */
208 public static function &fieldKeys() {
209 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
210 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
211 }
212 return Civi::$statics[__CLASS__]['fieldKeys'];
213 }
214
215 /**
216 * Returns the names of this table
217 *
218 * @return string
219 */
220 public static function getTableName() {
221 return self::$_tableName;
222 }
223
224 /**
225 * Returns if this table needs to be logged
226 *
227 * @return bool
228 */
229 public function getLog() {
230 return self::$_log;
231 }
232
233 /**
234 * Returns the list of fields that can be imported
235 *
236 * @param bool $prefix
237 *
238 * @return array
239 */
240 public static function &import($prefix = FALSE) {
241 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact', $prefix, []);
242 return $r;
243 }
244
245 /**
246 * Returns the list of fields that can be exported
247 *
248 * @param bool $prefix
249 *
250 * @return array
251 */
252 public static function &export($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact', $prefix, []);
254 return $r;
255 }
256
257 /**
258 * Returns the list of indices
259 *
260 * @param bool $localize
261 *
262 * @return array
263 */
264 public static function indices($localize = TRUE) {
265 $indices = [
266 'UI_contact_group' => [
267 'name' => 'UI_contact_group',
268 'field' => [
269 0 => 'contact_id',
270 1 => 'group_id',
271 ],
272 'localizable' => FALSE,
273 'unique' => TRUE,
274 'sig' => 'civicrm_group_contact::1::contact_id::group_id',
275 ],
276 ];
277 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
278 }
279
280 }