[ticket/15699] Add option to udpate configuration only

PHPBB3-15699
This commit is contained in:
Rubén Calvo 2018-08-25 17:54:18 +02:00 committed by Ruben Calvo
parent 6de2d44c87
commit 3a25c0222b
No known key found for this signature in database
3 changed files with 65 additions and 57 deletions

View file

@ -121,9 +121,11 @@
<fieldset> <fieldset>
<dl> <dl>
<dt><label for="remove_old">{{ lang('STORAGE_REMOVE_OLD_FILES') }}{{ lang('COLON') }}</label><br /><span>{{ lang('STORAGE_REMOVE_OLD_FILES_EXPLAIN') }}</span></dt> <dt><label for="update_type">{{ lang('STORAGE_UPDATE_TYPE') }}{{ lang('COLON') }}</label></dt>
<dd> <dd>
<input type="checkbox" name="remove_old"> <label><input id="update_type" class="radio" name="update_type" value="0" checked="checked" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_CONFIG') }}</label>
<label><input class="radio" name="update_type" value="1" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_COPY') }}</label>
<label><input class="radio" name="update_type" value="2" type="radio"> {{ lang('STORAGE_UPDATE_TYPE_MOVE') }}</label>
</dd> </dd>
</dl> </dl>
</fieldset> </fieldset>

View file

@ -162,7 +162,9 @@ class acp_storage
trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($this->user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING);
} }
// Copy files from the old to the new storage // If update_type is copy or move, copy files from the old to the new storage
if ($this->state['update_type'] >= 1)
{
$i = 0; $i = 0;
foreach ($this->state['storages'] as $storage_name => $storage_options) foreach ($this->state['storages'] as $storage_name => $storage_options)
{ {
@ -208,7 +210,8 @@ class acp_storage
$this->state['file_index'] = 0; $this->state['file_index'] = 0;
} }
if ($this->state['remove_old']) // If update_type is move files, remove the old files
if ($this->state['update_type'] == 2)
{ {
$i = 0; $i = 0;
foreach ($this->state['storages'] as $storage_name => $storage_options) foreach ($this->state['storages'] as $storage_name => $storage_options)
@ -248,6 +251,7 @@ class acp_storage
$this->state['file_index'] = 0; $this->state['file_index'] = 0;
} }
} }
}
// Here all files have been copied/moved, so save new configuration // Here all files have been copied/moved, so save new configuration
foreach (array_keys($this->state['storages']) as $storage_name) foreach (array_keys($this->state['storages']) as $storage_name)
@ -339,7 +343,7 @@ class acp_storage
$this->state = [ $this->state = [
// Save the value of the checkbox, to remove all files from the // Save the value of the checkbox, to remove all files from the
// old storage once they have been successfully moved // old storage once they have been successfully moved
'remove_old' => $this->request->variable('remove_old', false), 'update_type' => $this->request->variable('update_type', 0),
'storage_index' => 0, 'storage_index' => 0,
'file_index' => 0, 'file_index' => 0,
'remove_storage_index' => 0, 'remove_storage_index' => 0,

View file

@ -48,8 +48,10 @@ $lang = array_merge($lang, array(
'STORAGE_SIZE' => 'Size', 'STORAGE_SIZE' => 'Size',
'STORAGE_FREE' => 'Available space', 'STORAGE_FREE' => 'Available space',
'STORAGE_UNKNOWN' => 'Unknown', 'STORAGE_UNKNOWN' => 'Unknown',
'STORAGE_REMOVE_OLD_FILES' => 'Remove old files', 'STORAGE_UPDATE_TYPE' => 'Update type',
'STORAGE_REMOVE_OLD_FILES_EXPLAIN' => 'Remove old files after they are copied to the new storage system.', 'STORAGE_UPDATE_TYPE_CONFIG' => 'Update configuration only',
'STORAGE_UPDATE_TYPE_COPY' => 'Update configuration and copy files',
'STORAGE_UPDATE_TYPE_MOVE' => 'Update configuration and move files',
'START_UPDATING' => 'Start update process', 'START_UPDATING' => 'Start update process',
'START_UPDATING_EXPLAIN' => 'Start the storage update process', 'START_UPDATING_EXPLAIN' => 'Start the storage update process',
'CONTINUE_UPDATING' => 'Continue previous update process', 'CONTINUE_UPDATING' => 'Continue previous update process',