Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordizzy <diosmosis@users.noreply.github.com>2021-02-17 10:24:03 +0300
committerGitHub <noreply@github.com>2021-02-17 10:24:03 +0300
commit41964121548784f6e15cbe51194cf3b929be7585 (patch)
tree054f1eb616ea5d4fc96b664c5afd72497bd7209c /plugins/ExamplePlugin
parent419699c0fd3135468e0af2268a1b564997acd037 (diff)
properly encode segment definitions from table so the hash will be the same as from query params (#17029)
* initial fix * when creating a Segment or getting a segment hash using a segment definition from the segment table, make sure to urlencode so the hash is the same as when we send the segment as a query parameter * try to make segment definition change appear in tests (seems like this is just a test fix? if I undo the changes the new test changes still pass) * add test demonstrating bug * check access in exampleplugin * Add missing use * fix test * better fix * fix tests * fix test * update expected screenshots
Diffstat (limited to 'plugins/ExamplePlugin')
-rw-r--r--plugins/ExamplePlugin/API.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/plugins/ExamplePlugin/API.php b/plugins/ExamplePlugin/API.php
index 88f6249ecb..a99c45788e 100644
--- a/plugins/ExamplePlugin/API.php
+++ b/plugins/ExamplePlugin/API.php
@@ -11,6 +11,8 @@ namespace Piwik\Plugins\ExamplePlugin;
use Piwik\Archive;
use Piwik\DataTable;
use Piwik\DataTable\Row;
+use Piwik\Piwik;
+use Piwik\Segment;
/**
* API for plugin ExamplePlugin
@@ -48,6 +50,8 @@ class API extends \Piwik\Plugin\API
*/
public function getExampleReport($idSite, $period, $date, $segment = false)
{
+ Piwik::checkUserHasViewAccess($idSite);
+
$table = DataTable::makeFromSimpleArray(array(
array('label' => 'My Label 1', 'nb_visits' => '1'),
array('label' => 'My Label 2', 'nb_visits' => '5'),
@@ -66,8 +70,18 @@ class API extends \Piwik\Plugin\API
*/
public function getExampleArchivedMetric($idSite, $period, $date, $segment = false)
{
+ Piwik::checkUserHasViewAccess($idSite);
+
$archive = Archive::build($idSite, $period, $date, $segment);
$dataTable = $archive->getDataTableFromNumeric([Archiver::EXAMPLEPLUGIN_METRIC_NAME, Archiver::EXAMPLEPLUGIN_CONST_METRIC_NAME]);
return $dataTable;
}
+
+ public function getSegmentHash($idSite, $segment)
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+
+ $segment = new Segment($segment, [(int) $idSite]);
+ return $segment->getHash();
+ }
}