Piwik\Plugins\Dashboard\Controller::createNewDashboard PHP Method

createNewDashboard() public method

Creates a new dashboard for the current user User needs to be logged in
public createNewDashboard ( )
    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);
    }