Merge pull request #23419 from chrisgaraffa/contactheader-regions
[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:58fe115e0962f83c3906bce5f663f0fc)
10 */
11
12 /**
13 * Database access object for the Email entity.
14 */
15 class CRM_Core_DAO_Email 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_email';
25
26 /**
27 * Icon associated with this entity.
28 *
29 * @var string
30 */
31 public static $_icon = 'fa-envelope-o';
32
33 /**
34 * Field to show when displaying a record.
35 *
36 * @var string
37 */
38 public static $_labelField = 'email';
39
40 /**
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
42 *
43 * @var bool
44 */
45 public static $_log = TRUE;
46
47 /**
48 * Unique Email ID
49 *
50 * @var int|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
53 */
54 public $id;
55
56 /**
57 * FK to Contact ID
58 *
59 * @var int|string|null
60 * (SQL type: int unsigned)
61 * Note that values will be retrieved from the database as a string.
62 */
63 public $contact_id;
64
65 /**
66 * Which Location does this email belong to.
67 *
68 * @var int|string|null
69 * (SQL type: int unsigned)
70 * Note that values will be retrieved from the database as a string.
71 */
72 public $location_type_id;
73
74 /**
75 * Email address
76 *
77 * @var string|null
78 * (SQL type: varchar(254))
79 * Note that values will be retrieved from the database as a string.
80 */
81 public $email;
82
83 /**
84 * Is this the primary email address
85 *
86 * @var bool|string
87 * (SQL type: tinyint)
88 * Note that values will be retrieved from the database as a string.
89 */
90 public $is_primary;
91
92 /**
93 * Is this the billing?
94 *
95 * @var bool|string
96 * (SQL type: tinyint)
97 * Note that values will be retrieved from the database as a string.
98 */
99 public $is_billing;
100
101 /**
102 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
103 *
104 * @var int|string
105 * (SQL type: int unsigned)
106 * Note that values will be retrieved from the database as a string.
107 */
108 public $on_hold;
109
110 /**
111 * Is this address for bulk mail ?
112 *
113 * @var bool|string
114 * (SQL type: tinyint)
115 * Note that values will be retrieved from the database as a string.
116 */
117 public $is_bulkmail;
118
119 /**
120 * When the address went on bounce hold
121 *
122 * @var string|null
123 * (SQL type: datetime)
124 * Note that values will be retrieved from the database as a string.
125 */
126 public $hold_date;
127
128 /**
129 * When the address bounce status was last reset
130 *
131 * @var string|null
132 * (SQL type: datetime)
133 * Note that values will be retrieved from the database as a string.
134 */
135 public $reset_date;
136
137 /**
138 * Text formatted signature for the email.
139 *
140 * @var string|null
141 * (SQL type: text)
142 * Note that values will be retrieved from the database as a string.
143 */
144 public $signature_text;
145
146 /**
147 * HTML formatted signature for the email.
148 *
149 * @var string|null
150 * (SQL type: text)
151 * Note that values will be retrieved from the database as a string.
152 */
153 public $signature_html;
154
155 /**
156 * Class constructor.
157 */
158 public function __construct() {
159 $this->__table = 'civicrm_email';
160 parent::__construct();
161 }
162
163 /**
164 * Returns localized title of this entity.
165 *
166 * @param bool $plural
167 * Whether to return the plural version of the title.
168 */
169 public static function getEntityTitle($plural = FALSE) {
170 return $plural ? ts('Emails') : ts('Email');
171 }
172
173 /**
174 * Returns foreign keys and entity references.
175 *
176 * @return array
177 * [CRM_Core_Reference_Interface]
178 */
179 public static function getReferenceColumns() {
180 if (!isset(Civi::$statics[__CLASS__]['links'])) {
181 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
182 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
183 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
184 }
185 return Civi::$statics[__CLASS__]['links'];
186 }
187
188 /**
189 * Returns all the column names of this table
190 *
191 * @return array
192 */
193 public static function &fields() {
194 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
195 Civi::$statics[__CLASS__]['fields'] = [
196 'id' => [
197 'name' => 'id',
198 'type' => CRM_Utils_Type::T_INT,
199 'title' => ts('Email ID'),
200 'description' => ts('Unique Email ID'),
201 'required' => TRUE,
202 'where' => 'civicrm_email.id',
203 'table_name' => 'civicrm_email',
204 'entity' => 'Email',
205 'bao' => 'CRM_Core_BAO_Email',
206 'localizable' => 0,
207 'html' => [
208 'type' => 'Number',
209 ],
210 'readonly' => TRUE,
211 'add' => '1.1',
212 ],
213 'contact_id' => [
214 'name' => 'contact_id',
215 'type' => CRM_Utils_Type::T_INT,
216 'title' => ts('Contact ID'),
217 'description' => ts('FK to Contact ID'),
218 'where' => 'civicrm_email.contact_id',
219 'table_name' => 'civicrm_email',
220 'entity' => 'Email',
221 'bao' => 'CRM_Core_BAO_Email',
222 'localizable' => 0,
223 'FKClassName' => 'CRM_Contact_DAO_Contact',
224 'html' => [
225 'label' => ts("Contact"),
226 ],
227 'add' => '2.0',
228 ],
229 'location_type_id' => [
230 'name' => 'location_type_id',
231 'type' => CRM_Utils_Type::T_INT,
232 'title' => ts('Email Location Type'),
233 'description' => ts('Which Location does this email belong to.'),
234 'where' => 'civicrm_email.location_type_id',
235 'table_name' => 'civicrm_email',
236 'entity' => 'Email',
237 'bao' => 'CRM_Core_BAO_Email',
238 'localizable' => 0,
239 'html' => [
240 'type' => 'Select',
241 ],
242 'pseudoconstant' => [
243 'table' => 'civicrm_location_type',
244 'keyColumn' => 'id',
245 'labelColumn' => 'display_name',
246 ],
247 'add' => '2.0',
248 ],
249 'email' => [
250 'name' => 'email',
251 'type' => CRM_Utils_Type::T_STRING,
252 'title' => ts('Email'),
253 'description' => ts('Email address'),
254 'maxlength' => 254,
255 'size' => 30,
256 'import' => TRUE,
257 'where' => 'civicrm_email.email',
258 'headerPattern' => '/e.?mail/i',
259 '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]$/',
260 'export' => TRUE,
261 'rule' => 'email',
262 'table_name' => 'civicrm_email',
263 'entity' => 'Email',
264 'bao' => 'CRM_Core_BAO_Email',
265 'localizable' => 0,
266 'html' => [
267 'type' => 'Text',
268 ],
269 'add' => '1.1',
270 ],
271 'is_primary' => [
272 'name' => 'is_primary',
273 'type' => CRM_Utils_Type::T_BOOLEAN,
274 'title' => ts('Primary email'),
275 'description' => ts('Is this the primary email address'),
276 'required' => TRUE,
277 'where' => 'civicrm_email.is_primary',
278 'default' => '0',
279 'table_name' => 'civicrm_email',
280 'entity' => 'Email',
281 'bao' => 'CRM_Core_BAO_Email',
282 'localizable' => 0,
283 'html' => [
284 'type' => 'Radio',
285 ],
286 'add' => '1.1',
287 ],
288 'is_billing' => [
289 'name' => 'is_billing',
290 'type' => CRM_Utils_Type::T_BOOLEAN,
291 'title' => ts('Is Billing Email?'),
292 'description' => ts('Is this the billing?'),
293 'required' => TRUE,
294 'where' => 'civicrm_email.is_billing',
295 'default' => '0',
296 'table_name' => 'civicrm_email',
297 'entity' => 'Email',
298 'bao' => 'CRM_Core_BAO_Email',
299 'localizable' => 0,
300 'add' => '2.0',
301 ],
302 'on_hold' => [
303 'name' => 'on_hold',
304 'type' => CRM_Utils_Type::T_INT,
305 'title' => ts('On Hold'),
306 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
307 'required' => TRUE,
308 'where' => 'civicrm_email.on_hold',
309 'export' => TRUE,
310 'default' => '0',
311 'table_name' => 'civicrm_email',
312 'entity' => 'Email',
313 'bao' => 'CRM_Core_BAO_Email',
314 'localizable' => 0,
315 'html' => [
316 'type' => 'Select',
317 ],
318 'pseudoconstant' => [
319 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
320 ],
321 'add' => '1.1',
322 ],
323 'is_bulkmail' => [
324 'name' => 'is_bulkmail',
325 'type' => CRM_Utils_Type::T_BOOLEAN,
326 'title' => ts('Use for Bulk Mail'),
327 'description' => ts('Is this address for bulk mail ?'),
328 'required' => TRUE,
329 'where' => 'civicrm_email.is_bulkmail',
330 'export' => TRUE,
331 'default' => '0',
332 'table_name' => 'civicrm_email',
333 'entity' => 'Email',
334 'bao' => 'CRM_Core_BAO_Email',
335 'localizable' => 0,
336 'add' => '1.9',
337 ],
338 'hold_date' => [
339 'name' => 'hold_date',
340 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
341 'title' => ts('Hold Date'),
342 'description' => ts('When the address went on bounce hold'),
343 'where' => 'civicrm_email.hold_date',
344 'table_name' => 'civicrm_email',
345 'entity' => 'Email',
346 'bao' => 'CRM_Core_BAO_Email',
347 'localizable' => 0,
348 'html' => [
349 'type' => 'Select Date',
350 'formatType' => 'activityDateTime',
351 'label' => ts("Hold Date"),
352 ],
353 'add' => '1.1',
354 ],
355 'reset_date' => [
356 'name' => 'reset_date',
357 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
358 'title' => ts('Reset Date'),
359 'description' => ts('When the address bounce status was last reset'),
360 'where' => 'civicrm_email.reset_date',
361 'table_name' => 'civicrm_email',
362 'entity' => 'Email',
363 'bao' => 'CRM_Core_BAO_Email',
364 'localizable' => 0,
365 'html' => [
366 'type' => 'Select Date',
367 'formatType' => 'activityDateTime',
368 'label' => ts("Reset Date"),
369 ],
370 'add' => '1.1',
371 ],
372 'signature_text' => [
373 'name' => 'signature_text',
374 'type' => CRM_Utils_Type::T_TEXT,
375 'title' => ts('Signature Text'),
376 'description' => ts('Text formatted signature for the email.'),
377 'import' => TRUE,
378 'where' => 'civicrm_email.signature_text',
379 'export' => TRUE,
380 'default' => NULL,
381 'table_name' => 'civicrm_email',
382 'entity' => 'Email',
383 'bao' => 'CRM_Core_BAO_Email',
384 'localizable' => 0,
385 'html' => [
386 'label' => ts("Signature Text"),
387 ],
388 'add' => '3.2',
389 ],
390 'signature_html' => [
391 'name' => 'signature_html',
392 'type' => CRM_Utils_Type::T_TEXT,
393 'title' => ts('Signature Html'),
394 'description' => ts('HTML formatted signature for the email.'),
395 'import' => TRUE,
396 'where' => 'civicrm_email.signature_html',
397 'export' => TRUE,
398 'default' => NULL,
399 'table_name' => 'civicrm_email',
400 'entity' => 'Email',
401 'bao' => 'CRM_Core_BAO_Email',
402 'localizable' => 0,
403 'html' => [
404 'label' => ts("Signature HTML"),
405 ],
406 'add' => '3.2',
407 ],
408 ];
409 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
410 }
411 return Civi::$statics[__CLASS__]['fields'];
412 }
413
414 /**
415 * Return a mapping from field-name to the corresponding key (as used in fields()).
416 *
417 * @return array
418 * Array(string $name => string $uniqueName).
419 */
420 public static function &fieldKeys() {
421 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
422 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
423 }
424 return Civi::$statics[__CLASS__]['fieldKeys'];
425 }
426
427 /**
428 * Returns the names of this table
429 *
430 * @return string
431 */
432 public static function getTableName() {
433 return self::$_tableName;
434 }
435
436 /**
437 * Returns if this table needs to be logged
438 *
439 * @return bool
440 */
441 public function getLog() {
442 return self::$_log;
443 }
444
445 /**
446 * Returns the list of fields that can be imported
447 *
448 * @param bool $prefix
449 *
450 * @return array
451 */
452 public static function &import($prefix = FALSE) {
453 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
454 return $r;
455 }
456
457 /**
458 * Returns the list of fields that can be exported
459 *
460 * @param bool $prefix
461 *
462 * @return array
463 */
464 public static function &export($prefix = FALSE) {
465 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
466 return $r;
467 }
468
469 /**
470 * Returns the list of indices
471 *
472 * @param bool $localize
473 *
474 * @return array
475 */
476 public static function indices($localize = TRUE) {
477 $indices = [
478 'index_location_type' => [
479 'name' => 'index_location_type',
480 'field' => [
481 0 => 'location_type_id',
482 ],
483 'localizable' => FALSE,
484 'sig' => 'civicrm_email::0::location_type_id',
485 ],
486 'UI_email' => [
487 'name' => 'UI_email',
488 'field' => [
489 0 => 'email',
490 ],
491 'localizable' => FALSE,
492 'sig' => 'civicrm_email::0::email',
493 ],
494 'index_is_primary' => [
495 'name' => 'index_is_primary',
496 'field' => [
497 0 => 'is_primary',
498 ],
499 'localizable' => FALSE,
500 'sig' => 'civicrm_email::0::is_primary',
501 ],
502 'index_is_billing' => [
503 'name' => 'index_is_billing',
504 'field' => [
505 0 => 'is_billing',
506 ],
507 'localizable' => FALSE,
508 'sig' => 'civicrm_email::0::is_billing',
509 ],
510 ];
511 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
512 }
513
514 }