Save user dashboards to Icinga Web 2's configuration directory

fixes #8056
This commit is contained in:
Eric Lippmann 2015-02-02 15:05:47 +01:00
parent 6555a2ec0a
commit 9d6906bd64
2 changed files with 4 additions and 25 deletions

View File

@ -24,11 +24,11 @@ class DashboardController extends ActionController
* @var Dashboard; * @var Dashboard;
*/ */
private $dashboard; private $dashboard;
public function init() public function init()
{ {
$this->dashboard = new Dashboard(); $this->dashboard = new Dashboard();
$this->dashboard->setUser($this->getRequest()->getUser()); $this->dashboard->setUser($this->Auth()->getUser());
$this->dashboard->load(); $this->dashboard->load();
} }

View File

@ -9,7 +9,6 @@ use Icinga\Application\Config;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotReadableError; use Icinga\Exception\NotReadableError;
use Icinga\Exception\ProgrammingError; use Icinga\Exception\ProgrammingError;
use Icinga\Exception\SystemPermissionException;
use Icinga\User; use Icinga\User;
use Icinga\Web\Widget\Dashboard\Pane; use Icinga\Web\Widget\Dashboard\Pane;
use Icinga\Web\Widget\Dashboard\Dashlet as DashboardDashlet; use Icinga\Web\Widget\Dashboard\Dashlet as DashboardDashlet;
@ -425,28 +424,8 @@ class Dashboard extends AbstractWidget
public function getConfigFile() public function getConfigFile()
{ {
if ($this->user === null) { if ($this->user === null) {
return ''; throw new ProgrammingError('Can\'t load dashboards. User is not set');
} }
return Config::resolvePath('dashboards/' . $this->user->getUsername() . '/dashboard.ini');
$baseDir = '/var/lib/icingaweb';
if (! file_exists($baseDir)) {
throw new NotReadableError('Could not read: ' . $baseDir);
}
$userDir = $baseDir . '/' . $this->user->getUsername();
if (! file_exists($userDir)) {
$success = @mkdir($userDir);
if (!$success) {
throw new SystemPermissionException('Could not create: ' . $userDir);
}
}
if (! file_exists($userDir)) {
throw new NotReadableError('Could not read: ' . $userDir);
}
return $userDir . '/dashboard.ini';
} }
} }