Skip to content

Commit

Permalink
Merge pull request #5270 from rubencm/ticket/15699
Browse files Browse the repository at this point in the history
[ticket/15699] Move files between storages when configuration is changed
  • Loading branch information
marc1706 committed Jun 7, 2024
2 parents e813bcc + 195fb59 commit e2ff7a7
Show file tree
Hide file tree
Showing 31 changed files with 1,236 additions and 305 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

# Excludes test / dev files
/phpunit.xml
/.phpunit.result.cache
/phpBB/composer.phar
/tests/phpbb_unit_tests.sqlite*
/tests/test_config*.php
Expand Down
83 changes: 51 additions & 32 deletions phpBB/adm/style/acp_storage.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,32 @@ <h1>{{ lang('STORAGE_TITLE') }}</h1>
</tr>
</thead>
<tbody>
{% for storage in STORAGE_STATS %}
<tr>
<td>{{ storage.name }}</td>
<td>{{ storage.files }}</td>
<td>{{ storage.size }}</td>
<td>{{ storage.free_space }}</td>
</tr>
{% endfor %}
{% for storage in STORAGE_STATS %}
<tr>
<td>{{ storage.name }}</td>
<td>{{ storage.files }}</td>
<td>{{ storage.size }}</td>
<td>{{ storage.free_space }}</td>
</tr>
{% endfor %}
</tbody>
</table>

{% if S_ERROR %}
{% if ERROR_MESSAGES is not empty %}
<div class="errorbox">
<h3>{{ lang('WARNING') }}</h3>
<p>{{ ERROR_MSG }}</p>
{% for ERROR_MESSAGE in ERROR_MESSAGES %}
<p>{{ ERROR_MESSAGE }}</p>
{% endfor %}
</div>
{% endif %}

<form id="acp_storage" method="post" action="{{ U_ACTION }}">

