Merge pull request #22822 from civicrm/5.47
[civicrm-core.git] / CRM / Mailing / DAO / Mailing.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Mailing/Mailing.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:d9992e7d40fdab9d29f2a093e34aa1cb)
10 */
11
12 /**
13 * Database access object for the Mailing entity.
14 */
15 class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
18 const COMPONENT = 'CiviMail';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_mailing';
26
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-envelope-o';
33
34 /**
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
36 *
37 * @var bool
38 */
39 public static $_log = FALSE;
40
41 /**
42 * Paths for accessing this entity in the UI.
43 *
44 * @var string[]
45 */
46 protected static $_paths = [
47 'add' => 'civicrm/a/#/mailing/new',
48 'update' => 'civicrm/a/#/mailing/[id]',
49 ];
50
51 /**
52 * @var int|string|null
53 * (SQL type: int unsigned)
54 * Note that values will be retrieved from the database as a string.
55 */
56 public $id;
57
58 /**
59 * Which site is this mailing for
60 *
61 * @var int|string|null
62 * (SQL type: int unsigned)
63 * Note that values will be retrieved from the database as a string.
64 */
65 public $domain_id;
66
67 /**
68 * FK to the header component.
69 *
70 * @var int|string|null
71 * (SQL type: int unsigned)
72 * Note that values will be retrieved from the database as a string.
73 */
74 public $header_id;
75
76 /**
77 * FK to the footer component.
78 *
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
82 */
83 public $footer_id;
84
85 /**
86 * FK to the auto-responder component.
87 *
88 * @var int|string|null
89 * (SQL type: int unsigned)
90 * Note that values will be retrieved from the database as a string.
91 */
92 public $reply_id;
93
94 /**
95 * FK to the unsubscribe component.
96 *
97 * @var int|string|null
98 * (SQL type: int unsigned)
99 * Note that values will be retrieved from the database as a string.
100 */
101 public $unsubscribe_id;
102
103 /**
104 * @var int|string|null
105 * (SQL type: int unsigned)
106 * Note that values will be retrieved from the database as a string.
107 */
108 public $resubscribe_id;
109
110 /**
111 * FK to the opt-out component.
112 *
113 * @var int|string|null
114 * (SQL type: int unsigned)
115 * Note that values will be retrieved from the database as a string.
116 */
117 public $optout_id;
118
119 /**
120 * Mailing Name.
121 *
122 * @var string|null
123 * (SQL type: varchar(128))
124 * Note that values will be retrieved from the database as a string.
125 */
126 public $name;
127
128 /**
129 * differentiate between standalone mailings, A/B tests, and A/B final-winner
130 *
131 * @var string|null
132 * (SQL type: varchar(32))
133 * Note that values will be retrieved from the database as a string.
134 */
135 public $mailing_type;
136
137 /**
138 * From Header of mailing
139 *
140 * @var string|null
141 * (SQL type: varchar(128))
142 * Note that values will be retrieved from the database as a string.
143 */
144 public $from_name;
145
146 /**
147 * From Email of mailing
148 *
149 * @var string|null
150 * (SQL type: varchar(128))
151 * Note that values will be retrieved from the database as a string.
152 */
153 public $from_email;
154
155 /**
156 * Reply-To Email of mailing
157 *
158 * @var string|null
159 * (SQL type: varchar(128))
160 * Note that values will be retrieved from the database as a string.
161 */
162 public $replyto_email;
163
164 /**
165 * The language/processing system used for email templates.
166 *
167 * @var string
168 * (SQL type: varchar(64))
169 * Note that values will be retrieved from the database as a string.
170 */
171 public $template_type;
172
173 /**
174 * Advanced options used by the email templating system. (JSON encoded)
175 *
176 * @var string|null
177 * (SQL type: longtext)
178 * Note that values will be retrieved from the database as a string.
179 */
180 public $template_options;
181
182 /**
183 * Subject of mailing
184 *
185 * @var string|null
186 * (SQL type: varchar(128))
187 * Note that values will be retrieved from the database as a string.
188 */
189 public $subject;
190
191 /**
192 * Body of the mailing in text format.
193 *
194 * @var string|null
195 * (SQL type: longtext)
196 * Note that values will be retrieved from the database as a string.
197 */
198 public $body_text;
199
200 /**
201 * Body of the mailing in html format.
202 *
203 * @var string|null
204 * (SQL type: longtext)
205 * Note that values will be retrieved from the database as a string.
206 */
207 public $body_html;
208
209 /**
210 * Should we track URL click-throughs for this mailing?
211 *
212 * @var bool|string|null
213 * (SQL type: tinyint)
214 * Note that values will be retrieved from the database as a string.
215 */
216 public $url_tracking;
217
218 /**
219 * Should we forward replies back to the author?
220 *
221 * @var bool|string|null
222 * (SQL type: tinyint)
223 * Note that values will be retrieved from the database as a string.
224 */
225 public $forward_replies;
226
227 /**
228 * Should we enable the auto-responder?
229 *
230 * @var bool|string|null
231 * (SQL type: tinyint)
232 * Note that values will be retrieved from the database as a string.
233 */
234 public $auto_responder;
235
236 /**
237 * Should we track when recipients open/read this mailing?
238 *
239 * @var bool|string|null
240 * (SQL type: tinyint)
241 * Note that values will be retrieved from the database as a string.
242 */
243 public $open_tracking;
244
245 /**
246 * Has at least one job associated with this mailing finished?
247 *
248 * @var bool|string|null
249 * (SQL type: tinyint)
250 * Note that values will be retrieved from the database as a string.
251 */
252 public $is_completed;
253
254 /**
255 * FK to the message template.
256 *
257 * @var int|string|null
258 * (SQL type: int unsigned)
259 * Note that values will be retrieved from the database as a string.
260 */
261 public $msg_template_id;
262
263 /**
264 * Overwrite the VERP address in Reply-To
265 *
266 * @var bool|string|null
267 * (SQL type: tinyint)
268 * Note that values will be retrieved from the database as a string.
269 */
270 public $override_verp;
271
272 /**
273 * FK to Contact ID who first created this mailing
274 *
275 * @var int|string|null
276 * (SQL type: int unsigned)
277 * Note that values will be retrieved from the database as a string.
278 */
279 public $created_id;
280
281 /**
282 * Date and time this mailing was created.
283 *
284 * @var string
285 * (SQL type: timestamp)
286 * Note that values will be retrieved from the database as a string.
287 */
288 public $created_date;
289
290 /**
291 * When the mailing (or closely related entity) was created or modified or deleted.
292 *
293 * @var string
294 * (SQL type: timestamp)
295 * Note that values will be retrieved from the database as a string.
296 */
297 public $modified_date;
298
299 /**
300 * FK to Contact ID who scheduled this mailing
301 *
302 * @var int|string|null
303 * (SQL type: int unsigned)
304 * Note that values will be retrieved from the database as a string.
305 */
306 public $scheduled_id;
307
308 /**
309 * Date and time this mailing was scheduled.
310 *
311 * @var string
312 * (SQL type: timestamp)
313 * Note that values will be retrieved from the database as a string.
314 */
315 public $scheduled_date;
316
317 /**
318 * FK to Contact ID who approved this mailing
319 *
320 * @var int|string|null
321 * (SQL type: int unsigned)
322 * Note that values will be retrieved from the database as a string.
323 */
324 public $approver_id;
325
326 /**
327 * Date and time this mailing was approved.
328 *
329 * @var string
330 * (SQL type: timestamp)
331 * Note that values will be retrieved from the database as a string.
332 */
333 public $approval_date;
334
335 /**
336 * The status of this mailing. Values: none, approved, rejected
337 *
338 * @var int|string|null
339 * (SQL type: int unsigned)
340 * Note that values will be retrieved from the database as a string.
341 */
342 public $approval_status_id;
343
344 /**
345 * Note behind the decision.
346 *
347 * @var string|null
348 * (SQL type: longtext)
349 * Note that values will be retrieved from the database as a string.
350 */
351 public $approval_note;
352
353 /**
354 * Is this mailing archived?
355 *
356 * @var bool|string|null
357 * (SQL type: tinyint)
358 * Note that values will be retrieved from the database as a string.
359 */
360 public $is_archived;
361
362 /**
363 * In what context(s) is the mailing contents visible (online viewing)
364 *
365 * @var string|null
366 * (SQL type: varchar(40))
367 * Note that values will be retrieved from the database as a string.
368 */
369 public $visibility;
370
371 /**
372 * The campaign for which this mailing has been initiated.
373 *
374 * @var int|string|null
375 * (SQL type: int unsigned)
376 * Note that values will be retrieved from the database as a string.
377 */
378 public $campaign_id;
379
380 /**
381 * Remove duplicate emails?
382 *
383 * @var bool|string|null
384 * (SQL type: tinyint)
385 * Note that values will be retrieved from the database as a string.
386 */
387 public $dedupe_email;
388
389 /**
390 * @var int|string|null
391 * (SQL type: int unsigned)
392 * Note that values will be retrieved from the database as a string.
393 */
394 public $sms_provider_id;
395
396 /**
397 * Key for validating requests related to this mailing.
398 *
399 * @var string|null
400 * (SQL type: varchar(16))
401 * Note that values will be retrieved from the database as a string.
402 */
403 public $hash;
404
405 /**
406 * With email_selection_method, determines which email address to use
407 *
408 * @var int|string|null
409 * (SQL type: int unsigned)
410 * Note that values will be retrieved from the database as a string.
411 */
412 public $location_type_id;
413
414 /**
415 * With location_type_id, determine how to choose the email address to use.
416 *
417 * @var string|null
418 * (SQL type: varchar(20))
419 * Note that values will be retrieved from the database as a string.
420 */
421 public $email_selection_method;
422
423 /**
424 * Language of the content of the mailing. Useful for tokens.
425 *
426 * @var string|null
427 * (SQL type: varchar(5))
428 * Note that values will be retrieved from the database as a string.
429 */
430 public $language;
431
432 /**
433 * Class constructor.
434 */
435 public function __construct() {
436 $this->__table = 'civicrm_mailing';
437 parent::__construct();
438 }
439
440 /**
441 * Returns localized title of this entity.
442 *
443 * @param bool $plural
444 * Whether to return the plural version of the title.
445 */
446 public static function getEntityTitle($plural = FALSE) {
447 return $plural ? ts('Mailings') : ts('Mailing');
448 }
449
450 /**
451 * Returns user-friendly description of this entity.
452 *
453 * @return string
454 */
455 public static function getEntityDescription() {
456 return ts('Mass emails sent from CiviMail.');
457 }
458
459 /**
460 * Returns foreign keys and entity references.
461 *
462 * @return array
463 * [CRM_Core_Reference_Interface]
464 */
465 public static function getReferenceColumns() {
466 if (!isset(Civi::$statics[__CLASS__]['links'])) {
467 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
468 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
469 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'header_id', 'civicrm_mailing_component', 'id');
470 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'footer_id', 'civicrm_mailing_component', 'id');
471 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'reply_id', 'civicrm_mailing_component', 'id');
472 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'unsubscribe_id', 'civicrm_mailing_component', 'id');
473 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'optout_id', 'civicrm_mailing_component', 'id');
474 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'msg_template_id', 'civicrm_msg_template', 'id');
475 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
476 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'scheduled_id', 'civicrm_contact', 'id');
477 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'approver_id', 'civicrm_contact', 'id');
478 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
479 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'sms_provider_id', 'civicrm_sms_provider', 'id');
480 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id');
481 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
482 }
483 return Civi::$statics[__CLASS__]['links'];
484 }
485
486 /**
487 * Returns all the column names of this table
488 *
489 * @return array
490 */
491 public static function &fields() {
492 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
493 Civi::$statics[__CLASS__]['fields'] = [
494 'id' => [
495 'name' => 'id',
496 'type' => CRM_Utils_Type::T_INT,
497 'title' => ts('Mailing ID'),
498 'required' => TRUE,
499 'where' => 'civicrm_mailing.id',
500 'table_name' => 'civicrm_mailing',
501 'entity' => 'Mailing',
502 'bao' => 'CRM_Mailing_BAO_Mailing',
503 'localizable' => 0,
504 'html' => [
505 'type' => 'Number',
506 ],
507 'readonly' => TRUE,
508 'add' => NULL,
509 ],
510 'domain_id' => [
511 'name' => 'domain_id',
512 'type' => CRM_Utils_Type::T_INT,
513 'title' => ts('Domain ID'),
514 'description' => ts('Which site is this mailing for'),
515 'where' => 'civicrm_mailing.domain_id',
516 'table_name' => 'civicrm_mailing',
517 'entity' => 'Mailing',
518 'bao' => 'CRM_Mailing_BAO_Mailing',
519 'localizable' => 0,
520 'FKClassName' => 'CRM_Core_DAO_Domain',
521 'html' => [
522 'label' => ts("Domain"),
523 ],
524 'pseudoconstant' => [
525 'table' => 'civicrm_domain',
526 'keyColumn' => 'id',
527 'labelColumn' => 'name',
528 ],
529 'add' => '3.4',
530 ],
531 'header_id' => [
532 'name' => 'header_id',
533 'type' => CRM_Utils_Type::T_INT,
534 'title' => ts('Header ID'),
535 'description' => ts('FK to the header component.'),
536 'where' => 'civicrm_mailing.header_id',
537 'table_name' => 'civicrm_mailing',
538 'entity' => 'Mailing',
539 'bao' => 'CRM_Mailing_BAO_Mailing',
540 'localizable' => 0,
541 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
542 'html' => [
543 'label' => ts("Header"),
544 ],
545 'pseudoconstant' => [
546 'table' => 'civicrm_mailing_component',
547 'keyColumn' => 'id',
548 'labelColumn' => 'name',
549 'condition' => 'component_type = "Header"',
550 ],
551 'add' => NULL,
552 ],
553 'footer_id' => [
554 'name' => 'footer_id',
555 'type' => CRM_Utils_Type::T_INT,
556 'title' => ts('Footer ID'),
557 'description' => ts('FK to the footer component.'),
558 'where' => 'civicrm_mailing.footer_id',
559 'table_name' => 'civicrm_mailing',
560 'entity' => 'Mailing',
561 'bao' => 'CRM_Mailing_BAO_Mailing',
562 'localizable' => 0,
563 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
564 'html' => [
565 'label' => ts("Footer"),
566 ],
567 'pseudoconstant' => [
568 'table' => 'civicrm_mailing_component',
569 'keyColumn' => 'id',
570 'labelColumn' => 'name',
571 'condition' => 'component_type = "Footer"',
572 ],
573 'add' => NULL,
574 ],
575 'reply_id' => [
576 'name' => 'reply_id',
577 'type' => CRM_Utils_Type::T_INT,
578 'title' => ts('Reply ID'),
579 'description' => ts('FK to the auto-responder component.'),
580 'where' => 'civicrm_mailing.reply_id',
581 'table_name' => 'civicrm_mailing',
582 'entity' => 'Mailing',
583 'bao' => 'CRM_Mailing_BAO_Mailing',
584 'localizable' => 0,
585 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
586 'html' => [
587 'label' => ts("Reply"),
588 ],
589 'add' => NULL,
590 ],
591 'unsubscribe_id' => [
592 'name' => 'unsubscribe_id',
593 'type' => CRM_Utils_Type::T_INT,
594 'title' => ts('Unsubscribe ID'),
595 'description' => ts('FK to the unsubscribe component.'),
596 'where' => 'civicrm_mailing.unsubscribe_id',
597 'table_name' => 'civicrm_mailing',
598 'entity' => 'Mailing',
599 'bao' => 'CRM_Mailing_BAO_Mailing',
600 'localizable' => 0,
601 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
602 'html' => [
603 'label' => ts("Unsubscribe"),
604 ],
605 'add' => NULL,
606 ],
607 'resubscribe_id' => [
608 'name' => 'resubscribe_id',
609 'type' => CRM_Utils_Type::T_INT,
610 'title' => ts('Mailing Resubscribe'),
611 'where' => 'civicrm_mailing.resubscribe_id',
612 'table_name' => 'civicrm_mailing',
613 'entity' => 'Mailing',
614 'bao' => 'CRM_Mailing_BAO_Mailing',
615 'localizable' => 0,
616 'add' => NULL,
617 ],
618 'optout_id' => [
619 'name' => 'optout_id',
620 'type' => CRM_Utils_Type::T_INT,
621 'title' => ts('Opt Out ID'),
622 'description' => ts('FK to the opt-out component.'),
623 'where' => 'civicrm_mailing.optout_id',
624 'table_name' => 'civicrm_mailing',
625 'entity' => 'Mailing',
626 'bao' => 'CRM_Mailing_BAO_Mailing',
627 'localizable' => 0,
628 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
629 'html' => [
630 'label' => ts("Opt Out"),
631 ],
632 'add' => NULL,
633 ],
634 'mailing_name' => [
635 'name' => 'name',
636 'type' => CRM_Utils_Type::T_STRING,
637 'title' => ts('Mailing Name'),
638 'description' => ts('Mailing Name.'),
639 'maxlength' => 128,
640 'size' => CRM_Utils_Type::HUGE,
641 'where' => 'civicrm_mailing.name',
642 'table_name' => 'civicrm_mailing',
643 'entity' => 'Mailing',
644 'bao' => 'CRM_Mailing_BAO_Mailing',
645 'localizable' => 0,
646 'html' => [
647 'type' => 'Text',
648 ],
649 'add' => NULL,
650 ],
651 'mailing_type' => [
652 'name' => 'mailing_type',
653 'type' => CRM_Utils_Type::T_STRING,
654 'title' => ts('Mailing Type'),
655 'description' => ts('differentiate between standalone mailings, A/B tests, and A/B final-winner'),
656 'maxlength' => 32,
657 'size' => CRM_Utils_Type::MEDIUM,
658 'where' => 'civicrm_mailing.mailing_type',
659 'table_name' => 'civicrm_mailing',
660 'entity' => 'Mailing',
661 'bao' => 'CRM_Mailing_BAO_Mailing',
662 'localizable' => 0,
663 'html' => [
664 'type' => 'Select',
665 ],
666 'pseudoconstant' => [
667 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
668 ],
669 'add' => '4.6',
670 ],
671 'from_name' => [
672 'name' => 'from_name',
673 'type' => CRM_Utils_Type::T_STRING,
674 'title' => ts('Mailing From Name'),
675 'description' => ts('From Header of mailing'),
676 'maxlength' => 128,
677 'size' => CRM_Utils_Type::HUGE,
678 'where' => 'civicrm_mailing.from_name',
679 'table_name' => 'civicrm_mailing',
680 'entity' => 'Mailing',
681 'bao' => 'CRM_Mailing_BAO_Mailing',
682 'localizable' => 0,
683 'html' => [
684 'type' => 'Text',
685 ],
686 'add' => NULL,
687 ],
688 'from_email' => [
689 'name' => 'from_email',
690 'type' => CRM_Utils_Type::T_STRING,
691 'title' => ts('Mailing From Email'),
692 'description' => ts('From Email of mailing'),
693 'maxlength' => 128,
694 'size' => CRM_Utils_Type::HUGE,
695 'where' => 'civicrm_mailing.from_email',
696 'table_name' => 'civicrm_mailing',
697 'entity' => 'Mailing',
698 'bao' => 'CRM_Mailing_BAO_Mailing',
699 'localizable' => 0,
700 'html' => [
701 'type' => 'Text',
702 ],
703 'add' => NULL,
704 ],
705 'replyto_email' => [
706 'name' => 'replyto_email',
707 'type' => CRM_Utils_Type::T_STRING,
708 'title' => ts('Replyto Email'),
709 'description' => ts('Reply-To Email of mailing'),
710 'maxlength' => 128,
711 'size' => CRM_Utils_Type::HUGE,
712 'where' => 'civicrm_mailing.replyto_email',
713 'table_name' => 'civicrm_mailing',
714 'entity' => 'Mailing',
715 'bao' => 'CRM_Mailing_BAO_Mailing',
716 'localizable' => 0,
717 'html' => [
718 'type' => 'Text',
719 'label' => ts("Reply-To Email"),
720 ],
721 'add' => NULL,
722 ],
723 'template_type' => [
724 'name' => 'template_type',
725 'type' => CRM_Utils_Type::T_STRING,
726 'title' => ts('Template Type'),
727 'description' => ts('The language/processing system used for email templates.'),
728 'required' => TRUE,
729 'maxlength' => 64,
730 'size' => CRM_Utils_Type::BIG,
731 'where' => 'civicrm_mailing.template_type',
732 'default' => 'traditional',
733 'table_name' => 'civicrm_mailing',
734 'entity' => 'Mailing',
735 'bao' => 'CRM_Mailing_BAO_Mailing',
736 'localizable' => 0,
737 'pseudoconstant' => [
738 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
739 ],
740 'add' => '4.7.16',
741 ],
742 'template_options' => [
743 'name' => 'template_options',
744 'type' => CRM_Utils_Type::T_LONGTEXT,
745 'title' => ts('Template Options (JSON)'),
746 'description' => ts('Advanced options used by the email templating system. (JSON encoded)'),
747 'where' => 'civicrm_mailing.template_options',
748 'table_name' => 'civicrm_mailing',
749 'entity' => 'Mailing',
750 'bao' => 'CRM_Mailing_BAO_Mailing',
751 'localizable' => 0,
752 'serialize' => self::SERIALIZE_JSON,
753 'add' => '4.7.16',
754 ],
755 'subject' => [
756 'name' => 'subject',
757 'type' => CRM_Utils_Type::T_STRING,
758 'title' => ts('Subject'),
759 'description' => ts('Subject of mailing'),
760 'maxlength' => 128,
761 'size' => CRM_Utils_Type::HUGE,
762 'where' => 'civicrm_mailing.subject',
763 'table_name' => 'civicrm_mailing',
764 'entity' => 'Mailing',
765 'bao' => 'CRM_Mailing_BAO_Mailing',
766 'localizable' => 0,
767 'html' => [
768 'type' => 'Text',
769 'label' => ts("Subject"),
770 ],
771 'add' => NULL,
772 ],
773 'body_text' => [
774 'name' => 'body_text',
775 'type' => CRM_Utils_Type::T_LONGTEXT,
776 'title' => ts('Body Text'),
777 'description' => ts('Body of the mailing in text format.'),
778 'where' => 'civicrm_mailing.body_text',
779 'table_name' => 'civicrm_mailing',
780 'entity' => 'Mailing',
781 'bao' => 'CRM_Mailing_BAO_Mailing',
782 'localizable' => 0,
783 'html' => [
784 'label' => ts("Body Text"),
785 ],
786 'add' => NULL,
787 ],
788 'body_html' => [
789 'name' => 'body_html',
790 'type' => CRM_Utils_Type::T_LONGTEXT,
791 'title' => ts('Body Html'),
792 'description' => ts('Body of the mailing in html format.'),
793 'where' => 'civicrm_mailing.body_html',
794 'table_name' => 'civicrm_mailing',
795 'entity' => 'Mailing',
796 'bao' => 'CRM_Mailing_BAO_Mailing',
797 'localizable' => 0,
798 'html' => [
799 'label' => ts("Body HTML"),
800 ],
801 'add' => NULL,
802 ],
803 'url_tracking' => [
804 'name' => 'url_tracking',
805 'type' => CRM_Utils_Type::T_BOOLEAN,
806 'title' => ts('Url Tracking'),
807 'description' => ts('Should we track URL click-throughs for this mailing?'),
808 'where' => 'civicrm_mailing.url_tracking',
809 'table_name' => 'civicrm_mailing',
810 'entity' => 'Mailing',
811 'bao' => 'CRM_Mailing_BAO_Mailing',
812 'localizable' => 0,
813 'html' => [
814 'type' => 'CheckBox',
815 'label' => ts("Url Tracking"),
816 ],
817 'add' => NULL,
818 ],
819 'forward_replies' => [
820 'name' => 'forward_replies',
821 'type' => CRM_Utils_Type::T_BOOLEAN,
822 'title' => ts('Forward Replies'),
823 'description' => ts('Should we forward replies back to the author?'),
824 'where' => 'civicrm_mailing.forward_replies',
825 'table_name' => 'civicrm_mailing',
826 'entity' => 'Mailing',
827 'bao' => 'CRM_Mailing_BAO_Mailing',
828 'localizable' => 0,
829 'html' => [
830 'type' => 'CheckBox',
831 'label' => ts("Forward Replies"),
832 ],
833 'add' => NULL,
834 ],
835 'auto_responder' => [
836 'name' => 'auto_responder',
837 'type' => CRM_Utils_Type::T_BOOLEAN,
838 'title' => ts('Auto Responder'),
839 'description' => ts('Should we enable the auto-responder?'),
840 'where' => 'civicrm_mailing.auto_responder',
841 'table_name' => 'civicrm_mailing',
842 'entity' => 'Mailing',
843 'bao' => 'CRM_Mailing_BAO_Mailing',
844 'localizable' => 0,
845 'html' => [
846 'type' => 'CheckBox',
847 'label' => ts("Auto Responder"),
848 ],
849 'add' => NULL,
850 ],
851 'open_tracking' => [
852 'name' => 'open_tracking',
853 'type' => CRM_Utils_Type::T_BOOLEAN,
854 'title' => ts('Track Mailing?'),
855 'description' => ts('Should we track when recipients open/read this mailing?'),
856 'where' => 'civicrm_mailing.open_tracking',
857 'table_name' => 'civicrm_mailing',
858 'entity' => 'Mailing',
859 'bao' => 'CRM_Mailing_BAO_Mailing',
860 'localizable' => 0,
861 'add' => NULL,
862 ],
863 'is_completed' => [
864 'name' => 'is_completed',
865 'type' => CRM_Utils_Type::T_BOOLEAN,
866 'title' => ts('Mailing Completed'),
867 'description' => ts('Has at least one job associated with this mailing finished?'),
868 'where' => 'civicrm_mailing.is_completed',
869 'table_name' => 'civicrm_mailing',
870 'entity' => 'Mailing',
871 'bao' => 'CRM_Mailing_BAO_Mailing',
872 'localizable' => 0,
873 'html' => [
874 'type' => 'CheckBox',
875 ],
876 'add' => NULL,
877 ],
878 'msg_template_id' => [
879 'name' => 'msg_template_id',
880 'type' => CRM_Utils_Type::T_INT,
881 'title' => ts('Message Template ID'),
882 'description' => ts('FK to the message template.'),
883 'where' => 'civicrm_mailing.msg_template_id',
884 'table_name' => 'civicrm_mailing',
885 'entity' => 'Mailing',
886 'bao' => 'CRM_Mailing_BAO_Mailing',
887 'localizable' => 0,
888 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
889 'html' => [
890 'label' => ts("Message Template"),
891 ],
892 'add' => NULL,
893 ],
894 'override_verp' => [
895 'name' => 'override_verp',
896 'type' => CRM_Utils_Type::T_BOOLEAN,
897 'title' => ts('Override Verp'),
898 'description' => ts('Overwrite the VERP address in Reply-To'),
899 'where' => 'civicrm_mailing.override_verp',
900 'default' => '0',
901 'table_name' => 'civicrm_mailing',
902 'entity' => 'Mailing',
903 'bao' => 'CRM_Mailing_BAO_Mailing',
904 'localizable' => 0,
905 'html' => [
906 'type' => 'CheckBox',
907 'label' => ts("Overwrite VERP"),
908 ],
909 'add' => '2.2',
910 ],
911 'created_id' => [
912 'name' => 'created_id',
913 'type' => CRM_Utils_Type::T_INT,
914 'title' => ts('Created By Contact ID'),
915 'description' => ts('FK to Contact ID who first created this mailing'),
916 'where' => 'civicrm_mailing.created_id',
917 'table_name' => 'civicrm_mailing',
918 'entity' => 'Mailing',
919 'bao' => 'CRM_Mailing_BAO_Mailing',
920 'localizable' => 0,
921 'FKClassName' => 'CRM_Contact_DAO_Contact',
922 'html' => [
923 'label' => ts("Creator"),
924 ],
925 'add' => NULL,
926 ],
927 'created_date' => [
928 'name' => 'created_date',
929 'type' => CRM_Utils_Type::T_TIMESTAMP,
930 'title' => ts('Mailing Created Date'),
931 'description' => ts('Date and time this mailing was created.'),
932 'required' => FALSE,
933 'where' => 'civicrm_mailing.created_date',
934 'default' => 'CURRENT_TIMESTAMP',
935 'table_name' => 'civicrm_mailing',
936 'entity' => 'Mailing',
937 'bao' => 'CRM_Mailing_BAO_Mailing',
938 'localizable' => 0,
939 'html' => [
940 'type' => 'Select Date',
941 'formatType' => 'activityDateTime',
942 ],
943 'add' => '3.0',
944 ],
945 'mailing_modified_date' => [
946 'name' => 'modified_date',
947 'type' => CRM_Utils_Type::T_TIMESTAMP,
948 'title' => ts('Modified Date'),
949 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
950 'required' => FALSE,
951 'where' => 'civicrm_mailing.modified_date',
952 'export' => TRUE,
953 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
954 'table_name' => 'civicrm_mailing',
955 'entity' => 'Mailing',
956 'bao' => 'CRM_Mailing_BAO_Mailing',
957 'localizable' => 0,
958 'html' => [
959 'label' => ts("Modified Date"),
960 ],
961 'readonly' => TRUE,
962 'add' => '4.7',
963 ],
964 'scheduled_id' => [
965 'name' => 'scheduled_id',
966 'type' => CRM_Utils_Type::T_INT,
967 'title' => ts('Scheduled By Contact ID'),
968 'description' => ts('FK to Contact ID who scheduled this mailing'),
969 'where' => 'civicrm_mailing.scheduled_id',
970 'table_name' => 'civicrm_mailing',
971 'entity' => 'Mailing',
972 'bao' => 'CRM_Mailing_BAO_Mailing',
973 'localizable' => 0,
974 'FKClassName' => 'CRM_Contact_DAO_Contact',
975 'html' => [
976 'label' => ts("Scheduled By"),
977 ],
978 'add' => NULL,
979 ],
980 'scheduled_date' => [
981 'name' => 'scheduled_date',
982 'type' => CRM_Utils_Type::T_TIMESTAMP,
983 'title' => ts('Mailing Scheduled Date'),
984 'description' => ts('Date and time this mailing was scheduled.'),
985 'required' => FALSE,
986 'where' => 'civicrm_mailing.scheduled_date',
987 'default' => NULL,
988 'table_name' => 'civicrm_mailing',
989 'entity' => 'Mailing',
990 'bao' => 'CRM_Mailing_BAO_Mailing',
991 'localizable' => 0,
992 'html' => [
993 'type' => 'Select Date',
994 'formatType' => 'activityDateTime',
995 ],
996 'add' => '3.3',
997 ],
998 'approver_id' => [
999 'name' => 'approver_id',
1000 'type' => CRM_Utils_Type::T_INT,
1001 'title' => ts('Approved By Contact ID'),
1002 'description' => ts('FK to Contact ID who approved this mailing'),
1003 'where' => 'civicrm_mailing.approver_id',
1004 'table_name' => 'civicrm_mailing',
1005 'entity' => 'Mailing',
1006 'bao' => 'CRM_Mailing_BAO_Mailing',
1007 'localizable' => 0,
1008 'FKClassName' => 'CRM_Contact_DAO_Contact',
1009 'html' => [
1010 'label' => ts("Approved By"),
1011 ],
1012 'add' => NULL,
1013 ],
1014 'approval_date' => [
1015 'name' => 'approval_date',
1016 'type' => CRM_Utils_Type::T_TIMESTAMP,
1017 'title' => ts('Mailing Approved Date'),
1018 'description' => ts('Date and time this mailing was approved.'),
1019 'required' => FALSE,
1020 'where' => 'civicrm_mailing.approval_date',
1021 'default' => NULL,
1022 'table_name' => 'civicrm_mailing',
1023 'entity' => 'Mailing',
1024 'bao' => 'CRM_Mailing_BAO_Mailing',
1025 'localizable' => 0,
1026 'html' => [
1027 'type' => 'Select Date',
1028 'formatType' => 'activityDateTime',
1029 ],
1030 'add' => '3.3',
1031 ],
1032 'approval_status_id' => [
1033 'name' => 'approval_status_id',
1034 'type' => CRM_Utils_Type::T_INT,
1035 'title' => ts('Approval Status'),
1036 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
1037 'where' => 'civicrm_mailing.approval_status_id',
1038 'table_name' => 'civicrm_mailing',
1039 'entity' => 'Mailing',
1040 'bao' => 'CRM_Mailing_BAO_Mailing',
1041 'localizable' => 0,
1042 'html' => [
1043 'type' => 'Select',
1044 ],
1045 'pseudoconstant' => [
1046 'optionGroupName' => 'mail_approval_status',
1047 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
1048 ],
1049 'add' => '3.3',
1050 ],
1051 'approval_note' => [
1052 'name' => 'approval_note',
1053 'type' => CRM_Utils_Type::T_LONGTEXT,
1054 'title' => ts('Approval Note'),
1055 'description' => ts('Note behind the decision.'),
1056 'where' => 'civicrm_mailing.approval_note',
1057 'table_name' => 'civicrm_mailing',
1058 'entity' => 'Mailing',
1059 'bao' => 'CRM_Mailing_BAO_Mailing',
1060 'localizable' => 0,
1061 'html' => [
1062 'type' => 'TextArea',
1063 ],
1064 'add' => '3.3',
1065 ],
1066 'is_archived' => [
1067 'name' => 'is_archived',
1068 'type' => CRM_Utils_Type::T_BOOLEAN,
1069 'title' => ts('Is Mailing Archived?'),
1070 'description' => ts('Is this mailing archived?'),
1071 'where' => 'civicrm_mailing.is_archived',
1072 'default' => '0',
1073 'table_name' => 'civicrm_mailing',
1074 'entity' => 'Mailing',
1075 'bao' => 'CRM_Mailing_BAO_Mailing',
1076 'localizable' => 0,
1077 'html' => [
1078 'type' => 'CheckBox',
1079 ],
1080 'add' => '2.2',
1081 ],
1082 'visibility' => [
1083 'name' => 'visibility',
1084 'type' => CRM_Utils_Type::T_STRING,
1085 'title' => ts('Mailing Visibility'),
1086 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
1087 'maxlength' => 40,
1088 'size' => CRM_Utils_Type::BIG,
1089 'where' => 'civicrm_mailing.visibility',
1090 'default' => 'Public Pages',
1091 'table_name' => 'civicrm_mailing',
1092 'entity' => 'Mailing',
1093 'bao' => 'CRM_Mailing_BAO_Mailing',
1094 'localizable' => 0,
1095 'html' => [
1096 'type' => 'Select',
1097 ],
1098 'pseudoconstant' => [
1099 'callback' => 'CRM_Core_SelectValues::groupVisibility',
1100 ],
1101 'add' => '3.3',
1102 ],
1103 'campaign_id' => [
1104 'name' => 'campaign_id',
1105 'type' => CRM_Utils_Type::T_INT,
1106 'title' => ts('Campaign ID'),
1107 'description' => ts('The campaign for which this mailing has been initiated.'),
1108 'where' => 'civicrm_mailing.campaign_id',
1109 'table_name' => 'civicrm_mailing',
1110 'entity' => 'Mailing',
1111 'bao' => 'CRM_Mailing_BAO_Mailing',
1112 'localizable' => 0,
1113 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1114 'component' => 'CiviCampaign',
1115 'html' => [
1116 'type' => 'EntityRef',
1117 'label' => ts("Campaign"),
1118 ],
1119 'pseudoconstant' => [
1120 'table' => 'civicrm_campaign',
1121 'keyColumn' => 'id',
1122 'labelColumn' => 'title',
1123 'prefetch' => 'FALSE',
1124 ],
1125 'add' => '3.4',
1126 ],
1127 'dedupe_email' => [
1128 'name' => 'dedupe_email',
1129 'type' => CRM_Utils_Type::T_BOOLEAN,
1130 'title' => ts('No Duplicate emails?'),
1131 'description' => ts('Remove duplicate emails?'),
1132 'where' => 'civicrm_mailing.dedupe_email',
1133 'default' => '0',
1134 'table_name' => 'civicrm_mailing',
1135 'entity' => 'Mailing',
1136 'bao' => 'CRM_Mailing_BAO_Mailing',
1137 'localizable' => 0,
1138 'html' => [
1139 'type' => 'CheckBox',
1140 ],
1141 'add' => '4.1',
1142 ],
1143 'sms_provider_id' => [
1144 'name' => 'sms_provider_id',
1145 'type' => CRM_Utils_Type::T_INT,
1146 'title' => ts('SMS Provider ID'),
1147 'where' => 'civicrm_mailing.sms_provider_id',
1148 'table_name' => 'civicrm_mailing',
1149 'entity' => 'Mailing',
1150 'bao' => 'CRM_Mailing_BAO_Mailing',
1151 'localizable' => 0,
1152 'FKClassName' => 'CRM_SMS_DAO_Provider',
1153 'html' => [
1154 'type' => 'Select',
1155 'label' => ts("SMS Provider"),
1156 ],
1157 'add' => '4.2',
1158 ],
1159 'hash' => [
1160 'name' => 'hash',
1161 'type' => CRM_Utils_Type::T_STRING,
1162 'title' => ts('Mailing Hash'),
1163 'description' => ts('Key for validating requests related to this mailing.'),
1164 'maxlength' => 16,
1165 'size' => CRM_Utils_Type::TWELVE,
1166 'where' => 'civicrm_mailing.hash',
1167 'table_name' => 'civicrm_mailing',
1168 'entity' => 'Mailing',
1169 'bao' => 'CRM_Mailing_BAO_Mailing',
1170 'localizable' => 0,
1171 'readonly' => TRUE,
1172 'add' => '4.5',
1173 ],
1174 'location_type_id' => [
1175 'name' => 'location_type_id',
1176 'type' => CRM_Utils_Type::T_INT,
1177 'title' => ts('Location Type ID'),
1178 'description' => ts('With email_selection_method, determines which email address to use'),
1179 'where' => 'civicrm_mailing.location_type_id',
1180 'table_name' => 'civicrm_mailing',
1181 'entity' => 'Mailing',
1182 'bao' => 'CRM_Mailing_BAO_Mailing',
1183 'localizable' => 0,
1184 'FKClassName' => 'CRM_Core_DAO_LocationType',
1185 'html' => [
1186 'label' => ts("Location Type"),
1187 ],
1188 'pseudoconstant' => [
1189 'table' => 'civicrm_location_type',
1190 'keyColumn' => 'id',
1191 'labelColumn' => 'display_name',
1192 ],
1193 'add' => '4.6',
1194 ],
1195 'email_selection_method' => [
1196 'name' => 'email_selection_method',
1197 'type' => CRM_Utils_Type::T_STRING,
1198 'title' => ts('Email Selection Method'),
1199 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
1200 'maxlength' => 20,
1201 'size' => CRM_Utils_Type::MEDIUM,
1202 'where' => 'civicrm_mailing.email_selection_method',
1203 'default' => 'automatic',
1204 'table_name' => 'civicrm_mailing',
1205 'entity' => 'Mailing',
1206 'bao' => 'CRM_Mailing_BAO_Mailing',
1207 'localizable' => 0,
1208 'html' => [
1209 'label' => ts("Email Selection Method"),
1210 ],
1211 'pseudoconstant' => [
1212 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1213 ],
1214 'add' => '4.6',
1215 ],
1216 'language' => [
1217 'name' => 'language',
1218 'type' => CRM_Utils_Type::T_STRING,
1219 'title' => ts('Mailing Language'),
1220 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
1221 'maxlength' => 5,
1222 'size' => CRM_Utils_Type::SIX,
1223 'where' => 'civicrm_mailing.language',
1224 'table_name' => 'civicrm_mailing',
1225 'entity' => 'Mailing',
1226 'bao' => 'CRM_Mailing_BAO_Mailing',
1227 'localizable' => 0,
1228 'html' => [
1229 'type' => 'Select',
1230 ],
1231 'pseudoconstant' => [
1232 'optionGroupName' => 'languages',
1233 'keyColumn' => 'name',
1234 'optionEditPath' => 'civicrm/admin/options/languages',
1235 ],
1236 'add' => '4.6',
1237 ],
1238 ];
1239 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1240 }
1241 return Civi::$statics[__CLASS__]['fields'];
1242 }
1243
1244 /**
1245 * Return a mapping from field-name to the corresponding key (as used in fields()).
1246 *
1247 * @return array
1248 * Array(string $name => string $uniqueName).
1249 */
1250 public static function &fieldKeys() {
1251 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
1252 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
1253 }
1254 return Civi::$statics[__CLASS__]['fieldKeys'];
1255 }
1256
1257 /**
1258 * Returns the names of this table
1259 *
1260 * @return string
1261 */
1262 public static function getTableName() {
1263 return self::$_tableName;
1264 }
1265
1266 /**
1267 * Returns if this table needs to be logged
1268 *
1269 * @return bool
1270 */
1271 public function getLog() {
1272 return self::$_log;
1273 }
1274
1275 /**
1276 * Returns the list of fields that can be imported
1277 *
1278 * @param bool $prefix
1279 *
1280 * @return array
1281 */
1282 public static function &import($prefix = FALSE) {
1283 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, []);
1284 return $r;
1285 }
1286
1287 /**
1288 * Returns the list of fields that can be exported
1289 *
1290 * @param bool $prefix
1291 *
1292 * @return array
1293 */
1294 public static function &export($prefix = FALSE) {
1295 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, []);
1296 return $r;
1297 }
1298
1299 /**
1300 * Returns the list of indices
1301 *
1302 * @param bool $localize
1303 *
1304 * @return array
1305 */
1306 public static function indices($localize = TRUE) {
1307 $indices = [
1308 'index_hash' => [
1309 'name' => 'index_hash',
1310 'field' => [
1311 0 => 'hash',
1312 ],
1313 'localizable' => FALSE,
1314 'sig' => 'civicrm_mailing::0::hash',
1315 ],
1316 ];
1317 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1318 }
1319
1320 }