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