3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * This class contains functions for managing Action Logs
23 class CRM_Core_BAO_Country
extends CRM_Core_DAO_Country
{
26 * Get the list of countries for which we offer provinces.
30 public static function provinceLimit() {
31 if (!isset(Civi
::$statics[__CLASS__
]['provinceLimit'])) {
32 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
33 $provinceLimit = Civi
::settings()->get('provinceLimit');
35 if (is_array($provinceLimit)) {
36 foreach ($provinceLimit as $val) {
38 // some countries have disappeared and hence they might be in country limit
39 // but not in the country table
40 if (isset($countryIsoCodes[$val])) {
41 $country[] = $countryIsoCodes[$val];
46 $country[] = $countryIsoCodes[$provinceLimit];
48 Civi
::$statics[__CLASS__
]['provinceLimit'] = $country;
50 return Civi
::$statics[__CLASS__
]['provinceLimit'];
54 * Get the list of countries (with names) which are available to user.
58 public static function countryLimit() {
59 if (!isset(Civi
::$statics[__CLASS__
]['countryLimit'])) {
60 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
62 $countryLimit = Civi
::settings()->get('countryLimit');
63 if (is_array($countryLimit)) {
64 foreach ($countryLimit as $val) {
66 // some countries have disappeared and hence they might be in country limit
67 // but not in the country table
68 if (isset($countryIsoCodes[$val])) {
69 $country[] = $countryIsoCodes[$val];
74 $country[] = $countryIsoCodes[$countryLimit];
76 Civi
::$statics[__CLASS__
]['countryLimit'] = $country;
78 return Civi
::$statics[__CLASS__
]['countryLimit'];
82 * Provide cached default contact country.
86 public static function defaultContactCountry() {
87 static $cachedContactCountry = NULL;
88 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
90 if (!empty($defaultContactCountry) && !$cachedContactCountry) {
91 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
92 $cachedContactCountry = CRM_Utils_Array
::value($defaultContactCountry,
96 return $cachedContactCountry;
100 * Provide cached default country name.
104 public static function defaultContactCountryName() {
105 static $cachedContactCountryName = NULL;
106 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
107 if (!$cachedContactCountryName && $defaultContactCountry) {
108 $countryCodes = CRM_Core_PseudoConstant
::country();
109 $cachedContactCountryName = $countryCodes[$defaultContactCountry];
111 return $cachedContactCountryName;
115 * Provide cached default currency symbol.
117 * @param string $defaultCurrency
121 public static function defaultCurrencySymbol($defaultCurrency = NULL) {
122 static $cachedSymbol = NULL;
123 if (!$cachedSymbol ||
$defaultCurrency) {
124 $currency = $defaultCurrency ?
$defaultCurrency : Civi
::settings()->get('defaultCurrency');
126 $currencySymbols = CRM_Core_PseudoConstant
::get('CRM_Contribute_DAO_Contribution', 'currency', [
127 'labelColumn' => 'symbol',
128 'orderColumn' => TRUE,
130 $cachedSymbol = CRM_Utils_Array
::value($currency, $currencySymbols, '');
136 return $cachedSymbol;
140 * Get the default currency symbol.
142 * @param string $k Unused variable
146 public static function getDefaultCurrencySymbol($k = NULL) {
147 return CRM_Core_BAO_Country
::defaultCurrencySymbol(\Civi
::settings()->get('defaultCurrency'));