mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
A few changes to topic moving. TOPIC_MOVE constant gets set to the topic_status field so that moved topics don't 'stick' at the top of viewforum. Also, added topic_moved_id field to store the ID that the topic moves to.
git-svn-id: file:///svn/phpbb/trunk@877 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
bd8652f186
commit
e2710a5101
5 changed files with 325 additions and 388 deletions
|
@ -416,6 +416,7 @@ CREATE TABLE phpbb_topics (
|
|||
topic_status tinyint(3) DEFAULT '0' NOT NULL,
|
||||
topic_type tinyint(3) DEFAULT '0' NOT NULL,
|
||||
topic_last_post_id int(11) DEFAULT '0' NOT NULL,
|
||||
topic_moved_id int(10),
|
||||
topic_notify tinyint(1) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (topic_id),
|
||||
KEY forum_id (forum_id),
|
||||
|
|
|
@ -412,6 +412,7 @@ CREATE TABLE phpbb_topics (
|
|||
topic_type int2 DEFAULT '0' NOT NULL,
|
||||
topic_notify int2 DEFAULT '0',
|
||||
topic_last_post_id int4 DEFAULT '0' NOT NULL,
|
||||
topic_moved_id int4,
|
||||
CONSTRAINT phpbb_topics_pkey PRIMARY KEY (topic_id)
|
||||
);
|
||||
CREATE INDEX _phpbb_topics_index ON phpbb_topics (forum_id, topic_id);
|
||||
|
|
|
@ -40,18 +40,20 @@ define(ADMIN, 1);
|
|||
define(FORUM_UNLOCKED, 0);
|
||||
define(FORUM_LOCKED, 1);
|
||||
|
||||
// Topic state
|
||||
// Topic status
|
||||
define(TOPIC_UNLOCKED, 0);
|
||||
define(TOPIC_LOCKED, 1);
|
||||
define(TOPIC_MOVED, 2);
|
||||
define(TOPIC_WATCH_NOTIFIED, 1);
|
||||
define(TOPIC_WATCH_UN_NOTIFIED, 0);
|
||||
|
||||
|
||||
// Topic types
|
||||
define(POST_NORMAL, 0);
|
||||
define(POST_STICKY, 1);
|
||||
define(POST_ANNOUNCE, 2);
|
||||
define(POST_GLOBAL_ANNOUNCE, 3);
|
||||
define(TOPIC_MOVED,4);
|
||||
|
||||
|
||||
// SQL codes
|
||||
define(BEGIN_TRANSACTION, 1);
|
||||
|
|
323
phpBB/modcp.php
323
phpBB/modcp.php
|
@ -287,203 +287,136 @@ switch($mode)
|
|||
break;
|
||||
|
||||
case 'move':
|
||||
if($confirm)
|
||||
{
|
||||
$new_forum = $HTTP_POST_VARS['new_forum'];
|
||||
$old_forum = $HTTP_POST_VARS[POST_FORUM_URL];
|
||||
if($HTTP_POST_VARS['preform_op'])
|
||||
{
|
||||
$topics = $HTTP_POST_VARS['preform_op'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
|
||||
}
|
||||
for($x = 0; $x < count($topics); $x++)
|
||||
{
|
||||
if($x != 0)
|
||||
{
|
||||
$sql_clause .= ' OR ';
|
||||
}
|
||||
$sql_clause .= 'topic_id = '.$topics[$x];
|
||||
$sql_select = 'SELECT
|
||||
topic_title,
|
||||
topic_poster,
|
||||
topic_time
|
||||
FROM '.
|
||||
TOPICS_TABLE." WHERE
|
||||
topic_id = $topics[$x]";
|
||||
if(!$result = $db->sql_query($sql_select))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not select from topic table!", "Error", __LINE__, __FILE__
|
||||
, $sql_select);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row = $db->sql_fetchrowset($result);
|
||||
$ttitle = $row[0]['topic_title'];
|
||||
$tpost = $row[0]['topic_poster'];
|
||||
$ttime = $row[0]['topic_time'];
|
||||
$sql_insert = 'INSERT INTO '.TOPICS_TABLE."
|
||||
(forum_id,topic_title,topic_poster,topic_time,topic_status,topic_type)
|
||||
VALUES
|
||||
($old_forum,'$ttitle','$tpost',$ttime,$topics[$x],".TOPIC_MOVED.')';
|
||||
if(!$result = $db->sql_query($sql_insert))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not insert into topics table!", "Error", __LINE__,
|
||||
__FILE__, $sql_insert);
|
||||
}
|
||||
$newtopic_id = $db->sql_nextid();
|
||||
$sql_insert = 'INSERT INTO '.POSTS_TABLE."
|
||||
(topic_id,forum_id,poster_id,post_time)
|
||||
VALUES
|
||||
($newtopic_id,$old_forum,$tpost,$ttime)";
|
||||
if(!$result = $db->sql_query($sql_insert))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not insert into posts table!", "Error", __LINE__,
|
||||
__FILE__, $sql_insert);
|
||||
}
|
||||
//Finally, update the last_post_id column to reflect the new post just inserted
|
||||
$newpost_id = $db->sql_nextid();
|
||||
$sql = 'UPDATE '.TOPICS_TABLE." SET topic_last_post_id = $newpost_id WHERE topic_id = $newtopic_id";
|
||||
if(!$result = $db->sql_query($sql))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update the topics table!", "Error", __LINE__,
|
||||
__FILE__, $sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($confirm)
|
||||
{
|
||||
$new_forum = $HTTP_POST_VARS['new_forum'];
|
||||
$old_forum = $HTTP_POST_VARS[POST_FORUM_URL];
|
||||
if($HTTP_POST_VARS['preform_op'])
|
||||
{
|
||||
$topics = $HTTP_POST_VARS['preform_op'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
|
||||
}
|
||||
for($x = 0; $x < count($topics); $x++)
|
||||
{
|
||||
if($x != 0)
|
||||
{
|
||||
$sql_clause .= ' OR ';
|
||||
}
|
||||
$sql_clause .= 'topic_id = '.$topics[$x];
|
||||
$sql_select = 'SELECT
|
||||
topic_title,
|
||||
topic_poster,
|
||||
topic_time
|
||||
FROM '.
|
||||
TOPICS_TABLE." WHERE
|
||||
topic_id = $topics[$x]";
|
||||
if(!$result = $db->sql_query($sql_select))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not select from topic table!", "Error", __LINE__, __FILE__, $sql_select);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row = $db->sql_fetchrowset($result);
|
||||
$ttitle = $row[0]['topic_title'];
|
||||
$tpost = $row[0]['topic_poster'];
|
||||
$ttime = $row[0]['topic_time'];
|
||||
$sql_insert = 'INSERT INTO '.TOPICS_TABLE."
|
||||
(forum_id, topic_title, topic_poster, topic_time, topic_moved_id, topic_status)
|
||||
VALUES
|
||||
($old_forum, '$ttitle', '$tpost', $ttime, $topics[$x], ".TOPIC_MOVED.')';
|
||||
if(!$result = $db->sql_query($sql_insert))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not insert into topics table!", "Error", __LINE__, __FILE__, $sql_insert);
|
||||
}
|
||||
$newtopic_id = $db->sql_nextid();
|
||||
$sql_insert = 'INSERT INTO '.POSTS_TABLE."
|
||||
(topic_id,forum_id,poster_id,post_time)
|
||||
VALUES
|
||||
($newtopic_id,$old_forum,$tpost,$ttime)";
|
||||
if(!$result = $db->sql_query($sql_insert))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not insert into posts table!", "Error", __LINE__, __FILE__, $sql_insert);
|
||||
}
|
||||
|
||||
$sql_replies = 'SELECT SUM(topic_replies) AS total_posts FROM '.TOPICS_TABLE.' WHERE '.$sql_clause;
|
||||
if(!$result = $db->sql_query($sql_replies))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not sum topic replies in topics table!", "Error", __LINE__, __FILE__, $sql_replies);
|
||||
}
|
||||
else
|
||||
{
|
||||
$posts_row = $db->sql_fetchrowset($result);
|
||||
$posts = $posts_row[0]['total_posts'] + count($topics);
|
||||
}
|
||||
//Finally, update the last_post_id column to reflect the new post just inserted
|
||||
$newpost_id = $db->sql_nextid();
|
||||
$sql = 'UPDATE '.TOPICS_TABLE." SET topic_last_post_id = $newpost_id WHERE topic_id = $newtopic_id";
|
||||
if(!$result = $db->sql_query($sql))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update the topics table!", "Error", __LINE__, __FILE__, $sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql_post = 'UPDATE '.POSTS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
|
||||
$sql_topic = 'UPDATE '.TOPICS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
|
||||
if(!$result = $db->sql_query($sql_post))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update posts table!", "Error", __LINE__, __FILE__, $sql_post);
|
||||
}
|
||||
else if(!$result = $db->sql_query($sql_topic))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql_topic);
|
||||
}
|
||||
if(SQL_LAYER != 'mysql')
|
||||
{
|
||||
$sql_forums_new = 'UPDATE '.FORUMS_TABLE." SET
|
||||
forum_posts = forum_posts + $posts,
|
||||
forum_topics = forum_topics + ".count($topics).",
|
||||
forum_last_post_id =
|
||||
(select max(post_id) FROM ".POSTS_TABLE."
|
||||
WHERE forum_id = $new_forum)
|
||||
WHERE forum_id = ".$new_forum;
|
||||
$sql_forums_old = 'UPDATE '.FORUMS_TABLE." SET
|
||||
forum_posts = forum_posts - $posts + ".count($topics).",
|
||||
forum_last_post_id =
|
||||
(select max(post_id) FROM ".POSTS_TABLE."
|
||||
WHERE forum_id = $old_forum)
|
||||
WHERE forum_id = ".$old_forum;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql_lastpost = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $new_forum";
|
||||
if(!$result = $db->sql_query($sql_lastpost))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not get last post id from posts table", "Error", __LINE__,__FILE__, $sql_lastpost);
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_post_row = $db->sql_fetchrowset($result);
|
||||
$last_post_new = $last_post_row[0]['last_post'];
|
||||
if($last_post_new == "")
|
||||
{
|
||||
$last_post_new = "''";
|
||||
}
|
||||
}
|
||||
$sql_lastpost = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $old_forum";
|
||||
if(!$result = $db->sql_query($sql_lastpost))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not get last post id from posts table", "Error", __LINE__,__FILE__, $sql_lastpost);
|
||||
}
|
||||
else
|
||||
{
|
||||
$last_post_row = $db->sql_fetchrowset($result);
|
||||
$last_post_old = $last_post_row[0]['last_post'];
|
||||
if($last_post_old == "")
|
||||
{
|
||||
$last_post_old = "''";
|
||||
}
|
||||
}
|
||||
$sql_forums_new = 'UPDATE '.FORUMS_TABLE." SET
|
||||
forum_posts = forum_posts + $posts,
|
||||
forum_topics = forum_topics + ".count($topics).",
|
||||
forum_last_post_id = $last_post_new
|
||||
WHERE forum_id = $new_forum";
|
||||
$sql_forums_old = 'UPDATE '.FORUMS_TABLE." SET
|
||||
forum_posts = forum_posts - $posts + ".count($topics).",
|
||||
forum_last_post_id = $last_post_old
|
||||
WHERE forum_id = $old_forum";
|
||||
}
|
||||
if(!$result = $db->sql_query($sql_forums_new))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update forums table!", "Error", __LINE__, __FILE__, $sql_forums_new);
|
||||
}
|
||||
else if(!$result = $db->sql_query($sql_forums_old))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update forums table!", "Error", __LINE__, __FILE__, $sql_forums_old);
|
||||
}
|
||||
else
|
||||
{
|
||||
if($quick_op)
|
||||
{
|
||||
$next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id";
|
||||
$return_message = $lang['to_return_topic'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$next_page = "modcp.$phpEx?".POST_FORUM_URL."=$forum_id";
|
||||
$return_message = $lang['Return_to_modcp'];
|
||||
}
|
||||
$msg = $lang['Topics_Moved'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click']. " " . $lang['Here'] ."</a> " . $return_message;
|
||||
message_die(GENERAL_MESSAGE, $msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'"><input type="hidden" name="'.POST_FORUM_URL.'" value="'.$forum_id.'"><input type="hidden" name="quick_op" value="'.$quick_op.'">';
|
||||
$hidden_fields .= $lang['New_forum'] . ': ' . make_forum_box('new_forum'). '</select><br><br>';
|
||||
if($HTTP_POST_VARS['preform_op'])
|
||||
{
|
||||
$topics = $HTTP_POST_VARS['preform_op'];
|
||||
for($x = 0; $x < count($topics); $x++)
|
||||
{
|
||||
$hidden_fields .= '<input type="hidden" name="preform_op[]" value="'.$topics[$x].'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$hidden_fields .= '<input type="hidden" name="'.POST_TOPIC_URL.'" value="'.$topic_id.'">';
|
||||
}
|
||||
$template->assign_vars( array (
|
||||
"MESSAGE_TITLE" => $lang['Confirm'],
|
||||
"MESSAGE_TEXT" => $lang['Confirm_move_topic'],
|
||||
"L_YES" => $lang['Yes'],
|
||||
"L_NO" => $lang['No'],
|
||||
"S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
|
||||
"S_HIDDEN_FIELDS" => $hidden_fields
|
||||
)
|
||||
);
|
||||
$template->pparse("confirm");
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
}
|
||||
break;
|
||||
$sql_replies = 'SELECT SUM(topic_replies) AS total_posts FROM '.TOPICS_TABLE.' WHERE '.$sql_clause;
|
||||
if(!$result = $db->sql_query($sql_replies))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not sum topic replies in topics table!", "Error", __LINE__, __FILE__, $sql_replies);
|
||||
}
|
||||
else
|
||||
{
|
||||
$posts_row = $db->sql_fetchrowset($result);
|
||||
$posts = $posts_row[0]['total_posts'] + count($topics);
|
||||
}
|
||||
|
||||
$sql_post = 'UPDATE '.POSTS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
|
||||
$sql_topic = 'UPDATE '.TOPICS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
|
||||
if(!$result = $db->sql_query($sql_post))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update posts table!", "Error", __LINE__, __FILE__, $sql_post);
|
||||
}
|
||||
else if(!$result = $db->sql_query($sql_topic))
|
||||
{
|
||||
message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql_topic);
|
||||
}
|
||||
|
||||
// Sync the forum indexes
|
||||
sync("forum", $new_forum);
|
||||
sync("forum", $old_forum);
|
||||
|
||||
|
||||
if($quick_op)
|
||||
{
|
||||
$next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id";
|
||||
$return_message = $lang['to_return_topic'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$next_page = "modcp.$phpEx?".POST_FORUM_URL."=$forum_id";
|
||||
$return_message = $lang['Return_to_modcp'];
|
||||
}
|
||||
$msg = $lang['Topics_Moved'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click']. " " . $lang['Here'] ."</a> " . $return_message;
|
||||
message_die(GENERAL_MESSAGE, $msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
$hidden_fields = '<input type="hidden" name="mode" value="'.$mode.'"><input type="hidden" name="'.POST_FORUM_URL.'" value="'.$forum_id.'"><input type="hidden" name="quick_op" value="'.$quick_op.'">';
|
||||
$hidden_fields .= $lang['New_forum'] . ': ' . make_forum_box('new_forum'). '</select><br><br>';
|
||||
if($HTTP_POST_VARS['preform_op'])
|
||||
{
|
||||
$topics = $HTTP_POST_VARS['preform_op'];
|
||||
for($x = 0; $x < count($topics); $x++)
|
||||
{
|
||||
$hidden_fields .= '<input type="hidden" name="preform_op[]" value="'.$topics[$x].'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$hidden_fields .= '<input type="hidden" name="'.POST_TOPIC_URL.'" value="'.$topic_id.'">';
|
||||
}
|
||||
$template->assign_vars(array("MESSAGE_TITLE" => $lang['Confirm'],
|
||||
"MESSAGE_TEXT" => $lang['Confirm_move_topic'],
|
||||
"L_YES" => $lang['Yes'],
|
||||
"L_NO" => $lang['No'],
|
||||
"S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
|
||||
"S_HIDDEN_FIELDS" => $hidden_fields));
|
||||
$template->pparse("confirm");
|
||||
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
if($confirm)
|
||||
|
|
|
@ -380,18 +380,12 @@ if($total_topics || $total_announcements)
|
|||
{
|
||||
$topic_type = $lang['Topic_Sticky'] . " ";
|
||||
}
|
||||
else if($topic_type == TOPIC_MOVED)
|
||||
{
|
||||
$topic_type = $lang['Topic_Moved'] . " ";
|
||||
//New topic is hidden in topic_status
|
||||
$topic_rowset[$i]['topic_id'] = $topic_rowset[$i]['topic_status'];
|
||||
$topic_rowset[$i]['topic_status'] = TOPIC_UNLOCKED;
|
||||
}
|
||||
else
|
||||
{
|
||||
$topic_type = "";
|
||||
}
|
||||
|
||||
|
||||
$topic_id = $topic_rowset[$i]['topic_id'];
|
||||
|
||||
$replies = $topic_rowset[$i]['topic_replies'];
|
||||
|
@ -431,6 +425,12 @@ if($total_topics || $total_announcements)
|
|||
{
|
||||
$folder_image = "<img src=\"" . $images['folder_locked'] . "\" alt=\"" . $lang['Topic_locked'] . "\" />";
|
||||
}
|
||||
else if($topic_rowset[$i]['topic_status'] == TOPIC_MOVED)
|
||||
{
|
||||
$topic_type = $lang['Topic_Moved'] . " ";
|
||||
$topic_id = $topic_rowset[$i]['topic_moved_id'];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue