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