Exemplo n.º 1
0
 /**
  * Function to add additional config paramters to the core Config class
  * if CiviContribute is enabled
  *
  * Note that this config class prevent code bloat in the Core Config class,
  * however we declare all the variables assigned here, more for documentation
  * than anything else, at some point, we'll figure out how to extend a class
  * and properties dynamically in PHP (like Ruby)
  *
  * @param CRM_Core_Config (reference ) the system config object
  *
  * @return void
  * @static
  * @access public
  */
 function add(&$config)
 {
     $config->paymentProcessor = null;
     $config->paymentClass = null;
     $config->paymentBillingMode = null;
     $config->paymentCertPath = null;
     $config->paymentKey = null;
     $config->paymentPassword = null;
     $config->paymentProcessorButton = "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif";
     $config->paymentPayPalExpressUrl = "www.paypal.com";
     $config->paymentPayPalExpressTestUrl = "www.sandbox.paypal.com";
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_PROCESSOR')) {
         require_once 'CRM/Contribute/Payment.php';
         $config->paymentProcessor = CIVICRM_CONTRIBUTE_PAYMENT_PROCESSOR;
         switch ($config->paymentProcessor) {
             case 'PayPal':
                 $config->paymentClass = 'CRM_Contribute_Payment_PayPal';
                 $config->paymentExpressButton = CIVICRM_CONTRIBUTE_PAYMENT_EXPRESS_BUTTON;
                 $config->paymentPayPalExpressUrl = CIVICRM_CONTRIBUTE_PAYMENT_PAYPAL_EXPRESS_URL;
                 $config->paymentPayPalExpressTestUrl = CIVICRM_CONTRIBUTE_PAYMENT_PAYPAL_EXPRESS_TEST_URL;
                 $config->paymentBillingMode = CRM_CONTRIBUTE_PAYMENT_BILLING_MODE_FORM | CRM_CONTRIBUTE_PAYMENT_BILLING_MODE_BUTTON;
                 break;
             case 'PayPal_Express':
                 $config->paymentClass = 'CRM_Contribute_Payment_PayPal';
                 $config->paymentBillingMode = CRM_CONTRIBUTE_PAYMENT_BILLING_MODE_BUTTON;
                 $config->paymentExpressButton = CIVICRM_CONTRIBUTE_PAYMENT_EXPRESS_BUTTON;
                 $config->paymentPayPalExpressUrl = CIVICRM_CONTRIBUTE_PAYMENT_PAYPAL_EXPRESS_URL;
                 $config->paymentPayPalExpressTestUrl = CIVICRM_CONTRIBUTE_PAYMENT_PAYPAL_EXPRESS_TEST_URL;
                 break;
             case 'Moneris':
                 $config->paymentClass = 'CRM_Contribute_Payment_Moneris';
                 $config->paymentBillingMode = CRM_CONTRIBUTE_PAYMENT_BILLING_MODE_FORM;
                 break;
         }
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_CERT_PATH')) {
         $config->paymentCertPath['live'] = CRM_Core_Config::addTrailingSlash(CIVICRM_CONTRIBUTE_PAYMENT_CERT_PATH);
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_TEST_CERT_PATH')) {
         $config->paymentCertPath['test'] = CRM_Core_Config::addTrailingSlash(CIVICRM_CONTRIBUTE_PAYMENT_TEST_CERT_PATH);
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_KEY')) {
         $config->paymentKey['live'] = CIVICRM_CONTRIBUTE_PAYMENT_KEY;
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_TEST_KEY')) {
         $config->paymentKey['test'] = CIVICRM_CONTRIBUTE_PAYMENT_TEST_KEY;
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_PASSWORD')) {
         $config->paymentPassword['live'] = CIVICRM_CONTRIBUTE_PAYMENT_PASSWORD;
     }
     if (defined('CIVICRM_CONTRIBUTE_PAYMENT_TEST_PASSWORD')) {
         $config->paymentPassword['test'] = CIVICRM_CONTRIBUTE_PAYMENT_TEST_PASSWORD;
     }
 }
