<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
class Storage extends BaseAdmin
{
- public static function post(array $parameters = [])
+ protected function post(array $request = [])
{
self::checkAdminAccess();
self::checkFormSecurityTokenRedirectOnError('/admin/storage', 'admin_storage');
- $storagebackend = Strings::escapeTags(trim($parameters['name'] ?? ''));
+ $storagebackend = trim($this->parameters['name'] ?? '');
try {
/** @var ICanConfigureStorage|false $newStorageConfig */
$newStorageConfig = DI::storageManager()->getConfigurationByName($storagebackend);
} catch (InvalidClassStorageException $storageException) {
- notice(DI::l10n()->t('Storage backend, %s is invalid.', $storagebackend));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Storage backend, %s is invalid.', $storagebackend));
DI::baseUrl()->redirect('admin/storage');
}
$storage_form_errors = $newStorageConfig->saveOptions($storage_opts_data);
if (count($storage_form_errors)) {
foreach ($storage_form_errors as $name => $err) {
- notice(DI::l10n()->t('Storage backend %s error: %s', $storage_opts[$name][1], $err));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Storage backend %s error: %s', $storage_opts[$name][1], $err));
}
DI::baseUrl()->redirect('admin/storage');
}
}
- if (!empty($_POST['submit_save_set'])) {
+ if (!empty($_POST['submit_save_set']) && DI::config()->isWritable('storage', 'name') ) {
try {
$newstorage = DI::storageManager()->getWritableStorageByName($storagebackend);
if (!DI::storageManager()->setBackend($newstorage)) {
- notice(DI::l10n()->t('Invalid storage backend setting value.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Invalid storage backend setting value.'));
}
} catch (InvalidClassStorageException $storageException) {
- notice(DI::l10n()->t('Invalid storage backend setting value.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Invalid storage backend setting value.'));
}
}
DI::baseUrl()->redirect('admin/storage');
}
- public static function content(array $parameters = [])
+ protected function content(array $request = []): string
{
- parent::content($parameters);
+ parent::content();
$current_storage_backend = DI::storage();
$available_storage_forms = [];
foreach ($storageConfig->getOptions() as $option => $info) {
$type = $info[0];
- // Backward compatibilty with yesno field description
+ // Backward compatibility with yesno field description
if ($type == 'yesno') {
$type = 'checkbox';
// Remove translated labels Yes No from field info
'$use' => DI::l10n()->t('Use storage backend'),
'$save_reload' => DI::l10n()->t('Save & Reload'),
'$noconfig' => DI::l10n()->t('This backend doesn\'t have custom settings'),
- '$baseurl' => DI::baseUrl()->get(true),
'$form_security_token' => self::getFormSecurityToken("admin_storage"),
+ '$storagebackend_ro_txt' => !DI::config()->isWritable('storage', 'name') ? DI::l10n()->t('Changing the current backend is prohibited because it is set by an environment variable') : '',
+ '$is_writable' => DI::config()->isWritable('storage', 'name'),
'$storagebackend' => $current_storage_backend instanceof ICanWriteToStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'),
'$availablestorageforms' => $available_storage_forms,
]);