Commit 37b395e8 authored by Dan Cruson's avatar Dan Cruson Committed by colemanw

CRM-15365 - Windows Directory Fixes

CRM-15365 - Fix problems with adjusting directories through the UI
parent 2c3ca93b
......@@ -135,10 +135,18 @@ class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting
//CRM-5679
foreach ($params as $name => & $val) {
if ($val && in_array($name, array(
'newBaseURL', 'newBaseDir', 'newSiteName'))) {
'newBaseDir', 'newSiteName'))) {
$val = CRM_Utils_File::addTrailingSlash($val);
}
}
//CRM-15365 - Fix BaseURL to avoid wrong trailing slash on Windows installs
foreach ($params as $name => & $val) {
if ($val && in_array($name, array(
'newBaseURL'))) {
$val = CRM_Utils_File::addTrailingSlash($val,"/");
}
}
$from = array($this->_oldBaseURL, $this->_oldBaseDir);
$to = array(trim($params['newBaseURL']),
......
......@@ -383,11 +383,25 @@ class CRM_Core_BAO_ConfigSetting {
// lets use imageUploadDir since we dont mess around with its values
// in the config object, lets kep it a bit generic since folks
// might have different values etc
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
'',
$config->templateCompileDir
);
//CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
if(DIRECTORY_SEPARATOR == '\\')
{
$dir = preg_replace(
'|civicrm[/\\\\]templates_c[/\\\\].*$|',
'',
$config->templateCompileDir
);
}
else
{
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
'',
$config->templateCompileDir
);
}
$siteRoot = preg_replace(
'|/media/civicrm/.*$|',
'',
......@@ -404,11 +418,25 @@ class CRM_Core_BAO_ConfigSetting {
// lets use imageUploadDir since we dont mess around with its values
// in the config object, lets kep it a bit generic since folks
// might have different values etc
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
'',
$config->templateCompileDir
);
//CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
if(DIRECTORY_SEPARATOR == '\\')
{
$dir = preg_replace(
'|civicrm[/\\\\]templates_c[/\\\\].*$|',
'',
$config->templateCompileDir
);
}
else
{
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
'',
$config->templateCompileDir
);
}
$siteRoot = preg_replace(
'|/wp-content/plugins/files/civicrm/.*$|',
'',
......@@ -425,12 +453,25 @@ class CRM_Core_BAO_ConfigSetting {
// lets use imageUploadDir since we dont mess around with its values
// in the config object, lets kep it a bit generic since folks
// might have different values etc
$dir = preg_replace(
'|/files/civicrm/.*$|',
'/files/',
$config->imageUploadDir
);
//CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
if(DIRECTORY_SEPARATOR == '\\')
{
$dir = preg_replace(
'|[/\\\\]files[/\\\\]civicrm[/\\\\].*$|',
'\\\\files\\\\',
$config->imageUploadDir
);
}
else
{
$dir = preg_replace(
'|/files/civicrm/.*$|',
'/files/',
$config->imageUploadDir
);
}
$matches = array();
if (preg_match(
'|/sites/([\w\.\-\_]+)/|',
......@@ -448,7 +489,6 @@ class CRM_Core_BAO_ConfigSetting {
}
}
return array($url, $dir, $siteName, $siteRoot);
}
......@@ -462,8 +502,15 @@ class CRM_Core_BAO_ConfigSetting {
*/
static function getBestGuessSettings() {
$config = CRM_Core_Config::singleton();
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
//CRM-15365 - Fix preg_replace to handle backslash for Windows File Paths
if(DIRECTORY_SEPARATOR == '\\')
$needle = 'civicrm[/\\\\]templates_c[/\\\\].*$';
else
$needle = 'civicrm/templates_c/.*$';
$dir = preg_replace(
"|$needle|",
'',
$config->templateCompileDir
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment