Merge pull request #6058 from monishdeb/CRM-16575
[civicrm-core.git] / CRM / Admin / Form / Setting.php
index 6ab1d92e4646ac022b885414f83c47ebd9e34182..910e5f90d35ef8df960762b633f88b06399f60ab 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
  * $Id$
  */
 
@@ -85,11 +85,11 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
       //Set defaults for autocomplete and contact reference options
       $this->_defaults['autocompleteContactSearch'] = array(
-          '1' => 1,
-        ) + $autoSearchFields;
+        '1' => 1,
+      ) + $autoSearchFields;
       $this->_defaults['autocompleteContactReference'] = array(
-          '1' => 1,
-        ) + $cRSearchFields;
+        '1' => 1,
+      ) + $cRSearchFields;
 
       // we can handle all the ones defined in the metadata here. Others to be converted
       foreach ($this->_settings as $setting => $group) {
@@ -111,7 +111,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    */
   public function buildQuickForm() {
     $session = CRM_Core_Session::singleton();
@@ -173,6 +173,10 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
   }
 
   /**
+   * Common Process.
+   *
+   * @todo Document what I do.
+   *
    * @param array $params
    */
   public function commonProcess(&$params) {
@@ -207,12 +211,10 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
 
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
-      CRM_Core_BAO_Setting::setItem($params['enableComponents'],
-        CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
-
-      // unset params by emptying the values, so while retrieving we can detect and load from settings table
-      // instead of config-backend for backward compatibility. We could use unset() in later releases.
-      $params['enableComponents'] = $params['enableComponentIDs'] = array();
+      civicrm_api3('setting', 'create', array(
+        'enable_components' => $params['enableComponents'],
+      ));
+      unset($params['enableComponents']);
     }
 
     // save checksum timeout
@@ -259,6 +261,11 @@ AND    time_format <> ''
       unset($params[$setting]);
     }
     CRM_Core_BAO_ConfigSetting::create($params);
+
+    CRM_Core_Config::clearDBCache();
+    CRM_Utils_System::flushCache();
+    CRM_Core_Resources::singleton()->resetCacheCode();
+
     CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
   }
 
@@ -273,4 +280,5 @@ AND    time_format <> ''
     $configFile = $config->uploadDir . 'Config.IDS.ini';
     @unlink($configFile);
   }
+
 }