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