[NFC] Minor code cleanup
[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:a2d4155bf9e67023136598c9ca86be31)
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 ],
126 'group_id' => [
127 'name' => 'group_id',
128 'type' => CRM_Utils_Type::T_INT,
129 'title' => ts('Group ID'),
130 'description' => ts('FK to civicrm_group'),
131 'required' => TRUE,
132 'where' => 'civicrm_group_contact.group_id',
133 'table_name' => 'civicrm_group_contact',
134 'entity' => 'GroupContact',
135 'bao' => 'CRM_Contact_BAO_GroupContact',
136 'localizable' => 0,
137 'FKClassName' => 'CRM_Contact_DAO_Group',
138 'html' => [
139 'type' => 'Select',
140 ],
141 'pseudoconstant' => [
142 'table' => 'civicrm_group',
143 'keyColumn' => 'id',
144 'labelColumn' => 'title',
145 ],
146 ],
147 'contact_id' => [
148 'name' => 'contact_id',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Contact ID'),
151 'description' => ts('FK to civicrm_contact'),
152 'required' => TRUE,
153 'where' => 'civicrm_group_contact.contact_id',
154 'table_name' => 'civicrm_group_contact',
155 'entity' => 'GroupContact',
156 'bao' => 'CRM_Contact_BAO_GroupContact',
157 'localizable' => 0,
158 'FKClassName' => 'CRM_Contact_DAO_Contact',
159 ],
160 'status' => [
161 'name' => 'status',
162 'type' => CRM_Utils_Type::T_STRING,
163 'title' => ts('Group Contact Status'),
164 'description' => ts('status of contact relative to membership in group'),
165 'maxlength' => 8,
166 'size' => CRM_Utils_Type::EIGHT,
167 'where' => 'civicrm_group_contact.status',
168 'table_name' => 'civicrm_group_contact',
169 'entity' => 'GroupContact',
170 'bao' => 'CRM_Contact_BAO_GroupContact',
171 'localizable' => 0,
172 'html' => [
173 'type' => 'Select',
174 ],
175 'pseudoconstant' => [
176 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
177 ],
178 ],
179 'location_id' => [
180 'name' => 'location_id',
181 'type' => CRM_Utils_Type::T_INT,
182 'title' => ts('Group Contact Location'),
183 'description' => ts('Optional location to associate with this membership'),
184 'where' => 'civicrm_group_contact.location_id',
185 'table_name' => 'civicrm_group_contact',
186 'entity' => 'GroupContact',
187 'bao' => 'CRM_Contact_BAO_GroupContact',
188 'localizable' => 0,
189 'FKClassName' => 'CRM_Core_DAO_LocBlock',
190 ],
191 'email_id' => [
192 'name' => 'email_id',
193 'type' => CRM_Utils_Type::T_INT,
194 'title' => ts('Group Contact Email'),
195 'description' => ts('Optional email to associate with this membership'),
196 'where' => 'civicrm_group_contact.email_id',
197 'table_name' => 'civicrm_group_contact',
198 'entity' => 'GroupContact',
199 'bao' => 'CRM_Contact_BAO_GroupContact',
200 'localizable' => 0,
201 'FKClassName' => 'CRM_Core_DAO_Email',
202 ],
203 ];
204 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
205 }
206 return Civi::$statics[__CLASS__]['fields'];
207 }
208
209 /**
210 * Return a mapping from field-name to the corresponding key (as used in fields()).
211 *
212 * @return array
213 * Array(string $name => string $uniqueName).
214 */
215 public static function &fieldKeys() {
216 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
217 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
218 }
219 return Civi::$statics[__CLASS__]['fieldKeys'];
220 }
221
222 /**
223 * Returns the names of this table
224 *
225 * @return string
226 */
227 public static function getTableName() {
228 return self::$_tableName;
229 }
230
231 /**
232 * Returns if this table needs to be logged
233 *
234 * @return bool
235 */
236 public function getLog() {
237 return self::$_log;
238 }
239
240 /**
241 * Returns the list of fields that can be imported
242 *
243 * @param bool $prefix
244 *
245 * @return array
246 */
247 public static function &import($prefix = FALSE) {
248 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact', $prefix, []);
249 return $r;
250 }
251
252 /**
253 * Returns the list of fields that can be exported
254 *
255 * @param bool $prefix
256 *
257 * @return array
258 */
259 public static function &export($prefix = FALSE) {
260 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact', $prefix, []);
261 return $r;
262 }
263
264 /**
265 * Returns the list of indices
266 *
267 * @param bool $localize
268 *
269 * @return array
270 */
271 public static function indices($localize = TRUE) {
272 $indices = [
273 'UI_contact_group' => [
274 'name' => 'UI_contact_group',
275 'field' => [
276 0 => 'contact_id',
277 1 => 'group_id',
278 ],
279 'localizable' => FALSE,
280 'unique' => TRUE,
281 'sig' => 'civicrm_group_contact::1::contact_id::group_id',
282 ],
283 ];
284 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
285 }
286
287 }