Merge pull request #13258 from eileenmcnaughton/isam
[civicrm-core.git] / CRM / Mailing / DAO / Mailing.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Mailing/Mailing.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e380ee3b 9 * (GenCodeChecksum:5a53b90adc8124a3af37701d7a50b822)
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 */
22 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 */
c3fc2621
CW
29 static $_log = FALSE;
30
e501603b 31 /**
e501603b
TO
32 * @var int unsigned
33 */
34 public $id;
c3fc2621 35
e501603b
TO
36 /**
37 * Which site is this mailing for
38 *
39 * @var int unsigned
40 */
41 public $domain_id;
c3fc2621 42
e501603b
TO
43 /**
44 * FK to the header component.
45 *
46 * @var int unsigned
47 */
48 public $header_id;
c3fc2621 49
e501603b
TO
50 /**
51 * FK to the footer component.
52 *
53 * @var int unsigned
54 */
55 public $footer_id;
c3fc2621 56
e501603b
TO
57 /**
58 * FK to the auto-responder component.
59 *
60 * @var int unsigned
61 */
62 public $reply_id;
c3fc2621 63
e501603b
TO
64 /**
65 * FK to the unsubscribe component.
66 *
67 * @var int unsigned
68 */
69 public $unsubscribe_id;
c3fc2621 70
e501603b 71 /**
e501603b
TO
72 * @var int unsigned
73 */
74 public $resubscribe_id;
c3fc2621 75
e501603b
TO
76 /**
77 * FK to the opt-out component.
78 *
79 * @var int unsigned
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 *
156 * @var boolean
157 */
158 public $url_tracking;
c3fc2621 159
e501603b
TO
160 /**
161 * Should we forward replies back to the author?
162 *
163 * @var boolean
164 */
165 public $forward_replies;
c3fc2621 166
e501603b
TO
167 /**
168 * Should we enable the auto-responder?
169 *
170 * @var boolean
171 */
172 public $auto_responder;
c3fc2621 173
e501603b
TO
174 /**
175 * Should we track when recipients open/read this mailing?
176 *
177 * @var boolean
178 */
179 public $open_tracking;
c3fc2621 180
e501603b
TO
181 /**
182 * Has at least one job associated with this mailing finished?
183 *
184 * @var boolean
185 */
186 public $is_completed;
c3fc2621 187
e501603b
TO
188 /**
189 * FK to the message template.
190 *
191 * @var int unsigned
192 */
193 public $msg_template_id;
c3fc2621 194
e501603b
TO
195 /**
196 * Should we overrite VERP address in Reply-To
197 *
198 * @var boolean
199 */
200 public $override_verp;
c3fc2621 201
e501603b
TO
202 /**
203 * FK to Contact ID who first created this mailing
204 *
205 * @var int unsigned
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 *
226 * @var int unsigned
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 *
240 * @var int unsigned
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 *
254 * @var int unsigned
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 *
268 * @var boolean
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 *
282 * @var int unsigned
283 */
284 public $campaign_id;
c3fc2621 285
e501603b
TO
286 /**
287 * Remove duplicate emails?
288 *
289 * @var boolean
290 */
291 public $dedupe_email;
c3fc2621 292
e501603b 293 /**
e501603b
TO
294 * @var int unsigned
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 *
308 * @var int unsigned
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
TO
341 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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,
522a26c9 374 'table_name' => 'civicrm_mailing',
375 'entity' => 'Mailing',
376 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 377 'localizable' => 0,
c3fc2621
CW
378 ],
379 'domain_id' => [
e501603b
TO
380 'name' => 'domain_id',
381 'type' => CRM_Utils_Type::T_INT,
c3fc2621 382 'title' => ts('Mailing Domain'),
215b423e 383 'description' => ts('Which site is this mailing for'),
522a26c9 384 'table_name' => 'civicrm_mailing',
385 'entity' => 'Mailing',
386 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 387 'localizable' => 0,
e501603b 388 'FKClassName' => 'CRM_Core_DAO_Domain',
c3fc2621 389 'pseudoconstant' => [
e501603b
TO
390 'table' => 'civicrm_domain',
391 'keyColumn' => 'id',
392 'labelColumn' => 'name',
c3fc2621
CW
393 ]
394 ],
395 'header_id' => [
e501603b
TO
396 'name' => 'header_id',
397 'type' => CRM_Utils_Type::T_INT,
c3fc2621 398 'title' => ts('Mailing Header'),
215b423e 399 'description' => ts('FK to the header component.'),
522a26c9 400 'table_name' => 'civicrm_mailing',
401 'entity' => 'Mailing',
402 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 403 'localizable' => 0,
807f8008 404 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
c3fc2621
CW
405 ],
406 'footer_id' => [
e501603b
TO
407 'name' => 'footer_id',
408 'type' => CRM_Utils_Type::T_INT,
c3fc2621 409 'title' => ts('Mailing Footer'),
215b423e 410 'description' => ts('FK to the footer component.'),
522a26c9 411 'table_name' => 'civicrm_mailing',
412 'entity' => 'Mailing',
413 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 414 'localizable' => 0,
807f8008 415 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
c3fc2621
CW
416 ],
417 'reply_id' => [
e501603b
TO
418 'name' => 'reply_id',
419 'type' => CRM_Utils_Type::T_INT,
c3fc2621 420 'title' => ts('Mailing Reply'),
215b423e 421 'description' => ts('FK to the auto-responder component.'),
522a26c9 422 'table_name' => 'civicrm_mailing',
423 'entity' => 'Mailing',
424 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 425 'localizable' => 0,
807f8008 426 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
c3fc2621
CW
427 ],
428 'unsubscribe_id' => [
e501603b
TO
429 'name' => 'unsubscribe_id',
430 'type' => CRM_Utils_Type::T_INT,
c3fc2621 431 'title' => ts('Mailing Unsubscribe'),
215b423e 432 'description' => ts('FK to the unsubscribe component.'),
522a26c9 433 'table_name' => 'civicrm_mailing',
434 'entity' => 'Mailing',
435 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 436 'localizable' => 0,
807f8008 437 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
c3fc2621
CW
438 ],
439 'resubscribe_id' => [
e501603b
TO
440 'name' => 'resubscribe_id',
441 'type' => CRM_Utils_Type::T_INT,
c3fc2621 442 'title' => ts('Mailing Resubscribe'),
522a26c9 443 'table_name' => 'civicrm_mailing',
444 'entity' => 'Mailing',
445 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 446 'localizable' => 0,
c3fc2621
CW
447 ],
448 'optout_id' => [
e501603b
TO
449 'name' => 'optout_id',
450 'type' => CRM_Utils_Type::T_INT,
c3fc2621 451 'title' => ts('Mailing Opt Out'),
215b423e 452 'description' => ts('FK to the opt-out component.'),
522a26c9 453 'table_name' => 'civicrm_mailing',
454 'entity' => 'Mailing',
455 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 456 'localizable' => 0,
807f8008 457 'FKClassName' => 'CRM_Mailing_DAO_MailingComponent',
c3fc2621
CW
458 ],
459 'name' => [
e501603b
TO
460 'name' => 'name',
461 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 462 'title' => ts('Mailing Name'),
215b423e 463 'description' => ts('Mailing Name.'),
e501603b
TO
464 'maxlength' => 128,
465 'size' => CRM_Utils_Type::HUGE,
522a26c9 466 'table_name' => 'civicrm_mailing',
467 'entity' => 'Mailing',
468 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 469 'localizable' => 0,
c3fc2621 470 'html' => [
e501603b 471 'type' => 'Text',
c3fc2621
CW
472 ],
473 ],
474 'mailing_type' => [
e501603b
TO
475 'name' => 'mailing_type',
476 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 477 'title' => ts('Mailing Type'),
215b423e 478 'description' => ts('differentiate between standalone mailings, A/B tests, and A/B final-winner'),
e501603b
TO
479 'maxlength' => 32,
480 'size' => CRM_Utils_Type::MEDIUM,
522a26c9 481 'table_name' => 'civicrm_mailing',
482 'entity' => 'Mailing',
483 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 484 'localizable' => 0,
c3fc2621 485 'html' => [
e501603b 486 'type' => 'Select',
c3fc2621
CW
487 ],
488 'pseudoconstant' => [
e501603b 489 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
c3fc2621
CW
490 ]
491 ],
492 'from_name' => [
e501603b
TO
493 'name' => 'from_name',
494 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 495 'title' => ts('Mailing From Name'),
215b423e 496 'description' => ts('From Header of mailing'),
e501603b
TO
497 'maxlength' => 128,
498 'size' => CRM_Utils_Type::HUGE,
522a26c9 499 'table_name' => 'civicrm_mailing',
500 'entity' => 'Mailing',
501 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 502 'localizable' => 0,
c3fc2621 503 'html' => [
e501603b 504 'type' => 'Text',
c3fc2621
CW
505 ],
506 ],
507 'from_email' => [
e501603b
TO
508 'name' => 'from_email',
509 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 510 'title' => ts('Mailing From Email'),
215b423e 511 'description' => ts('From Email of mailing'),
e501603b
TO
512 'maxlength' => 128,
513 'size' => CRM_Utils_Type::HUGE,
522a26c9 514 'table_name' => 'civicrm_mailing',
515 'entity' => 'Mailing',
516 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 517 'localizable' => 0,
c3fc2621 518 'html' => [
e501603b 519 'type' => 'Text',
c3fc2621
CW
520 ],
521 ],
522 'replyto_email' => [
e501603b
TO
523 'name' => 'replyto_email',
524 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 525 'title' => ts('Replyto Email'),
215b423e 526 'description' => ts('Reply-To Email of mailing'),
e501603b
TO
527 'maxlength' => 128,
528 'size' => CRM_Utils_Type::HUGE,
522a26c9 529 'table_name' => 'civicrm_mailing',
530 'entity' => 'Mailing',
531 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 532 'localizable' => 0,
c3fc2621 533 'html' => [
e501603b 534 'type' => 'Text',
c3fc2621
CW
535 ],
536 ],
537 'template_type' => [
703875d8
TO
538 'name' => 'template_type',
539 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 540 'title' => ts('Template Type'),
215b423e 541 'description' => ts('The language/processing system used for email templates.'),
c3fc2621 542 'required' => TRUE,
703875d8
TO
543 'maxlength' => 64,
544 'size' => CRM_Utils_Type::BIG,
545 'default' => 'traditional',
522a26c9 546 'table_name' => 'civicrm_mailing',
547 'entity' => 'Mailing',
548 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 549 'localizable' => 0,
c3fc2621 550 'pseudoconstant' => [
703875d8 551 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
c3fc2621
CW
552 ]
553 ],
554 'template_options' => [
703875d8
TO
555 'name' => 'template_options',
556 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 557 'title' => ts('Template Options (JSON)'),
215b423e 558 'description' => ts('Advanced options used by the email templating system. (JSON encoded)'),
522a26c9 559 'table_name' => 'civicrm_mailing',
560 'entity' => 'Mailing',
561 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 562 'localizable' => 0,
c3fc2621
CW
563 ],
564 'subject' => [
e501603b
TO
565 'name' => 'subject',
566 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 567 'title' => ts('Subject'),
215b423e 568 'description' => ts('Subject of mailing'),
e501603b
TO
569 'maxlength' => 128,
570 'size' => CRM_Utils_Type::HUGE,
522a26c9 571 'table_name' => 'civicrm_mailing',
572 'entity' => 'Mailing',
573 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 574 'localizable' => 0,
c3fc2621 575 'html' => [
e501603b 576 'type' => 'Text',
c3fc2621
CW
577 ],
578 ],
579 'body_text' => [
e501603b
TO
580 'name' => 'body_text',
581 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 582 'title' => ts('Body Text'),
215b423e 583 'description' => ts('Body of the mailing in text format.'),
522a26c9 584 'table_name' => 'civicrm_mailing',
585 'entity' => 'Mailing',
586 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 587 'localizable' => 0,
c3fc2621
CW
588 ],
589 'body_html' => [
e501603b
TO
590 'name' => 'body_html',
591 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 592 'title' => ts('Body Html'),
215b423e 593 'description' => ts('Body of the mailing in html format.'),
522a26c9 594 'table_name' => 'civicrm_mailing',
595 'entity' => 'Mailing',
596 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 597 'localizable' => 0,
c3fc2621
CW
598 ],
599 'url_tracking' => [
e501603b
TO
600 'name' => 'url_tracking',
601 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 602 'title' => ts('Url Tracking'),
215b423e 603 'description' => ts('Should we track URL click-throughs for this mailing?'),
522a26c9 604 'table_name' => 'civicrm_mailing',
605 'entity' => 'Mailing',
606 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 607 'localizable' => 0,
c3fc2621 608 'html' => [
e501603b 609 'type' => 'CheckBox',
c3fc2621
CW
610 ],
611 ],
612 'forward_replies' => [
e501603b
TO
613 'name' => 'forward_replies',
614 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 615 'title' => ts('Forward Replies'),
215b423e 616 'description' => ts('Should we forward replies back to the author?'),
522a26c9 617 'table_name' => 'civicrm_mailing',
618 'entity' => 'Mailing',
619 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 620 'localizable' => 0,
c3fc2621 621 'html' => [
e501603b 622 'type' => 'CheckBox',
c3fc2621
CW
623 ],
624 ],
625 'auto_responder' => [
e501603b
TO
626 'name' => 'auto_responder',
627 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 628 'title' => ts('Auto Responder'),
215b423e 629 'description' => ts('Should we enable the auto-responder?'),
522a26c9 630 'table_name' => 'civicrm_mailing',
631 'entity' => 'Mailing',
632 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 633 'localizable' => 0,
c3fc2621 634 'html' => [
e501603b 635 'type' => 'CheckBox',
c3fc2621
CW
636 ],
637 ],
638 'open_tracking' => [
e501603b
TO
639 'name' => 'open_tracking',
640 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 641 'title' => ts('Track Mailing?'),
215b423e 642 'description' => ts('Should we track when recipients open/read this mailing?'),
522a26c9 643 'table_name' => 'civicrm_mailing',
644 'entity' => 'Mailing',
645 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 646 'localizable' => 0,
c3fc2621
CW
647 ],
648 'is_completed' => [
e501603b
TO
649 'name' => 'is_completed',
650 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 651 'title' => ts('Mailing Completed'),
215b423e 652 'description' => ts('Has at least one job associated with this mailing finished?'),
522a26c9 653 'table_name' => 'civicrm_mailing',
654 'entity' => 'Mailing',
655 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 656 'localizable' => 0,
c3fc2621 657 'html' => [
e501603b 658 'type' => 'CheckBox',
c3fc2621
CW
659 ],
660 ],
661 'msg_template_id' => [
e501603b
TO
662 'name' => 'msg_template_id',
663 'type' => CRM_Utils_Type::T_INT,
c3fc2621 664 'title' => ts('Mailing Message Template'),
215b423e 665 'description' => ts('FK to the message template.'),
522a26c9 666 'table_name' => 'civicrm_mailing',
667 'entity' => 'Mailing',
668 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 669 'localizable' => 0,
e501603b 670 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
c3fc2621
CW
671 ],
672 'override_verp' => [
e501603b
TO
673 'name' => 'override_verp',
674 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 675 'title' => ts('Override Verp'),
215b423e 676 'description' => ts('Should we overrite VERP address in Reply-To'),
45a83e42 677 'default' => '0',
522a26c9 678 'table_name' => 'civicrm_mailing',
679 'entity' => 'Mailing',
680 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 681 'localizable' => 0,
c3fc2621 682 'html' => [
e501603b 683 'type' => 'CheckBox',
c3fc2621
CW
684 ],
685 ],
686 'created_id' => [
e501603b
TO
687 'name' => 'created_id',
688 'type' => CRM_Utils_Type::T_INT,
c3fc2621 689 'title' => ts('Mailing Creator'),
215b423e 690 'description' => ts('FK to Contact ID who first created this mailing'),
522a26c9 691 'table_name' => 'civicrm_mailing',
692 'entity' => 'Mailing',
693 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 694 'localizable' => 0,
e501603b 695 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
696 ],
697 'created_date' => [
e501603b 698 'name' => 'created_date',
6c2b97b7 699 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 700 'title' => ts('Mailing Created Date'),
215b423e 701 'description' => ts('Date and time this mailing was created.'),
c3fc2621 702 'required' => FALSE,
e7a6eae8 703 'default' => 'NULL',
522a26c9 704 'table_name' => 'civicrm_mailing',
705 'entity' => 'Mailing',
706 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 707 'localizable' => 0,
c3fc2621 708 'html' => [
e501603b 709 'type' => 'Select Date',
6c2b97b7 710 'formatType' => 'activityDateTime',
c3fc2621
CW
711 ],
712 ],
713 'mailing_modified_date' => [
e7a6eae8
SL
714 'name' => 'modified_date',
715 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 716 'title' => ts('Modified Date'),
215b423e 717 'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
c3fc2621
CW
718 'required' => FALSE,
719 'export' => TRUE,
e7a6eae8
SL
720 'where' => 'civicrm_mailing.modified_date',
721 'headerPattern' => '',
722 'dataPattern' => '',
723 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
724 'table_name' => 'civicrm_mailing',
725 'entity' => 'Mailing',
726 'bao' => 'CRM_Mailing_BAO_Mailing',
727 'localizable' => 0,
c3fc2621
CW
728 ],
729 'scheduled_id' => [
e501603b
TO
730 'name' => 'scheduled_id',
731 'type' => CRM_Utils_Type::T_INT,
c3fc2621 732 'title' => ts('Scheduled By'),
215b423e 733 'description' => ts('FK to Contact ID who scheduled this mailing'),
522a26c9 734 'table_name' => 'civicrm_mailing',
735 'entity' => 'Mailing',
736 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 737 'localizable' => 0,
e501603b 738 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
739 ],
740 'scheduled_date' => [
e501603b 741 'name' => 'scheduled_date',
6c2b97b7 742 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 743 'title' => ts('Mailing Scheduled Date'),
215b423e 744 'description' => ts('Date and time this mailing was scheduled.'),
c3fc2621 745 'required' => FALSE,
6c2b97b7 746 'default' => 'NULL',
522a26c9 747 'table_name' => 'civicrm_mailing',
748 'entity' => 'Mailing',
749 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 750 'localizable' => 0,
c3fc2621 751 'html' => [
6c2b97b7 752 'type' => 'Select Date',
753 'formatType' => 'activityDateTime',
c3fc2621
CW
754 ],
755 ],
756 'approver_id' => [
e501603b
TO
757 'name' => 'approver_id',
758 'type' => CRM_Utils_Type::T_INT,
c3fc2621 759 'title' => ts('Approved By'),
215b423e 760 'description' => ts('FK to Contact ID who approved this mailing'),
522a26c9 761 'table_name' => 'civicrm_mailing',
762 'entity' => 'Mailing',
763 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 764 'localizable' => 0,
e501603b 765 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
766 ],
767 'approval_date' => [
e501603b 768 'name' => 'approval_date',
6c2b97b7 769 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 770 'title' => ts('Mailing Approved Date'),
215b423e 771 'description' => ts('Date and time this mailing was approved.'),
c3fc2621 772 'required' => FALSE,
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 'approval_status_id' => [
e501603b
TO
784 'name' => 'approval_status_id',
785 'type' => CRM_Utils_Type::T_INT,
c3fc2621 786 'title' => ts('Approval Status'),
215b423e 787 'description' => ts('The status of this mailing. Values: none, approved, rejected'),
522a26c9 788 'table_name' => 'civicrm_mailing',
789 'entity' => 'Mailing',
790 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 791 'localizable' => 0,
c3fc2621 792 'html' => [
e501603b 793 'type' => 'Select',
c3fc2621
CW
794 ],
795 'pseudoconstant' => [
e501603b
TO
796 'optionGroupName' => 'mail_approval_status',
797 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
c3fc2621
CW
798 ]
799 ],
800 'approval_note' => [
e501603b
TO
801 'name' => 'approval_note',
802 'type' => CRM_Utils_Type::T_LONGTEXT,
c3fc2621 803 'title' => ts('Approval Note'),
215b423e 804 'description' => ts('Note behind the decision.'),
522a26c9 805 'table_name' => 'civicrm_mailing',
806 'entity' => 'Mailing',
807 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 808 'localizable' => 0,
c3fc2621 809 'html' => [
e501603b 810 'type' => 'TextArea',
c3fc2621
CW
811 ],
812 ],
813 'is_archived' => [
e501603b
TO
814 'name' => 'is_archived',
815 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 816 'title' => ts('Is Mailing Archived?'),
215b423e 817 'description' => ts('Is this mailing archived?'),
45a83e42 818 'default' => '0',
522a26c9 819 'table_name' => 'civicrm_mailing',
820 'entity' => 'Mailing',
821 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 822 'localizable' => 0,
c3fc2621 823 'html' => [
e501603b 824 'type' => 'CheckBox',
c3fc2621
CW
825 ],
826 ],
827 'visibility' => [
e501603b
TO
828 'name' => 'visibility',
829 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 830 'title' => ts('Mailing Visibility'),
215b423e 831 'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
e501603b
TO
832 'maxlength' => 40,
833 'size' => CRM_Utils_Type::BIG,
834 'default' => 'Public Pages',
522a26c9 835 'table_name' => 'civicrm_mailing',
836 'entity' => 'Mailing',
837 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 838 'localizable' => 0,
c3fc2621 839 'html' => [
e501603b 840 'type' => 'Select',
c3fc2621
CW
841 ],
842 'pseudoconstant' => [
e501603b 843 'callback' => 'CRM_Core_SelectValues::groupVisibility',
c3fc2621
CW
844 ]
845 ],
846 'campaign_id' => [
e501603b
TO
847 'name' => 'campaign_id',
848 'type' => CRM_Utils_Type::T_INT,
c3fc2621 849 'title' => ts('Mailing Campaign'),
215b423e 850 'description' => ts('The campaign for which this mailing has been initiated.'),
522a26c9 851 'table_name' => 'civicrm_mailing',
852 'entity' => 'Mailing',
853 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 854 'localizable' => 0,
e501603b 855 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
c3fc2621 856 'html' => [
e501603b 857 'type' => 'Select',
c3fc2621
CW
858 ],
859 'pseudoconstant' => [
e501603b
TO
860 'table' => 'civicrm_campaign',
861 'keyColumn' => 'id',
862 'labelColumn' => 'title',
c3fc2621
CW
863 ]
864 ],
865 'dedupe_email' => [
e501603b
TO
866 'name' => 'dedupe_email',
867 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 868 'title' => ts('No Duplicate emails?'),
215b423e 869 'description' => ts('Remove duplicate emails?'),
45a83e42 870 'default' => '0',
522a26c9 871 'table_name' => 'civicrm_mailing',
872 'entity' => 'Mailing',
873 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 874 'localizable' => 0,
c3fc2621 875 'html' => [
e501603b 876 'type' => 'CheckBox',
c3fc2621
CW
877 ],
878 ],
879 'sms_provider_id' => [
e501603b
TO
880 'name' => 'sms_provider_id',
881 'type' => CRM_Utils_Type::T_INT,
c3fc2621 882 'title' => ts('Mailing SMS Provider'),
522a26c9 883 'table_name' => 'civicrm_mailing',
884 'entity' => 'Mailing',
885 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 886 'localizable' => 0,
e501603b 887 'FKClassName' => 'CRM_SMS_DAO_Provider',
c3fc2621 888 'html' => [
e501603b 889 'type' => 'Select',
c3fc2621
CW
890 ],
891 ],
892 'hash' => [
e501603b
TO
893 'name' => 'hash',
894 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 895 'title' => ts('Mailing Hash'),
215b423e 896 'description' => ts('Key for validating requests related to this mailing.'),
e501603b
TO
897 'maxlength' => 16,
898 'size' => CRM_Utils_Type::TWELVE,
522a26c9 899 'table_name' => 'civicrm_mailing',
900 'entity' => 'Mailing',
901 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 902 'localizable' => 0,
c3fc2621
CW
903 ],
904 'location_type_id' => [
e501603b
TO
905 'name' => 'location_type_id',
906 'type' => CRM_Utils_Type::T_INT,
c3fc2621 907 'title' => ts('Location Type'),
215b423e 908 'description' => ts('With email_selection_method, determines which email address to use'),
522a26c9 909 'table_name' => 'civicrm_mailing',
910 'entity' => 'Mailing',
911 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 912 'localizable' => 0,
e501603b 913 'FKClassName' => 'CRM_Core_DAO_LocationType',
c3fc2621 914 'pseudoconstant' => [
e501603b
TO
915 'table' => 'civicrm_location_type',
916 'keyColumn' => 'id',
917 'labelColumn' => 'display_name',
c3fc2621
CW
918 ]
919 ],
920 'email_selection_method' => [
e501603b
TO
921 'name' => 'email_selection_method',
922 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 923 'title' => ts('Email Selection Method'),
215b423e 924 'description' => ts('With location_type_id, determine how to choose the email address to use.'),
e501603b
TO
925 'maxlength' => 20,
926 'size' => CRM_Utils_Type::MEDIUM,
927 'default' => 'automatic',
522a26c9 928 'table_name' => 'civicrm_mailing',
929 'entity' => 'Mailing',
930 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 931 'localizable' => 0,
c3fc2621 932 'pseudoconstant' => [
e501603b 933 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
c3fc2621
CW
934 ]
935 ],
936 'language' => [
10d3f7d3
SV
937 'name' => 'language',
938 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 939 'title' => ts('Mailing Language'),
215b423e 940 'description' => ts('Language of the content of the mailing. Useful for tokens.'),
10d3f7d3
SV
941 'maxlength' => 5,
942 'size' => CRM_Utils_Type::SIX,
522a26c9 943 'table_name' => 'civicrm_mailing',
944 'entity' => 'Mailing',
945 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 946 'localizable' => 0,
c3fc2621 947 'html' => [
10d3f7d3 948 'type' => 'Select',
c3fc2621
CW
949 ],
950 'pseudoconstant' => [
10d3f7d3
SV
951 'optionGroupName' => 'languages',
952 'keyColumn' => 'name',
953 'optionEditPath' => 'civicrm/admin/options/languages',
c3fc2621
CW
954 ]
955 ],
956 ];
346aaaba 957 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 958 }
346aaaba 959 return Civi::$statics[__CLASS__]['fields'];
e501603b 960 }
c3fc2621 961
e501603b 962 /**
bd8e0b14 963 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
964 *
965 * @return array
bd8e0b14 966 * Array(string $name => string $uniqueName).
e501603b 967 */
c3fc2621 968 public static function &fieldKeys() {
bd8e0b14
TO
969 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
970 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 971 }
bd8e0b14 972 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 973 }
c3fc2621 974
e501603b
TO
975 /**
976 * Returns the names of this table
977 *
978 * @return string
979 */
c3fc2621 980 public static function getTableName() {
e501603b
TO
981 return self::$_tableName;
982 }
c3fc2621 983
e501603b
TO
984 /**
985 * Returns if this table needs to be logged
986 *
c3fc2621 987 * @return bool
e501603b 988 */
c3fc2621 989 public function getLog() {
e501603b
TO
990 return self::$_log;
991 }
c3fc2621 992
e501603b
TO
993 /**
994 * Returns the list of fields that can be imported
995 *
996 * @param bool $prefix
997 *
998 * @return array
999 */
c3fc2621
CW
1000 public static function &import($prefix = FALSE) {
1001 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, []);
60808919 1002 return $r;
e501603b 1003 }
c3fc2621 1004
e501603b
TO
1005 /**
1006 * Returns the list of fields that can be exported
1007 *
1008 * @param bool $prefix
1009 *
1010 * @return array
1011 */
c3fc2621
CW
1012 public static function &export($prefix = FALSE) {
1013 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, []);
60808919 1014 return $r;
e501603b 1015 }
c3fc2621 1016
e7a6b91a
AS
1017 /**
1018 * Returns the list of indices
c3fc2621
CW
1019 *
1020 * @param bool $localize
1021 *
1022 * @return array
e7a6b91a
AS
1023 */
1024 public static function indices($localize = TRUE) {
c3fc2621
CW
1025 $indices = [
1026 'index_hash' => [
e7a6b91a 1027 'name' => 'index_hash',
c3fc2621 1028 'field' => [
e7a6b91a 1029 0 => 'hash',
c3fc2621
CW
1030 ],
1031 'localizable' => FALSE,
e7a6b91a 1032 'sig' => 'civicrm_mailing::0::hash',
c3fc2621
CW
1033 ],
1034 ];
e7a6b91a
AS
1035 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1036 }
c3fc2621 1037
e501603b 1038}