-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to manage and view Intranet websites #7724
- Loading branch information
Showing
11 changed files
with
163 additions
and
6 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
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
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,46 @@ | ||
<?php | ||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\IntranetMeasurable; | ||
|
||
use Piwik\Container\StaticContainer; | ||
use Piwik\Site; | ||
|
||
class IntranetMeasurable extends \Piwik\Plugin | ||
{ | ||
/** | ||
* @see \Piwik\Plugin::registerEvents | ||
*/ | ||
public function registerEvents() | ||
{ | ||
return array( | ||
'Tracker.Cache.getSiteAttributes' => 'recordWebsiteDataInCache', | ||
); | ||
} | ||
|
||
public function isTrackerPlugin() | ||
{ | ||
return true; | ||
} | ||
|
||
public function recordWebsiteDataInCache(&$array, $idSite) | ||
{ | ||
$idSite = (int) $idSite; | ||
$type = Site::getTypeFor($idSite); | ||
if ($type === Type::ID) { | ||
/** @var \Piwik\Plugins\IntranetMeasurable\MeasurableSettings $measurableSettings */ | ||
$measurableSettings = StaticContainer::getContainer()->make( | ||
'\Piwik\Plugins\IntranetMeasurable\MeasurableSettings', | ||
array('idSite' => $idSite, 'idMeasurableType' => Site::getTypeFor($idSite)) | ||
); | ||
|
||
// add the 'hosts' entry in the website array | ||
$array['enable_trust_visitors_cookies'] = (int) $measurableSettings->trustvisitorcookies->getValue(); | ||
} | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\IntranetMeasurable; | ||
|
||
use Piwik\Piwik; | ||
use Piwik\Settings\FieldConfig; | ||
use Piwik\Settings\Setting; | ||
|
||
class MeasurableSettings extends \Piwik\Plugins\WebsiteMeasurable\MeasurableSettings | ||
{ | ||
/** @var Setting */ | ||
public $trustvisitorcookies; | ||
|
||
protected function shouldShowSettingsForType($type) | ||
{ | ||
return $type === Type::ID; | ||
} | ||
|
||
protected function init() | ||
{ | ||
$this->trustvisitorcookies = $this->makeTrustVisitorCookies(); | ||
parent::init(); | ||
} | ||
|
||
private function makeTrustVisitorCookies() | ||
{ | ||
return $this->makeSetting('trust_visitors_cookies', $default = true, FieldConfig::TYPE_BOOL, function (FieldConfig $field) { | ||
$field->title = Piwik::translate('IntranetMeasurable_TrustVisitorCookies'); | ||
$field->inlineHelp = Piwik::translate('IntranetMeasurable_TrustVisitorCookiesHelp'); | ||
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX; | ||
}); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
*/ | ||
|
||
namespace Piwik\Plugins\IntranetMeasurable\Tracker; | ||
|
||
use Piwik\Container\StaticContainer; | ||
use Piwik\Plugins\IntranetMeasurable\MeasurableSettings; | ||
use Piwik\Plugins\IntranetMeasurable\Type; | ||
use Piwik\Tracker\Cache; | ||
use Piwik\Tracker\Request; | ||
|
||
class RequestProcessor extends \Piwik\Tracker\RequestProcessor | ||
{ | ||
private $settingName = 'ini.Tracker.trust_visitors_cookies'; | ||
|
||
public function manipulateRequest(Request $request) | ||
{ | ||
$idSite = $request->getIdSite(); | ||
if ($idSite && !StaticContainer::get($this->settingName)) { | ||
// we may need to enable it for an intranet site... | ||
|
||
$site = Cache::getCacheWebsiteAttributes($idSite); | ||
if (!empty($site['type']) | ||
&& $site['type'] === Type::ID | ||
&& !empty($site['enable_trust_visitors_cookies'])) { | ||
|
||
StaticContainer::get('Piwik\Tracker\VisitorRecognizer')->setTrustCookiesOnly(1); | ||
StaticContainer::getContainer()->set($this->settingName, 1); | ||
} | ||
} | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
/** | ||
* Matomo - free/libre analytics platform | ||
* | ||
* @link https://matomo.org | ||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | ||
* | ||
*/ | ||
namespace Piwik\Plugins\IntranetMeasurable; | ||
|
||
class Type extends \Piwik\Measurable\Type | ||
{ | ||
const ID = 'intranet'; | ||
protected $name = 'IntranetMeasurable_Intranet'; | ||
protected $namePlural = 'IntranetMeasurable_Intranets'; | ||
protected $description = 'IntranetMeasurable_IntranetDescription'; | ||
protected $howToSetupUrl = '?module=CoreAdminHome&action=trackingCodeGenerator'; | ||
|
||
} | ||
|
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 @@ | ||
{ | ||
"IntranetMeasurable": { | ||
"Intranet": "Intranet", | ||
"Intranets": "Intranets", | ||
"IntranetDescription": "An intranet measurable is just like a website but hosted on an internal network.", | ||
"TrustVisitorCookies": "Trust Visitor Cookies", | ||
"TrustVisitorCookiesHelp": "This should be enabled when most visitors have the same configuration (browsers, operating systems); and the same IP for better unique visitors recognition. If disabled, all visitors will be counted as one single visitor." | ||
} | ||
} |
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,4 @@ | ||
{ | ||
"name": "IntranetMeasurable", | ||
"description": "Analytics for the web: lets you measure and analyze intranet websites." | ||
} |
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