CRM-14684 refactor function that identifies is a site supports back-office contributions
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 14 May 2014 00:26:44 +0000 (12:26 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 14 May 2014 00:26:44 +0000 (12:26 +1200)
& leave form layer part on forms

CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Page/Tab.php
CRM/Core/Block.php
CRM/Core/Config.php
CRM/Core/Payment.php
CRM/Event/Page/Tab.php
CRM/Member/Page/Tab.php
CRM/Pledge/Page/Payment.php
CRM/Pledge/Page/Tab.php

index 1c7fc5cfa5e436265a88fc2fd53b4dd640385dfe..f54af2d56076fcab8b2abf503fa1be162c342633 100644 (file)
@@ -196,7 +196,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
 
     // Set $newCredit variable in template to control whether link to credit card mode is included
-    CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
     return $defaults;
   }
 
index dd2dc1fbfef759fe4662bc9e959d71de11108c40..b71b60c0b23a4ea071141f6d9dfe60783477e034 100644 (file)
@@ -322,7 +322,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     }
 
     // Set $newCredit variable in template to control whether link to credit card mode is included
-    CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
 
     // fix the display of the monetary value, CRM-4038
     if (isset($defaults['total_amount'])) {
index bac070363ac614b8db955f7d30f930bd0c3596b5..b6093725a989a7475249e98010b916f92c2401c8 100644 (file)
@@ -283,7 +283,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
     $this->preProcess();
 
     // check if we can process credit card contribs
-    CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
 
     $this->setContext();
 
index bbf5ec6e52fb19465a4417cd1496aa651c69587a..5690a41da8af0ad26609a4082bf8716ee1bcb5be 100644 (file)
@@ -368,7 +368,7 @@ class CRM_Core_Block {
 
       if (!empty($config->enableComponents)) {
         // check if we can process credit card contribs
-        $newCredit = CRM_Core_Payment::allowBackofficeCreditCard();
+        $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
 
         foreach ($components as $componentName => $obj) {
           if (in_array($componentName, $config->enableComponents)) {
index 8533d4be408716c4079228158211a15cf63fb1db..6e6157f46a42f0e757438cd0b1e0d9a02b35a116 100644 (file)
@@ -851,6 +851,22 @@ AND
     $this->userFramework = $userFramework;
     $this->_setUserFrameworkConfig($userFramework);
   }
+
+  /**
+   * Is back office credit card processing enabled for this site - ie are there any installed processors that support
+   * on-site processing
+   * @return bool
+   */
+  static function isEnabledBackOfficeCreditCardPayments() {
+    // restrict to type=1 (credit card) payment processor payment_types and only include billing mode types 1 and 3
+    $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE,
+      "billing_mode IN ( 1, 3 ) AND payment_type = 1"
+    );
+    if (count($processors) > 0) {
+      return TRUE;
+    }
+    return FALSE;
+  }
 }
 // end CRM_Core_Config
 
index 762eb8a878aa1b7079f6b66c9ada385ae4aca17f..bc84d21cfab045a382e8d2b0b93502ed9f22a8bb 100644 (file)
@@ -388,24 +388,4 @@ INNER JOIN civicrm_contribution con ON ( con.contribution_recur_id = rec.id )
     }
     return $this->_paymentProcessor['url_recur'];
   }
-
-  /**
-   * Check for presence of type 1 or type 3 enabled processors (means we can do back-office submit credit/debit card trxns)
-   * @public
-   */
-  static function allowBackofficeCreditCard($template = NULL, $variableName = 'newCredit') {
-    $newCredit = FALSE;
-    // restrict to type=1 (credit card) payment processor payment_types and only include billing mode types 1 and 3
-    $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE,
-      "billing_mode IN ( 1, 3 ) AND payment_type = 1"
-    );
-    if (count($processors) > 0) {
-      $newCredit = TRUE;
-    }
-    if ($template) {
-      $template->assign($variableName, $newCredit);
-    }
-    return $newCredit;
-  }
-
 }
index 14ff3f8421e09a685fe03fc29be16c9cbc7efefd..9d971eba4460b9fcc985bf0b0bfb7330ae4ddc74 100644 (file)
@@ -159,7 +159,7 @@ class CRM_Event_Page_Tab extends CRM_Core_Page {
     $this->preProcess();
 
     // check if we can process credit card registration
-    CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
 
     // Only show credit card registration button if user has CiviContribute permission
     if (CRM_Core_Permission::access('CiviContribute')) {
index 2aad0d971cf983622c767b8f78fc7262dba252e7..d4eb65e215dc00dafbe00fcb44ab705e02437d00 100644 (file)
@@ -321,7 +321,9 @@ class CRM_Member_Page_Tab extends CRM_Core_Page {
     $this->preProcess();
 
     // check if we can process credit card membership
-    $newCredit = CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $newCredit = CRM_Core_Config::isEnabledBackOfficeCreditCardPayments();
+    $this->assign('newCredit', $newCredit);
+
     if ($newCredit) {
       $this->_isPaymentProcessor = TRUE;
     }
index 34c078d1134f7abdb0c77507f4aecfc4cced919b..ac36d7e2d1619b545d6b17aec526748cc1552f60 100644 (file)
@@ -66,7 +66,7 @@ class CRM_Pledge_Page_Payment extends CRM_Core_Page {
       $this->assign('contactId', $this->_contactId);
 
       // check if we can process credit card contribs
-      CRM_Core_Payment::allowBackofficeCreditCard($this);
+      $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
 
       // check is the user has view/edit signer permission
       $permission = 'view';
index 5b485730194eb226867d28609058e76fb39ec77c..ca0e360704c742b66416c9936d8441d83146830c 100644 (file)
@@ -136,7 +136,7 @@ class CRM_Pledge_Page_Tab extends CRM_Core_Page {
     $this->preProcess();
 
     // check if we can process credit card registration
-    CRM_Core_Payment::allowBackofficeCreditCard($this);
+    $this->assign('newCredit', CRM_Core_Config::isEnabledBackOfficeCreditCardPayments());
 
     $this->setContext();