[ticket/11103] Remove notifications to posts/topics when they are deleted

PHPBB3-11103
This commit is contained in:
Nathan Guse 2012-09-09 17:43:10 -05:00
parent 2c31e82b60
commit 12e46e48c8

View file

@ -619,6 +619,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true)
function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true) function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_sync = true, $call_delete_posts = true)
{ {
global $db, $config; global $db, $config;
global $phpbb_container;
$approved_topics = 0; $approved_topics = 0;
$forum_ids = $topic_ids = array(); $forum_ids = $topic_ids = array();
@ -715,6 +716,10 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
set_config_count('num_topics', $approved_topics * (-1), true); set_config_count('num_topics', $approved_topics * (-1), true);
} }
// Delete notifications
$notifications = $phpbb_container->get('notifications');
$notifications->delete_notifications('topic', $topic_ids);
return $return; return $return;
} }
@ -724,6 +729,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true) function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true)
{ {
global $db, $config, $phpbb_root_path, $phpEx, $auth, $user; global $db, $config, $phpbb_root_path, $phpEx, $auth, $user;
global $phpbb_container;
if ($where_type === 'range') if ($where_type === 'range')
{ {
@ -892,6 +898,10 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false); delete_topics('topic_id', $remove_topics, $auto_sync, $post_count_sync, false);
} }
// Delete notifications
$notifications = $phpbb_container->get('notifications');
$notifications->delete_notifications('post', $post_ids);
return sizeof($post_ids); return sizeof($post_ids);
} }