From 61f0ce65e0e88ece58806eb7db5d1654bde1df83 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 29 Sep 2014 12:27:26 +0200 Subject: [PATCH] Add preferences page refs #7163 --- application/forms/Setup/PreferencesPage.php | 70 +++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 application/forms/Setup/PreferencesPage.php diff --git a/application/forms/Setup/PreferencesPage.php b/application/forms/Setup/PreferencesPage.php new file mode 100644 index 0000000000..f643d4a349 --- /dev/null +++ b/application/forms/Setup/PreferencesPage.php @@ -0,0 +1,70 @@ +setName('setup_preferences_type'); + } + + /** + * Pre-select "db" as preference backend and add a hint to the select element + * + * @return self + */ + public function showDatabaseNote() + { + $this->getElement('type') + ->setValue('db') + ->setDescription( + t('Note that choosing "Database" causes Icinga Web 2 to use the same database as for authentication.') + ); + return $this; + } + + /** + * @see Form::createElements() + */ + public function createElements(array $formData) + { + $this->addElement( + 'note', + 'description', + array( + 'value' => t('Please choose how Icinga Web 2 should store user preferences.') + ) + ); + + $storageTypes = array(); + $storageTypes['ini'] = t('File System (INI Files)'); + if (Platform::extensionLoaded('pdo') && (Platform::zendClassExists('Zend_Db_Adapter_Pdo_Mysql') + || Platform::zendClassExists('Zend_Db_Adapter_Pdo_Pgsql'))) + { + $storageTypes['db'] = t('Database'); + } + $storageTypes['null'] = t('Don\'t Store Preferences'); + + $this->addElement( + 'select', + 'type', + array( + 'required' => true, + 'label' => t('User Preference Storage Type'), + 'multiOptions' => $storageTypes + ) + ); + } +}