if ($countryValue) {
CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
- $config = CRM_Core_Config::singleton();
- $limitCodes = $config->countryLimit();
+ $limitCodes = CRM_Core_BAO_Country::countryLimit();
$error = TRUE;
foreach (array(
if ($stateValue['country']) {
CRM_Core_PseudoConstant::populate($countryNames, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active');
CRM_Core_PseudoConstant::populate($countryIsoCodes, 'CRM_Core_DAO_Country', TRUE, 'iso_code');
- $config = CRM_Core_Config::singleton();
- $limitCodes = $config->countryLimit();
+ $limitCodes = CRM_Core_BAO_Country::countryLimit();
//If no country is selected in
//localization then take all countries
if (empty($limitCodes)) {
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2015
+ * $Id$
+ *
+ */
+
+/**
+ * This class contains functions for managing Action Logs
+ */
+class CRM_Core_BAO_Country extends CRM_Core_DAO_Country {
+
+ /**
+ * Get the list of countries for which we offer provinces.
+ *
+ * @return mixed
+ */
+ public static function provinceLimit() {
+ if (!isset(Civi::$statics[__CLASS__]['provinceLimit'])) {
+ $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
+ $provinceLimit = Civi::settings()->get('provinceLimit');
+ $country = array();
+ if (is_array($provinceLimit)) {
+ foreach ($provinceLimit as $val) {
+ // CRM-12007
+ // some countries have disappeared and hence they might be in country limit
+ // but not in the country table
+ if (isset($countryIsoCodes[$val])) {
+ $country[] = $countryIsoCodes[$val];
+ }
+ }
+ }
+ else {
+ $country[] = $countryIsoCodes[$provinceLimit];
+ }
+ Civi::$statics[__CLASS__]['provinceLimit'] = $country;
+ }
+ return Civi::$statics[__CLASS__]['provinceLimit'];
+ }
+
+ /**
+ * Get the list of countries (with names) which are available to user.
+ *
+ * @return mixed
+ */
+ public static function countryLimit() {
+ if (!isset(Civi::$statics[__CLASS__]['countryLimit'])) {
+ $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
+ $country = array();
+ $countryLimit = Civi::settings()->get('countryLimit');
+ if (is_array($countryLimit)) {
+ foreach ($countryLimit as $val) {
+ // CRM-12007
+ // some countries have disappeared and hence they might be in country limit
+ // but not in the country table
+ if (isset($countryIsoCodes[$val])) {
+ $country[] = $countryIsoCodes[$val];
+ }
+ }
+ }
+ else {
+ $country[] = $countryIsoCodes[$countryLimit];
+ }
+ Civi::$statics[__CLASS__]['countryLimit'] = $country;
+ }
+ return Civi::$statics[__CLASS__]['countryLimit'];
+ }
+
+ /**
+ * Provide cached default contact country.
+ *
+ * @return string
+ */
+ public static function defaultContactCountry() {
+ static $cachedContactCountry = NULL;
+ $defaultContactCountry = Civi::settings()->get('defaultContactCountry');
+
+ if (!empty($defaultContactCountry) && !$cachedContactCountry) {
+ $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
+ $cachedContactCountry = CRM_Utils_Array::value($defaultContactCountry,
+ $countryIsoCodes
+ );
+ }
+ return $cachedContactCountry;
+ }
+
+ /**
+ * Provide cached default country name.
+ *
+ * @return string
+ */
+ public static function defaultContactCountryName() {
+ static $cachedContactCountryName = NULL;
+ $defaultContactCountry = Civi::settings()->get('defaultContactCountry');
+ if (!$cachedContactCountryName && $defaultContactCountry) {
+ $countryCodes = CRM_Core_PseudoConstant::country();
+ $cachedContactCountryName = $countryCodes[$defaultContactCountry];
+ }
+ return $cachedContactCountryName;
+ }
+
+ /**
+ * Provide cached default currency symbol.
+ *
+ * @return string
+ */
+ public static function defaultCurrencySymbol($defaultCurrency = NULL) {
+ static $cachedSymbol = NULL;
+ if (!$cachedSymbol || $defaultCurrency) {
+ $currency = $defaultCurrency ? $defaultCurrency : Civi::settings()->get('defaultCurrency');
+ if ($currency) {
+ $currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array(
+ 'labelColumn' => 'symbol',
+ 'orderColumn' => TRUE,
+ ));
+ $cachedSymbol = CRM_Utils_Array::value($currency, $currencySymbols, '');
+ }
+ else {
+ $cachedSymbol = '$';
+ }
+ }
+ return $cachedSymbol;
+ }
+
+}
// Suppress Language switcher if language is inherited from CMS - CRM-9971
$config = CRM_Core_Config::singleton();
- if ($id == self::LANGSWITCH && property_exists($config, "inheritLocale") && $config->inheritLocale) {
+ if ($id == self::LANGSWITCH && $config->inheritLocale) {
return NULL;
}
* 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;
-
- /**
- * The connector module for the CMS/UF
- * @todo Introduce an interface.
- *
- * @var CRM_Utils_System_Base
- */
- public $userSystem = NULL;
-
- /**
- * @var CRM_Core_Permission_Base
- */
- public $userPermissionClass;
-
- /**
- * The root directory where Smarty should store compiled files.
- *
- * @var string
- */
- public $templateCompileDir;
-
- /**
- * @var string
- */
- public $configAndLogDir = NULL;
-
- // END: BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
-
- ///
- /// BEGIN HELPER CLASS PROPERTIES
- ///
-
- /**
- * Are we initialized and in a proper state
- *
- * @var string
- */
- public $initialized = 0;
-
- /**
- * @var string
- */
- public $customPHPPathDir;
/**
* The handle to the log that we are using
*/
private static $_singleton = NULL;
- ///
- /// END HELPER CLASS PROPERTIES
- ///
-
- ///
- /// RUNTIME SET CLASS PROPERTIES
- ///
-
- /**
- * @var bool
- * TRUE, if the call is CiviCRM.
- * FALSE, if the call is from the CMS.
- */
- public $inCiviCRM = FALSE;
-
- ///
- /// END: RUNTIME SET CLASS PROPERTIES
- ///
-
- /**
- * @var string
- */
- public $recaptchaPublicKey;
-
/**
* The constructor. Sets domain id if defined, otherwise assumes
* single instance installation.
*/
- private function __construct() {
+ public function __construct() {
+ //parent::__construct();
}
/**
return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice'));
}
+ /**
+ * @deprecated
+ */
+ public function addressSequence() {
+ return CRM_Utils_Address::sequence(Civi::settings()->get('address_format'));
+ }
+
+ /**
+ * @deprecated
+ */
+ public function defaultContactCountry() {
+ return CRM_Core_BAO_Country::defaultContactCountry();
+ }
+
+ /**
+ * @deprecated
+ */
+ public function defaultContactCountryName() {
+ return CRM_Core_BAO_Country::defaultContactCountryName();
+ }
+
+ /**
+ * @deprecated
+ */
+ public function defaultCurrencySymbol($defaultCurrency = NULL) {
+ return CRM_Core_BAO_Country::defaultCurrencySymbol($defaultCurrency);
+ }
+
/**
* Resets the singleton, so that the next call to CRM_Core_Config::singleton()
* reloads completely.
*/
class CRM_Core_Config_Variables extends CRM_Core_Config_Defaults {
+ ///
+ /// 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;
+
+ /**
+ * The connector module for the CMS/UF
+ * @todo Introduce an interface.
+ *
+ * @var CRM_Utils_System_Base
+ */
+ public $userSystem = NULL;
+
+ /**
+ * The root directory where Smarty should store compiled files.
+ *
+ * @var string
+ */
+ public $templateCompileDir;
+
+ /**
+ * @var string
+ */
+ public $configAndLogDir = NULL;
+
+ // END: BASE SYSTEM PROPERTIES (CIVICRM.SETTINGS.PHP)
+
+
+ /**
+ * determine whether 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;
+
+ ///
+ /// END: RUNTIME SET CLASS PROPERTIES
+ ///
+
+ /**
+ * @var string
+ */
+ public $recaptchaPublicKey;
+
+ ///
+ /// BEGIN HELPER CLASS PROPERTIES
+ ///
+
+ /**
+ * Are we initialized and in a proper state
+ *
+ * @var string
+ */
+ public $initialized = 0;
+
+ /**
+ * @var string
+ */
+ public $customPHPPathDir;
+
/**
* The debug level for civicrm.
* @var int
/**
* Default user framework. This basically makes Drupal 7 the default
*/
- public $userFramework = 'Drupal';
public $userFrameworkClass = 'CRM_Utils_System_Drupal';
public $userHookClass = 'CRM_Utils_Hook_Drupal';
*/
public $userPermissionTemp = NULL;
- public $userFrameworkURLVar = 'q';
- public $userFrameworkDSN = NULL;
public $userFrameworkBaseURL = NULL;
public $userFrameworkResourceURL = NULL;
public $userFrameworkFrontend = FALSE;
public $includeAlphabeticalPager = 1;
public $includeOrderByClause = 1;
- /**
- * determine whether the call is from cms or civicrm
- */
- public $inCiviCRM = FALSE;
-
/**
* PDF receipt as attachment is disabled by default (CRM-8350)
*/
public $verpSeparator = '.', $mailThrottleTime = 0, $mailerJobsMax = 0, $mailerJobSize = 0, $mailerBatchLimit = 0;
- /**
- * Provide addressSequence.
- *
- * @param
- *
- * @return string
- */
- public function addressSequence() {
- $addressFormat = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
- 'address_format'
- );
-
- return CRM_Utils_Address::sequence($addressFormat);
- }
-
- /**
- * Provide cached default currency symbol.
- *
- * @param
- *
- * @return string
- */
- public function defaultCurrencySymbol($defaultCurrency = NULL) {
- static $cachedSymbol = NULL;
- if (!$cachedSymbol || $defaultCurrency) {
- $currency = $defaultCurrency ? $defaultCurrency : $this->defaultCurrency;
- if ($currency) {
- $currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array(
- 'labelColumn' => 'symbol',
- 'orderColumn' => TRUE,
- ));
- $cachedSymbol = CRM_Utils_Array::value($currency, $currencySymbols, '');
- }
- else {
- $cachedSymbol = '$';
- }
- }
- return $cachedSymbol;
- }
-
- /**
- * Provide cached default currency symbol.
- *
- * @param
- *
- * @return string
- */
- public function defaultContactCountry() {
- static $cachedContactCountry = NULL;
-
- if (!empty($this->defaultContactCountry) &&
- !$cachedContactCountry
- ) {
- $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
- $cachedContactCountry = CRM_Utils_Array::value($this->defaultContactCountry,
- $countryIsoCodes
- );
- }
- return $cachedContactCountry;
- }
-
- /**
- * Provide cached default country name.
- *
- * @param
- *
- * @return string
- */
- public function defaultContactCountryName() {
- static $cachedContactCountryName = NULL;
- if (!$cachedContactCountryName && $this->defaultContactCountry) {
- $countryCodes = CRM_Core_PseudoConstant::country();
- $cachedContactCountryName = $countryCodes[$this->defaultContactCountry];
- }
- return $cachedContactCountryName;
- }
-
- /**
- * Provide cached country limit translated to names.
- *
- * @param
- *
- * @return array
- */
- public function countryLimit() {
- static $cachedCountryLimit = NULL;
- if (!$cachedCountryLimit) {
- $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
- $country = array();
- if (is_array($this->countryLimit)) {
- foreach ($this->countryLimit as $val) {
- // CRM-12007
- // some countries have disappeared and hence they might be in country limit
- // but not in the country table
- if (isset($countryIsoCodes[$val])) {
- $country[] = $countryIsoCodes[$val];
- }
- }
- }
- else {
- $country[] = $countryIsoCodes[$this->countryLimit];
- }
- $cachedCountryLimit = $country;
- }
- return $cachedCountryLimit;
- }
-
- /**
- * Provide cached province limit translated to names.
- *
- * @param
- *
- * @return array
- */
- public function provinceLimit() {
- static $cachedProvinceLimit = NULL;
- if (!$cachedProvinceLimit) {
- $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode();
- $country = array();
- if (is_array($this->provinceLimit)) {
- foreach ($this->provinceLimit as $val) {
- // CRM-12007
- // some countries have disappeared and hence they might be in country limit
- // but not in the country table
- if (isset($countryIsoCodes[$val])) {
- $country[] = $countryIsoCodes[$val];
- }
- }
- }
- else {
- $country[] = $countryIsoCodes[$this->provinceLimit];
- }
- $cachedProvinceLimit = $country;
- }
- return $cachedProvinceLimit;
- }
+ public $inheritLocale = 0;
}
// end CRM_Core_Config
public static function &stateProvince($id = FALSE, $limit = TRUE) {
if (($id && !CRM_Utils_Array::value($id, self::$stateProvince)) || !self::$stateProvince || !$id) {
$whereClause = FALSE;
- $config = CRM_Core_Config::singleton();
if ($limit) {
$countryIsoCodes = self::countryIsoCode();
- $limitCodes = $config->provinceLimit();
+ $limitCodes = CRM_Core_BAO_Country::provinceLimit();
$limitIds = array();
foreach ($limitCodes as $code) {
$limitIds = array_merge($limitIds, array_keys($countryIsoCodes, $code));
$whereClause = FALSE;
if ($limit) {
- $config = CRM_Core_Config::singleton();
$countryIsoCodes = self::countryIsoCode();
- $limitCodes = $config->provinceLimit();
+ $limitCodes = CRM_Core_BAO_Country::provinceLimit();
$limitIds = array();
foreach ($limitCodes as $code) {
$tmpArray = array_keys($countryIsoCodes, $code);
// limit the country list to the countries specified in CIVICRM_COUNTRY_LIMIT
// (ensuring it's a subset of the legal values)
// K/P: We need to fix this, i dont think it works with new setting files
- $limitCodes = $config->countryLimit();
+ $limitCodes = CRM_Core_BAO_Country::countryLimit();
if (!is_array($limitCodes)) {
$limitCodes = array(
$config->countryLimit => 1,
'multiple' => 1,
'class' => 'crm-select2',
),
- 'default' => NULL,
+ 'default' => array('1228'),
'add' => '4.3',
'title' => 'Available Countries',
'is_domain' => 1,
'multiple' => 1,
'class' => 'crm-select2',
),
- 'default' => NULL,
+ 'default' => array('1228'),
'add' => '4.3',
'title' => 'Available States and Provinces',
'is_domain' => 1,