5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Mailing/Mailing.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:9815b093c77eedc9aa2c97c338a0e75d)
13 * Database access object for the Mailing entity.
15 class CRM_Mailing_DAO_Mailing
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '';
18 const COMPONENT
= 'CiviMail';
21 * Static instance to hold the table name.
25 public static $_tableName = 'civicrm_mailing';
28 * Icon associated with this entity.
32 public static $_icon = 'fa-envelope-o';
35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
39 public static $_log = FALSE;
42 * Paths for accessing this entity in the UI.
46 protected static $_paths = [
47 'add' => 'civicrm/a/#/mailing/new',
48 'update' => 'civicrm/a/#/mailing/[id]',
52 * @var int|string|null
53 * (SQL type: int unsigned)
54 * Note that values will be retrieved from the database as a string.
59 * Which site is this mailing for
61 * @var int|string|null
62 * (SQL type: int unsigned)
63 * Note that values will be retrieved from the database as a string.
68 * FK to the header component.
70 * @var int|string|null
71 * (SQL type: int unsigned)
72 * Note that values will be retrieved from the database as a string.
77 * FK to the footer component.
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
86 * FK to the auto-responder component.
88 * @var int|string|null
89 * (SQL type: int unsigned)
90 * Note that values will be retrieved from the database as a string.
95 * FK to the unsubscribe component.
97 * @var int|string|null
98 * (SQL type: int unsigned)
99 * Note that values will be retrieved from the database as a string.
101 public $unsubscribe_id;
104 * @var int|string|null
105 * (SQL type: int unsigned)
106 * Note that values will be retrieved from the database as a string.
108 public $resubscribe_id;
111 * FK to the opt-out component.
113 * @var int|string|null
114 * (SQL type: int unsigned)
115 * Note that values will be retrieved from the database as a string.
123 * (SQL type: varchar(128))
124 * Note that values will be retrieved from the database as a string.
129 * differentiate between standalone mailings, A/B tests, and A/B final-winner
132 * (SQL type: varchar(32))
133 * Note that values will be retrieved from the database as a string.
135 public $mailing_type;
138 * From Header of mailing
141 * (SQL type: varchar(128))
142 * Note that values will be retrieved from the database as a string.
147 * From Email of mailing
150 * (SQL type: varchar(128))
151 * Note that values will be retrieved from the database as a string.
156 * Reply-To Email of mailing
159 * (SQL type: varchar(128))
160 * Note that values will be retrieved from the database as a string.
162 public $replyto_email;
165 * The language/processing system used for email templates.
168 * (SQL type: varchar(64))
169 * Note that values will be retrieved from the database as a string.
171 public $template_type;
174 * Advanced options used by the email templating system. (JSON encoded)
177 * (SQL type: longtext)
178 * Note that values will be retrieved from the database as a string.
180 public $template_options;
186 * (SQL type: varchar(128))
187 * Note that values will be retrieved from the database as a string.
192 * Body of the mailing in text format.
195 * (SQL type: longtext)
196 * Note that values will be retrieved from the database as a string.
201 * Body of the mailing in html format.
204 * (SQL type: longtext)
205 * Note that values will be retrieved from the database as a string.
210 * Should we track URL click-throughs for this mailing?
212 * @var bool|string|null
213 * (SQL type: tinyint)
214 * Note that values will be retrieved from the database as a string.
216 public $url_tracking;
219 * Should we forward replies back to the author?
221 * @var bool|string|null
222 * (SQL type: tinyint)
223 * Note that values will be retrieved from the database as a string.
225 public $forward_replies;
228 * Should we enable the auto-responder?
230 * @var bool|string|null
231 * (SQL type: tinyint)
232 * Note that values will be retrieved from the database as a string.
234 public $auto_responder;
237 * Should we track when recipients open/read this mailing?
239 * @var bool|string|null
240 * (SQL type: tinyint)
241 * Note that values will be retrieved from the database as a string.
243 public $open_tracking;
246 * Has at least one job associated with this mailing finished?
248 * @var bool|string|null
249 * (SQL type: tinyint)
250 * Note that values will be retrieved from the database as a string.
252 public $is_completed;
255 * FK to the message template.
257 * @var int|string|null
258 * (SQL type: int unsigned)
259 * Note that values will be retrieved from the database as a string.
261 public $msg_template_id;
264 * Overwrite the VERP address in Reply-To
266 * @var bool|string|null
267 * (SQL type: tinyint)
268 * Note that values will be retrieved from the database as a string.
270 public $override_verp;
273 * FK to Contact ID who first created this mailing
275 * @var int|string|null
276 * (SQL type: int unsigned)
277 * Note that values will be retrieved from the database as a string.
282 * Date and time this mailing was created.
285 * (SQL type: timestamp)
286 * Note that values will be retrieved from the database as a string.
288 public $created_date;
291 * When the mailing (or closely related entity) was created or modified or deleted.
294 * (SQL type: timestamp)
295 * Note that values will be retrieved from the database as a string.
297 public $modified_date;
300 * FK to Contact ID who scheduled this mailing
302 * @var int|string|null
303 * (SQL type: int unsigned)
304 * Note that values will be retrieved from the database as a string.
306 public $scheduled_id;
309 * Date and time this mailing was scheduled.
312 * (SQL type: timestamp)
313 * Note that values will be retrieved from the database as a string.
315 public $scheduled_date;
318 * FK to Contact ID who approved this mailing
320 * @var int|string|null
321 * (SQL type: int unsigned)
322 * Note that values will be retrieved from the database as a string.
327 * Date and time this mailing was approved.
330 * (SQL type: timestamp)
331 * Note that values will be retrieved from the database as a string.
333 public $approval_date;
336 * The status of this mailing. Values: none, approved, rejected
338 * @var int|string|null
339 * (SQL type: int unsigned)
340 * Note that values will be retrieved from the database as a string.
342 public $approval_status_id;
345 * Note behind the decision.
348 * (SQL type: longtext)
349 * Note that values will be retrieved from the database as a string.
351 public $approval_note;
354 * Is this mailing archived?
356 * @var bool|string|null
357 * (SQL type: tinyint)
358 * Note that values will be retrieved from the database as a string.
363 * In what context(s) is the mailing contents visible (online viewing)
366 * (SQL type: varchar(40))
367 * Note that values will be retrieved from the database as a string.
372 * The campaign for which this mailing has been initiated.
374 * @var int|string|null
375 * (SQL type: int unsigned)
376 * Note that values will be retrieved from the database as a string.
381 * Remove duplicate emails?
383 * @var bool|string|null
384 * (SQL type: tinyint)
385 * Note that values will be retrieved from the database as a string.
387 public $dedupe_email;
390 * @var int|string|null
391 * (SQL type: int unsigned)
392 * Note that values will be retrieved from the database as a string.
394 public $sms_provider_id;
397 * Key for validating requests related to this mailing.
400 * (SQL type: varchar(16))
401 * Note that values will be retrieved from the database as a string.
406 * With email_selection_method, determines which email address to use
408 * @var int|string|null
409 * (SQL type: int unsigned)
410 * Note that values will be retrieved from the database as a string.
412 public $location_type_id;
415 * With location_type_id, determine how to choose the email address to use.
418 * (SQL type: varchar(20))
419 * Note that values will be retrieved from the database as a string.
421 public $email_selection_method;
424 * Language of the content of the mailing. Useful for tokens.
427 * (SQL type: varchar(5))
428 * Note that values will be retrieved from the database as a string.
435 public function __construct() {
436 $this->__table
= 'civicrm_mailing';
437 parent
::__construct();
441 * Returns localized title of this entity.
443 * @param bool $plural
444 * Whether to return the plural version of the title.
446 public static function getEntityTitle($plural = FALSE) {
447 return $plural ?
ts('Mailings') : ts('Mailing');
451 * Returns user-friendly description of this entity.
455 public static function getEntityDescription() {
456 return ts('Mass emails sent from CiviMail.');
460 * Returns foreign keys and entity references.
463 * [CRM_Core_Reference_Interface]
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']);
483 return Civi
::$statics[__CLASS__
]['links'];
487 * Returns all the column names of this table
491 public static function &fields() {
492 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
493 Civi
::$statics[__CLASS__
]['fields'] = [
496 'type' => CRM_Utils_Type
::T_INT
,
497 'title' => ts('Mailing ID'),
499 'where' => 'civicrm_mailing.id',
500 'table_name' => 'civicrm_mailing',
501 'entity' => 'Mailing',
502 'bao' => 'CRM_Mailing_BAO_Mailing',
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',
520 'FKClassName' => 'CRM_Core_DAO_Domain',
522 'label' => ts("Domain"),
524 'pseudoconstant' => [
525 'table' => 'civicrm_domain',
527 'labelColumn' => 'name',
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',
541 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
543 'label' => ts("Header"),
545 'pseudoconstant' => [
546 'table' => 'civicrm_mailing_component',
548 'labelColumn' => 'name',
549 'condition' => 'component_type = "Header"',
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',
563 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
565 'label' => ts("Footer"),
567 'pseudoconstant' => [
568 'table' => 'civicrm_mailing_component',
570 'labelColumn' => 'name',
571 'condition' => 'component_type = "Footer"',
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',
585 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
587 'label' => ts("Reply"),
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',
601 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
603 'label' => ts("Unsubscribe"),
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',
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',
628 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
630 'label' => ts("Opt Out"),
636 'type' => CRM_Utils_Type
::T_STRING
,
637 'title' => ts('Mailing Name'),
638 'description' => ts('Mailing Name.'),
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',
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'),
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',
666 'pseudoconstant' => [
667 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
672 'name' => 'from_name',
673 'type' => CRM_Utils_Type
::T_STRING
,
674 'title' => ts('Mailing From Name'),
675 'description' => ts('From Header of mailing'),
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',
689 'name' => 'from_email',
690 'type' => CRM_Utils_Type
::T_STRING
,
691 'title' => ts('Mailing From Email'),
692 'description' => ts('From Email of mailing'),
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',
706 'name' => 'replyto_email',
707 'type' => CRM_Utils_Type
::T_STRING
,
708 'title' => ts('Replyto Email'),
709 'description' => ts('Reply-To Email of mailing'),
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',
719 'label' => ts("Reply-To Email"),
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.'),
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',
737 'pseudoconstant' => [
738 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
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',
756 'type' => CRM_Utils_Type
::T_STRING
,
757 'title' => ts('Subject'),
758 'description' => ts('Subject of mailing'),
760 'size' => CRM_Utils_Type
::HUGE
,
761 'where' => 'civicrm_mailing.subject',
762 'table_name' => 'civicrm_mailing',
763 'entity' => 'Mailing',
764 'bao' => 'CRM_Mailing_BAO_Mailing',
768 'label' => ts("Subject"),
773 'name' => 'body_text',
774 'type' => CRM_Utils_Type
::T_LONGTEXT
,
775 'title' => ts('Body Text'),
776 'description' => ts('Body of the mailing in text format.'),
777 'where' => 'civicrm_mailing.body_text',
778 'table_name' => 'civicrm_mailing',
779 'entity' => 'Mailing',
780 'bao' => 'CRM_Mailing_BAO_Mailing',
783 'label' => ts("Body Text"),
788 'name' => 'body_html',
789 'type' => CRM_Utils_Type
::T_LONGTEXT
,
790 'title' => ts('Body Html'),
791 'description' => ts('Body of the mailing in html format.'),
792 'where' => 'civicrm_mailing.body_html',
793 'table_name' => 'civicrm_mailing',
794 'entity' => 'Mailing',
795 'bao' => 'CRM_Mailing_BAO_Mailing',
798 'label' => ts("Body HTML"),
803 'name' => 'url_tracking',
804 'type' => CRM_Utils_Type
::T_BOOLEAN
,
805 'title' => ts('Url Tracking'),
806 'description' => ts('Should we track URL click-throughs for this mailing?'),
807 'where' => 'civicrm_mailing.url_tracking',
808 'table_name' => 'civicrm_mailing',
809 'entity' => 'Mailing',
810 'bao' => 'CRM_Mailing_BAO_Mailing',
813 'type' => 'CheckBox',
814 'label' => ts("Url Tracking"),
818 'forward_replies' => [
819 'name' => 'forward_replies',
820 'type' => CRM_Utils_Type
::T_BOOLEAN
,
821 'title' => ts('Forward Replies'),
822 'description' => ts('Should we forward replies back to the author?'),
823 'where' => 'civicrm_mailing.forward_replies',
824 'table_name' => 'civicrm_mailing',
825 'entity' => 'Mailing',
826 'bao' => 'CRM_Mailing_BAO_Mailing',
829 'type' => 'CheckBox',
830 'label' => ts("Forward Replies"),
834 'auto_responder' => [
835 'name' => 'auto_responder',
836 'type' => CRM_Utils_Type
::T_BOOLEAN
,
837 'title' => ts('Auto Responder'),
838 'description' => ts('Should we enable the auto-responder?'),
839 'where' => 'civicrm_mailing.auto_responder',
840 'table_name' => 'civicrm_mailing',
841 'entity' => 'Mailing',
842 'bao' => 'CRM_Mailing_BAO_Mailing',
845 'type' => 'CheckBox',
846 'label' => ts("Auto Responder"),
851 'name' => 'open_tracking',
852 'type' => CRM_Utils_Type
::T_BOOLEAN
,
853 'title' => ts('Track Mailing?'),
854 'description' => ts('Should we track when recipients open/read this mailing?'),
855 'where' => 'civicrm_mailing.open_tracking',
856 'table_name' => 'civicrm_mailing',
857 'entity' => 'Mailing',
858 'bao' => 'CRM_Mailing_BAO_Mailing',
863 'name' => 'is_completed',
864 'type' => CRM_Utils_Type
::T_BOOLEAN
,
865 'title' => ts('Mailing Completed'),
866 'description' => ts('Has at least one job associated with this mailing finished?'),
867 'where' => 'civicrm_mailing.is_completed',
868 'table_name' => 'civicrm_mailing',
869 'entity' => 'Mailing',
870 'bao' => 'CRM_Mailing_BAO_Mailing',
873 'type' => 'CheckBox',
877 'msg_template_id' => [
878 'name' => 'msg_template_id',
879 'type' => CRM_Utils_Type
::T_INT
,
880 'title' => ts('Message Template ID'),
881 'description' => ts('FK to the message template.'),
882 'where' => 'civicrm_mailing.msg_template_id',
883 'table_name' => 'civicrm_mailing',
884 'entity' => 'Mailing',
885 'bao' => 'CRM_Mailing_BAO_Mailing',
887 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
889 'label' => ts("Message Template"),
894 'name' => 'override_verp',
895 'type' => CRM_Utils_Type
::T_BOOLEAN
,
896 'title' => ts('Override Verp'),
897 'description' => ts('Overwrite the VERP address in Reply-To'),
898 'where' => 'civicrm_mailing.override_verp',
900 'table_name' => 'civicrm_mailing',
901 'entity' => 'Mailing',
902 'bao' => 'CRM_Mailing_BAO_Mailing',
905 'type' => 'CheckBox',
906 'label' => ts("Overwrite VERP"),
911 'name' => 'created_id',
912 'type' => CRM_Utils_Type
::T_INT
,
913 'title' => ts('Created By Contact ID'),
914 'description' => ts('FK to Contact ID who first created this mailing'),
915 'where' => 'civicrm_mailing.created_id',
916 'table_name' => 'civicrm_mailing',
917 'entity' => 'Mailing',
918 'bao' => 'CRM_Mailing_BAO_Mailing',
920 'FKClassName' => 'CRM_Contact_DAO_Contact',
922 'label' => ts("Creator"),
927 'name' => 'created_date',
928 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
929 'title' => ts('Mailing Created Date'),
930 'description' => ts('Date and time this mailing was created.'),
932 'where' => 'civicrm_mailing.created_date',
933 'default' => 'CURRENT_TIMESTAMP',
934 'table_name' => 'civicrm_mailing',
935 'entity' => 'Mailing',
936 'bao' => 'CRM_Mailing_BAO_Mailing',
939 'type' => 'Select Date',
940 'formatType' => 'activityDateTime',
944 'mailing_modified_date' => [
945 'name' => 'modified_date',
946 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
947 'title' => ts('Modified Date'),
948 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
950 'where' => 'civicrm_mailing.modified_date',
952 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
953 'table_name' => 'civicrm_mailing',
954 'entity' => 'Mailing',
955 'bao' => 'CRM_Mailing_BAO_Mailing',
958 'label' => ts("Modified Date"),
964 'name' => 'scheduled_id',
965 'type' => CRM_Utils_Type
::T_INT
,
966 'title' => ts('Scheduled By Contact ID'),
967 'description' => ts('FK to Contact ID who scheduled this mailing'),
968 'where' => 'civicrm_mailing.scheduled_id',
969 'table_name' => 'civicrm_mailing',
970 'entity' => 'Mailing',
971 'bao' => 'CRM_Mailing_BAO_Mailing',
973 'FKClassName' => 'CRM_Contact_DAO_Contact',
975 'label' => ts("Scheduled By"),
979 'scheduled_date' => [
980 'name' => 'scheduled_date',
981 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
982 'title' => ts('Mailing Scheduled Date'),
983 'description' => ts('Date and time this mailing was scheduled.'),
985 'where' => 'civicrm_mailing.scheduled_date',
987 'table_name' => 'civicrm_mailing',
988 'entity' => 'Mailing',
989 'bao' => 'CRM_Mailing_BAO_Mailing',
992 'type' => 'Select Date',
993 'formatType' => 'activityDateTime',
998 'name' => 'approver_id',
999 'type' => CRM_Utils_Type
::T_INT
,
1000 'title' => ts('Approved By Contact ID'),
1001 'description' => ts('FK to Contact ID who approved this mailing'),
1002 'where' => 'civicrm_mailing.approver_id',
1003 'table_name' => 'civicrm_mailing',
1004 'entity' => 'Mailing',
1005 'bao' => 'CRM_Mailing_BAO_Mailing',
1007 'FKClassName' => 'CRM_Contact_DAO_Contact',
1009 'label' => ts("Approved By"),
1013 'approval_date' => [
1014 'name' => 'approval_date',
1015 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1016 'title' => ts('Mailing Approved Date'),
1017 'description' => ts('Date and time this mailing was approved.'),
1018 'required' => FALSE,
1019 'where' => 'civicrm_mailing.approval_date',
1021 'table_name' => 'civicrm_mailing',
1022 'entity' => 'Mailing',
1023 'bao' => 'CRM_Mailing_BAO_Mailing',
1026 'type' => 'Select Date',
1027 'formatType' => 'activityDateTime',
1031 'approval_status_id' => [
1032 'name' => 'approval_status_id',
1033 'type' => CRM_Utils_Type
::T_INT
,
1034 'title' => ts('Approval Status'),
1035 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
1036 'where' => 'civicrm_mailing.approval_status_id',
1037 'table_name' => 'civicrm_mailing',
1038 'entity' => 'Mailing',
1039 'bao' => 'CRM_Mailing_BAO_Mailing',
1044 'pseudoconstant' => [
1045 'optionGroupName' => 'mail_approval_status',
1046 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
1050 'approval_note' => [
1051 'name' => 'approval_note',
1052 'type' => CRM_Utils_Type
::T_LONGTEXT
,
1053 'title' => ts('Approval Note'),
1054 'description' => ts('Note behind the decision.'),
1055 'where' => 'civicrm_mailing.approval_note',
1056 'table_name' => 'civicrm_mailing',
1057 'entity' => 'Mailing',
1058 'bao' => 'CRM_Mailing_BAO_Mailing',
1061 'type' => 'TextArea',
1066 'name' => 'is_archived',
1067 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1068 'title' => ts('Is Mailing Archived?'),
1069 'description' => ts('Is this mailing archived?'),
1070 'where' => 'civicrm_mailing.is_archived',
1072 'table_name' => 'civicrm_mailing',
1073 'entity' => 'Mailing',
1074 'bao' => 'CRM_Mailing_BAO_Mailing',
1077 'type' => 'CheckBox',
1082 'name' => 'visibility',
1083 'type' => CRM_Utils_Type
::T_STRING
,
1084 'title' => ts('Mailing Visibility'),
1085 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
1087 'size' => CRM_Utils_Type
::BIG
,
1088 'where' => 'civicrm_mailing.visibility',
1089 'default' => 'Public Pages',
1090 'table_name' => 'civicrm_mailing',
1091 'entity' => 'Mailing',
1092 'bao' => 'CRM_Mailing_BAO_Mailing',
1097 'pseudoconstant' => [
1098 'callback' => 'CRM_Core_SelectValues::groupVisibility',
1103 'name' => 'campaign_id',
1104 'type' => CRM_Utils_Type
::T_INT
,
1105 'title' => ts('Campaign ID'),
1106 'description' => ts('The campaign for which this mailing has been initiated.'),
1107 'where' => 'civicrm_mailing.campaign_id',
1108 'table_name' => 'civicrm_mailing',
1109 'entity' => 'Mailing',
1110 'bao' => 'CRM_Mailing_BAO_Mailing',
1112 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1113 'component' => 'CiviCampaign',
1115 'type' => 'EntityRef',
1116 'label' => ts("Campaign"),
1118 'pseudoconstant' => [
1119 'table' => 'civicrm_campaign',
1120 'keyColumn' => 'id',
1121 'labelColumn' => 'title',
1122 'prefetch' => 'FALSE',
1127 'name' => 'dedupe_email',
1128 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1129 'title' => ts('No Duplicate emails?'),
1130 'description' => ts('Remove duplicate emails?'),
1131 'where' => 'civicrm_mailing.dedupe_email',
1133 'table_name' => 'civicrm_mailing',
1134 'entity' => 'Mailing',
1135 'bao' => 'CRM_Mailing_BAO_Mailing',
1138 'type' => 'CheckBox',
1142 'sms_provider_id' => [
1143 'name' => 'sms_provider_id',
1144 'type' => CRM_Utils_Type
::T_INT
,
1145 'title' => ts('SMS Provider ID'),
1146 'where' => 'civicrm_mailing.sms_provider_id',
1147 'table_name' => 'civicrm_mailing',
1148 'entity' => 'Mailing',
1149 'bao' => 'CRM_Mailing_BAO_Mailing',
1151 'FKClassName' => 'CRM_SMS_DAO_Provider',
1154 'label' => ts("SMS Provider"),
1160 'type' => CRM_Utils_Type
::T_STRING
,
1161 'title' => ts('Mailing Hash'),
1162 'description' => ts('Key for validating requests related to this mailing.'),
1164 'size' => CRM_Utils_Type
::TWELVE
,
1165 'where' => 'civicrm_mailing.hash',
1166 'table_name' => 'civicrm_mailing',
1167 'entity' => 'Mailing',
1168 'bao' => 'CRM_Mailing_BAO_Mailing',
1173 'location_type_id' => [
1174 'name' => 'location_type_id',
1175 'type' => CRM_Utils_Type
::T_INT
,
1176 'title' => ts('Location Type ID'),
1177 'description' => ts('With email_selection_method, determines which email address to use'),
1178 'where' => 'civicrm_mailing.location_type_id',
1179 'table_name' => 'civicrm_mailing',
1180 'entity' => 'Mailing',
1181 'bao' => 'CRM_Mailing_BAO_Mailing',
1183 'FKClassName' => 'CRM_Core_DAO_LocationType',
1185 'label' => ts("Location Type"),
1187 'pseudoconstant' => [
1188 'table' => 'civicrm_location_type',
1189 'keyColumn' => 'id',
1190 'labelColumn' => 'display_name',
1194 'email_selection_method' => [
1195 'name' => 'email_selection_method',
1196 'type' => CRM_Utils_Type
::T_STRING
,
1197 'title' => ts('Email Selection Method'),
1198 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
1200 'size' => CRM_Utils_Type
::MEDIUM
,
1201 'where' => 'civicrm_mailing.email_selection_method',
1202 'default' => 'automatic',
1203 'table_name' => 'civicrm_mailing',
1204 'entity' => 'Mailing',
1205 'bao' => 'CRM_Mailing_BAO_Mailing',
1208 'label' => ts("Email Selection Method"),
1210 'pseudoconstant' => [
1211 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1216 'name' => 'language',
1217 'type' => CRM_Utils_Type
::T_STRING
,
1218 'title' => ts('Mailing Language'),
1219 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
1221 'size' => CRM_Utils_Type
::SIX
,
1222 'where' => 'civicrm_mailing.language',
1223 'table_name' => 'civicrm_mailing',
1224 'entity' => 'Mailing',
1225 'bao' => 'CRM_Mailing_BAO_Mailing',
1230 'pseudoconstant' => [
1231 'optionGroupName' => 'languages',
1232 'keyColumn' => 'name',
1233 'optionEditPath' => 'civicrm/admin/options/languages',
1238 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1240 return Civi
::$statics[__CLASS__
]['fields'];
1244 * Return a mapping from field-name to the corresponding key (as used in fields()).
1247 * Array(string $name => string $uniqueName).
1249 public static function &fieldKeys() {
1250 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1251 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1253 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1257 * Returns the names of this table
1261 public static function getTableName() {
1262 return self
::$_tableName;
1266 * Returns if this table needs to be logged
1270 public function getLog() {
1275 * Returns the list of fields that can be imported
1277 * @param bool $prefix
1281 public static function &import($prefix = FALSE) {
1282 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'mailing', $prefix, []);
1287 * Returns the list of fields that can be exported
1289 * @param bool $prefix
1293 public static function &export($prefix = FALSE) {
1294 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'mailing', $prefix, []);
1299 * Returns the list of indices
1301 * @param bool $localize
1305 public static function indices($localize = TRUE) {
1308 'name' => 'index_hash',
1312 'localizable' => FALSE,
1313 'sig' => 'civicrm_mailing::0::hash',
1316 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;