2013-06-27 12:45:18 +02:00
|
|
|
<?php
|
2015-02-04 10:46:36 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */
|
2013-06-27 12:45:18 +02:00
|
|
|
|
2015-08-27 13:36:33 +02:00
|
|
|
namespace Icinga\Controllers;
|
|
|
|
|
2014-09-05 10:21:24 +02:00
|
|
|
use Icinga\Application\Config;
|
2015-07-01 15:41:45 +02:00
|
|
|
use Icinga\Data\ConfigObject;
|
2015-08-27 13:35:32 +02:00
|
|
|
use Icinga\Forms\PreferenceForm;
|
2014-09-05 10:21:24 +02:00
|
|
|
use Icinga\User\Preferences\PreferencesStore;
|
2015-08-27 13:35:32 +02:00
|
|
|
use Icinga\Web\Controller\BasePreferenceController;
|
|
|
|
use Icinga\Web\Url;
|
|
|
|
use Icinga\Web\Widget\Tab;
|
2013-06-27 12:45:18 +02:00
|
|
|
|
|
|
|
/**
|
2013-08-12 15:58:26 +02:00
|
|
|
* Application wide preference controller for user preferences
|
2015-08-27 13:38:19 +02:00
|
|
|
*
|
|
|
|
* @TODO(el): Rename to PreferencesController: https://dev.icinga.org/issues/10014
|
2013-06-27 12:45:18 +02:00
|
|
|
*/
|
2013-08-12 15:58:26 +02:00
|
|
|
class PreferenceController extends BasePreferenceController
|
2013-06-27 12:45:18 +02:00
|
|
|
{
|
2013-08-12 15:58:26 +02:00
|
|
|
/**
|
2013-08-14 12:42:32 +02:00
|
|
|
* Create tabs for this preference controller
|
2013-08-12 15:58:26 +02:00
|
|
|
*
|
2013-08-16 14:56:23 +02:00
|
|
|
* @return array
|
|
|
|
*
|
|
|
|
* @see BasePreferenceController::createProvidedTabs()
|
2013-08-12 15:58:26 +02:00
|
|
|
*/
|
|
|
|
public static function createProvidedTabs()
|
2013-06-27 12:45:18 +02:00
|
|
|
{
|
2013-08-12 15:58:26 +02:00
|
|
|
return array(
|
2015-10-01 09:01:03 +02:00
|
|
|
'preferences' => new Tab(array(
|
|
|
|
'title' => t('Adjust the preferences of Icinga Web 2 according to your needs'),
|
|
|
|
'label' => t('Preferences'),
|
|
|
|
'url' => 'preference'
|
|
|
|
)),
|
|
|
|
'navigation' => new Tab(array(
|
|
|
|
'title' => t('List and configure your own navigation items'),
|
|
|
|
'label' => t('Navigation'),
|
|
|
|
'url' => 'navigation'
|
|
|
|
))
|
2013-08-12 15:58:26 +02:00
|
|
|
);
|
2013-06-27 12:45:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-05 10:21:24 +02:00
|
|
|
* Show form to adjust user preferences
|
2013-06-27 12:45:18 +02:00
|
|
|
*/
|
2013-06-27 16:06:38 +02:00
|
|
|
public function indexAction()
|
2013-06-27 12:45:18 +02:00
|
|
|
{
|
2015-07-01 15:41:45 +02:00
|
|
|
$config = Config::app()->getSection('global');
|
2014-09-05 10:21:24 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
2015-07-01 15:41:45 +02:00
|
|
|
|
2014-09-05 10:21:24 +02:00
|
|
|
$form = new PreferenceForm();
|
|
|
|
$form->setPreferences($user->getPreferences());
|
2015-07-01 15:41:45 +02:00
|
|
|
if ($config->get('config_backend', 'ini') !== 'none') {
|
|
|
|
$form->setStore(PreferencesStore::create(new ConfigObject(array(
|
|
|
|
'store' => $config->get('config_backend', 'ini'),
|
|
|
|
'resource' => $config->config_resource
|
|
|
|
)), $user));
|
2015-01-23 16:19:39 +01:00
|
|
|
}
|
2014-09-05 10:21:24 +02:00
|
|
|
$form->handleRequest();
|
|
|
|
|
2013-08-19 20:00:55 +02:00
|
|
|
$this->view->form = $form;
|
2014-11-13 18:08:30 +01:00
|
|
|
$this->getTabs()->activate('preferences');
|
2013-06-27 12:45:18 +02:00
|
|
|
}
|
2013-08-14 12:42:32 +02:00
|
|
|
}
|