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