1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/16604] Display warning messages on storage path setting issues

PHPBB3-16604
This commit is contained in:
rxu
2020-10-17 21:45:30 +07:00
parent 4679c82214
commit 3ba7a7a30e
6 changed files with 146 additions and 50 deletions

View File

@@ -42,6 +42,9 @@ class acp_storage
/** @var \phpbb\di\service_collection */
protected $storage_collection;
/** @var \phpbb\filesystem\filesystem */
protected $filesystem;
/** @var string */
public $page_title;
@@ -60,6 +63,7 @@ class acp_storage
global $phpbb_container, $phpbb_dispatcher;
$this->config = $phpbb_container->get('config');
$this->filesystem = $phpbb_container->get('filesystem');
$this->lang = $phpbb_container->get('language');
$this->request = $phpbb_container->get('request');
$this->template = $phpbb_container->get('template');
@@ -87,6 +91,8 @@ class acp_storage
*/
public function overview($id, $mode)
{
global $phpbb_root_path;
$form_key = 'acp_storage';
add_form_key($form_key);
@@ -96,10 +102,10 @@ class acp_storage
// Set page title
$this->page_title = 'STORAGE_TITLE';
$messages = [];
if ($this->request->is_set_post('submit'))
{
$modified_storages = [];
$messages = [];
if (!check_form_key($form_key))
{
@@ -112,6 +118,20 @@ class acp_storage
$options = $this->get_provider_options($this->get_current_provider($storage_name));
if (isset($options['path']))
{
$path = $this->get_new_definition($storage_name, 'path');
if (empty($path))
{
$messages[] = $this->lang->lang('STORAGE_PATH_NOT_SET', $this->lang->lang('STORAGE_' . strtoupper($storage->get_name()) . '_TITLE'));
}
else if (!$this->filesystem->is_writable($phpbb_root_path . $path) || !$this->filesystem->exists($phpbb_root_path . $path))
{
$messages[] = $this->lang->lang('STORAGE_PATH_NOT_EXISTS', $this->lang->lang('STORAGE_' . strtoupper($storage->get_name()) . '_TITLE'));
}
}
$modified = false;
// Check if provider have been modified
@@ -165,6 +185,23 @@ class acp_storage
$storage_stats = [];
foreach ($this->storage_collection as $storage)
{
$storage_name = $storage->get_name();
$options = $this->get_provider_options($this->get_current_provider($storage_name));
if (isset($options['path']))
{
$path = $this->get_current_definition($storage_name, 'path');
if (empty($path))
{
$messages[] = $this->lang->lang('STORAGE_PATH_NOT_SET', $this->lang->lang('STORAGE_' . strtoupper($storage->get_name()) . '_TITLE'));
}
else if (!$this->filesystem->is_writable($phpbb_root_path . $path) || !$this->filesystem->exists($phpbb_root_path . $path))
{
$messages[] = $this->lang->lang('STORAGE_PATH_NOT_EXISTS', $this->lang->lang('STORAGE_' . strtoupper($storage->get_name()) . '_TITLE'));
}
}
try
{
$free_space = get_formatted_filesize($storage->free_space());
@@ -182,11 +219,14 @@ class acp_storage
];
}
$this->template->assign_vars(array(
$this->template->assign_vars([
'STORAGES' => $this->storage_collection,
'STORAGE_STATS' => $storage_stats,
'PROVIDERS' => $this->provider_collection,
));
'ERROR_MSG' => implode('<br />', $messages),
'S_ERROR' => !empty($messages),
]);
}
/**