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