Merge pull request #23567 from kurund/honor-roll-fixes
[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:f7c8513020809cc974eec784b983a75d)
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|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
39 */
40 public $id;
41
42 /**
43 * FK to civicrm_group
44 *
45 * @var int|string
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
48 */
49 public $group_id;
50
51 /**
52 * FK to civicrm_contact
53 *
54 * @var int|string
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
57 */
58 public $contact_id;
59
60 /**
61 * status of contact relative to membership in group
62 *
63 * @var string|null
64 * (SQL type: varchar(8))
65 * Note that values will be retrieved from the database as a string.
66 */
67 public $status;
68
69 /**
70 * Optional location to associate with this membership
71 *
72 * @var int|string|null
73 * (SQL type: int unsigned)
74 * Note that values will be retrieved from the database as a string.
75 */
76 public $location_id;
77
78 /**
79 * Optional email to associate with this membership
80 *
81 * @var int|string|null
82 * (SQL type: int unsigned)
83 * Note that values will be retrieved from the database as a string.
84 */
85 public $email_id;
86
87 /**
88 * Class constructor.
89 */
90 public function __construct() {
91 $this->__table = 'civicrm_group_contact';
92 parent::__construct();
93 }
94
95 /**
96 * Returns localized title of this entity.
97 *
98 * @param bool $plural
99 * Whether to return the plural version of the title.
100 */
101 public static function getEntityTitle($plural = FALSE) {
102 return $plural ? ts('Group Contacts') : ts('Group Contact');
103 }
104
105 /**
106 * Returns foreign keys and entity references.
107 *
108 * @return array
109 * [CRM_Core_Reference_Interface]
110 */
111 public static function getReferenceColumns() {
112 if (!isset(Civi::$statics[__CLASS__]['links'])) {
113 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
114 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
115 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
116 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_id', 'civicrm_loc_block', 'id');
117 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
118 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
119 }
120 return Civi::$statics[__CLASS__]['links'];
121 }
122
123 /**
124 * Returns all the column names of this table
125 *
126 * @return array
127 */
128 public static function &fields() {
129 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
130 Civi::$statics[__CLASS__]['fields'] = [
131 'id' => [
132 'name' => 'id',
133 'type' => CRM_Utils_Type::T_INT,
134 'title' => ts('Group Contact ID'),
135 'description' => ts('primary key'),
136 'required' => TRUE,
137 'where' => 'civicrm_group_contact.id',
138 'table_name' => 'civicrm_group_contact',
139 'entity' => 'GroupContact',
140 'bao' => 'CRM_Contact_BAO_GroupContact',
141 'localizable' => 0,
142 'html' => [
143 'type' => 'Number',
144 ],
145 'readonly' => TRUE,
146 'add' => '1.1',
147 ],
148 'group_id' => [
149 'name' => 'group_id',
150 'type' => CRM_Utils_Type::T_INT,
151 'title' => ts('Group ID'),
152 'description' => ts('FK to civicrm_group'),
153 'required' => TRUE,
154 'where' => 'civicrm_group_contact.group_id',
155 'table_name' => 'civicrm_group_contact',
156 'entity' => 'GroupContact',
157 'bao' => 'CRM_Contact_BAO_GroupContact',
158 'localizable' => 0,
159 'FKClassName' => 'CRM_Contact_DAO_Group',
160 'html' => [
161 'type' => 'Select',
162 'label' => ts("Group"),
163 ],
164 'pseudoconstant' => [
165 'table' => 'civicrm_group',
166 'keyColumn' => 'id',
167 'labelColumn' => 'title',
168 ],
169 'add' => '1.1',
170 ],
171 'contact_id' => [
172 'name' => 'contact_id',
173 'type' => CRM_Utils_Type::T_INT,
174 'title' => ts('Contact ID'),
175 'description' => ts('FK to civicrm_contact'),
176 'required' => TRUE,
177 'where' => 'civicrm_group_contact.contact_id',
178 'table_name' => 'civicrm_group_contact',
179 'entity' => 'GroupContact',
180 'bao' => 'CRM_Contact_BAO_GroupContact',
181 'localizable' => 0,
182 'FKClassName' => 'CRM_Contact_DAO_Contact',
183 'html' => [
184 'label' => ts("Contact"),
185 ],
186 'add' => '1.1',
187 ],
188 'status' => [
189 'name' => 'status',
190 'type' => CRM_Utils_Type::T_STRING,
191 'title' => ts('Group Contact Status'),
192 'description' => ts('status of contact relative to membership in group'),
193 'maxlength' => 8,
194 'size' => CRM_Utils_Type::EIGHT,
195 'where' => 'civicrm_group_contact.status',
196 'table_name' => 'civicrm_group_contact',
197 'entity' => 'GroupContact',
198 'bao' => 'CRM_Contact_BAO_GroupContact',
199 'localizable' => 0,
200 'html' => [
201 'type' => 'Select',
202 ],
203 'pseudoconstant' => [
204 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
205 ],
206 'add' => '1.1',
207 ],
208 'location_id' => [
209 'name' => 'location_id',
210 'type' => CRM_Utils_Type::T_INT,
211 'title' => ts('Location ID'),
212 'description' => ts('Optional location to associate with this membership'),
213 'where' => 'civicrm_group_contact.location_id',
214 'table_name' => 'civicrm_group_contact',
215 'entity' => 'GroupContact',
216 'bao' => 'CRM_Contact_BAO_GroupContact',
217 'localizable' => 0,
218 'FKClassName' => 'CRM_Core_DAO_LocBlock',
219 'html' => [
220 'label' => ts("Location"),
221 ],
222 'add' => '1.1',
223 ],
224 'email_id' => [
225 'name' => 'email_id',
226 'type' => CRM_Utils_Type::T_INT,
227 'title' => ts('Email ID'),
228 'description' => ts('Optional email to associate with this membership'),
229 'where' => 'civicrm_group_contact.email_id',
230 'table_name' => 'civicrm_group_contact',
231 'entity' => 'GroupContact',
232 'bao' => 'CRM_Contact_BAO_GroupContact',
233 'localizable' => 0,
234 'FKClassName' => 'CRM_Core_DAO_Email',
235 'html' => [
236 'label' => ts("Email"),
237 ],
238 'add' => '1.1',
239 ],
240 ];
241 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
242 }
243 return Civi::$statics[__CLASS__]['fields'];
244 }
245
246 /**
247 * Return a mapping from field-name to the corresponding key (as used in fields()).
248 *
249 * @return array
250 * Array(string $name => string $uniqueName).
251 */
252 public static function &fieldKeys() {
253 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
254 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
255 }
256 return Civi::$statics[__CLASS__]['fieldKeys'];
257 }
258
259 /**
260 * Returns the names of this table
261 *
262 * @return string
263 */
264 public static function getTableName() {
265 return self::$_tableName;
266 }
267
268 /**
269 * Returns if this table needs to be logged
270 *
271 * @return bool
272 */
273 public function getLog() {
274 return self::$_log;
275 }
276
277 /**
278 * Returns the list of fields that can be imported
279 *
280 * @param bool $prefix
281 *
282 * @return array
283 */
284 public static function &import($prefix = FALSE) {
285 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group_contact', $prefix, []);
286 return $r;
287 }
288
289 /**
290 * Returns the list of fields that can be exported
291 *
292 * @param bool $prefix
293 *
294 * @return array
295 */
296 public static function &export($prefix = FALSE) {
297 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group_contact', $prefix, []);
298 return $r;
299 }
300
301 /**
302 * Returns the list of indices
303 *
304 * @param bool $localize
305 *
306 * @return array
307 */
308 public static function indices($localize = TRUE) {
309 $indices = [
310 'UI_contact_group' => [
311 'name' => 'UI_contact_group',
312 'field' => [
313 0 => 'contact_id',
314 1 => 'group_id',
315 ],
316 'localizable' => FALSE,
317 'unique' => TRUE,
318 'sig' => 'civicrm_group_contact::1::contact_id::group_id',
319 ],
320 ];
321 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
322 }
323
324 }