Commit 74f89a9f authored by eileen's avatar eileen

Fix notices on mailing components screen, convert to metadata based

parent 83b778bd
......@@ -41,7 +41,10 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
'contact_smart_group_display' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'advanced_search_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'user_dashboard_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'activity_assignee_notification' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'activity_assignee_notification_ics' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'preserve_activity_tab_filter' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'ajaxPopupsEnabled' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'display_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'sort_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
);
......@@ -57,31 +60,15 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
'title' => ts('Editing Contacts'),
'weight' => 3,
),
'activity_assignee_notification' => array(
'html_type' => 'checkbox',
'title' => ts('Notify Activity Assignees'),
'weight' => 5,
),
'activity_assignee_notification_ics' => array(
'html_type' => 'checkbox',
'title' => ts('Include ICal Invite to Activity Assignees'),
'weight' => 6,
),
'contact_ajax_check_similar' => array(
'title' => ts('Check for Similar Contacts'),
'weight' => 8,
'html_type' => NULL,
),
'editor_id' => array(
'html_type' => NULL,
'weight' => 12,
),
'ajaxPopupsEnabled' => array(
'html_type' => 'checkbox',
'title' => ts('Enable Popup Forms'),
'weight' => 13,
),
'do_not_notify_assignees_for' => array(
'html_type' => 'select',
'option_values' => $optionValues,
......
......@@ -29,102 +29,34 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
* $Id: Display.php 36505 2011-10-03 14:19:56Z lobo $
*
*/
/**
* This class generates form components for the component preferences
*
* This class generates form components for the maling component preferences.
*/
class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
public function preProcess() {
CRM_Utils_System::setTitle(ts('CiviMail Component Settings'));
$this->_varNames = array(
CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array(
'profile_double_optin' => array(
'html_type' => 'checkbox',
'title' => ts('Enable Double Opt-in for Profile Group(s) field'),
'weight' => 1,
'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.'),
),
'profile_add_to_group_double_optin' => array(
'html_type' => 'checkbox',
'title' => ts('Enable Double Opt-in for Profiles which use the "Add to Group" setting'),
'weight' => 2,
'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.'),
),
'track_civimail_replies' => array(
'html_type' => 'checkbox',
'title' => ts('Track replies using VERP in Reply-To header'),
'weight' => 3,
'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To.'),
),
'civimail_workflow' => array(
'html_type' => 'checkbox',
'title' => ts('Enable workflow support for CiviMail'),
'weight' => 4,
'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'),
),
'civimail_multiple_bulk_emails' => array(
'html_type' => 'checkbox',
'title' => ts('Enable multiple bulk email address for a contact.'),
'weight' => 5,
'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact.'),
),
'civimail_server_wide_lock' => array(
'html_type' => 'checkbox',
'title' => ts('Enable global server wide lock for CiviMail'),
'weight' => 6,
'description' => NULL,
),
'include_message_id' => array(
'html_type' => 'checkbox',
'title' => ts('Enable CiviMail to generate Message-ID header'),
'weight' => 7,
'description' => NULL,
),
'write_activity_record' => array(
'html_type' => 'checkbox',
'title' => ts('Enable CiviMail to create activities on delivery'),
'weight' => 8,
'description' => NULL,
),
'disable_mandatory_tokens_check' => array(
'html_type' => 'checkbox',
'title' => ts('Disable check for mandatory tokens'),
'weight' => 9,
'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.'),
),
'dedupe_email_default' => array(
'html_type' => 'checkbox',
'title' => ts('CiviMail dedupes e-mail addresses by default'),
'weight' => 10,
'description' => NULL,
),
'hash_mailing_url' => array(
'html_type' => 'checkbox',
'title' => ts('Hashed Mailing URL\'s'),
'weight' => 11,
'description' => ts('If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID'),
),
'auto_recipient_rebuild' => array(
'html_type' => 'checkbox',
'title' => ts('Enable automatic CiviMail recipient count display'),
'weight' => 12,
'description' => ts('Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.'),
),
),
);
parent::preProcess();
}
protected $_settings = [
'profile_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'profile_add_to_group_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'track_civimail_replies' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'civimail_workflow' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'civimail_multiple_bulk_emails' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'civimail_server_wide_lock' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'include_message_id' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'write_activity_record' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'disable_mandatory_tokens_check' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'dedupe_email_default' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'hash_mailing_url' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
'auto_recipient_rebuild' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
];
public function postProcess() {
// check if mailing tab is enabled, if not prompt user to enable the tab if "write_activity_record" is disabled
$params = $this->controller->exportValues($this->_name);
if (empty($params['write_activity_record'])) {
// @todo use the setting onToggle & add an action rather than have specific form handling.
// see logging setting for eg.
$existingViewOptions = Civi::settings()->get('contact_view_options');
$displayValue = CRM_Core_OptionGroup::getValue('contact_view_options', 'CiviMail', 'name');
......
......@@ -74,7 +74,16 @@ trait CRM_Admin_Form_SettingTrait {
* @return array
*/
protected function getSettingsToSetByMetadata($params) {
return array_intersect_key($params, $this->_settings);
$setValues = array_intersect_key($params, $this->_settings);
// Checkboxes will be unset rather than empty so we need to add them back in.
// Handle quickform hateability just once, right here right now.
$unsetValues = array_diff_key($this->_settings, $params);
foreach ($unsetValues as $key => $unsetValue) {
if ($this->getQuickFormType($this->getSettingMetadata($key)) === 'CheckBox') {
$setValues[$key] = [$key => 0];
}
}
return $setValues;
}
/**
......@@ -231,6 +240,9 @@ trait CRM_Admin_Form_SettingTrait {
if ($this->getQuickFormType($spec) === 'CheckBoxes') {
$this->_defaults[$setting] = array_fill_keys($this->_defaults[$setting], 1);
}
if ($this->getQuickFormType($spec) === 'CheckBox') {
$this->_defaults[$setting] = [$setting => $this->_defaults[$setting]];
}
}
}
......@@ -244,6 +256,10 @@ trait CRM_Admin_Form_SettingTrait {
if ($this->getQuickFormType($this->getSettingMetadata($setting)) === 'CheckBoxes') {
$settings[$setting] = array_keys($settingValue);
}
if ($this->getQuickFormType($this->getSettingMetadata($setting)) === 'CheckBox') {
// This will be an array with one value.
$settings[$setting] = (int) reset($settings[$setting]);
}
}
civicrm_api3('setting', 'create', $settings);
}
......
......@@ -29,8 +29,6 @@
*
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/
/**
......@@ -243,7 +241,7 @@ return array(
'group' => 'core',
'name' => 'ajaxPopupsEnabled',
'type' => 'Boolean',
'quick_form_type' => 'YesNo',
'html_type' => 'checkbox',
'default' => 1,
'add' => '4.5',
'title' => ts('Enable Popup Forms'),
......@@ -256,8 +254,8 @@ return array(
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'activity_assignee_notification',
'type' => 'String',
'html_type' => 'Text',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '1',
'add' => '4.1',
'title' => ts('Notify Activity Assignees'),
......@@ -270,8 +268,8 @@ return array(
'group_name' => 'CiviCRM Preferences',
'group' => 'core',
'name' => 'activity_assignee_notification_ics',
'type' => 'String',
'html_type' => 'Text',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '0',
'add' => '4.3',
'title' => ts('Include ICal Invite to Activity Assignees'),
......
......@@ -41,28 +41,28 @@ return array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'profile_double_optin',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '1',
'add' => '4.1',
'title' => 'Enable Double Opt-in for Profile Group(s) field',
'title' => ts('Enable Double Opt-in for Profile Group(s) field'),
'is_domain' => 1,
'is_contact' => 0,
'description' => '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.',
'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.'),
'help_text' => NULL,
),
'track_civimail_replies' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'track_civimail_replies',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '0',
'add' => '4.1',
'title' => 'Track replies using VERP in Reply-To header',
'title' => ts('Track replies using VERP in Reply-To header'),
'is_domain' => 1,
'is_contact' => 0,
'description' => 'If checked, mailings will default to tracking replies using VERP-ed Reply-To. ',
'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To. '),
'help_text' => NULL,
'validate_callback' => 'CRM_Core_BAO_Setting::validateBoolSetting',
),
......@@ -70,25 +70,25 @@ return array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_workflow',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '0',
'add' => '4.1',
'title' => 'Use CiviMail Workflow',
'title' => ts('Enable workflow support for CiviMail'),
'is_domain' => 1,
'is_contact' => 0,
'description' => '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.',
'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'),
'help_text' => NULL,
),
'civimail_server_wide_lock' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_server_wide_lock',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '0',
'add' => '4.1',
'title' => 'Lock Mails Server-Wide for Mail Sending',
'title' => ts('Enable global server wide lock for CiviMail'),
'is_domain' => 1,
'is_contact' => 0,
'description' => NULL,
......@@ -126,81 +126,81 @@ return array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'profile_add_to_group_double_optin',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => '0',
'add' => '4.1',
'title' => 'Enable Double Opt-in for Profile Group(s) field',
'title' => ts('Enable Double Opt-in for Profile Group(s) field'),
'is_domain' => 1,
'is_contact' => 0,
'description' => '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.',
'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.'),
'help_text' => NULL,
),
'disable_mandatory_tokens_check' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'disable_mandatory_tokens_check',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 0,
'add' => '4.4',
'title' => 'Disable check for mandatory tokens',
'title' => ts('Disable check for mandatory tokens'),
'is_domain' => 1,
'is_contact' => 0,
'description' => '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.',
'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.'),
'help_text' => NULL,
),
'dedupe_email_default' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'dedupe_email_default',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 1,
'add' => '4.5',
'title' => 'CiviMail dedupes e-mail addresses by default',
'title' => ts('CiviMail dedupes e-mail addresses by default'),
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Set the "dedupe e-mail" option when sending a new mailing to "true" by default.',
'description' => ts('Set the "dedupe e-mail" option when sending a new mailing to "true" by default.'),
'help_text' => NULL,
),
'hash_mailing_url' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'hash_mailing_url',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 0,
'add' => '4.5',
'title' => 'Hashed Mailing URL\'s',
'title' => ts('Hashed Mailing URL\'s'),
'is_domain' => 1,
'is_contact' => 0,
'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',
'description' => ts('If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID'),
'help_text' => NULL,
),
'civimail_multiple_bulk_emails' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'civimail_multiple_bulk_emails',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => 0,
'add' => '4.5',
'title' => ' Multiple Bulk Emails',
'title' => ts('Enable multiple bulk email address for a contact.'),
'is_domain' => 1,
'is_contact' => 0,
'description' => 'If enabled, CiviMail will deliver a copy of the email to each bulk email listed for the contact.',
'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact.'),
'help_text' => NULL,
),
'include_message_id' => array(
'group_name' => 'Mailing Preferences',
'group' => 'mailing',
'name' => 'include_message_id',
'type' => 'Integer',
'type' => 'Boolean',
'html_type' => 'checkbox',
'default' => FALSE,
'add' => '4.5',
'title' => 'Enable CiviMail to generate Message-ID header',
'title' => ts('Enable CiviMail to generate Message-ID header'),
'is_domain' => 1,
'is_contact' => 0,
'description' => '',
......@@ -306,10 +306,11 @@ return array(
'group' => 'mailing',
'name' => 'write_activity_record',
'type' => 'Boolean',
'quick_form_type' => 'YesNo',
'html_type' => 'checkbox',
'quick_form_type' => 'CheckBox',
'default' => '1',
'add' => '4.7',
'title' => 'Enable CiviMail to create activities on delivery',
'title' => ts('Enable CiviMail to create activities on delivery'),
'is_domain' => 1,
'is_contact' => 0,
'description' => NULL,
......@@ -338,13 +339,14 @@ return array(
'group' => 'mailing',
'name' => 'auto_recipient_rebuild',
'type' => 'Boolean',
'quick_form_type' => 'YesNo',
'html_type' => 'checkbox',
'quick_form_type' => 'CheckBox',
'default' => '1',
'title' => 'Enable automatic CiviMail recipient count display',
'title' => ts('Enable automatic CiviMail recipient count display'),
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.',
'help_text' => 'CiviMail automatically fetches recipient list and count whenever mailing groups are included or excluded while composing bulk mail. This phenomena may degrade performance for large sites, so disable this setting to build and fetch recipients for selected groups, manually.',
'description' => ts('Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.'),
'help_text' => ts('CiviMail automatically fetches recipient list and count whenever mailing groups are included or excluded while composing bulk mail. This phenomena may degrade performance for large sites, so disable this setting to build and fetch recipients for selected groups, manually.'),
),
'allow_mail_from_logged_in_contact' => array(
'group_name' => 'Mailing Preferences',
......
......@@ -61,7 +61,7 @@
{if $field.html_type EQ 'checkbox'|| $field.html_type EQ 'checkboxes'}
<td class="label"></td>
<td>
{$form.$n.html} {$form.$n.label}
{$form.$n.html}
{if $field.description}
<br /><span class="description">{$field.description}</span>
{/if}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment