mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-19 07:08:09 +01:00
Merge pull request #5726 from marc1706/ticket/12559
[ticket/12559] Add forum setting to limit subforum legend
This commit is contained in:
commit
79a6648b99
@ -210,6 +210,11 @@
|
||||
<dd><label><input type="radio" class="radio" name="display_subforum_list" value="1"<!-- IF S_DISPLAY_SUBFORUM_LIST --> id="display_subforum_list" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
|
||||
<label><input type="radio" class="radio" name="display_subforum_list" value="0"<!-- IF not S_DISPLAY_SUBFORUM_LIST --> id="display_subforum_list" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="display_subforum_limit">{L_LIMIT_SUBFORUMS}{L_COLON}</label><br /><span>{L_LIMIT_SUBFORUMS_EXPLAIN}</span></dt>
|
||||
<dd><label><input type="radio" class="radio" name="display_subforum_limit" value="1"<!-- IF S_DISPLAY_SUBFORUM_LIMIT --> id="display_subforum_limit" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
|
||||
<label><input type="radio" class="radio" name="display_subforum_limit" value="0"<!-- IF not S_DISPLAY_SUBFORUM_LIMIT --> id="display_subforum_limit" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="display_on_index">{L_LIST_INDEX}{L_COLON}</label><br /><span>{L_LIST_INDEX_EXPLAIN}</span></dt>
|
||||
<dd><label><input type="radio" class="radio" name="display_on_index" value="1"<!-- IF S_DISPLAY_ON_INDEX --> id="display_on_index" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
|
||||
|
@ -132,6 +132,7 @@ class acp_forums
|
||||
'forum_image' => $request->variable('forum_image', ''),
|
||||
'forum_style' => $request->variable('forum_style', 0),
|
||||
'display_subforum_list' => $request->variable('display_subforum_list', true),
|
||||
'display_subforum_limit'=> $request->variable('display_subforum_limit', false),
|
||||
'display_on_index' => $request->variable('display_on_index', true),
|
||||
'forum_topics_per_page' => $request->variable('topics_per_page', 0),
|
||||
'enable_indexing' => $request->variable('enable_indexing', true),
|
||||
@ -454,6 +455,7 @@ class acp_forums
|
||||
'forum_image' => '',
|
||||
'forum_style' => 0,
|
||||
'display_subforum_list' => true,
|
||||
'display_subforum_limit' => false,
|
||||
'display_on_index' => true,
|
||||
'forum_topics_per_page' => 0,
|
||||
'enable_indexing' => true,
|
||||
@ -676,6 +678,7 @@ class acp_forums
|
||||
'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false,
|
||||
'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false,
|
||||
'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false,
|
||||
'S_DISPLAY_SUBFORUM_LIMIT' => ($forum_data['display_subforum_limit']) ? true : false,
|
||||
'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false,
|
||||
'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false,
|
||||
'S_PRUNE_SHADOW_ENABLE' => ($forum_data['enable_shadow_prune']) ? true : false,
|
||||
|
@ -30,6 +30,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||
|
||||
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
|
||||
$parent_id = $visible_forums = 0;
|
||||
$parent_subforum_limit = false;
|
||||
|
||||
// Mark forums read?
|
||||
$mark_read = $request->variable('mark', '');
|
||||
@ -266,6 +267,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||
|
||||
// Direct child of current branch
|
||||
$parent_id = $forum_id;
|
||||
$parent_subforum_limit = $row['display_subforum_limit'];
|
||||
$forum_rows[$forum_id] = $row;
|
||||
|
||||
if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id'])
|
||||
@ -278,7 +280,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
|
||||
}
|
||||
else if ($row['forum_type'] != FORUM_CAT)
|
||||
{
|
||||
$subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index']) ? true : false;
|
||||
$subforums[$parent_id][$forum_id]['display'] = ($row['display_on_index'] && (!$parent_subforum_limit || $parent_id == $row['parent_id']));
|
||||
$subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
|
||||
$subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
|
||||
$subforums[$parent_id][$forum_id]['children'] = array();
|
||||
|
@ -129,6 +129,8 @@ $lang = array_merge($lang, array(
|
||||
'GENERAL_FORUM_SETTINGS' => 'General forum settings',
|
||||
|
||||
'LINK' => 'Link',
|
||||
'LIMIT_SUBFORUMS' => 'Limit legend to direct child-subforums',
|
||||
'LIMIT_SUBFORUMS_EXPLAIN' => 'Limits the subforums to be displayed to subforums that are direct descendants (children) of the current forum. Disabling this will display all subforums with the “List subforums in legend” option enabled, regardless of depth.',
|
||||
'LIST_INDEX' => 'List subforum in parent-forum’s legend',
|
||||
'LIST_INDEX_EXPLAIN' => 'Displays this forum on the index and elsewhere as a link within the legend of its parent-forum if the parent-forum’s “List subforums in legend” option is enabled.',
|
||||
'LIST_SUBFORUMS' => 'List subforums in legend',
|
||||
|
49
phpBB/phpbb/db/migration/data/v330/forums_legend_limit.php
Normal file
49
phpBB/phpbb/db/migration/data/v330/forums_legend_limit.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?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\v330;
|
||||
|
||||
class forums_legend_limit extends \phpbb\db\migration\migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->db_tools->sql_column_exists($this->table_prefix . 'forums', 'display_subforum_limit');
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v330\v330b1'];
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return [
|
||||
'add_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'display_subforum_limit' => ['BOOL', 0, 'after' => 'display_subforum_list'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return [
|
||||
'drop_columns' => [
|
||||
$this->table_prefix . 'forums' => [
|
||||
'display_subforum_limit',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
113
tests/functional/subforum_test.php
Normal file
113
tests/functional/subforum_test.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_subforum_test extends phpbb_functional_test_case
|
||||
{
|
||||
public function test_setup_forums()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$forum_name = 'Subforum Test #1';
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
|
||||
$form = $crawler->selectButton('addforum')->form([
|
||||
'forum_name' => $forum_name,
|
||||
]);
|
||||
$crawler = self::submit($form);
|
||||
$form = $crawler->selectButton('update')->form([
|
||||
'forum_perm_from' => 2,
|
||||
]);
|
||||
self::submit($form);
|
||||
$forum_id = self::get_forum_id($forum_name);
|
||||
|
||||
// 'Feeds #1.1' is a sub-forum of 'Feeds #1'
|
||||
$forum_name = 'Subforum Test #1.1';
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}");
|
||||
$form = $crawler->selectButton('addforum')->form([
|
||||
'forum_name' => $forum_name,
|
||||
]);
|
||||
$crawler = self::submit($form);
|
||||
$form = $crawler->selectButton('update')->form([
|
||||
'forum_perm_from' => 2,
|
||||
]);
|
||||
self::submit($form);
|
||||
$forum_id = self::get_forum_id('Subforum Test #1.1');
|
||||
|
||||
// 'Feeds #news' will be used for feed.php?mode=news
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}");
|
||||
$form = $crawler->selectButton('addforum')->form([
|
||||
'forum_name' => 'Subforum Test #1.1.1',
|
||||
]);
|
||||
$crawler = self::submit($form);
|
||||
$form = $crawler->selectButton('update')->form([
|
||||
'forum_perm_from' => 2,
|
||||
]);
|
||||
self::submit($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_setup_forums
|
||||
*/
|
||||
public function test_display_subforums()
|
||||
{
|
||||
$crawler = self::request('GET', "index.php?sid={$this->sid}");
|
||||
$this->assertContains('Subforum Test #1.1', $crawler->html());
|
||||
$this->assertContains('Subforum Test #1.1.1', $crawler->html());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_display_subforums
|
||||
*/
|
||||
public function test_display_subforums_limit()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
// Disable listing subforums
|
||||
$forum_id = $this->get_forum_id('Subforum Test #1');
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=7&mode=manage&parent_id=0&f={$forum_id}&action=edit");
|
||||
$form = $crawler->selectButton('submit')->form([
|
||||
'display_subforum_limit' => 1,
|
||||
]);
|
||||
self::submit($form);
|
||||
|
||||
$crawler = self::request('GET', "index.php?sid={$this->sid}");
|
||||
$this->assertContains('Subforum Test #1.1', $crawler->html());
|
||||
$this->assertNotContains('Subforum Test #1.1.1', $crawler->html());
|
||||
}
|
||||
|
||||
protected function get_forum_id($forum_name)
|
||||
{
|
||||
$this->db = $this->get_db();
|
||||
$forum_id = 0;
|
||||
|
||||
$sql = 'SELECT *
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE ' . $this->db->sql_in_set('forum_name', $forum_name);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if ($row['forum_name'] == $forum_name)
|
||||
{
|
||||
$forum_id = (int) $row['forum_id'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $forum_id;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user