From 3af26897ffd52d850766a4aa1f9d9e89a2dea8a2 Mon Sep 17 00:00:00 2001 From: Luciano Spiegel Date: Mon, 14 Jun 2021 19:07:12 +0200 Subject: [PATCH] fix activity_date_time_relative filter when `preserve_activity_tab_filter` setting is on --- CRM/Activity/Page/AJAX.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index f61df22bb478..cea6bbd4c09c 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -397,6 +397,8 @@ public static function getContactActivity() { $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters); + // $params will be modified later on, need to save original filters + $filterParams = $params; // To be consistent, the cid parameter should be renamed to contact_id in // the template file, see templates/CRM/Activity/Selector/Selector.tpl @@ -416,6 +418,7 @@ public static function getContactActivity() { // store the activity filter preference CRM-11761 if (Civi::settings()->get('preserve_activity_tab_filter') && ($userID = CRM_Core_Session::getLoggedInContactID())) { + $activityFilter = []; unset($optionalParameters['context']); foreach ($optionalParameters as $searchField => $dataType) { $formSearchField = $searchField; @@ -425,8 +428,8 @@ public static function getContactActivity() { elseif ($searchField === 'activity_type_exclude_id') { $formSearchField = 'activity_type_exclude_filter_id'; } - if (!empty($params[$searchField])) { - $activityFilter[$formSearchField] = $params[$searchField]; + if (!empty($filterParams[$searchField])) { + $activityFilter[$formSearchField] = $filterParams[$searchField]; if (in_array($searchField, ['activity_date_time_low', 'activity_date_time_high'])) { $activityFilter['activity_date_time_relative'] = 0; }