Merge pull request #14276 from eileenmcnaughton/dbunit_2
[civicrm-core.git] / CRM / Core / DAO / Email.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
6b83d5bd 5 * @copyright CiviCRM LLC (c) 2004-2019
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Core/Email.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
042043f1 9 * (GenCodeChecksum:c25ff93d9132b6329970a092b7cbc5e6)
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 {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_email';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * Unique Email ID
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * FK to Contact ID
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Which Location does this email belong to.
47 *
48 * @var int unsigned
49 */
50 public $location_type_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Email address
54 *
55 * @var string
56 */
57 public $email;
c3fc2621 58
e501603b
TO
59 /**
60 * Is this the primary?
61 *
62 * @var boolean
63 */
64 public $is_primary;
c3fc2621 65
e501603b
TO
66 /**
67 * Is this the billing?
68 *
69 * @var boolean
70 */
71 public $is_billing;
c3fc2621 72
e501603b 73 /**
f61d1b83 74 * Implicit FK to civicrm_option_value where option_group = email_on_hold.
e501603b 75 *
f61d1b83 76 * @var int unsigned
e501603b
TO
77 */
78 public $on_hold;
c3fc2621 79
e501603b
TO
80 /**
81 * Is this address for bulk mail ?
82 *
83 * @var boolean
84 */
85 public $is_bulkmail;
c3fc2621 86
e501603b
TO
87 /**
88 * When the address went on bounce hold
89 *
90 * @var datetime
91 */
92 public $hold_date;
c3fc2621 93
e501603b
TO
94 /**
95 * When the address bounce status was last reset
96 *
97 * @var datetime
98 */
99 public $reset_date;
c3fc2621 100
e501603b
TO
101 /**
102 * Text formatted signature for the email.
103 *
104 * @var text
105 */
106 public $signature_text;
c3fc2621 107
e501603b
TO
108 /**
109 * HTML formatted signature for the email.
110 *
111 * @var text
112 */
113 public $signature_html;
c3fc2621 114
e501603b 115 /**
f41f0342 116 * Class constructor.
e501603b 117 */
c3fc2621 118 public function __construct() {
e501603b
TO
119 $this->__table = 'civicrm_email';
120 parent::__construct();
121 }
c3fc2621 122
e501603b 123 /**
f41f0342 124 * Returns foreign keys and entity references.
e501603b
TO
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
c3fc2621 129 public static function getReferenceColumns() {
346aaaba 130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 131 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621 132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
346aaaba 133 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 134 }
346aaaba 135 return Civi::$statics[__CLASS__]['links'];
e501603b 136 }
c3fc2621 137
e501603b
TO
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
c3fc2621 143 public static function &fields() {
346aaaba 144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
145 Civi::$statics[__CLASS__]['fields'] = [
146 'id' => [
e501603b
TO
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
c3fc2621 149 'title' => ts('Email ID'),
215b423e 150 'description' => ts('Unique Email ID'),
c3fc2621 151 'required' => TRUE,
a36434b9 152 'where' => 'civicrm_email.id',
522a26c9 153 'table_name' => 'civicrm_email',
154 'entity' => 'Email',
155 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 156 'localizable' => 0,
c3fc2621
CW
157 ],
158 'contact_id' => [
e501603b
TO
159 'name' => 'contact_id',
160 'type' => CRM_Utils_Type::T_INT,
c3fc2621 161 'title' => ts('Email Contact'),
215b423e 162 'description' => ts('FK to Contact ID'),
a36434b9 163 'where' => 'civicrm_email.contact_id',
522a26c9 164 'table_name' => 'civicrm_email',
165 'entity' => 'Email',
166 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 167 'localizable' => 0,
e501603b 168 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
169 ],
170 'location_type_id' => [
e501603b
TO
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type::T_INT,
c3fc2621 173 'title' => ts('Email Location Type'),
215b423e 174 'description' => ts('Which Location does this email belong to.'),
a36434b9 175 'where' => 'civicrm_email.location_type_id',
522a26c9 176 'table_name' => 'civicrm_email',
177 'entity' => 'Email',
178 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 179 'localizable' => 0,
c3fc2621 180 'html' => [
e501603b 181 'type' => 'Select',
c3fc2621
CW
182 ],
183 'pseudoconstant' => [
e501603b
TO
184 'table' => 'civicrm_location_type',
185 'keyColumn' => 'id',
186 'labelColumn' => 'display_name',
c3fc2621
CW
187 ]
188 ],
189 'email' => [
e501603b
TO
190 'name' => 'email',
191 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 192 'title' => ts('Email'),
215b423e 193 'description' => ts('Email address'),
e501603b
TO
194 'maxlength' => 254,
195 'size' => 30,
c3fc2621 196 'import' => TRUE,
e501603b
TO
197 'where' => 'civicrm_email.email',
198 'headerPattern' => '/e.?mail/i',
199 '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 200 'export' => TRUE,
e501603b 201 'rule' => 'email',
522a26c9 202 'table_name' => 'civicrm_email',
203 'entity' => 'Email',
204 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 205 'localizable' => 0,
c3fc2621 206 'html' => [
e501603b 207 'type' => 'Text',
c3fc2621
CW
208 ],
209 ],
210 'is_primary' => [
e501603b
TO
211 'name' => 'is_primary',
212 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 213 'title' => ts('Is Primary email'),
215b423e 214 'description' => ts('Is this the primary?'),
a36434b9 215 'where' => 'civicrm_email.is_primary',
45a83e42 216 'default' => '0',
522a26c9 217 'table_name' => 'civicrm_email',
218 'entity' => 'Email',
219 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 220 'localizable' => 0,
c3fc2621
CW
221 ],
222 'is_billing' => [
e501603b
TO
223 'name' => 'is_billing',
224 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 225 'title' => ts('Is Billing Email?'),
215b423e 226 'description' => ts('Is this the billing?'),
a36434b9 227 'where' => 'civicrm_email.is_billing',
45a83e42 228 'default' => '0',
522a26c9 229 'table_name' => 'civicrm_email',
230 'entity' => 'Email',
231 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 232 'localizable' => 0,
c3fc2621
CW
233 ],
234 'on_hold' => [
e501603b 235 'name' => 'on_hold',
f61d1b83 236 'type' => CRM_Utils_Type::T_INT,
c3fc2621 237 'title' => ts('On Hold'),
215b423e 238 'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
c3fc2621 239 'required' => TRUE,
e501603b 240 'where' => 'civicrm_email.on_hold',
a36434b9 241 'export' => TRUE,
45a83e42 242 'default' => '0',
522a26c9 243 'table_name' => 'civicrm_email',
244 'entity' => 'Email',
245 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 246 'localizable' => 0,
c3fc2621 247 'html' => [
f61d1b83 248 'type' => 'Select',
c3fc2621 249 ],
f61d1b83
AS
250 'pseudoconstant' => [
251 'callback' => 'CRM_Core_PseudoConstant::emailOnHoldOptions',
252 ]
c3fc2621
CW
253 ],
254 'is_bulkmail' => [
e501603b
TO
255 'name' => 'is_bulkmail',
256 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 257 'title' => ts('Use for Bulk Mail'),
215b423e 258 'description' => ts('Is this address for bulk mail ?'),
c3fc2621 259 'required' => TRUE,
e501603b 260 'where' => 'civicrm_email.is_bulkmail',
a36434b9 261 'export' => TRUE,
45a83e42 262 'default' => '0',
522a26c9 263 'table_name' => 'civicrm_email',
264 'entity' => 'Email',
265 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 266 'localizable' => 0,
c3fc2621
CW
267 ],
268 'hold_date' => [
e501603b
TO
269 'name' => 'hold_date',
270 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 271 'title' => ts('Hold Date'),
215b423e 272 'description' => ts('When the address went on bounce hold'),
a36434b9 273 'where' => 'civicrm_email.hold_date',
522a26c9 274 'table_name' => 'civicrm_email',
275 'entity' => 'Email',
276 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 277 'localizable' => 0,
c3fc2621
CW
278 ],
279 'reset_date' => [
e501603b
TO
280 'name' => 'reset_date',
281 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
c3fc2621 282 'title' => ts('Reset Date'),
215b423e 283 'description' => ts('When the address bounce status was last reset'),
a36434b9 284 'where' => 'civicrm_email.reset_date',
522a26c9 285 'table_name' => 'civicrm_email',
286 'entity' => 'Email',
287 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 288 'localizable' => 0,
c3fc2621
CW
289 ],
290 'signature_text' => [
e501603b
TO
291 'name' => 'signature_text',
292 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 293 'title' => ts('Signature Text'),
215b423e 294 'description' => ts('Text formatted signature for the email.'),
c3fc2621 295 'import' => TRUE,
e501603b 296 'where' => 'civicrm_email.signature_text',
c3fc2621 297 'export' => TRUE,
e501603b 298 'default' => 'NULL',
522a26c9 299 'table_name' => 'civicrm_email',
300 'entity' => 'Email',
301 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 302 'localizable' => 0,
c3fc2621
CW
303 ],
304 'signature_html' => [
e501603b
TO
305 'name' => 'signature_html',
306 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 307 'title' => ts('Signature Html'),
215b423e 308 'description' => ts('HTML formatted signature for the email.'),
c3fc2621 309 'import' => TRUE,
e501603b 310 'where' => 'civicrm_email.signature_html',
c3fc2621 311 'export' => TRUE,
e501603b 312 'default' => 'NULL',
522a26c9 313 'table_name' => 'civicrm_email',
314 'entity' => 'Email',
315 'bao' => 'CRM_Core_BAO_Email',
6a7e5e5d 316 'localizable' => 0,
c3fc2621
CW
317 ],
318 ];
346aaaba 319 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 320 }
346aaaba 321 return Civi::$statics[__CLASS__]['fields'];
e501603b 322 }
c3fc2621 323
e501603b 324 /**
bd8e0b14 325 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
326 *
327 * @return array
bd8e0b14 328 * Array(string $name => string $uniqueName).
e501603b 329 */
c3fc2621 330 public static function &fieldKeys() {
bd8e0b14
TO
331 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
332 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 333 }
bd8e0b14 334 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 335 }
c3fc2621 336
e501603b
TO
337 /**
338 * Returns the names of this table
339 *
340 * @return string
341 */
c3fc2621 342 public static function getTableName() {
e501603b
TO
343 return self::$_tableName;
344 }
c3fc2621 345
e501603b
TO
346 /**
347 * Returns if this table needs to be logged
348 *
c3fc2621 349 * @return bool
e501603b 350 */
c3fc2621 351 public function getLog() {
e501603b
TO
352 return self::$_log;
353 }
c3fc2621 354
e501603b
TO
355 /**
356 * Returns the list of fields that can be imported
357 *
358 * @param bool $prefix
359 *
360 * @return array
361 */
c3fc2621
CW
362 public static function &import($prefix = FALSE) {
363 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'email', $prefix, []);
60808919 364 return $r;
e501603b 365 }
c3fc2621 366
e501603b
TO
367 /**
368 * Returns the list of fields that can be exported
369 *
370 * @param bool $prefix
371 *
372 * @return array
373 */
c3fc2621
CW
374 public static function &export($prefix = FALSE) {
375 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'email', $prefix, []);
60808919 376 return $r;
e501603b 377 }
c3fc2621 378
e7a6b91a
AS
379 /**
380 * Returns the list of indices
c3fc2621
CW
381 *
382 * @param bool $localize
383 *
384 * @return array
e7a6b91a
AS
385 */
386 public static function indices($localize = TRUE) {
c3fc2621
CW
387 $indices = [
388 'index_location_type' => [
e7a6b91a 389 'name' => 'index_location_type',
c3fc2621 390 'field' => [
e7a6b91a 391 0 => 'location_type_id',
c3fc2621
CW
392 ],
393 'localizable' => FALSE,
e7a6b91a 394 'sig' => 'civicrm_email::0::location_type_id',
c3fc2621
CW
395 ],
396 'UI_email' => [
e7a6b91a 397 'name' => 'UI_email',
c3fc2621 398 'field' => [
e7a6b91a 399 0 => 'email',
c3fc2621
CW
400 ],
401 'localizable' => FALSE,
e7a6b91a 402 'sig' => 'civicrm_email::0::email',
c3fc2621
CW
403 ],
404 'index_is_primary' => [
e7a6b91a 405 'name' => 'index_is_primary',
c3fc2621 406 'field' => [
e7a6b91a 407 0 => 'is_primary',
c3fc2621
CW
408 ],
409 'localizable' => FALSE,
e7a6b91a 410 'sig' => 'civicrm_email::0::is_primary',
c3fc2621
CW
411 ],
412 'index_is_billing' => [
e7a6b91a 413 'name' => 'index_is_billing',
c3fc2621 414 'field' => [
e7a6b91a 415 0 => 'is_billing',
c3fc2621
CW
416 ],
417 'localizable' => FALSE,
e7a6b91a 418 'sig' => 'civicrm_email::0::is_billing',
c3fc2621
CW
419 ],
420 ];
e7a6b91a
AS
421 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
422 }
c3fc2621 423
e501603b 424}