Merge pull request #22538 from masetto/pdfletter
[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:9815b093c77eedc9aa2c97c338a0e75d)
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|null
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|null
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|null
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|null
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|null
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|null
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|null
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|null
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' => NULL,
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 'add' => NULL,
753 ],
754 'subject' => [
755 'name' => 'subject',
756 'type' => CRM_Utils_Type::T_STRING,
757 'title' => ts('Subject'),
758 'description' => ts('Subject of mailing'),
759 'maxlength' => 128,
760 'size' => CRM_Utils_Type::HUGE,
761 'where' => 'civicrm_mailing.subject',
762 'table_name' => 'civicrm_mailing',
763 'entity' => 'Mailing',
764 'bao' => 'CRM_Mailing_BAO_Mailing',
765 'localizable' => 0,
766 'html' => [
767 'type' => 'Text',
768 'label' => ts("Subject"),
769 ],
770 'add' => NULL,
771 ],
772 'body_text' => [
773 'name' => 'body_text',
774 'type' => CRM_Utils_Type::T_LONGTEXT,
775 'title' => ts('Body Text'),
776 'description' => ts('Body of the mailing in text format.'),
777 'where' => 'civicrm_mailing.body_text',
778 'table_name' => 'civicrm_mailing',
779 'entity' => 'Mailing',
780 'bao' => 'CRM_Mailing_BAO_Mailing',
781 'localizable' => 0,
782 'html' => [
783 'label' => ts("Body Text"),
784 ],
785 'add' => NULL,
786 ],
787 'body_html' => [
788 'name' => 'body_html',
789 'type' => CRM_Utils_Type::T_LONGTEXT,
790 'title' => ts('Body Html'),
791 'description' => ts('Body of the mailing in html format.'),
792 'where' => 'civicrm_mailing.body_html',
793 'table_name' => 'civicrm_mailing',
794 'entity' => 'Mailing',
795 'bao' => 'CRM_Mailing_BAO_Mailing',
796 'localizable' => 0,
797 'html' => [
798 'label' => ts("Body HTML"),
799 ],
800 'add' => NULL,
801 ],
802 'url_tracking' => [
803 'name' => 'url_tracking',
804 'type' => CRM_Utils_Type::T_BOOLEAN,
805 'title' => ts('Url Tracking'),
806 'description' => ts('Should we track URL click-throughs for this mailing?'),
807 'where' => 'civicrm_mailing.url_tracking',
808 'table_name' => 'civicrm_mailing',
809 'entity' => 'Mailing',
810 'bao' => 'CRM_Mailing_BAO_Mailing',
811 'localizable' => 0,
812 'html' => [
813 'type' => 'CheckBox',
814 'label' => ts("Url Tracking"),
815 ],
816 'add' => NULL,
817 ],
818 'forward_replies' => [
819 'name' => 'forward_replies',
820 'type' => CRM_Utils_Type::T_BOOLEAN,
821 'title' => ts('Forward Replies'),
822 'description' => ts('Should we forward replies back to the author?'),
823 'where' => 'civicrm_mailing.forward_replies',
824 'table_name' => 'civicrm_mailing',
825 'entity' => 'Mailing',
826 'bao' => 'CRM_Mailing_BAO_Mailing',
827 'localizable' => 0,
828 'html' => [
829 'type' => 'CheckBox',
830 'label' => ts("Forward Replies"),
831 ],
832 'add' => NULL,
833 ],
834 'auto_responder' => [
835 'name' => 'auto_responder',
836 'type' => CRM_Utils_Type::T_BOOLEAN,
837 'title' => ts('Auto Responder'),
838 'description' => ts('Should we enable the auto-responder?'),
839 'where' => 'civicrm_mailing.auto_responder',
840 'table_name' => 'civicrm_mailing',
841 'entity' => 'Mailing',
842 'bao' => 'CRM_Mailing_BAO_Mailing',
843 'localizable' => 0,
844 'html' => [
845 'type' => 'CheckBox',
846 'label' => ts("Auto Responder"),
847 ],
848 'add' => NULL,
849 ],
850 'open_tracking' => [
851 'name' => 'open_tracking',
852 'type' => CRM_Utils_Type::T_BOOLEAN,
853 'title' => ts('Track Mailing?'),
854 'description' => ts('Should we track when recipients open/read this mailing?'),
855 'where' => 'civicrm_mailing.open_tracking',
856 'table_name' => 'civicrm_mailing',
857 'entity' => 'Mailing',
858 'bao' => 'CRM_Mailing_BAO_Mailing',
859 'localizable' => 0,
860 'add' => NULL,
861 ],
862 'is_completed' => [
863 'name' => 'is_completed',
864 'type' => CRM_Utils_Type::T_BOOLEAN,
865 'title' => ts('Mailing Completed'),
866 'description' => ts('Has at least one job associated with this mailing finished?'),
867 'where' => 'civicrm_mailing.is_completed',
868 'table_name' => 'civicrm_mailing',
869 'entity' => 'Mailing',
870 'bao' => 'CRM_Mailing_BAO_Mailing',
871 'localizable' => 0,
872 'html' => [
873 'type' => 'CheckBox',
874 ],
875 'add' => NULL,
876 ],
877 'msg_template_id' => [
878 'name' => 'msg_template_id',
879 'type' => CRM_Utils_Type::T_INT,
880 'title' => ts('Message Template ID'),
881 'description' => ts('FK to the message template.'),
882 'where' => 'civicrm_mailing.msg_template_id',
883 'table_name' => 'civicrm_mailing',
884 'entity' => 'Mailing',
885 'bao' => 'CRM_Mailing_BAO_Mailing',
886 'localizable' => 0,
887 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
888 'html' => [
889 'label' => ts("Message Template"),
890 ],
891 'add' => NULL,
892 ],
893 'override_verp' => [
894 'name' => 'override_verp',
895 'type' => CRM_Utils_Type::T_BOOLEAN,
896 'title' => ts('Override Verp'),
897 'description' => ts('Overwrite the VERP address in Reply-To'),
898 'where' => 'civicrm_mailing.override_verp',
899 'default' => '0',
900 'table_name' => 'civicrm_mailing',
901 'entity' => 'Mailing',
902 'bao' => 'CRM_Mailing_BAO_Mailing',
903 'localizable' => 0,
904 'html' => [
905 'type' => 'CheckBox',
906 'label' => ts("Overwrite VERP"),
907 ],
908 'add' => '2.2',
909 ],
910 'created_id' => [
911 'name' => 'created_id',
912 'type' => CRM_Utils_Type::T_INT,
913 'title' => ts('Created By Contact ID'),
914 'description' => ts('FK to Contact ID who first created this mailing'),
915 'where' => 'civicrm_mailing.created_id',
916 'table_name' => 'civicrm_mailing',
917 'entity' => 'Mailing',
918 'bao' => 'CRM_Mailing_BAO_Mailing',
919 'localizable' => 0,
920 'FKClassName' => 'CRM_Contact_DAO_Contact',
921 'html' => [
922 'label' => ts("Creator"),
923 ],
924 'add' => NULL,
925 ],
926 'created_date' => [
927 'name' => 'created_date',
928 'type' => CRM_Utils_Type::T_TIMESTAMP,
929 'title' => ts('Mailing Created Date'),
930 'description' => ts('Date and time this mailing was created.'),
931 'required' => FALSE,
932 'where' => 'civicrm_mailing.created_date',
933 'default' => 'CURRENT_TIMESTAMP',
934 'table_name' => 'civicrm_mailing',
935 'entity' => 'Mailing',
936 'bao' => 'CRM_Mailing_BAO_Mailing',
937 'localizable' => 0,
938 'html' => [
939 'type' => 'Select Date',
940 'formatType' => 'activityDateTime',
941 ],
942 'add' => '3.0',
943 ],
944 'mailing_modified_date' => [
945 'name' => 'modified_date',
946 'type' => CRM_Utils_Type::T_TIMESTAMP,
947 'title' => ts('Modified Date'),
948 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
949 'required' => FALSE,
950 'where' => 'civicrm_mailing.modified_date',
951 'export' => TRUE,
952 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
953 'table_name' => 'civicrm_mailing',
954 'entity' => 'Mailing',
955 'bao' => 'CRM_Mailing_BAO_Mailing',
956 'localizable' => 0,
957 'html' => [
958 'label' => ts("Modified Date"),
959 ],
960 'readonly' => TRUE,
961 'add' => '4.7',
962 ],
963 'scheduled_id' => [
964 'name' => 'scheduled_id',
965 'type' => CRM_Utils_Type::T_INT,
966 'title' => ts('Scheduled By Contact ID'),
967 'description' => ts('FK to Contact ID who scheduled this mailing'),
968 'where' => 'civicrm_mailing.scheduled_id',
969 'table_name' => 'civicrm_mailing',
970 'entity' => 'Mailing',
971 'bao' => 'CRM_Mailing_BAO_Mailing',
972 'localizable' => 0,
973 'FKClassName' => 'CRM_Contact_DAO_Contact',
974 'html' => [
975 'label' => ts("Scheduled By"),
976 ],
977 'add' => NULL,
978 ],
979 'scheduled_date' => [
980 'name' => 'scheduled_date',
981 'type' => CRM_Utils_Type::T_TIMESTAMP,
982 'title' => ts('Mailing Scheduled Date'),
983 'description' => ts('Date and time this mailing was scheduled.'),
984 'required' => FALSE,
985 'where' => 'civicrm_mailing.scheduled_date',
986 'default' => NULL,
987 'table_name' => 'civicrm_mailing',
988 'entity' => 'Mailing',
989 'bao' => 'CRM_Mailing_BAO_Mailing',
990 'localizable' => 0,
991 'html' => [
992 'type' => 'Select Date',
993 'formatType' => 'activityDateTime',
994 ],
995 'add' => '3.3',
996 ],
997 'approver_id' => [
998 'name' => 'approver_id',
999 'type' => CRM_Utils_Type::T_INT,
1000 'title' => ts('Approved By Contact ID'),
1001 'description' => ts('FK to Contact ID who approved this mailing'),
1002 'where' => 'civicrm_mailing.approver_id',
1003 'table_name' => 'civicrm_mailing',
1004 'entity' => 'Mailing',
1005 'bao' => 'CRM_Mailing_BAO_Mailing',
1006 'localizable' => 0,
1007 'FKClassName' => 'CRM_Contact_DAO_Contact',
1008 'html' => [
1009 'label' => ts("Approved By"),
1010 ],
1011 'add' => NULL,
1012 ],
1013 'approval_date' => [
1014 'name' => 'approval_date',
1015 'type' => CRM_Utils_Type::T_TIMESTAMP,
1016 'title' => ts('Mailing Approved Date'),
1017 'description' => ts('Date and time this mailing was approved.'),
1018 'required' => FALSE,
1019 'where' => 'civicrm_mailing.approval_date',
1020 'default' => NULL,
1021 'table_name' => 'civicrm_mailing',
1022 'entity' => 'Mailing',
1023 'bao' => 'CRM_Mailing_BAO_Mailing',
1024 'localizable' => 0,
1025 'html' => [
1026 'type' => 'Select Date',
1027 'formatType' => 'activityDateTime',
1028 ],
1029 'add' => '3.3',
1030 ],
1031 'approval_status_id' => [
1032 'name' => 'approval_status_id',
1033 'type' => CRM_Utils_Type::T_INT,
1034 'title' => ts('Approval Status'),
1035 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
1036 'where' => 'civicrm_mailing.approval_status_id',
1037 'table_name' => 'civicrm_mailing',
1038 'entity' => 'Mailing',
1039 'bao' => 'CRM_Mailing_BAO_Mailing',
1040 'localizable' => 0,
1041 'html' => [
1042 'type' => 'Select',
1043 ],
1044 'pseudoconstant' => [
1045 'optionGroupName' => 'mail_approval_status',
1046 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
1047 ],
1048 'add' => '3.3',
1049 ],
1050 'approval_note' => [
1051 'name' => 'approval_note',
1052 'type' => CRM_Utils_Type::T_LONGTEXT,
1053 'title' => ts('Approval Note'),
1054 'description' => ts('Note behind the decision.'),
1055 'where' => 'civicrm_mailing.approval_note',
1056 'table_name' => 'civicrm_mailing',
1057 'entity' => 'Mailing',
1058 'bao' => 'CRM_Mailing_BAO_Mailing',
1059 'localizable' => 0,
1060 'html' => [
1061 'type' => 'TextArea',
1062 ],
1063 'add' => '3.3',
1064 ],
1065 'is_archived' => [
1066 'name' => 'is_archived',
1067 'type' => CRM_Utils_Type::T_BOOLEAN,
1068 'title' => ts('Is Mailing Archived?'),
1069 'description' => ts('Is this mailing archived?'),
1070 'where' => 'civicrm_mailing.is_archived',
1071 'default' => '0',
1072 'table_name' => 'civicrm_mailing',
1073 'entity' => 'Mailing',
1074 'bao' => 'CRM_Mailing_BAO_Mailing',
1075 'localizable' => 0,
1076 'html' => [
1077 'type' => 'CheckBox',
1078 ],
1079 'add' => '2.2',
1080 ],
1081 'visibility' => [
1082 'name' => 'visibility',
1083 'type' => CRM_Utils_Type::T_STRING,
1084 'title' => ts('Mailing Visibility'),
1085 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
1086 'maxlength' => 40,
1087 'size' => CRM_Utils_Type::BIG,
1088 'where' => 'civicrm_mailing.visibility',
1089 'default' => 'Public Pages',
1090 'table_name' => 'civicrm_mailing',
1091 'entity' => 'Mailing',
1092 'bao' => 'CRM_Mailing_BAO_Mailing',
1093 'localizable' => 0,
1094 'html' => [
1095 'type' => 'Select',
1096 ],
1097 'pseudoconstant' => [
1098 'callback' => 'CRM_Core_SelectValues::groupVisibility',
1099 ],
1100 'add' => '3.3',
1101 ],
1102 'campaign_id' => [
1103 'name' => 'campaign_id',
1104 'type' => CRM_Utils_Type::T_INT,
1105 'title' => ts('Campaign ID'),
1106 'description' => ts('The campaign for which this mailing has been initiated.'),
1107 'where' => 'civicrm_mailing.campaign_id',
1108 'table_name' => 'civicrm_mailing',
1109 'entity' => 'Mailing',
1110 'bao' => 'CRM_Mailing_BAO_Mailing',
1111 'localizable' => 0,
1112 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
1113 'component' => 'CiviCampaign',
1114 'html' => [
1115 'type' => 'EntityRef',
1116 'label' => ts("Campaign"),
1117 ],
1118 'pseudoconstant' => [
1119 'table' => 'civicrm_campaign',
1120 'keyColumn' => 'id',
1121 'labelColumn' => 'title',
1122 'prefetch' => 'FALSE',
1123 ],
1124 'add' => '3.4',
1125 ],
1126 'dedupe_email' => [
1127 'name' => 'dedupe_email',
1128 'type' => CRM_Utils_Type::T_BOOLEAN,
1129 'title' => ts('No Duplicate emails?'),
1130 'description' => ts('Remove duplicate emails?'),
1131 'where' => 'civicrm_mailing.dedupe_email',
1132 'default' => '0',
1133 'table_name' => 'civicrm_mailing',
1134 'entity' => 'Mailing',
1135 'bao' => 'CRM_Mailing_BAO_Mailing',
1136 'localizable' => 0,
1137 'html' => [
1138 'type' => 'CheckBox',
1139 ],
1140 'add' => '4.1',
1141 ],
1142 'sms_provider_id' => [
1143 'name' => 'sms_provider_id',
1144 'type' => CRM_Utils_Type::T_INT,
1145 'title' => ts('SMS Provider ID'),
1146 'where' => 'civicrm_mailing.sms_provider_id',
1147 'table_name' => 'civicrm_mailing',
1148 'entity' => 'Mailing',
1149 'bao' => 'CRM_Mailing_BAO_Mailing',
1150 'localizable' => 0,
1151 'FKClassName' => 'CRM_SMS_DAO_Provider',
1152 'html' => [
1153 'type' => 'Select',
1154 'label' => ts("SMS Provider"),
1155 ],
1156 'add' => '4.2',
1157 ],
1158 'hash' => [
1159 'name' => 'hash',
1160 'type' => CRM_Utils_Type::T_STRING,
1161 'title' => ts('Mailing Hash'),
1162 'description' => ts('Key for validating requests related to this mailing.'),
1163 'maxlength' => 16,
1164 'size' => CRM_Utils_Type::TWELVE,
1165 'where' => 'civicrm_mailing.hash',
1166 'table_name' => 'civicrm_mailing',
1167 'entity' => 'Mailing',
1168 'bao' => 'CRM_Mailing_BAO_Mailing',
1169 'localizable' => 0,
1170 'readonly' => TRUE,
1171 'add' => '4.5',
1172 ],
1173 'location_type_id' => [
1174 'name' => 'location_type_id',
1175 'type' => CRM_Utils_Type::T_INT,
1176 'title' => ts('Location Type ID'),
1177 'description' => ts('With email_selection_method, determines which email address to use'),
1178 'where' => 'civicrm_mailing.location_type_id',
1179 'table_name' => 'civicrm_mailing',
1180 'entity' => 'Mailing',
1181 'bao' => 'CRM_Mailing_BAO_Mailing',
1182 'localizable' => 0,
1183 'FKClassName' => 'CRM_Core_DAO_LocationType',
1184 'html' => [
1185 'label' => ts("Location Type"),
1186 ],
1187 'pseudoconstant' => [
1188 'table' => 'civicrm_location_type',
1189 'keyColumn' => 'id',
1190 'labelColumn' => 'display_name',
1191 ],
1192 'add' => '4.6',
1193 ],
1194 'email_selection_method' => [
1195 'name' => 'email_selection_method',
1196 'type' => CRM_Utils_Type::T_STRING,
1197 'title' => ts('Email Selection Method'),
1198 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
1199 'maxlength' => 20,
1200 'size' => CRM_Utils_Type::MEDIUM,
1201 'where' => 'civicrm_mailing.email_selection_method',
1202 'default' => 'automatic',
1203 'table_name' => 'civicrm_mailing',
1204 'entity' => 'Mailing',
1205 'bao' => 'CRM_Mailing_BAO_Mailing',
1206 'localizable' => 0,
1207 'html' => [
1208 'label' => ts("Email Selection Method"),
1209 ],
1210 'pseudoconstant' => [
1211 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
1212 ],
1213 'add' => '4.6',
1214 ],
1215 'language' => [
1216 'name' => 'language',
1217 'type' => CRM_Utils_Type::T_STRING,
1218 'title' => ts('Mailing Language'),
1219 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
1220 'maxlength' => 5,
1221 'size' => CRM_Utils_Type::SIX,
1222 'where' => 'civicrm_mailing.language',
1223 'table_name' => 'civicrm_mailing',
1224 'entity' => 'Mailing',
1225 'bao' => 'CRM_Mailing_BAO_Mailing',
1226 'localizable' => 0,
1227 'html' => [
1228 'type' => 'Select',
1229 ],
1230 'pseudoconstant' => [
1231 'optionGroupName' => 'languages',
1232 'keyColumn' => 'name',
1233 'optionEditPath' => 'civicrm/admin/options/languages',
1234 ],
1235 'add' => '4.6',
1236 ],
1237 ];
1238 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
1239 }
1240 return Civi::$statics[__CLASS__]['fields'];
1241 }
1242
1243 /**
1244 * Return a mapping from field-name to the corresponding key (as used in fields()).
1245 *
1246 * @return array
1247 * Array(string $name => string $uniqueName).
1248 */
1249 public static function &fieldKeys() {
1250 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
1251 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
1252 }
1253 return Civi::$statics[__CLASS__]['fieldKeys'];
1254 }
1255
1256 /**
1257 * Returns the names of this table
1258 *
1259 * @return string
1260 */
1261 public static function getTableName() {
1262 return self::$_tableName;
1263 }
1264
1265 /**
1266 * Returns if this table needs to be logged
1267 *
1268 * @return bool
1269 */
1270 public function getLog() {
1271 return self::$_log;
1272 }
1273
1274 /**
1275 * Returns the list of fields that can be imported
1276 *
1277 * @param bool $prefix
1278 *
1279 * @return array
1280 */
1281 public static function &import($prefix = FALSE) {
1282 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, []);
1283 return $r;
1284 }
1285
1286 /**
1287 * Returns the list of fields that can be exported
1288 *
1289 * @param bool $prefix
1290 *
1291 * @return array
1292 */
1293 public static function &export($prefix = FALSE) {
1294 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, []);
1295 return $r;
1296 }
1297
1298 /**
1299 * Returns the list of indices
1300 *
1301 * @param bool $localize
1302 *
1303 * @return array
1304 */
1305 public static function indices($localize = TRUE) {
1306 $indices = [
1307 'index_hash' => [
1308 'name' => 'index_hash',
1309 'field' => [
1310 0 => 'hash',
1311 ],
1312 'localizable' => FALSE,
1313 'sig' => 'civicrm_mailing::0::hash',
1314 ],
1315 ];
1316 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1317 }
1318
1319 }