$this->extensionsDir = CRM_Core_Config_Defaults::getExtensionsDir();
$this->imageUploadDir = CRM_Core_Config_Defaults::getImageUploadDir();
$this->resourceBase = CRM_Core_Config_Defaults::getResourceBase();
- $this->uploadDir = CRM_Core_Config_Defaults::getImageUploadDir();
+ $this->uploadDir = CRM_Core_Config_Defaults::getUploadDir();
$this->userFrameworkResourceURL = CRM_Core_Config_Defaults::getUserFrameworkResourceUrl();
$this->customCSSURL = CRM_Core_Config_Defaults::getCustomCssUrl();
}
public static function getCustomFileUploadDir() {
- $value = Civi::settings()->getPath('customFileUploadDir');
+ $settings = Civi::settings();
+ $value = $settings->getPath('customFileUploadDir');
if (empty($value)) {
$defaultFileStorage = CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
- $value = $defaultFileStorage['url'] . "custom/";
+ $value = $settings->filterPath($defaultFileStorage['path'] . "custom/");
}
$value = CRM_Utils_File::addTrailingSlash($value);
CRM_Utils_File::createDir($value);
}
public static function getImageUploadDir() {
- $value = Civi::settings()->getPath('imageUploadDir');
+ $settings = Civi::settings();
+ $value = $settings->getPath('imageUploadDir');
if (empty($value)) {
$defaultFileStorage = CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
- $value = $defaultFileStorage['path'] . "persist/contribute/";
+ $value = $settings->filterPath($defaultFileStorage['path'] . "persist/contribute/");
}
$value = CRM_Utils_File::addTrailingSlash($value);
CRM_Utils_File::createDir($value);
}
public static function getImageUploadUrl() {
- $imageUploadURL = Civi::settings()->getUrl('imageUploadURL', 'absolute');
+ $settings = Civi::settings();
+ $imageUploadURL = $settings->getUrl('imageUploadURL', 'absolute');
if (empty($imageUploadURL)) {
$defaultFileStorage = CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
- $imageUploadURL = $defaultFileStorage['url'] . 'persist/contribute/';
+ $imageUploadURL = $settings->filterUrl($defaultFileStorage['url'] . 'persist/contribute/', 'absolute');
}
return $imageUploadURL;
}
public static function getUploadDir() {
- $value = Civi::settings()->getPath('uploadDir');
+ $settings = Civi::settings();
+ $value = $settings->getPath('uploadDir');
if (empty($value)) {
$defaultFileStorage = CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
- $value = $defaultFileStorage['path'] . "upload/";
+ $value = $settings->filterPath($defaultFileStorage['path'] . "upload/");
}
$value = CRM_Utils_File::addTrailingSlash($value);
CRM_Utils_File::createDir($value);
*/
public function getPath($key) {
if (!isset($this->filteredValues[$key])) {
- $this->filteredValues[$key] = \CRM_Utils_File::absoluteDirectory($this->get($key));
+ $this->filteredValues[$key] = $this->filterPath($this->get($key));
}
return $this->filteredValues[$key];
}
if ($value) {
if ($ssl || ($ssl === NULL && \CRM_Utils_System::isSSL())) {
$value = str_replace('http://', 'https://', $value);
- return $value;
}
- return $value;
}
return $value;
}
+ /**
+ * @param string $value
+ * @return bool|string
+ */
+ public function filterPath($value) {
+ if ($value) {
+ return \CRM_Utils_File::absoluteDirectory($value);
+ }
+ else {
+ return FALSE;
+ }
+ }
+
}