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