1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 13:30:25 +02:00

[ticket/16904] Fix regression in MCP for topics selection

Regression introduced in #5760

PHPBB3-16904
This commit is contained in:
rxu
2021-11-02 13:55:39 +07:00
parent 8246023e0f
commit 337d876df7
2 changed files with 29 additions and 41 deletions

View File

@@ -35,7 +35,7 @@ function phpbb_module_notes_url($mode, $module_row)
}
global $user_id;
return ($user_id) ? "&u=$user_id" : '';
return phpbb_extra_url();
}
function phpbb_module_warn_url($mode, $module_row)
@@ -43,34 +43,18 @@ function phpbb_module_warn_url($mode, $module_row)
if ($mode == 'front' || $mode == 'list')
{
global $forum_id;
return ($forum_id) ? "&f=$forum_id" : '';
return phpbb_extra_url();
}
if ($mode == 'warn_post')
{
global $forum_id, $post_id;
if ($post_id)
{
$url_extra = "&p=$post_id";
}
else if ($forum_id)
{
$url_extra = "&f=$forum_id";
}
else
{
$url_extra = '';
}
return $url_extra;
return phpbb_extra_url();
}
else
{
global $user_id;
return ($user_id) ? "&u=$user_id" : '';
return phpbb_extra_url();
}
}
@@ -99,30 +83,34 @@ function phpbb_module_reports_url($mode, $module_row)
return phpbb_extra_url();
}
function phpbb_extra_url()
/**
* Generate URL parameters for MCP modules
*
* @param array $additional_parameters Array with additional parameters in format of ['key' => 'parameter_name']
*
* @return string String with URL parameters (empty string if not any)
*/
function phpbb_extra_url($additional_parameters = [])
{
global $forum_id, $topic_id, $post_id, $report_id, $user_id;
$url_extra = [];
$url_parameters = array_merge([
'f' => 'forum_id',
't' => 'topic_id',
'p' => 'post_id',
'r' => 'report_id',
'u' => 'user_id',
], $additional_parameters);
if ($post_id)
foreach ($url_parameters as $key => $value)
{
$url_extra = "&p=$post_id";
global $$value;
if (isset($$value) && $parameter = $$value)
{
$url_extra[] = "$key=$parameter";
}
}
else if ($topic_id)
{
$url_extra = "&t=$topic_id";
}
else if ($forum_id)
{
$url_extra = "&f=$forum_id";
}
else
{
$url_extra = '';
}
$url_extra .= ($user_id) ? "&u=$user_id" : '';
$url_extra .= ($report_id) ? "&r=$report_id" : '';
return $url_extra;
return implode('&', $url_extra);
}
/**