spelling fixes
[civicrm-core.git] / CRM / Core / Config.php
index 49ae50299482e5ab083d4b3dcf3bf93cdf4403f0..1510711b199c3aff04147cd54ce9ffd05015b826 100644 (file)
@@ -1,9 +1,9 @@
 <?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.                                    |
  |                                                                    |
@@ -31,7 +31,7 @@
  * 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$
  *
  */
@@ -40,6 +40,10 @@ require_once 'Log.php';
 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)
@@ -47,42 +51,50 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
 
   /**
    * 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;
 
   /**
    * The connector module for the CMS/UF
+   * @todo Introduce an interface.
    *
-   * @var CRM_Util_System_{$uf}
+   * @var CRM_Utils_System_Base
    */
   public $userSystem = NULL;
 
   /**
-   * The root directory where Smarty should store
-   * compiled files
+   * 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)
@@ -93,12 +105,19 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
 
   /**
    * 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';
@@ -111,6 +130,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
 
   /**
    * the handle on the mail handler that we are using
+   *
    * @var object
    */
   public static $_mail = NULL;
@@ -118,13 +138,13 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
   /**
    * 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;
 
@@ -137,7 +157,9 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
   ///
 
   /**
-   * 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;
 
@@ -146,17 +168,13 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
   ///
 
   /**
-   *  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() {
   }
@@ -167,14 +185,14 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
    * @param $loadFromDB boolean  whether to load from the database
    * @param $force      boolean  whether to force a reconstruction
    *
-   * @return object
+   * @return CRM_Core_Config
    * @static
    */
   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
@@ -198,7 +216,7 @@ class CRM_Core_Config extends CRM_Core_Config_Variables {
 
           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
@@ -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) {
 
@@ -481,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']) &&
@@ -606,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;
@@ -835,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