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@piwik.org>2018-03-09 06:29:25 +0300
committerMatthieu Aubry <mattab@users.noreply.github.com>2018-03-09 06:29:25 +0300
commitb77050f1772d16bcbd7cd4cd89f2a61ece43df89 (patch)
tree8229c7849db3d4cc112cac7fcd91598e92ee5608 /plugins/Dashboard/Controller.php
parentd9e8932997828762af26b4163b834a0ba018060b (diff)
Moves some dashboard methods to API (#12587)
* Move some dashboard methods to API * Pass correct param in dashboard APITest for createNewDashboardForUser API method.
Diffstat (limited to 'plugins/Dashboard/Controller.php')
-rw-r--r--plugins/Dashboard/Controller.php76
1 files changed, 3 insertions, 73 deletions
diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php
index bef5a89237..4aaabe1828 100644
--- a/plugins/Dashboard/Controller.php
+++ b/plugins/Dashboard/Controller.php
@@ -7,6 +7,7 @@
*/
namespace Piwik\Plugins\Dashboard;
+use Piwik\API\Request;
use Piwik\Common;
use Piwik\DataTable\Renderer\Json;
use Piwik\Db;
@@ -85,14 +86,12 @@ class Controller extends \Piwik\Plugin\Controller
public function resetLayout()
{
$this->checkTokenInUrl();
- $layout = $this->dashboard->getDefaultLayout();
- $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
if (Piwik::isUserIsAnonymous()) {
$session = new SessionNamespace("Dashboard");
- $session->dashboardLayout = $layout;
+ $session->dashboardLayout = $this->dashboard->getDefaultLayout();
$session->setExpirationSeconds(1800);
} else {
- $this->getModel()->updateLayoutForUser(Piwik::getCurrentUserLogin(), $idDashboard, $layout);
+ Request::processRequest('Dashboard.resetDashboardLayout');
}
}
@@ -102,25 +101,6 @@ class Controller extends \Piwik\Plugin\Controller
}
/**
- * Removes the dashboard with the given id
- */
- public function removeDashboard()
- {
- $this->checkTokenInUrl();
-
- if (Piwik::isUserIsAnonymous()) {
- return;
- }
-
- $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
-
- // first layout can't be removed
- if ($idDashboard != 1) {
- $this->getModel()->deleteDashboardForUser($idDashboard, Piwik::getCurrentUserLogin());
- }
- }
-
- /**
* Outputs all available dashboards for the current user as a JSON string
*/
public function getAllDashboards()
@@ -140,56 +120,6 @@ class Controller extends \Piwik\Plugin\Controller
}
/**
- * Creates a new dashboard for the current user
- * User needs to be logged in
- */
- public function createNewDashboard()
- {
- $this->checkTokenInUrl();
-
- if (Piwik::isUserIsAnonymous()) {
- return '0';
- }
-
- $name = urldecode(Common::getRequestVar('name', '', 'string'));
- $type = urldecode(Common::getRequestVar('type', 'default', 'string'));
- $layout = '{}';
- $login = Piwik::getCurrentUserLogin();
-
- if ($type == 'default') {
- $layout = $this->dashboard->getDefaultLayout();
- }
-
- $nextId = $this->getModel()->createNewDashboardForUser($login, $name, $layout);
-
- Json::sendHeaderJSON();
- return json_encode($nextId);
- }
-
- public function copyDashboardToUser()
- {
- $this->checkTokenInUrl();
-
- if (!Piwik::hasUserSuperUserAccess()) {
- return '0';
- }
-
- $login = Piwik::getCurrentUserLogin();
- $name = urldecode(Common::getRequestVar('name', '', 'string'));
- $user = urldecode(Common::getRequestVar('user', '', 'string'));
- $idDashboard = Common::getRequestVar('dashboardId', 0, 'int');
-
- $layout = $this->dashboard->getLayoutForUser($login, $idDashboard);
-
- if ($layout !== false) {
- $nextId = $this->getModel()->createNewDashboardForUser($user, $name, $layout);
-
- Json::sendHeaderJSON();
- return json_encode($nextId);
- }
- }
-
- /**
* Saves the layout for the current user
* anonymous = in the session
* authenticated user = in the DB