aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-12-30 11:04:43 -0800
committerNathan Guse <nathaniel.guse@gmail.com>2013-12-30 11:04:43 -0800
commitbe67124dc7d5461c9b085e4dc3f32ece87e4b1aa (patch)
treec65ec32dc4cd23154ed0b289ce4bd17cc2a31614 /phpBB/includes
parent34c3e74c16b6e7455733d7ba41494c38d753618e (diff)
parent3da445ada4a8de1f50a004c074e2a4befb9fc040 (diff)
downloadforums-be67124dc7d5461c9b085e4dc3f32ece87e4b1aa.tar
forums-be67124dc7d5461c9b085e4dc3f32ece87e4b1aa.tar.gz
forums-be67124dc7d5461c9b085e4dc3f32ece87e4b1aa.tar.bz2
forums-be67124dc7d5461c9b085e4dc3f32ece87e4b1aa.tar.xz
forums-be67124dc7d5461c9b085e4dc3f32ece87e4b1aa.zip
Merge pull request #1889 from prototech/ticket/11963
[ticket/11963] Remove stale MCP notifications.
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/mcp/mcp_queue.php38
-rw-r--r--phpBB/includes/mcp/mcp_reports.php10
2 files changed, 37 insertions, 11 deletions
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 3b6897f4e1..9f9c22a5c5 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -654,6 +654,11 @@ class mcp_queue
// Handle notifications
foreach ($post_info as $post_id => $post_data)
{
+ // A single topic approval may also happen here, so handle deleting the respective notification.
+ if (!$post_data['topic_posts_approved'])
+ {
+ $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']);
+ }
$phpbb_notifications->delete_notifications('post_in_queue', $post_id);
$phpbb_notifications->add_notifications(array(
@@ -773,9 +778,12 @@ class mcp_queue
$notify_poster = ($action == 'approve' && isset($_REQUEST['notify_poster'])) ? true : false;
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
+ $first_post_ids = array();
+
foreach ($topic_info as $topic_id => $topic_data)
{
$phpbb_content_visibility->set_topic_visibility(ITEM_APPROVED, $topic_id, $topic_data['forum_id'], $user->data['user_id'], time(), '');
+ $first_post_ids[$topic_id] = (int) $topic_data['topic_first_post_id'];
$topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_data['forum_id']}&amp;t={$topic_id}");
@@ -799,23 +807,43 @@ class mcp_queue
// Only send out the mails, when the posts are being approved
if ($action == 'approve')
{
+ // Grab the first post text as it's needed for the quote notification.
+ $sql = 'SELECT topic_id, post_text
+ FROM ' . POSTS_TABLE . '
+ WHERE ' . $db->sql_in_set('post_id', $first_post_ids);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $topic_info[$row['topic_id']]['post_text'] = $row['post_text'];
+ }
+ $db->sql_freeresult($result);
+
// Handle notifications
$phpbb_notifications = $phpbb_container->get('notification_manager');
foreach ($topic_info as $topic_id => $topic_data)
{
- $phpbb_notifications->delete_notifications('topic_in_queue', $post_data['topic_id']);
+ $topic_data = array_merge($topic_data, array(
+ 'post_id' => $topic_data['topic_first_post_id'],
+ 'post_subject' => $topic_data['topic_title'],
+ 'post_time' => $topic_data['topic_time'],
+ 'poster_id' => $topic_data['topic_poster'],
+ 'username' => $topic_data['topic_first_poster_name'],
+ ));
+
+ $phpbb_notifications->delete_notifications('topic_in_queue', $topic_id);
$phpbb_notifications->add_notifications(array(
'quote',
'topic',
- ), $post_data);
+ ), $topic_data);
- $phpbb_notifications->mark_notifications_read('quote', $post_data['post_id'], $user->data['user_id']);
- $phpbb_notifications->mark_notifications_read('topic', $post_data['topic_id'], $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read('quote', $topic_data['post_id'], $user->data['user_id']);
+ $phpbb_notifications->mark_notifications_read('topic', $topic_id, $user->data['user_id']);
if ($notify_poster)
{
- $phpbb_notifications->add_notifications('approve_topic', $post_data);
+ $phpbb_notifications->add_notifications('approve_topic', $topic_data);
}
}
}
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index 02892964f1..954f8a8349 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -616,23 +616,25 @@ function close_report($report_id_list, $mode, $action, $pm = false)
}
unset($close_report_posts, $close_report_topics);
+ $phpbb_notifications = $phpbb_container->get('notification_manager');
+
foreach ($reports as $report)
{
if ($pm)
{
add_log('mod', 0, 0, 'LOG_PM_REPORT_' . strtoupper($action) . 'D', $post_info[$report['pm_id']]['message_subject']);
+ $phpbb_notifications->delete_notifications('report_pm', $report['pm_id']);
}
else
{
add_log('mod', $post_info[$report['post_id']]['forum_id'], $post_info[$report['post_id']]['topic_id'], 'LOG_REPORT_' . strtoupper($action) . 'D', $post_info[$report['post_id']]['post_subject']);
+ $phpbb_notifications->delete_notifications('report_post', $report['post_id']);
}
}
// Notify reporters
if (sizeof($notify_reporters))
{
- $phpbb_notifications = $phpbb_container->get('notification_manager');
-
foreach ($notify_reporters as $report_id => $reporter)
{
if ($reporter['user_id'] == ANONYMOUS)
@@ -649,8 +651,6 @@ function close_report($report_id_list, $mode, $action, $pm = false)
'closer_id' => $user->data['user_id'],
'from_user_id' => $post_info[$post_id]['author_id'],
)));
-
- $phpbb_notifications->delete_notifications('report_pm', $post_id);
}
else
{
@@ -658,8 +658,6 @@ function close_report($report_id_list, $mode, $action, $pm = false)
'reporter' => $reporter['user_id'],
'closer_id' => $user->data['user_id'],
)));
-
- $phpbb_notifications->delete_notifications('report_post', $post_id);
}
}
}