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