From e0d197576aca00b8db88fa96835c82674df861ed Mon Sep 17 00:00:00 2001 From: Web Access Date: Thu, 18 Jun 2015 11:36:06 +0530 Subject: [PATCH] Fix for CRM-16691 --- CRM/Admin/Form/Preferences/Contribute.php | 39 +++++++++++++++++++++++ CRM/Admin/Form/Setting/Url.php | 1 - templates/CRM/Admin/Form/Setting/Url.tpl | 7 ---- templates/CRM/Form/basicForm.tpl | 16 ++++++++-- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index b54e9dd821..7c1ec68306 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -38,6 +38,9 @@ * */ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { + protected $_settings = array( + 'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, + ); /** * Process the form submission. * @@ -122,6 +125,27 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { * @return void */ public function buildQuickForm() { + //CRM-16691: Changes made related to settings of 'CVV'. + foreach ($this->_settings as $setting => $group) { + $settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting)); + $props = $settingMetaData['values'][$setting]; + if (isset($props['quick_form_type'])) { + $add = 'add' . $props['quick_form_type']; + if ($add == 'addElement') { + $this->$add( + $props['html_type'], + $setting, + ts($props['title']), + CRM_Utils_Array::value($props['html_type'] == 'select' ? 'option_values' : 'html_attributes', $props, array()), + $props['html_type'] == 'select' ? CRM_Utils_Array::value('html_attributes', $props) : NULL + ); + } + else { + $this->$add($setting, ts($props['title'])); + } + } + $this->assign("{$setting}_description", ts($props['description'])); + } $this->add('checkbox', 'invoicing', ts('Enable Tax and Invoicing')); parent::buildQuickForm(); } @@ -135,6 +159,17 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { */ public function setDefaultValues() { $defaults = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings'); + //CRM-16691: Changes made related to settings of 'CVV'. + foreach ($this->_settings as $setting => $group) { + $settingMetaData = civicrm_api3('setting', 'getfields', array('name' => $setting)); + $defaults[$setting] = civicrm_api3('setting', 'getvalue', + array( + 'name' => $setting, + 'group' => $group, + 'default_value' => CRM_Utils_Array::value('default', $settingMetaData['values'][$setting]), + ) + ); + } return $defaults; } @@ -173,6 +208,10 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { CRM_Core_DAO::VALUE_SEPARATOR; CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options'); } + //CRM-16691: Changes made related to settings of 'CVV'. + $settings = array_intersect_key($params, $this->_settings); + $result = civicrm_api3('setting', 'create', $settings); + CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success"); } } diff --git a/CRM/Admin/Form/Setting/Url.php b/CRM/Admin/Form/Setting/Url.php index d8d64ec7e9..28e1f108ca 100644 --- a/CRM/Admin/Form/Setting/Url.php +++ b/CRM/Admin/Form/Setting/Url.php @@ -39,7 +39,6 @@ */ class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting { protected $_settings = array( - 'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'disable_core_css' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ); diff --git a/templates/CRM/Admin/Form/Setting/Url.tpl b/templates/CRM/Admin/Form/Setting/Url.tpl index da4eea6a7b..20b610476f 100644 --- a/templates/CRM/Admin/Form/Setting/Url.tpl +++ b/templates/CRM/Admin/Form/Setting/Url.tpl @@ -87,13 +87,6 @@

{ts}{$verifySSL_description}{/ts}

- - {$form.cvv_backoffice_required.label} - - {$form.cvv_backoffice_required.html}
-

{ts}{$cvv_backoffice_required_description}{/ts}

- -
{include file="CRM/common/formButtons.tpl" location="bottom"}
diff --git a/templates/CRM/Form/basicForm.tpl b/templates/CRM/Form/basicForm.tpl index 274fd99c20..62eaafb89d 100644 --- a/templates/CRM/Form/basicForm.tpl +++ b/templates/CRM/Form/basicForm.tpl @@ -26,12 +26,22 @@
{include file="CRM/common/formButtons.tpl" location="top"}
{if $formName == "Contribute_Preferences" } - - +
+ + + {if $formName == "Contribute_Preferences" } + + + + + {/if}
{$form.cvv_backoffice_required.label} - {$form.invoicing.html} {$form.invoicing.label} + {$form.cvv_backoffice_required.html}
+

{ts}{$cvv_backoffice_required_description}{/ts}

{$form.invoicing.label} + {$form.invoicing.html} +
{/if} -- 2.25.1