Do not error on view contribution recur if not displaying contributions
authoreileen <emcnaughton@wikimedia.org>
Mon, 3 May 2021 03:27:22 +0000 (15:27 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 5 May 2021 05:39:37 +0000 (17:39 +1200)
CRM/Contribute/Page/ContributionRecur.php
templates/CRM/Contribute/Page/ContributionRecur.tpl

index ef68f424c7c1fa47313d45158742b60d4c197456..07f5f0fd7743a281288b7aa85779e5815620c0f4 100644 (file)
@@ -99,7 +99,7 @@ class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page {
    */
   public function run() {
     $this->preProcess();
-
+    $this->assign('hasAccessCiviContributePermission', CRM_Core_Permission::check('access CiviContribute'));
     if ($this->isViewContext()) {
       $this->view();
     }
index 1c8b4dca28b9860472f6893b7c6ca9357e92e6f9..a84499b3a74ece01dc7e4549a8155c24a37394bb 100644 (file)
     <div class="crm-submit-buttons"><a class="button cancel crm-form-submit" href="{crmURL p='civicrm/contact/view' q='action=browse&selectedChild=contribute'}">{ts}Done{/ts}</a></div>
   </div>
 {/if}
-
-<script type="text/javascript">
-  var recurContribID = {$recur.id};
-  var contactID = {$contactId};
-  {literal}
-  CRM.$(function($) {
-    CRM.loadPage(
-            CRM.url(
-                    'civicrm/contribute/contributionrecur-payments',
-                    {
-                      reset: 1,
-                      id: recurContribID,
-                      cid: contactID
-                    },
-                    'back'
-            ),
-            {
-              target : '#recurring-contribution-payments',
-              dialog : false
-            }
-    );
-  });
-  {/literal}
-</script>
+{if $hasAccessCiviContributePermission}
+  <script type="text/javascript">
+    var recurContribID = {$recur.id};
+    var contactID = {$contactId};
+    {literal}
+    CRM.$(function($) {
+      CRM.loadPage(
+              CRM.url(
+                      'civicrm/contribute/contributionrecur-payments',
+                      {
+                        reset: 1,
+                        id: recurContribID,
+                        cid: contactID
+                      },
+                      'back'
+              ),
+              {
+                target : '#recurring-contribution-payments',
+                dialog : false
+              }
+      );
+    });
+    {/literal}
+  </script>
+{/if}
 <div id="recurring-contribution-payments"></div>