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