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
path: root/core
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-06-19 05:37:17 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-06-19 05:37:17 +0400
commit253b165e621953efcb692f985036e217920ba696 (patch)
treede76a07700ed5b41f3f6a2cc4a880351e1b8b20b /core
parent95aed5eba938839e2ffe74beca4fbf3399c77a54 (diff)
added possibility to pass a report instance to renderReport() in controller, fixed a bug in menu where the sorting was wrong in case the first added menu item of a category was a submenu entry, made sure it is possible for plugin Menu classes to rename/modify report menu entries, created some reports for live plugin, centralized no permission to view report check and made it possible to overwrite this message for each report
Diffstat (limited to 'core')
-rw-r--r--core/Menu/MenuAbstract.php23
-rw-r--r--core/Menu/MenuReporting.php7
-rw-r--r--core/Plugin/Controller.php9
-rw-r--r--core/Plugin/Report.php7
4 files changed, 34 insertions, 12 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index 3f624b117f..cbd5c5a798 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -126,13 +126,17 @@ abstract class MenuAbstract extends Singleton
*/
private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false)
{
- if (!isset($this->menu[$menuName]) || empty($subMenuName)) {
- $this->menu[$menuName]['_url'] = $url;
- if (empty($subMenuName)) {
- $this->menu[$menuName]['_order'] = $order;
- }
- $this->menu[$menuName]['_name'] = $menuName;
- $this->menu[$menuName]['_hasSubmenu'] = false;
+ if (!isset($this->menu[$menuName])) {
+ $this->menu[$menuName] = array(
+ '_hasSubmenu' => false,
+ '_order' => $order
+ );
+ }
+
+ if (empty($subMenuName)) {
+ $this->menu[$menuName]['_url'] = $url;
+ $this->menu[$menuName]['_order'] = $order;
+ $this->menu[$menuName]['_name'] = $menuName;
$this->menu[$menuName]['_tooltip'] = $tooltip;
}
if (!empty($subMenuName)) {
@@ -141,7 +145,10 @@ abstract class MenuAbstract extends Singleton
$this->menu[$menuName][$subMenuName]['_name'] = $subMenuName;
$this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip;
$this->menu[$menuName]['_hasSubmenu'] = true;
- $this->menu[$menuName]['_tooltip'] = $tooltip;
+
+ if (!array_key_exists('_tooltip', $this->menu[$menuName])) {
+ $this->menu[$menuName]['_tooltip'] = $tooltip;
+ }
}
}
diff --git a/core/Menu/MenuReporting.php b/core/Menu/MenuReporting.php
index 67f95bb8a6..d704134510 100644
--- a/core/Menu/MenuReporting.php
+++ b/core/Menu/MenuReporting.php
@@ -68,13 +68,14 @@ class MenuReporting extends MenuAbstract
*/
Piwik::postEvent('Menu.Reporting.addItems', array());
+ foreach (Report::getAllReports() as $report) {
+ $report->configureReportingMenu($this);
+ }
+
foreach ($this->getAvailableMenus() as $menu) {
$menu->configureReportingMenu($this);
}
- foreach (Report::getAllReports() as $report) {
- $report->configureReportingMenu($this);
- }
}
return parent::getMenu();
diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php
index 056ff50ba8..d3ae15a306 100644
--- a/core/Plugin/Controller.php
+++ b/core/Plugin/Controller.php
@@ -251,7 +251,8 @@ abstract class Controller
/**
* Convenience method that creates and renders a ViewDataTable for a API method.
*
- * @param string $apiAction The name of the API action (eg, `'getResolution'`).
+ * @param string|\Piwik\Plugin\Report $apiAction The name of the API action (eg, `'getResolution'`) or
+ * an instance of an report.
* @param bool $controllerAction The name of the Controller action name that is rendering the report. Defaults
* to the `$apiAction`.
* @param bool $fetch If `true`, the rendered string is returned, if `false` it is `echo`'d.
@@ -262,6 +263,12 @@ abstract class Controller
*/
protected function renderReport($apiAction, $controllerAction = false)
{
+ if ($apiAction instanceof Report) {
+ $apiAction->checkIsEnabled();
+
+ return $apiAction->render();
+ }
+
if (empty($controllerAction)) {
$report = Report::factory($this->pluginName, $apiAction);
diff --git a/core/Plugin/Report.php b/core/Plugin/Report.php
index b45cb75b72..d3c4159802 100644
--- a/core/Plugin/Report.php
+++ b/core/Plugin/Report.php
@@ -69,6 +69,13 @@ class Report
return true;
}
+ public function checkIsEnabled()
+ {
+ if (!$this->isEnabled()) {
+ throw new \Exception('This report is not enabled. Maybe you do not have enough permission');
+ }
+ }
+
public function getDefaultTypeViewDataTable()
{
return HtmlTable::ID;