Exemplo n.º 2
0
 /**
  * The constructor. Basically redefines the class variables if
  * it finds a constant definition for that class variable
  *
  * @return object
  * @access private
  */
 function CRM_Core_Config()
 {
     require_once 'CRM/Core/Session.php';
     $session =& CRM_Core_Session::singleton();
     if (defined('CIVICRM_DOMAIN_ID')) {
         $GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = CIVICRM_DOMAIN_ID;
     } else {
         $GLOBALS['_CRM_CORE_CONFIG']['_domainID'] = 1;
     }
     $session->set('domainID', $GLOBALS['_CRM_CORE_CONFIG']['_domainID']);
     // we figure this out early, since some config parameters are loaded
     // based on what components are enabled
     if (defined('ENABLE_COMPONENTS')) {
         $this->enableComponents = explode(',', ENABLE_COMPONENTS);
         for ($i = 0; $i < count($this->enableComponents); $i++) {
             $this->enableComponents[$i] = trim($this->enableComponents[$i]);
         }
     }
     if (defined('CIVICRM_DSN')) {
         $this->dsn = CIVICRM_DSN;
     }
     if (defined('UF_DSN')) {
         $this->ufDSN = UF_DSN;
     }
     if (defined('UF_USERTABLENAME')) {
         $this->ufUserTableName = UF_USERTABLENAME;
     }
     if (defined('CIVICRM_DEBUG')) {
         $this->debug = CIVICRM_DEBUG;
     }
     if (defined('CIVICRM_DAO_DEBUG')) {
         $this->daoDebug = CIVICRM_DAO_DEBUG;
     }
     if (defined('CIVICRM_DAO_FACTORY_CLASS')) {
         $this->DAOFactoryClass = CIVICRM_DAO_FACTORY_CLASS;
     }
     if (defined('CIVICRM_SMARTYDIR')) {
         $this->smartyDir = CIVICRM_SMARTYDIR;
     }
     if (defined('CIVICRM_PLUGINSDIR')) {
         $this->pluginsDir = CIVICRM_PLUGINSDIR;
     }
     if (defined('CIVICRM_TEMPLATEDIR')) {
         $this->templateDir = CIVICRM_TEMPLATEDIR;
     }
     if (defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
         $this->templateCompileDir = CIVICRM_TEMPLATE_COMPILEDIR;
         // make sure this directory exists
         CRM_Utils_File::createDir($this->templateCompileDir);
     }
     if (defined('CIVICRM_RESOURCEBASE')) {
         $this->resourceBase = CRM_Core_Config::addTrailingSlash(CIVICRM_RESOURCEBASE, '/');
     }
     if (defined('CIVICRM_UPLOADDIR')) {
         $this->uploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_UPLOADDIR);
         CRM_Utils_File::createDir($this->uploadDir);
     }
     if (defined('CIVICRM_IMAGE_UPLOADDIR')) {
         $this->imageUploadDir = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADDIR);
         CRM_Utils_File::createDir($this->imageUploadDir);
     }
     if (defined('CIVICRM_IMAGE_UPLOADURL')) {
         $this->imageUploadURL = CRM_Core_Config::addTrailingSlash(CIVICRM_IMAGE_UPLOADURL, '/');
     }
     if (defined('CIVICRM_CLEANURL')) {
         $this->cleanURL = CIVICRM_CLEANURL;
     }
     if (defined('CIVICRM_COUNTRY_LIMIT')) {
         $isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_COUNTRY_LIMIT);
         $this->countryLimit = array_filter($isoCodes);
     }
     if (defined('CIVICRM_PROVINCE_LIMIT')) {
         $isoCodes = preg_split('/[^a-zA-Z]/', CIVICRM_PROVINCE_LIMIT);
         $provinceLimitList = array_filter($isoCodes);
         if (!empty($provinceLimitList)) {
             $this->provinceLimit = array_filter($isoCodes);
         }
     }
     // Note: we can't change the ISO code to country_id
     // here, as we can't access the database yet...
     if (defined('CIVICRM_DEFAULT_CONTACT_COUNTRY')) {
         $this->defaultContactCountry = CIVICRM_DEFAULT_CONTACT_COUNTRY;
     }
     if (defined('CIVICONTRIBUTE_DEFAULT_CURRENCY') and CRM_Utils_Rule::currencyCode(CIVICONTRIBUTE_DEFAULT_CURRENCY)) {
         $this->defaultCurrency = CIVICONTRIBUTE_DEFAULT_CURRENCY;
     }
     if (defined('CIVICRM_LC_MESSAGES')) {
         $this->lcMessages = CIVICRM_LC_MESSAGES;
     }
     if (defined('CIVICRM_ADDRESS_FORMAT')) {
         // trim the format and unify line endings to LF
         $format = trim(CIVICRM_ADDRESS_FORMAT);
         $format = str_replace(array("\r\n", "\r"), "\n", $format);
         // get the field sequence from the format
         $newSequence = array();
         foreach ($this->addressSequence as $field) {
             if (substr_count($format, $field)) {
                 $newSequence[strpos($format, $field)] = $field;
             }
         }
         ksort($newSequence);
         // add the addressSequence fields that are missing in the addressFormat
         // to the end of the list, so that (for example) if state_province is not
         // specified in the addressFormat it's still in the address-editing form
         $newSequence = array_merge($newSequence, $this->addressSequence);
         $newSequence = array_unique($newSequence);
         $this->addressSequence = $newSequence;
         $this->addressFormat = $format;
     }
     if (defined('CIVICRM_DATEFORMAT_DATETIME')) {
         $this->dateformatDatetime = CIVICRM_DATEFORMAT_DATETIME;
     }
     if (defined('CIVICRM_DATEFORMAT_FULL')) {
         $this->dateformatFull = CIVICRM_DATEFORMAT_FULL;
     }
     if (defined('CIVICRM_DATEFORMAT_PARTIAL')) {
         $this->dateformatPartial = CIVICRM_DATEFORMAT_PARTIAL;
     }
     if (defined('CIVICRM_DATEFORMAT_YEAR')) {
         $this->dateformatYear = CIVICRM_DATEFORMAT_YEAR;
     }
     if (defined('CIVICRM_DATEFORMAT_QF_DATE')) {
         $this->dateformatQfDate = CIVICRM_DATEFORMAT_QF_DATE;
     }
     if (defined('CIVICRM_DATEFORMAT_QF_DATETIME')) {
         $this->dateformatQfDatetime = CIVICRM_DATEFORMAT_QF_DATETIME;
     }
     if (defined('CIVICRM_MONEYFORMAT')) {
         $this->moneyformat = CIVICRM_MONEYFORMAT;
     }
     if (defined('CIVICRM_LC_MONETARY')) {
         $this->lcMonetary = CIVICRM_LC_MONETARY;
         setlocale(LC_MONETARY, $this->lcMonetary . '.UTF-8', $this->lcMonetary, 'C');
     }
     if (defined('CIVICRM_GETTEXT_CODESET')) {
         $this->gettextCodeset = CIVICRM_GETTEXT_CODESET;
     }
     if (defined('CIVICRM_GETTEXT_DOMAIN')) {
         $this->gettextDomain = CIVICRM_GETTEXT_DOMAIN;
     }
     if (defined('CIVICRM_GETTEXT_RESOURCEDIR')) {
         $this->gettextResourceDir = CRM_Core_Config::addTrailingSlash(CIVICRM_GETTEXT_RESOURCEDIR);
     }
     if (defined('CIVICRM_SMTP_SERVER')) {
         $this->smtpServer = CIVICRM_SMTP_SERVER;
     }
     if (defined('CIVICRM_SMTP_PORT')) {
         $this->smtpPort = CIVICRM_SMTP_PORT;
     }
     if (defined('CIVICRM_SMTP_AUTH')) {
         if (CIVICRM_SMTP_AUTH === true) {
             $this->smtpAuth = true;
         }
         // else it stays false
     }
     if (defined('CIVICRM_SMTP_USERNAME')) {
         $this->smtpUsername = CIVICRM_SMTP_USERNAME;
     }
     if (defined('CIVICRM_SMTP_PASSWORD')) {
         $this->smtpPassword = CIVICRM_SMTP_PASSWORD;
     }
     if (defined('CIVICRM_UF')) {
         $this->userFramework = CIVICRM_UF;
         $this->userFrameworkClass = 'CRM_Utils_System_' . $this->userFramework;
         $this->userHookClass = 'CRM_Utils_Hook_' . $this->userFramework;
         $this->userPermissionClass = 'CRM_Core_Permission_' . $this->userFramework;
     }
     if (defined('CIVICRM_UF_VERSION')) {
         $this->userFrameworkVersion = (double) CIVICRM_UF_VERSION;
     }
     if (defined('CIVICRM_UF_URLVAR')) {
         $this->userFrameworkURLVar = CIVICRM_UF_URLVAR;
     }
     if (defined('CIVICRM_UF_DSN')) {
         $this->userFrameworkDSN = CIVICRM_UF_DSN;
     }
     if (defined('CIVICRM_UF_USERSTABLENAME')) {
         $this->userFrameworkUsersTableName = CIVICRM_UF_USERSTABLENAME;
     }
     if (defined('CIVICRM_UF_BASEURL')) {
         $this->userFrameworkBaseURL = CRM_Core_Config::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
     }
     if (defined('CIVICRM_UF_RESOURCEURL')) {
         $this->userFrameworkResourceURL = CRM_Core_Config::addTrailingSlash(CIVICRM_UF_RESOURCEURL, '/');
     }
     if (defined('CIVICRM_UF_FRONTEND')) {
         $this->userFrameworkFrontend = CIVICRM_UF_FRONTEND;
     }
     if (defined('CIVICRM_MYSQL_VERSION')) {
         $this->mysqlVersion = CIVICRM_MYSQL_VERSION;
     }
     if (defined('CIVICRM_MYSQL_PATH')) {
         $this->mysqlPath = CIVICRM_MYSQL_PATH;
     }
     $size = trim(ini_get('upload_max_filesize'));
     if ($size) {
         $last = strtolower($size[strlen($size) - 1]);
         switch ($last) {
             // The 'G' modifier is available since PHP 5.1.0
             case 'g':
                 $size *= 1024;
             case 'm':
                 $size *= 1024;
             case 'k':
                 $size *= 1024;
         }
         $this->maxImportFileSize = $size;
     }
     if (defined('CIVICRM_MAP_PROVIDER')) {
         $this->mapProvider = CIVICRM_MAP_PROVIDER;
     }
     if (defined('CIVICRM_MAP_API_KEY')) {
         $this->mapAPIKey = CIVICRM_MAP_API_KEY;
     }
     if (defined('CIVICRM_GEOCODE_METHOD')) {
         if (CIVICRM_GEOCODE_METHOD == 'CRM_Utils_Geocode_ZipTable' || CIVICRM_GEOCODE_METHOD == 'CRM_Utils_Geocode_RPC' || CIVICRM_GEOCODE_METHOD == 'CRM_Utils_Geocode_Yahoo') {
             $this->geocodeMethod = CIVICRM_GEOCODE_METHOD;
         }
     }
     if (defined('CIVICRM_VERSION_CHECK') and CIVICRM_VERSION_CHECK) {
         $this->versionCheck = true;
     }
     if (defined('CIVICRM_MAILER_SPOOL_PERIOD')) {
         $this->mailerPeriod = CIVICRM_MAILER_SPOOL_PERIOD;
     }
     if (defined('CIVICRM_VERP_SEPARATOR')) {
         $this->verpSeparator = CIVICRM_VERP_SEPARATOR;
     }
     if (defined('CIVICRM_ENABLE_SSL')) {
         $this->enableSSL = CIVICRM_ENABLE_SSL;
     }
     if (in_array('CiviContribute', $this->enableComponents)) {
         require_once 'CRM/Contribute/Config.php';
         CRM_Contribute_Config::add($this);
     }
     if (in_array('CiviSMS', $this->enableComponents)) {
         require_once 'CRM/SMS/Config.php';
         CRM_SMS_Config::add($this);
     }
     // initialize the framework
     $this->initialize();
 }