Exemplo n.º 1
0
 function run($file)
 {
     $json = file_get_contents($file);
     $decodedContacts = json_decode($json);
     //migrate contact data
     $this->contact($decodedContacts->civicrm_contact);
     $this->email($decodedContacts->civicrm_email);
     $this->phone($decodedContacts->civicrm_phone);
     $this->address($decodedContacts->civicrm_address);
     $this->note($decodedContacts->civicrm_note);
     $this->relationship($decodedContacts->civicrm_relationship);
     $this->activity($decodedContacts->civicrm_activity, $decodedContacts->civicrm_activity_contact);
     $this->group($decodedContacts->civicrm_group, $decodedContacts->civicrm_group_contact);
     $this->tag($decodedContacts->civicrm_tag, $decodedContacts->civicrm_entity_tag);
     // clean up all caches etc
     CRM_Core_Config::clearDBCache();
 }
 public function postProcess()
 {
     if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) {
         $config = CRM_Core_Config::singleton();
         // cleanup templates_c directory
         $config->cleanup(1, FALSE);
         // clear all caches
         CRM_Core_Config::clearDBCache();
         CRM_Utils_System::flushCache();
         parent::rebuildMenu();
         CRM_Core_BAO_WordReplacement::rebuild();
         CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success");
     }
     if (!empty($_POST['_qf_UpdateConfigBackend_next_resetpaths'])) {
         $msg = CRM_Core_BAO_ConfigSetting::doSiteMove();
         CRM_Core_Session::setStatus($msg, ts("Success"), "success");
     }
     return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1'));
 }
Exemplo n.º 3
0
 /**
  * Import custom-data from an XML element
  *
  * @param SimpleXMLElement $xml
  * @return void
  */
 public function runXmlElement($xml)
 {
     $idMap = array('custom_group' => array(), 'option_group' => array());
     // first create option groups and values if any
     $this->optionGroups($xml, $idMap);
     $this->optionValues($xml, $idMap);
     $this->relationshipTypes($xml);
     $this->contributionTypes($xml);
     // now create custom groups
     $this->customGroups($xml, $idMap);
     $this->customFields($xml, $idMap);
     // now create profile groups
     $this->profileGroups($xml, $idMap);
     $this->profileFields($xml, $idMap);
     $this->profileJoins($xml, $idMap);
     //create DB Template String sample data
     $this->dbTemplateString($xml, $idMap);
     // clean up all caches etc
     CRM_Core_Config::clearDBCache();
 }
Exemplo n.º 4
0
 function run($file)
 {
     // read xml file
     $dom = DomDocument::load($file);
     $dom->xinclude();
     $xml = simplexml_import_dom($dom);
     $idMap = array('custom_group' => array(), 'option_group' => array());
     // first create option groups and values if any
     $this->optionGroups($xml, $idMap);
     $this->optionValues($xml, $idMap);
     $this->relationshipTypes($xml);
     $this->contributionTypes($xml);
     // now create custom groups
     $this->customGroups($xml, $idMap);
     $this->customFields($xml, $idMap);
     // now create profile groups
     $this->profileGroups($xml, $idMap);
     $this->profileFields($xml, $idMap);
     $this->profileJoins($xml, $idMap);
     //create DB Template String sample data
     $this->dbTemplateString($xml, $idMap);
     // clean up all caches etc
     CRM_Core_Config::clearDBCache();
 }
