Merge pull request #21513 from JKingsnorth/core-2846-1-improve-start-end-date-validation
[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:4144d565580335c15e750f73a73df644)
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|string|null
53 * (SQL type: int unsigned)
54 * Note that values will be retrieved from the database as a string.
55 */
56 public $id;
57
58 /**
59 * Which site is this mailing for
60 *
61 * @var int|string|null
62 * (SQL type: int unsigned)
63 * Note that values will be retrieved from the database as a string.
64 */
65 public $domain_id;
66
67 /**
68 * FK to the header component.
69 *
70 * @var int|string|null
71 * (SQL type: int unsigned)
72 * Note that values will be retrieved from the database as a string.
73 */
74 public $header_id;
75
76 /**
77 * FK to the footer component.
78 *
79 * @var int|string|null
80 * (SQL type: int unsigned)
81 * Note that values will be retrieved from the database as a string.
82 */
83 public $footer_id;
84
85 /**
86 * FK to the auto-responder component.
87 *
88 * @var int|string|null
89 * (SQL type: int unsigned)
90 * Note that values will be retrieved from the database as a string.
91 */
92 public $reply_id;
93
94 /**
95 * FK to the unsubscribe component.
96 *
97 * @var int|string|null
98 * (SQL type: int unsigned)
99 * Note that values will be retrieved from the database as a string.
100 */
101 public $unsubscribe_id;
102
103 /**
104 * @var int|string|null
105 * (SQL type: int unsigned)
106 * Note that values will be retrieved from the database as a string.
107 */
108 public $resubscribe_id;
109
110 /**
111 * FK to the opt-out component.
112 *
113 * @var int|string|null
114 * (SQL type: int unsigned)
115 * Note that values will be retrieved from the database as a string.
116 */
117 public $optout_id;
118
119 /**
120 * Mailing Name.
121 *
122 * @var string|null
123 * (SQL type: varchar(128))
124 * Note that values will be retrieved from the database as a string.
125 */
126 public $name;
127
128 /**
129 * differentiate between standalone mailings, A/B tests, and A/B final-winner
130 *
131 * @var string|null
132 * (SQL type: varchar(32))
133 * Note that values will be retrieved from the database as a string.
134 */
135 public $mailing_type;
136
137 /**
138 * From Header of mailing
139 *
140 * @var string|null
141 * (SQL type: varchar(128))
142 * Note that values will be retrieved from the database as a string.
143 */
144 public $from_name;
145
146 /**
147 * From Email of mailing
148 *
149 * @var string|null
150 * (SQL type: varchar(128))
151 * Note that values will be retrieved from the database as a string.
152 */
153 public $from_email;
154
155 /**
156 * Reply-To Email of mailing
157 *
158 * @var string|null
159 * (SQL type: varchar(128))
160 * Note that values will be retrieved from the database as a string.
161 */
162 public $replyto_email;
163
164 /**
165 * The language/processing system used for email templates.
166 *
167 * @var string
168 * (SQL type: varchar(64))
169 * Note that values will be retrieved from the database as a string.
170 */
171 public $template_type;
172
173 /**
174 * Advanced options used by the email templating system. (JSON encoded)
175 *
176 * @var string|null
177 * (SQL type: longtext)
178 * Note that values will be retrieved from the database as a string.
179 */
180 public $template_options;
181
182 /**
183 * Subject of mailing
184 *
185 * @var string|null
186 * (SQL type: varchar(128))
187 * Note that values will be retrieved from the database as a string.
188 */
189 public $subject;
190
191 /**
192 * Body of the mailing in text format.
193 *
194 * @var string|null
195 * (SQL type: longtext)
196 * Note that values will be retrieved from the database as a string.
197 */
198 public $body_text;
199
200 /**
201 * Body of the mailing in html format.
202 *
203 * @var string|null
204 * (SQL type: longtext)
205 * Note that values will be retrieved from the database as a string.
206 */
207 public $body_html;
208
209 /**
210 * Should we track URL click-throughs for this mailing?
211 *
212 * @var bool|string
213 * (SQL type: tinyint)
214 * Note that values will be retrieved from the database as a string.
215 */
216 public $url_tracking;
217
218 /**
219 * Should we forward replies back to the author?
220 *
221 * @var bool|string
222 * (SQL type: tinyint)
223 * Note that values will be retrieved from the database as a string.
224 */
225 public $forward_replies;
226
227 /**
228 * Should we enable the auto-responder?
229 *
230 * @var bool|string
231 * (SQL type: tinyint)
232 * Note that values will be retrieved from the database as a string.
233 */
234 public $auto_responder;
235
236 /**
237 * Should we track when recipients open/read this mailing?
238 *
239 * @var bool|string
240 * (SQL type: tinyint)
241 * Note that values will be retrieved from the database as a string.
242 */
243 public $open_tracking;
244
245 /**
246 * Has at least one job associated with this mailing finished?
247 *
248 * @var bool|string
249 * (SQL type: tinyint)
250 * Note that values will be retrieved from the database as a string.
251 */
252 public $is_completed;
253
254 /**
255 * FK to the message template.
256 *
257 * @var int|string|null
258 * (SQL type: int unsigned)
259 * Note that values will be retrieved from the database as a string.
260 */
261 public $msg_template_id;
262
263 /**
264 * Overwrite the VERP address in Reply-To
265 *
266 * @var bool|string
267 * (SQL type: tinyint)
268 * Note that values will be retrieved from the database as a string.
269 */
270 public $override_verp;
271
272 /**
273 * FK to Contact ID who first created this mailing
274 *
275 * @var int|string|null
276 * (SQL type: int unsigned)
277 * Note that values will be retrieved from the database as a string.
278 */
279 public $created_id;
280
281 /**
282 * Date and time this mailing was created.
283 *
284 * @var string
285 * (SQL type: timestamp)
286 * Note that values will be retrieved from the database as a string.
287 */
288 public $created_date;
289
290 /**
291 * When the mailing (or closely related entity) was created or modified or deleted.
292 *
293 * @var string
294 * (SQL type: timestamp)
295 * Note that values will be retrieved from the database as a string.
296 */
297 public $modified_date;
298
299 /**
300 * FK to Contact ID who scheduled this mailing
301 *
302 * @var int|string|null
303 * (SQL type: int unsigned)
304 * Note that values will be retrieved from the database as a string.
305 */
306 public $scheduled_id;
307
308 /**
309 * Date and time this mailing was scheduled.
310 *
311 * @var string
312 * (SQL type: timestamp)
313 * Note that values will be retrieved from the database as a string.
314 */
315 public $scheduled_date;
316
317 /**
318 * FK to Contact ID who approved this mailing
319 *
320 * @var int|string|null
321 * (SQL type: int unsigned)
322 * Note that values will be retrieved from the database as a string.
323 */
324 public $approver_id;
325
326 /**
327 * Date and time this mailing was approved.
328 *
329 * @var string
330 * (SQL type: timestamp)
331 * Note that values will be retrieved from the database as a string.
332 */
333 public $approval_date;
334
335 /**
336 * The status of this mailing. Values: none, approved, rejected
337 *
338 * @var int|string|null
339 * (SQL type: int unsigned)
340 * Note that values will be retrieved from the database as a string.
341 */
342 public $approval_status_id;
343
344 /**
345 * Note behind the decision.
346 *
347 * @var string|null
348 * (SQL type: longtext)
349 * Note that values will be retrieved from the database as a string.
350 */
351 public $approval_note;
352
353 /**
354 * Is this mailing archived?
355 *
356 * @var bool|string
357 * (SQL type: tinyint)
358 * Note that values will be retrieved from the database as a string.
359 */
360 public $is_archived;
361
362 /**
363 * In what context(s) is the mailing contents visible (online viewing)
364 *
365 * @var string|null
366 * (SQL type: varchar(40))
367 * Note that values will be retrieved from the database as a string.
368 */
369 public $visibility;
370
371 /**
372 * The campaign for which this mailing has been initiated.
373 *
374 * @var int|string|null
375 * (SQL type: int unsigned)
376 * Note that values will be retrieved from the database as a string.
377 */
378 public $campaign_id;
379
380 /**
381 * Remove duplicate emails?
382 *
383 * @var bool|string
384 * (SQL type: tinyint)
385 * Note that values will be retrieved from the database as a string.
386 */
387 public $dedupe_email;
388
389 /**
390 * @var int|string|null
391 * (SQL type: int unsigned)
392 * Note that values will be retrieved from the database as a string.
393 */
394 public $sms_provider_id;
395
396 /**
397 * Key for validating requests related to this mailing.
398 *
399 * @var string|null
400 * (SQL type: varchar(16))
401 * Note that values will be retrieved from the database as a string.
402 */
403 public $hash;
404
405 /**
406 * With email_selection_method, determines which email address to use
407 *
408 * @var int|string|null
409 * (SQL type: int unsigned)
410 * Note that values will be retrieved from the database as a string.
411 */
412 public $location_type_id;
413
414 /**
415 * With location_type_id, determine how to choose the email address to use.
416 *
417 * @var string|null
418 * (SQL type: varchar(20))
419 * Note that values will be retrieved from the database as a string.
420 */
421 public $email_selection_method;
422
423 /**
424 * Language of the content of the mailing. Useful for tokens.
425 *
426 * @var string|null
427 * (SQL type: varchar(5))
428 * Note that values will be retrieved from the database as a string.
429 */
430 public $language;
431
432 /**
433 * Class constructor.
434 */
435 public function __construct() {
436 $this->__table = 'civicrm_mailing';
437 parent::__construct();
438 }
439
440 /**
441 * Returns localized title of this entity.
442 *
443 * @param bool $plural
444 * Whether to return the plural version of the title.
445 */
446 public static function getEntityTitle($plural = FALSE) {
447 return $plural ? ts('Mailings') : ts('Mailing');
448 }
449
450 /**
451 * Returns user-friendly description of this entity.
452 *
453 * @return string
454 */
455 public static function getEntityDescription() {
456 return ts('Mass emails sent from CiviMail.');
457 }
458
459 /**
460 * Returns foreign keys and entity references.
461 *
462 * @return array
463 * [CRM_Core_Reference_Interface]
464 */
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']);
482 }
483 return Civi::$statics[__CLASS__]['links'];
484 }
485
486 /**
487 * Returns all the column names of this table
488 *
489 * @return array
490 */
491 public static function &fields() {
492 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
493 Civi::$statics[__CLASS__]['fields'] = [
494 'id' => [
495 'name' => 'id',
496 'type' => CRM_Utils_Type::T_INT,
497 'title' => ts('Mailing ID'),
498 'required' => TRUE,
499 'where' => 'civicrm_mailing.id',
500 'table_name' => 'civicrm_mailing',
501 'entity' => 'Mailing',
502 'bao' => 'CRM_Mailing_BAO_Mailing',
503 'localizable' => 0,
504 'html' => [
505 'type' => 'Number',
506 ],
507 'readonly' => TRUE,
508 'add' => NULL,
509 ],
510 'domain_id' => [
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',
519 'localizable' => 0,
520 'FKClassName' => 'CRM_Core_DAO_Domain',
521 'html' => [
522 'label' => ts("Domain"),
523 ],
524 'pseudoconstant' => [
525 'table' => 'civicrm_domain',
526 'keyColumn' => 'id',
527 'labelColumn' => 'name',
528 ],
529 'add' => '3.4',
530 ],
531 'header_id' => [
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',
540 'localizable' => 0,
541 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
542 'html' => [
543 'label' => ts("Header"),
544 ],
545 'pseudoconstant' => [
546 'table' => 'civicrm_mailing_component',
547 'keyColumn' => 'id',
548 'labelColumn' => 'name',
549 'condition' => 'component_type = "Header"',
550 ],
551 'add' => NULL,
552 ],
553 'footer_id' => [
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',
562 'localizable' => 0,
563 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
564 'html' => [
565 'label' => ts("Footer"),
566 ],
567 'pseudoconstant' => [
568 'table' => 'civicrm_mailing_component',
569 'keyColumn' => 'id',
570 'labelColumn' => 'name',
571 'condition' => 'component_type = "Footer"',
572 ],
573 'add' => NULL,
574 ],
575 'reply_id' => [
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',
584 'localizable' => 0,
585 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
586 'html' => [
587 'label' => ts("Reply"),
588 ],
589 'add' => NULL,
590 ],
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',
600 'localizable' => 0,
601 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
602 'html' => [
603 'label' => ts("Unsubscribe"),
604 ],
605 'add' => NULL,
606 ],
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',
615 'localizable' => 0,
616 'add' => NULL,
617 ],
618 'optout_id' => [
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',
627 'localizable' => 0,
628 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
629 'html' => [
630 'label' => ts("Opt Out"),
631 ],
632 'add' => NULL,
633 ],
634 'mailing_name' => [
635 'name' => 'name',
636 'type' => CRM_Utils_Type::T_STRING,
637 'title' => ts('Mailing Name'),
638 'description' => ts('Mailing Name.'),
639 'maxlength' => 128,
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',
645 'localizable' => 0,
646 'html' => [
647 'type' => 'Text',
648 ],
649 'add' => NULL,
650 ],
651 'mailing_type' => [
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'),
656 'maxlength' => 32,
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',
662 'localizable' => 0,
663 'html' => [
664 'type' => 'Select',
665 ],
666 'pseudoconstant' => [
667 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
668 ],
669 'add' => '4.6',
670 ],
671 'from_name' => [
672 'name' => 'from_name',
673 'type' => CRM_Utils_Type::T_STRING,
674 'title' => ts('Mailing From Name'),
675 'description' => ts('From Header of mailing'),
676 'maxlength' => 128,
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',
682 'localizable' => 0,
683 'html' => [
684 'type' => 'Text',
685 ],
686 'add' => NULL,
687 ],
688 'from_email' => [
689 'name' => 'from_email',
690 'type' => CRM_Utils_Type::T_STRING,
691 'title' => ts('Mailing From Email'),
692 'description' => ts('From Email of mailing'),
693 'maxlength' => 128,
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',
699 'localizable' => 0,
700 'html' => [
701 'type' => 'Text',
702 ],
703 'add' => NULL,
704 ],
705 'replyto_email' => [
706 'name' => 'replyto_email',
707 'type' => CRM_Utils_Type::T_STRING,
708 'title' => ts('Replyto Email'),
709 'description' => ts('Reply-To Email of mailing'),
710 'maxlength' => 128,
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',
716 'localizable' => 0,
717 'html' => [
718 'type' => 'Text',
719 'label' => ts("Reply-To Email"),
720 ],
721 'add' => NULL,
722 ],
723 'template_type' => [
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.'),
728 'required' => TRUE,
729 'maxlength' => 64,
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',
736 'localizable' => 0,
737 'pseudoconstant' => [
738 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
739 ],
740 'add' => '4.7.16',
741 ],
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',
751 'localizable' => 0,
752 'serialize' => self::SERIALIZE_JSON,
753 'add' => '4.7.16',
754 ],
755 'subject' => [
756 'name' => 'subject',
757 'type' => CRM_Utils_Type::T_STRING,
758 'title' => ts('Subject'),
759 'description' => ts('Subject of mailing'),
760 'maxlength' => 128,
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',
766 'localizable' => 0,
767 'html' => [
768 'type' => 'Text',
769 'label' => ts("Subject"),
770 ],
771 'add' => NULL,
772 ],
773 'body_text' => [
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',
782 'localizable' => 0,
783 'html' => [
784 'label' => ts("Body Text"),
785 ],
786 'add' => NULL,
787 ],
788 'body_html' => [
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',
797 'localizable' => 0,
798 'html' => [
799 'label' => ts("Body HTML"),
800 ],
801 'add' => NULL,
802 ],
803 'url_tracking' => [
804 'name' => 'url_tracking',
805 'type' => CRM_Utils_Type::T_BOOLEAN,
806 'title' => ts('Url Tracking'),
807 'description' => ts('Should we track URL click-throughs for this mailing?'),
808 'required' => TRUE,
809 'where' => 'civicrm_mailing.url_tracking',
810 'default' => '0',
811 'table_name' => 'civicrm_mailing',
812 'entity' => 'Mailing',
813 'bao' => 'CRM_Mailing_BAO_Mailing',
814 'localizable' => 0,
815 'html' => [
816 'type' => 'CheckBox',
817 'label' => ts("Url Tracking"),
818 ],
819 'add' => NULL,
820 ],
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?'),
826 'required' => TRUE,
827 'where' => 'civicrm_mailing.forward_replies',
828 'default' => '0',
829 'table_name' => 'civicrm_mailing',
830 'entity' => 'Mailing',
831 'bao' => 'CRM_Mailing_BAO_Mailing',
832 'localizable' => 0,
833 'html' => [
834 'type' => 'CheckBox',
835 'label' => ts("Forward Replies"),
836 ],
837 'add' => NULL,
838 ],
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?'),
844 'required' => TRUE,
845 'where' => 'civicrm_mailing.auto_responder',
846 'default' => '0',
847 'table_name' => 'civicrm_mailing',
848 'entity' => 'Mailing',
849 'bao' => 'CRM_Mailing_BAO_Mailing',
850 'localizable' => 0,
851 'html' => [
852 'type' => 'CheckBox',
853 'label' => ts("Auto Responder"),
854 ],
855 'add' => NULL,
856 ],
857 'open_tracking' => [
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?'),
862 'required' => TRUE,
863 'where' => 'civicrm_mailing.open_tracking',
864 'default' => '0',
865 'table_name' => 'civicrm_mailing',
866 'entity' => 'Mailing',
867 'bao' => 'CRM_Mailing_BAO_Mailing',
868 'localizable' => 0,
869 'add' => NULL,
870 ],
871 'is_completed' => [
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?'),
876 'required' => TRUE,
877 'where' => 'civicrm_mailing.is_completed',
878 'default' => '0',
879 'table_name' => 'civicrm_mailing',
880 'entity' => 'Mailing',
881 'bao' => 'CRM_Mailing_BAO_Mailing',
882 'localizable' => 0,
883 'html' => [
884 'type' => 'CheckBox',
885 ],
886 'add' => NULL,
887 ],
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',
897 'localizable' => 0,
898 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
899 'html' => [
900 'label' => ts("Message Template"),
901 ],
902 'add' => NULL,
903 ],
904 'override_verp' => [
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'),
909 'required' => TRUE,
910 'where' => 'civicrm_mailing.override_verp',
911 'default' => '0',
912 'table_name' => 'civicrm_mailing',
913 'entity' => 'Mailing',
914 'bao' => 'CRM_Mailing_BAO_Mailing',
915 'localizable' => 0,
916 'html' => [
917 'type' => 'CheckBox',
918 'label' => ts("Overwrite VERP"),
919 ],
920 'add' => '2.2',
921 ],
922 'created_id' => [
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',
931 'localizable' => 0,
932 'FKClassName' => 'CRM_Contact_DAO_Contact',
933 'html' => [
934 'label' => ts("Creator"),
935 ],
936 'add' => NULL,
937 ],
938 'created_date' => [
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.'),
943 'required' => FALSE,
944 'where' => 'civicrm_mailing.created_date',
945 'default' => 'CURRENT_TIMESTAMP',
946 'table_name' => 'civicrm_mailing',
947 'entity' => 'Mailing',
948 'bao' => 'CRM_Mailing_BAO_Mailing',
949 'localizable' => 0,
950 'html' => [
951 'type' => 'Select Date',
952 'formatType' => 'activityDateTime',
953 ],
954 'add' => '3.0',
955 ],
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.'),
961 'required' => FALSE,
962 'where' => 'civicrm_mailing.modified_date',
963 'export' => TRUE,
964 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
965 'table_name' => 'civicrm_mailing',
966 'entity' => 'Mailing',
967 'bao' => 'CRM_Mailing_BAO_Mailing',
968 'localizable' => 0,
969 'html' => [
970 'label' => ts("Modified Date"),
971 ],
972 'readonly' => TRUE,
973 'add' => '4.7',
974 ],
975 'scheduled_id' => [
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',
984 'localizable' => 0,
985 'FKClassName' => 'CRM_Contact_DAO_Contact',
986 'html' => [
987 'label' => ts("Scheduled By"),
988 ],
989 'add' => NULL,
990 ],
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.'),
996 'required' => FALSE,
997 'where' => 'civicrm_mailing.scheduled_date',
998 'default' => NULL,
999 'table_name' => 'civicrm_mailing',
1000 'entity' => 'Mailing',
1001 'bao' => 'CRM_Mailing_BAO_Mailing',
1002 'localizable' => 0,
1003 'html' => [
1004 'type' => 'Select Date',
1005 'formatType' => 'activityDateTime',
1006 ],
1007 'add' => '3.3',
1008 ],
1009 'approver_id' => [
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',
1018 'localizable' => 0,
1019 'FKClassName' => 'CRM_Contact_DAO_Contact',
1020 'html' => [
1021 'label' => ts("Approved By"),
1022 ],
1023 'add' => NULL,
1024 ],
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',
1032 'default' => NULL,
1033 'table_name' => 'civicrm_mailing',
1034 'entity' => 'Mailing',
1035 'bao' => 'CRM_Mailing_BAO_Mailing',
1036 'localizable' => 0,
1037 'html' => [
1038 'type' => 'Select Date',
1039 'formatType' => 'activityDateTime',
1040 ],
1041 'add' => '3.3',
1042 ],
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',
1052 'localizable' => 0,
1053 'html' => [
1054 'type' => 'Select',
1055 ],
1056 'pseudoconstant' => [
1057 'optionGroupName' => 'mail_approval_status',
1058 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
1059 ],
1060 'add' => '3.3',
1061 ],
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',
1071 'localizable' => 0,
1072 'html' => [
1073 'type' => 'TextArea',
1074 ],
1075 'add' => '3.3',
1076 ],
1077 'is_archived' => [
1078 'name' => 'is_archived',
1079 'type' => CRM_Utils_Type::T_BOOLEAN,
1080 'title' => ts('Is Mailing Archived?'),
1081 'description' => ts('Is this mailing archived?'),
1082 'required' => TRUE,
1083 'where' => 'civicrm_mailing.is_archived',
1084 'default' => '0',
1085 'table_name' => 'civicrm_mailing',
1086 'entity' => 'Mailing',
1087 'bao' => 'CRM_Mailing_BAO_Mailing',
1088 'localizable' => 0,
1089 'html' => [
1090 'type' => 'CheckBox',
1091 ],
1092 'add' => '2.2',
1093 ],
1094 'visibility' => [
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)'),
1099 'maxlength' => 40,
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',
1106 'localizable' => 0,
1107 'html' => [
1108 'type' => 'Select',
1109 ],
1110 'pseudoconstant' => [
1111 'callback' => 'CRM_Core_SelectValues::groupVisibility',
1112 ],
1113 'add' => '3.3',
1114 ],
1115 'campaign_id' => [
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',
1124 'localizable' => 0,
1125 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1126 'component' => 'CiviCampaign',
1127 'html' => [
1128 'type' => 'EntityRef',
1129 'label' => ts("Campaign"),
1130 ],
1131 'pseudoconstant' => [
1132 'table' => 'civicrm_campaign',
1133 'keyColumn' => 'id',
1134 'labelColumn' => 'title',
1135 'prefetch' => 'FALSE',
1136 ],
1137 'add' => '3.4',
1138 ],
1139 'dedupe_email' => [
1140 'name' => 'dedupe_email',
1141 'type' => CRM_Utils_Type::T_BOOLEAN,
1142 'title' => ts('No Duplicate emails?'),
1143 'description' => ts('Remove duplicate emails?'),
1144 'required' => TRUE,
1145 'where' => 'civicrm_mailing.dedupe_email',
1146 'default' => '0',
1147 'table_name' => 'civicrm_mailing',
1148 'entity' => 'Mailing',
1149 'bao' => 'CRM_Mailing_BAO_Mailing',
1150 'localizable' => 0,
1151 'html' => [
1152 'type' => 'CheckBox',
1153 ],
1154 'add' => '4.1',
1155 ],
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',
1164 'localizable' => 0,
1165 'FKClassName' => 'CRM_SMS_DAO_Provider',
1166 'html' => [
1167 'type' => 'Select',
1168 'label' => ts("SMS Provider"),
1169 ],
1170 'add' => '4.2',
1171 ],
1172 'hash' => [
1173 'name' => 'hash',
1174 'type' => CRM_Utils_Type::T_STRING,
1175 'title' => ts('Mailing Hash'),
1176 'description' => ts('Key for validating requests related to this mailing.'),
1177 'maxlength' => 16,
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',
1183 'localizable' => 0,
1184 'readonly' => TRUE,
1185 'add' => '4.5',
1186 ],
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',
1196 'localizable' => 0,
1197 'FKClassName' => 'CRM_Core_DAO_LocationType',
1198 'html' => [
1199 'label' => ts("Location Type"),
1200 ],
1201 'pseudoconstant' => [
1202 'table' => 'civicrm_location_type',
1203 'keyColumn' => 'id',
1204 'labelColumn' => 'display_name',
1205 ],
1206 'add' => '4.6',
1207 ],
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.'),
1213 'maxlength' => 20,
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',
1220 'localizable' => 0,
1221 'html' => [
1222 'label' => ts("Email Selection Method"),
1223 ],
1224 'pseudoconstant' => [
1225 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1226 ],
1227 'add' => '4.6',
1228 ],
1229 'language' => [
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.'),
1234 'maxlength' => 5,
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',
1240 'localizable' => 0,
1241 'html' => [
1242 'type' => 'Select',
1243 ],
1244 'pseudoconstant' => [
1245 'optionGroupName' => 'languages',
1246 'keyColumn' => 'name',
1247 'optionEditPath' => 'civicrm/admin/options/languages',
1248 ],
1249 'add' => '4.6',
1250 ],
1251 ];
1252 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1253 }
1254 return Civi::$statics[__CLASS__]['fields'];
1255 }
1256
1257 /**
1258 * Return a mapping from field-name to the corresponding key (as used in fields()).
1259 *
1260 * @return array
1261 * Array(string $name => string $uniqueName).
1262 */
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()));
1266 }
1267 return Civi::$statics[__CLASS__]['fieldKeys'];
1268 }
1269
1270 /**
1271 * Returns the names of this table
1272 *
1273 * @return string
1274 */
1275 public static function getTableName() {
1276 return self::$_tableName;
1277 }
1278
1279 /**
1280 * Returns if this table needs to be logged
1281 *
1282 * @return bool
1283 */
1284 public function getLog() {
1285 return self::$_log;
1286 }
1287
1288 /**
1289 * Returns the list of fields that can be imported
1290 *
1291 * @param bool $prefix
1292 *
1293 * @return array
1294 */
1295 public static function &import($prefix = FALSE) {
1296 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, []);
1297 return $r;
1298 }
1299
1300 /**
1301 * Returns the list of fields that can be exported
1302 *
1303 * @param bool $prefix
1304 *
1305 * @return array
1306 */
1307 public static function &export($prefix = FALSE) {
1308 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, []);
1309 return $r;
1310 }
1311
1312 /**
1313 * Returns the list of indices
1314 *
1315 * @param bool $localize
1316 *
1317 * @return array
1318 */
1319 public static function indices($localize = TRUE) {
1320 $indices = [
1321 'index_hash' => [
1322 'name' => 'index_hash',
1323 'field' => [
1324 0 => 'hash',
1325 ],
1326 'localizable' => FALSE,
1327 'sig' => 'civicrm_mailing::0::hash',
1328 ],
1329 ];
1330 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1331 }
1332
1333 }