CRM-19130 - xml/templates/dao.tpl - Fire events for fields() and links()
[civicrm-core.git] / CRM / Mailing / DAO / Mailing.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Mailing/Mailing.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:5a9a6f1b3a07e96bd988ce1259736a3a)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_mailing';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the FK relationships
52 *
53 * @var string
54 */
55 static $_links = null;
56 /**
57 * static value to see if we should log any modifications to
58 * this table in the civicrm_log table
59 *
60 * @var boolean
61 */
62 static $_log = false;
63 /**
64 *
65 * @var int unsigned
66 */
67 public $id;
68 /**
69 * Which site is this mailing for
70 *
71 * @var int unsigned
72 */
73 public $domain_id;
74 /**
75 * FK to the header component.
76 *
77 * @var int unsigned
78 */
79 public $header_id;
80 /**
81 * FK to the footer component.
82 *
83 * @var int unsigned
84 */
85 public $footer_id;
86 /**
87 * FK to the auto-responder component.
88 *
89 * @var int unsigned
90 */
91 public $reply_id;
92 /**
93 * FK to the unsubscribe component.
94 *
95 * @var int unsigned
96 */
97 public $unsubscribe_id;
98 /**
99 *
100 * @var int unsigned
101 */
102 public $resubscribe_id;
103 /**
104 * FK to the opt-out component.
105 *
106 * @var int unsigned
107 */
108 public $optout_id;
109 /**
110 * Mailing Name.
111 *
112 * @var string
113 */
114 public $name;
115 /**
116 * differentiate between standalone mailings, A/B tests, and A/B final-winner
117 *
118 * @var string
119 */
120 public $mailing_type;
121 /**
122 * From Header of mailing
123 *
124 * @var string
125 */
126 public $from_name;
127 /**
128 * From Email of mailing
129 *
130 * @var string
131 */
132 public $from_email;
133 /**
134 * Reply-To Email of mailing
135 *
136 * @var string
137 */
138 public $replyto_email;
139 /**
140 * Subject of mailing
141 *
142 * @var string
143 */
144 public $subject;
145 /**
146 * Body of the mailing in text format.
147 *
148 * @var longtext
149 */
150 public $body_text;
151 /**
152 * Body of the mailing in html format.
153 *
154 * @var longtext
155 */
156 public $body_html;
157 /**
158 * Should we track URL click-throughs for this mailing?
159 *
160 * @var boolean
161 */
162 public $url_tracking;
163 /**
164 * Should we forward replies back to the author?
165 *
166 * @var boolean
167 */
168 public $forward_replies;
169 /**
170 * Should we enable the auto-responder?
171 *
172 * @var boolean
173 */
174 public $auto_responder;
175 /**
176 * Should we track when recipients open/read this mailing?
177 *
178 * @var boolean
179 */
180 public $open_tracking;
181 /**
182 * Has at least one job associated with this mailing finished?
183 *
184 * @var boolean
185 */
186 public $is_completed;
187 /**
188 * FK to the message template.
189 *
190 * @var int unsigned
191 */
192 public $msg_template_id;
193 /**
194 * Should we overrite VERP address in Reply-To
195 *
196 * @var boolean
197 */
198 public $override_verp;
199 /**
200 * FK to Contact ID who first created this mailing
201 *
202 * @var int unsigned
203 */
204 public $created_id;
205 /**
206 * Date and time this mailing was created.
207 *
208 * @var datetime
209 */
210 public $created_date;
211 /**
212 * FK to Contact ID who scheduled this mailing
213 *
214 * @var int unsigned
215 */
216 public $scheduled_id;
217 /**
218 * Date and time this mailing was scheduled.
219 *
220 * @var datetime
221 */
222 public $scheduled_date;
223 /**
224 * FK to Contact ID who approved this mailing
225 *
226 * @var int unsigned
227 */
228 public $approver_id;
229 /**
230 * Date and time this mailing was approved.
231 *
232 * @var datetime
233 */
234 public $approval_date;
235 /**
236 * The status of this mailing. Values: none, approved, rejected
237 *
238 * @var int unsigned
239 */
240 public $approval_status_id;
241 /**
242 * Note behind the decision.
243 *
244 * @var longtext
245 */
246 public $approval_note;
247 /**
248 * Is this mailing archived?
249 *
250 * @var boolean
251 */
252 public $is_archived;
253 /**
254 * In what context(s) is the mailing contents visible (online viewing)
255 *
256 * @var string
257 */
258 public $visibility;
259 /**
260 * The campaign for which this mailing has been initiated.
261 *
262 * @var int unsigned
263 */
264 public $campaign_id;
265 /**
266 * Remove duplicate emails?
267 *
268 * @var boolean
269 */
270 public $dedupe_email;
271 /**
272 *
273 * @var int unsigned
274 */
275 public $sms_provider_id;
276 /**
277 * Key for validating requests related to this mailing.
278 *
279 * @var string
280 */
281 public $hash;
282 /**
283 * With email_selection_method, determines which email address to use
284 *
285 * @var int unsigned
286 */
287 public $location_type_id;
288 /**
289 * With location_type_id, determine how to choose the email address to use.
290 *
291 * @var string
292 */
293 public $email_selection_method;
294 /**
295 * class constructor
296 *
297 * @return civicrm_mailing
298 */
299 function __construct() {
300 $this->__table = 'civicrm_mailing';
301 parent::__construct();
302 }
303 /**
304 * Returns foreign keys and entity references
305 *
306 * @return array
307 * [CRM_Core_Reference_Interface]
308 */
309 static function getReferenceColumns() {
310 if (!self::$_links) {
311 self::$_links = static ::createReferenceColumns(__CLASS__);
312 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'domain_id', 'civicrm_domain', 'id');
313 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'header_id', 'civicrm_mailing_component', 'id');
314 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'footer_id', 'civicrm_mailing_component', 'id');
315 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'reply_id', 'civicrm_mailing_component', 'id');
316 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'unsubscribe_id', 'civicrm_mailing_component', 'id');
317 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'optout_id', 'civicrm_mailing_component', 'id');
318 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'msg_template_id', 'civicrm_msg_template', 'id');
319 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
320 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'scheduled_id', 'civicrm_contact', 'id');
321 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'approver_id', 'civicrm_contact', 'id');
322 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'campaign_id', 'civicrm_campaign', 'id');
323 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'sms_provider_id', 'civicrm_sms_provider', 'id');
324 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'location_type_id', 'civicrm_location_type', 'id');
325 }
326 return self::$_links;
327 }
328 /**
329 * Returns all the column names of this table
330 *
331 * @return array
332 */
333 static function &fields() {
334 if (!(self::$_fields)) {
335 self::$_fields = array(
336 'id' => array(
337 'name' => 'id',
338 'type' => CRM_Utils_Type::T_INT,
339 'title' => ts('Mailing ID') ,
340 'required' => true,
341 ) ,
342 'domain_id' => array(
343 'name' => 'domain_id',
344 'type' => CRM_Utils_Type::T_INT,
345 'title' => ts('Mailing Domain') ,
346 'description' => 'Which site is this mailing for',
347 'FKClassName' => 'CRM_Core_DAO_Domain',
348 'pseudoconstant' => array(
349 'table' => 'civicrm_domain',
350 'keyColumn' => 'id',
351 'labelColumn' => 'name',
352 )
353 ) ,
354 'header_id' => array(
355 'name' => 'header_id',
356 'type' => CRM_Utils_Type::T_INT,
357 'title' => ts('Mailing Header') ,
358 'description' => 'FK to the header component.',
359 'FKClassName' => 'CRM_Mailing_DAO_Component',
360 ) ,
361 'footer_id' => array(
362 'name' => 'footer_id',
363 'type' => CRM_Utils_Type::T_INT,
364 'title' => ts('Mailing Footer') ,
365 'description' => 'FK to the footer component.',
366 'FKClassName' => 'CRM_Mailing_DAO_Component',
367 ) ,
368 'reply_id' => array(
369 'name' => 'reply_id',
370 'type' => CRM_Utils_Type::T_INT,
371 'title' => ts('Mailing Reply') ,
372 'description' => 'FK to the auto-responder component.',
373 'FKClassName' => 'CRM_Mailing_DAO_Component',
374 ) ,
375 'unsubscribe_id' => array(
376 'name' => 'unsubscribe_id',
377 'type' => CRM_Utils_Type::T_INT,
378 'title' => ts('Mailing Unsubscribe') ,
379 'description' => 'FK to the unsubscribe component.',
380 'FKClassName' => 'CRM_Mailing_DAO_Component',
381 ) ,
382 'resubscribe_id' => array(
383 'name' => 'resubscribe_id',
384 'type' => CRM_Utils_Type::T_INT,
385 'title' => ts('Mailing Resubscribe') ,
386 ) ,
387 'optout_id' => array(
388 'name' => 'optout_id',
389 'type' => CRM_Utils_Type::T_INT,
390 'title' => ts('Mailing Opt Out') ,
391 'description' => 'FK to the opt-out component.',
392 'FKClassName' => 'CRM_Mailing_DAO_Component',
393 ) ,
394 'name' => array(
395 'name' => 'name',
396 'type' => CRM_Utils_Type::T_STRING,
397 'title' => ts('Mailing Name') ,
398 'description' => 'Mailing Name.',
399 'maxlength' => 128,
400 'size' => CRM_Utils_Type::HUGE,
401 'html' => array(
402 'type' => 'Text',
403 ) ,
404 ) ,
405 'mailing_type' => array(
406 'name' => 'mailing_type',
407 'type' => CRM_Utils_Type::T_STRING,
408 'title' => ts('Mailing Type') ,
409 'description' => 'differentiate between standalone mailings, A/B tests, and A/B final-winner',
410 'maxlength' => 32,
411 'size' => CRM_Utils_Type::MEDIUM,
412 'html' => array(
413 'type' => 'Select',
414 ) ,
415 'pseudoconstant' => array(
416 'callback' => 'CRM_Mailing_PseudoConstant::mailingTypes',
417 )
418 ) ,
419 'from_name' => array(
420 'name' => 'from_name',
421 'type' => CRM_Utils_Type::T_STRING,
422 'title' => ts('Mailing From Name') ,
423 'description' => 'From Header of mailing',
424 'maxlength' => 128,
425 'size' => CRM_Utils_Type::HUGE,
426 'html' => array(
427 'type' => 'Text',
428 ) ,
429 ) ,
430 'from_email' => array(
431 'name' => 'from_email',
432 'type' => CRM_Utils_Type::T_STRING,
433 'title' => ts('Mailing From Email') ,
434 'description' => 'From Email of mailing',
435 'maxlength' => 128,
436 'size' => CRM_Utils_Type::HUGE,
437 'html' => array(
438 'type' => 'Text',
439 ) ,
440 ) ,
441 'replyto_email' => array(
442 'name' => 'replyto_email',
443 'type' => CRM_Utils_Type::T_STRING,
444 'title' => ts('Replyto Email') ,
445 'description' => 'Reply-To Email of mailing',
446 'maxlength' => 128,
447 'size' => CRM_Utils_Type::HUGE,
448 'html' => array(
449 'type' => 'Text',
450 ) ,
451 ) ,
452 'subject' => array(
453 'name' => 'subject',
454 'type' => CRM_Utils_Type::T_STRING,
455 'title' => ts('Subject') ,
456 'description' => 'Subject of mailing',
457 'maxlength' => 128,
458 'size' => CRM_Utils_Type::HUGE,
459 'html' => array(
460 'type' => 'Text',
461 ) ,
462 ) ,
463 'body_text' => array(
464 'name' => 'body_text',
465 'type' => CRM_Utils_Type::T_LONGTEXT,
466 'title' => ts('Body Text') ,
467 'description' => 'Body of the mailing in text format.',
468 ) ,
469 'body_html' => array(
470 'name' => 'body_html',
471 'type' => CRM_Utils_Type::T_LONGTEXT,
472 'title' => ts('Body Html') ,
473 'description' => 'Body of the mailing in html format.',
474 ) ,
475 'url_tracking' => array(
476 'name' => 'url_tracking',
477 'type' => CRM_Utils_Type::T_BOOLEAN,
478 'title' => ts('Url Tracking') ,
479 'description' => 'Should we track URL click-throughs for this mailing?',
480 'html' => array(
481 'type' => 'CheckBox',
482 ) ,
483 ) ,
484 'forward_replies' => array(
485 'name' => 'forward_replies',
486 'type' => CRM_Utils_Type::T_BOOLEAN,
487 'title' => ts('Forward Replies') ,
488 'description' => 'Should we forward replies back to the author?',
489 'html' => array(
490 'type' => 'CheckBox',
491 ) ,
492 ) ,
493 'auto_responder' => array(
494 'name' => 'auto_responder',
495 'type' => CRM_Utils_Type::T_BOOLEAN,
496 'title' => ts('Auto Responder') ,
497 'description' => 'Should we enable the auto-responder?',
498 'html' => array(
499 'type' => 'CheckBox',
500 ) ,
501 ) ,
502 'open_tracking' => array(
503 'name' => 'open_tracking',
504 'type' => CRM_Utils_Type::T_BOOLEAN,
505 'title' => ts('Track Mailing?') ,
506 'description' => 'Should we track when recipients open/read this mailing?',
507 ) ,
508 'is_completed' => array(
509 'name' => 'is_completed',
510 'type' => CRM_Utils_Type::T_BOOLEAN,
511 'title' => ts('Mailing Completed') ,
512 'description' => 'Has at least one job associated with this mailing finished?',
513 'html' => array(
514 'type' => 'CheckBox',
515 ) ,
516 ) ,
517 'msg_template_id' => array(
518 'name' => 'msg_template_id',
519 'type' => CRM_Utils_Type::T_INT,
520 'title' => ts('Mailing Message Template') ,
521 'description' => 'FK to the message template.',
522 'FKClassName' => 'CRM_Core_DAO_MessageTemplate',
523 ) ,
524 'override_verp' => array(
525 'name' => 'override_verp',
526 'type' => CRM_Utils_Type::T_BOOLEAN,
527 'title' => ts('Override Verp') ,
528 'description' => 'Should we overrite VERP address in Reply-To',
529 'html' => array(
530 'type' => 'CheckBox',
531 ) ,
532 ) ,
533 'created_id' => array(
534 'name' => 'created_id',
535 'type' => CRM_Utils_Type::T_INT,
536 'title' => ts('Mailing Creator') ,
537 'description' => 'FK to Contact ID who first created this mailing',
538 'FKClassName' => 'CRM_Contact_DAO_Contact',
539 ) ,
540 'created_date' => array(
541 'name' => 'created_date',
542 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
543 'title' => ts('Mailing Created Date') ,
544 'description' => 'Date and time this mailing was created.',
545 'html' => array(
546 'type' => 'Select Date',
547 ) ,
548 ) ,
549 'scheduled_id' => array(
550 'name' => 'scheduled_id',
551 'type' => CRM_Utils_Type::T_INT,
552 'title' => ts('Scheduled By') ,
553 'description' => 'FK to Contact ID who scheduled this mailing',
554 'FKClassName' => 'CRM_Contact_DAO_Contact',
555 ) ,
556 'scheduled_date' => array(
557 'name' => 'scheduled_date',
558 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
559 'title' => ts('Mailing Scheduled Date') ,
560 'description' => 'Date and time this mailing was scheduled.',
561 ) ,
562 'approver_id' => array(
563 'name' => 'approver_id',
564 'type' => CRM_Utils_Type::T_INT,
565 'title' => ts('Approved By') ,
566 'description' => 'FK to Contact ID who approved this mailing',
567 'FKClassName' => 'CRM_Contact_DAO_Contact',
568 ) ,
569 'approval_date' => array(
570 'name' => 'approval_date',
571 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
572 'title' => ts('Mailing Approved Date') ,
573 'description' => 'Date and time this mailing was approved.',
574 ) ,
575 'approval_status_id' => array(
576 'name' => 'approval_status_id',
577 'type' => CRM_Utils_Type::T_INT,
578 'title' => ts('Approval Status') ,
579 'description' => 'The status of this mailing. Values: none, approved, rejected',
580 'html' => array(
581 'type' => 'Select',
582 ) ,
583 'pseudoconstant' => array(
584 'optionGroupName' => 'mail_approval_status',
585 'optionEditPath' => 'civicrm/admin/options/mail_approval_status',
586 )
587 ) ,
588 'approval_note' => array(
589 'name' => 'approval_note',
590 'type' => CRM_Utils_Type::T_LONGTEXT,
591 'title' => ts('Approval Note') ,
592 'description' => 'Note behind the decision.',
593 'html' => array(
594 'type' => 'TextArea',
595 ) ,
596 ) ,
597 'is_archived' => array(
598 'name' => 'is_archived',
599 'type' => CRM_Utils_Type::T_BOOLEAN,
600 'title' => ts('Is Mailing Archived?') ,
601 'description' => 'Is this mailing archived?',
602 'html' => array(
603 'type' => 'CheckBox',
604 ) ,
605 ) ,
606 'visibility' => array(
607 'name' => 'visibility',
608 'type' => CRM_Utils_Type::T_STRING,
609 'title' => ts('Mailing Visibility') ,
610 'description' => 'In what context(s) is the mailing contents visible (online viewing)',
611 'maxlength' => 40,
612 'size' => CRM_Utils_Type::BIG,
613 'default' => 'Public Pages',
614 'html' => array(
615 'type' => 'Select',
616 ) ,
617 'pseudoconstant' => array(
618 'callback' => 'CRM_Core_SelectValues::groupVisibility',
619 )
620 ) ,
621 'campaign_id' => array(
622 'name' => 'campaign_id',
623 'type' => CRM_Utils_Type::T_INT,
624 'title' => ts('Mailing Campaign') ,
625 'description' => 'The campaign for which this mailing has been initiated.',
626 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
627 'html' => array(
628 'type' => 'Select',
629 ) ,
630 'pseudoconstant' => array(
631 'table' => 'civicrm_campaign',
632 'keyColumn' => 'id',
633 'labelColumn' => 'title',
634 )
635 ) ,
636 'dedupe_email' => array(
637 'name' => 'dedupe_email',
638 'type' => CRM_Utils_Type::T_BOOLEAN,
639 'title' => ts('No Duplicate emails?') ,
640 'description' => 'Remove duplicate emails?',
641 'html' => array(
642 'type' => 'CheckBox',
643 ) ,
644 ) ,
645 'sms_provider_id' => array(
646 'name' => 'sms_provider_id',
647 'type' => CRM_Utils_Type::T_INT,
648 'title' => ts('Mailing SMS Provider') ,
649 'FKClassName' => 'CRM_SMS_DAO_Provider',
650 'html' => array(
651 'type' => 'Select',
652 ) ,
653 ) ,
654 'hash' => array(
655 'name' => 'hash',
656 'type' => CRM_Utils_Type::T_STRING,
657 'title' => ts('Mailing Hash') ,
658 'description' => 'Key for validating requests related to this mailing.',
659 'maxlength' => 16,
660 'size' => CRM_Utils_Type::TWELVE,
661 ) ,
662 'location_type_id' => array(
663 'name' => 'location_type_id',
664 'type' => CRM_Utils_Type::T_INT,
665 'title' => ts('Location Type') ,
666 'description' => 'With email_selection_method, determines which email address to use',
667 'FKClassName' => 'CRM_Core_DAO_LocationType',
668 'pseudoconstant' => array(
669 'table' => 'civicrm_location_type',
670 'keyColumn' => 'id',
671 'labelColumn' => 'display_name',
672 )
673 ) ,
674 'email_selection_method' => array(
675 'name' => 'email_selection_method',
676 'type' => CRM_Utils_Type::T_STRING,
677 'title' => ts('Email Selection Method') ,
678 'description' => 'With location_type_id, determine how to choose the email address to use.',
679 'maxlength' => 20,
680 'size' => CRM_Utils_Type::MEDIUM,
681 'default' => 'automatic',
682 'pseudoconstant' => array(
683 'callback' => 'CRM_Core_SelectValues::emailSelectMethods',
684 )
685 ) ,
686 );
687 }
688 return self::$_fields;
689 }
690 /**
691 * Return a mapping from field-name to the corresponding key (as used in fields()).
692 *
693 * @return array
694 * Array(string $name => string $uniqueName).
695 */
696 static function &fieldKeys() {
697 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
698 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
699 }
700 return Civi::$statics[__CLASS__]['fieldKeys'];
701 }
702 /**
703 * Returns the names of this table
704 *
705 * @return string
706 */
707 static function getTableName() {
708 return self::$_tableName;
709 }
710 /**
711 * Returns if this table needs to be logged
712 *
713 * @return boolean
714 */
715 function getLog() {
716 return self::$_log;
717 }
718 /**
719 * Returns the list of fields that can be imported
720 *
721 * @param bool $prefix
722 *
723 * @return array
724 */
725 static function &import($prefix = false) {
726 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing', $prefix, array());
727 return $r;
728 }
729 /**
730 * Returns the list of fields that can be exported
731 *
732 * @param bool $prefix
733 *
734 * @return array
735 */
736 static function &export($prefix = false) {
737 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing', $prefix, array());
738 return $r;
739 }
740 }