Exemplo n.º 5
0
function run()
{
    session_start();
    if (!array_key_exists('file', $_GET) || empty($_GET['file'])) {
        echo "Please send an input file to import<p>";
        exit;
    }
    require_once '../../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config = CRM_Core_Config::singleton();
    // this does not return on failure
    CRM_Utils_System::authenticateScript(true);
    $import = new bin_migrate_import();
    $import->run($_GET['file']);
    // clean up all caches etc
    CRM_Core_Config::clearDBCache();
    echo "Import Done!";
}
Exemplo n.º 6
0
 /**
  * Common Process.
  *
  * @todo Document what I do.
  *
  * @param array $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['contact_autocomplete_options'])) {
         Civi::settings()->set('contact_autocomplete_options', CRM_Utils_Array::implodePadded(array_keys($params['contact_autocomplete_options'])));
         unset($params['contact_autocomplete_options']);
     }
     // save autocomplete contact reference options
     if (!empty($params['contact_reference_options'])) {
         Civi::settings()->set('contact_reference_options', CRM_Utils_Array::implodePadded(array_keys($params['contact_reference_options'])));
         unset($params['contact_reference_options']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         civicrm_api3('setting', 'create', array('enable_components' => $params['enableComponents']));
         unset($params['enableComponents']);
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         Civi::settings()->set('verifySSL', $params['verifySSL']);
         unset($params['verifySSL']);
     }
     // force secure URLs
     if (isset($params['enableSSL'])) {
         Civi::settings()->set('enableSSL', $params['enableSSL']);
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         unset($params[$setting]);
     }
     if (!empty($result['error_message'])) {
         CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
     }
     //CRM_Core_BAO_ConfigSetting::create($params);
     $params = CRM_Core_BAO_ConfigSetting::filterSkipVars($params);
     if (!empty($params)) {
         CRM_Core_Error::fatal('Unrecognized setting. This may be a config field which has not been properly migrated to a setting. (' . implode(', ', array_keys($params)) . ')');
     }
     CRM_Core_Config::clearDBCache();
     CRM_Utils_System::flushCache();
     CRM_Core_Resources::singleton()->resetCacheCode();
     CRM_Core_Session::setStatus(" ", ts('Changes Saved'), "success");
 }
Exemplo n.º 7
0
    /**
     * @param array $defaultValues
     *
     * @return string
     * @throws Exception
     */
    public static function doSiteMove($defaultValues = array())
    {
        $moveStatus = ts('Beginning site move process...') . '<br />';
        // get the current and guessed values
        list($oldURL, $oldDir, $oldSiteName, $oldSiteRoot) = self::getConfigSettings();
        list($newURL, $newDir, $newSiteName, $newSiteRoot) = self::getBestGuessSettings();
        // retrieve these values from the argument list
        $variables = array('URL', 'Dir', 'SiteName', 'SiteRoot', 'Val_1', 'Val_2', 'Val_3');
        $states = array('old', 'new');
        foreach ($variables as $varSuffix) {
            foreach ($states as $state) {
                $var = "{$state}{$varSuffix}";
                if (!isset(${$var})) {
                    if (isset($defaultValues[$var])) {
                        ${$var} = $defaultValues[$var];
                    } else {
                        ${$var} = NULL;
                    }
                }
                ${$var} = CRM_Utils_Request::retrieve($var, 'String', CRM_Core_DAO::$_nullArray, FALSE, ${$var}, 'REQUEST');
            }
        }
        $from = $to = array();
        foreach ($variables as $varSuffix) {
            $oldVar = "old{$varSuffix}";
            $newVar = "new{$varSuffix}";
            //skip it if either is empty or both are exactly the same
            if (${$oldVar} && ${$newVar} && ${$oldVar} != ${$newVar}) {
                $from[] = ${$oldVar};
                $to[] = ${$newVar};
            }
        }
        $sql = "\nSELECT config_backend\nFROM   civicrm_domain\nWHERE  id = %1\n";
        $params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
        $configBackend = CRM_Core_DAO::singleValueQuery($sql, $params);
        if (!$configBackend) {
            CRM_Core_Error::fatal(ts('Returning early due to unexpected error - civicrm_domain.config_backend column value is NULL. Try visiting CiviCRM Home page.'));
        }
        $configBackend = unserialize($configBackend);
        $configBackend = str_replace($from, $to, $configBackend);
        $configBackend = serialize($configBackend);
        $sql = "\nUPDATE civicrm_domain\nSET    config_backend = %2\nWHERE  id = %1\n";
        $params[2] = array($configBackend, 'String');
        CRM_Core_DAO::executeQuery($sql, $params);
        // Apply the changes to civicrm_option_values
        $optionGroups = array('url_preferences', 'directory_preferences');
        foreach ($optionGroups as $option) {
            foreach ($variables as $varSuffix) {
                $oldVar = "old{$varSuffix}";
                $newVar = "new{$varSuffix}";
                $from = ${$oldVar};
                $to = ${$newVar};
                if ($from && $to && $from != $to) {
                    $sql = '
UPDATE civicrm_option_value
SET    value = REPLACE(value, %1, %2)
WHERE  option_group_id = (
  SELECT id
  FROM   civicrm_option_group
  WHERE  name = %3 )
';
                    $params = array(1 => array($from, 'String'), 2 => array($to, 'String'), 3 => array($option, 'String'));
                    CRM_Core_DAO::executeQuery($sql, $params);
                }
            }
        }
        $moveStatus .= ts('Directory and Resource URLs have been updated in the moved database to reflect current site location.') . '<br />';
        $config = CRM_Core_Config::singleton();
        // clear the template_c and upload directory also
        $config->cleanup(3, TRUE);
        $moveStatus .= ts('Template cache and upload directory have been cleared.') . '<br />';
        // clear all caches
        CRM_Core_Config::clearDBCache();
        $moveStatus .= ts('Database cache tables cleared.') . '<br />';
        $resetSessionTable = CRM_Utils_Request::retrieve('resetSessionTable', 'Boolean', CRM_Core_DAO::$_nullArray, FALSE, FALSE, 'REQUEST');
        if ($config->userSystem->is_drupal && $resetSessionTable) {
            db_query("DELETE FROM {sessions} WHERE 1");
            $moveStatus .= ts('Drupal session table cleared.') . '<br />';
        } else {
            $session = CRM_Core_Session::singleton();
            $session->reset(2);
            $moveStatus .= ts('Session has been reset.') . '<br />';
        }
        return $moveStatus;
    }