{% for storage in STORAGES %}
<fieldset>
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }}</legend>
<dl>
<dt><label for="{{ storage.get_name }}">{{ lang('STORAGE_SELECT') }}{{ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_SELECT_DESC') }}</span></dt>
<dt><label for="{{ storage.get_name }}">{{ lang('STORAGE_SELECT') ~ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_SELECT_DESC') }}</span></dt>
<dd>
<select id="{{ storage.get_name }}" name="{{ storage.get_name }}[provider]" data-togglable-settings="true">
{% for provider in PROVIDERS %}
Expand All @@ -60,34 +61,41 @@ <h3>{{ lang('WARNING') }}</h3>
<fieldset id="{{ storage.get_name }}_{{ provider.get_name }}_settings">
<legend>{{ lang('STORAGE_' ~ storage.get_name | upper ~ '_TITLE') }} - {{ lang('STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_NAME') }}</legend>
{% for name, options in provider.get_options %}
{% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
{% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %}
{% set input_id = storage.get_name ~ '_' ~ provider.get_name ~ '_' ~ name %}
{% set input_type = options['type'] %}
{% set input_name = storage.get_name ~ '[' ~ name ~ ']' %}
{% set input_value = attribute(config, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name) %}
<dl>
<dt>
<label for="{{ input_id }}}">{{ lang(title) }}{{ lang('COLON') }}</label>
{% set title = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
{% set description = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper ~ '_EXPLAIN' %}
<label>{{ lang(title) ~ lang('COLON') }}</label>
{% if lang_defined(description) %}
<br /><span>{{ lang(description) }}</span>
{% endif %}
</dt>
<dd>
{% if input_type in ['text', 'password', 'email'] %}
<input id="{{ input_id }}" type="{{ input_type }}" name="{{ input_name }}" value="{{ input_value }}" maxlength="{{ options['maxlength'] ?: 255 }}" />
{% elseif input_type == 'textarea' %}
<textarea id="{{ input_id }}" name="{{ input_name }}">{{ input_value }}</textarea>
{% elseif input_type == 'radio' %}
{% for option_name, option_value in options['options'] %}
<input type="radio" name="{{ input_name }}" value="{{ option_value }}" class="radio"{% if loop.first %} id="{{ input_id }}"{% endif %}{{ (option_value == input_value) ? ' checked="checked"' }}> {{ lang(option_name) }}
{% set input_name = storage.get_name ~ '[' ~ name ~ ']' %}
{% set input_value = attribute(config, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name) %}

{% if options.tag == 'input' %}
{{ FormsInput(options | merge({"name": input_name, "value": input_value})) }}
{% elseif options.tag == 'textarea' %}
{{ FormsTextarea(options | merge({"name": input_name, "content": input_value})) }}
{% elseif options.tag == 'radio' %}
{% set buttons = [] %}

{% for button in options.buttons %}
{% set new_button = button | merge({"name": input_name, "checked": button.value == input_value}) %}
{% set buttons = buttons | merge([new_button]) %}
{% endfor %}

{{ FormsRadioButtons(options | merge({"buttons": buttons})) }}
{% elseif options.tag == 'select' %}
{% set select_options = [] %}

{% for option in options.options %}
{% set new_option = option | merge({"selected": option.value == input_value}) %}
{% set select_options = select_options | merge([new_option]) %}
{% endfor %}
{% elseif input_type == 'select' %}
<select name="{{ input_name }}" id="{{ input_id }}">
{% for option_name, option_value in options['options'] %}
<option value="{{ option_value }}"{{ (option_value == input_value) ? ' selected' }}>{{ lang(option_name) }}</option>
{% endfor %}
</select>

{{ FormsSelect(options | merge({"name": input_name, "options": select_options})) }}
{% endif %}
</dd>
</dl>
Expand All @@ -97,6 +105,17 @@ <h3>{{ lang('WARNING') }}</h3>
{% endfor %}
{% endfor %}

<fieldset>
<dl>
<dt><label for="update_type">{{ lang('STORAGE_UPDATE_TYPE') ~ lang('COLON') }}</label></dt>
<dd>
<label><input id="update_type" class="radio" name="update_type" value="{{ STORAGE_UPDATE_TYPE_CONFIG }}" checked="checked" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_CONFIG') }}</label>
<label><input class="radio" name="update_type" value="{{ STORAGE_UPDATE_TYPE_COPY }}" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_COPY') }}</label>
<label><input class="radio" name="update_type" value="{{ STORAGE_UPDATE_TYPE_MOVE }}" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_MOVE') }}</label>
</dd>
</dl>
</fieldset>

<fieldset class="submit-buttons">
<legend>{{ lang('SUBMIT') }}</legend>
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />&nbsp;
Expand Down
32 changes: 32 additions & 0 deletions phpBB/adm/style/acp_storage_update_inprogress.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% include 'overall_header.html' %}

<a id="maincontent"></a>

<h1>{{ lang('STORAGE_TITLE') }}</h1>

<p>{{ lang('STORAGE_TITLE_EXPLAIN') }}</p>

<form id="acp_storage_continue" method="post" action="{{ U_ACTION }}">
<fieldset>
<legend>{{ lang('SUBMIT') }}</legend>

{% if CONTINUE_PROGRESS %}
<div class="centered-text">
<br>
<progress
value="{{ CONTINUE_PROGRESS.VALUE }}"
max="{{ CONTINUE_PROGRESS.TOTAL }}"
style="height: 2em; width: 20em;"></progress><br>
{{ CONTINUE_PROGRESS.PERCENTAGE|number_format(2) ~ ' %' }}
</div>
{% endif %}

<p class="submit-buttons">
<input class="button1" type="submit" id="continue" name="continue" value="{{ lang('SUBMIT') }}" />&nbsp;
<input class="button2" type="submit" id="cancel" name="cancel" value="{{ lang('CANCEL') }}" />
</p>
{{ S_FORM_TOKEN }}
</fieldset>
</form>

{% include 'overall_footer.html' %}
20 changes: 20 additions & 0 deletions phpBB/adm/style/acp_storage_update_progress.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% include 'overall_header.html' %}

<a id="maincontent"></a>

<div class="successbox">
<h3>{{ INDEXING_TITLE }}</h3>
<p>
{{ INDEXING_EXPLAIN }}
{% if INDEXING_PROGRESS_BAR %}
<br>
<progress
value="{{ INDEXING_PROGRESS_BAR.VALUE }}"
max="{{ INDEXING_PROGRESS_BAR.TOTAL }}"
style="height: 2em; width: 20em;"></progress><br>
{{ INDEXING_PROGRESS_BAR.PERCENTAGE|number_format(2) ~ ' %' }}
{% endif %}
</p>
</div>

{% include 'overall_footer.html' %}
17 changes: 17 additions & 0 deletions phpBB/config/default/container/services_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,20 @@ services:
- '@storage.attachment'
- '@symfony_request'
- '@user'

# Helpers
storage.state_helper:
class: phpbb\storage\state_helper
arguments:
- '@config'
- '@config_text'
- '@storage.provider_collection'

storage.helper:
class: phpbb\storage\helper
arguments:
- '@config'
- '@storage.adapter.factory'
- '@storage.state_helper'
- '@storage.provider_collection'
- '@storage.adapter_collection'
2 changes: 1 addition & 1 deletion phpBB/includes/acp/acp_database.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function main($id, $mode)
fclose($fp);
fclose($stream);
}
catch (\phpbb\storage\exception\exception $e)
catch (\phpbb\storage\exception\storage_exception $e)
{
trigger_error($user->lang['RESTORE_DOWNLOAD_FAIL'] . adm_back_link($this->u_action));
}
Expand Down
Loading

0 comments on commit e2ff7a7

Please sign in to comment.