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