ApplicationConfigForm: Make preference options be global options
refs #8709
This commit is contained in:
parent
5b908d85bb
commit
066b3d9e28
|
@ -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();
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue