Merge pull request #4979 from xurizaemon/codingstandards-12
[civicrm-core.git] / CRM / Admin / Form / Preferences / Mailing.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
39de6fd5 4 | CiviCRM version 4.6 |
6a488035 5 +--------------------------------------------------------------------+
06b69b18 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
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/**
29 *
30 * @package CRM
06b69b18 31 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
32 * $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
33 *
34 */
35
36/**
37 * This class generates form components for the component preferences
38 *
39 */
40class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
00be9182 41 public function preProcess() {
6a488035
TO
42 CRM_Utils_System::setTitle(ts('CiviMail Component Settings'));
43 $this->_varNames = array(
9d72cede
EM
44 CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
45 'profile_double_optin' => array(
6a488035
TO
46 'html_type' => 'checkbox',
47 'title' => ts('Enable Double Opt-in for Profile Group(s) field'),
48 'weight' => 1,
49 'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'),
50 ),
9d72cede 51 'profile_add_to_group_double_optin' => array(
6a488035
TO
52 'html_type' => 'checkbox',
53 'title' => ts('Enable Double Opt-in for Profiles which use the "Add to Group" setting'),
54 'weight' => 2,
55 'description' => ts('When CiviMail is enabled and a profile uses the "Add to Group" setting, users who complete the profile form will receive a confirmation email. They must respond (opt-in) before they are added to the group.'),
56 ),
9d72cede 57 'track_civimail_replies' => array(
6a488035
TO
58 'html_type' => 'checkbox',
59 'title' => ts('Track replies using VERP in Reply-To header'),
60 'weight' => 3,
61 'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To.'),
62 ),
9d72cede 63 'civimail_workflow' => array(
6a488035
TO
64 'html_type' => 'checkbox',
65 'title' => ts('Enable workflow support for CiviMail'),
66 'weight' => 4,
67 'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'),
68 ),
9d72cede 69 'civimail_multiple_bulk_emails' => array(
6a488035
TO
70 'html_type' => 'checkbox',
71 'title' => ts('Enable multiple bulk email address for a contact.'),
72 'weight' => 5,
73 'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact.'),
74 ),
9d72cede 75 'civimail_server_wide_lock' => array(
6a488035
TO
76 'html_type' => 'checkbox',
77 'title' => ts('Enable global server wide lock for CiviMail'),
78 'weight' => 6,
79 'description' => NULL,
80 ),
9d72cede 81 'include_message_id' => array(
6a488035
TO
82 'html_type' => 'checkbox',
83 'title' => ts('Enable CiviMail to generate Message-ID header'),
84 'weight' => 7,
85 'description' => NULL,
86 ),
9d72cede 87 'write_activity_record' => array(
2ede60ec
DL
88 'html_type' => 'checkbox',
89 'title' => ts('Enable CiviMail to create activities on delivery'),
90 'weight' => 8,
91 'description' => NULL,
92 ),
9d72cede 93 'disable_mandatory_tokens_check' => array(
9babb598
OB
94 'html_type' => 'checkbox',
95 'title' => ts('Disable check for mandatory tokens'),
96 'weight' => 9,
97 'description' => ts('Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.'),
98 ),
9d72cede 99 'dedupe_email_default' => array(
9d76357a
DG
100 'html_type' => 'checkbox',
101 'title' => ts('CiviMail dedupes e-mail addresses by default'),
102 'weight' => 10,
103 'description' => NULL,
104 ),
9d72cede 105 'hash_mailing_url' => array(
c57f36a1
PJ
106 'html_type' => 'checkbox',
107 'title' => ts('Hashed Mailing URL\'s'),
108 'weight' => 11,
109 'description' => 'If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID',
110 ),
6a488035
TO
111 ),
112 );
113
114 parent::preProcess();
115 }
5c61cec2 116
00be9182 117 public function postProcess() {
5c61cec2
KJ
118 // check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled
119 $params = $this->controller->exportValues($this->_name);
120
a7488080 121 if (empty($params['write_activity_record'])) {
5c61cec2
KJ
122 $existingViewOptions = CRM_Core_BAO_Setting::getItem(
123 CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
124 'contact_view_options'
125 );
126
127 $displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name');
128 $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions);
129
130 if (!in_array($displayValue, $viewOptions)) {
131 $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
132
133 CRM_Core_BAO_Setting::setItem($existingViewOptions, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options');
134 CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
135 so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
136 }
137 }
138
139 parent::postProcess();
140 }
9d72cede 141}