Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Overlay do not call API directly since it does not have access to the token auth. #13420

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions plugins/Overlay/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Piwik;
use Piwik\Plugin\Report;
use Piwik\Plugins\Actions\ArchivingHelper;
use Piwik\Plugins\SegmentEditor\SegmentFormatter;
use Piwik\Plugins\SitesManager\API as APISitesManager;
use Piwik\ProxyHttp;
use Piwik\Segment;
use Piwik\Tracker\Action;
use Piwik\Tracker\PageUrl;
use Piwik\View;
Expand All @@ -37,6 +35,21 @@ public function __construct(SegmentFormatter $segmentFormatter)
parent::__construct();
}

public function getTranslations()
{
return $this->apiRequest('getTranslations');
}

public function getExcludedQueryParameters()
{
return $this->apiRequest('getExcludedQueryParameters');
}

public function getFollowingPages()
{
return $this->apiRequest('getFollowingPages');
}

/** The index of the plugin */
public function index()
{
Expand Down Expand Up @@ -235,4 +248,10 @@ protected function outputCORSHeaders()
$corsHandler = new CORSHandler();
$corsHandler->handle();
}

private function apiRequest($methodName)
{
$request = new Request('method=Overlay.'.$methodName);
return $request->process();
}
}
5 changes: 2 additions & 3 deletions plugins/Overlay/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,8 @@ var Piwik_Overlay_Client = (function () {
},

/** Piwik Overlay API Request */
api: function (method, callback, additionalParams) {
var url = piwikRoot + 'index.php?module=API&method=Overlay.' + method
+ '&idSite=' + idSite + '&period=' + period + '&date=' + date + '&format=JSON&filter_limit=-1';
controller: function (method, callback, additionalParams) {
var url = piwikRoot + 'index.php?module=Overlay&action=' + method + '&idSite=' + idSite + '&period=' + period + '&date=' + date + '&format=JSON&filter_limit=-1';

if (segment) {
url += '&segment=' + segment;
Expand Down
4 changes: 2 additions & 2 deletions plugins/Overlay/client/followingpages.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var Piwik_Overlay_FollowingPages = (function () {
var followingPagesLoaded = false;

// load excluded params
Piwik_Overlay_Client.api('getExcludedQueryParameters', function (data) {
Piwik_Overlay_Client.controller('getExcludedQueryParameters', function (data) {
for (var i = 0; i < data.length; i++) {
if (typeof data[i] == 'object') {
data[i] = data[i][0];
Expand All @@ -44,7 +44,7 @@ var Piwik_Overlay_FollowingPages = (function () {
});

// load following pages
Piwik_Overlay_Client.api('getFollowingPages', function (data) {
Piwik_Overlay_Client.controller('getFollowingPages', function (data) {
followingPages = data;
processFollowingPages();

Expand Down
2 changes: 1 addition & 1 deletion plugins/Overlay/client/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var Piwik_Overlay_Translations = (function () {
*/
initialize: function (callback) {
// Load translation data
Piwik_Overlay_Client.api('getTranslations', function (data) {
Piwik_Overlay_Client.controller('getTranslations', function (data) {
translations = data[0];
callback();
});
Expand Down