diff --git a/upload/ajax/posts.php b/upload/ajax/posts.php index 67d72417f..7c6397144 100644 --- a/upload/ajax/posts.php +++ b/upload/ajax/posts.php @@ -58,8 +58,8 @@ switch($this->request['type']) } post_delete($post_id); - // Update user atom feed - update_atom((int) $this->request['topic_id']); + // Update atom feed + update_atom('topic', (int) $this->request['topic_id']); $this->response['hide'] = true; $this->response['post_id'] = $post_id; @@ -162,8 +162,8 @@ switch($this->request['type']) } else $this->ajax_die($lang['EMPTY_MESSAGE']); - // Update user atom feed - update_atom((int) $this->request['topic_id']); + // Update atom feed + update_atom('topic', (int) $this->request['topic_id']); $this->response['html'] = bbcode2html($text); } @@ -316,8 +316,8 @@ switch($this->request['type']) user_notification('reply', $post, $post['topic_title'], $post['forum_id'], $topic_id, $notify); } - // Update user atom feed - update_atom((int) $this->request['topic_id']); + // Update atom feed + update_atom('topic', (int) $this->request['topic_id']); $this->response['redirect'] = make_url(POST_URL . "$post_id#$post_id"); break; diff --git a/upload/includes/functions.php b/upload/includes/functions.php index c83a7fb0f..b92c29b34 100644 --- a/upload/includes/functions.php +++ b/upload/includes/functions.php @@ -2838,11 +2838,19 @@ function is_gold ($type) return $is_gold; } -function update_atom ($topic_id) +function update_atom ($type, $id) { require_once(INC_DIR .'functions_atom.php'); - // Update user atom feed - $topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $topic_id LIMIT 1", 'topic_poster'); - update_user_feed($topic_poster, get_username($topic_poster)); + switch ($type) + { + case 'user': + update_user_feed($id, get_username($id)); + break; + + case 'topic': + $topic_poster = (int) DB()->fetch_row("SELECT topic_poster FROM ". BB_TOPICS ." WHERE topic_id = $id LIMIT 1", 'topic_poster'); + update_user_feed($topic_poster, get_username($topic_poster)); + break; + } } \ No newline at end of file diff --git a/upload/includes/functions_admin.php b/upload/includes/functions_admin.php index 6a4b0a793..1c4319d32 100644 --- a/upload/includes/functions_admin.php +++ b/upload/includes/functions_admin.php @@ -277,6 +277,13 @@ function topic_delete ($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pr GROUP BY p.poster_id "); + // Get array for atom update + $atom_csv = array(); + foreach (DB()->fetch_rowset('SELECT user_id FROM '.$tmp_user_posts) as $at) + { + $atom_csv[] = $at['user_id']; + } + DB()->query(" UPDATE $tmp_user_posts tmp, ". BB_USERS ." u @@ -384,6 +391,12 @@ function topic_delete ($mode_or_topic_id, $forum_id = null, $prune_time = 0, $pr // Sync sync('forum', array_keys($sync_forums)); + // Update atom feed + foreach ($atom_csv as $atom) + { + update_atom('user', $atom); + } + DB()->query("DROP TEMPORARY TABLE $tmp_delete_topics"); return $deleted_topics_count; @@ -663,6 +676,16 @@ function post_delete ($mode_or_post_id, $user_id = null, $exclude_first = true) sync('forum', array_keys($sync_forums)); sync('user_posts', $sync_users); + // Update atom feed + foreach ($sync_topics as $atom_topic) + { + update_atom('topic', $atom_topic); + } + foreach ($sync_users as $atom_user) + { + update_atom('user', $atom_user); + } + DB()->query("DROP TEMPORARY TABLE $tmp_delete_posts"); return $deleted_posts_count; diff --git a/upload/posting.php b/upload/posting.php index a67293946..62956849f 100644 --- a/upload/posting.php +++ b/upload/posting.php @@ -444,8 +444,8 @@ elseif ( ($submit || $confirm) && !$topic_has_new_posts ) } } - // Update user atom feed - update_atom($topic_id); + // Update atom feed + update_atom('topic', $topic_id); if ($mode == 'reply' && $post_info['topic_status'] == TOPIC_LOCKED) {