aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/mcp/mcp_front.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/mcp/mcp_front.php')
-rw-r--r--phpBB/includes/mcp/mcp_front.php89
1 files changed, 75 insertions, 14 deletions
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index 44cab5d910..432b26ad11 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -1,9 +1,13 @@
<?php
/**
*
-* @package mcp
-* @copyright (c) 2005 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+* 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.
*
*/
@@ -20,8 +24,9 @@ if (!defined('IN_PHPBB'))
*/
function mcp_front_view($id, $mode, $action)
{
- global $phpEx, $phpbb_root_path, $config;
+ global $phpEx, $phpbb_root_path;
global $template, $db, $user, $auth, $module;
+ global $phpbb_dispatcher, $request;
// Latest 5 unapproved
if ($module->loaded('queue'))
@@ -30,16 +35,33 @@ function mcp_front_view($id, $mode, $action)
$post_list = array();
$forum_names = array();
- $forum_id = request_var('f', 0);
+ $forum_id = $request->variable('f', 0);
$template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
if (!empty($forum_list))
{
- $sql = 'SELECT COUNT(post_id) AS total
- FROM ' . POSTS_TABLE . '
- WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
- AND post_visibility = ' . ITEM_UNAPPROVED;
+ $sql_ary = array(
+ 'SELECT' => 'COUNT(post_id) AS total',
+ 'FROM' => array(
+ POSTS_TABLE => 'p',
+ ),
+ 'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . '
+ AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE))
+ );
+
+ /**
+ * Allow altering the query to get the number of unapproved posts
+ *
+ * @event core.mcp_front_queue_unapproved_total_before
+ * @var int sql_ary Query to get the total number of unapproved posts
+ * @var array forum_list List of forums to look for unapproved posts
+ * @since 3.1.5-RC1
+ */
+ $vars = array('sql_ary', 'forum_list');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars)));
+
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result);
@@ -60,8 +82,8 @@ function mcp_front_view($id, $mode, $action)
$sql = 'SELECT post_id
FROM ' . POSTS_TABLE . '
WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
- AND post_visibility = ' . ITEM_UNAPPROVED . '
- ORDER BY post_time DESC';
+ AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
+ ORDER BY post_time DESC, post_id DESC';
$result = $db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result))
@@ -76,6 +98,19 @@ function mcp_front_view($id, $mode, $action)
}
}
+ /**
+ * Alter list of posts and total as required
+ *
+ * @event core.mcp_front_view_queue_postid_list_after
+ * @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
+ * @since 3.1.0-RC3
+ */
+ $vars = array('total', 'post_list', 'forum_list', 'forum_names');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars)));
+
if ($total)
{
$sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
@@ -83,7 +118,7 @@ function mcp_front_view($id, $mode, $action)
WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
AND t.topic_id = p.topic_id
AND p.poster_id = u.user_id
- ORDER BY p.post_time DESC';
+ ORDER BY p.post_time DESC, p.post_id DESC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -139,6 +174,18 @@ function mcp_front_view($id, $mode, $action)
AND r.pm_id = 0
AND r.report_closed = 0
AND ' . $db->sql_in_set('p.forum_id', $forum_list);
+
+ /**
+ * Alter sql query to count the number of reported posts
+ *
+ * @event core.mcp_front_reports_count_query_before
+ * @var int sql The query string used to get the number of reports that exist
+ * @var array forum_list List of forums that contain the posts
+ * @since 3.1.5-RC1
+ */
+ $vars = array('sql', 'forum_list');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars)));
+
$result = $db->sql_query($sql);
$total = (int) $db->sql_fetchfield('total');
$db->sql_freeresult($result);
@@ -172,8 +219,20 @@ function mcp_front_view($id, $mode, $action)
AND p.poster_id = u2.user_id
AND ' . $db->sql_in_set('p.forum_id', $forum_list),
- 'ORDER_BY' => 'p.post_time DESC',
+ 'ORDER_BY' => 'p.post_time DESC, p.post_id DESC',
);
+
+ /**
+ * Alter sql query to get latest reported posts
+ *
+ * @event core.mcp_front_reports_listing_query_before
+ * @var int sql_ary Associative array with the query to be executed
+ * @var array forum_list List of forums that contain the posts
+ * @since 3.1.0-RC3
+ */
+ $vars = array('sql_ary', 'forum_list');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_listing_query_before', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query_limit($sql, 5);
@@ -204,6 +263,7 @@ function mcp_front_view($id, $mode, $action)
'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']) : '',
));
}
+ $db->sql_freeresult($result);
}
$template->assign_vars(array(
@@ -214,7 +274,7 @@ function mcp_front_view($id, $mode, $action)
}
// Latest 5 reported PMs
- if ($module->loaded('pm_reports') && $auth->acl_getf_global('m_report'))
+ if ($module->loaded('pm_reports') && $auth->acl_get('m_pm_report'))
{
$template->assign_var('S_SHOW_PM_REPORTS', true);
$user->add_lang(array('ucp'));
@@ -260,6 +320,7 @@ function mcp_front_view($id, $mode, $action)
$pm_by_id[(int) $row['msg_id']] = $row;
$pm_list[] = (int) $row['msg_id'];
}
+ $db->sql_freeresult($result);
$address_list = get_recipient_strings($pm_by_id);