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
|
|
|
|
2014-02-17 14:11:55 +01:00
|
|
|
use Icinga\Web\Controller\BasePreferenceController;
|
|
|
|
use Icinga\Web\Url;
|
2014-09-05 10:21:24 +02:00
|
|
|
use Icinga\Web\Widget\Tab;
|
|
|
|
use Icinga\Application\Config;
|
2014-11-14 10:57:14 +01:00
|
|
|
use Icinga\Forms\PreferenceForm;
|
2015-07-01 15:41:45 +02:00
|
|
|
use Icinga\Data\ConfigObject;
|
2014-09-05 10:21:24 +02:00
|
|
|
use Icinga\User\Preferences\PreferencesStore;
|
2013-06-27 12:45:18 +02:00
|
|
|
|
|
|
|
/**
|
2013-08-12 15:58:26 +02:00
|
|
|
* Application wide preference controller for user preferences
|
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(
|
2014-11-13 18:08:30 +01:00
|
|
|
'preferences' => new Tab(
|
2013-08-12 15:58:26 +02:00
|
|
|
array(
|
2015-02-23 16:50:31 +01:00
|
|
|
'title' => t('Adjust the preferences of Icinga Web 2 according to your needs'),
|
|
|
|
'label' => t('Preferences'),
|
|
|
|
'url' => Url::fromPath('/preference')
|
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
|
|
|
}
|