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:
authorStefan Giehl <stefan@matomo.org>2022-05-17 11:46:52 +0300
committerGitHub <noreply@github.com>2022-05-17 11:46:52 +0300
commit0acc68778bcb18931b1f74f3374e85832fe2fee1 (patch)
tree2cea1cbcb79f63d393ab9cb74fffaf7751131719 /plugins/MultiSites/API.php
parentf4915657a65088de22bdfa2c380d08f634136061 (diff)
MultiSites: move getAllWithGroups method from Controller to API (#19180)
* MultiSites: move getAllWithGroups method from Controller to API * update test files * updates expected UI files * mark method as not compatible with multiple periods
Diffstat (limited to 'plugins/MultiSites/API.php')
-rw-r--r--plugins/MultiSites/API.php39
1 files changed, 38 insertions, 1 deletions
diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php
index 097725bd84..575964ec30 100644
--- a/plugins/MultiSites/API.php
+++ b/plugins/MultiSites/API.php
@@ -15,6 +15,7 @@ use Piwik\Common;
use Piwik\Container\StaticContainer;
use Piwik\DataTable;
use Piwik\DataTable\Row;
+use Piwik\Period;
use Piwik\Period\Range;
use Piwik\Piwik;
use Piwik\Plugins\Goals\Archiver;
@@ -190,6 +191,42 @@ class API extends \Piwik\Plugin\API
);
}
+ /**
+ * @param null|string $period
+ * @param null|string $date
+ * @param false|string $segment
+ * @param string $pattern
+ * @param int $filter_limit
+ * @return array
+ * @throws Exception
+ */
+ public function getAllWithGroups($period = null, $date = null, $segment = false, $pattern = '', $filter_limit = 0)
+ {
+ Piwik::checkUserHasSomeViewAccess();
+
+ if (Period::isMultiplePeriod($date, $period)) {
+ throw new Exception('Multiple periods are not supported');
+ }
+
+ $segment = $segment ?: false;
+ $request = $_GET + $_POST;
+
+ $dashboard = new Dashboard($period, $date, $segment);
+
+ if ($pattern !== '') {
+ $dashboard->search(strtolower($pattern));
+ }
+
+ $response = [
+ 'numSites' => $dashboard->getNumSites(),
+ 'totals' => $dashboard->getTotals(),
+ 'lastDate' => $dashboard->getLastDate(),
+ 'sites' => $dashboard->getSites($request, $filter_limit)
+ ];
+
+ return $response;
+ }
+
private function getSiteFromId($idSite)
{
$idSite = (int) $idSite;
@@ -242,7 +279,7 @@ class API extends \Piwik\Plugin\API
// if the period isn't a range & a lastN/previousN date isn't used, we get the same
// data for the last period to show the evolution of visits/actions/revenue
- list($strLastDate, $lastPeriod) = Range::getLastDate($date, $period);
+ [$strLastDate, $lastPeriod] = Range::getLastDate($date, $period);
if ($strLastDate !== false) {