1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 00:02:18 +02:00

[ticket/14738] Add core events to improve modifying forum lists

PHPBB3-14738
This commit is contained in:
rxu 2016-08-07 16:10:49 +07:00
parent 2dae36e3fb
commit 3bf64de247
3 changed files with 59 additions and 11 deletions

View File

@ -842,9 +842,26 @@ class acp_forums
ORDER BY left_id";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
do
$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);
/**
* Modify the forum list data
*
* @event core.acp_manage_forums_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_modify_forum_list', compact($vars)));
if (!empty($rowset))
{
foreach ($rowset as $row)
{
$forum_type = $row['forum_type'];
@ -888,7 +905,6 @@ class acp_forums
'U_SYNC' => $url . '&action=sync')
);
}
while ($row = $db->sql_fetchrow($result));
}
else if ($this->parent_id)
{
@ -904,7 +920,7 @@ class acp_forums
'U_SYNC' => $url . '&action=sync')
);
}
$db->sql_freeresult($result);
unset($rowset);
$template->assign_vars(array(
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',

View File

@ -65,7 +65,7 @@ function recalc_nested_sets(&$new_id, $pkey, $table, $parent_id = 0, $where = ar
*/
function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = false, $ignore_nonpost = false, $ignore_emptycat = true, $only_acl_post = false, $return_array = false)
{
global $db, $user, $auth;
global $db, $user, $auth, $phpbb_dispatcher;
// This query is identical to the jumpbox one
$sql = 'SELECT forum_id, forum_name, parent_id, forum_type, forum_flags, forum_options, left_id, right_id
@ -73,16 +73,33 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);
$right = 0;
$padding_store = array('0' => '');
$padding = '';
$forum_list = ($return_array) ? array() : '';
/**
* Modify the forum list data
*
* @event core.make_forum_select_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.make_forum_select_modify_forum_list', compact($vars)));
// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"
while ($row = $db->sql_fetchrow($result))
foreach ($rowset as $row)
{
if ($row['left_id'] < $right)
{
@ -133,8 +150,7 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl =
$forum_list .= '<option value="' . $row['forum_id'] . '"' . (($disabled) ? ' disabled="disabled" class="disabled-option"' : $selected) . '>' . $padding . $row['forum_name'] . '</option>';
}
}
$db->sql_freeresult($result);
unset($padding_store);
unset($padding_store, $rowset);
return $forum_list;
}

View File

@ -163,16 +163,33 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list
ORDER BY left_id ASC';
$result = $db->sql_query($sql, 600);
$rowset = array();
while ($row = $db->sql_fetchrow($result))
{
$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);
$right = $padding = 0;
$padding_store = array('0' => 0);
$display_jumpbox = false;
$iteration = 0;
/**
* Modify the jumpbox forum list data
*
* @event core.make_jumpbox_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.make_jumpbox_modify_forum_list', compact($vars)));
// Sometimes it could happen that forums will be displayed here not be displayed within the index page
// This is the result of forums not displayed at index, having list permissions and a parent of a forum with no permissions.
// If this happens, the padding could be "broken"
while ($row = $db->sql_fetchrow($result))
foreach ($rowset as $row)
{
if ($row['left_id'] < $right)
{
@ -254,8 +271,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list
}
$iteration++;
}
$db->sql_freeresult($result);
unset($padding_store);
unset($padding_store, $rowset);
$url_parts = $phpbb_path_helper->get_url_parts($action);