Update copyright date for 2020
[civicrm-core.git] / CRM / Admin / Form / Preferences / Mailing.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2020 |
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
31 * @copyright CiviCRM LLC (c) 2004-2020
32 */
33
34 /**
35 * This class generates form components for the maling component preferences.
36 */
37 class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
38
39 protected $_settings = [
40 'profile_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
41 'profile_add_to_group_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
42 'track_civimail_replies' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
43 'civimail_workflow' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
44 'civimail_multiple_bulk_emails' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
45 'civimail_server_wide_lock' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
46 'include_message_id' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
47 'write_activity_record' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
48 'disable_mandatory_tokens_check' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
49 'dedupe_email_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
50 'hash_mailing_url' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
51 'auto_recipient_rebuild' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
52 ];
53
54 public function postProcess() {
55 $params = $this->controller->exportValues($this->_name);
56
57 if (empty($params['write_activity_record'])) {
58 // @todo use the setting onToggle & add an action rather than have specific form handling.
59 // see logging setting for eg.
60 $existingViewOptions = Civi::settings()->get('contact_view_options');
61
62 $displayViewOptions = CRM_Core_OptionGroup::values('contact_view_options', TRUE, FALSE, FALSE, NULL, 'name');
63 $displayValue = $displayViewOptions['CiviMail'];
64
65 $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions);
66
67 if (!in_array($displayValue, $viewOptions)) {
68 $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
69
70 Civi::settings()->set('contact_view_options', $existingViewOptions);
71 CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
72 so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
73 }
74 }
75
76 parent::postProcess();
77 }
78
79 }