mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
[ticket/8610] Update Bookmarks and Subscriptions when splitting topics
Update bookmarks and subscriptions to add bookmarks/subscriptions to the new topic when using the split_topic function PHPBB3-8610
This commit is contained in:
parent
05d7decdd3
commit
5a88bd1bf1
@ -98,6 +98,9 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
|
||||
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
|
||||
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
|
||||
|
||||
$base_url = $url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : '');
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
|
||||
|
||||
$template->assign_vars(array(
|
||||
'ACTION' => $action,
|
||||
'FORUM_NAME' => $forum_info['forum_name'],
|
||||
@ -425,10 +428,15 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
|
||||
// If the topic no longer exist, we will update the bookmarks table.
|
||||
// To not let it error out on users who bookmarked both topics, we just return on an error...
|
||||
$db->sql_return_on_error(true);
|
||||
$db->sql_query('UPDATE ' . BOOKMARKS_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
||||
$sql = 'UPDATE ' . BOOKMARKS_TABLE . '
|
||||
SET topic_id = ' . (int) $to_topic_id . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$db->sql_query('DELETE FROM ' . BOOKMARKS_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
|
||||
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
|
||||
$db->sql_query($sql);
|
||||
|
||||
// Link to the new topic
|
||||
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&t=' . $to_topic_id) . '">', '</a>');
|
||||
|
@ -307,6 +307,12 @@ function mcp_topic_view($id, $mode, $action)
|
||||
'post_ids' => $post_id_list,
|
||||
));
|
||||
|
||||
$base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir");
|
||||
if ($posts_per_page)
|
||||
{
|
||||
phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $posts_per_page, $start);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'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']),
|
||||
@ -517,6 +523,47 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
|
||||
WHERE post_id = {$post_id_list[0]}";
|
||||
$db->sql_query($sql);
|
||||
|
||||
$sql = 'SELECT user_id, notify_status
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary[] = array(
|
||||
'topic_id' => (int) $to_topic_id,
|
||||
'user_id' => (int) $row['user_id'],
|
||||
'notify_status' => (int) $row['notify_status'],
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
|
||||
}
|
||||
|
||||
$sql = 'SELECT user_id
|
||||
FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE topic_id = ' . $topic_id;
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql_ary = array();
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$sql_ary[] = array(
|
||||
'topic_id' => (int) $to_topic_id,
|
||||
'user_id' => (int) $row['user_id'],
|
||||
);
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
if (sizeof($sql_ary))
|
||||
{
|
||||
$db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
|
||||
}
|
||||
|
||||
$success_msg = 'TOPIC_SPLIT_SUCCESS';
|
||||
|
||||
// Update forum statistics
|
||||
@ -630,10 +677,15 @@ function merge_posts($topic_id, $to_topic_id)
|
||||
// If the topic no longer exist, we will update the bookmarks table.
|
||||
// To not let it error out on users who bookmarked both topics, we just return on an error...
|
||||
$db->sql_return_on_error(true);
|
||||
$db->sql_query('UPDATE ' . BOOKMARKS_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id);
|
||||
$sql = 'UPDATE ' . BOOKMARKS_TABLE . '
|
||||
SET topic_id = ' . (int) $to_topic_id . '
|
||||
WHERE topic_id = ' . (int) $topic_id;
|
||||
$db->sql_query($sql);
|
||||
$db->sql_return_on_error(false);
|
||||
|
||||
$db->sql_query('DELETE FROM ' . BOOKMARKS_TABLE . ' WHERE topic_id = ' . (int) $topic_id);
|
||||
$sql = 'DELETE FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE topic_id = ' . (int) $topic_id;
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
|
||||
// Link to the new topic
|
||||
|
Loading…
x
Reference in New Issue
Block a user