[ticket/17093] Add new board settings option for disable board access

PHPBB3-17093
This commit is contained in:
Christian Schnegelberger 2023-01-17 19:49:07 +01:00
parent 276d793c7b
commit d86c51f9e3
5 changed files with 65 additions and 1 deletions

View file

@ -79,6 +79,7 @@ class acp_board
'board_index_text' => array('lang' => 'BOARD_INDEX_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
'board_disable_msg' => false,
'board_disable_access' => array('lang' => 'DISABLE_BOARD_ACCESS', 'validate' => 'int', 'type' => 'select', 'method' => 'board_disable_access', 'explain' => true),
'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'method' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true),
@ -1047,6 +1048,16 @@ class acp_board
return h_radio('config[board_disable]', $radio_ary, $value) . '<br /><input id="' . $key . '" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $this->new_config['board_disable_msg'] . '" />';
}
/**
* Board disable access for which group: admins: 0; plus global moderators: 1 and plus all moderators: 2
*/
function board_disable_access($value, $key ='')
{
global $user;
return '<option value="0"' . (($value == 0) ? ' selected="selected"' : '') . '>' . $user->lang['DISABLE_BOARD_ACCESS_ADMIN'] . '</option><option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DISABLE_BOARD_ACCESS_ADMIN_GLOB_MODS'] . '</option><option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DISABLE_BOARD_ACCESS_ADMIN_ALL_MODS'] . '</option>';
}
/**
* Global quick reply enable/disable setting and button to enable in all forums
*/

View file

@ -57,6 +57,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact', 'c
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact_name', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_msg', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_access', '2');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email', 'address@yourdomain.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig', '{L_CONFIG_BOARD_EMAIL_SIG}');

View file

@ -50,6 +50,11 @@ $lang = array_merge($lang, array(
'DEFAULT_STYLE_EXPLAIN' => 'The default style for new users.',
'DISABLE_BOARD' => 'Disable board',
'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users who are neither administrators nor moderators. You can also enter a short (255 character) message to display if you wish.',
'DISABLE_BOARD_ACCESS' => 'Limit access of disabled board',
'DISABLE_BOARD_ACCESS_EXPLAIN' => 'This setting limits the access to a disable board to only administrators, or administrators plus global moderators or administrators and all moderators',
'DISABLE_BOARD_ACCESS_ADMIN' => 'Only administrators',
'DISABLE_BOARD_ACCESS_ADMIN_GLOB_MODS' => 'Only administrators and global moderators',
'DISABLE_BOARD_ACCESS_ADMIN_ALL_MODS' => 'Only administrators and all moderators',
'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list',
'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesnt have read access are not shown.',
'DISPLAY_UNAPPROVED_POSTS' => 'Display unapproved posts to the author',

View file

@ -0,0 +1,31 @@
<?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.
*
*/
namespace phpbb\db\migration\data\v33x;
class add_disable_board_access_config extends \phpbb\db\migration\migration
{
static public function depends_on()
{
return [
'\phpbb\db\migration\data\v33x\v339',
];
}
public function update_data()
{
return [
['config.add', ['board_disable_access', '2']],
];
}
}

View file

@ -372,7 +372,23 @@ class user extends \phpbb\session
}
// Is board disabled and user not an admin or moderator?
if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
// Check acp setting who has access: only admins "case: 0", plus global moderators "case: 1" and plus moderators "case: 2"
$disable_board_access = (int) $config['add_disable_board_access_config'];
switch ($disable_board_access) {
case 0:
$access_disabled_board = $auth->acl_gets('a_');
break;
case 1:
$access_disabled_board = $auth->acl_gets('a_') && $auth->acl_getf_global('m_');
break;
default:
case 2:
$access_disabled_board = $auth->acl_gets('a_', 'm_') && $auth->acl_getf_global('m_');
break;
}
if ($config['board_disable'] && !defined('IN_INSTALL') && !defined('IN_LOGIN') && !defined('SKIP_CHECK_DISABLED') && !$access_disabled_board)
{
if ($this->data['is_bot'])
{