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:4144d565580335c15e750f73a73df644)
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?
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?
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?
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?
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?
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
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?
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?
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?'),
809 'where' => 'civicrm_mailing.url_tracking',
811 'table_name' => 'civicrm_mailing',
812 'entity' => 'Mailing',
813 'bao' => 'CRM_Mailing_BAO_Mailing',
816 'type' => 'CheckBox',
817 'label' => ts("Url Tracking"),
821 'forward_replies' => [
822 'name' => 'forward_replies',
823 'type' => CRM_Utils_Type
::T_BOOLEAN
,
824 'title' => ts('Forward Replies'),
825 'description' => ts('Should we forward replies back to the author?'),
827 'where' => 'civicrm_mailing.forward_replies',
829 'table_name' => 'civicrm_mailing',
830 'entity' => 'Mailing',
831 'bao' => 'CRM_Mailing_BAO_Mailing',
834 'type' => 'CheckBox',
835 'label' => ts("Forward Replies"),
839 'auto_responder' => [
840 'name' => 'auto_responder',
841 'type' => CRM_Utils_Type
::T_BOOLEAN
,
842 'title' => ts('Auto Responder'),
843 'description' => ts('Should we enable the auto-responder?'),
845 'where' => 'civicrm_mailing.auto_responder',
847 'table_name' => 'civicrm_mailing',
848 'entity' => 'Mailing',
849 'bao' => 'CRM_Mailing_BAO_Mailing',
852 'type' => 'CheckBox',
853 'label' => ts("Auto Responder"),
858 'name' => 'open_tracking',
859 'type' => CRM_Utils_Type
::T_BOOLEAN
,
860 'title' => ts('Track Mailing?'),
861 'description' => ts('Should we track when recipients open/read this mailing?'),
863 'where' => 'civicrm_mailing.open_tracking',
865 'table_name' => 'civicrm_mailing',
866 'entity' => 'Mailing',
867 'bao' => 'CRM_Mailing_BAO_Mailing',
872 'name' => 'is_completed',
873 'type' => CRM_Utils_Type
::T_BOOLEAN
,
874 'title' => ts('Mailing Completed'),
875 'description' => ts('Has at least one job associated with this mailing finished?'),
877 'where' => 'civicrm_mailing.is_completed',
879 'table_name' => 'civicrm_mailing',
880 'entity' => 'Mailing',
881 'bao' => 'CRM_Mailing_BAO_Mailing',
884 'type' => 'CheckBox',
888 'msg_template_id' => [
889 'name' => 'msg_template_id',
890 'type' => CRM_Utils_Type
::T_INT
,
891 'title' => ts('Message Template ID'),
892 'description' => ts('FK to the message template.'),
893 'where' => 'civicrm_mailing.msg_template_id',
894 'table_name' => 'civicrm_mailing',
895 'entity' => 'Mailing',
896 'bao' => 'CRM_Mailing_BAO_Mailing',
898 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
900 'label' => ts("Message Template"),
905 'name' => 'override_verp',
906 'type' => CRM_Utils_Type
::T_BOOLEAN
,
907 'title' => ts('Override Verp'),
908 'description' => ts('Overwrite the VERP address in Reply-To'),
910 'where' => 'civicrm_mailing.override_verp',
912 'table_name' => 'civicrm_mailing',
913 'entity' => 'Mailing',
914 'bao' => 'CRM_Mailing_BAO_Mailing',
917 'type' => 'CheckBox',
918 'label' => ts("Overwrite VERP"),
923 'name' => 'created_id',
924 'type' => CRM_Utils_Type
::T_INT
,
925 'title' => ts('Created By Contact ID'),
926 'description' => ts('FK to Contact ID who first created this mailing'),
927 'where' => 'civicrm_mailing.created_id',
928 'table_name' => 'civicrm_mailing',
929 'entity' => 'Mailing',
930 'bao' => 'CRM_Mailing_BAO_Mailing',
932 'FKClassName' => 'CRM_Contact_DAO_Contact',
934 'label' => ts("Creator"),
939 'name' => 'created_date',
940 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
941 'title' => ts('Mailing Created Date'),
942 'description' => ts('Date and time this mailing was created.'),
944 'where' => 'civicrm_mailing.created_date',
945 'default' => 'CURRENT_TIMESTAMP',
946 'table_name' => 'civicrm_mailing',
947 'entity' => 'Mailing',
948 'bao' => 'CRM_Mailing_BAO_Mailing',
951 'type' => 'Select Date',
952 'formatType' => 'activityDateTime',
956 'mailing_modified_date' => [
957 'name' => 'modified_date',
958 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
959 'title' => ts('Modified Date'),
960 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
962 'where' => 'civicrm_mailing.modified_date',
964 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
965 'table_name' => 'civicrm_mailing',
966 'entity' => 'Mailing',
967 'bao' => 'CRM_Mailing_BAO_Mailing',
970 'label' => ts("Modified Date"),
976 'name' => 'scheduled_id',
977 'type' => CRM_Utils_Type
::T_INT
,
978 'title' => ts('Scheduled By Contact ID'),
979 'description' => ts('FK to Contact ID who scheduled this mailing'),
980 'where' => 'civicrm_mailing.scheduled_id',
981 'table_name' => 'civicrm_mailing',
982 'entity' => 'Mailing',
983 'bao' => 'CRM_Mailing_BAO_Mailing',
985 'FKClassName' => 'CRM_Contact_DAO_Contact',
987 'label' => ts("Scheduled By"),
991 'scheduled_date' => [
992 'name' => 'scheduled_date',
993 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
994 'title' => ts('Mailing Scheduled Date'),
995 'description' => ts('Date and time this mailing was scheduled.'),
997 'where' => 'civicrm_mailing.scheduled_date',
999 'table_name' => 'civicrm_mailing',
1000 'entity' => 'Mailing',
1001 'bao' => 'CRM_Mailing_BAO_Mailing',
1004 'type' => 'Select Date',
1005 'formatType' => 'activityDateTime',
1010 'name' => 'approver_id',
1011 'type' => CRM_Utils_Type
::T_INT
,
1012 'title' => ts('Approved By Contact ID'),
1013 'description' => ts('FK to Contact ID who approved this mailing'),
1014 'where' => 'civicrm_mailing.approver_id',
1015 'table_name' => 'civicrm_mailing',
1016 'entity' => 'Mailing',
1017 'bao' => 'CRM_Mailing_BAO_Mailing',
1019 'FKClassName' => 'CRM_Contact_DAO_Contact',
1021 'label' => ts("Approved By"),
1025 'approval_date' => [
1026 'name' => 'approval_date',
1027 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
1028 'title' => ts('Mailing Approved Date'),
1029 'description' => ts('Date and time this mailing was approved.'),
1030 'required' => FALSE,
1031 'where' => 'civicrm_mailing.approval_date',
1033 'table_name' => 'civicrm_mailing',
1034 'entity' => 'Mailing',
1035 'bao' => 'CRM_Mailing_BAO_Mailing',
1038 'type' => 'Select Date',
1039 'formatType' => 'activityDateTime',
1043 'approval_status_id' => [
1044 'name' => 'approval_status_id',
1045 'type' => CRM_Utils_Type
::T_INT
,
1046 'title' => ts('Approval Status'),
1047 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
1048 'where' => 'civicrm_mailing.approval_status_id',
1049 'table_name' => 'civicrm_mailing',
1050 'entity' => 'Mailing',
1051 'bao' => 'CRM_Mailing_BAO_Mailing',
1056 'pseudoconstant' => [
1057 'optionGroupName' => 'mail_approval_status',
1058 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
1062 'approval_note' => [
1063 'name' => 'approval_note',
1064 'type' => CRM_Utils_Type
::T_LONGTEXT
,
1065 'title' => ts('Approval Note'),
1066 'description' => ts('Note behind the decision.'),
1067 'where' => 'civicrm_mailing.approval_note',
1068 'table_name' => 'civicrm_mailing',
1069 'entity' => 'Mailing',
1070 'bao' => 'CRM_Mailing_BAO_Mailing',
1073 'type' => 'TextArea',
1078 'name' => 'is_archived',
1079 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1080 'title' => ts('Is Mailing Archived?'),
1081 'description' => ts('Is this mailing archived?'),
1083 'where' => 'civicrm_mailing.is_archived',
1085 'table_name' => 'civicrm_mailing',
1086 'entity' => 'Mailing',
1087 'bao' => 'CRM_Mailing_BAO_Mailing',
1090 'type' => 'CheckBox',
1095 'name' => 'visibility',
1096 'type' => CRM_Utils_Type
::T_STRING
,
1097 'title' => ts('Mailing Visibility'),
1098 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
1100 'size' => CRM_Utils_Type
::BIG
,
1101 'where' => 'civicrm_mailing.visibility',
1102 'default' => 'Public Pages',
1103 'table_name' => 'civicrm_mailing',
1104 'entity' => 'Mailing',
1105 'bao' => 'CRM_Mailing_BAO_Mailing',
1110 'pseudoconstant' => [
1111 'callback' => 'CRM_Core_SelectValues::groupVisibility',
1116 'name' => 'campaign_id',
1117 'type' => CRM_Utils_Type
::T_INT
,
1118 'title' => ts('Campaign ID'),
1119 'description' => ts('The campaign for which this mailing has been initiated.'),
1120 'where' => 'civicrm_mailing.campaign_id',
1121 'table_name' => 'civicrm_mailing',
1122 'entity' => 'Mailing',
1123 'bao' => 'CRM_Mailing_BAO_Mailing',
1125 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1126 'component' => 'CiviCampaign',
1128 'type' => 'EntityRef',
1129 'label' => ts("Campaign"),
1131 'pseudoconstant' => [
1132 'table' => 'civicrm_campaign',
1133 'keyColumn' => 'id',
1134 'labelColumn' => 'title',
1135 'prefetch' => 'FALSE',
1140 'name' => 'dedupe_email',
1141 'type' => CRM_Utils_Type
::T_BOOLEAN
,
1142 'title' => ts('No Duplicate emails?'),
1143 'description' => ts('Remove duplicate emails?'),
1145 'where' => 'civicrm_mailing.dedupe_email',
1147 'table_name' => 'civicrm_mailing',
1148 'entity' => 'Mailing',
1149 'bao' => 'CRM_Mailing_BAO_Mailing',
1152 'type' => 'CheckBox',
1156 'sms_provider_id' => [
1157 'name' => 'sms_provider_id',
1158 'type' => CRM_Utils_Type
::T_INT
,
1159 'title' => ts('SMS Provider ID'),
1160 'where' => 'civicrm_mailing.sms_provider_id',
1161 'table_name' => 'civicrm_mailing',
1162 'entity' => 'Mailing',
1163 'bao' => 'CRM_Mailing_BAO_Mailing',
1165 'FKClassName' => 'CRM_SMS_DAO_Provider',
1168 'label' => ts("SMS Provider"),
1174 'type' => CRM_Utils_Type
::T_STRING
,
1175 'title' => ts('Mailing Hash'),
1176 'description' => ts('Key for validating requests related to this mailing.'),
1178 'size' => CRM_Utils_Type
::TWELVE
,
1179 'where' => 'civicrm_mailing.hash',
1180 'table_name' => 'civicrm_mailing',
1181 'entity' => 'Mailing',
1182 'bao' => 'CRM_Mailing_BAO_Mailing',
1187 'location_type_id' => [
1188 'name' => 'location_type_id',
1189 'type' => CRM_Utils_Type
::T_INT
,
1190 'title' => ts('Location Type ID'),
1191 'description' => ts('With email_selection_method, determines which email address to use'),
1192 'where' => 'civicrm_mailing.location_type_id',
1193 'table_name' => 'civicrm_mailing',
1194 'entity' => 'Mailing',
1195 'bao' => 'CRM_Mailing_BAO_Mailing',
1197 'FKClassName' => 'CRM_Core_DAO_LocationType',
1199 'label' => ts("Location Type"),
1201 'pseudoconstant' => [
1202 'table' => 'civicrm_location_type',
1203 'keyColumn' => 'id',
1204 'labelColumn' => 'display_name',
1208 'email_selection_method' => [
1209 'name' => 'email_selection_method',
1210 'type' => CRM_Utils_Type
::T_STRING
,
1211 'title' => ts('Email Selection Method'),
1212 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
1214 'size' => CRM_Utils_Type
::MEDIUM
,
1215 'where' => 'civicrm_mailing.email_selection_method',
1216 'default' => 'automatic',
1217 'table_name' => 'civicrm_mailing',
1218 'entity' => 'Mailing',
1219 'bao' => 'CRM_Mailing_BAO_Mailing',
1222 'label' => ts("Email Selection Method"),
1224 'pseudoconstant' => [
1225 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1230 'name' => 'language',
1231 'type' => CRM_Utils_Type
::T_STRING
,
1232 'title' => ts('Mailing Language'),
1233 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
1235 'size' => CRM_Utils_Type
::SIX
,
1236 'where' => 'civicrm_mailing.language',
1237 'table_name' => 'civicrm_mailing',
1238 'entity' => 'Mailing',
1239 'bao' => 'CRM_Mailing_BAO_Mailing',
1244 'pseudoconstant' => [
1245 'optionGroupName' => 'languages',
1246 'keyColumn' => 'name',
1247 'optionEditPath' => 'civicrm/admin/options/languages',
1252 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
1254 return Civi
::$statics[__CLASS__
]['fields'];
1258 * Return a mapping from field-name to the corresponding key (as used in fields()).
1261 * Array(string $name => string $uniqueName).
1263 public static function &fieldKeys() {
1264 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
1265 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
1267 return Civi
::$statics[__CLASS__
]['fieldKeys'];
1271 * Returns the names of this table
1275 public static function getTableName() {
1276 return self
::$_tableName;
1280 * Returns if this table needs to be logged
1284 public function getLog() {
1289 * Returns the list of fields that can be imported
1291 * @param bool $prefix
1295 public static function &import($prefix = FALSE) {
1296 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'mailing', $prefix, []);
1301 * Returns the list of fields that can be exported
1303 * @param bool $prefix
1307 public static function &export($prefix = FALSE) {
1308 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'mailing', $prefix, []);
1313 * Returns the list of indices
1315 * @param bool $localize
1319 public static function indices($localize = TRUE) {
1322 'name' => 'index_hash',
1326 'localizable' => FALSE,
1327 'sig' => 'civicrm_mailing::0::hash',
1330 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;