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

View File

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

View File

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