CRM-17507 - Cleanup settings setItem calls
authorColeman Watts <coleman@civicrm.org>
Mon, 7 Dec 2015 03:29:07 +0000 (22:29 -0500)
committerColeman Watts <coleman@civicrm.org>
Mon, 7 Dec 2015 03:34:06 +0000 (22:34 -0500)
CRM/Admin/Form/Preferences.php
CRM/Admin/Form/Preferences/Contribute.php
CRM/Admin/Form/Preferences/Mailing.php
CRM/Admin/Form/Setting.php
CRM/Admin/Form/Setting/Smtp.php
CRM/Core/Resources.php
CRM/Upgrade/Incremental/php/FourSeven.php
tests/phpunit/CRM/Core/BAO/SettingTest.php
tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php
tests/phpunit/CiviTest/CiviMailUtils.php
tests/phpunit/api/v3/TaxContributionPageTest.php

index d8e19ec4c80990b5ea3951680df90f185db02007..6b35849c9fada9e0f85adff8581700c6a0c3ec5b 100644 (file)
@@ -288,10 +288,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form {
     foreach ($this->_varNames as $groupName => $groupValues) {
       foreach ($groupValues as $settingName => $fieldValue) {
         $settingValue = isset($this->_config->$settingName) ? $this->_config->$settingName : NULL;
-        CRM_Core_BAO_Setting::setItem($settingValue,
-          $groupName,
-          $settingName
-        );
+        Civi::settings()->set($settingName, $settingValue);
       }
     }
     // Update any settings stored in dynamic js
index 0a5513cbd2b051261b22f9d7523d877f28a12e95..d3b1fc8c7982632f758804be2b2fbdfeb29efb47 100644 (file)
@@ -173,7 +173,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
     $params = $this->controller->exportValues($this->_name);
     unset($params['qfKey']);
     unset($params['entryURL']);
-    $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($params, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+    Civi::settings()->set('contribution_invoice_settings', $params);
 
     // to set default value for 'Invoices / Credit Notes' checkbox on display preferences
     $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences");
@@ -185,8 +185,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
       $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR .
         implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) .
         CRM_Core_DAO::VALUE_SEPARATOR;
-      CRM_Core_BAO_Setting::setItem($values['user_dashboard_options'] .
-        $setInvoice, 'CiviCRM Preferences', 'user_dashboard_options');
+      Civi::settings()->set('user_dashboard_options', $values['user_dashboard_options'] . $setInvoice);
     }
     else {
       $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1));
@@ -195,7 +194,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences {
       $settingName = CRM_Core_DAO::VALUE_SEPARATOR .
         implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) .
         CRM_Core_DAO::VALUE_SEPARATOR;
-      CRM_Core_BAO_Setting::setItem($settingName, 'CiviCRM Preferences', 'user_dashboard_options');
+      Civi::settings()->set('user_dashboard_options', $settingName);
     }
     //CRM-16691: Changes made related to settings of 'CVV'.
     $settings = array_intersect_key($params, $this->_settings);
