From ac983377ef8090f16fdf02b7eb828452f71d7d62 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 1 Nov 2017 15:47:45 +0530 Subject: [PATCH] CRM-21380: Add setting to block activity types from sending assignee notification --- CRM/Activity/Form/Activity.php | 3 ++- CRM/Admin/Form/Preferences.php | 3 ++- CRM/Admin/Form/Preferences/Display.php | 8 +++++++ settings/Core.setting.php | 21 +++++++++++++++++ .../CRM/Admin/Form/Preferences/Display.tpl | 23 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 9cdfd4a74a..42791ab667 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -1047,7 +1047,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { // send copy to assignee contacts.CRM-4509 $mailStatus = ''; - if (Civi::settings()->get('activity_assignee_notification')) { + if (Civi::settings()->get('activity_assignee_notification') + && !in_array($activity->activity_type_id, Civi::settings()->get('filter_activity_type_notification'))) { $activityIDs = array($activity->id); if ($followupActivity) { $activityIDs = array_merge($activityIDs, array($followupActivity->id)); diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index ab6519517d..43d1455dd4 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -196,7 +196,8 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { $this->addElement('select', $fieldName, $fieldValue['title'], - $fieldValue['option_values'] + $fieldValue['option_values'], + CRM_Utils_Array::value('attributes', $fieldValue) ); break; diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index bc678af444..2d20d89210 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -37,6 +37,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { public function preProcess() { CRM_Utils_System::setTitle(ts('Settings - Display Preferences')); + $optionValues = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, NULL, 'name'); $this->_varNames = array( CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array( @@ -104,6 +105,13 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'title' => ts('Enable Popup Forms'), 'weight' => 13, ), + 'filter_activity_type_notification' => array( + 'html_type' => 'select', + 'option_values' => $optionValues, + 'attributes' => array('multiple' => 1, "class" => "crm-select2"), + 'title' => ts('Blocked Activity Types.'), + 'weight' => 14, + ), ), ); diff --git a/settings/Core.setting.php b/settings/Core.setting.php index d09cc36c45..ec93ba8a9b 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -967,4 +967,25 @@ return array( 'description' => 'When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts', 'help_text' => NULL, ), + 'filter_activity_type_notification' => array( + 'group_name' => 'Filter Activity Type Notification', + 'group' => 'core', + 'name' => 'filter_activity_type_notification', + 'type' => 'Array', + 'add' => '4.7', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => 'Select Activity types to disable assignee notifications.', + 'title' => 'Filter Activity Type Notification', + 'help_text' => '', + 'html_type' => 'Select', + 'html_attributes' => array( + 'multiple' => 1, + 'class' => 'crm-select2', + ), + 'pseudoconstant' => array( + 'optionGroupName' => 'activity_type', + ), + 'quick_form_type' => 'Select', + ), ); diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index fe6e16231d..7591ca7e87 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -133,6 +133,17 @@ + + {$form.filter_activity_type_notification.label} + {$form.filter_activity_type_notification.html} + + +   + + {ts}Selected activity types will not be included in notifying the assignees.{/ts} + + + {$form.activity_assignee_notification_ics.html} {$form.activity_assignee_notification_ics.label} @@ -228,6 +239,18 @@ $('#contact_edit_preferences').val(params.toString()); } + //show/hide activity types based on checkbox value + $('#filter_activity_type_notification').hide(); + $('#filter_activity_type_notification-desc').hide(); + if ($('#activity_assignee_notification').is(":checked")) { + $('#filter_activity_type_notification').show(); + $('#filter_activity_type_notification-desc').show(); + } + $('#activity_assignee_notification').change(function() { + $('#filter_activity_type_notification').toggle(); + $('#filter_activity_type_notification-desc').toggle(); + }); + var invoicesKey = '{/literal}{$invoicesKey}{literal}'; var invoicing = '{/literal}{$invoicing}{literal}'; if (!invoicing) { -- 2.25.1