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:
authorThomas Steur <thomas.steur@googlemail.com>2014-06-18 09:13:42 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-06-18 09:14:14 +0400
commit79ec9d19368dbe49b4dbb34bb4762784962b3652 (patch)
tree0a2e6d648bd9767cb0c458ca4cc6f3f9adb3c503 /core/FrontController.php
parentc6f7e78c537921bda68b51c993ada8a220f896c1 (diff)
this is epic... by rendering the reports this way we can remove a lot of duplicated, unneeded code while having backwards compatible urls, developers are still able to completely overwrite the reports controller action, we fix some issues where CoreHome.renderWidget was reported in dispatch events instead of the actual module/action -> fixes also some security issues and most saved params for reports work again. Hope it works as expected
Diffstat (limited to 'core/FrontController.php')
-rw-r--r--core/FrontController.php20
1 files changed, 16 insertions, 4 deletions
diff --git a/core/FrontController.php b/core/FrontController.php
index c67d313337..0a716d3366 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -13,6 +13,7 @@ use Exception;
use Piwik\API\Request;
use Piwik\API\ResponseBuilder;
use Piwik\Plugin\Controller;
+use Piwik\Plugin\Report;
use Piwik\Session;
/**
@@ -100,7 +101,7 @@ class FrontController extends Singleton
}
}
- protected function makeController($module, $action)
+ protected function makeController($module, $action, &$parameters)
{
$controllerClassName = $this->getClassNameController($module);
@@ -121,8 +122,19 @@ class FrontController extends Singleton
}
if (!is_callable(array($controller, $action))) {
- throw new Exception("Action '$action' not found in the controller '$controllerClassName'.");
+
+ $report = Report::factory($module, $action);
+
+ if (empty($report) || !$report->isEnabled()) {
+ throw new Exception("Action '$action' not found in the controller '$controllerClassName'.");
+ }
+
+ $parameters['reportModule'] = $module;
+ $parameters['reportAction'] = $action;
+
+ return $this->makeController('CoreHome', 'renderWidget', $parameters);
}
+
return array($controller, $action);
}
@@ -484,7 +496,7 @@ class FrontController extends Singleton
*/
Piwik::postEvent('Request.dispatch', array(&$module, &$action, &$parameters));
- list($controller, $action) = $this->makeController($module, $action);
+ list($controller, $actionToCall) = $this->makeController($module, $action, $parameters);
/**
* Triggered directly before controller actions are dispatched.
@@ -499,7 +511,7 @@ class FrontController extends Singleton
*/
Piwik::postEvent(sprintf('Controller.%s.%s', $module, $action), array(&$parameters));
- $result = call_user_func_array(array($controller, $action), $parameters);
+ $result = call_user_func_array(array($controller, $actionToCall), $parameters);
/**
* Triggered after a controller action is successfully called.