X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FConfig.php;h=1510711b199c3aff04147cd54ce9ffd05015b826;hb=7c60edb1bf1ca31accfafd35ef0ae02409615e7c;hp=ee12caba087bb1a71aecc402b900ac427e319478;hpb=e68bce7b9d941cb8dbf44bc27ca08571df3a4811;p=civicrm-core.git diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index ee12caba08..1510711b19 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -1,9 +1,9 @@ _initVariables(); - // I dont think we need to do this twice + // I don't think we need to do this twice // however just keeping this commented for now in 4.4 // in case we hit any issues - CRM-13064 // We can safely delete this once we release 4.4.4 @@ -212,7 +230,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // CRM-9803, NYSS-4822 // this causes various settings to be reset and hence we should - // only use the config object that we retrived from memcache + // only use the config object that we retrieved from memcache } self::$_singleton->initialized = 1; @@ -226,7 +244,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // set the callback at the very very end, to avoid an infinite loop // set the error callback - CRM_Core_Error::setCallback(); + unset($errorScope); // call the hook so other modules can add to the config // again doing this at the very very end @@ -249,7 +267,10 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { return self::$_singleton; } - + /** + * @param string $userFramework + * One of 'Drupal', 'Joomla', etc. + */ private function _setUserFrameworkConfig($userFramework) { $this->userFrameworkClass = 'CRM_Utils_System_' . $userFramework; @@ -259,7 +280,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { $class = $this->userFrameworkClass; // redundant with _initVariables - $userSystem = $this->userSystem = new $class(); + $this->userSystem = new $class(); if ($userFramework == 'Joomla') { $this->userFrameworkURLVar = 'task'; @@ -290,9 +311,10 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { $this->cleanURL = 0; } - $this->userFrameworkVersion = $userSystem->getVersion(); + $this->userFrameworkVersion = $this->userSystem->getVersion(); if ($userFramework == 'Joomla') { + /** @var object|null $mainframe */ global $mainframe; $dbprefix = $mainframe ? $mainframe->getCfg('dbprefix') : 'jos_'; $this->userFrameworkUsersTableName = $dbprefix . 'users'; @@ -309,8 +331,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { * Reads constants defined in civicrm.settings.php and * stores them in config properties. * - * @return void - * @access public + * @param bool $loadFromDB */ private function _initialize($loadFromDB = TRUE) { @@ -335,6 +356,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { CRM_Utils_File::baseFilePath($this->templateCompileDir) . 'ConfigAndLog' . DIRECTORY_SEPARATOR; CRM_Utils_File::createDir($this->configAndLogDir); + CRM_Utils_File::restrictAccess($this->configAndLogDir); // we're automatically prefixing compiled templates directories with country/language code global $tsLocale; @@ -346,6 +368,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } CRM_Utils_File::createDir($this->templateCompileDir); + CRM_Utils_File::restrictAccess($this->templateCompileDir); } elseif ($loadFromDB) { echo 'You need to define CIVICRM_TEMPLATE_COMPILEDIR in civicrm.settings.php'; @@ -466,6 +489,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { if (substr($this->templateCompileDir, -1 * strlen($value) - 1, -1) != $value) { $this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value); CRM_Utils_File::createDir($this->templateCompileDir); + CRM_Utils_File::restrictAccess($this->templateCompileDir); } } @@ -478,7 +502,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { CRM_Utils_System::mapConfigToSSL(); } $rrb = parse_url($this->userFrameworkResourceURL); - // dont use absolute path if resources are stored on a different server + // don't use absolute path if resources are stored on a different server // CRM-4642 $this->resourceBase = $this->userFrameworkResourceURL; if (isset($_SERVER['HTTP_HOST']) && @@ -603,13 +627,11 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { } /** - * delete the web server writable directories - * - * @param int $value 1 - clean templates_c, 2 - clean upload, 3 - clean both + * Deletes the web server writable directories * - * @access public - * - * @return void + * @param int $value + * 1: clean templates_c, 2: clean upload, 3: clean both + * @param bool $rmdir */ public function cleanup($value, $rmdir = TRUE) { $value = (int ) $value; @@ -623,7 +645,14 @@ class CRM_Core_Config extends CRM_Core_Config_Variables { // clean upload dir CRM_Utils_File::cleanDir($this->uploadDir); CRM_Utils_File::createDir($this->uploadDir); - CRM_Utils_File::restrictAccess($this->uploadDir); + } + + // Whether we delete/create or simply preserve directories, we should + // certainly make sure the restrictions are enforced. + foreach (array($this->templateCompileDir, $this->uploadDir, $this->configAndLogDir, $this->customFileUploadDir) as $dir) { + if ($dir && is_dir($dir)) { + CRM_Utils_File::restrictAccess($dir); + } } } @@ -825,6 +854,22 @@ AND $this->userFramework = $userFramework; $this->_setUserFrameworkConfig($userFramework); } + + /** + * Is back office credit card processing enabled for this site - ie are there any installed processors that support + * on-site processing + * @return bool + */ + static function isEnabledBackOfficeCreditCardPayments() { + // restrict to type=1 (credit card) payment processor payment_types and only include billing mode types 1 and 3 + $processors = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, + "billing_mode IN ( 1, 3 ) AND payment_type = 1" + ); + if (count($processors) > 0) { + return TRUE; + } + return FALSE; + } } // end CRM_Core_Config