Schema - Fix boolean fields in various tables
[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
c1e814c7 9 * (GenCodeChecksum:58fe115e0962f83c3906bce5f663f0fc)
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 *
c1e814c7 86 * @var bool|string
28979d65
CW
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 *
c1e814c7 95 * @var bool|string
28979d65
CW
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'),
c1e814c7 276 'required' => TRUE,
a36434b9 277 'where' => 'civicrm_email.is_primary',
45a83e42 278 'default' => '0',
522a26c9 279 'table_name' => 'civicrm_email',
280 'entity' => 'Email',
281 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 282 'localizable' => 0,
b6673dcd
CW
283 'html' => [
284 'type' => 'Radio',
285 ],
a9d0587b 286 'add' => '1.1',
c3fc2621
CW
287 ],
288 'is_billing' => [
e501603b
TO
289 'name' => 'is_billing',
290 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 291 'title' => ts('Is Billing Email?'),
215b423e 292 'description' => ts('Is this the billing?'),
c1e814c7 293 'required' => TRUE,
a36434b9 294 'where' => 'civicrm_email.is_billing',
45a83e42 295 'default' => '0',
522a26c9 296 'table_name' => 'civicrm_email',
297 'entity' => 'Email',
298 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 299 'localizable' => 0,
a9d0587b 300 'add' => '2.0',
c3fc2621
CW
301 ],
302 'on_hold' => [
e501603b 303 'name' => 'on_hold',
f61d1b83 304 'type' => CRM_Utils_Type::T_INT,
c3fc2621 305 'title' => ts('On Hold'),
215b423e 306 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
c3fc2621 307 'required' => TRUE,
e501603b 308 'where' => 'civicrm_email.on_hold',
a36434b9 309 'export' => TRUE,
45a83e42 310 'default' => '0',
522a26c9 311 'table_name' => 'civicrm_email',
312 'entity' => 'Email',
313 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 314 'localizable' => 0,
c3fc2621 315 'html' => [
f61d1b83 316 'type' => 'Select',
c3fc2621 317 ],
f61d1b83
AS
318 'pseudoconstant' => [
319 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
e6ca0a57 320 ],
a9d0587b 321 'add' => '1.1',
c3fc2621
CW
322 ],
323 'is_bulkmail' => [
e501603b
TO
324 'name' => 'is_bulkmail',
325 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 326 'title' => ts('Use for Bulk Mail'),
215b423e 327 'description' => ts('Is this address for bulk mail ?'),
c3fc2621 328 'required' => TRUE,
e501603b 329 'where' => 'civicrm_email.is_bulkmail',
a36434b9 330 'export' => TRUE,
45a83e42 331 'default' => '0',
522a26c9 332 'table_name' => 'civicrm_email',
333 'entity' => 'Email',
334 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 335 'localizable' => 0,
a9d0587b 336 'add' => '1.9',
c3fc2621
CW
337 ],
338 'hold_date' => [
e501603b
TO
339 'name' => 'hold_date',
340 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 341 'title' => ts('Hold Date'),
215b423e 342 'description' => ts('When the address went on bounce hold'),
a36434b9 343 'where' => 'civicrm_email.hold_date',
522a26c9 344 'table_name' => 'civicrm_email',
345 'entity' => 'Email',
346 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 347 'localizable' => 0,
c23563e3 348 'html' => [
f01d655f
EM
349 'type' => 'Select Date',
350 'formatType' => 'activityDateTime',
c23563e3
SL
351 'label' => ts("Hold Date"),
352 ],
a9d0587b 353 'add' => '1.1',
c3fc2621
CW
354 ],
355 'reset_date' => [
e501603b
TO
356 'name' => 'reset_date',
357 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 358 'title' => ts('Reset Date'),
215b423e 359 'description' => ts('When the address bounce status was last reset'),
a36434b9 360 'where' => 'civicrm_email.reset_date',
522a26c9 361 'table_name' => 'civicrm_email',
362 'entity' => 'Email',
363 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 364 'localizable' => 0,
c23563e3 365 'html' => [
f01d655f
EM
366 'type' => 'Select Date',
367 'formatType' => 'activityDateTime',
c23563e3
SL
368 'label' => ts("Reset Date"),
369 ],
a9d0587b 370 'add' => '1.1',
c3fc2621
CW
371 ],
372 'signature_text' => [
e501603b
TO
373 'name' => 'signature_text',
374 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 375 'title' => ts('Signature Text'),
215b423e 376 'description' => ts('Text formatted signature for the email.'),
c3fc2621 377 'import' => TRUE,
e501603b 378 'where' => 'civicrm_email.signature_text',
c3fc2621 379 'export' => TRUE,
5fb0de1f 380 'default' => NULL,
522a26c9 381 'table_name' => 'civicrm_email',
382 'entity' => 'Email',
383 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 384 'localizable' => 0,
c23563e3
SL
385 'html' => [
386 'label' => ts("Signature Text"),
387 ],
a9d0587b 388 'add' => '3.2',
c3fc2621
CW
389 ],
390 'signature_html' => [
e501603b
TO
391 'name' => 'signature_html',
392 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 393 'title' => ts('Signature Html'),
215b423e 394 'description' => ts('HTML formatted signature for the email.'),
c3fc2621 395 'import' => TRUE,
e501603b 396 'where' => 'civicrm_email.signature_html',
c3fc2621 397 'export' => TRUE,
5fb0de1f 398 'default' => NULL,
522a26c9 399 'table_name' => 'civicrm_email',
400 'entity' => 'Email',
401 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 402 'localizable' => 0,
c23563e3
SL
403 'html' => [
404 'label' => ts("Signature HTML"),
405 ],
a9d0587b 406 'add' => '3.2',
c3fc2621
CW
407 ],
408 ];
346aaaba 409 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 410 }
346aaaba 411 return Civi::$statics[__CLASS__]['fields'];
e501603b 412 }
c3fc2621 413
e501603b 414 /**
bd8e0b14 415 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
416 *
417 * @return array
bd8e0b14 418 * Array(string $name => string $uniqueName).
e501603b 419 */
c3fc2621 420 public static function &fieldKeys() {
bd8e0b14
TO
421 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
422 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 423 }
bd8e0b14 424 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 425 }
c3fc2621 426
e501603b
TO
427 /**
428 * Returns the names of this table
429 *
430 * @return string
431 */
c3fc2621 432 public static function getTableName() {
e501603b
TO
433 return self::$_tableName;
434 }
c3fc2621 435
e501603b
TO
436 /**
437 * Returns if this table needs to be logged
438 *
c3fc2621 439 * @return bool
e501603b 440 */
c3fc2621 441 public function getLog() {
e501603b
TO
442 return self::$_log;
443 }
c3fc2621 444
e501603b
TO
445 /**
446 * Returns the list of fields that can be imported
447 *
448 * @param bool $prefix
449 *
450 * @return array
451 */
c3fc2621
CW
452 public static function &import($prefix = FALSE) {
453 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
60808919 454 return $r;
e501603b 455 }
c3fc2621 456
e501603b
TO
457 /**
458 * Returns the list of fields that can be exported
459 *
460 * @param bool $prefix
461 *
462 * @return array
463 */
c3fc2621
CW
464 public static function &export($prefix = FALSE) {
465 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
60808919 466 return $r;
e501603b 467 }
c3fc2621 468
e7a6b91a
AS
469 /**
470 * Returns the list of indices
c3fc2621
CW
471 *
472 * @param bool $localize
473 *
474 * @return array
e7a6b91a
AS
475 */
476 public static function indices($localize = TRUE) {
c3fc2621
CW
477 $indices = [
478 'index_location_type' => [
e7a6b91a 479 'name' => 'index_location_type',
c3fc2621 480 'field' => [
e7a6b91a 481 0 => 'location_type_id',
c3fc2621
CW
482 ],
483 'localizable' => FALSE,
e7a6b91a 484 'sig' => 'civicrm_email::0::location_type_id',
c3fc2621
CW
485 ],
486 'UI_email' => [
e7a6b91a 487 'name' => 'UI_email',
c3fc2621 488 'field' => [
e7a6b91a 489 0 => 'email',
c3fc2621
CW
490 ],
491 'localizable' => FALSE,
e7a6b91a 492 'sig' => 'civicrm_email::0::email',
c3fc2621
CW
493 ],
494 'index_is_primary' => [
e7a6b91a 495 'name' => 'index_is_primary',
c3fc2621 496 'field' => [
e7a6b91a 497 0 => 'is_primary',
c3fc2621
CW
498 ],
499 'localizable' => FALSE,
e7a6b91a 500 'sig' => 'civicrm_email::0::is_primary',
c3fc2621
CW
501 ],
502 'index_is_billing' => [
e7a6b91a 503 'name' => 'index_is_billing',
c3fc2621 504 'field' => [
e7a6b91a 505 0 => 'is_billing',
c3fc2621
CW
506 ],
507 'localizable' => FALSE,
e7a6b91a 508 'sig' => 'civicrm_email::0::is_billing',
c3fc2621
CW
509 ],
510 ];
e7a6b91a
AS
511 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
512 }
c3fc2621 513
e501603b 514}