Skip to content

Commit

Permalink
dev/core#2066 Use shared function to set the next url
Browse files Browse the repository at this point in the history
Extends civicrm#18767 to more places
  • Loading branch information
eileenmcnaughton committed Oct 14, 2020
1 parent 7ad12b2 commit 188bf7c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 66 deletions.
10 changes: 1 addition & 9 deletions CRM/Campaign/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,7 @@ public function preProcess() {
$this->_voterIds = $this->_contactIds = $this->_componentIds = $ids;

$this->assign('totalSelectedContacts', count($this->_contactIds));

//set the context for redirection for any task actions
$session = CRM_Core_Session::singleton();
$qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this);
$urlParams = 'force=1';
if (CRM_Utils_Rule::qfKey($qfKey)) {
$urlParams .= '&qfKey=' . $qfKey;
}
$session->replaceUserContext(CRM_Utils_System::url('civicrm/survey/search', $urlParams));
$this->setNextUrl('survey');
}

/**
Expand Down
19 changes: 1 addition & 18 deletions CRM/Event/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,24 +86,7 @@ public static function preProcessCommon(&$form) {

$form->_participantIds = $form->_componentIds = $ids;

//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/event/search', $urlParams));
}
else {
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName",
$urlParams
));
}
$form->setNextUrl('event');
}

/**
Expand Down
10 changes: 1 addition & 9 deletions CRM/Grant/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ public static function preProcessCommon(&$form) {

$form->_grantIds = $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();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/grant/search', $urlParams));
$form->setNextUrl('grant');
}

/**
Expand Down
20 changes: 1 addition & 19 deletions CRM/Member/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,25 +88,7 @@ public static function preProcessCommon(&$form) {
}

$form->_memberIds = $form->_componentIds = $ids;

//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/member/search', $urlParams));
}
else {
$session->replaceUserContext(CRM_Utils_System::url("civicrm/contact/search/$searchFormName",
$urlParams
));
}
$form->setNextUrl('member');
}

/**
Expand Down
13 changes: 2 additions & 11 deletions CRM/Pledge/Form/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function preProcess() {
/**
* Common pre-processing.
*
* @param CRM_Core_Form $form
* @param CRM_Pledge_Form_Task $form
*/
public static function preProcessCommon(&$form) {
$form->_pledgeIds = [];
Expand Down Expand Up @@ -79,16 +79,7 @@ public static function preProcessCommon(&$form) {
}

$form->_pledgeIds = $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();
$session->replaceUserContext(CRM_Utils_System::url('civicrm/pledge/search', $urlParams));
$form->setNextUrl('pledge');
}

/**
Expand Down

0 comments on commit 188bf7c

Please sign in to comment.