diff options
-rw-r--r-- | config/global.ini.php | 1 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 13 | ||||
-rw-r--r-- | plugins/Live/Visitor.php | 2 | ||||
-rw-r--r-- | plugins/UserCountry/API.php | 4 | ||||
-rw-r--r-- | plugins/UserCountry/UserCountry.php | 2 | ||||
-rw-r--r-- | plugins/UserCountry/functions.php | 12 |
6 files changed, 14 insertions, 20 deletions
diff --git a/config/global.ini.php b/config/global.ini.php index d8c78a70b6..82da69ad1d 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -522,6 +522,7 @@ PluginsInstalled[] = Installation Plugins_Tracker[] = Provider Plugins_Tracker[] = Goals Plugins_Tracker[] = DoNotTrack +Plugins_Tracker[] = UserCountry [APISettings] ; Any key/value pair can be added in this section, they will be available via the REST call diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index e516593873..146112734d 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -35,6 +35,8 @@ interface Piwik_Tracker_Visit_Interface { */ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface { + const UNKNOWN_CODE = 'xx'; + /** * @var Piwik_Cookie */ @@ -606,16 +608,9 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface $userInfo = array('lang' => $browserLang, 'ip' => Piwik_IP::N2P($this->getVisitorIp())); Piwik_PostEvent('Tracker.getVisitorLocation', $location, $userInfo); - if (empty($location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY])) - { - $location[Piwik_UserCountry_LocationProvider::COUNTRY_CODE_KEY] = - Piwik_UserCountry::UNKNOWN_CODE; - } - - if (empty($location[Piwik_UserCountry_LocationProvider::CONTINENT_CODE_KEY])) + if (empty($location['country_code'])) // sanity check { - $location[Piwik_UserCountry_LocationProvider::CONTINENT_CODE_KEY] = - Piwik_UserCountry::UNKNOWN_CODE; + $location['country_code'] = self::UNKNOWN_CODE; } return $location; diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index 97eeac99a4..9cf0aff607 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -230,7 +230,7 @@ class Piwik_Live_Visitor // add region if it's known $region = $this->details['location_region']; - if ($region != '' && $region != Piwik_UserCountry::UNKNOWN_CODE) + if ($region != '' && $region != Piwik_Tracker_Visit::UNKNOWN_CODE) { $parts[] = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes( $this->details['location_country'], $region); diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php index 4043e88b88..0309dc01d8 100644 --- a/plugins/UserCountry/API.php +++ b/plugins/UserCountry/API.php @@ -76,7 +76,7 @@ class Piwik_UserCountry_API $dataTable = $this->getDataTable($recordName, $idSite, $period, $date, $segment); $separator = Piwik_UserCountry::LOCATION_SEPARATOR; - $unk = Piwik_UserCountry::UNKNOWN_CODE; + $unk = Piwik_Tracker_Visit::UNKNOWN_CODE; // split the label and put the elements into the 'region' and 'country' metadata fields $dataTable->filter('ColumnCallbackAddMetadata', @@ -119,7 +119,7 @@ class Piwik_UserCountry_API $dataTable = $this->getDataTable($recordName, $idSite, $period, $date, $segment); $separator = Piwik_UserCountry::LOCATION_SEPARATOR; - $unk = Piwik_UserCountry::UNKNOWN_CODE; + $unk = Piwik_Tracker_Visit::UNKNOWN_CODE; // split the label and put the elements into the 'city_name', 'region', 'country', // 'lat' & 'long' metadata fields diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 7fbc4455d8..3d8e421892 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -22,8 +22,6 @@ class Piwik_UserCountry extends Piwik_Plugin const DISTINCT_COUNTRIES_METRIC = 'UserCountry_distinctCountries'; - const UNKNOWN_CODE = 'xx'; - // separate region, city & country info in stored report labels const LOCATION_SEPARATOR = '|'; diff --git a/plugins/UserCountry/functions.php b/plugins/UserCountry/functions.php index 9cf0583819..f91fedb19d 100644 --- a/plugins/UserCountry/functions.php +++ b/plugins/UserCountry/functions.php @@ -25,7 +25,7 @@ function Piwik_getFlagFromCode($code) { return $pathWithCode; } - return sprintf($pathInPiwik, Piwik_UserCountry::UNKNOWN_CODE); + return sprintf($pathInPiwik, Piwik_Tracker_Visit::UNKNOWN_CODE); } /** @@ -51,7 +51,7 @@ function Piwik_ContinentTranslate($label) */ function Piwik_CountryTranslate($label) { - if($label == Piwik_UserCountry::UNKNOWN_CODE || $label == '') + if($label == Piwik_Tracker_Visit::UNKNOWN_CODE || $label == '') { return Piwik_Translate('General_Unknown'); } @@ -126,7 +126,7 @@ function Piwik_UserCountry_getPrettyRegionName( $label ) list($regionCode, $countryCode) = explode(Piwik_UserCountry::LOCATION_SEPARATOR, $label); $result = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode); - if ($countryCode != Piwik_UserCountry::UNKNOWN_CODE && $countryCode != '') + if ($countryCode != Piwik_Tracker_Visit::UNKNOWN_CODE && $countryCode != '') { $result .= ', '.Piwik_CountryTranslate($countryCode); } @@ -160,15 +160,15 @@ function Piwik_UserCountry_getPrettyCityName( $label ) $regionCode = $parts[1]; $countryCode = $parts[2]; - if ($cityName == Piwik_UserCountry::UNKNOWN_CODE || $cityName == '') + if ($cityName == Piwik_Tracker_Visit::UNKNOWN_CODE || $cityName == '') { $cityName = Piwik_Translate('General_Unknown'); } $result = $cityName; - if ($countryCode != Piwik_UserCountry::UNKNOWN_CODE && $countryCode != '') + if ($countryCode != Piwik_Tracker_Visit::UNKNOWN_CODE && $countryCode != '') { - if ($regionCode != '' && $regionCode != Piwik_UserCountry::UNKNOWN_CODE) + if ($regionCode != '' && $regionCode != Piwik_Tracker_Visit::UNKNOWN_CODE) { $regionName = Piwik_UserCountry_LocationProvider_GeoIp::getRegionNameFromCodes($countryCode, $regionCode); $result .= ', '.$regionName; |