Merge pull request #5465 from colemanw/CRM-16163
[civicrm-core.git] / CRM / Core / BAO / ConfigSetting.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
06b69b18 4 | CiviCRM version 4.5 |
6a488035 5 +--------------------------------------------------------------------+
06b69b18 6 | Copyright CiviCRM LLC (c) 2004-2014 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 *
31 * @package CRM
06b69b18 32 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
33 * $Id$
34 *
35 */
36
37/**
38 * file contains functions used in civicrm configuration
39 *
40 */
41class CRM_Core_BAO_ConfigSetting {
42
43 /**
b597d0b1
DL
44 * Function to create civicrm settings. This is the same as add but it clears the cache and
45 * reloads the config object
6a488035
TO
46 *
47 * @params array $params associated array of civicrm variables
48 *
77b97be7
EM
49 * @param $params
50 *
6a488035
TO
51 * @return null
52 * @static
53 */
54 static function create($params) {
55 self::add($params);
56 $cache = CRM_Utils_Cache::singleton();
57 $cache->delete('CRM_Core_Config');
0e04f44e 58 $cache->delete('CRM_Core_Config' . CRM_Core_Config::domainID());
6a488035
TO
59 $config = CRM_Core_Config::singleton(TRUE, TRUE);
60 }
61
62 /**
63 * Function to add civicrm settings
64 *
65 * @params array $params associated array of civicrm variables
66 *
dd244018
EM
67 * @param $params
68 *
6a488035
TO
69 * @return null
70 * @static
71 */
72 static function add(&$params) {
73 self::fixParams($params);
74
75 // also set a template url so js files can use this
76 // CRM-6194
77 $params['civiRelativeURL'] = CRM_Utils_System::url('CIVI_BASE_TEMPLATE');
b597d0b1
DL
78 $params['civiRelativeURL'] =
79 str_replace(
80 'CIVI_BASE_TEMPLATE',
81 '',
6a488035
TO
82 $params['civiRelativeURL']
83 );
84
b597d0b1
DL
85 // also add the version number for use by template / js etc
86 $params['civiVersion'] = CRM_Utils_System::version();
87
6a488035
TO
88 $domain = new CRM_Core_DAO_Domain();
89 $domain->id = CRM_Core_Config::domainID();
90 $domain->find(TRUE);
91 if ($domain->config_backend) {
92 $values = unserialize($domain->config_backend);
93 self::formatParams($params, $values);
94 }
95
96 // CRM-6151
97 if (isset($params['localeCustomStrings']) &&
98 is_array($params['localeCustomStrings'])
99 ) {
100 $domain->locale_custom_strings = serialize($params['localeCustomStrings']);
101 }
102
103 // unset any of the variables we read from file that should not be stored in the database
104 // the username and certpath are stored flat with _test and _live
105 // check CRM-1470
106 $skipVars = self::skipVars();
107 foreach ($skipVars as $var) {
108 unset($params[$var]);
109 }
110
111 CRM_Core_BAO_Setting::fixAndStoreDirAndURL($params);
112
113 // also skip all Dir Params, we dont need to store those in the DB!
114 foreach ($params as $name => $val) {
115 if (substr($name, -3) == 'Dir') {
116 unset($params[$name]);
117 }
118 }
119
120 //keep user preferred language upto date, CRM-7746
121 $session = CRM_Core_Session::singleton();
122 $lcMessages = CRM_Utils_Array::value('lcMessages', $params);
123 if ($lcMessages && $session->get('userID')) {
124 $languageLimit = CRM_Utils_Array::value('languageLimit', $params);
125 if (is_array($languageLimit) &&
126 !in_array($lcMessages, array_keys($languageLimit))
127 ) {
128 $lcMessages = $session->get('lcMessages');
129 }
130
131 $ufm = new CRM_Core_DAO_UFMatch();
132 $ufm->contact_id = $session->get('userID');
133 if ($lcMessages && $ufm->find(TRUE)) {
134 $ufm->language = $lcMessages;
135 $ufm->save();
136 $session->set('lcMessages', $lcMessages);
137 $params['lcMessages'] = $lcMessages;
138 }
139 }
140
141 $domain->config_backend = serialize($params);
142 $domain->save();
143 }
144
145 /**
146 * Function to fix civicrm setting variables
147 *
148 * @params array $params associated array of civicrm variables
149 *
dd244018
EM
150 * @param $params
151 *
6a488035
TO
152 * @return null
153 * @static
154 */
155 static function fixParams(&$params) {
156 // in our old civicrm.settings.php we were using ISO code for country and
157 // province limit, now we have changed it to use ids
158
159 $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
160
161 $specialArray = array('countryLimit', 'provinceLimit');
162
163 foreach ($params as $key => $value) {
164 if (in_array($key, $specialArray) && is_array($value)) {
165 foreach ($value as $k => $val) {
166 if (!is_numeric($val)) {
167 $params[$key][$k] = array_search($val, $countryIsoCodes);
168 }
169 }
170 }
171 elseif ($key == 'defaultContactCountry') {
172 if (!is_numeric($value)) {
173 $params[$key] = array_search($value, $countryIsoCodes);
174 }
175 }
176 }
177 }
178
179 /**
180 * Function to format the array containing before inserting in db
181 *
182 * @param array $params associated array of civicrm variables(submitted)
183 * @param array $values associated array of civicrm variables stored in db
184 *
185 * @return null
186 * @static
187 */
188 static function formatParams(&$params, &$values) {
189 if (empty($params) ||
190 !is_array($params)
191 ) {
192 $params = $values;
193 }
194 else {
195 foreach ($params as $key => $val) {
196 if (array_key_exists($key, $values)) {
197 unset($values[$key]);
198 }
199 }
200 $params = array_merge($params, $values);
201 }
202 }
203
204 /**
205 * Function to retrieve the settings values from db
206 *
da6b46f4
EM
207 * @param $defaults
208 *
6a488035
TO
209 * @return array $defaults
210 * @static
211 */
212 static function retrieve(&$defaults) {
213 $domain = new CRM_Core_DAO_Domain();
214
215 //we are initializing config, really can't use, CRM-7863
216 $urlVar = 'q';
217 if (defined('CIVICRM_UF') && CIVICRM_UF == 'Joomla') {
218 $urlVar = 'task';
219 }
220
221 if (CRM_Core_Config::isUpgradeMode()) {
222 $domain->selectAdd('config_backend');
223 }
224 elseif (CRM_Utils_Array::value($urlVar, $_GET) == 'admin/modules/list/confirm') {
225 $domain->selectAdd('config_backend', 'locales');
226 }
227 else {
228 $domain->selectAdd('config_backend, locales, locale_custom_strings');
229 }
230
231 $domain->id = CRM_Core_Config::domainID();
232 $domain->find(TRUE);
233 if ($domain->config_backend) {
234 $defaults = unserialize($domain->config_backend);
235 if ($defaults === FALSE || !is_array($defaults)) {
236 $defaults = array();
237 return;
238 }
239
240 $skipVars = self::skipVars();
241 foreach ($skipVars as $skip) {
242 if (array_key_exists($skip, $defaults)) {
243 unset($defaults[$skip]);
244 }
245 }
246
6a488035
TO
247 // check if there are any locale strings
248 if ($domain->locale_custom_strings) {
249 $defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
250 }
251 else {
252 $defaults['localeCustomStrings'] = NULL;
253 }
254
255 // are we in a multi-language setup?
256 $multiLang = $domain->locales ? TRUE : FALSE;
257
258 // set the current language
259 $lcMessages = NULL;
260
261 $session = CRM_Core_Session::singleton();
262
263 // on multi-lang sites based on request and civicrm_uf_match
264 if ($multiLang) {
265 $lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
266 $languageLimit = array();
267 if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
268 $languageLimit = $defaults['languageLimit'];
269 }
270
271 if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
272 $lcMessages = $lcMessagesRequest;
273
274 //CRM-8559, cache navigation do not respect locale if it is changed, so reseting cache.
275 CRM_Core_BAO_Cache::deleteGroup('navigation');
276 }
277 else {
278 $lcMessagesRequest = NULL;
279 }
280
281 if (!$lcMessagesRequest) {
282 $lcMessagesSession = $session->get('lcMessages');
283 if (in_array($lcMessagesSession, array_keys($languageLimit))) {
284 $lcMessages = $lcMessagesSession;
285 }
286 else {
287 $lcMessagesSession = NULL;
288 }
289 }
290
291 if ($lcMessagesRequest) {
292 $ufm = new CRM_Core_DAO_UFMatch();
293 $ufm->contact_id = $session->get('userID');
294 if ($ufm->find(TRUE)) {
295 $ufm->language = $lcMessages;
296 $ufm->save();
297 }
298 $session->set('lcMessages', $lcMessages);
299 }
300
301 if (!$lcMessages and $session->get('userID')) {
302 $ufm = new CRM_Core_DAO_UFMatch();
303 $ufm->contact_id = $session->get('userID');
304 if ($ufm->find(TRUE) &&
305 in_array($ufm->language, array_keys($languageLimit))
306 ) {
307 $lcMessages = $ufm->language;
308 }
309 $session->set('lcMessages', $lcMessages);
310 }
311 }
312 global $dbLocale;
313
314 // try to inherit the language from the hosting CMS
a7488080 315 if (!empty($defaults['inheritLocale'])) {
6a488035
TO
316 // FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
317 $dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
318 $lcMessages = CRM_Utils_System::getUFLocale();
319 if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_DAO::VALUE_SEPARATOR,
320 $domain->locales
321 ))) {
322 $lcMessages = NULL;
323 }
324 }
325
326 if ($lcMessages) {
327 // update config lcMessages - CRM-5027 fixed.
328 $defaults['lcMessages'] = $lcMessages;
329 }
330 else {
331 // if a single-lang site or the above didn't yield a result, use default
332 $lcMessages = CRM_Utils_Array::value( 'lcMessages', $defaults );
333 }
334
335 // set suffix for table names - use views if more than one language
336 $dbLocale = $multiLang ? "_{$lcMessages}" : '';
337
338 // FIXME: an ugly hack to fix CRM-4041
339 global $tsLocale;
340 $tsLocale = $lcMessages;
341
342 // FIXME: as bad aplace as any to fix CRM-5428
343 // (to be moved to a sane location along with the above)
344 if (function_exists('mb_internal_encoding')) {
345 mb_internal_encoding('UTF-8');
346 }
347 }
348
349 // dont add if its empty
350 if (!empty($defaults)) {
351 // retrieve directory and url preferences also
352 CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($defaults);
3124edb3 353
2efcf0c2 354 // Pickup enabled-components from settings table if found.
4acb1c97
DS
355 $enableComponents = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
356 if (!empty($enableComponents)) {
357 $defaults['enableComponents'] = $enableComponents;
2efcf0c2 358
3124edb3
DS
359 $components = CRM_Core_Component::getComponents();
360 $enabledComponentIDs = array();
361 foreach ($defaults['enableComponents'] as $name) {
362 $enabledComponentIDs[] = $components[$name]->componentID;
363 }
364 $defaults['enableComponentIDs'] = $enabledComponentIDs;
365 }
6a488035
TO
366 }
367 }
368
b5c2afd0
EM
369 /**
370 * @return array
371 */
6a488035
TO
372 static function getConfigSettings() {
373 $config = CRM_Core_Config::singleton();
374
375 $url = $dir = $siteName = $siteRoot = NULL;
376 if ($config->userFramework == 'Joomla') {
e51744f5
DL
377 $url = preg_replace(
378 '|administrator/components/com_civicrm/civicrm/|',
6a488035
TO
379 '',
380 $config->userFrameworkResourceURL
381 );
382
383 // lets use imageUploadDir since we dont mess around with its values
384 // in the config object, lets kep it a bit generic since folks
385 // might have different values etc
37b395e8
DC
386
387 //CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
388 if(DIRECTORY_SEPARATOR == '\\')
389 {
390 $dir = preg_replace(
391 '|civicrm[/\\\\]templates_c[/\\\\].*$|',
392 '',
393 $config->templateCompileDir
394 );
395 }
396 else
397 {
398 $dir = preg_replace(
399 '|civicrm/templates_c/.*$|',
400 '',
401 $config->templateCompileDir
402 );
403 }
404
e51744f5
DL
405 $siteRoot = preg_replace(
406 '|/media/civicrm/.*$|',
407 '',
408 $config->imageUploadDir
409 );
410 }
411 else if ($config->userFramework == 'WordPress') {
412 $url = preg_replace(
413 '|wp-content/plugins/civicrm/civicrm/|',
414 '',
415 $config->userFrameworkResourceURL
416 );
417
418 // lets use imageUploadDir since we dont mess around with its values
419 // in the config object, lets kep it a bit generic since folks
420 // might have different values etc
37b395e8
DC
421
422 //CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
423 if(DIRECTORY_SEPARATOR == '\\')
424 {
425 $dir = preg_replace(
426 '|civicrm[/\\\\]templates_c[/\\\\].*$|',
427 '',
428 $config->templateCompileDir
429 );
430 }
431 else
432 {
433 $dir = preg_replace(
434 '|civicrm/templates_c/.*$|',
435 '',
436 $config->templateCompileDir
437 );
438 }
439
e51744f5
DL
440 $siteRoot = preg_replace(
441 '|/wp-content/plugins/files/civicrm/.*$|',
6a488035
TO
442 '',
443 $config->imageUploadDir
444 );
445 }
446 else {
e51744f5
DL
447 $url = preg_replace(
448 '|sites/[\w\.\-\_]+/modules/civicrm/|',
6a488035
TO
449 '',
450 $config->userFrameworkResourceURL
451 );
452
453 // lets use imageUploadDir since we dont mess around with its values
454 // in the config object, lets kep it a bit generic since folks
455 // might have different values etc
37b395e8
DC
456
457 //CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
458 if(DIRECTORY_SEPARATOR == '\\')
459 {
460 $dir = preg_replace(
461 '|[/\\\\]files[/\\\\]civicrm[/\\\\].*$|',
462 '\\\\files\\\\',
463 $config->imageUploadDir
464 );
465 }
466 else
467 {
468 $dir = preg_replace(
469 '|/files/civicrm/.*$|',
470 '/files/',
471 $config->imageUploadDir
472 );
473 }
474
6a488035 475 $matches = array();
e51744f5
DL
476 if (preg_match(
477 '|/sites/([\w\.\-\_]+)/|',
6a488035
TO
478 $config->imageUploadDir,
479 $matches
480 )) {
481 $siteName = $matches[1];
482 if ($siteName) {
483 $siteName = "/sites/$siteName/";
484 $siteNamePos = strpos($dir, $siteName);
485 if ($siteNamePos !== FALSE) {
486 $siteRoot = substr($dir, 0, $siteNamePos);
487 }
488 }
489 }
490 }
491
6a488035
TO
492 return array($url, $dir, $siteName, $siteRoot);
493 }
494
9977c6f5 495/**
496 * Return likely default settings
497 * @return array site settings
498 * -$url,
499 * - $dir Base Directory
500 * - $siteName
501 * - $siteRoot
502 */
6a488035
TO
503 static function getBestGuessSettings() {
504 $config = CRM_Core_Config::singleton();
37b395e8
DC
505
506 //CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
507 if(DIRECTORY_SEPARATOR == '\\')
508 $needle = 'civicrm[/\\\\]templates_c[/\\\\].*$';
509 else
510 $needle = 'civicrm/templates_c/.*$';
511
512 $dir = preg_replace(
513 "|$needle|",
6a488035
TO
514 '',
515 $config->templateCompileDir
516 );
517
9977c6f5 518 list($url, $siteName, $siteRoot) = $config->userSystem->getDefaultSiteSettings($dir);
6a488035
TO
519 return array($url, $dir, $siteName, $siteRoot);
520 }
521
b5c2afd0
EM
522 /**
523 * @param array $defaultValues
524 *
525 * @return string
526 * @throws Exception
527 */
6a488035
TO
528 static function doSiteMove($defaultValues = array() ) {
529 $moveStatus = ts('Beginning site move process...') . '<br />';
530 // get the current and guessed values
531 list($oldURL, $oldDir, $oldSiteName, $oldSiteRoot) = self::getConfigSettings();
532 list($newURL, $newDir, $newSiteName, $newSiteRoot) = self::getBestGuessSettings();
533
534
535 // retrieve these values from the argument list
536 $variables = array('URL', 'Dir', 'SiteName', 'SiteRoot', 'Val_1', 'Val_2', 'Val_3');
537 $states = array('old', 'new');
538 foreach ($variables as $varSuffix) {
539 foreach ($states as $state) {
540 $var = "{$state}{$varSuffix}";
541 if (!isset($$var)) {
542 if (isset($defaultValues[$var])) {
543 $$var = $defaultValues[$var];
544 }
545 else {
546 $$var = NULL;
547 }
548 }
549 $$var = CRM_Utils_Request::retrieve($var,
550 'String',
551 CRM_Core_DAO::$_nullArray,
552 FALSE,
553 $$var,
554 'REQUEST'
555 );
556 }
557 }
558
559 $from = $to = array();
560 foreach ($variables as $varSuffix) {
561 $oldVar = "old{$varSuffix}";
562 $newVar = "new{$varSuffix}";
563 //skip it if either is empty or both are exactly the same
564 if ($$oldVar &&
565 $$newVar &&
566 $$oldVar != $$newVar
567 ) {
568 $from[] = $$oldVar;
569 $to[] = $$newVar;
570 }
571 }
572
573 $sql = "
574SELECT config_backend
575FROM civicrm_domain
576WHERE id = %1
577";
578 $params = array(1 => array(CRM_Core_Config::domainID(), 'Integer'));
579 $configBackend = CRM_Core_DAO::singleValueQuery($sql, $params);
580 if (!$configBackend) {
581 CRM_Core_Error::fatal(ts('Returning early due to unexpected error - civicrm_domain.config_backend column value is NULL. Try visiting CiviCRM Home page.'));
582 }
583 $configBackend = unserialize($configBackend);
584
585 $configBackend = str_replace($from,
586 $to,
587 $configBackend
588 );
589
590 $configBackend = serialize($configBackend);
591 $sql = "
592UPDATE civicrm_domain
593SET config_backend = %2
594WHERE id = %1
595";
596 $params[2] = array($configBackend, 'String');
597 CRM_Core_DAO::executeQuery($sql, $params);
598
599 // Apply the changes to civicrm_option_values
600 $optionGroups = array('url_preferences', 'directory_preferences');
601 foreach ($optionGroups as $option) {
602 foreach ($variables as $varSuffix) {
603 $oldVar = "old{$varSuffix}";
604 $newVar = "new{$varSuffix}";
605
606 $from = $$oldVar;
607 $to = $$newVar;
608
609 if ($from && $to && $from != $to) {
610 $sql = '
611UPDATE civicrm_option_value
612SET value = REPLACE(value, %1, %2)
613WHERE option_group_id = (
614 SELECT id
615 FROM civicrm_option_group
616 WHERE name = %3 )
617';
618 $params = array(1 => array($from, 'String'),
619 2 => array($to, 'String'),
620 3 => array($option, 'String'),
621 );
622 CRM_Core_DAO::executeQuery($sql, $params);
623 }
624 }
625 }
626
627 $moveStatus .= ts('Directory and Resource URLs have been updated in the moved database to reflect current site location.') . '<br />';
628
629 $config = CRM_Core_Config::singleton();
630
631 // clear the template_c and upload directory also
632 $config->cleanup(3, TRUE);
633 $moveStatus .= ts('Template cache and upload directory have been cleared.') . '<br />';
634
635 // clear all caches
636 CRM_Core_Config::clearDBCache();
637 $moveStatus .= ts('Database cache tables cleared.') . '<br />';
638
639 $resetSessionTable = CRM_Utils_Request::retrieve('resetSessionTable',
640 'Boolean',
641 CRM_Core_DAO::$_nullArray,
642 FALSE,
643 FALSE,
644 'REQUEST'
645 );
646 if ($config->userSystem->is_drupal &&
647 $resetSessionTable
648 ) {
649 db_query("DELETE FROM {sessions} WHERE 1");
650 $moveStatus .= ts('Drupal session table cleared.') . '<br />';
651 }
652 else {
653 $session = CRM_Core_Session::singleton();
654 $session->reset(2);
655 $moveStatus .= ts('Session has been reset.') . '<br />';
656 }
657
658 return $moveStatus;
659 }
660
661 /**
662 * takes a componentName and enables it in the config
663 * Primarily used during unit testing
664 *
665 * @param string $componentName name of the component to be enabled, needs to be valid
666 *
667 * @return boolean - true if valid component name and enabling succeeds, else false
668 * @static
669 */
670 static function enableComponent($componentName) {
671 $config = CRM_Core_Config::singleton();
672 if (in_array($componentName, $config->enableComponents)) {
673 // component is already enabled
674 return TRUE;
675 }
6a488035
TO
676
677 // return if component does not exist
b086633a 678 if (!array_key_exists($componentName, CRM_Core_Component::getComponents())) {
6a488035
TO
679 return FALSE;
680 }
681
3124edb3 682 // get enabled-components from DB and add to the list
2efcf0c2 683 $enabledComponents =
3124edb3
DS
684 CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
685 $enabledComponents[] = $componentName;
6a488035 686
b086633a
TO
687 self::setEnabledComponents($enabledComponents);
688
689 return TRUE;
690 }
691
692 static function disableComponent($componentName) {
693 $config = CRM_Core_Config::singleton();
694 if (!in_array($componentName, $config->enableComponents) || !array_key_exists($componentName, CRM_Core_Component::getComponents())) {
695 // post-condition satisified
696 return TRUE;
697 }
698
699 // get enabled-components from DB and add to the list
700 $enabledComponents =
701 CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components', NULL, array());
702 $enabledComponents = array_diff($enabledComponents, array($componentName));
703
704 self::setEnabledComponents($enabledComponents);
705
706 return TRUE;
707 }
708
709 public static function setEnabledComponents($enabledComponents) {
710 $config = CRM_Core_Config::singleton();
711 $components = CRM_Core_Component::getComponents();
712
3124edb3
DS
713 $enabledComponentIDs = array();
714 foreach ($enabledComponents as $name) {
715 $enabledComponentIDs[] = $components[$name]->componentID;
6a488035 716 }
6a488035
TO
717
718 // fix the config object
3124edb3
DS
719 $config->enableComponents = $enabledComponents;
720 $config->enableComponentIDs = $enabledComponentIDs;
6a488035
TO
721
722 // also force reset of component array
723 CRM_Core_Component::getEnabledComponents(TRUE);
724
3124edb3
DS
725 // update DB
726 CRM_Core_BAO_Setting::setItem($enabledComponents,
b086633a 727 CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'enable_components');
6a488035
TO
728 }
729
b5c2afd0
EM
730 /**
731 * @return array
732 */
6a488035
TO
733 static function skipVars() {
734 return array(
735 'dsn', 'templateCompileDir',
736 'userFrameworkDSN',
737 'userFramework',
738 'userFrameworkBaseURL', 'userFrameworkClass', 'userHookClass',
739 'userPermissionClass', 'userFrameworkURLVar', 'userFrameworkVersion',
740 'newBaseURL', 'newBaseDir', 'newSiteName', 'configAndLogDir',
741 'qfKey', 'gettextResourceDir', 'cleanURL',
742 'locale_custom_strings', 'localeCustomStrings',
743 'autocompleteContactSearch',
744 'autocompleteContactReference',
745 'checksumTimeout',
746 );
747 }
748}
749