CRM-14684 refactor function that identifies is a site supports back-office contributions
[civicrm-core.git] / CRM / Core / Config.php
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