-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from ThaDafinser/feature/piwik3
piwik3
- Loading branch information
Showing
10 changed files
with
186 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?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\IntranetGeoIP\Columns; | ||
|
||
use Piwik\Tracker\Visitor; | ||
use Piwik\Tracker\Request; | ||
use Piwik\Plugins\UserCountry\Columns\Base as UserCountryBase; | ||
use Piwik\Plugins\IntranetGeoIP\IntranetGeoIP; | ||
|
||
abstract class AbstractBase extends UserCountryBase | ||
{ | ||
|
||
public function onNewVisit(Request $request, Visitor $visitor, $action) | ||
{ | ||
$userInfo = $this->getUserInfo($request, $visitor); | ||
|
||
return $this->getLocationIntranetColumn($userInfo, $this->columnName); | ||
} | ||
|
||
protected function getLocationIntranetColumn(array $userInfo, $locationKey) | ||
{ | ||
$result = IntranetGeoIP::getResult($userInfo); | ||
|
||
if (isset($result[$locationKey])) { | ||
return $result[$locationKey]; | ||
} | ||
|
||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
class OverwriteCity extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_city'; | ||
// protected $columnType = 'varchar(255) DEFAULT NULL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
class OverwriteCountry extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_country'; | ||
// protected $columnType = 'CHAR(3) NULL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
class OverwriteLatitude extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_latitude'; | ||
// protected $columnType = 'decimal(9, 6) DEFAULT NULL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
class OverwriteLongitude extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_longitude'; | ||
// protected $columnType = 'decimal(9, 6) DEFAULT NULL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
use Piwik\Plugin\Manager; | ||
use Piwik\Tracker\Visitor; | ||
use Piwik\Tracker\Action; | ||
use Piwik\Tracker\Request; | ||
|
||
class OverwriteProvider extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_provider'; | ||
|
||
public function onNewVisit(Request $request, Visitor $visitor, $action) | ||
{ | ||
if (! Manager::getInstance()->isPluginInstalled('Provider')) { | ||
return false; | ||
} | ||
|
||
return parent::onNewVisit($request, $visitor, $action); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
namespace Piwik\Plugins\IntranetGeoIP\Columns; | ||
|
||
class OverwriteRegion extends AbstractBase | ||
{ | ||
|
||
protected $columnName = 'location_region'; | ||
// protected $columnType = 'char(2) DEFAULT NULL'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
{ | ||
"name": "IntranetGeoIP", | ||
"version": "2.3.2", | ||
"description": "Piwik plugin to locate all locale data of a user based on the IP address/subnetwork (country, region, city, latitude, longitude, provider, ...)", | ||
"keywords": ["Subnet", "Intranet", "IPv4", "IPv6", "GeoIP", "ThaDafinser"], | ||
"license": "GPL v3", | ||
"homepage": "https://github.com/ThaDafinser/Piwik-IntranetGeoIP", | ||
"authors": [ | ||
{"name": "Martin Keckeis", "homepage": "https://github.com/thadafinser"} | ||
], | ||
"theme": false, | ||
"require": { | ||
"piwik": ">=2.15.0,<3.0.0-b1", | ||
"php": ">=5.6.0" | ||
} | ||
} | ||
{ | ||
"name": "IntranetGeoIP", | ||
"version": "3.0.0", | ||
"description": "Piwik plugin to locate all locale data of a user based on the IP address/subnetwork (country, region, city, latitude, longitude, provider, ...)", | ||
"keywords": ["Subnet", "Intranet", "IPv4", "IPv6", "GeoIP", "ThaDafinser"], | ||
"license": "GPL v3", | ||
"homepage": "https://github.com/ThaDafinser/Piwik-IntranetGeoIP", | ||
"authors": [ | ||
{"name": "Martin Keckeis", "homepage": "https://github.com/thadafinser"} | ||
], | ||
"theme": false, | ||
"require": { | ||
"piwik": ">=2.16.0,<4.0.0-b1", | ||
"php": ">=5.6.0" | ||
} | ||
} |