CRM-16573 Back office supress back office cvn
authorEileen McNaughton <eileen@fuzion.co.nz>
Wed, 27 May 2015 05:53:16 +0000 (17:53 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 27 May 2015 05:53:50 +0000 (17:53 +1200)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/UpdateBilling.php
CRM/Core/Payment/Form.php
CRM/Core/Payment/ProcessorForm.php
CRM/Event/Cart/Form/Checkout/Payment.php
CRM/Event/Form/EventFees.php
CRM/Member/Form.php

index c3b971d3d3b179abb676480c90d7894f1e1a9ad2..f2655045d1ef05aa4baa979237d96a869ac61a3c 100644 (file)
@@ -625,7 +625,7 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
         $this->assignBillingType();
 
         $this->_fields = array();
-        CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor);
+        CRM_Core_Payment_Form::setPaymentFieldsByProcessor($this, $this->_paymentProcessor, FALSE, TRUE);
       }
     }
     catch (CRM_Core_Exception $e) {
index ff5d5ea764715ddaf7574f4d80f9f23afad792b3..f53eee5ebe3584144acde197df5e6c64cf0f1aa0 100644 (file)
@@ -248,7 +248,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
           'id' => $type,
         );
 
-        CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE);
+        CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
 
         $qfKey = $this->controller->_key;
         $this->assign('qfKey', $qfKey);
index e77e62ff4d932a2ca899d7dc8f2c79f186867492..d31899abafa981187bd7e934baf25c1e28189e79 100644 (file)
@@ -575,7 +575,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     $billingPanes = array();
     if ($this->_mode) {
-      if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE) == TRUE) {
+      if (CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE) == TRUE) {
         $buildRecurBlock = TRUE;
         foreach ($this->billingPane as $name => $label) {
           if (!empty($this->billingFieldSets[$name]['fields'])) {
index ae33a8a464d501a724a204da6deb75d41dafa6e3..b3dbaa80814ab046db5f19d7d97cba688e8c6324 100644 (file)
@@ -213,7 +213,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Core_Form {
       )
     );
 
-    CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor['object'], TRUE);
+    CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor['object'], TRUE, TRUE);
     $this->addFormRule(array('CRM_Contribute_Form_UpdateBilling', 'formRule'), $this);
   }
 
index 865fa196db96a5d52ba5aa0151d639012884957d..71d1c9ff1426e3b4dbb56c3895ff29f93e73e9cc 100644 (file)
@@ -49,12 +49,19 @@ class CRM_Core_Payment_Form {
    *   Array of properties including 'object' as loaded from CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors.
    * @param bool $forceBillingFieldsForPayLater
    *   Display billing fields even for pay later.
+   * @param bool $isBackOffice
+   *   Is this a back office function? If so the option to suppress the cvn needs to be evaluated.
    */
-  static public function setPaymentFieldsByProcessor(&$form, $processor, $forceBillingFieldsForPayLater = FALSE) {
+  static public function setPaymentFieldsByProcessor(&$form, $processor, $forceBillingFieldsForPayLater = FALSE, $isBackOffice = FALSE) {
     $form->billingFieldSets = array();
     if ($processor != NULL) {
       // ie it is pay later
       $paymentFields = self::getPaymentFields($processor);
+      if (in_array('cvv2', $paymentFields) && $isBackOffice) {
+        if (!civicrm_api3('setting', 'getvalue', array('name' => 'cvv_backoffice_required', 'group' => 'Contribute Preferences'))) {
+          unset($paymentFields[array_search('cvv2', $paymentFields)]);
+        }
+      }
       $paymentTypeName = self::getPaymentTypeName($processor);
       $paymentTypeLabel = self::getPaymentTypeLabel($processor);
       //@todo if we switch to iterating through $form->billingFieldSets we won't need to assign these directly
@@ -254,7 +261,7 @@ class CRM_Core_Payment_Form {
    *
    * @return bool
    */
-  public static function buildPaymentForm(&$form, $processor, $isBillingDataOptional) {
+  public static function buildPaymentForm(&$form, $processor, $isBillingDataOptional, $isBackOffice) {
     //if the form has address fields assign to the template so the js can decide what billing fields to show
     $profileAddressFields = $form->get('profileAddressFields');
     if (!empty($profileAddressFields)) {
@@ -268,7 +275,7 @@ class CRM_Core_Payment_Form {
       return NULL;
     }
 
-    self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional));
+    self::setPaymentFieldsByProcessor($form, $processor, empty($isBillingDataOptional), $isBackOffice);
     self::addCommonFields($form, !$isBillingDataOptional, $form->_paymentFields);
     self::addRules($form, $form->_paymentFields);
     self::addPaypalExpressCode($form);
index 9e9f33660f5e45d13f62a4747afb7a8165b02039..97345f3554d7992d15302908b7c784e0b830f747 100644 (file)
@@ -111,7 +111,7 @@ class CRM_Core_Payment_ProcessorForm {
     if (!empty($form->_paymentProcessorID)) {
       $form->addElement('hidden', 'hidden_processor', 1);
     }
-    CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, empty($form->_isBillingAddressRequiredForPayLater));
+    CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, empty($form->_isBillingAddressRequiredForPayLater), FALSE);
   }
 
 }
index b646e1290946cc57e69828c4ff64326448324630..25249270f32c74c084b3246caf01382341412d2e 100644 (file)
@@ -160,7 +160,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
     $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($payment_processor_id, $this->_mode);
     $this->assign('paymentProcessor', $this->_paymentProcessor);
 
-    CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE);
+    CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, FALSE);
 
     if ($can_pay_later || self::is_administrator()) {
       $this->addElement('checkbox', 'is_pay_later',
index 5ac257e2a6d5739832def2bcaef0f7a67dd07f09..498e0df6d5359bcdba8d343b10280fc5f08821fd 100644 (file)
@@ -412,7 +412,7 @@ SELECT  id, html_type
         }
       }
       if ($form->_mode) {
-        CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE);
+        CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE, TRUE);
       }
       elseif (!$form->_mode) {
         $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL,
index 72c1bdcadcfbb7edacd6fd6192156c84ad210c35..28295d2f7a7356f9ac83d8e93e02e7ef612a6500 100644 (file)
@@ -129,7 +129,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment {
         $this->_processors, TRUE,
         array('onChange' => "buildAutoRenew( null, this.value );")
       );
-      CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE);
+      CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE);
     }
     if ($this->_action & CRM_Core_Action::RENEW) {
       $this->addButtons(array(