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