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