Split beyond this post works

git-svn-id: file:///svn/phpbb/trunk@654 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
James Atkinson 2001-07-13 18:22:00 +00:00
parent 66e3d18e3a
commit 769b9673af

View file

@ -425,16 +425,9 @@ switch($mode)
case 'split': case 'split':
if($HTTP_POST_VARS['split']) if($HTTP_POST_VARS['split'])
{ {
if($HTTP_POST_VARS['split_type'] == "split_after")
{
// Split off posts after the selected one
}
else if($HTTP_POST_VARS['split_type'] == "split")
{
$posts = $HTTP_POST_VARS['preform_op']; $posts = $HTTP_POST_VARS['preform_op'];
$sql = "SELECT poster_id, topic_id FROM ".POSTS_TABLE." WHERE post_id = ".$posts[0]; $sql = "SELECT poster_id, topic_id, post_time FROM ".POSTS_TABLE." WHERE post_id = ".$posts[0];
if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION))
{ {
message_die(GENERAL_ERROR, "Could not get post information", "Error", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not get post information", "Error", __LINE__, __FILE__, $sql);
@ -443,8 +436,9 @@ switch($mode)
$post_rowset = $db->sql_fetchrowset($result); $post_rowset = $db->sql_fetchrowset($result);
$first_poster = $post_rowset[0]['poster_id']; $first_poster = $post_rowset[0]['poster_id'];
$topic_id = $post_rowset[0]['topic_id']; $topic_id = $post_rowset[0]['topic_id'];
$post_time = $post_rowset[0]['post_time'];
$subject = trim(strip_tags(htmlspecialchars(stripslashes($HTTP_POST_VARS['subject'])))); $subject = trim(strip_tags(htmlspecialchars(addslashes($HTTP_POST_VARS['subject']))));
if(empty($subject)) if(empty($subject))
{ {
message_die(GENERAL_ERROR, $lang['Empty_subject'], $lang['Error'], __LINE__, __FILE__); message_die(GENERAL_ERROR, $lang['Empty_subject'], $lang['Error'], __LINE__, __FILE__);
@ -461,7 +455,8 @@ switch($mode)
} }
$new_topic_id = $db->sql_nextid(); $new_topic_id = $db->sql_nextid();
if($HTTP_POST_VARS['split_type'] == "split")
{
$sql = "UPDATE ".POSTS_TABLE." SET topic_id = $new_topic_id WHERE "; $sql = "UPDATE ".POSTS_TABLE." SET topic_id = $new_topic_id WHERE ";
for($x = 0; $x < count($posts); $x++) for($x = 0; $x < count($posts); $x++)
{ {
@ -472,7 +467,11 @@ switch($mode)
$sql .= "post_id = ".$posts[$x]; $sql .= "post_id = ".$posts[$x];
$last_post_id = $posts[$x]; $last_post_id = $posts[$x];
} }
}
else if($HTTP_POST_VARS['split_type'] == "split_after")
{
$sql = "UPDATE ".POSTS_TABLE." SET topic_id = $new_topic_id WHERE post_time >= $post_time AND topic_id = $topic_id";
}
if(!$result = $db->sql_query($sql, END_TRANSACTION)) if(!$result = $db->sql_query($sql, END_TRANSACTION))
{ {
@ -480,14 +479,7 @@ switch($mode)
} }
else else
{ {
$sql = "UPDATE ".TOPICS_TABLE." SET topic_last_post_id = $last_post_id, topic_replies = ". ($x - 1) ." WHERE topic_id = $new_topic_id"; sync("topic", $new_topic_id);
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not update topics table", $lang['Error'], __LINE__, __FILE__, $sql);
}
else
{
sync("topic", $topic_id); sync("topic", $topic_id);
sync("forum", $forum_id); sync("forum", $forum_id);
$next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$new_topic_id"; $next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$new_topic_id";
@ -495,8 +487,6 @@ switch($mode)
message_die(GENERAL_MESSAGE, $lang['Topic_split'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $return_message); message_die(GENERAL_MESSAGE, $lang['Topic_split'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $return_message);
} }
} }
}
}
else else
{ {
$topic_id = ($HTTP_POST_VARS[POST_TOPIC_URL]) ? $HTTP_POST_VARS[POST_TOPIC_URL] : $HTTP_GET_VARS[POST_TOPIC_URL]; $topic_id = ($HTTP_POST_VARS[POST_TOPIC_URL]) ? $HTTP_POST_VARS[POST_TOPIC_URL] : $HTTP_GET_VARS[POST_TOPIC_URL];