From faa31fa64dbf30da01b20fe978ccbc29fdda1010 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 14 Oct 2020 17:09:07 +1300 Subject: [PATCH] dev/core#2066 Use shared function to set the next url Reduces copy & paste - there are some more places like this to sort out after .... --- CRM/Activity/Form/Task.php | 19 +------------------ CRM/Contribute/Form/Task.php | 20 +------------------- CRM/Core/Form/Task.php | 2 +- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/CRM/Activity/Form/Task.php b/CRM/Activity/Form/Task.php index 3be85d5bc3..2c9adde728 100644 --- a/CRM/Activity/Form/Task.php +++ b/CRM/Activity/Form/Task.php @@ -83,24 +83,7 @@ class CRM_Activity_Form_Task extends CRM_Core_Form_Task { } $form->_activityHolderIds = $form->_componentIds = $ids; - - // Set the context for redirection for any task actions. - $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); - $urlParams = 'force=1'; - if (CRM_Utils_Rule::qfKey($qfKey)) { - $urlParams .= "&qfKey=$qfKey"; - } - - $session = CRM_Core_Session::singleton(); - $searchFormName = strtolower($form->get('searchFormName')); - if ($searchFormName == 'search') { - $session->replaceUserContext(CRM_Utils_System::url('civicrm/activity/search', $urlParams)); - } - else { - $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName", - $urlParams - )); - } + $form->setNextUrl('activity'); } /** diff --git a/CRM/Contribute/Form/Task.php b/CRM/Contribute/Form/Task.php index e6cc4ea750..94d76b0fd4 100644 --- a/CRM/Contribute/Form/Task.php +++ b/CRM/Contribute/Form/Task.php @@ -136,25 +136,7 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { $form->_contributionIds = $form->_componentIds = $ids; $form->set('contributionIds', $form->_contributionIds); - - //set the context for redirection for any task actions - $session = CRM_Core_Session::singleton(); - - $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $form); - $urlParams = 'force=1'; - if (CRM_Utils_Rule::qfKey($qfKey)) { - $urlParams .= "&qfKey=$qfKey"; - } - - $searchFormName = strtolower($form->get('searchFormName')); - if ($searchFormName == 'search') { - $session->replaceUserContext(CRM_Utils_System::url('civicrm/contribute/search', $urlParams)); - } - else { - $session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName", - $urlParams - )); - } + $form->setNextUrl('contribute'); } /** diff --git a/CRM/Core/Form/Task.php b/CRM/Core/Form/Task.php index 2c87a8ccbb..a051f6bf53 100644 --- a/CRM/Core/Form/Task.php +++ b/CRM/Core/Form/Task.php @@ -80,7 +80,7 @@ abstract class CRM_Core_Form_Task extends CRM_Core_Form { * * @throws \CRM_Core_Exception */ - protected function setNextUrl(string $pathPart) { + public function setNextUrl(string $pathPart) { //set the context for redirection for any task actions $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); $urlParams = 'force=1'; -- 2.25.1