diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-25 17:14:23 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-26 11:23:38 +0400 |
commit | ade4198dd4bdcfd7c03119bb52208e006bf64082 (patch) | |
tree | 4cfb4e9eaf3a09ac765d16a40927c7cd111353da /plugins/Provider | |
parent | 63777c8158e50e4da66b13bb96c360f2550fcd0f (diff) |
refs #6045 #6049 added an event to collect visitor info and made sure the Piwik UI kinda works when most tracker plugins are disabled
Diffstat (limited to 'plugins/Provider')
-rw-r--r-- | plugins/Provider/Provider.php | 19 | ||||
-rw-r--r-- | plugins/Provider/Visitor.php | 42 |
2 files changed, 61 insertions, 0 deletions
diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 9c06887c1e..719029dc8b 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -17,6 +17,16 @@ use Piwik\Piwik; class Provider extends \Piwik\Plugin { + /** + * @see Piwik\Plugin::getListHooksRegistered + */ + public function getListHooksRegistered() + { + return array( + 'Live.getAllVisitorDetails' => 'extendVisitorDetails' + ); + } + public function install() { // add column hostname / hostname ext in the visit table @@ -32,6 +42,15 @@ class Provider extends \Piwik\Plugin } } + public function extendVisitorDetails(&$visitor, $details) + { + $instance = new Visitor($details); + + $visitor['provider'] = $instance->getProvider(); + $visitor['providerName'] = $instance->getProviderName(); + $visitor['providerUrl'] = $instance->getProviderUrl(); + } + public function uninstall() { // add column hostname / hostname ext in the visit table diff --git a/plugins/Provider/Visitor.php b/plugins/Provider/Visitor.php new file mode 100644 index 0000000000..0efbb92eb3 --- /dev/null +++ b/plugins/Provider/Visitor.php @@ -0,0 +1,42 @@ +<?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\Provider; + +use Piwik\Piwik; + +require_once PIWIK_INCLUDE_PATH . '/plugins/Provider/functions.php'; + +class Visitor +{ + private $details = array(); + + public function __construct($details) + { + $this->details = $details; + } + + public function getProvider() + { + if (isset($this->details['location_provider'])) { + return $this->details['location_provider']; + } else { + return Piwik::translate('General_Unknown'); + } + } + + public function getProviderName() + { + return getPrettyProviderName($this->getProvider()); + } + + public function getProviderUrl() + { + return getHostnameUrl(@$this->details['location_provider']); + } +}
\ No newline at end of file |