diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-10-07 22:51:40 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-10-07 22:51:40 +0300 |
commit | 89d8479ac242b2ffc98053fe504ce882086c6999 (patch) | |
tree | 6e47c9898547520ab52bf842ca6be84f36c6e153 /plugins/IntranetMeasurable/Tracker/RequestProcessor.php | |
parent | 5470c4f46cbc00ee704ffee6bfae965412771ad3 (diff) |
Add possibility to manage and view Intranet websites (#13473)3.6.1-b3
* Add possibility to manage and view Intranet websites #7724
* more tweaks
* ui tests
* fix some tests
* added missing name
* remove intranet setting, added test for tracking
* fix various tests
* remove test
* Update RequestProcessor.php
* Update en.json
* fix some tests
* do not throw exception if site does not exist
* seeing just now it is fine to trigger exception
* debug error
* log only certain requests
* Update piwik.php
* Update JsProxyTest.php
* trying to fix tests
* remove debug code
* trying to fix tests
Diffstat (limited to 'plugins/IntranetMeasurable/Tracker/RequestProcessor.php')
-rw-r--r-- | plugins/IntranetMeasurable/Tracker/RequestProcessor.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/IntranetMeasurable/Tracker/RequestProcessor.php b/plugins/IntranetMeasurable/Tracker/RequestProcessor.php new file mode 100644 index 0000000000..a97c09893e --- /dev/null +++ b/plugins/IntranetMeasurable/Tracker/RequestProcessor.php @@ -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\Tracker; + +use Piwik\Container\StaticContainer; +use Piwik\Exception\UnexpectedWebsiteFoundException; +use Piwik\Plugins\IntranetMeasurable\Type; +use Piwik\Tracker\Cache; +use Piwik\Tracker\Request; + +class RequestProcessor extends \Piwik\Tracker\RequestProcessor +{ + private $didEnableSetting = false; + private $settingName = 'ini.Tracker.trust_visitors_cookies'; + + public function manipulateRequest(Request $request) + { + try { + $site = Cache::getCacheWebsiteAttributes($request->getIdSite()); + } catch (UnexpectedWebsiteFoundException $e) { + return; + } + $isIntranetSite = !empty($site['type']) && $site['type'] === Type::ID; + + if ($isIntranetSite && !StaticContainer::get($this->settingName)) { + $this->setTrustCookiesSetting(1); + $this->didEnableSetting = true; + } elseif ($this->didEnableSetting) { + // we reset it in case of bulk tracking with different sites etc + $this->setTrustCookiesSetting(0); + $this->didEnableSetting = false; + } + } + + private function setTrustCookiesSetting($value) + { + StaticContainer::get('Piwik\Tracker\VisitorRecognizer')->setTrustCookiesOnly($value); + StaticContainer::getContainer()->set($this->settingName, $value); + } +} |