From 635aec5844a1bb5ccf177340386890cf7527e54b Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Sat, 23 Oct 2021 11:27:33 +1300 Subject: [PATCH] [REF] Remove support for not-passed 'pledge' value On grepping 'pledge' is never passed to this function (it has had it's own option value for a long time) so this removes the handling for if it is passed. Also, some simplification --- CRM/Contribute/BAO/Contribution/Utils.php | 41 ++++------------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index a5161686af..59db370f4a 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -215,12 +215,7 @@ LIMIT 1 * Array of contribution statuses in array('status id' => 'label') format */ public static function getContributionStatuses($usedFor = 'contribution', $name = NULL) { - if ($usedFor === 'pledge') { - $statusNames = CRM_Pledge_BAO_Pledge::buildOptions('status_id', 'validate'); - } - else { - $statusNames = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); - } + $statusNames = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); $statusNamesToUnset = [ // For records which represent a data template for a recurring @@ -237,36 +232,19 @@ LIMIT 1 'Refunded', 'Chargeback', 'Pending refund', + 'In Progress', + 'Overdue', + 'Partially paid', ]); - if ($usedFor === 'contribution') { - $statusNamesToUnset = array_merge($statusNamesToUnset, [ - 'In Progress', - 'Overdue', - 'Partially paid', - ]); - } - elseif ($usedFor === 'participant') { - $statusNamesToUnset = array_merge($statusNamesToUnset, [ - 'Cancelled', - 'Failed', - 'In Progress', - 'Overdue', - 'Partially paid', - ]); - } - elseif ($usedFor === 'membership') { + if ($usedFor && $usedFor !== 'contribution') { $statusNamesToUnset = array_merge($statusNamesToUnset, [ - 'In Progress', 'Cancelled', 'Failed', - 'Overdue', - 'Partially paid', ]); } } else { - switch ($name) { case 'Completed': // [CRM-17498] Removing unsupported status change options. @@ -312,13 +290,8 @@ LIMIT 1 unset($statusNames[CRM_Utils_Array::key($name, $statusNames)]); } - // based on filtered statuse names fetch the final list of statuses in array('id' => 'label') format - if ($usedFor == 'pledge') { - $statuses = CRM_Pledge_BAO_Pledge::buildOptions('status_id'); - } - else { - $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id'); - } + $statuses = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id'); + foreach ($statuses as $statusID => $label) { if (!array_key_exists($statusID, $statusNames)) { unset($statuses[$statusID]); -- 2.25.1