diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 50cd5af865..5608b2f252 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -503,4 +503,110 @@ function validate_username($username) return(TRUE); } + +function sync($type, $id) +{ + global $db; + + switch($type) + { + case 'forum': + $sql = "SELECT max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get post ID", "Error", __LINE__, __FILE__, $sql); + } + if($rowset = $db->sql_fetchrowset($result)) + { + $last_post = $rowset[0]['last_post']; + } + + $sql = "SELECT count(post_id) AS total FROM ".POSTS_TABLE." WHERE forum_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get post count", "Error", __LINE__, __FILE__, $sql); + } + if($rowset = $db->sql_fetchrowset($result)) + { + $total_posts = $rowset[0]['total']; + } + + $sql = "SELECT count(topic_id) AS total FROM ".TOPICS_TABLE." WHERE forum_id = $id"; + if(!$result = $db->sql_query($sql, $db)) + { + message_die(GENERAL_ERROR, "Could not get topic count", "Error", __LINE__, __FILE__, $sql); + } + if($rowset = $db->sql_fetchrowset($result)) + { + $total_topics = $rowset[0]['total']; + } + + $sql = "UPDATE ".FORUMS_TABLE." SET forum_last_post_id = '$last_post', forum_posts = $total_posts, forum_topics = $total_topics WHERE forum_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not update forum $id", "Error", __LINE__, __FILE__, $sql); + } + break; + + case 'topic': + $sql = "SELECT max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE topic_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get post ID", "Error", __LINE__, __FILE__, $sql); + } + if($row = $db->sql_fetchrowset($result)) + { + $last_post = $row[0]["last_post"]; + } + + $sql = "SELECT count(post_id) AS total FROM ".POSTS_TABLE." WHERE topic_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get post count", "Error", __LINE__, __FILE__, $sql); + } + if($row = $db->sql_fetchrowset($result)) + { + $total_posts = $row[0]["total"]; + } + $total_posts -= 1; + $sql = "UPDATE ".TOPICS_TABLE." SET topic_replies = $total_posts, topic_last_post_id = $last_post WHERE topic_id = $id"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not update topic $id", "Error", __LINE__, __FILE__, $sql); + } + break; + + case 'all forums': + $sql = "SELECT forum_id FROM ".FORUMS_TABLE; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get forum IDs", "Error", __LINE__, __FILE__, $sql); + } + $rowset = $db->sql_fetchrowset($result); + $count = $db->sql_numrows($result); + for($i = 0; $i < $count; $i++) + { + $id = $row[$i]['forum_id']; + sync($db, $id, "forum"); + } + break; + case 'all topics': + $sql = "SELECT topic_id FROM topics"; + if(!$result = $db->sql_query($sql)) + { + message_die(GENERAL_ERROR, "Could not get topic ID's", "Error", __LINE__, __FILE__, $sql); + } + $rowset = $db->sql_fetchrowset($result); + $count = $db->sql_numrows($result); + for($i = 0; $i < $count; $i++) + { + $id = $row[$i]['topic_id']; + sync($db, $id, "topic"); + } + break; + } + return(TRUE); +} + + ?> \ No newline at end of file diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index bb3d3bdcf2..faacb921a6 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -110,6 +110,8 @@ $lang['AIM'] = "AIM Address"; $lang['MSNM'] = "MSN Messenger"; $lang['YIM'] = "Yahoo Messenger"; +$lang['Error'] = "Error"; + // // Global Header strings // @@ -498,6 +500,8 @@ $lang['Confirm_unlock_topic'] = "Are you sure you want to unlock the selected to $lang['Confirm_move_topic'] = "Are you sure you want to move the selected topic(s)?"; $lang['Split_posts'] = "Split Posts"; $lang['Split_after'] = "Split Posts Beyond Selected"; +$lang['Topic_split'] = "The selected topic has been split successfully"; + // // Old format ... _DON'T_add_any_ new entries here!! diff --git a/phpBB/modcp.php b/phpBB/modcp.php index 2869545c43..303ad9e5d4 100644 --- a/phpBB/modcp.php +++ b/phpBB/modcp.php @@ -434,7 +434,7 @@ switch($mode) $posts = $HTTP_POST_VARS['preform_op']; - $sql = "SELECT poster_id FROM ".POSTS_TABLE." WHERE post_id = ".$posts[0]; + $sql = "SELECT poster_id, topic_id FROM ".POSTS_TABLE." WHERE post_id = ".$posts[0]; if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) { message_die(GENERAL_ERROR, "Could not get post information", "Error", __LINE__, __FILE__, $sql); @@ -442,7 +442,8 @@ switch($mode) $post_rowset = $db->sql_fetchrowset($result); $first_poster = $post_rowset[0]['poster_id']; - + $topic_id = $post_rowset[0]['topic_id']; + $subject = trim(strip_tags(htmlspecialchars(stripslashes($HTTP_POST_VARS['subject'])))); if(empty($subject)) { @@ -488,11 +489,11 @@ switch($mode) else { sync("topic", $topic_id); - if(!$result = $db->sql_query($sql - - $next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$new_topic_id"; - $return_message = $lang['to_return_topic']; - message_die(GENERAL_MESSAGE, $lang['Topic_split'] . "
" . "". $lang['Click'] . " " . $lang['Here'] ." " . $return_message); + sync("forum", $forum_id); + $next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$new_topic_id"; + $return_message = $lang['to_return_topic']; + message_die(GENERAL_MESSAGE, $lang['Topic_split'] . "
" . "". $lang['Click'] . " " . $lang['Here'] ." " . $return_message); + } } } } diff --git a/phpBB/templates/PSO/split_body.tpl b/phpBB/templates/PSO/split_body.tpl index a8470cb8fd..824a376cce 100644 --- a/phpBB/templates/PSO/split_body.tpl +++ b/phpBB/templates/PSO/split_body.tpl @@ -32,7 +32,7 @@ - +
Post image icon{L_POSTED}: {postrow.POST_DATE}     Post Subject: {postrow.POST_SUBJECT}
Post image icon{L_POSTED}: {postrow.POST_DATE}     Post Subject: {postrow.POST_SUBJECT}
{postrow.MESSAGE}