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