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