Fix for CRM-16691
authorWeb Access <rohan.katkar@webaccessglobal.com>
Thu, 18 Jun 2015 06:06:06 +0000 (11:36 +0530)
committerWeb Access <rohan.katkar@webaccessglobal.com>
Thu, 18 Jun 2015 06:06:06 +0000 (11:36 +0530)
CRM/Admin/Form/Preferences/Contribute.php
CRM/Admin/Form/Setting/Url.php
templates/CRM/Admin/Form/Setting/Url.tpl
templates/CRM/Form/basicForm.tpl

index b54e9dd8210b9e1e9d22e19eb298b031b3a04ab9..7c1ec683069589df0c875ee19f6286b59f084efc 100644 (file)
@@ -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");
   }
 
 }
index d8d64ec7e9070ccead72ee94e1c63f3c72b61444..28e1f108cacb9e708bcf8d0c0720aeb2ca388e8e 100644 (file)
@@ -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,
   );
 
index da4eea6a7bd6455868cdf99de4927f59aa2c8e12..20b610476f677ab43dfa53cc682acb5dee72f091 100644 (file)
             <p class="description font-red">{ts}{$verifySSL_description}{/ts}</p>
         </td>
     </tr>
-    <tr class="crm-miscellaneous-form-block-cvv-backoffice-required">
-          <td class="label">{$form.cvv_backoffice_required.label}</td>
-          <td>
-            {$form.cvv_backoffice_required.html}<br />
-            <p class="description">{ts}{$cvv_backoffice_required_description}{/ts}</p>
-          </td>
-        </tr>
 </table>
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
index 274fd99c208972c21c9260b9201b9e9a587cfcfb..62eaafb89d4bfd96193aeb6e349ca972f436b2f4 100644 (file)
 <div class="crm-block crm-form-block crm-{$formName}-block">
     <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
     {if $formName == "Contribute_Preferences" }
-      <table class="form-layout">
-        <tr class="crm-preferences-form-block-invoicing">
+      <table class = "form-layout">
+        <tr class="crm-miscellaneous-form-block-cvv-backoffice-required">
+          <td class="label">{$form.cvv_backoffice_required.label}</td>
           <td>
-            {$form.invoicing.html} {$form.invoicing.label}
+            {$form.cvv_backoffice_required.html}<br />
+            <p class="description">{ts}{$cvv_backoffice_required_description}{/ts}</p>
           </td>
         </tr>
+        {if $formName == "Contribute_Preferences" }
+          <tr class="crm-preferences-form-block-invoicing">
+            <td class="label">{$form.invoicing.label}</td>
+            <td>
+              {$form.invoicing.html}
+            </td>
+          </tr>
+        {/if}
       </table>
     {/if}
     <table class="form-layout" id="invoicing_blocks">