mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 21:38:54 +00:00
[ticket/15289] Update acp to be able to save data in the database
PHPBB3-15289
This commit is contained in:
parent
6e739a1d0b
commit
c3c8117f0a
3 changed files with 61 additions and 4 deletions
|
@ -31,7 +31,7 @@
|
||||||
{% for name, options in provider.get_options %}
|
{% for name, options in provider.get_options %}
|
||||||
{% set lang_name = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
|
{% set lang_name = 'STORAGE_ADAPTER_' ~ provider.get_name | upper ~ '_OPTION_' ~ name | upper %}
|
||||||
{% set options = options|merge({'name': storage.get_name ~ '[' ~ name ~ ']'}) %}
|
{% set options = options|merge({'name': storage.get_name ~ '[' ~ name ~ ']'}) %}
|
||||||
{{ adm_block(lang(lang_name), '', input(options)) }}
|
{{ adm_block(lang(lang_name), '', input(options, attribute(CONFIG, 'storage\\' ~ storage.get_name ~ '\\config\\' ~ name))) }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -78,6 +78,7 @@ class acp_storage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Validate data
|
||||||
public function overview($id, $mode)
|
public function overview($id, $mode)
|
||||||
{
|
{
|
||||||
$form_name = 'acp_storage';
|
$form_name = 'acp_storage';
|
||||||
|
@ -89,9 +90,65 @@ class acp_storage
|
||||||
// Set page title
|
// Set page title
|
||||||
$this->page_title = 'STORAGE_TITLE';
|
$this->page_title = 'STORAGE_TITLE';
|
||||||
|
|
||||||
|
if ($this->request->is_set_post('submit'))
|
||||||
|
{
|
||||||
|
foreach ($this->storage_collection as $storage)
|
||||||
|
{
|
||||||
|
$modified = false;
|
||||||
|
$provider = $this->provider_collection->get_by_class($this->config['storage\\' . $storage->get_name() . '\\provider']);
|
||||||
|
|
||||||
|
// Check if provider have been modified
|
||||||
|
if ($this->request->variable([$storage->get_name(), 'provider'], '') != $this->config['storage\\' . $storage->get_name() . '\\provider'])
|
||||||
|
{
|
||||||
|
$modified = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if options have been modified
|
||||||
|
if(!$modified)
|
||||||
|
{
|
||||||
|
foreach($provider->get_options() as $option => $params)
|
||||||
|
{
|
||||||
|
if ($this->request->variable([$storage->get_name(), $option], '') != $this->config['storage\\' . $storage->get_name() . '\\provider'])
|
||||||
|
{
|
||||||
|
$modified = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update storage
|
||||||
|
if($modified)
|
||||||
|
{
|
||||||
|
// TODO: Allow to move data to the new storage automatically
|
||||||
|
|
||||||
|
// TODO: Validate data
|
||||||
|
|
||||||
|
// Remove old straoge config
|
||||||
|
foreach (array_keys($provider->get_options()) as $def)
|
||||||
|
{
|
||||||
|
$this->config->delete('storage\\' . $storage->get_name() . '\\config\\' . $def);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update provider
|
||||||
|
$this->config->set('storage\\' . $storage->get_name() . '\\provider', $this->request->variable([$storage->get_name(), 'provider'], ''));
|
||||||
|
|
||||||
|
// Set new storage config
|
||||||
|
$new_provider = $this->provider_collection->get_by_class($this->config['storage\\' . $storage->get_name() . '\\provider']);
|
||||||
|
|
||||||
|
foreach (array_keys($new_provider->get_options()) as $def)
|
||||||
|
{
|
||||||
|
$this->config->set('storage\\' . $storage->get_name() . '\\config\\' . $def, $this->request->variable([$storage->get_name(), $def], ''));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updated succesfuly
|
||||||
|
}
|
||||||
|
|
||||||
$this->template->assign_vars(array(
|
$this->template->assign_vars(array(
|
||||||
'STORAGES' => $this->storage_collection,
|
'STORAGES' => $this->storage_collection,
|
||||||
'PROVIDERS' => $this->provider_collection
|
'PROVIDERS' => $this->provider_collection,
|
||||||
|
'CONFIG' => $this->config // Maybe this should be added to \phpbb\templat\twig\extension
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ class form extends \Twig_Extension
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generate_input($options)
|
public static function generate_input($options, $value = '')
|
||||||
{
|
{
|
||||||
$input = '<input ';
|
$input = '<input value="' . $value . '"';
|
||||||
|
|
||||||
switch ($options['type'])
|
switch ($options['type'])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue