Regenerate DAO files
[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
2cbbebe8 9 * (GenCodeChecksum:4587ad732a1c0eee767b2180c1a79dcf)
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 ],
a9d0587b 186 'add' => '1.1',
c3fc2621
CW
187 ],
188 'contact_id' => [
e501603b
TO
189 'name' => 'contact_id',
190 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 191 'title' => ts('Contact ID'),
215b423e 192 'description' => ts('FK to Contact ID'),
a36434b9 193 'where' => 'civicrm_email.contact_id',
522a26c9 194 'table_name' => 'civicrm_email',
195 'entity' => 'Email',
196 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 197 'localizable' => 0,
e501603b 198 'FKClassName' => 'CRM_Contact_DAO_Contact',
2cbbebe8
A
199 'html' => [
200 'label' => ts("Contact"),
201 ],
a9d0587b 202 'add' => '2.0',
c3fc2621
CW
203 ],
204 'location_type_id' => [
e501603b
TO
205 'name' => 'location_type_id',
206 'type' => CRM_Utils_Type::T_INT,
c3fc2621 207 'title' => ts('Email Location Type'),
215b423e 208 'description' => ts('Which Location does this email belong to.'),
a36434b9 209 'where' => 'civicrm_email.location_type_id',
522a26c9 210 'table_name' => 'civicrm_email',
211 'entity' => 'Email',
212 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 213 'localizable' => 0,
c3fc2621 214 'html' => [
e501603b 215 'type' => 'Select',
c3fc2621
CW
216 ],
217 'pseudoconstant' => [
e501603b
TO
218 'table' => 'civicrm_location_type',
219 'keyColumn' => 'id',
220 'labelColumn' => 'display_name',
e6ca0a57 221 ],
a9d0587b 222 'add' => '2.0',
c3fc2621
CW
223 ],
224 'email' => [
e501603b
TO
225 'name' => 'email',
226 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 227 'title' => ts('Email'),
215b423e 228 'description' => ts('Email address'),
e501603b
TO
229 'maxlength' => 254,
230 'size' => 30,
c3fc2621 231 'import' => TRUE,
e501603b
TO
232 'where' => 'civicrm_email.email',
233 'headerPattern' => '/e.?mail/i',
234 '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 235 'export' => TRUE,
e501603b 236 'rule' => 'email',
522a26c9 237 'table_name' => 'civicrm_email',
238 'entity' => 'Email',
239 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 240 'localizable' => 0,
c3fc2621 241 'html' => [
e501603b 242 'type' => 'Text',
c3fc2621 243 ],
a9d0587b 244 'add' => '1.1',
c3fc2621
CW
245 ],
246 'is_primary' => [
e501603b
TO
247 'name' => 'is_primary',
248 'type' => CRM_Utils_Type::T_BOOLEAN,
b6673dcd
CW
249 'title' => ts('Primary email'),
250 'description' => ts('Is this the primary email address'),
a36434b9 251 'where' => 'civicrm_email.is_primary',
45a83e42 252 'default' => '0',
522a26c9 253 'table_name' => 'civicrm_email',
254 'entity' => 'Email',
255 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 256 'localizable' => 0,
b6673dcd
CW
257 'html' => [
258 'type' => 'Radio',
259 ],
a9d0587b 260 'add' => '1.1',
c3fc2621
CW
261 ],
262 'is_billing' => [
e501603b
TO
263 'name' => 'is_billing',
264 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 265 'title' => ts('Is Billing Email?'),
215b423e 266 'description' => ts('Is this the billing?'),
a36434b9 267 'where' => 'civicrm_email.is_billing',
45a83e42 268 'default' => '0',
522a26c9 269 'table_name' => 'civicrm_email',
270 'entity' => 'Email',
271 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 272 'localizable' => 0,
a9d0587b 273 'add' => '2.0',
c3fc2621
CW
274 ],
275 'on_hold' => [
e501603b 276 'name' => 'on_hold',
f61d1b83 277 'type' => CRM_Utils_Type::T_INT,
c3fc2621 278 'title' => ts('On Hold'),
215b423e 279 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
c3fc2621 280 'required' => TRUE,
e501603b 281 'where' => 'civicrm_email.on_hold',
a36434b9 282 'export' => TRUE,
45a83e42 283 'default' => '0',
522a26c9 284 'table_name' => 'civicrm_email',
285 'entity' => 'Email',
286 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 287 'localizable' => 0,
c3fc2621 288 'html' => [
f61d1b83 289 'type' => 'Select',
c3fc2621 290 ],
f61d1b83
AS
291 'pseudoconstant' => [
292 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
e6ca0a57 293 ],
a9d0587b 294 'add' => '1.1',
c3fc2621
CW
295 ],
296 'is_bulkmail' => [
e501603b
TO
297 'name' => 'is_bulkmail',
298 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 299 'title' => ts('Use for Bulk Mail'),
215b423e 300 'description' => ts('Is this address for bulk mail ?'),
c3fc2621 301 'required' => TRUE,
e501603b 302 'where' => 'civicrm_email.is_bulkmail',
a36434b9 303 'export' => TRUE,
45a83e42 304 'default' => '0',
522a26c9 305 'table_name' => 'civicrm_email',
306 'entity' => 'Email',
307 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 308 'localizable' => 0,
a9d0587b 309 'add' => '1.9',
c3fc2621
CW
310 ],
311 'hold_date' => [
e501603b
TO
312 'name' => 'hold_date',
313 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 314 'title' => ts('Hold Date'),
215b423e 315 'description' => ts('When the address went on bounce hold'),
a36434b9 316 'where' => 'civicrm_email.hold_date',
522a26c9 317 'table_name' => 'civicrm_email',
318 'entity' => 'Email',
319 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 320 'localizable' => 0,
a9d0587b 321 'add' => '1.1',
c3fc2621
CW
322 ],
323 'reset_date' => [
e501603b
TO
324 'name' => 'reset_date',
325 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 326 'title' => ts('Reset Date'),
215b423e 327 'description' => ts('When the address bounce status was last reset'),
a36434b9 328 'where' => 'civicrm_email.reset_date',
522a26c9 329 'table_name' => 'civicrm_email',
330 'entity' => 'Email',
331 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 332 'localizable' => 0,
a9d0587b 333 'add' => '1.1',
c3fc2621
CW
334 ],
335 'signature_text' => [
e501603b
TO
336 'name' => 'signature_text',
337 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 338 'title' => ts('Signature Text'),
215b423e 339 'description' => ts('Text formatted signature for the email.'),
c3fc2621 340 'import' => TRUE,
e501603b 341 'where' => 'civicrm_email.signature_text',
c3fc2621 342 'export' => TRUE,
e501603b 343 'default' => 'NULL',
522a26c9 344 'table_name' => 'civicrm_email',
345 'entity' => 'Email',
346 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 347 'localizable' => 0,
a9d0587b 348 'add' => '3.2',
c3fc2621
CW
349 ],
350 'signature_html' => [
e501603b
TO
351 'name' => 'signature_html',
352 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 353 'title' => ts('Signature Html'),
215b423e 354 'description' => ts('HTML formatted signature for the email.'),
c3fc2621 355 'import' => TRUE,
e501603b 356 'where' => 'civicrm_email.signature_html',
c3fc2621 357 'export' => TRUE,
e501603b 358 'default' => 'NULL',
522a26c9 359 'table_name' => 'civicrm_email',
360 'entity' => 'Email',
361 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 362 'localizable' => 0,
a9d0587b 363 'add' => '3.2',
c3fc2621
CW
364 ],
365 ];
346aaaba 366 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 367 }
346aaaba 368 return Civi::$statics[__CLASS__]['fields'];
e501603b 369 }
c3fc2621 370
e501603b 371 /**
bd8e0b14 372 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
373 *
374 * @return array
bd8e0b14 375 * Array(string $name => string $uniqueName).
e501603b 376 */
c3fc2621 377 public static function &fieldKeys() {
bd8e0b14
TO
378 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
379 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 380 }
bd8e0b14 381 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 382 }
c3fc2621 383
e501603b
TO
384 /**
385 * Returns the names of this table
386 *
387 * @return string
388 */
c3fc2621 389 public static function getTableName() {
e501603b
TO
390 return self::$_tableName;
391 }
c3fc2621 392
e501603b
TO
393 /**
394 * Returns if this table needs to be logged
395 *
c3fc2621 396 * @return bool
e501603b 397 */
c3fc2621 398 public function getLog() {
e501603b
TO
399 return self::$_log;
400 }
c3fc2621 401
e501603b
TO
402 /**
403 * Returns the list of fields that can be imported
404 *
405 * @param bool $prefix
406 *
407 * @return array
408 */
c3fc2621
CW
409 public static function &import($prefix = FALSE) {
410 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
60808919 411 return $r;
e501603b 412 }
c3fc2621 413
e501603b
TO
414 /**
415 * Returns the list of fields that can be exported
416 *
417 * @param bool $prefix
418 *
419 * @return array
420 */
c3fc2621
CW
421 public static function &export($prefix = FALSE) {
422 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
60808919 423 return $r;
e501603b 424 }
c3fc2621 425
e7a6b91a
AS
426 /**
427 * Returns the list of indices
c3fc2621
CW
428 *
429 * @param bool $localize
430 *
431 * @return array
e7a6b91a
AS
432 */
433 public static function indices($localize = TRUE) {
c3fc2621
CW
434 $indices = [
435 'index_location_type' => [
e7a6b91a 436 'name' => 'index_location_type',
c3fc2621 437 'field' => [
e7a6b91a 438 0 => 'location_type_id',
c3fc2621
CW
439 ],
440 'localizable' => FALSE,
e7a6b91a 441 'sig' => 'civicrm_email::0::location_type_id',
c3fc2621
CW
442 ],
443 'UI_email' => [
e7a6b91a 444 'name' => 'UI_email',
c3fc2621 445 'field' => [
e7a6b91a 446 0 => 'email',
c3fc2621
CW
447 ],
448 'localizable' => FALSE,
e7a6b91a 449 'sig' => 'civicrm_email::0::email',
c3fc2621
CW
450 ],
451 'index_is_primary' => [
e7a6b91a 452 'name' => 'index_is_primary',
c3fc2621 453 'field' => [
e7a6b91a 454 0 => 'is_primary',
c3fc2621
CW
455 ],
456 'localizable' => FALSE,
e7a6b91a 457 'sig' => 'civicrm_email::0::is_primary',
c3fc2621
CW
458 ],
459 'index_is_billing' => [
e7a6b91a 460 'name' => 'index_is_billing',
c3fc2621 461 'field' => [
e7a6b91a 462 0 => 'is_billing',
c3fc2621
CW
463 ],
464 'localizable' => FALSE,
e7a6b91a 465 'sig' => 'civicrm_email::0::is_billing',
c3fc2621
CW
466 ],
467 ];
e7a6b91a
AS
468 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
469 }
c3fc2621 470
e501603b 471}