diff options
Diffstat (limited to 'plugins/MultiSites/API.php')
-rw-r--r-- | plugins/MultiSites/API.php | 39 |
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) { |