[ticket/15289] Add acp module

PHPBB3-15289
This commit is contained in:
Rubén Calvo 2017-07-25 10:29:13 +02:00
parent 944f9bf54e
commit ba9f082bf4
5 changed files with 225 additions and 1 deletions

View file

@ -0,0 +1,36 @@
<!-- INCLUDE overall_header.html -->
<a id="maincontent"></a>
<h1>{L_TITLE}</h1>
<p>{L_TITLE_EXPLAIN}</p>
<form id="acp_storage" method="post" action="{U_ACTION}">
<!-- BEGIN storage -->
<fieldset>
<legend>{storage.LEGEND}</legend>
<dl>
<dt><label for="{storage.key}">{storage.TITLE}{L_COLON}</label><!-- IF storage.TITLE_EXPLAIN --><br /><span>{storage.TITLE_EXPLAIN}</span><!-- ENDIF --></dt>
<dd><select id="{storage.key}" name="{storage.key}[provider]" data-togglable-settings="true">{storage.OPTIONS}</select></dd>
</dl>
</fieldset>
<!-- BEGIN adapter -->
<fieldset id="avatar_{avatar_backend.IDENTIFIER}_settings">
<legend>{adapter.NAME}</legend>
{adapter.SETTINGS}
</fieldset>
<!-- END adapter -->
<!-- END storage -->
<fieldset class="submit-buttons">
<legend>{L_SUBMIT}</legend>
<input class="button1" type="submit" id="submit" name="submit" value="{L_SUBMIT}" />&nbsp;
<input class="button2" type="reset" id="reset" name="reset" value="{L_RESET}" />
{S_FORM_TOKEN}
</fieldset>
</form>
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,132 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* @todo add cron intervals to server settings? (database_gc, queue_interval, session_gc, search_gc, cache_gc, warnings_gc)
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class acp_storage
{
/** @var \phpbb\config $config */
protected $config;
/** @var \phpbb\language\language $lang */
protected $lang;
/** @var \phpbb\request\request */
protected $request;
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/** @var string */
public $page_title;
/** @var string */
public $tpl_name;
/** @var string */
public $u_action;
public function main($id, $mode)
{
global $phpbb_container;
$this->config = $phpbb_container->get('config');
$this->lang = $phpbb_container->get('language');
$this->request = $phpbb_container->get('request');
$this->template = $phpbb_container->get('template');
$this->user = $phpbb_container->get('user');
// Add necesary language files
$this->user->add_lang(array('acp/storage'));
switch($mode)
{
case 'settings':
$this->overview($id, $mode);
break;
}
}
public function overview($id, $mode)
{
$form_name = 'acp_storage';
add_form_key($form_name);
global $phpbb_container;
$storage_collection = $phpbb_container->get('storage.storage_collection');
$adapter_provider_collection = $phpbb_container->get('storage.provider_collection');
$storages = array();
foreach($storage_collection->getIterator() as $storage)
{
$this->template->assign_block_vars('storage', array(
'LEGEND' => $storage->get_name(),
'TITLE' => $storage->get_name(),
'TITLE_EXPLAIN' => $storage->get_description(),
'OPTIONS' => $this->generate_adapter_options(),
));
foreach($adapter_provider_collection as $provider)
{
if(!$provider->is_available())
{
continue;
}
$this->template->assign_block_vars('storage.adapter', array(
'NAME' => get_class($provider),
'SETTINGS' => print_r($provider->get_options(), 1),
));
}
}
// Template from adm/style
$this->tpl_name = 'acp_storage';
// Set page title
$this->page_title = 'STORAGE_TITLE';
$this->template->assign_vars(array(
));
}
protected function generate_adapter_options()
{
global $phpbb_container;
$adapter_provider_collection = $phpbb_container->get('storage.provider_collection');
$options = '';
foreach($adapter_provider_collection as $provider)
{
$class = get_class($provider);
$options .= "<option value=\"$class\" data-toggle-setting=\"\">$class</option>";
}
return $options;
}
}

View file

@ -407,6 +407,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_reasons', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_roles', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_search', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_server', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_storage', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_styles', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_switchperm', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_uauth', 1);
@ -522,7 +523,7 @@ INSERT INTO phpbb_ranks (rank_title, rank_min, rank_special, rank_image) VALUES
# -- Roles data
# Standard Admin (a_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_aauth', 'a_roles');
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 1, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option NOT IN ('a_switchperm', 'a_jabber', 'a_phpinfo', 'a_server', 'a_backup', 'a_styles', 'a_clearlogs', 'a_modules', 'a_language', 'a_email', 'a_bots', 'a_search', 'a_storage', 'a_aauth', 'a_roles');
# Forum admin (a_)
INSERT INTO phpbb_acl_roles_data (role_id, auth_option_id, auth_setting) SELECT 2, auth_option_id, 1 FROM phpbb_acl_options WHERE auth_option LIKE 'a_%' AND auth_option IN ('a_', 'a_authgroups', 'a_authusers', 'a_fauth', 'a_forum', 'a_forumadd', 'a_forumdel', 'a_mauth', 'a_prune', 'a_uauth', 'a_viewauth', 'a_viewlogs');

View file

@ -0,0 +1,40 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}
if (empty($lang) || !is_array($lang))
{
$lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
$lang = array_merge($lang, array(
));

View file

@ -45,6 +45,21 @@ class storage
$this->storage_name = $storage_name;
}
public function get_id()
{
return $this->storage_name;
}
public function get_name()
{
return strtoupper('STORAGE_' . $this->storage_name . '_NAME');
}
public function get_description()
{
return strtoupper('STORAGE_' . $this->storage_name . '_DESCRIPTION');
}
/**
* Returns an adapter instance
*