Merge pull request #19525 from eileenmcnaughton/member_soft
[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:cea36c1d0da157e6d5b42b505eb44a53)
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 foreign keys and entity references.
366 *
367 * @return array
368 * [CRM_Core_Reference_Interface]
369 */
370 public static function getReferenceColumns() {
371 if (!isset(Civi::$statics[__CLASS__]['links'])) {
372 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
373 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id');
374 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'header_id', 'civicrm_mailing_component', 'id');
375 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'footer_id', 'civicrm_mailing_component', 'id');
376 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'reply_id', 'civicrm_mailing_component', 'id');
377 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'unsubscribe_id', 'civicrm_mailing_component', 'id');
378 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'optout_id', 'civicrm_mailing_component', 'id');
379 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'msg_template_id', 'civicrm_msg_template', 'id');
380 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id');
381 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'scheduled_id', 'civicrm_contact', 'id');
382 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'approver_id', 'civicrm_contact', 'id');
383 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
384 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'sms_provider_id', 'civicrm_sms_provider', 'id');
385 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id');
386 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
387 }
388 return Civi::$statics[__CLASS__]['links'];
389 }
390
391 /**
392 * Returns all the column names of this table
393 *
394 * @return array
395 */
396 public static function &fields() {
397 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
398 Civi::$statics[__CLASS__]['fields'] = [
399 'id' => [
400 'name' => 'id',
401 'type' => CRM_Utils_Type::T_INT,
402 'title' => ts('Mailing ID'),
403 'required' => TRUE,
404 'where' => 'civicrm_mailing.id',
405 'table_name' => 'civicrm_mailing',
406 'entity' => 'Mailing',
407 'bao' => 'CRM_Mailing_BAO_Mailing',
408 'localizable' => 0,
409 'html' => [
410 'type' => 'Number',
411 ],
412 'add' => NULL,
413 ],
414 'domain_id' => [
415 'name' => 'domain_id',
416 'type' => CRM_Utils_Type::T_INT,
417 'title' => ts('Domain ID'),
418 'description' => ts('Which site is this mailing for'),
419 'where' => 'civicrm_mailing.domain_id',
420 'table_name' => 'civicrm_mailing',
421 'entity' => 'Mailing',
422 'bao' => 'CRM_Mailing_BAO_Mailing',
423 'localizable' => 0,
424 'FKClassName' => 'CRM_Core_DAO_Domain',
425 'html' => [
426 'label' => ts("Domain"),
427 ],
428 'pseudoconstant' => [
429 'table' => 'civicrm_domain',
430 'keyColumn' => 'id',
431 'labelColumn' => 'name',
432 ],
433 'add' => '3.4',
434 ],
435 'header_id' => [
436 'name' => 'header_id',
437 'type' => CRM_Utils_Type::T_INT,
438 'title' => ts('Header ID'),
439 'description' => ts('FK to the header component.'),
440 'where' => 'civicrm_mailing.header_id',
441 'table_name' => 'civicrm_mailing',
442 'entity' => 'Mailing',
443 'bao' => 'CRM_Mailing_BAO_Mailing',
444 'localizable' => 0,
445 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
446 'html' => [
447 'label' => ts("Header"),
448 ],
449 'pseudoconstant' => [
450 'table' => 'civicrm_mailing_component',
451 'keyColumn' => 'id',
452 'labelColumn' => 'name',
453 'condition' => 'component_type = "Header"',
454 ],
455 'add' => NULL,
456 ],
457 'footer_id' => [
458 'name' => 'footer_id',
459 'type' => CRM_Utils_Type::T_INT,
460 'title' => ts('Footer ID'),
461 'description' => ts('FK to the footer component.'),
462 'where' => 'civicrm_mailing.footer_id',
463 'table_name' => 'civicrm_mailing',
464 'entity' => 'Mailing',
465 'bao' => 'CRM_Mailing_BAO_Mailing',
466 'localizable' => 0,
467 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
468 'html' => [
469 'label' => ts("Footer"),
470 ],
471 'pseudoconstant' => [
472 'table' => 'civicrm_mailing_component',
473 'keyColumn' => 'id',
474 'labelColumn' => 'name',
475 'condition' => 'component_type = "Footer"',
476 ],
477 'add' => NULL,
478 ],
479 'reply_id' => [
480 'name' => 'reply_id',
481 'type' => CRM_Utils_Type::T_INT,
482 'title' => ts('Reply ID'),
483 'description' => ts('FK to the auto-responder component.'),
484 'where' => 'civicrm_mailing.reply_id',
485 'table_name' => 'civicrm_mailing',
486 'entity' => 'Mailing',
487 'bao' => 'CRM_Mailing_BAO_Mailing',
488 'localizable' => 0,
489 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
490 'html' => [
491 'label' => ts("Reply"),
492 ],
493 'add' => NULL,
494 ],
495 'unsubscribe_id' => [
496 'name' => 'unsubscribe_id',
497 'type' => CRM_Utils_Type::T_INT,
498 'title' => ts('Unsubscribe ID'),
499 'description' => ts('FK to the unsubscribe component.'),
500 'where' => 'civicrm_mailing.unsubscribe_id',
501 'table_name' => 'civicrm_mailing',
502 'entity' => 'Mailing',
503 'bao' => 'CRM_Mailing_BAO_Mailing',
504 'localizable' => 0,
505 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
506 'html' => [
507 'label' => ts("Unsubscribe"),
508 ],
509 'add' => NULL,
510 ],
511 'resubscribe_id' => [
512 'name' => 'resubscribe_id',
513 'type' => CRM_Utils_Type::T_INT,
514 'title' => ts('Mailing Resubscribe'),
515 'where' => 'civicrm_mailing.resubscribe_id',
516 'table_name' => 'civicrm_mailing',
517 'entity' => 'Mailing',
518 'bao' => 'CRM_Mailing_BAO_Mailing',
519 'localizable' => 0,
520 'add' => NULL,
521 ],
522 'optout_id' => [
523 'name' => 'optout_id',
524 'type' => CRM_Utils_Type::T_INT,
525 'title' => ts('Opt Out ID'),
526 'description' => ts('FK to the opt-out component.'),
527 'where' => 'civicrm_mailing.optout_id',
528 'table_name' => 'civicrm_mailing',
529 'entity' => 'Mailing',
530 'bao' => 'CRM_Mailing_BAO_Mailing',
531 'localizable' => 0,
532 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
533 'html' => [
534 'label' => ts("Opt Out"),
535 ],
536 'add' => NULL,
537 ],
538 'mailing_name' => [
539 'name' => 'name',
540 'type' => CRM_Utils_Type::T_STRING,
541 'title' => ts('Mailing Name'),
542 'description' => ts('Mailing Name.'),
543 'maxlength' => 128,
544 'size' => CRM_Utils_Type::HUGE,
545 'where' => 'civicrm_mailing.name',
546 'table_name' => 'civicrm_mailing',
547 'entity' => 'Mailing',
548 'bao' => 'CRM_Mailing_BAO_Mailing',
549 'localizable' => 0,
550 'html' => [
551 'type' => 'Text',
552 ],
553 'add' => NULL,
554 ],
555 'mailing_type' => [
556 'name' => 'mailing_type',
557 'type' => CRM_Utils_Type::T_STRING,
558 'title' => ts('Mailing Type'),
559 'description' => ts('differentiate between standalone mailings, A/B tests, and A/B final-winner'),
560 'maxlength' => 32,
561 'size' => CRM_Utils_Type::MEDIUM,
562 'where' => 'civicrm_mailing.mailing_type',
563 'table_name' => 'civicrm_mailing',
564 'entity' => 'Mailing',
565 'bao' => 'CRM_Mailing_BAO_Mailing',
566 'localizable' => 0,
567 'html' => [
568 'type' => 'Select',
569 ],
570 'pseudoconstant' => [
571 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
572 ],
573 'add' => '4.6',
574 ],
575 'from_name' => [
576 'name' => 'from_name',
577 'type' => CRM_Utils_Type::T_STRING,
578 'title' => ts('Mailing From Name'),
579 'description' => ts('From Header of mailing'),
580 'maxlength' => 128,
581 'size' => CRM_Utils_Type::HUGE,
582 'where' => 'civicrm_mailing.from_name',
583 'table_name' => 'civicrm_mailing',
584 'entity' => 'Mailing',
585 'bao' => 'CRM_Mailing_BAO_Mailing',
586 'localizable' => 0,
587 'html' => [
588 'type' => 'Text',
589 ],
590 'add' => NULL,
591 ],
592 'from_email' => [
593 'name' => 'from_email',
594 'type' => CRM_Utils_Type::T_STRING,
595 'title' => ts('Mailing From Email'),
596 'description' => ts('From Email of mailing'),
597 'maxlength' => 128,
598 'size' => CRM_Utils_Type::HUGE,
599 'where' => 'civicrm_mailing.from_email',
600 'table_name' => 'civicrm_mailing',
601 'entity' => 'Mailing',
602 'bao' => 'CRM_Mailing_BAO_Mailing',
603 'localizable' => 0,
604 'html' => [
605 'type' => 'Text',
606 ],
607 'add' => NULL,
608 ],
609 'replyto_email' => [
610 'name' => 'replyto_email',
611 'type' => CRM_Utils_Type::T_STRING,
612 'title' => ts('Replyto Email'),
613 'description' => ts('Reply-To Email of mailing'),
614 'maxlength' => 128,
615 'size' => CRM_Utils_Type::HUGE,
616 'where' => 'civicrm_mailing.replyto_email',
617 'table_name' => 'civicrm_mailing',
618 'entity' => 'Mailing',
619 'bao' => 'CRM_Mailing_BAO_Mailing',
620 'localizable' => 0,
621 'html' => [
622 'type' => 'Text',
623 ],
624 'add' => NULL,
625 ],
626 'template_type' => [
627 'name' => 'template_type',
628 'type' => CRM_Utils_Type::T_STRING,
629 'title' => ts('Template Type'),
630 'description' => ts('The language/processing system used for email templates.'),
631 'required' => TRUE,
632 'maxlength' => 64,
633 'size' => CRM_Utils_Type::BIG,
634 'where' => 'civicrm_mailing.template_type',
635 'default' => 'traditional',
636 'table_name' => 'civicrm_mailing',
637 'entity' => 'Mailing',
638 'bao' => 'CRM_Mailing_BAO_Mailing',
639 'localizable' => 0,
640 'pseudoconstant' => [
641 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
642 ],
643 'add' => NULL,
644 ],
645 'template_options' => [
646 'name' => 'template_options',
647 'type' => CRM_Utils_Type::T_LONGTEXT,
648 'title' => ts('Template Options (JSON)'),
649 'description' => ts('Advanced options used by the email templating system. (JSON encoded)'),
650 'where' => 'civicrm_mailing.template_options',
651 'table_name' => 'civicrm_mailing',
652 'entity' => 'Mailing',
653 'bao' => 'CRM_Mailing_BAO_Mailing',
654 'localizable' => 0,
655 'add' => NULL,
656 ],
657 'subject' => [
658 'name' => 'subject',
659 'type' => CRM_Utils_Type::T_STRING,
660 'title' => ts('Subject'),
661 'description' => ts('Subject of mailing'),
662 'maxlength' => 128,
663 'size' => CRM_Utils_Type::HUGE,
664 'where' => 'civicrm_mailing.subject',
665 'table_name' => 'civicrm_mailing',
666 'entity' => 'Mailing',
667 'bao' => 'CRM_Mailing_BAO_Mailing',
668 'localizable' => 0,
669 'html' => [
670 'type' => 'Text',
671 ],
672 'add' => NULL,
673 ],
674 'body_text' => [
675 'name' => 'body_text',
676 'type' => CRM_Utils_Type::T_LONGTEXT,
677 'title' => ts('Body Text'),
678 'description' => ts('Body of the mailing in text format.'),
679 'where' => 'civicrm_mailing.body_text',
680 'table_name' => 'civicrm_mailing',
681 'entity' => 'Mailing',
682 'bao' => 'CRM_Mailing_BAO_Mailing',
683 'localizable' => 0,
684 'add' => NULL,
685 ],
686 'body_html' => [
687 'name' => 'body_html',
688 'type' => CRM_Utils_Type::T_LONGTEXT,
689 'title' => ts('Body Html'),
690 'description' => ts('Body of the mailing in html format.'),
691 'where' => 'civicrm_mailing.body_html',
692 'table_name' => 'civicrm_mailing',
693 'entity' => 'Mailing',
694 'bao' => 'CRM_Mailing_BAO_Mailing',
695 'localizable' => 0,
696 'add' => NULL,
697 ],
698 'url_tracking' => [
699 'name' => 'url_tracking',
700 'type' => CRM_Utils_Type::T_BOOLEAN,
701 'title' => ts('Url Tracking'),
702 'description' => ts('Should we track URL click-throughs for this mailing?'),
703 'where' => 'civicrm_mailing.url_tracking',
704 'table_name' => 'civicrm_mailing',
705 'entity' => 'Mailing',
706 'bao' => 'CRM_Mailing_BAO_Mailing',
707 'localizable' => 0,
708 'html' => [
709 'type' => 'CheckBox',
710 ],
711 'add' => NULL,
712 ],
713 'forward_replies' => [
714 'name' => 'forward_replies',
715 'type' => CRM_Utils_Type::T_BOOLEAN,
716 'title' => ts('Forward Replies'),
717 'description' => ts('Should we forward replies back to the author?'),
718 'where' => 'civicrm_mailing.forward_replies',
719 'table_name' => 'civicrm_mailing',
720 'entity' => 'Mailing',
721 'bao' => 'CRM_Mailing_BAO_Mailing',
722 'localizable' => 0,
723 'html' => [
724 'type' => 'CheckBox',
725 ],
726 'add' => NULL,
727 ],
728 'auto_responder' => [
729 'name' => 'auto_responder',
730 'type' => CRM_Utils_Type::T_BOOLEAN,
731 'title' => ts('Auto Responder'),
732 'description' => ts('Should we enable the auto-responder?'),
733 'where' => 'civicrm_mailing.auto_responder',
734 'table_name' => 'civicrm_mailing',
735 'entity' => 'Mailing',
736 'bao' => 'CRM_Mailing_BAO_Mailing',
737 'localizable' => 0,
738 'html' => [
739 'type' => 'CheckBox',
740 ],
741 'add' => NULL,
742 ],
743 'open_tracking' => [
744 'name' => 'open_tracking',
745 'type' => CRM_Utils_Type::T_BOOLEAN,
746 'title' => ts('Track Mailing?'),
747 'description' => ts('Should we track when recipients open/read this mailing?'),
748 'where' => 'civicrm_mailing.open_tracking',
749 'table_name' => 'civicrm_mailing',
750 'entity' => 'Mailing',
751 'bao' => 'CRM_Mailing_BAO_Mailing',
752 'localizable' => 0,
753 'add' => NULL,
754 ],
755 'is_completed' => [
756 'name' => 'is_completed',
757 'type' => CRM_Utils_Type::T_BOOLEAN,
758 'title' => ts('Mailing Completed'),
759 'description' => ts('Has at least one job associated with this mailing finished?'),
760 'where' => 'civicrm_mailing.is_completed',
761 'table_name' => 'civicrm_mailing',
762 'entity' => 'Mailing',
763 'bao' => 'CRM_Mailing_BAO_Mailing',
764 'localizable' => 0,
765 'html' => [
766 'type' => 'CheckBox',
767 ],
768 'add' => NULL,
769 ],
770 'msg_template_id' => [
771 'name' => 'msg_template_id',
772 'type' => CRM_Utils_Type::T_INT,
773 'title' => ts('Message Template ID'),
774 'description' => ts('FK to the message template.'),
775 'where' => 'civicrm_mailing.msg_template_id',
776 'table_name' => 'civicrm_mailing',
777 'entity' => 'Mailing',
778 'bao' => 'CRM_Mailing_BAO_Mailing',
779 'localizable' => 0,
780 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
781 'html' => [
782 'label' => ts("Message Template"),
783 ],
784 'add' => NULL,
785 ],
786 'override_verp' => [
787 'name' => 'override_verp',
788 'type' => CRM_Utils_Type::T_BOOLEAN,
789 'title' => ts('Override Verp'),
790 'description' => ts('Overwrite the VERP address in Reply-To'),
791 'where' => 'civicrm_mailing.override_verp',
792 'default' => '0',
793 'table_name' => 'civicrm_mailing',
794 'entity' => 'Mailing',
795 'bao' => 'CRM_Mailing_BAO_Mailing',
796 'localizable' => 0,
797 'html' => [
798 'type' => 'CheckBox',
799 ],
800 'add' => '2.2',
801 ],
802 'created_id' => [
803 'name' => 'created_id',
804 'type' => CRM_Utils_Type::T_INT,
805 'title' => ts('Created By Contact ID'),
806 'description' => ts('FK to Contact ID who first created this mailing'),
807 'where' => 'civicrm_mailing.created_id',
808 'table_name' => 'civicrm_mailing',
809 'entity' => 'Mailing',
810 'bao' => 'CRM_Mailing_BAO_Mailing',
811 'localizable' => 0,
812 'FKClassName' => 'CRM_Contact_DAO_Contact',
813 'html' => [
814 'label' => ts("Creator"),
815 ],
816 'add' => NULL,
817 ],
818 'created_date' => [
819 'name' => 'created_date',
820 'type' => CRM_Utils_Type::T_TIMESTAMP,
821 'title' => ts('Mailing Created Date'),
822 'description' => ts('Date and time this mailing was created.'),
823 'required' => FALSE,
824 'where' => 'civicrm_mailing.created_date',
825 'default' => 'NULL',
826 'table_name' => 'civicrm_mailing',
827 'entity' => 'Mailing',
828 'bao' => 'CRM_Mailing_BAO_Mailing',
829 'localizable' => 0,
830 'html' => [
831 'type' => 'Select Date',
832 'formatType' => 'activityDateTime',
833 ],
834 'add' => '3.0',
835 ],
836 'mailing_modified_date' => [
837 'name' => 'modified_date',
838 'type' => CRM_Utils_Type::T_TIMESTAMP,
839 'title' => ts('Modified Date'),
840 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
841 'required' => FALSE,
842 'where' => 'civicrm_mailing.modified_date',
843 'export' => TRUE,
844 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
845 'table_name' => 'civicrm_mailing',
846 'entity' => 'Mailing',
847 'bao' => 'CRM_Mailing_BAO_Mailing',
848 'localizable' => 0,
849 'add' => '4.7',
850 ],
851 'scheduled_id' => [
852 'name' => 'scheduled_id',
853 'type' => CRM_Utils_Type::T_INT,
854 'title' => ts('Scheduled By Contact ID'),
855 'description' => ts('FK to Contact ID who scheduled this mailing'),
856 'where' => 'civicrm_mailing.scheduled_id',
857 'table_name' => 'civicrm_mailing',
858 'entity' => 'Mailing',
859 'bao' => 'CRM_Mailing_BAO_Mailing',
860 'localizable' => 0,
861 'FKClassName' => 'CRM_Contact_DAO_Contact',
862 'html' => [
863 'label' => ts("Scheduled By"),
864 ],
865 'add' => NULL,
866 ],
867 'scheduled_date' => [
868 'name' => 'scheduled_date',
869 'type' => CRM_Utils_Type::T_TIMESTAMP,
870 'title' => ts('Mailing Scheduled Date'),
871 'description' => ts('Date and time this mailing was scheduled.'),
872 'required' => FALSE,
873 'where' => 'civicrm_mailing.scheduled_date',
874 'default' => 'NULL',
875 'table_name' => 'civicrm_mailing',
876 'entity' => 'Mailing',
877 'bao' => 'CRM_Mailing_BAO_Mailing',
878 'localizable' => 0,
879 'html' => [
880 'type' => 'Select Date',
881 'formatType' => 'activityDateTime',
882 ],
883 'add' => '3.3',
884 ],
885 'approver_id' => [
886 'name' => 'approver_id',
887 'type' => CRM_Utils_Type::T_INT,
888 'title' => ts('Approved By Contact ID'),
889 'description' => ts('FK to Contact ID who approved this mailing'),
890 'where' => 'civicrm_mailing.approver_id',
891 'table_name' => 'civicrm_mailing',
892 'entity' => 'Mailing',
893 'bao' => 'CRM_Mailing_BAO_Mailing',
894 'localizable' => 0,
895 'FKClassName' => 'CRM_Contact_DAO_Contact',
896 'html' => [
897 'label' => ts("Approved By"),
898 ],
899 'add' => NULL,
900 ],
901 'approval_date' => [
902 'name' => 'approval_date',
903 'type' => CRM_Utils_Type::T_TIMESTAMP,
904 'title' => ts('Mailing Approved Date'),
905 'description' => ts('Date and time this mailing was approved.'),
906 'required' => FALSE,
907 'where' => 'civicrm_mailing.approval_date',
908 'default' => 'NULL',
909 'table_name' => 'civicrm_mailing',
910 'entity' => 'Mailing',
911 'bao' => 'CRM_Mailing_BAO_Mailing',
912 'localizable' => 0,
913 'html' => [
914 'type' => 'Select Date',
915 'formatType' => 'activityDateTime',
916 ],
917 'add' => '3.3',
918 ],
919 'approval_status_id' => [
920 'name' => 'approval_status_id',
921 'type' => CRM_Utils_Type::T_INT,
922 'title' => ts('Approval Status'),
923 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
924 'where' => 'civicrm_mailing.approval_status_id',
925 'table_name' => 'civicrm_mailing',
926 'entity' => 'Mailing',
927 'bao' => 'CRM_Mailing_BAO_Mailing',
928 'localizable' => 0,
929 'html' => [
930 'type' => 'Select',
931 ],
932 'pseudoconstant' => [
933 'optionGroupName' => 'mail_approval_status',
934 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
935 ],
936 'add' => '3.3',
937 ],
938 'approval_note' => [
939 'name' => 'approval_note',
940 'type' => CRM_Utils_Type::T_LONGTEXT,
941 'title' => ts('Approval Note'),
942 'description' => ts('Note behind the decision.'),
943 'where' => 'civicrm_mailing.approval_note',
944 'table_name' => 'civicrm_mailing',
945 'entity' => 'Mailing',
946 'bao' => 'CRM_Mailing_BAO_Mailing',
947 'localizable' => 0,
948 'html' => [
949 'type' => 'TextArea',
950 ],
951 'add' => '3.3',
952 ],
953 'is_archived' => [
954 'name' => 'is_archived',
955 'type' => CRM_Utils_Type::T_BOOLEAN,
956 'title' => ts('Is Mailing Archived?'),
957 'description' => ts('Is this mailing archived?'),
958 'where' => 'civicrm_mailing.is_archived',
959 'default' => '0',
960 'table_name' => 'civicrm_mailing',
961 'entity' => 'Mailing',
962 'bao' => 'CRM_Mailing_BAO_Mailing',
963 'localizable' => 0,
964 'html' => [
965 'type' => 'CheckBox',
966 ],
967 'add' => '2.2',
968 ],
969 'visibility' => [
970 'name' => 'visibility',
971 'type' => CRM_Utils_Type::T_STRING,
972 'title' => ts('Mailing Visibility'),
973 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
974 'maxlength' => 40,
975 'size' => CRM_Utils_Type::BIG,
976 'where' => 'civicrm_mailing.visibility',
977 'default' => 'Public Pages',
978 'table_name' => 'civicrm_mailing',
979 'entity' => 'Mailing',
980 'bao' => 'CRM_Mailing_BAO_Mailing',
981 'localizable' => 0,
982 'html' => [
983 'type' => 'Select',
984 ],
985 'pseudoconstant' => [
986 'callback' => 'CRM_Core_SelectValues::groupVisibility',
987 ],
988 'add' => '3.3',
989 ],
990 'campaign_id' => [
991 'name' => 'campaign_id',
992 'type' => CRM_Utils_Type::T_INT,
993 'title' => ts('Campaign ID'),
994 'description' => ts('The campaign for which this mailing has been initiated.'),
995 'where' => 'civicrm_mailing.campaign_id',
996 'table_name' => 'civicrm_mailing',
997 'entity' => 'Mailing',
998 'bao' => 'CRM_Mailing_BAO_Mailing',
999 'localizable' => 0,
1000 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1001 'html' => [
1002 'type' => 'Select',
1003 'label' => ts("Campaign"),
1004 ],
1005 'add' => '3.4',
1006 ],
1007 'dedupe_email' => [
1008 'name' => 'dedupe_email',
1009 'type' => CRM_Utils_Type::T_BOOLEAN,
1010 'title' => ts('No Duplicate emails?'),
1011 'description' => ts('Remove duplicate emails?'),
1012 'where' => 'civicrm_mailing.dedupe_email',
1013 'default' => '0',
1014 'table_name' => 'civicrm_mailing',
1015 'entity' => 'Mailing',
1016 'bao' => 'CRM_Mailing_BAO_Mailing',
1017 'localizable' => 0,
1018 'html' => [
1019 'type' => 'CheckBox',
1020 ],
1021 'add' => '4.1',
1022 ],
1023 'sms_provider_id' => [
1024 'name' => 'sms_provider_id',
1025 'type' => CRM_Utils_Type::T_INT,
1026 'title' => ts('SMS Provider ID'),
1027 'where' => 'civicrm_mailing.sms_provider_id',
1028 'table_name' => 'civicrm_mailing',
1029 'entity' => 'Mailing',
1030 'bao' => 'CRM_Mailing_BAO_Mailing',
1031 'localizable' => 0,
1032 'FKClassName' => 'CRM_SMS_DAO_Provider',
1033 'html' => [
1034 'type' => 'Select',
1035 'label' => ts("SMS Provider"),
1036 ],
1037 'add' => '4.2',
1038 ],
1039 'hash' => [
1040 'name' => 'hash',
1041 'type' => CRM_Utils_Type::T_STRING,
1042 'title' => ts('Mailing Hash'),
1043 'description' => ts('Key for validating requests related to this mailing.'),
1044 'maxlength' => 16,
1045 'size' => CRM_Utils_Type::TWELVE,
1046 'where' => 'civicrm_mailing.hash',
1047 'table_name' => 'civicrm_mailing',
1048 'entity' => 'Mailing',
1049 'bao' => 'CRM_Mailing_BAO_Mailing',
1050 'localizable' => 0,
1051 'add' => '4.5',
1052 ],
1053 'location_type_id' => [
1054 'name' => 'location_type_id',
1055 'type' => CRM_Utils_Type::T_INT,
1056 'title' => ts('Location Type ID'),
1057 'description' => ts('With email_selection_method, determines which email address to use'),
1058 'where' => 'civicrm_mailing.location_type_id',
1059 'table_name' => 'civicrm_mailing',
1060 'entity' => 'Mailing',
1061 'bao' => 'CRM_Mailing_BAO_Mailing',
1062 'localizable' => 0,
1063 'FKClassName' => 'CRM_Core_DAO_LocationType',
1064 'html' => [
1065 'label' => ts("Location Type"),
1066 ],
1067 'pseudoconstant' => [
1068 'table' => 'civicrm_location_type',
1069 'keyColumn' => 'id',
1070 'labelColumn' => 'display_name',
1071 ],
1072 'add' => '4.6',
1073 ],
1074 'email_selection_method' => [
1075 'name' => 'email_selection_method',
1076 'type' => CRM_Utils_Type::T_STRING,
1077 'title' => ts('Email Selection Method'),
1078 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
1079 'maxlength' => 20,
1080 'size' => CRM_Utils_Type::MEDIUM,
1081 'where' => 'civicrm_mailing.email_selection_method',
1082 'default' => 'automatic',
1083 'table_name' => 'civicrm_mailing',
1084 'entity' => 'Mailing',
1085 'bao' => 'CRM_Mailing_BAO_Mailing',
1086 'localizable' => 0,
1087 'pseudoconstant' => [
1088 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1089 ],
1090 'add' => '4.6',
1091 ],
1092 'language' => [
1093 'name' => 'language',
1094 'type' => CRM_Utils_Type::T_STRING,
1095 'title' => ts('Mailing Language'),
1096 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
1097 'maxlength' => 5,
1098 'size' => CRM_Utils_Type::SIX,
1099 'where' => 'civicrm_mailing.language',
1100 'table_name' => 'civicrm_mailing',
1101 'entity' => 'Mailing',
1102 'bao' => 'CRM_Mailing_BAO_Mailing',
1103 'localizable' => 0,
1104 'html' => [
1105 'type' => 'Select',
1106 ],
1107 'pseudoconstant' => [
1108 'optionGroupName' => 'languages',
1109 'keyColumn' => 'name',
1110 'optionEditPath' => 'civicrm/admin/options/languages',
1111 ],
1112 'add' => '4.6',
1113 ],
1114 ];
1115 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1116 }
1117 return Civi::$statics[__CLASS__]['fields'];
1118 }
1119
1120 /**
1121 * Return a mapping from field-name to the corresponding key (as used in fields()).
1122 *
1123 * @return array
1124 * Array(string $name => string $uniqueName).
1125 */
1126 public static function &fieldKeys() {
1127 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
1128 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
1129 }
1130 return Civi::$statics[__CLASS__]['fieldKeys'];
1131 }
1132
1133 /**
1134 * Returns the names of this table
1135 *
1136 * @return string
1137 */
1138 public static function getTableName() {
1139 return self::$_tableName;
1140 }
1141
1142 /**
1143 * Returns if this table needs to be logged
1144 *
1145 * @return bool
1146 */
1147 public function getLog() {
1148 return self::$_log;
1149 }
1150
1151 /**
1152 * Returns the list of fields that can be imported
1153 *
1154 * @param bool $prefix
1155 *
1156 * @return array
1157 */
1158 public static function &import($prefix = FALSE) {
1159 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, []);
1160 return $r;
1161 }
1162
1163 /**
1164 * Returns the list of fields that can be exported
1165 *
1166 * @param bool $prefix
1167 *
1168 * @return array
1169 */
1170 public static function &export($prefix = FALSE) {
1171 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, []);
1172 return $r;
1173 }
1174
1175 /**
1176 * Returns the list of indices
1177 *
1178 * @param bool $localize
1179 *
1180 * @return array
1181 */
1182 public static function indices($localize = TRUE) {
1183 $indices = [
1184 'index_hash' => [
1185 'name' => 'index_hash',
1186 'field' => [
1187 0 => 'hash',
1188 ],
1189 'localizable' => FALSE,
1190 'sig' => 'civicrm_mailing::0::hash',
1191 ],
1192 ];
1193 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1194 }
1195
1196 }