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