2014-09-29 12:27:26 +02:00
|
|
|
<?php
|
2015-02-03 16:27:59 +01:00
|
|
|
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | http://www.gnu.org/licenses/gpl-2.0.txt */
|
2014-09-29 12:27:26 +02:00
|
|
|
|
2014-11-14 11:01:16 +01:00
|
|
|
namespace Icinga\Module\Setup\Forms;
|
2014-09-29 12:27:26 +02:00
|
|
|
|
|
|
|
use Icinga\Web\Form;
|
|
|
|
use Icinga\Application\Platform;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Wizard page to choose a preference backend
|
|
|
|
*/
|
|
|
|
class PreferencesPage extends Form
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Initialize this page
|
|
|
|
*/
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->setName('setup_preferences_type');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pre-select "db" as preference backend and add a hint to the select element
|
|
|
|
*
|
|
|
|
* @return self
|
|
|
|
*/
|
|
|
|
public function showDatabaseNote()
|
|
|
|
{
|
2015-01-26 07:39:31 +01:00
|
|
|
$this->getElement('store')
|
2014-09-29 12:27:26 +02:00
|
|
|
->setValue('db')
|
|
|
|
->setDescription(
|
2015-01-19 11:07:39 +01:00
|
|
|
$this->translate(
|
2014-11-11 09:24:53 +01:00
|
|
|
'Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.'
|
|
|
|
)
|
2014-09-29 12:27:26 +02:00
|
|
|
);
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see Form::createElements()
|
|
|
|
*/
|
|
|
|
public function createElements(array $formData)
|
|
|
|
{
|
2014-11-11 15:27:14 +01:00
|
|
|
$this->addElement(
|
2014-11-14 10:15:11 +01:00
|
|
|
'note',
|
|
|
|
'title',
|
|
|
|
array(
|
2015-01-19 11:07:39 +01:00
|
|
|
'value' => $this->translate('Preferences', 'setup.page.title'),
|
2014-11-14 10:15:11 +01:00
|
|
|
'decorators' => array(
|
|
|
|
'ViewHelper',
|
|
|
|
array('HtmlTag', array('tag' => 'h2'))
|
2014-11-11 15:27:14 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2014-09-29 12:27:26 +02:00
|
|
|
$this->addElement(
|
2014-11-14 10:15:11 +01:00
|
|
|
'note',
|
|
|
|
'description',
|
|
|
|
array(
|
2015-01-19 11:07:39 +01:00
|
|
|
'value' => $this->translate('Please choose how Icinga Web 2 should store user preferences.')
|
2014-09-29 12:27:26 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$storageTypes = array();
|
2015-01-19 11:07:39 +01:00
|
|
|
$storageTypes['ini'] = $this->translate('File System (INI Files)');
|
2014-12-01 15:38:10 +01:00
|
|
|
if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) {
|
2015-01-19 11:07:39 +01:00
|
|
|
$storageTypes['db'] = $this->translate('Database');
|
2014-09-29 12:27:26 +02:00
|
|
|
}
|
2015-01-23 16:04:45 +01:00
|
|
|
$storageTypes['none'] = $this->translate('Don\'t Store Preferences');
|
2014-09-29 12:27:26 +02:00
|
|
|
|
|
|
|
$this->addElement(
|
|
|
|
'select',
|
2015-01-23 16:03:29 +01:00
|
|
|
'store',
|
2014-09-29 12:27:26 +02:00
|
|
|
array(
|
2015-01-23 15:23:43 +01:00
|
|
|
'required' => true,
|
2015-01-19 11:07:39 +01:00
|
|
|
'label' => $this->translate('User Preference Storage Type'),
|
2014-09-29 12:27:26 +02:00
|
|
|
'multiOptions' => $storageTypes
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|