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