Don't try to save form for "None" backend.

This commit is contained in:
fabrixxm 2018-12-14 14:17:15 +01:00 committed by Hypolite Petovan
parent 3f03f3b4b7
commit 204c5a4d99

View File

@ -1176,35 +1176,36 @@ function admin_page_site_post(App $a)
StorageManager::setBackend($storagebackend); StorageManager::setBackend($storagebackend);
// save storage backend form // save storage backend form
$storage_opts = $storagebackend::getOptions(); if (!is_null($storagebackend) && $storagebackend != "") {
$storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend); $storage_opts = $storagebackend::getOptions();
$storage_opts_data = []; $storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storagebackend);
foreach($storage_opts as $name => $info) { $storage_opts_data = [];
$fieldname = $storage_form_prefix . '_' . $name; foreach($storage_opts as $name => $info) {
switch ($info[0]) { // type $fieldname = $storage_form_prefix . '_' . $name;
case 'checkbox': switch ($info[0]) { // type
case 'yesno': case 'checkbox':
$value = !empty($_POST[$fieldname]); case 'yesno':
break; $value = !empty($_POST[$fieldname]);
default: break;
$value = defaults($_POST, $fieldname, ''); default:
$value = defaults($_POST, $fieldname, '');
}
$storage_opts_data[$name] = $value;
} }
$storage_opts_data[$name] = $value; unset($name);
} unset($info);
unset($name);
unset($info);
$storage_form_errors = $storagebackend::saveOptions($storage_opts_data); $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
if (count($storage_form_errors)) { if (count($storage_form_errors)) {
foreach($storage_form_errors as $name => $err) { foreach($storage_form_errors as $name => $err) {
notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err); notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
}
$a->internalRedirect('admin/site' . $active_panel);
} }
$a->internalRedirect('admin/site' . $active_panel);
} }
// Has the directory url changed? If yes, then resubmit the existing profiles there // Has the directory url changed? If yes, then resubmit the existing profiles there
if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) { if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
Config::set('system', 'directory', $global_directory); Config::set('system', 'directory', $global_directory);