3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
37 * This class contains functions for managing Action Logs
39 class CRM_Core_BAO_Country
extends CRM_Core_DAO_Country
{
42 * Get the list of countries for which we offer provinces.
46 public static function provinceLimit() {
47 if (!isset(Civi
::$statics[__CLASS__
]['provinceLimit'])) {
48 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
49 $provinceLimit = Civi
::settings()->get('provinceLimit');
51 if (is_array($provinceLimit)) {
52 foreach ($provinceLimit as $val) {
54 // some countries have disappeared and hence they might be in country limit
55 // but not in the country table
56 if (isset($countryIsoCodes[$val])) {
57 $country[] = $countryIsoCodes[$val];
62 $country[] = $countryIsoCodes[$provinceLimit];
64 Civi
::$statics[__CLASS__
]['provinceLimit'] = $country;
66 return Civi
::$statics[__CLASS__
]['provinceLimit'];
70 * Get the list of countries (with names) which are available to user.
74 public static function countryLimit() {
75 if (!isset(Civi
::$statics[__CLASS__
]['countryLimit'])) {
76 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
78 $countryLimit = Civi
::settings()->get('countryLimit');
79 if (is_array($countryLimit)) {
80 foreach ($countryLimit as $val) {
82 // some countries have disappeared and hence they might be in country limit
83 // but not in the country table
84 if (isset($countryIsoCodes[$val])) {
85 $country[] = $countryIsoCodes[$val];
90 $country[] = $countryIsoCodes[$countryLimit];
92 Civi
::$statics[__CLASS__
]['countryLimit'] = $country;
94 return Civi
::$statics[__CLASS__
]['countryLimit'];
98 * Provide cached default contact country.
102 public static function defaultContactCountry() {
103 static $cachedContactCountry = NULL;
104 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
106 if (!empty($defaultContactCountry) && !$cachedContactCountry) {
107 $countryIsoCodes = CRM_Core_PseudoConstant
::countryIsoCode();
108 $cachedContactCountry = CRM_Utils_Array
::value($defaultContactCountry,
112 return $cachedContactCountry;
116 * Provide cached default country name.
120 public static function defaultContactCountryName() {
121 static $cachedContactCountryName = NULL;
122 $defaultContactCountry = Civi
::settings()->get('defaultContactCountry');
123 if (!$cachedContactCountryName && $defaultContactCountry) {
124 $countryCodes = CRM_Core_PseudoConstant
::country();
125 $cachedContactCountryName = $countryCodes[$defaultContactCountry];
127 return $cachedContactCountryName;
131 * Provide cached default currency symbol.
133 * @param string $defaultCurrency
137 public static function defaultCurrencySymbol($defaultCurrency = NULL) {
138 static $cachedSymbol = NULL;
139 if (!$cachedSymbol ||
$defaultCurrency) {
140 $currency = $defaultCurrency ?
$defaultCurrency : Civi
::settings()->get('defaultCurrency');
142 $currencySymbols = CRM_Core_PseudoConstant
::get('CRM_Contribute_DAO_Contribution', 'currency', array(
143 'labelColumn' => 'symbol',
144 'orderColumn' => TRUE,
146 $cachedSymbol = CRM_Utils_Array
::value($currency, $currencySymbols, '');
152 return $cachedSymbol;
155 public static function getDefaultCurrencySymbol($k = NULL) {
156 $config = CRM_Core_Config
::singleton();
157 return $config->defaultCurrencySymbol(Civi
::settings()->get('defaultCurrency'));