2014-09-01 16:16:56 +02:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2014-11-14 10:57:14 +01:00
|
|
|
namespace Icinga\Forms\Config\General;
|
2014-09-01 16:16:56 +02:00
|
|
|
|
|
|
|
use DateTimeZone;
|
2014-11-13 09:33:31 +01:00
|
|
|
use Icinga\Application\Icinga;
|
2014-09-01 16:16:56 +02:00
|
|
|
use Icinga\Data\ResourceFactory;
|
2014-11-13 09:33:31 +01:00
|
|
|
use Icinga\Util\Translator;
|
|
|
|
use Icinga\Web\Form;
|
|
|
|
|
2014-09-01 16:16:56 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Form class to modify the general application configuration
|
|
|
|
*/
|
|
|
|
class ApplicationConfigForm extends Form
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Initialize this form
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->setName('form_config_general_application');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Form::createElements()
|
|
|
|
*/
|
|
|
|
public function createElements(array $formData)
|
|
|
|
{
|
2014-09-03 12:21:31 +02:00
|
|
|
$this->addElement(
|
2014-09-01 16:16:56 +02:00
|
|
|
'text',
|
2014-11-17 10:10:08 +01:00
|
|
|
'global_module_path',
|
2014-09-01 16:16:56 +02:00
|
|
|
array(
|
2015-01-19 11:26:23 +01:00
|
|
|
'label' => $this->translate('Module Path'),
|
2014-09-02 17:03:32 +02:00
|
|
|
'required' => true,
|
2014-11-13 09:33:31 +01:00
|
|
|
'value' => implode(':', Icinga::app()->getModuleManager()->getModuleDirs()),
|
2015-01-19 11:26:23 +01:00
|
|
|
'description' => $this->translate(
|
2014-09-01 16:16:56 +02:00
|
|
|
'Contains the directories that will be searched for available modules, separated by '
|
|
|
|
. 'colons. Modules that don\'t exist in these directories can still be symlinked in '
|
|
|
|
. 'the module folder, but won\'t show up in the list of disabled modules.'
|
2014-11-13 09:33:31 +01:00
|
|
|
)
|
2014-09-01 16:16:56 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2014-09-03 12:21:31 +02:00
|
|
|
$this->addElement(
|
2014-09-01 16:16:56 +02:00
|
|
|
'select',
|
|
|
|
'preferences_type',
|
|
|
|
array(
|
2015-01-23 14:41:14 +01:00
|
|
|
'allowEmpty' => true,
|
2014-09-01 16:16:56 +02:00
|
|
|
'autosubmit' => true,
|
2015-01-19 11:26:23 +01:00
|
|
|
'label' => $this->translate('User Preference Storage Type'),
|
2014-09-01 16:16:56 +02:00
|
|
|
'multiOptions' => array(
|
2015-01-19 11:26:23 +01:00
|
|
|
'ini' => $this->translate('File System (INI Files)'),
|
|
|
|
'db' => $this->translate('Database'),
|
2015-01-23 14:41:14 +01:00
|
|
|
'' => $this->translate('Don\'t Store Preferences')
|
2014-09-01 16:16:56 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
if (isset($formData['preferences_type']) && $formData['preferences_type'] === 'db') {
|
|
|
|
$backends = array();
|
|
|
|
foreach (ResourceFactory::getResourceConfigs()->toArray() as $name => $resource) {
|
|
|
|
if ($resource['type'] === 'db') {
|
|
|
|
$backends[$name] = $name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-03 12:21:31 +02:00
|
|
|
$this->addElement(
|
2014-09-01 16:16:56 +02:00
|
|
|
'select',
|
|
|
|
'preferences_resource',
|
|
|
|
array(
|
|
|
|
'required' => true,
|
|
|
|
'multiOptions' => $backends,
|
2015-01-19 11:26:23 +01:00
|
|
|
'label' => $this->translate('Database Connection')
|
2014-09-01 16:16:56 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-09-03 12:21:31 +02:00
|
|
|
return $this;
|
2014-09-01 16:16:56 +02:00
|
|
|
}
|
|
|
|
}
|