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