index 63bdb2072a244ce467cd9dfd144dd25d8ae75c72..1c41c07922e9ad546d30ac190bbee18577b1d341 100644 (file)
@@ -127,7 +127,7 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences {
       if (!in_array($displayValue, $viewOptions)) {
         $existingViewOptions .= $displayValue . CRM_Core_DAO::VALUE_SEPARATOR;
 
-        CRM_Core_BAO_Setting::setItem($existingViewOptions, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options');
+        Civi::settings()->set('contact_view_options', $existingViewOptions);
         CRM_Core_Session::setStatus(ts('We have automatically enabled the Mailings tab for the Contact Summary screens
         so that you can view mailings sent to each contact.'), ts('Saved'), 'success');
       }
index 90b494806d31d690bc67452078692f9f5cf8b1a8..e1b743caade23df15400e02b37eecfba52f9fabd 100644 (file)
@@ -200,19 +200,13 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
-      CRM_Core_BAO_Setting::setItem($params['verifySSL'],
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-        'verifySSL'
-      );
+      Civi::settings()->set('verifySSL', $params['verifySSL']);
       unset($params['verifySSL']);
     }
 
     // force secure URLs
     if (isset($params['enableSSL'])) {
-      CRM_Core_BAO_Setting::setItem($params['enableSSL'],
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
-        'enableSSL'
-      );
+      Civi::settings()->set('enableSSL', $params['enableSSL']);
       unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
index 1eb9661009dd694e4eb6bfadb7f8ef2bcb2b5998..84272a9583dacc0071ea3de16a96c8098e0e0e2c 100644 (file)
@@ -187,10 +187,7 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
       $formValues['smtpPassword'] = CRM_Utils_Crypt::encrypt($formValues['smtpPassword']);
     }
 
-    CRM_Core_BAO_Setting::setItem($formValues,
-      CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-      'mailing_backend'
-    );
+    Civi::settings()->set('mailing_backend', $formValues);
   }
 
   /**
index 08d6f05a0986982134675cb10faa6e106810e505..b9ff1e7f3ce77f72a046c6a265ad4f5e16cf9072 100644 (file)
@@ -557,7 +557,7 @@ class CRM_Core_Resources {
   public function setCacheCode($value) {
     $this->cacheCode = $value;
     if ($this->cacheCodeKey) {
-      CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $this->cacheCodeKey);
+      Civi::settings()->set($this->cacheCodeKey, $value);
     }
     return $this;
   }
index d9c9b411a2e3d1e82cee3306c03f19c1ce189f5c..90112b35c6d93bae515a7a0d732360071a76280d 100644 (file)
@@ -134,7 +134,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
     // Previously a numeric value indicated one of 4 wysiwyg editors shipped in core, and no value indicated 'Textarea'
     // Now the options are "Textarea", "CKEditor", and the rest have been dropped from core.
     $newEditor = $editorID ? "CKEditor" : "Textarea";
-    CRM_Core_BAO_Setting::setItem($newEditor, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'editor_id');
+    Civi::settings()->set('editor_id', $newEditor);
 
     return $editorID;
   }
index 48f140d5b8f7061e9c8a06adab337291f20c01bf..aeb3a040fac6b118d9457653f93ff59059f90f1e 100644 (file)
@@ -87,7 +87,7 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
     Civi::service('settings_manager')->useMandatory();
     $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
     $this->assertEquals('/test/override', $values['overrideSetting']);
-    CRM_Core_BAO_Setting::setItem('/test/database', 'Test Preferences', 'databaseSetting');
+    Civi::settings()->set('databaseSetting', '/test/database');
     $values = CRM_Core_BAO_Setting::getItem('Test Preferences');
     $this->assertEquals('/test/override', $values['overrideSetting']);
     $this->assertEquals('/test/database', $values['databaseSetting']);
@@ -153,22 +153,14 @@ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase {
 
     // set initial value
     $_testOnChange_hookCalls = array('count' => 0);
-    CRM_Core_BAO_Setting::setItem(
-      array('First', 'Value'),
-      'CiviCRM Preferences',
-      'onChangeExample'
-    );
+    Civi::settings()->set('onChangeExample', array('First', 'Value'));
     $this->assertEquals(1, $_testOnChange_hookCalls['count']);
     $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['newValue']);
     $this->assertEquals('List of Components', $_testOnChange_hookCalls['metadata']['title']);
 
     // change value
     $_testOnChange_hookCalls = array('count' => 0);
-    CRM_Core_BAO_Setting::setItem(
-      array('Second', 'Value'),
-      'CiviCRM Preferences',
-      'onChangeExample'
-    );
+    Civi::settings()->set('onChangeExample', array('Second', 'Value'));
     $this->assertEquals(1, $_testOnChange_hookCalls['count']);
     $this->assertEquals(array('First', 'Value'), $_testOnChange_hookCalls['oldValue']);
     $this->assertEquals(array('Second', 'Value'), $_testOnChange_hookCalls['newValue']);
index c766c4049992f03d026c91e4efd9e992ed198589..6803db78b936a3d70ef3eecf8bf0324dfd107bd3 100644 (file)
@@ -165,10 +165,10 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     );
 
     // turn verifySSL off
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
     $this->doPayment($params);
     // turn verifySSL on
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
 
     // if subscription was successful, processor_id / subscription-id must not be null
     $this->assertDBNotNull('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id',
@@ -306,10 +306,10 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     $smarty->assign('subscriptionType', 'create');
 
     // turn verifySSL off
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
     $this->doPayment($params);
     // turn verifySSL on
-    CRM_Core_BAO_Setting::setItem('0', CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL');
+    Civi::settings()->set('verifySSL', '0');
 
     // if subscription was successful, processor_id / subscription-id must not be null
     $this->assertDBNotNull('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id',
index ca3d7eb392ace7674676192cea11418a4a7bd09b..854974f18514c7e3c9b795fd9b04c164c11c6ab2 100644 (file)
@@ -106,10 +106,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
       $this->_outBound_option = $mailingBackend['outBound_option'];
       $mailingBackend['outBound_option'] = CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB;
 
-      CRM_Core_BAO_Setting::setItem($mailingBackend,
-        CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-        'mailing_backend'
-      );
+      Civi::settings()->set('mailing_backend', $mailingBackend);
 
       $mailingBackend = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
         'mailing_backend'
@@ -138,10 +135,7 @@ class CiviMailUtils extends PHPUnit_Framework_TestCase {
 
       $mailingBackend['outBound_option'] = $this->_outBound_option;
 
-      CRM_Core_BAO_Setting::setItem($mailingBackend,
-        CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME,
-        'mailing_backend'
-      );
+      Civi::settings()->set('mailing_backend', $mailingBackend);
     }
   }
 
index 51aab4e337f29a80db092b1877185539dd9c257f..90e48b54ae395f20384ca206ae67fb347c6cc0ce 100644 (file)
@@ -154,7 +154,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       'tax_term' => 'Sales Tax',
       'tax_display_settings' => 'Inclusive',
     );
-    $setInvoiceSettings = CRM_Core_BAO_Setting::setItem($contributeSetting, CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
+    $setInvoiceSettings = Civi::settings()->set('contribution_invoice_settings', $contributeSetting);
 
     // Payment Processor
     $paymentProceParams = array(