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:d9992e7d40fdab9d29f2a093e34aa1cb)
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',
752 'serialize' => self
::SERIALIZE_JSON
,
757 'type' => CRM_Utils_Type
::T_STRING
,
758 'title' => ts('Subject'),
759 'description' => ts('Subject of mailing'),
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',
769 'label' => ts("Subject"),
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',
784 'label' => ts("Body Text"),
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',
799 'label' => ts("Body HTML"),
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',
814 'type' => 'CheckBox',
815 'label' => ts("Url Tracking"),
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',
830 'type' => 'CheckBox',
831 'label' => ts("Forward Replies"),
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',
846 'type' => 'CheckBox',
847 'label' => ts("Auto Responder"),
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',
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',
874 'type' => 'CheckBox',
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',
888 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
890 'label' => ts("Message Template"),
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',
901 'table_name' => 'civicrm_mailing',
902 'entity' => 'Mailing',
903 'bao' => 'CRM_Mailing_BAO_Mailing',
906 'type' => 'CheckBox',
907 'label' => ts("Overwrite VERP"),
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',
921 'FKClassName' => 'CRM_Contact_DAO_Contact',
923 'label' => ts("Creator"),
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.'),
933 'where' => 'civicrm_mailing.created_date',
934 'default' => 'CURRENT_TIMESTAMP',
935 'table_name' => 'civicrm_mailing',
936 'entity' => 'Mailing',
937 'bao' => 'CRM_Mailing_BAO_Mailing',
940 'type' => 'Select Date',
941 'formatType' => 'activityDateTime',
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.'),
951 'where' => 'civicrm_mailing.modified_date',
953 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
954 'table_name' => 'civicrm_mailing',
955 'entity' => 'Mailing',
956 'bao' => 'CRM_Mailing_BAO_Mailing',
959 'label' => ts("Modified Date"),
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',
974 'FKClassName' => 'CRM_Contact_DAO_Contact',
976 'label' => ts("Scheduled By"),
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.'),
986 'where' => 'civicrm_mailing.scheduled_date',
988 'table_name' => 'civicrm_mailing',
989 'entity' => 'Mailing',
990 'bao' => 'CRM_Mailing_BAO_Mailing',
993 'type' => 'Select Date',
994 'formatType' => 'activityDateTime',
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',
1008 'FKClassName' => 'CRM_Contact_DAO_Contact',
1010 'label' => ts("Approved By"),
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',
1022 'table_name' => 'civicrm_mailing',
1023 'entity' => 'Mailing',
1024 'bao' => 'CRM_Mailing_BAO_Mailing',
1027 'type' => 'Select Date',
1028 'formatType' => 'activityDateTime',
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',
1045 'pseudoconstant' => [
1046 'optionGroupName' => 'mail_approval_status',
1047 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
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',
1062 'type' => 'TextArea',
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',
1073 'table_name' => 'civicrm_mailing',
1074 'entity' => 'Mailing',
1075 'bao' => 'CRM_Mailing_BAO_Mailing',
1078 'type' => 'CheckBox',
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)'),
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',
1098 'pseudoconstant' => [
1099 'callback' => 'CRM_Core_SelectValues::groupVisibility',
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',
1113 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1114 'component' => 'CiviCampaign',
1116 'type' => 'EntityRef',
1117 'label' => ts("Campaign"),
1119 'pseudoconstant' => [
1120 'table' => 'civicrm_campaign',
1121 'keyColumn' => 'id',
1122 'labelColumn' => 'title',
1123 'prefetch' => 'FALSE',
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',
1134 'table_name' => 'civicrm_mailing',
1135 'entity' => 'Mailing',
1136 'bao' => 'CRM_Mailing_BAO_Mailing',
1139 'type' => 'CheckBox',
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',
1152 'FKClassName' => 'CRM_SMS_DAO_Provider',
1155 'label' => ts("SMS Provider"),
1161 'type' => CRM_Utils_Type
::T_STRING
,
1162 'title' => ts('Mailing Hash'),
1163 'description' => ts('Key for validating requests related to this mailing.'),
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',
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',
1184 'FKClassName' => 'CRM_Core_DAO_LocationType',
1186 'label' => ts("Location Type"),
1188 'pseudoconstant' => [
1189 'table' => 'civicrm_location_type',
1190 'keyColumn' => 'id',
1191 'labelColumn' => 'display_name',
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.'),
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',
1209 'label' => ts("Email Selection Method"),
1211 'pseudoconstant' => [
1212 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
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.'),
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',
1231 'pseudoconstant' => [
1232 'optionGroupName' => 'languages',
1233 'keyColumn' => 'name',
1234 'optionEditPath' => 'civicrm/admin/options/languages',
1239 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1241 return Civi
::$statics[__CLASS__
]['fields'];
1245 * Return a mapping from field-name to the corresponding key (as used in fields()).
1248 * Array(string $name => string $uniqueName).
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()));
1254 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1258 * Returns the names of this table
1262 public static function getTableName() {
1263 return self
::$_tableName;
1267 * Returns if this table needs to be logged
1271 public function getLog() {
1276 * Returns the list of fields that can be imported
1278 * @param bool $prefix
1282 public static function &import($prefix = FALSE) {
1283 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'mailing', $prefix, []);
1288 * Returns the list of fields that can be exported
1290 * @param bool $prefix
1294 public static function &export($prefix = FALSE) {
1295 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'mailing', $prefix, []);
1300 * Returns the list of indices
1302 * @param bool $localize
1306 public static function indices($localize = TRUE) {
1309 'name' => 'index_hash',
1313 'localizable' => FALSE,
1314 'sig' => 'civicrm_mailing::0::hash',
1317 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;