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;
|
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(
|
2014-11-13 18:08:30 +01:00
|
|
|
'title' => t('Preferences'),
|
2013-08-16 14:56:23 +02:00
|
|
|
'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
|
|
|
{
|
2014-11-18 13:11:52 +01:00
|
|
|
$storeConfig = Config::app()->getSection('preferences');
|
2014-07-21 10:20:04 +02:00
|
|
|
|
2014-09-05 10:21:24 +02:00
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
$form = new PreferenceForm();
|
|
|
|
$form->setPreferences($user->getPreferences());
|
2015-01-23 16:19:39 +01:00
|
|
|
if ($storeConfig->get('store', 'ini') !== 'none') {
|
|
|
|
$form->setStore(PreferencesStore::create($storeConfig, $user));
|
|
|
|
}
|
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
|
|
|
}
|