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
19 * This class contains functions for managing Action Logs
21 class CRM_Core_BAO_Country
extends CRM_Core_DAO_Country
{
24 * Get the list of countries for which we offer provinces.
28 public static function provinceLimit() {
29 if (!isset(Civi
::$statics[__CLASS__
]['provinceLimit'])) {
30 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
31 $provinceLimit = Civi
::settings()->get('provinceLimit');
33 if (is_array($provinceLimit)) {
34 foreach ($provinceLimit as $val) {
36 // some countries have disappeared and hence they might be in country limit
37 // but not in the country table
38 if (isset($countryIsoCodes[$val])) {
39 $country[] = $countryIsoCodes[$val];
44 $country[] = $countryIsoCodes[$provinceLimit];
46 Civi
::$statics[__CLASS__
]['provinceLimit'] = $country;
48 return Civi
::$statics[__CLASS__
]['provinceLimit'];
52 * Get the list of countries (with names) which are available to user.
56 public static function countryLimit() {
57 if (!isset(Civi
::$statics[__CLASS__
]['countryLimit'])) {
58 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
60 $countryLimit = Civi
::settings()->get('countryLimit');
61 if (is_array($countryLimit)) {
62 foreach ($countryLimit as $val) {
64 // some countries have disappeared and hence they might be in country limit
65 // but not in the country table
66 if (isset($countryIsoCodes[$val])) {
67 $country[] = $countryIsoCodes[$val];
72 $country[] = $countryIsoCodes[$countryLimit];
74 Civi
::$statics[__CLASS__
]['countryLimit'] = $country;
76 return Civi
::$statics[__CLASS__
]['countryLimit'];
80 * Provide cached default contact country.
84 public static function defaultContactCountry() {
85 static $cachedContactCountry = NULL;
86 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
88 if (!empty($defaultContactCountry) && !$cachedContactCountry) {
89 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
90 $cachedContactCountry = CRM_Utils_Array
::value($defaultContactCountry,
94 return $cachedContactCountry;
98 * Provide cached default country name.
102 public static function defaultContactCountryName() {
103 static $cachedContactCountryName = NULL;
104 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
105 if (!$cachedContactCountryName && $defaultContactCountry) {
106 $countryCodes = CRM_Core_PseudoConstant
::country();
107 $cachedContactCountryName = $countryCodes[$defaultContactCountry];
109 return $cachedContactCountryName;
113 * Provide cached default currency symbol.
115 * @param string $defaultCurrency
119 public static function defaultCurrencySymbol($defaultCurrency = NULL) {
120 static $cachedSymbol = NULL;
121 if (!$cachedSymbol ||
$defaultCurrency) {
122 $currency = $defaultCurrency ?
$defaultCurrency : Civi
::settings()->get('defaultCurrency');
124 $currencySymbols = CRM_Core_PseudoConstant
::get('CRM_Contribute_DAO_Contribution', 'currency', [
125 'labelColumn' => 'symbol',
126 'orderColumn' => TRUE,
128 $cachedSymbol = CRM_Utils_Array
::value($currency, $currencySymbols, '');
134 return $cachedSymbol;
138 * Get the default currency symbol.
140 * @param string $k Unused variable
144 public static function getDefaultCurrencySymbol($k = NULL) {
145 return CRM_Core_BAO_Country
::defaultCurrencySymbol(\Civi
::settings()->get('defaultCurrency'));