Exemplo n.º 8
0
 /**
  * @param array $params
  *
  * @return mixed
  */
 public function membershipTypeCreate($params = array())
 {
     CRM_Member_PseudoConstant::flush('membershipType');
     CRM_Core_Config::clearDBCache();
     $this->setupIDs['contact'] = $memberOfOrganization = $this->organizationCreate();
     $params = array_merge(array('name' => 'General', 'duration_unit' => 'year', 'duration_interval' => 1, 'period_type' => 'rolling', 'member_of_contact_id' => $memberOfOrganization, 'domain_id' => 1, 'financial_type_id' => 2, 'is_active' => 1, 'sequential' => 1, 'visibility' => 'Public'), $params);
     $result = $this->callAPISuccess('MembershipType', 'Create', $params);
     CRM_Member_PseudoConstant::flush('membershipType');
     CRM_Utils_Cache::singleton()->flush();
     return $result['id'];
 }
Exemplo n.º 9
0
 /**
  * Common Process.
  *
  * @todo Document what I do.
  *
  * @param array $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['autocompleteContactSearch'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         unset($params['autocompleteContactSearch']);
     }
     // save autocomplete contact reference options
     if (!empty($params['autocompleteContactReference'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         unset($params['autocompleteContactReference']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         civicrm_api3('setting', 'create', array('enable_components' => $params['enableComponents']));
         unset($params['enableComponents']);
     }
     // save checksum timeout
     if (!empty($params['checksumTimeout'])) {
         CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
     }
     // update time for date formats when global time is changed
     if (!empty($params['timeInputFormat'])) {
         $query = "\nUPDATE civicrm_preferences_date\nSET    time_format = %1\nWHERE  time_format IS NOT NULL\nAND    time_format <> ''\n";
         $sqlParams = array(1 => array($params['timeInputFormat'], 'String'));
         CRM_Core_DAO::executeQuery($query, $sqlParams);
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, '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');
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         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");
 }
Exemplo n.º 10
0
/**
 * This api cleans up all the old session entries and temp tables.
 *
 * We recommend that sites run this on an hourly basis.
 *
 * @param array $params
 *   Sends in various config parameters to decide what needs to be cleaned.
 */
