Merge pull request #16098 from MegaphoneJon/event-23-correct
[civicrm-core.git] / CRM / Core / DAO / Email.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ae76175a9d3e57bc555ce90cac672e73)
10 */
11
12 /**
13 * Database access object for the Email entity.
14 */
15 class CRM_Core_DAO_Email extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_email';
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 * Unique Email ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * FK to Contact ID
40 *
41 * @var int
42 */
43 public $contact_id;
44
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int
49 */
50 public $location_type_id;
51
52 /**
53 * Email address
54 *
55 * @var string
56 */
57 public $email;
58
59 /**
60 * Is this the primary email address
61 *
62 * @var bool
63 */
64 public $is_primary;
65
66 /**
67 * Is this the billing?
68 *
69 * @var bool
70 */
71 public $is_billing;
72
73 /**
74 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
75 *
76 * @var int
77 */
78 public $on_hold;
79
80 /**
81 * Is this address for bulk mail ?
82 *
83 * @var bool
84 */
85 public $is_bulkmail;
86
87 /**
88 * When the address went on bounce hold
89 *
90 * @var datetime
91 */
92 public $hold_date;
93
94 /**
95 * When the address bounce status was last reset
96 *
97 * @var datetime
98 */
99 public $reset_date;
100
101 /**
102 * Text formatted signature for the email.
103 *
104 * @var text
105 */
106 public $signature_text;
107
108 /**
109 * HTML formatted signature for the email.
110 *
111 * @var text
112 */
113 public $signature_html;
114
115 /**
116 * Class constructor.
117 */
118 public function __construct() {
119 $this->__table = 'civicrm_email';
120 parent::__construct();
121 }
122
123 /**
124 * Returns foreign keys and entity references.
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
129 public static function getReferenceColumns() {
130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
134 }
135 return Civi::$statics[__CLASS__]['links'];
136 }
137
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
143 public static function &fields() {
144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Email ID'),
150 'description' => ts('Unique Email ID'),
151 'required' => TRUE,
152 'where' => 'civicrm_email.id',
153 'table_name' => 'civicrm_email',
154 'entity' => 'Email',
155 'bao' => 'CRM_Core_BAO_Email',
156 'localizable' => 0,
157 ],
158 'contact_id' => [
159 'name' => 'contact_id',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Email Contact'),
162 'description' => ts('FK to Contact ID'),
163 'where' => 'civicrm_email.contact_id',
164 'table_name' => 'civicrm_email',
165 'entity' => 'Email',
166 'bao' => 'CRM_Core_BAO_Email',
167 'localizable' => 0,
168 'FKClassName' => 'CRM_Contact_DAO_Contact',
169 ],
170 'location_type_id' => [
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type::T_INT,
173 'title' => ts('Email Location Type'),
174 'description' => ts('Which Location does this email belong to.'),
175 'where' => 'civicrm_email.location_type_id',
176 'table_name' => 'civicrm_email',
177 'entity' => 'Email',
178 'bao' => 'CRM_Core_BAO_Email',
179 'localizable' => 0,
180 'html' => [
181 'type' => 'Select',
182 ],
183 'pseudoconstant' => [
184 'table' => 'civicrm_location_type',
185 'keyColumn' => 'id',
186 'labelColumn' => 'display_name',
187 ],
188 ],
189 'email' => [
190 'name' => 'email',
191 'type' => CRM_Utils_Type::T_STRING,
192 'title' => ts('Email'),
193 'description' => ts('Email address'),
194 'maxlength' => 254,
195 'size' => 30,
196 'import' => TRUE,
197 'where' => 'civicrm_email.email',
198 'headerPattern' => '/e.?mail/i',
199 'dataPattern' => '/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/',
200 'export' => TRUE,
201 'rule' => 'email',
202 'table_name' => 'civicrm_email',
203 'entity' => 'Email',
204 'bao' => 'CRM_Core_BAO_Email',
205 'localizable' => 0,
206 'html' => [
207 'type' => 'Text',
208 ],
209 ],
210 'is_primary' => [
211 'name' => 'is_primary',
212 'type' => CRM_Utils_Type::T_BOOLEAN,
213 'title' => ts('Primary email'),
214 'description' => ts('Is this the primary email address'),
215 'where' => 'civicrm_email.is_primary',
216 'default' => '0',
217 'table_name' => 'civicrm_email',
218 'entity' => 'Email',
219 'bao' => 'CRM_Core_BAO_Email',
220 'localizable' => 0,
221 'html' => [
222 'type' => 'Radio',
223 ],
224 ],
225 'is_billing' => [
226 'name' => 'is_billing',
227 'type' => CRM_Utils_Type::T_BOOLEAN,
228 'title' => ts('Is Billing Email?'),
229 'description' => ts('Is this the billing?'),
230 'where' => 'civicrm_email.is_billing',
231 'default' => '0',
232 'table_name' => 'civicrm_email',
233 'entity' => 'Email',
234 'bao' => 'CRM_Core_BAO_Email',
235 'localizable' => 0,
236 ],
237 'on_hold' => [
238 'name' => 'on_hold',
239 'type' => CRM_Utils_Type::T_INT,
240 'title' => ts('On Hold'),
241 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
242 'required' => TRUE,
243 'where' => 'civicrm_email.on_hold',
244 'export' => TRUE,
245 'default' => '0',
246 'table_name' => 'civicrm_email',
247 'entity' => 'Email',
248 'bao' => 'CRM_Core_BAO_Email',
249 'localizable' => 0,
250 'html' => [
251 'type' => 'Select',
252 ],
253 'pseudoconstant' => [
254 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
255 ],
256 ],
257 'is_bulkmail' => [
258 'name' => 'is_bulkmail',
259 'type' => CRM_Utils_Type::T_BOOLEAN,
260 'title' => ts('Use for Bulk Mail'),
261 'description' => ts('Is this address for bulk mail ?'),
262 'required' => TRUE,
263 'where' => 'civicrm_email.is_bulkmail',
264 'export' => TRUE,
265 'default' => '0',
266 'table_name' => 'civicrm_email',
267 'entity' => 'Email',
268 'bao' => 'CRM_Core_BAO_Email',
269 'localizable' => 0,
270 ],
271 'hold_date' => [
272 'name' => 'hold_date',
273 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
274 'title' => ts('Hold Date'),
275 'description' => ts('When the address went on bounce hold'),
276 'where' => 'civicrm_email.hold_date',
277 'table_name' => 'civicrm_email',
278 'entity' => 'Email',
279 'bao' => 'CRM_Core_BAO_Email',
280 'localizable' => 0,
281 ],
282 'reset_date' => [
283 'name' => 'reset_date',
284 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
285 'title' => ts('Reset Date'),
286 'description' => ts('When the address bounce status was last reset'),
287 'where' => 'civicrm_email.reset_date',
288 'table_name' => 'civicrm_email',
289 'entity' => 'Email',
290 'bao' => 'CRM_Core_BAO_Email',
291 'localizable' => 0,
292 ],
293 'signature_text' => [
294 'name' => 'signature_text',
295 'type' => CRM_Utils_Type::T_TEXT,
296 'title' => ts('Signature Text'),
297 'description' => ts('Text formatted signature for the email.'),
298 'import' => TRUE,
299 'where' => 'civicrm_email.signature_text',
300 'export' => TRUE,
301 'default' => 'NULL',
302 'table_name' => 'civicrm_email',
303 'entity' => 'Email',
304 'bao' => 'CRM_Core_BAO_Email',
305 'localizable' => 0,
306 ],
307 'signature_html' => [
308 'name' => 'signature_html',
309 'type' => CRM_Utils_Type::T_TEXT,
310 'title' => ts('Signature Html'),
311 'description' => ts('HTML formatted signature for the email.'),
312 'import' => TRUE,
313 'where' => 'civicrm_email.signature_html',
314 'export' => TRUE,
315 'default' => 'NULL',
316 'table_name' => 'civicrm_email',
317 'entity' => 'Email',
318 'bao' => 'CRM_Core_BAO_Email',
319 'localizable' => 0,
320 ],
321 ];
322 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
323 }
324 return Civi::$statics[__CLASS__]['fields'];
325 }
326
327 /**
328 * Return a mapping from field-name to the corresponding key (as used in fields()).
329 *
330 * @return array
331 * Array(string $name => string $uniqueName).
332 */
333 public static function &fieldKeys() {
334 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
335 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
336 }
337 return Civi::$statics[__CLASS__]['fieldKeys'];
338 }
339
340 /**
341 * Returns the names of this table
342 *
343 * @return string
344 */
345 public static function getTableName() {
346 return self::$_tableName;
347 }
348
349 /**
350 * Returns if this table needs to be logged
351 *
352 * @return bool
353 */
354 public function getLog() {
355 return self::$_log;
356 }
357
358 /**
359 * Returns the list of fields that can be imported
360 *
361 * @param bool $prefix
362 *
363 * @return array
364 */
365 public static function &import($prefix = FALSE) {
366 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
367 return $r;
368 }
369
370 /**
371 * Returns the list of fields that can be exported
372 *
373 * @param bool $prefix
374 *
375 * @return array
376 */
377 public static function &export($prefix = FALSE) {
378 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
379 return $r;
380 }
381
382 /**
383 * Returns the list of indices
384 *
385 * @param bool $localize
386 *
387 * @return array
388 */
389 public static function indices($localize = TRUE) {
390 $indices = [
391 'index_location_type' => [
392 'name' => 'index_location_type',
393 'field' => [
394 0 => 'location_type_id',
395 ],
396 'localizable' => FALSE,
397 'sig' => 'civicrm_email::0::location_type_id',
398 ],
399 'UI_email' => [
400 'name' => 'UI_email',
401 'field' => [
402 0 => 'email',
403 ],
404 'localizable' => FALSE,
405 'sig' => 'civicrm_email::0::email',
406 ],
407 'index_is_primary' => [
408 'name' => 'index_is_primary',
409 'field' => [
410 0 => 'is_primary',
411 ],
412 'localizable' => FALSE,
413 'sig' => 'civicrm_email::0::is_primary',
414 ],
415 'index_is_billing' => [
416 'name' => 'index_is_billing',
417 'field' => [
418 0 => 'is_billing',
419 ],
420 'localizable' => FALSE,
421 'sig' => 'civicrm_email::0::is_billing',
422 ],
423 ];
424 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
425 }
426
427 }