blob: 19ce528a2cc5b7f9f4b0f465e51fdc612bc1e032 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\UserCountry\Columns;
use Piwik\Plugin\Manager;
use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\Tracker\Visitor;
use Piwik\Tracker\Action;
use Piwik\Tracker\Request;
class Provider extends Base
{
protected $columnName = 'location_provider';
protected $type = self::TYPE_TEXT;
protected $category = 'UserCountry_VisitLocation';
/**
* @param Request $request
* @param Visitor $visitor
* @param Action|null $action
* @return mixed
*/
public function onNewVisit(Request $request, Visitor $visitor, $action)
{
if (!Manager::getInstance()->isPluginInstalled('Provider')) {
return false;
}
$userInfo = $this->getUserInfo($request, $visitor);
$isp = $this->getLocationDetail($userInfo, LocationProvider::ISP_KEY);
$org = $this->getLocationDetail($userInfo, LocationProvider::ORG_KEY);
// if the location has provider/organization info, set it
if (!empty($isp)) {
$providerValue = $isp;
// if the org is set and not the same as the isp, add it to the provider value
if (!empty($org) && $org != $providerValue) {
$providerValue .= ' - ' . $org;
}
return $providerValue;
}
if (!empty($org)) {
return $org;
}
return false;
}
}
|