From ec5480d9f0ed2fbce2ecb38723a3067da81b7bde Mon Sep 17 00:00:00 2001 From: Omar abu hussein Date: Fri, 16 Nov 2018 12:09:55 +0000 Subject: [PATCH] dev/core#288 Removing the date from the membership update notification --- CRM/Contribute/BAO/Contribution.php | 44 ++++++----------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index c0c2916fab..854f73c24e 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5213,23 +5213,16 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Member_PseudoConstant::membershipStatus() ); - if ($updatedStatusName == 'Cancelled') { - $statusMsg .= "
" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName)); - } - elseif ($updatedStatusName == 'Expired') { - $statusMsg .= "
" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName)); - } - else { - $endDate = self::getFormattedMembershipEndDateFromContributionId($contributionId); - if ($endDate) { - $statusMsg .= "
" . ts("Membership for %1 has been updated. The membership End Date is %2.", - array( - 1 => $userDisplayName, - 2 => $endDate, - ) - ); - } + + $statusNameMsgPart = 'updated'; + switch ($updatedStatusName) { + case 'Cancelled': + case 'Expired': + $statusNameMsgPart = $updatedStatusName; + break; } + + $statusMsg .= "
" . ts("Membership for %1 has been %2.", array(1 => $userDisplayName, 2 => $statusNameMsgPart)); } if ($componentName == 'CiviEvent') { @@ -5263,25 +5256,6 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co return $statusMsg; } - private static function getFormattedMembershipEndDateFromContributionId($contributionId) { - $endDateResponse = civicrm_api3('MembershipPayment', 'get', [ - 'sequential' => 1, - 'contribution_id' => $contributionId, - 'api.Membership.get' => ['id' => '$value.id', 'return' => ['end_date']], - 'options' => ['limit' => 1, 'sort' => 'id DESC'], - ]); - - $endDate = NULL; - if (!empty($endDateResponse['values'][0]['api.Membership.get']['count'])) { - $endDate = $endDateResponse['values'][0]['api.Membership.get']['values'][0]['end_date']; - $endDate = CRM_Utils_Date::customFormat($endDate, - '%B %E%f, %Y' - ); - } - - return $endDate; - } - /** * Get the contribution as it is in the database before being updated. * -- 2.25.1