<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* The default values in general, should reflect production values (minimizes chances of screwing up)
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
require_once 'Mail.php';
require_once 'api/api.php';
+
+/**
+ * Class CRM_Core_Config
+ */
class CRM_Core_Config extends CRM_Core_Config_Variables {
///
/// BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
/**
* the dsn of the database connection
+ *
* @var string
*/
public $dsn;
/**
* the name of user framework
+ *
* @var string
*/
public $userFramework = 'Drupal';
/**
* the name of user framework url variable name
+ *
* @var string
*/
public $userFrameworkURLVar = 'q';
/**
* the dsn of the database connection for user framework
+ *
* @var string
*/
public $userFrameworkDSN = NULL;
public $userSystem = NULL;
/**
- * The root directory where Smarty should store
- * compiled files
+ * @var CRM_Core_Permission_Base
+ */
+ public $userPermissionClass;
+
+ /**
+ * The root directory where Smarty should store compiled files
+ *
* @var string
*/
public $templateCompileDir = './templates_c/en_US/';
+ /**
+ * @var string
+ */
public $configAndLogDir = NULL;
// END: BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
/**
* are we initialized and in a proper state
+ *
* @var string
*/
public $initialized = 0;
+ /**
+ * @var string
+ */
+ public $customPHPPathDir;
+
/**
* the factory class used to instantiate our DB objects
+ *
* @var string
*/
private $DAOFactoryClass = 'CRM_Contact_DAO_Factory';
/**
* the handle on the mail handler that we are using
+ *
* @var object
*/
public static $_mail = NULL;
/**
* We only need one instance of this object. So we use the singleton
* pattern and cache the instance in this variable
- * @var object
- * @static
+ *
+ * @var CRM_Core_Config
*/
private static $_singleton = NULL;
/**
- * component registry object (of CRM_Core_Component type)
+ * @var CRM_Core_Component
*/
public $componentRegistry = NULL;
///
/**
- * to determine wether the call is from cms or civicrm
+ * @var bool
+ * TRUE, if the call is CiviCRM.
+ * FALSE, if the call is from the CMS.
*/
public $inCiviCRM = FALSE;
///
/**
- * Define recaptcha key
+ * @var string
*/
-
public $recaptchaPublicKey;
/**
* The constructor. Sets domain id if defined, otherwise assumes
* single instance installation.
- *
- * @return void
- * @access private
*/
private function __construct() {
}
static function &singleton($loadFromDB = TRUE, $force = FALSE) {
if (self::$_singleton === NULL || $force) {
// goto a simple error handler
- $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK;
- $GLOBALS['_PEAR_default_error_options'] = array('CRM_Core_Error', 'simpleHandler');
+ $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle'));
+ $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler'));
// lets ensure we set E_DEPRECATED to minimize errors
// CRM-6327
self::$_singleton->_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
// 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;
// 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
return self::$_singleton;
}
-
+ /**
+ * @param string $userFramework
+ * One of 'Drupal', 'Joomla', etc.
+ */
private function _setUserFrameworkConfig($userFramework) {
$this->userFrameworkClass = 'CRM_Utils_System_' . $userFramework;
$class = $this->userFrameworkClass;
// redundant with _initVariables
- $userSystem = $this->userSystem = new $class();
+ $this->userSystem = new $class();
if ($userFramework == 'Joomla') {
$this->userFrameworkURLVar = 'task';
$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';
* 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) {
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']) &&
}
/**
- * 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;
// 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) as $dir) {
+ foreach (array($this->templateCompileDir, $this->uploadDir, $this->configAndLogDir, $this->customFileUploadDir) as $dir) {
if ($dir && is_dir($dir)) {
CRM_Utils_File::restrictAccess($dir);
}
$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