ApplicationConfigForm: Make preference options be global options

refs #8709
This commit is contained in:
Johannes Meyer 2015-07-01 15:41:45 +02:00
parent 5b908d85bb
commit 066b3d9e28
3 changed files with 17 additions and 10 deletions

View File

@ -6,6 +6,7 @@ use Icinga\Web\Url;
use Icinga\Web\Widget\Tab; use Icinga\Web\Widget\Tab;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Forms\PreferenceForm; use Icinga\Forms\PreferenceForm;
use Icinga\Data\ConfigObject;
use Icinga\User\Preferences\PreferencesStore; use Icinga\User\Preferences\PreferencesStore;
/** /**
@ -38,13 +39,16 @@ class PreferenceController extends BasePreferenceController
*/ */
public function indexAction() public function indexAction()
{ {
$storeConfig = Config::app()->getSection('preferences'); $config = Config::app()->getSection('global');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$form = new PreferenceForm(); $form = new PreferenceForm();
$form->setPreferences($user->getPreferences()); $form->setPreferences($user->getPreferences());
if ($storeConfig->get('store', 'ini') !== 'none') { if ($config->get('config_backend', 'ini') !== 'none') {
$form->setStore(PreferencesStore::create($storeConfig, $user)); $form->setStore(PreferencesStore::create(new ConfigObject(array(
'store' => $config->get('config_backend', 'ini'),
'resource' => $config->config_resource
)), $user));
} }
$form->handleRequest(); $form->handleRequest();

View File

@ -7,7 +7,6 @@ use Icinga\Application\Icinga;
use Icinga\Data\ResourceFactory; use Icinga\Data\ResourceFactory;
use Icinga\Web\Form; use Icinga\Web\Form;
/** /**
* Form class to modify the general application configuration * Form class to modify the general application configuration
*/ */
@ -43,7 +42,7 @@ class ApplicationConfigForm extends Form
$this->addElement( $this->addElement(
'select', 'select',
'preferences_store', 'global_config_backend',
array( array(
'required' => true, 'required' => true,
'autosubmit' => true, 'autosubmit' => true,
@ -55,7 +54,7 @@ class ApplicationConfigForm extends Form
) )
) )
); );
if (isset($formData['preferences_store']) && $formData['preferences_store'] === 'db') { if (isset($formData['global_config_backend']) && $formData['global_config_backend'] === 'db') {
$backends = array(); $backends = array();
foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) { foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) {
if ($resource['type'] === 'db') { if ($resource['type'] === 'db') {
@ -65,7 +64,7 @@ class ApplicationConfigForm extends Form
$this->addElement( $this->addElement(
'select', 'select',
'preferences_resource', 'global_config_resource',
array( array(
'required' => true, 'required' => true,
'multiOptions' => $backends, 'multiOptions' => $backends,

View File

@ -6,6 +6,7 @@ namespace Icinga\Authentication;
use Exception; use Exception;
use Icinga\Authentication\UserGroup\UserGroupBackend; use Icinga\Authentication\UserGroup\UserGroupBackend;
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Data\ConfigObject;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
use Icinga\Exception\NotReadableError; use Icinga\Exception\NotReadableError;
use Icinga\Application\Logger; use Icinga\Application\Logger;
@ -63,8 +64,11 @@ class Manager
); );
$config = new Config(); $config = new Config();
} }
if ($config->get('preferences', 'store', 'ini') !== 'none') { if ($config->get('global', 'config_backend', 'ini') !== 'none') {
$preferencesConfig = $config->getSection('preferences'); $preferencesConfig = new ConfigObject(array(
'store' => $config->get('global', 'config_backend', 'ini'),
'resource' => $config->get('global', 'config_resource')
));
try { try {
$preferencesStore = PreferencesStore::create( $preferencesStore = PreferencesStore::create(
$preferencesConfig, $preferencesConfig,