function civicrm_api3_job_cleanup($params)
{
    $session = CRM_Utils_Array::value('session', $params, TRUE);
    $tempTable = CRM_Utils_Array::value('tempTables', $params, TRUE);
    $jobLog = CRM_Utils_Array::value('jobLog', $params, TRUE);
    $prevNext = CRM_Utils_Array::value('prevNext', $params, TRUE);
    $dbCache = CRM_Utils_Array::value('dbCache', $params, FALSE);
    $memCache = CRM_Utils_Array::value('memCache', $params, FALSE);
    $tplCache = CRM_Utils_Array::value('tplCache', $params, FALSE);
    $wordRplc = CRM_Utils_Array::value('wordRplc', $params, FALSE);
    if ($session || $tempTable || $prevNext) {
        CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext);
    }
    if ($jobLog) {
        CRM_Core_BAO_Job::cleanup();
    }
    if ($tplCache) {
        $config = CRM_Core_Config::singleton();
        $config->cleanup(1, FALSE);
    }
    if ($dbCache) {
        CRM_Core_Config::clearDBCache();
    }
    if ($memCache) {
        CRM_Utils_System::flushCache();
    }
    if ($wordRplc) {
        CRM_Core_BAO_WordReplacement::rebuild();
    }
}
Exemplo n.º 11
0
 /**
  * Common Process.
  *
  * @todo Document what I do.
  *
  * @param array $params
  */
 public function commonProcess(&$params)
 {
     // save autocomplete search options
     if (!empty($params['autocompleteContactSearch'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactSearch'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options');
         unset($params['autocompleteContactSearch']);
     }
     // save autocomplete contact reference options
     if (!empty($params['autocompleteContactReference'])) {
         $value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($params['autocompleteContactReference'])) . CRM_Core_DAO::VALUE_SEPARATOR;
         CRM_Core_BAO_Setting::setItem($value, CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_reference_options');
         unset($params['autocompleteContactReference']);
     }
     // save components to be enabled
     if (array_key_exists('enableComponents', $params)) {
         civicrm_api3('setting', 'create', array('enable_components' => $params['enableComponents']));
         unset($params['enableComponents']);
     }
     // save checksum timeout
     if (!empty($params['checksumTimeout'])) {
         CRM_Core_BAO_Setting::setItem($params['checksumTimeout'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'checksum_timeout');
     }
     // verify ssl peer option
     if (isset($params['verifySSL'])) {
         CRM_Core_BAO_Setting::setItem($params['verifySSL'], CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, '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');
         unset($params['enableSSL']);
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
     foreach ($settings as $setting => $settingGroup) {
         //@todo array_diff this
         unset($params[$setting]);
     }
     if (!empty($result['error_message'])) {
         CRM_Core_Session::setStatus($result['error_message'], ts('Save Failed'), 'error');
     }
     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");
 }
Exemplo n.º 12
0
/**
 * This api cleans up all the old session entries and temp tables. We recommend that sites run this on an hourly basis
 *
 * @param  array    $params (reference ) - sends in various config parameters to decide what needs to be cleaned
 *
 * @return boolean  true if success, else false
 * @static void
 * @access public
 */
function civicrm_api3_job_cleanup($params)
{
    $session = CRM_Utils_Array::value('session', $params, true);
    $tempTable = CRM_Utils_Array::value('tempTables', $params, true);
    $jobLog = CRM_Utils_Array::value('jobLog', $params, true);
    $prevNext = CRM_Utils_Array::value('prevNext', $params, true);
    $dbCache = CRM_Utils_Array::value('dbCache', $params, false);
    $memCache = CRM_Utils_Array::value('memCache', $params, false);
    if ($session || $tempTable || $prevNext) {
        CRM_Core_BAO_Cache::cleanup($session, $tempTable, $prevNext);
    }
    if ($jobLog) {
        CRM_Core_BAO_Job::cleanup();
    }
    if ($dbCache) {
        CRM_Core_Config::clearDBCache();
    }
    if ($memCache) {
        CRM_Utils_System::flushCache();
    }
}
Exemplo n.º 13
0
 /**
  * @param array $defaultValues
  *
  * @return string
  * @throws Exception
  */
 public static function doSiteMove($defaultValues = array())
 {
     $moveStatus = ts('Beginning site move process...') . '<br />';
     $settings = Civi::settings();
     foreach (array_merge(self::getPathSettings(), self::getUrlSettings()) as $key) {
         $value = $settings->get($key);
         if ($value && $value != $settings->getDefault($key)) {
             if ($settings->getMandatory($key) === NULL) {
                 $settings->revert($key);
                 $moveStatus .= ts("WARNING: The setting (%1) has been reverted.", array(1 => $key));
                 $moveStatus .= '<br />';
             } else {
                 $moveStatus .= ts("WARNING: The setting (%1) is overridden and could not be reverted.", array(1 => $key));
                 $moveStatus .= '<br />';
             }
         }
     }
     $config = CRM_Core_Config::singleton();
     // clear the template_c and upload directory also
     $config->cleanup(3, TRUE);
     $moveStatus .= ts('Template cache and upload directory have been cleared.') . '<br />';
     // clear all caches
     CRM_Core_Config::clearDBCache();
     $moveStatus .= ts('Database cache tables cleared.') . '<br />';
     $resetSessionTable = CRM_Utils_Request::retrieve('resetSessionTable', 'Boolean', CRM_Core_DAO::$_nullArray, FALSE, FALSE, 'REQUEST');
     if ($config->userSystem->is_drupal && $resetSessionTable) {
         db_query("DELETE FROM {sessions} WHERE 1");
         $moveStatus .= ts('Drupal session table cleared.') . '<br />';
     } else {
         $session = CRM_Core_Session::singleton();
         $session->reset(2);
         $moveStatus .= ts('Session has been reset.') . '<br />';
     }
     return $moveStatus;
 }
 function postProcess()
 {
     if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) {
         $config = CRM_Core_Config::singleton();
         // cleanup templates_c directory
         $config->cleanup(1, FALSE);
         // clear db caching
         CRM_Core_Config::clearDBCache();
         parent::rebuildMenu();
         CRM_Core_BAO_WordReplacement::rebuild();
         CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success");
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1'));
     }
     // redirect to admin page after saving
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin'));
     $params = $this->controller->exportValues($this->_name);
     //CRM-5679
     foreach ($params as $name => &$val) {
         if ($val && in_array($name, array('newBaseURL', 'newBaseDir', 'newSiteName'))) {
             $val = CRM_Utils_File::addTrailingSlash($val);
         }
     }
     $from = array($this->_oldBaseURL, $this->_oldBaseDir);
     $to = array(trim($params['newBaseURL']), trim($params['newBaseDir']));
     if ($this->_oldSiteName && $params['newSiteName']) {
         $from[] = $this->_oldSiteName;
         $to[] = $params['newSiteName'];
     }
     $newValues = str_replace($from, $to, $this->_defaults);
     parent::commonProcess($newValues);
     parent::rebuildMenu();
 }
Exemplo n.º 15
0
 static function doSiteMove()
 {
     // get the current and guessed values
     list($oldURL, $oldDir, $oldSiteName) = self::getConfigSettings();
     list($newURL, $newDir, $newSiteName) = self::getBestGuessSettings();
     require_once 'CRM/Utils/Request.php';
     // retrieve these values from the argument list
     $variables = array('URL', 'Dir', 'SiteName', 'Val_1', 'Val_2', 'Val_3');
     $states = array('old', 'new');
     foreach ($variables as $varSuffix) {
         foreach ($states as $state) {
             $var = "{$state}{$varSuffix}";
             if (!isset(${$var})) {
                 ${$var} = null;
             }
             ${$var} = CRM_Utils_Request::retrieve($var, 'String', CRM_Core_DAO::$_nullArray, false, ${$var}, 'REQUEST');
         }
     }
     $from = $to = array();
     foreach ($variables as $varSuffix) {
         $oldVar = "old{$varSuffix}";
         $newVar = "new{$varSuffix}";
         if (${$oldVar} && ${$newVar}) {
             $from[] = ${$oldVar};
             $to[] = ${$newVar};
         }
     }
     $sql = "\nSELECT config_backend\nFROM   civicrm_domain\nWHERE  id = %1\n";
     $params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
     $configBackend = CRM_Core_DAO::singleValueQuery($sql, $params);
     if (!$configBackend) {
         CRM_Core_Error::fatal();
     }
     $configBackend = unserialize($configBackend);
     $configBackend = str_replace($from, $to, $configBackend);
     $configBackend = serialize($configBackend);
     $sql = "\nUPDATE civicrm_domain\nSET    config_backend = %2\nWHERE  id = %1\n";
     $params[2] = array($configBackend, 'String');
     CRM_Core_DAO::executeQuery($sql, $params);
     $config =& CRM_Core_Config::singleton();
     // clear the template_c and upload directory also
     $config->cleanup(3, true);
     // clear all caches
     CRM_Core_Config::clearDBCache();
     $resetSessionTable = CRM_Utils_Request::retrieve('resetSessionTable', 'Boolean', CRM_Core_DAO::$_nullArray, false, false, 'REQUEST');
     if ($config->userFramework == 'Drupal' && $resetSessionTable) {
         db_query("DELETE FROM {sessions} WHERE 1");
     } else {
         $session =& CRM_Core_Session::singleton();
         $session->reset(2);
     }
 }