Merge pull request #15982 from civicrm/5.20
[civicrm-core.git] / CRM / Admin / Form / Preferences / Mailing.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class generates form components for the maling component preferences.
20 */
21 class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
22
23 protected $_settings = [
24 'profile_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
25 'profile_add_to_group_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
26 'track_civimail_replies' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
27 'civimail_workflow' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
28 'civimail_multiple_bulk_emails' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
29 'civimail_server_wide_lock' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
30 'include_message_id' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
31 'write_activity_record' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
32 'disable_mandatory_tokens_check' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
33 'dedupe_email_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
34 'hash_mailing_url' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
35 'auto_recipient_rebuild' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
36 ];
37
38 public function postProcess() {
39 $params = $this->controller->exportValues($this->_name);
40
41 if (empty($params['write_activity_record'])) {
42 // @todo use the setting onToggle & add an action rather than have specific form handling.
43 // see logging setting for eg.
44 $existingViewOptions = Civi::settings()->get('contact_view_options');
45
46 $displayViewOptions = CRM_Core_OptionGroup::values('contact_view_options', TRUE, FALSE, FALSE, NULL, 'name');
47 $displayValue = $displayViewOptions['CiviMail'];
48
49 $viewOptions = explode(CRM_Core_DAO::VALUE_SEPARATOR, $existingViewOptions);
50
51 if (!in_array($displayValue, $viewOptions)) {
52 $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
53
54 Civi::settings()->set('contact_view_options', $existingViewOptions);
55 CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
56 so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
57 }
58 }
59
60 parent::postProcess();
61 }
62
63 }