mirror of
https://github.com/phpbb/phpbb.git
synced 2025-01-18 06:38:43 +01:00
Merge pull request #6209 from rxu/ticket/16771
[ticket/16771] Add MCP core events
This commit is contained in:
commit
49974a169b
@ -105,7 +105,7 @@ function mcp_front_view($id, $mode, $action)
|
||||
* @var int total Number of unapproved posts
|
||||
* @var array post_list List of unapproved posts
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var array forum_names Associative array with forum_id as key and it's corresponding forum_name as value
|
||||
* @var array forum_names Associative array with forum_id as key and its corresponding forum_name as value
|
||||
* @since 3.1.0-RC3
|
||||
*/
|
||||
$vars = array('total', 'post_list', 'forum_list', 'forum_names');
|
||||
@ -119,11 +119,32 @@ function mcp_front_view($id, $mode, $action)
|
||||
AND t.topic_id = p.topic_id
|
||||
AND p.poster_id = u.user_id
|
||||
ORDER BY p.post_time DESC, p.post_id DESC';
|
||||
|
||||
/**
|
||||
* Alter posts data SQL query
|
||||
*
|
||||
* @event core.mcp_front_view_modify_posts_data_sql
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var array forum_names Associative array with forum_id as key and its corresponding forum_name as value
|
||||
* @var array post_list List of unapproved posts
|
||||
* @var string sql String with the SQL query to be executed
|
||||
* @var int total Number of unapproved posts
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'forum_list',
|
||||
'forum_names',
|
||||
'post_list',
|
||||
'sql',
|
||||
'total',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_modify_posts_data_sql', compact($vars)));
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('unapproved', array(
|
||||
$unapproved_post_row = [
|
||||
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $row['forum_id'] . '&p=' . $row['post_id']),
|
||||
'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=forum_view&f=' . $row['forum_id']),
|
||||
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&mode=topic_view&f=' . $row['forum_id'] . '&t=' . $row['topic_id']),
|
||||
@ -141,7 +162,27 @@ function mcp_front_view($id, $mode, $action)
|
||||
'SUBJECT' => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
|
||||
'POST_TIME' => $user->format_date($row['post_time']),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
];
|
||||
|
||||
/**
|
||||
* Alter unapproved posts template block for MCP front page
|
||||
*
|
||||
* @event core.mcp_front_view_modify_unapproved_post_row
|
||||
* @var array forum_names Array containing forum names
|
||||
* @var string mode MCP front view mode
|
||||
* @var array row Array with unapproved post data
|
||||
* @var array unapproved_post_row Template block array of the unapproved post
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'forum_names',
|
||||
'mode',
|
||||
'row',
|
||||
'unapproved_post_row',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_modify_unapproved_post_row', compact($vars)));
|
||||
|
||||
$template->assign_block_vars('unapproved', $unapproved_post_row);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
@ -238,7 +279,7 @@ function mcp_front_view($id, $mode, $action)
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('report', array(
|
||||
$reported_post_row = [
|
||||
'U_POST_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id'] . "&i=reports&mode=report_details"),
|
||||
'U_MCP_FORUM' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&i=$id&mode=forum_view"),
|
||||
'U_MCP_TOPIC' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id'] . "&i=$id&mode=topic_view"),
|
||||
@ -261,7 +302,27 @@ function mcp_front_view($id, $mode, $action)
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'POST_TIME' => $user->format_date($row['post_time']),
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
];
|
||||
|
||||
/**
|
||||
* Alter reported posts template block for MCP front page
|
||||
*
|
||||
* @event core.mcp_front_view_modify_reported_post_row
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var string mode MCP front view mode
|
||||
* @var array reported_post_row Template block array of the reported post
|
||||
* @var array row Array with reported post data
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'forum_list',
|
||||
'mode',
|
||||
'reported_post_row',
|
||||
'row',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_modify_reported_post_row', compact($vars)));
|
||||
|
||||
$template->assign_block_vars('report', $reported_post_row);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
|
@ -493,11 +493,30 @@ class mcp_reports
|
||||
AND ru.user_id = r.user_id
|
||||
AND r.pm_id = 0
|
||||
ORDER BY ' . $sort_order_sql;
|
||||
|
||||
/**
|
||||
* Alter sql query to get reports data for requested forum and topic or just forum
|
||||
*
|
||||
* @event core.mcp_reports_modify_reports_data_sql
|
||||
* @var string sql String with the query to be executed
|
||||
* @var array forum_list List of forums that contain the posts
|
||||
* @var int topic_id topic_id in the page request
|
||||
* @var string sort_order_sql String with the ORDER BY SQL code used in this query
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'sql',
|
||||
'forum_list',
|
||||
'topic_id',
|
||||
'sort_order_sql',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_reports_modify_reports_data_sql', compact($vars)));
|
||||
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$template->assign_block_vars('postrow', array(
|
||||
$post_row = [
|
||||
'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
|
||||
'U_VIEWPOST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&p=' . $row['post_id']) . '#p' . $row['post_id'],
|
||||
'U_VIEW_DETAILS' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=reports&start=$start&mode=report_details&f={$row['forum_id']}&r={$row['report_id']}"),
|
||||
@ -520,7 +539,31 @@ class mcp_reports
|
||||
'REPORT_TIME' => $user->format_date($row['report_time']),
|
||||
'TOPIC_TITLE' => $row['topic_title'],
|
||||
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||
));
|
||||
];
|
||||
|
||||
/**
|
||||
* Alter posts template block for MCP reports
|
||||
*
|
||||
* @event core.mcp_reports_modify_post_row
|
||||
* @var string mode Post report mode
|
||||
* @var array forum_data Array containing forum data
|
||||
* @var array post_row Template block array of the post
|
||||
* @var array row Array with original post and report data
|
||||
* @var int start Start item of this page
|
||||
* @var int topic_id topic_id in the page request
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'mode',
|
||||
'forum_data',
|
||||
'post_row',
|
||||
'row',
|
||||
'start',
|
||||
'topic_id',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_reports_modify_post_row', compact($vars)));
|
||||
|
||||
$template->assign_block_vars('postrow', $post_row);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
unset($report_ids, $row);
|
||||
|
@ -379,7 +379,7 @@ function mcp_topic_view($id, $mode, $action)
|
||||
$pagination->generate_template_pagination($base_url, 'pagination', 'start', $total, $posts_per_page, $start);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
$topic_row = [
|
||||
'TOPIC_TITLE' => $topic_info['topic_title'],
|
||||
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&t=' . $topic_info['topic_id']),
|
||||
|
||||
@ -420,7 +420,49 @@ function mcp_topic_view($id, $mode, $action)
|
||||
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&start=$start") . '">', '</a>'),
|
||||
|
||||
'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total),
|
||||
));
|
||||
];
|
||||
|
||||
/**
|
||||
* Event to modify the template data block for topic data output in the MCP
|
||||
*
|
||||
* @event core.mcp_topic_review_modify_topic_row
|
||||
* @var string action Moderation action type to be performed with the topic
|
||||
* @var bool has_unapproved_posts Flag indicating if the topic has unapproved posts
|
||||
* @var int icon_id Split topic icon ID
|
||||
* @var int id ID of the tab we are displaying
|
||||
* @var string mode Mode of the MCP page we are displaying
|
||||
* @var int topic_id The topic ID we are currently reviewing
|
||||
* @var int forum_id The forum ID we are currently in
|
||||
* @var bool s_topic_icons Flag indicating if split topic icon to be displayed
|
||||
* @var int start Start item of this page
|
||||
* @var string subject Subject of the topic to be split
|
||||
* @var array topic_info Array with topic data
|
||||
* @var int to_forum_id Forum id the topic is being moved to
|
||||
* @var int to_topic_id Topic ID the topic is being merged with
|
||||
* @var array topic_row Topic template data array
|
||||
* @var int total Total posts count
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'action',
|
||||
'has_unapproved_posts',
|
||||
'icon_id',
|
||||
'id',
|
||||
'mode',
|
||||
'topic_id',
|
||||
'forum_id',
|
||||
's_topic_icons',
|
||||
'start',
|
||||
'subject',
|
||||
'topic_info',
|
||||
'to_forum_id',
|
||||
'to_topic_id',
|
||||
'topic_row',
|
||||
'total',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topic_review_modify_topic_row', compact($vars)));
|
||||
|
||||
$template->assign_vars($topic_row);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -696,6 +738,32 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
|
||||
$redirect = $request->variable('redirect', "{$phpbb_root_path}viewtopic.$phpEx?f=$to_forum_id&t=$to_topic_id");
|
||||
$redirect = reapply_sid($redirect);
|
||||
|
||||
/**
|
||||
* Event to access topic data after split
|
||||
*
|
||||
* @event core.mcp_topic_split_topic_after
|
||||
* @var string action Split action type to be performed with the topic
|
||||
* @var int topic_id The topic ID we are currently splitting
|
||||
* @var int forum_id The forum ID we are currently in
|
||||
* @var int start Start item of this page
|
||||
* @var string subject Subject of the topic to be split
|
||||
* @var array topic_info Array with topic data
|
||||
* @var int to_forum_id Forum id the topic is being moved to
|
||||
* @var int to_topic_id Topic ID the topic is being split to
|
||||
* @since 3.3.5-RC1
|
||||
*/
|
||||
$vars = [
|
||||
'action',
|
||||
'topic_id',
|
||||
'forum_id',
|
||||
'start',
|
||||
'subject',
|
||||
'topic_info',
|
||||
'to_forum_id',
|
||||
'to_topic_id',
|
||||
];
|
||||
extract($phpbb_dispatcher->trigger_event('core.mcp_topic_split_topic_after', compact($vars)));
|
||||
|
||||
meta_refresh(3, $redirect);
|
||||
trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user