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