CRM21512 follow-up. Show recurring contribution links based on payment processor...
authorMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 14 Sep 2018 13:41:14 +0000 (14:41 +0100)
committerMatthew Wire (MJW Consulting) <mjw@mjwconsult.co.uk>
Fri, 14 Sep 2018 14:03:31 +0000 (15:03 +0100)
CRM/Contribute/Page/Tab.php
templates/CRM/Contribute/Form/UpdateSubscription.tpl

index fa80f7d728fd7f3ab686a62d407bf8ed63e08c96..8a3f02ad13dcd357f75c1e956e65b933955d4184 100644 (file)
@@ -81,13 +81,18 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     if ($recurID) {
       $links = self::$_links;
       $paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj');
-      if (is_object($paymentProcessorObj) && $paymentProcessorObj->supports('cancelRecurring')) {
+      if (!is_object($paymentProcessorObj)) {
+        unset($links[CRM_Core_Action::DISABLE]);
+        unset($links[CRM_Core_Action::UPDATE]);
+        return $links;
+      }
+      if ($paymentProcessorObj->supports('cancelRecurring')) {
         unset($links[CRM_Core_Action::DISABLE]['extra'], $links[CRM_Core_Action::DISABLE]['ref']);
         $links[CRM_Core_Action::DISABLE]['url'] = "civicrm/contribute/unsubscribe";
         $links[CRM_Core_Action::DISABLE]['qs'] = "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}";
       }
 
-      if (is_object($paymentProcessorObj) && $paymentProcessorObj->isSupported('updateSubscriptionBillingInfo')) {
+      if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')) {
         $links[CRM_Core_Action::RENEW] = array(
           'name' => ts('Change Billing Details'),
           'title' => ts('Change Billing Details'),
@@ -95,6 +100,10 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
           'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}",
         );
       }
+
+      if (!$paymentProcessorObj->supports('ChangeSubscriptionAmount') && !$paymentProcessorObj->supports('EditRecurringContribution')) {
+        unset($links[CRM_Core_Action::UPDATE]);
+      }
       return $links;
     }
 
@@ -251,13 +260,6 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
       }
 
       if ($recurContributions[$recurId]['is_active']) {
-        $details = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurContributions[$recurId]['id'], 'recur');
-        $hideUpdate = $details->membership_id & $details->auto_renew;
-
-        if ($hideUpdate) {
-          $action -= CRM_Core_Action::UPDATE;
-        }
-
         $recurContributions[$recurId]['action'] = CRM_Core_Action::formLink(self::recurLinks($recurId), $action,
           array(
             'cid' => $this->_contactId,
index 1d4ea231ff7c181992a0b494eccf438d1362c1c5..ee71492bd6e5450b97fca99da20b210ba3877bd1 100644 (file)
@@ -28,7 +28,7 @@
     <div class="help">
       {$changeHelpText}
       {if $recurMembership}
-        <br/><strong> {ts}'WARNING: This recurring contribution is linked to membership:{/ts}
+        <br/><strong> {ts}WARNING: This recurring contribution is linked to membership:{/ts}
         <a class="crm-hover-button" href='{crmURL p="civicrm/contact/view/membership" q="action=view&reset=1&cid=`$contactId`&id=`$recurMembership.membership_id`&context=membership&selectedChild=member"}'>{$recurMembership.membership_name}</a>
         </strong>
       {/if}