CRM-20892 Convert Created_date to default NULL and add in trigger to set it
[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
e7a6eae8 33 * (GenCodeChecksum:3e332257744be5cf9d7a2545f69f67eb)
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;
e7a6eae8
SL
213 /**
214 * When the mailing (or closely related entity) was created or modified or deleted.
215 *
216 * @var timestamp
217 */
218 public $modified_date;
e501603b
TO
219 /**
220 * FK to Contact ID who scheduled this mailing
221 *
222 * @var int unsigned
223 */
224 public $scheduled_id;
225 /**
226 * Date and time this mailing was scheduled.
227 *
6c2b97b7 228 * @var timestamp
e501603b
TO
229 */
230 public $scheduled_date;
231 /**
232 * FK to Contact ID who approved this mailing
233 *
234 * @var int unsigned
235 */
236 public $approver_id;
237 /**
238 * Date and time this mailing was approved.
239 *
6c2b97b7 240 * @var timestamp
e501603b
TO
241 */
242 public $approval_date;
243 /**
244 * The status of this mailing. Values: none, approved, rejected
245 *
246 * @var int unsigned
247 */
248 public $approval_status_id;
249 /**
250 * Note behind the decision.
251 *
252 * @var longtext
253 */
254 public $approval_note;
255 /**
256 * Is this mailing archived?
257 *
258 * @var boolean
259 */
260 public $is_archived;
261 /**
262 * In what context(s) is the mailing contents visible (online viewing)
263 *
264 * @var string
265 */
266 public $visibility;
267 /**
268 * The campaign for which this mailing has been initiated.
269 *
270 * @var int unsigned
271 */
272 public $campaign_id;
273 /**
274 * Remove duplicate emails?
275 *
276 * @var boolean
277 */
278 public $dedupe_email;
279 /**
280 *
281 * @var int unsigned
282 */
283 public $sms_provider_id;
284 /**
285 * Key for validating requests related to this mailing.
286 *
287 * @var string
288 */
289 public $hash;
290 /**
291 * With email_selection_method, determines which email address to use
292 *
293 * @var int unsigned
294 */
295 public $location_type_id;
296 /**
297 * With location_type_id, determine how to choose the email address to use.
298 *
299 * @var string
300 */
301 public $email_selection_method;
10d3f7d3
SV
302 /**
303 * Language of the content of the mailing. Useful for tokens.
304 *
305 * @var string
306 */
307 public $language;
e501603b 308 /**
f41f0342 309 * Class constructor.
e501603b
TO
310 */
311 function __construct() {
312 $this->__table = 'civicrm_mailing';
313 parent::__construct();
314 }
315 /**
f41f0342 316 * Returns foreign keys and entity references.
e501603b
TO
317 *
318 * @return array
319 * [CRM_Core_Reference_Interface]
320 */
321 static function getReferenceColumns() {
346aaaba
TO
322 if (!isset(Civi::$statics[__CLASS__]['links'])) {
323 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
324 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'domain_id', 'civicrm_domain', 'id');
325 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'header_id', 'civicrm_mailing_component', 'id');
326 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'footer_id', 'civicrm_mailing_component', 'id');
327 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'reply_id', 'civicrm_mailing_component', 'id');
328 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'unsubscribe_id', 'civicrm_mailing_component', 'id');
329 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'optout_id', 'civicrm_mailing_component', 'id');
330 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'msg_template_id', 'civicrm_msg_template', 'id');
331 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
332 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'scheduled_id', 'civicrm_contact', 'id');
333 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'approver_id', 'civicrm_contact', 'id');
334 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
335 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'sms_provider_id', 'civicrm_sms_provider', 'id');
336 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'location_type_id', 'civicrm_location_type', 'id');
337 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 338 }
346aaaba 339 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
340 }
341 /**
342 * Returns all the column names of this table
343 *
344 * @return array
345 */
346 static function &fields() {
346aaaba
TO
347 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
348 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
349 'id' => array(
350 'name' => 'id',
351 'type' => CRM_Utils_Type::T_INT,
352 'title' => ts('Mailing ID') ,
353 'required' => true,
522a26c9 354 'table_name' => 'civicrm_mailing',
355 'entity' => 'Mailing',
356 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 357 'localizable' => 0,
e501603b
TO
358 ) ,
359 'domain_id' => array(
360 'name' => 'domain_id',
361 'type' => CRM_Utils_Type::T_INT,
362 'title' => ts('Mailing Domain') ,
363 'description' => 'Which site is this mailing for',
522a26c9 364 'table_name' => 'civicrm_mailing',
365 'entity' => 'Mailing',
366 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 367 'localizable' => 0,
e501603b
TO
368 'FKClassName' => 'CRM_Core_DAO_Domain',
369 'pseudoconstant' => array(
370 'table' => 'civicrm_domain',
371 'keyColumn' => 'id',
372 'labelColumn' => 'name',
373 )
374 ) ,
375 'header_id' => array(
376 'name' => 'header_id',
377 'type' => CRM_Utils_Type::T_INT,
378 'title' => ts('Mailing Header') ,
379 'description' => 'FK to the header component.',
522a26c9 380 'table_name' => 'civicrm_mailing',
381 'entity' => 'Mailing',
382 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 383 'localizable' => 0,
e501603b
TO
384 'FKClassName' => 'CRM_Mailing_DAO_Component',
385 ) ,
386 'footer_id' => array(
387 'name' => 'footer_id',
388 'type' => CRM_Utils_Type::T_INT,
389 'title' => ts('Mailing Footer') ,
390 'description' => 'FK to the footer component.',
522a26c9 391 'table_name' => 'civicrm_mailing',
392 'entity' => 'Mailing',
393 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 394 'localizable' => 0,
e501603b
TO
395 'FKClassName' => 'CRM_Mailing_DAO_Component',
396 ) ,
397 'reply_id' => array(
398 'name' => 'reply_id',
399 'type' => CRM_Utils_Type::T_INT,
400 'title' => ts('Mailing Reply') ,
401 'description' => 'FK to the auto-responder component.',
522a26c9 402 'table_name' => 'civicrm_mailing',
403 'entity' => 'Mailing',
404 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 405 'localizable' => 0,
e501603b
TO
406 'FKClassName' => 'CRM_Mailing_DAO_Component',
407 ) ,
408 'unsubscribe_id' => array(
409 'name' => 'unsubscribe_id',
410 'type' => CRM_Utils_Type::T_INT,
411 'title' => ts('Mailing Unsubscribe') ,
412 'description' => 'FK to the unsubscribe component.',
522a26c9 413 'table_name' => 'civicrm_mailing',
414 'entity' => 'Mailing',
415 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 416 'localizable' => 0,
e501603b
TO
417 'FKClassName' => 'CRM_Mailing_DAO_Component',
418 ) ,
419 'resubscribe_id' => array(
420 'name' => 'resubscribe_id',
421 'type' => CRM_Utils_Type::T_INT,
422 'title' => ts('Mailing Resubscribe') ,
522a26c9 423 'table_name' => 'civicrm_mailing',
424 'entity' => 'Mailing',
425 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 426 'localizable' => 0,
e501603b
TO
427 ) ,
428 'optout_id' => array(
429 'name' => 'optout_id',
430 'type' => CRM_Utils_Type::T_INT,
431 'title' => ts('Mailing Opt Out') ,
432 'description' => 'FK to the opt-out component.',
522a26c9 433 'table_name' => 'civicrm_mailing',
434 'entity' => 'Mailing',
435 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 436 'localizable' => 0,
e501603b
TO
437 'FKClassName' => 'CRM_Mailing_DAO_Component',
438 ) ,
439 'name' => array(
440 'name' => 'name',
441 'type' => CRM_Utils_Type::T_STRING,
442 'title' => ts('Mailing Name') ,
443 'description' => 'Mailing Name.',
444 'maxlength' => 128,
445 'size' => CRM_Utils_Type::HUGE,
522a26c9 446 'table_name' => 'civicrm_mailing',
447 'entity' => 'Mailing',
448 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 449 'localizable' => 0,
e501603b
TO
450 'html' => array(
451 'type' => 'Text',
452 ) ,
453 ) ,
454 'mailing_type' => array(
455 'name' => 'mailing_type',
456 'type' => CRM_Utils_Type::T_STRING,
457 'title' => ts('Mailing Type') ,
458 'description' => 'differentiate between standalone mailings, A/B tests, and A/B final-winner',
459 'maxlength' => 32,
460 'size' => CRM_Utils_Type::MEDIUM,
522a26c9 461 'table_name' => 'civicrm_mailing',
462 'entity' => 'Mailing',
463 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 464 'localizable' => 0,
e501603b
TO
465 'html' => array(
466 'type' => 'Select',
467 ) ,
468 'pseudoconstant' => array(
469 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
470 )
471 ) ,
472 'from_name' => array(
473 'name' => 'from_name',
474 'type' => CRM_Utils_Type::T_STRING,
475 'title' => ts('Mailing From Name') ,
476 'description' => 'From Header of mailing',
477 'maxlength' => 128,
478 'size' => CRM_Utils_Type::HUGE,
522a26c9 479 'table_name' => 'civicrm_mailing',
480 'entity' => 'Mailing',
481 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 482 'localizable' => 0,
e501603b
TO
483 'html' => array(
484 'type' => 'Text',
485 ) ,
486 ) ,
487 'from_email' => array(
488 'name' => 'from_email',
489 'type' => CRM_Utils_Type::T_STRING,
490 'title' => ts('Mailing From Email') ,
491 'description' => 'From Email of mailing',
492 'maxlength' => 128,
493 'size' => CRM_Utils_Type::HUGE,
522a26c9 494 'table_name' => 'civicrm_mailing',
495 'entity' => 'Mailing',
496 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 497 'localizable' => 0,
e501603b
TO
498 'html' => array(
499 'type' => 'Text',
500 ) ,
501 ) ,
502 'replyto_email' => array(
503 'name' => 'replyto_email',
504 'type' => CRM_Utils_Type::T_STRING,
505 'title' => ts('Replyto Email') ,
506 'description' => 'Reply-To Email of mailing',
507 'maxlength' => 128,
508 'size' => CRM_Utils_Type::HUGE,
522a26c9 509 'table_name' => 'civicrm_mailing',
510 'entity' => 'Mailing',
511 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 512 'localizable' => 0,
e501603b
TO
513 'html' => array(
514 'type' => 'Text',
515 ) ,
516 ) ,
703875d8
TO
517 'template_type' => array(
518 'name' => 'template_type',
519 'type' => CRM_Utils_Type::T_STRING,
520 'title' => ts('Template Type') ,
521 'description' => 'The language/processing system used for email templates.',
522 'required' => true,
523 'maxlength' => 64,
524 'size' => CRM_Utils_Type::BIG,
525 'default' => 'traditional',
522a26c9 526 'table_name' => 'civicrm_mailing',
527 'entity' => 'Mailing',
528 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 529 'localizable' => 0,
703875d8
TO
530 'pseudoconstant' => array(
531 'callback' => 'CRM_Mailing_BAO_Mailing::getTemplateTypeNames',
532 )
533 ) ,
534 'template_options' => array(
535 'name' => 'template_options',
536 'type' => CRM_Utils_Type::T_LONGTEXT,
537 'title' => ts('Template Options (JSON)') ,
538 'description' => 'Advanced options used by the email templating system. (JSON encoded)',
522a26c9 539 'table_name' => 'civicrm_mailing',
540 'entity' => 'Mailing',
541 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 542 'localizable' => 0,
703875d8 543 ) ,
e501603b
TO
544 'subject' => array(
545 'name' => 'subject',
546 'type' => CRM_Utils_Type::T_STRING,
547 'title' => ts('Subject') ,
548 'description' => 'Subject of mailing',
549 'maxlength' => 128,
550 'size' => CRM_Utils_Type::HUGE,
522a26c9 551 'table_name' => 'civicrm_mailing',
552 'entity' => 'Mailing',
553 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 554 'localizable' => 0,
e501603b
TO
555 'html' => array(
556 'type' => 'Text',
557 ) ,
558 ) ,
559 'body_text' => array(
560 'name' => 'body_text',
561 'type' => CRM_Utils_Type::T_LONGTEXT,
562 'title' => ts('Body Text') ,
563 'description' => 'Body of the mailing in text format.',
522a26c9 564 'table_name' => 'civicrm_mailing',
565 'entity' => 'Mailing',
566 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 567 'localizable' => 0,
e501603b
TO
568 ) ,
569 'body_html' => array(
570 'name' => 'body_html',
571 'type' => CRM_Utils_Type::T_LONGTEXT,
572 'title' => ts('Body Html') ,
573 'description' => 'Body of the mailing in html format.',
522a26c9 574 'table_name' => 'civicrm_mailing',
575 'entity' => 'Mailing',
576 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 577 'localizable' => 0,
e501603b
TO
578 ) ,
579 'url_tracking' => array(
580 'name' => 'url_tracking',
581 'type' => CRM_Utils_Type::T_BOOLEAN,
582 'title' => ts('Url Tracking') ,
583 'description' => 'Should we track URL click-throughs for this mailing?',
522a26c9 584 'table_name' => 'civicrm_mailing',
585 'entity' => 'Mailing',
586 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 587 'localizable' => 0,
e501603b
TO
588 'html' => array(
589 'type' => 'CheckBox',
590 ) ,
591 ) ,
592 'forward_replies' => array(
593 'name' => 'forward_replies',
594 'type' => CRM_Utils_Type::T_BOOLEAN,
595 'title' => ts('Forward Replies') ,
596 'description' => 'Should we forward replies back to the author?',
522a26c9 597 'table_name' => 'civicrm_mailing',
598 'entity' => 'Mailing',
599 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 600 'localizable' => 0,
e501603b
TO
601 'html' => array(
602 'type' => 'CheckBox',
603 ) ,
604 ) ,
605 'auto_responder' => array(
606 'name' => 'auto_responder',
607 'type' => CRM_Utils_Type::T_BOOLEAN,
608 'title' => ts('Auto Responder') ,
609 'description' => 'Should we enable the auto-responder?',
522a26c9 610 'table_name' => 'civicrm_mailing',
611 'entity' => 'Mailing',
612 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 613 'localizable' => 0,
e501603b
TO
614 'html' => array(
615 'type' => 'CheckBox',
616 ) ,
617 ) ,
618 'open_tracking' => array(
619 'name' => 'open_tracking',
620 'type' => CRM_Utils_Type::T_BOOLEAN,
621 'title' => ts('Track Mailing?') ,
622 'description' => 'Should we track when recipients open/read this mailing?',
522a26c9 623 'table_name' => 'civicrm_mailing',
624 'entity' => 'Mailing',
625 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 626 'localizable' => 0,
e501603b
TO
627 ) ,
628 'is_completed' => array(
629 'name' => 'is_completed',
630 'type' => CRM_Utils_Type::T_BOOLEAN,
631 'title' => ts('Mailing Completed') ,
632 'description' => 'Has at least one job associated with this mailing finished?',
522a26c9 633 'table_name' => 'civicrm_mailing',
634 'entity' => 'Mailing',
635 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 636 'localizable' => 0,
e501603b
TO
637 'html' => array(
638 'type' => 'CheckBox',
639 ) ,
640 ) ,
641 'msg_template_id' => array(
642 'name' => 'msg_template_id',
643 'type' => CRM_Utils_Type::T_INT,
644 'title' => ts('Mailing Message Template') ,
645 'description' => 'FK to the message template.',
522a26c9 646 'table_name' => 'civicrm_mailing',
647 'entity' => 'Mailing',
648 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 649 'localizable' => 0,
e501603b
TO
650 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
651 ) ,
652 'override_verp' => array(
653 'name' => 'override_verp',
654 'type' => CRM_Utils_Type::T_BOOLEAN,
655 'title' => ts('Override Verp') ,
656 'description' => 'Should we overrite VERP address in Reply-To',
522a26c9 657 'table_name' => 'civicrm_mailing',
658 'entity' => 'Mailing',
659 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 660 'localizable' => 0,
e501603b
TO
661 'html' => array(
662 'type' => 'CheckBox',
663 ) ,
664 ) ,
665 'created_id' => array(
666 'name' => 'created_id',
667 'type' => CRM_Utils_Type::T_INT,
668 'title' => ts('Mailing Creator') ,
669 'description' => 'FK to Contact ID who first created this mailing',
522a26c9 670 'table_name' => 'civicrm_mailing',
671 'entity' => 'Mailing',
672 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 673 'localizable' => 0,
e501603b
TO
674 'FKClassName' => 'CRM_Contact_DAO_Contact',
675 ) ,
676 'created_date' => array(
677 'name' => 'created_date',
6c2b97b7 678 'type' => CRM_Utils_Type::T_TIMESTAMP,
e501603b
TO
679 'title' => ts('Mailing Created Date') ,
680 'description' => 'Date and time this mailing was created.',
6c2b97b7 681 'required' => false,
e7a6eae8 682 'default' => 'NULL',
522a26c9 683 'table_name' => 'civicrm_mailing',
684 'entity' => 'Mailing',
685 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 686 'localizable' => 0,
e501603b
TO
687 'html' => array(
688 'type' => 'Select Date',
6c2b97b7 689 'formatType' => 'activityDateTime',
e501603b
TO
690 ) ,
691 ) ,
e7a6eae8
SL
692 'mailing_modified_date' => array(
693 'name' => 'modified_date',
694 'type' => CRM_Utils_Type::T_TIMESTAMP,
695 'title' => ts('Modified Date') ,
696 'description' => 'When the mailing (or closely related entity) was created or modified or deleted.',
697 'required' => false,
698 'export' => true,
699 'where' => 'civicrm_mailing.modified_date',
700 'headerPattern' => '',
701 'dataPattern' => '',
702 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
703 'table_name' => 'civicrm_mailing',
704 'entity' => 'Mailing',
705 'bao' => 'CRM_Mailing_BAO_Mailing',
706 'localizable' => 0,
707 ) ,
e501603b
TO
708 'scheduled_id' => array(
709 'name' => 'scheduled_id',
710 'type' => CRM_Utils_Type::T_INT,
711 'title' => ts('Scheduled By') ,
712 'description' => 'FK to Contact ID who scheduled this mailing',
522a26c9 713 'table_name' => 'civicrm_mailing',
714 'entity' => 'Mailing',
715 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 716 'localizable' => 0,
e501603b
TO
717 'FKClassName' => 'CRM_Contact_DAO_Contact',
718 ) ,
719 'scheduled_date' => array(
720 'name' => 'scheduled_date',
6c2b97b7 721 'type' => CRM_Utils_Type::T_TIMESTAMP,
e501603b
TO
722 'title' => ts('Mailing Scheduled Date') ,
723 'description' => 'Date and time this mailing was scheduled.',
6c2b97b7 724 'required' => false,
725 'default' => 'NULL',
522a26c9 726 'table_name' => 'civicrm_mailing',
727 'entity' => 'Mailing',
728 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 729 'localizable' => 0,
6c2b97b7 730 'html' => array(
731 'type' => 'Select Date',
732 'formatType' => 'activityDateTime',
733 ) ,
e501603b
TO
734 ) ,
735 'approver_id' => array(
736 'name' => 'approver_id',
737 'type' => CRM_Utils_Type::T_INT,
738 'title' => ts('Approved By') ,
739 'description' => 'FK to Contact ID who approved this mailing',
522a26c9 740 'table_name' => 'civicrm_mailing',
741 'entity' => 'Mailing',
742 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 743 'localizable' => 0,
e501603b
TO
744 'FKClassName' => 'CRM_Contact_DAO_Contact',
745 ) ,
746 'approval_date' => array(
747 'name' => 'approval_date',
6c2b97b7 748 'type' => CRM_Utils_Type::T_TIMESTAMP,
e501603b
TO
749 'title' => ts('Mailing Approved Date') ,
750 'description' => 'Date and time this mailing was approved.',
6c2b97b7 751 'required' => false,
752 'default' => 'NULL',
522a26c9 753 'table_name' => 'civicrm_mailing',
754 'entity' => 'Mailing',
755 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 756 'localizable' => 0,
6c2b97b7 757 'html' => array(
758 'type' => 'Select Date',
759 'formatType' => 'activityDateTime',
760 ) ,
e501603b
TO
761 ) ,
762 'approval_status_id' => array(
763 'name' => 'approval_status_id',
764 'type' => CRM_Utils_Type::T_INT,
765 'title' => ts('Approval Status') ,
766 'description' => 'The status of this mailing. Values: none, approved, rejected',
522a26c9 767 'table_name' => 'civicrm_mailing',
768 'entity' => 'Mailing',
769 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 770 'localizable' => 0,
e501603b
TO
771 'html' => array(
772 'type' => 'Select',
773 ) ,
774 'pseudoconstant' => array(
775 'optionGroupName' => 'mail_approval_status',
776 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
777 )
778 ) ,
779 'approval_note' => array(
780 'name' => 'approval_note',
781 'type' => CRM_Utils_Type::T_LONGTEXT,
782 'title' => ts('Approval Note') ,
783 'description' => 'Note behind the decision.',
522a26c9 784 'table_name' => 'civicrm_mailing',
785 'entity' => 'Mailing',
786 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 787 'localizable' => 0,
e501603b
TO
788 'html' => array(
789 'type' => 'TextArea',
790 ) ,
791 ) ,
792 'is_archived' => array(
793 'name' => 'is_archived',
794 'type' => CRM_Utils_Type::T_BOOLEAN,
795 'title' => ts('Is Mailing Archived?') ,
796 'description' => 'Is this mailing archived?',
522a26c9 797 'table_name' => 'civicrm_mailing',
798 'entity' => 'Mailing',
799 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 800 'localizable' => 0,
e501603b
TO
801 'html' => array(
802 'type' => 'CheckBox',
803 ) ,
804 ) ,
805 'visibility' => array(
806 'name' => 'visibility',
807 'type' => CRM_Utils_Type::T_STRING,
808 'title' => ts('Mailing Visibility') ,
809 'description' => 'In what context(s) is the mailing contents visible (online viewing)',
810 'maxlength' => 40,
811 'size' => CRM_Utils_Type::BIG,
812 'default' => 'Public Pages',
522a26c9 813 'table_name' => 'civicrm_mailing',
814 'entity' => 'Mailing',
815 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 816 'localizable' => 0,
e501603b
TO
817 'html' => array(
818 'type' => 'Select',
819 ) ,
820 'pseudoconstant' => array(
821 'callback' => 'CRM_Core_SelectValues::groupVisibility',
822 )
823 ) ,
824 'campaign_id' => array(
825 'name' => 'campaign_id',
826 'type' => CRM_Utils_Type::T_INT,
827 'title' => ts('Mailing Campaign') ,
828 'description' => 'The campaign for which this mailing has been initiated.',
522a26c9 829 'table_name' => 'civicrm_mailing',
830 'entity' => 'Mailing',
831 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 832 'localizable' => 0,
e501603b
TO
833 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
834 'html' => array(
835 'type' => 'Select',
836 ) ,
837 'pseudoconstant' => array(
838 'table' => 'civicrm_campaign',
839 'keyColumn' => 'id',
840 'labelColumn' => 'title',
841 )
842 ) ,
843 'dedupe_email' => array(
844 'name' => 'dedupe_email',
845 'type' => CRM_Utils_Type::T_BOOLEAN,
846 'title' => ts('No Duplicate emails?') ,
847 'description' => 'Remove duplicate emails?',
522a26c9 848 'table_name' => 'civicrm_mailing',
849 'entity' => 'Mailing',
850 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 851 'localizable' => 0,
e501603b
TO
852 'html' => array(
853 'type' => 'CheckBox',
854 ) ,
855 ) ,
856 'sms_provider_id' => array(
857 'name' => 'sms_provider_id',
858 'type' => CRM_Utils_Type::T_INT,
859 'title' => ts('Mailing SMS Provider') ,
522a26c9 860 'table_name' => 'civicrm_mailing',
861 'entity' => 'Mailing',
862 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 863 'localizable' => 0,
e501603b
TO
864 'FKClassName' => 'CRM_SMS_DAO_Provider',
865 'html' => array(
866 'type' => 'Select',
867 ) ,
868 ) ,
869 'hash' => array(
870 'name' => 'hash',
871 'type' => CRM_Utils_Type::T_STRING,
872 'title' => ts('Mailing Hash') ,
873 'description' => 'Key for validating requests related to this mailing.',
874 'maxlength' => 16,
875 'size' => CRM_Utils_Type::TWELVE,
522a26c9 876 'table_name' => 'civicrm_mailing',
877 'entity' => 'Mailing',
878 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 879 'localizable' => 0,
e501603b
TO
880 ) ,
881 'location_type_id' => array(
882 'name' => 'location_type_id',
883 'type' => CRM_Utils_Type::T_INT,
884 'title' => ts('Location Type') ,
885 'description' => 'With email_selection_method, determines which email address to use',
522a26c9 886 'table_name' => 'civicrm_mailing',
887 'entity' => 'Mailing',
888 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 889 'localizable' => 0,
e501603b
TO
890 'FKClassName' => 'CRM_Core_DAO_LocationType',
891 'pseudoconstant' => array(
892 'table' => 'civicrm_location_type',
893 'keyColumn' => 'id',
894 'labelColumn' => 'display_name',
895 )
896 ) ,
897 'email_selection_method' => array(
898 'name' => 'email_selection_method',
899 'type' => CRM_Utils_Type::T_STRING,
900 'title' => ts('Email Selection Method') ,
901 'description' => 'With location_type_id, determine how to choose the email address to use.',
902 'maxlength' => 20,
903 'size' => CRM_Utils_Type::MEDIUM,
904 'default' => 'automatic',
522a26c9 905 'table_name' => 'civicrm_mailing',
906 'entity' => 'Mailing',
907 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 908 'localizable' => 0,
e501603b
TO
909 'pseudoconstant' => array(
910 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
911 )
912 ) ,
10d3f7d3
SV
913 'language' => array(
914 'name' => 'language',
915 'type' => CRM_Utils_Type::T_STRING,
916 'title' => ts('Mailing Language') ,
917 'description' => 'Language of the content of the mailing. Useful for tokens.',
918 'maxlength' => 5,
919 'size' => CRM_Utils_Type::SIX,
522a26c9 920 'table_name' => 'civicrm_mailing',
921 'entity' => 'Mailing',
922 'bao' => 'CRM_Mailing_BAO_Mailing',
6a7e5e5d 923 'localizable' => 0,
10d3f7d3
SV
924 'html' => array(
925 'type' => 'Select',
926 ) ,
927 'pseudoconstant' => array(
928 'optionGroupName' => 'languages',
929 'keyColumn' => 'name',
930 'optionEditPath' => 'civicrm/admin/options/languages',
931 )
932 ) ,
e501603b 933 );
346aaaba 934 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 935 }
346aaaba 936 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
937 }
938 /**
bd8e0b14 939 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
940 *
941 * @return array
bd8e0b14 942 * Array(string $name => string $uniqueName).
e501603b
TO
943 */
944 static function &fieldKeys() {
bd8e0b14
TO
945 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
946 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 947 }
bd8e0b14 948 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
949 }
950 /**
951 * Returns the names of this table
952 *
953 * @return string
954 */
955 static function getTableName() {
956 return self::$_tableName;
957 }
958 /**
959 * Returns if this table needs to be logged
960 *
961 * @return boolean
962 */
963 function getLog() {
964 return self::$_log;
965 }
966 /**
967 * Returns the list of fields that can be imported
968 *
969 * @param bool $prefix
970 *
971 * @return array
972 */
973 static function &import($prefix = false) {
60808919
TO
974 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, array());
975 return $r;
e501603b
TO
976 }
977 /**
978 * Returns the list of fields that can be exported
979 *
980 * @param bool $prefix
981 *
982 * @return array
983 */
984 static function &export($prefix = false) {
60808919
TO
985 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, array());
986 return $r;
e501603b 987 }
e7a6b91a
AS
988 /**
989 * Returns the list of indices
990 */
991 public static function indices($localize = TRUE) {
992 $indices = array(
993 'index_hash' => array(
994 'name' => 'index_hash',
995 'field' => array(
996 0 => 'hash',
997 ) ,
998 'localizable' => false,
999 'sig' => 'civicrm_mailing::0::hash',
1000 ) ,
1001 );
1002 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
1003 }
e501603b 1004}