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