From: Eileen McNaughton Date: Wed, 27 May 2015 05:53:16 +0000 (+1200) Subject: CRM-16573 Back office supress back office cvn X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=dfc68e8280167c2b4096fae5ea84f3e410ffd880;p=civicrm-core.git CRM-16573 Back office supress back office cvn --- diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index c3b971d3d3..f2655045d1 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -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) { diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index ff5d5ea764..f53eee5ebe 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -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); diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index e77e62ff4d..d31899abaf 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -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'])) { diff --git a/CRM/Contribute/Form/UpdateBilling.php b/CRM/Contribute/Form/UpdateBilling.php index ae33a8a464..b3dbaa8081 100644 --- a/CRM/Contribute/Form/UpdateBilling.php +++ b/CRM/Contribute/Form/UpdateBilling.php @@ -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); } diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 865fa196db..71d1c9ff14 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -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); diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index 9e9f33660f..97345f3554 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -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); } } diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php index b646e12909..25249270f3 100644 --- a/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/CRM/Event/Cart/Form/Checkout/Payment.php @@ -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', diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index 5ac257e2a6..498e0df6d5 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -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, diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 72c1bdcadc..28295d2f7a 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -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(