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:
James Atkinson 2001-08-14 20:43:56 +00:00
parent bd8652f186
commit e2710a5101
5 changed files with 325 additions and 388 deletions

View file

@ -43,7 +43,7 @@ CREATE TABLE phpbb_user_group (
DROP TABLE IF EXISTS phpbb_groups; DROP TABLE IF EXISTS phpbb_groups;
CREATE TABLE phpbb_groups ( CREATE TABLE phpbb_groups (
group_id int(11) NOT NULL auto_increment, group_id int(11) NOT NULL auto_increment,
group_type tinyint(4) DEFAULT '1' NOT NULL, group_type tinyint(4) DEFAULT '1' NOT NULL,
group_name varchar(40) NOT NULL, group_name varchar(40) NOT NULL,
group_description varchar(255) NOT NULL, group_description varchar(255) NOT NULL,
group_moderator int(11) DEFAULT '0' NOT NULL, group_moderator int(11) DEFAULT '0' NOT NULL,
@ -85,46 +85,46 @@ CREATE TABLE phpbb_categories (
DROP TABLE IF EXISTS phpbb_config; DROP TABLE IF EXISTS phpbb_config;
CREATE TABLE phpbb_config ( CREATE TABLE phpbb_config (
config_id int(10) NOT NULL auto_increment, config_id int(10) NOT NULL auto_increment,
board_disable tinyint(1) DEFAULT '0' NOT NULL, board_disable tinyint(1) DEFAULT '0' NOT NULL,
board_startdate int(11), board_startdate int(11),
sitename varchar(100), sitename varchar(100),
cookie_name char(20), cookie_name char(20),
cookie_path char(25), cookie_path char(25),
cookie_domain char(50), cookie_domain char(50),
cookie_secure tinyint(1), cookie_secure tinyint(1),
session_length int(11), session_length int(11),
allow_html tinyint(1), allow_html tinyint(1),
allow_html_tags char(255) DEFAULT 'b,u,i,pre,font color' NOT NULL, allow_html_tags char(255) DEFAULT 'b,u,i,pre,font color' NOT NULL,
allow_bbcode tinyint(1), allow_bbcode tinyint(1),
allow_smilies tinyint(1), allow_smilies tinyint(1),
allow_sig tinyint(1), allow_sig tinyint(1),
allow_namechange tinyint(1), allow_namechange tinyint(1),
allow_theme_create tinyint(1), allow_theme_create tinyint(1),
allow_avatar_local tinyint(1) DEFAULT '0' NOT NULL, allow_avatar_local tinyint(1) DEFAULT '0' NOT NULL,
allow_avatar_remote tinyint(1) DEFAULT '0' NOT NULL, allow_avatar_remote tinyint(1) DEFAULT '0' NOT NULL,
allow_avatar_upload tinyint(1) DEFAULT '0' NOT NULL, allow_avatar_upload tinyint(1) DEFAULT '0' NOT NULL,
override_themes tinyint(3), override_themes tinyint(3),
posts_per_page int(10), posts_per_page int(10),
topics_per_page int(10), topics_per_page int(10),
hot_threshold int(10), hot_threshold int(10),
email_sig varchar(255), email_sig varchar(255),
email_from varchar(100), email_from varchar(100),
smtp_delivery smallint(1) DEFAULT '0' NOT NULL, smtp_delivery smallint(1) DEFAULT '0' NOT NULL,
smtp_host varchar(50), smtp_host varchar(50),
require_activation tinyint(1) DEFAULT '0' NOT NULL, require_activation tinyint(1) DEFAULT '0' NOT NULL,
flood_interval int(4) NOT NULL, flood_interval int(4) NOT NULL,
avatar_filesize int(11) DEFAULT '6144' NOT NULL, avatar_filesize int(11) DEFAULT '6144' NOT NULL,
avatar_max_width smallint(6) DEFAULT '70' NOT NULL, avatar_max_width smallint(6) DEFAULT '70' NOT NULL,
avatar_max_height smallint(6) DEFAULT '70' NOT NULL, avatar_max_height smallint(6) DEFAULT '70' NOT NULL,
avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL, avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL,
smilies_path char(100) DEFAULT 'images/smiles' NOT NULL, smilies_path char(100) DEFAULT 'images/smiles' NOT NULL,
default_theme int(11) DEFAULT '1' NOT NULL, default_theme int(11) DEFAULT '1' NOT NULL,
default_lang varchar(255), default_lang varchar(255),
default_dateformat varchar(14) DEFAULT 'd M Y H:i' NOT NULL, default_dateformat varchar(14) DEFAULT 'd M Y H:i' NOT NULL,
system_timezone int(11) DEFAULT '0' NOT NULL, system_timezone int(11) DEFAULT '0' NOT NULL,
sys_template varchar(100) DEFAULT 'Default' NOT NULL, sys_template varchar(100) DEFAULT 'Default' NOT NULL,
prune_enable tinyint(1) DEFAULT '1' NOT NULL, prune_enable tinyint(1) DEFAULT '1' NOT NULL,
gzip_compress tinyint(1) DEFAULT '0' NOT NULL, gzip_compress tinyint(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (config_id) PRIMARY KEY (config_id)
); );
@ -164,7 +164,7 @@ CREATE TABLE phpbb_forums (
cat_id int(10) NOT NULL, cat_id int(10) NOT NULL,
forum_name varchar(150), forum_name varchar(150),
forum_desc text, forum_desc text,
forum_status tinyint(4) DEFAULT '0' NOT NULL, forum_status tinyint(4) DEFAULT '0' NOT NULL,
forum_order int(11) DEFAULT '1' NOT NULL, forum_order int(11) DEFAULT '1' NOT NULL,
forum_posts int(11) DEFAULT '0' NOT NULL, forum_posts int(11) DEFAULT '0' NOT NULL,
forum_topics tinyint(4) DEFAULT '0' NOT NULL, forum_topics tinyint(4) DEFAULT '0' NOT NULL,
@ -201,8 +201,8 @@ CREATE TABLE phpbb_posts (
forum_id int(10) DEFAULT '0' NOT NULL, forum_id int(10) DEFAULT '0' NOT NULL,
poster_id int(10) DEFAULT '0' NOT NULL, poster_id int(10) DEFAULT '0' NOT NULL,
post_time int(10) DEFAULT '0' NOT NULL, post_time int(10) DEFAULT '0' NOT NULL,
poster_ip char(8) NOT NULL, poster_ip char(8) NOT NULL,
post_username varchar(30), post_username varchar(30),
enable_bbcode smallint(1) DEFAULT '1' NOT NULL, enable_bbcode smallint(1) DEFAULT '1' NOT NULL,
enable_html smallint(1) DEFAULT '0' NOT NULL, enable_html smallint(1) DEFAULT '0' NOT NULL,
enable_smilies smallint(1) DEFAULT '1' NOT NULL, enable_smilies smallint(1) DEFAULT '1' NOT NULL,
@ -416,7 +416,8 @@ CREATE TABLE phpbb_topics (
topic_status tinyint(3) DEFAULT '0' NOT NULL, topic_status tinyint(3) DEFAULT '0' NOT NULL,
topic_type 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_last_post_id int(11) DEFAULT '0' NOT NULL,
topic_notify tinyint(1) DEFAULT '0' NOT NULL, topic_moved_id int(10),
topic_notify tinyint(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (topic_id), PRIMARY KEY (topic_id),
KEY forum_id (forum_id), KEY forum_id (forum_id),
KEY topic_id (topic_id) KEY topic_id (topic_id)
@ -458,11 +459,11 @@ CREATE TABLE phpbb_users (
user_attachsig tinyint(1), user_attachsig tinyint(1),
user_allowhtml tinyint(1), user_allowhtml tinyint(1),
user_allowbbcode tinyint(1), user_allowbbcode tinyint(1),
user_allowsmile tinyint(1), user_allowsmile tinyint(1),
user_allowavatar tinyint(1) DEFAULT '1' NOT NULL, user_allowavatar tinyint(1) DEFAULT '1' NOT NULL,
user_allow_pm tinyint(1) DEFAULT '1' NOT NULL, user_allow_pm tinyint(1) DEFAULT '1' NOT NULL,
user_allow_viewonline tinyint(1) DEFAULT '1' NOT NULL, user_allow_viewonline tinyint(1) DEFAULT '1' NOT NULL,
user_notify_pm tinyint(1) DEFAULT '1' NOT NULL, user_notify_pm tinyint(1) DEFAULT '1' NOT NULL,
user_regdate int(11) DEFAULT '0' NOT NULL, user_regdate int(11) DEFAULT '0' NOT NULL,
user_rank int(11) DEFAULT '0', user_rank int(11) DEFAULT '0',
user_avatar varchar(100), user_avatar varchar(100),

View file

@ -86,32 +86,32 @@ CREATE TABLE phpbb_categories (
-------------------------------------------------------- */ -------------------------------------------------------- */
CREATE TABLE phpbb_config ( CREATE TABLE phpbb_config (
config_id int2 NOT NULL, config_id int2 NOT NULL,
board_disable int2 DEFAULT '0' NOT NULL, board_disable int2 DEFAULT '0' NOT NULL,
board_startdate int4, board_startdate int4,
sitename varchar(100) NOT NULL, sitename varchar(100) NOT NULL,
cookie_name char(20), cookie_name char(20),
cookie_path char(25), cookie_path char(25),
cookie_domain char(50), cookie_domain char(50),
cookie_secure int2, cookie_secure int2,
session_length int4, session_length int4,
allow_html int2 NOT NULL, allow_html int2 NOT NULL,
allow_html_tags char(255) DEFAULT 'b,u,i,pre,font color' NOT NULL, allow_html_tags char(255) DEFAULT 'b,u,i,pre,font color' NOT NULL,
allow_bbcode int2 NOT NULL, allow_bbcode int2 NOT NULL,
allow_smilies int2 NOT NULL, allow_smilies int2 NOT NULL,
allow_sig int2 NOT NULL, allow_sig int2 NOT NULL,
allow_namechange int2 NOT NULL, allow_namechange int2 NOT NULL,
allow_theme_create int2 NOT NULL, allow_theme_create int2 NOT NULL,
allow_avatar_local int2 DEFAULT '0' NOT NULL, allow_avatar_local int2 DEFAULT '0' NOT NULL,
allow_avatar_remote int2 DEFAULT '0' NOT NULL, allow_avatar_remote int2 DEFAULT '0' NOT NULL,
allow_avatar_upload int2 DEFAULT '0' NOT NULL, allow_avatar_upload int2 DEFAULT '0' NOT NULL,
posts_per_page int2 NOT NULL, posts_per_page int2 NOT NULL,
topics_per_page int2 NOT NULL, topics_per_page int2 NOT NULL,
hot_threshold int2 NOT NULL, hot_threshold int2 NOT NULL,
email_sig varchar(255) NOT NULL, email_sig varchar(255) NOT NULL,
email_from varchar(100) NOT NULL, email_from varchar(100) NOT NULL,
smtp_delivery int2 DEFAULT '0' NOT NULL, smtp_delivery int2 DEFAULT '0' NOT NULL,
smtp_host varchar(50), smtp_host varchar(50),
require_activation int2 DEFAULT '0' NOT NULL, require_activation int2 DEFAULT '0' NOT NULL,
default_theme int4 NOT NULL, default_theme int4 NOT NULL,
default_dateformat varchar(20) NOT NULL, default_dateformat varchar(20) NOT NULL,
default_lang varchar(50) NOT NULL, default_lang varchar(50) NOT NULL,
@ -121,11 +121,11 @@ CREATE TABLE phpbb_config (
avatar_max_width int2 DEFAULT '70' NOT NULL, avatar_max_width int2 DEFAULT '70' NOT NULL,
avatar_max_height int2 DEFAULT '70' NOT NULL, avatar_max_height int2 DEFAULT '70' NOT NULL,
avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL, avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL,
smilies_patch varchar(50) DEFAULT 'images/smiles' NOT NULL, smilies_patch varchar(50) DEFAULT 'images/smiles' NOT NULL,
override_themes int2 NOT NULL, override_themes int2 NOT NULL,
flood_interval int NOT NULL, flood_interval int NOT NULL,
prune_enable int2 DEFAULT '1' NOT NULL, prune_enable int2 DEFAULT '1' NOT NULL,
gzip_compress int2 DEFAULT '0' NOT NULL, gzip_compress int2 DEFAULT '0' NOT NULL,
CONSTRAINT phpbb_config_pkey PRIMARY KEY (config_id) CONSTRAINT phpbb_config_pkey PRIMARY KEY (config_id)
); );
@ -148,7 +148,7 @@ CREATE TABLE phpbb_forums (
cat_id int4, cat_id int4,
forum_name varchar(150), forum_name varchar(150),
forum_desc text, forum_desc text,
forum_status int2 DEFAULT '0' NOT NULL, forum_status int2 DEFAULT '0' NOT NULL,
forum_order int4 DEFAULT '1' NOT NULL, forum_order int4 DEFAULT '1' NOT NULL,
forum_posts int4 DEFAULT '0' NOT NULL, forum_posts int4 DEFAULT '0' NOT NULL,
forum_topics int4 DEFAULT '0' NOT NULL, forum_topics int4 DEFAULT '0' NOT NULL,
@ -190,10 +190,10 @@ CREATE INDEX forum_id_phpbb_forum_prune_index ON phpbb_forum_prune (forum_id);
-------------------------------------------------------- */ -------------------------------------------------------- */
CREATE TABLE phpbb_groups ( CREATE TABLE phpbb_groups (
group_id int4 DEFAULT nextval('phpbb_groups_id_seq'::text) NOT NULL, group_id int4 DEFAULT nextval('phpbb_groups_id_seq'::text) NOT NULL,
group_type int2 DEFAULT '1' NOT NULL, group_type int2 DEFAULT '1' NOT NULL,
group_name varchar(100) NOT NULL, group_name varchar(100) NOT NULL,
group_description varchar(255) NOT NULL, group_description varchar(255) NOT NULL,
group_moderator int4 NOT NULL, group_moderator int4 NOT NULL,
group_single_user int2 NOT NULL group_single_user int2 NOT NULL
); );
@ -206,15 +206,15 @@ CREATE TABLE phpbb_posts (
topic_id int4 DEFAULT '0' NOT NULL, topic_id int4 DEFAULT '0' NOT NULL,
forum_id int4 DEFAULT '0' NOT NULL, forum_id int4 DEFAULT '0' NOT NULL,
poster_id int4 DEFAULT '0' NOT NULL, poster_id int4 DEFAULT '0' NOT NULL,
post_time int4 DEFAULT '0' NOT NULL, post_time int4 DEFAULT '0' NOT NULL,
post_username varchar(30), post_username varchar(30),
poster_ip char(8) DEFAULT '' NOT NULL, poster_ip char(8) DEFAULT '' NOT NULL,
enable_bbcode int2 DEFAULT '1' NOT NULL, enable_bbcode int2 DEFAULT '1' NOT NULL,
enable_html int2 DEFAULT '0' NOT NULL, enable_html int2 DEFAULT '0' NOT NULL,
enable_smilies int2 DEFAULT '1' NOT NULL, enable_smilies int2 DEFAULT '1' NOT NULL,
bbcode_uid varchar(10) DEFAULT '' NOT NULL, bbcode_uid varchar(10) DEFAULT '' NOT NULL,
post_edit_time int4, post_edit_time int4,
post_edit_count int2 DEFAULT '0' NOT NULL, post_edit_count int2 DEFAULT '0' NOT NULL,
CONSTRAINT phpbb_posts_pkey PRIMARY KEY (post_id) CONSTRAINT phpbb_posts_pkey PRIMARY KEY (post_id)
); );
CREATE INDEX forum_id_phpbb_posts_index ON phpbb_posts (forum_id); CREATE INDEX forum_id_phpbb_posts_index ON phpbb_posts (forum_id);
@ -412,6 +412,7 @@ CREATE TABLE phpbb_topics (
topic_type int2 DEFAULT '0' NOT NULL, topic_type int2 DEFAULT '0' NOT NULL,
topic_notify int2 DEFAULT '0', topic_notify int2 DEFAULT '0',
topic_last_post_id int4 DEFAULT '0' NOT NULL, topic_last_post_id int4 DEFAULT '0' NOT NULL,
topic_moved_id int4,
CONSTRAINT phpbb_topics_pkey PRIMARY KEY (topic_id) CONSTRAINT phpbb_topics_pkey PRIMARY KEY (topic_id)
); );
CREATE INDEX _phpbb_topics_index ON phpbb_topics (forum_id, topic_id); CREATE INDEX _phpbb_topics_index ON phpbb_topics (forum_id, topic_id);
@ -471,10 +472,10 @@ CREATE TABLE phpbb_users (
user_allowhtml int2, user_allowhtml int2,
user_allowbbcode int2, user_allowbbcode int2,
user_allowsmile int2, user_allowsmile int2,
user_allow_pm int2 DEFAULT '1' NOT NULL, user_allow_pm int2 DEFAULT '1' NOT NULL,
user_allowavatar int2 DEFAULT '1' NOT NULL, user_allowavatar int2 DEFAULT '1' NOT NULL,
user_allow_viewonline int2 DEFAULT '1' NOT NULL, user_allow_viewonline int2 DEFAULT '1' NOT NULL,
user_notify_pm int2 DEFAULT '1' NOT NULL, user_notify_pm int2 DEFAULT '1' NOT NULL,
user_rank int4 DEFAULT '0', user_rank int4 DEFAULT '0',
user_avatar varchar(100), user_avatar varchar(100),
user_level int4 DEFAULT '1', user_level int4 DEFAULT '1',

View file

@ -40,18 +40,20 @@ define(ADMIN, 1);
define(FORUM_UNLOCKED, 0); define(FORUM_UNLOCKED, 0);
define(FORUM_LOCKED, 1); define(FORUM_LOCKED, 1);
// Topic state // Topic status
define(TOPIC_UNLOCKED, 0); define(TOPIC_UNLOCKED, 0);
define(TOPIC_LOCKED, 1); define(TOPIC_LOCKED, 1);
define(TOPIC_MOVED, 2);
define(TOPIC_WATCH_NOTIFIED, 1); define(TOPIC_WATCH_NOTIFIED, 1);
define(TOPIC_WATCH_UN_NOTIFIED, 0); define(TOPIC_WATCH_UN_NOTIFIED, 0);
// Topic types // Topic types
define(POST_NORMAL, 0); define(POST_NORMAL, 0);
define(POST_STICKY, 1); define(POST_STICKY, 1);
define(POST_ANNOUNCE, 2); define(POST_ANNOUNCE, 2);
define(POST_GLOBAL_ANNOUNCE, 3); define(POST_GLOBAL_ANNOUNCE, 3);
define(TOPIC_MOVED,4);
// SQL codes // SQL codes
define(BEGIN_TRANSACTION, 1); define(BEGIN_TRANSACTION, 1);
@ -136,7 +138,7 @@ define('GROUPS_TABLE', $table_prefix.'groups');
define('POSTS_TABLE', $table_prefix.'posts'); define('POSTS_TABLE', $table_prefix.'posts');
define('POSTS_TEXT_TABLE', $table_prefix.'posts_text'); define('POSTS_TEXT_TABLE', $table_prefix.'posts_text');
define('PRIVMSGS_TABLE', $table_prefix.'privmsgs'); define('PRIVMSGS_TABLE', $table_prefix.'privmsgs');
define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text'); define('PRIVMSGS_TEXT_TABLE', $table_prefix.'privmsgs_text');
define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore'); define('PRIVMSGS_IGNORE_TABLE', $table_prefix.'privmsgs_ignore');
define('RANKS_TABLE', $table_prefix.'ranks'); define('RANKS_TABLE', $table_prefix.'ranks');
define('SESSIONS_TABLE', $table_prefix.'session'); define('SESSIONS_TABLE', $table_prefix.'session');

View file

@ -1,36 +1,36 @@
<?php <?php
/*************************************************************************** /***************************************************************************
* modcp.php * modcp.php
* ------------------- * -------------------
* begin : July 4, 2001 * begin : July 4, 2001
* copyright : (C) 2001 The phpBB Group * copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com * email : support@phpbb.com
* *
* $Id$ * $Id$
* *
* *
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* *
***************************************************************************/ ***************************************************************************/
/** /**
* Moderator Control Panel * Moderator Control Panel
* *
* From this 'Control Panel' the moderator of a forum will be able to do * From this 'Control Panel' the moderator of a forum will be able to do
* mass topic operations (locking/unlocking/moving/deleteing), and it will * mass topic operations (locking/unlocking/moving/deleteing), and it will
* provide an interface to do quick locking/unlocking/moving/deleting of * provide an interface to do quick locking/unlocking/moving/deleting of
* topics via the moderator operations buttons on all of the viewtopic pages. * topics via the moderator operations buttons on all of the viewtopic pages.
*/ */
$phpbb_root_path = "./"; $phpbb_root_path = "./";
include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . 'common.'.$phpEx);
@ -44,9 +44,9 @@ $topic_id = ($HTTP_POST_VARS[POST_TOPIC_URL]) ? $HTTP_POST_VARS[POST_TOPIC_URL]
if(empty($forum_id) || !isset($forum_id)) if(empty($forum_id) || !isset($forum_id))
{ {
$sql = "SELECT f.forum_id, f.forum_name, f.forum_topics $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
WHERE t.topic_id = " . $topic_id . " WHERE t.topic_id = " . $topic_id . "
AND f.forum_id = t.forum_id"; AND f.forum_id = t.forum_id";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
@ -60,8 +60,8 @@ if(empty($forum_id) || !isset($forum_id))
} }
else else
{ {
$sql = "SELECT forum_name, forum_topics $sql = "SELECT forum_name, forum_topics
FROM " . FORUMS_TABLE . " FROM " . FORUMS_TABLE . "
WHERE forum_id = " . $forum_id; WHERE forum_id = " . $forum_id;
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
@ -113,14 +113,14 @@ include($phpbb_root_path . 'includes/page_header.'.$phpEx);
// Set template files // Set template files
$template->set_filenames(array( $template->set_filenames(array(
"body" => "modcp_body.tpl", "body" => "modcp_body.tpl",
"confirm" => "confirm_body.tpl", "confirm" => "confirm_body.tpl",
"split_body" => "split_body.tpl") "split_body" => "split_body.tpl")
); );
$template->assign_vars(array( $template->assign_vars(array(
"FORUM_NAME" => $forum_name, "FORUM_NAME" => $forum_name,
"U_VIEW_FORUM" => "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") "U_VIEW_FORUM" => "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")
); );
@ -165,7 +165,7 @@ switch($mode)
{ {
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]); $topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
} }
$sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE "; $sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE ";
$delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE "; $delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE ";
for($x = 0; $x < count($topics); $x++) for($x = 0; $x < count($topics); $x++)
@ -179,7 +179,7 @@ switch($mode)
$delete_topics .= "topic_id = ".$topics[$x]; $delete_topics .= "topic_id = ".$topics[$x];
} }
$topics_removed = $x; $topics_removed = $x;
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql);
@ -199,30 +199,30 @@ switch($mode)
$delete_text .= "post_id = ".$rowset[$x]['post_id']; $delete_text .= "post_id = ".$rowset[$x]['post_id'];
} }
$posts_removed = $x; $posts_removed = $x;
if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION)) if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION))
{ {
message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text); message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text);
} }
if(!$result = $db->sql_query($delete_posts)) if(!$result = $db->sql_query($delete_posts))
{ {
message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts); message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts);
} }
if(!$result = $db->sql_query($delete_topics)) if(!$result = $db->sql_query($delete_topics))
{ {
message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics); message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics);
} }
if(SQL_LAYER != "mysql") if(SQL_LAYER != "mysql")
{ {
$update_index = "UPDATE ".FORUMS_TABLE." $update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed, SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed, forum_posts = forum_posts - $posts_removed,
forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE." forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE."
WHERE forum_id = $forum_id) WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id) WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION)) if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{ {
message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics); message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics);
@ -236,9 +236,9 @@ switch($mode)
message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql);
} }
$last_post = $db->sql_fetchrowset($result); $last_post = $db->sql_fetchrowset($result);
$update_index = "UPDATE ".FORUMS_TABLE." $update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed, SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed, forum_posts = forum_posts - $posts_removed,
forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id"; forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION)) if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{ {
@ -255,7 +255,7 @@ switch($mode)
$next_page = "modcp.$phpEx?".POST_FORUM_URL."=$forum_id"; $next_page = "modcp.$phpEx?".POST_FORUM_URL."=$forum_id";
$return_message = $lang['Return_to_modcp']; $return_message = $lang['Return_to_modcp'];
} }
$msg = $lang['Topics_Removed'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $return_message; $msg = $lang['Topics_Removed'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $return_message;
message_die(GENERAL_MESSAGE, $msg); message_die(GENERAL_MESSAGE, $msg);
} }
@ -287,203 +287,136 @@ switch($mode)
break; break;
case 'move': case 'move':
if($confirm) if($confirm)
{ {
$new_forum = $HTTP_POST_VARS['new_forum']; $new_forum = $HTTP_POST_VARS['new_forum'];
$old_forum = $HTTP_POST_VARS[POST_FORUM_URL]; $old_forum = $HTTP_POST_VARS[POST_FORUM_URL];
if($HTTP_POST_VARS['preform_op']) if($HTTP_POST_VARS['preform_op'])
{ {
$topics = $HTTP_POST_VARS['preform_op']; $topics = $HTTP_POST_VARS['preform_op'];
} }
else else
{ {
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]); $topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
} }
for($x = 0; $x < count($topics); $x++) for($x = 0; $x < count($topics); $x++)
{ {
if($x != 0) if($x != 0)
{ {
$sql_clause .= ' OR '; $sql_clause .= ' OR ';
} }
$sql_clause .= 'topic_id = '.$topics[$x]; $sql_clause .= 'topic_id = '.$topics[$x];
$sql_select = 'SELECT $sql_select = 'SELECT
topic_title, topic_title,
topic_poster, topic_poster,
topic_time topic_time
FROM '. FROM '.
TOPICS_TABLE." WHERE TOPICS_TABLE." WHERE
topic_id = $topics[$x]"; topic_id = $topics[$x]";
if(!$result = $db->sql_query($sql_select)) if(!$result = $db->sql_query($sql_select))
{ {
message_die(GENERAL_ERROR, "Could not select from topic table!", "Error", __LINE__, __FILE__ message_die(GENERAL_ERROR, "Could not select from topic table!", "Error", __LINE__, __FILE__, $sql_select);
, $sql_select); }
} else
else {
{ $row = $db->sql_fetchrowset($result);
$row = $db->sql_fetchrowset($result); $ttitle = $row[0]['topic_title'];
$ttitle = $row[0]['topic_title']; $tpost = $row[0]['topic_poster'];
$tpost = $row[0]['topic_poster']; $ttime = $row[0]['topic_time'];
$ttime = $row[0]['topic_time']; $sql_insert = 'INSERT INTO '.TOPICS_TABLE."
$sql_insert = 'INSERT INTO '.TOPICS_TABLE." (forum_id, topic_title, topic_poster, topic_time, topic_moved_id, topic_status)
(forum_id,topic_title,topic_poster,topic_time,topic_status,topic_type) VALUES
VALUES ($old_forum, '$ttitle', '$tpost', $ttime, $topics[$x], ".TOPIC_MOVED.')';
($old_forum,'$ttitle','$tpost',$ttime,$topics[$x],".TOPIC_MOVED.')'; if(!$result = $db->sql_query($sql_insert))
if(!$result = $db->sql_query($sql_insert)) {
{ message_die(GENERAL_ERROR, "Could not insert into topics table!", "Error", __LINE__, __FILE__, $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."
$newtopic_id = $db->sql_nextid(); (topic_id,forum_id,poster_id,post_time)
$sql_insert = 'INSERT INTO '.POSTS_TABLE." VALUES
(topic_id,forum_id,poster_id,post_time) ($newtopic_id,$old_forum,$tpost,$ttime)";
VALUES if(!$result = $db->sql_query($sql_insert))
($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);
{ }
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);
}
}
}
$sql_replies = 'SELECT SUM(topic_replies) AS total_posts FROM '.TOPICS_TABLE.' WHERE '.$sql_clause; //Finally, update the last_post_id column to reflect the new post just inserted
if(!$result = $db->sql_query($sql_replies)) $newpost_id = $db->sql_nextid();
{ $sql = 'UPDATE '.TOPICS_TABLE." SET topic_last_post_id = $newpost_id WHERE topic_id = $newtopic_id";
message_die(GENERAL_ERROR, "Could not sum topic replies in topics table!", "Error", __LINE__, __FILE__, $sql_replies); if(!$result = $db->sql_query($sql))
} {
else message_die(GENERAL_ERROR, "Could not update the topics table!", "Error", __LINE__, __FILE__, $sql);
{ }
$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_replies = 'SELECT SUM(topic_replies) AS total_posts FROM '.TOPICS_TABLE.' WHERE '.$sql_clause;
$sql_topic = 'UPDATE '.TOPICS_TABLE." SET forum_id = $new_forum WHERE $sql_clause"; if(!$result = $db->sql_query($sql_replies))
if(!$result = $db->sql_query($sql_post)) {
{ message_die(GENERAL_ERROR, "Could not sum topic replies in topics table!", "Error", __LINE__, __FILE__, $sql_replies);
message_die(GENERAL_ERROR, "Could not update posts table!", "Error", __LINE__, __FILE__, $sql_post); }
} else
else if(!$result = $db->sql_query($sql_topic)) {
{ $posts_row = $db->sql_fetchrowset($result);
message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql_topic); $posts = $posts_row[0]['total_posts'] + count($topics);
} }
if(SQL_LAYER != 'mysql')
{ $sql_post = 'UPDATE '.POSTS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
$sql_forums_new = 'UPDATE '.FORUMS_TABLE." SET $sql_topic = 'UPDATE '.TOPICS_TABLE." SET forum_id = $new_forum WHERE $sql_clause";
forum_posts = forum_posts + $posts, if(!$result = $db->sql_query($sql_post))
forum_topics = forum_topics + ".count($topics).", {
forum_last_post_id = message_die(GENERAL_ERROR, "Could not update posts table!", "Error", __LINE__, __FILE__, $sql_post);
(select max(post_id) FROM ".POSTS_TABLE." }
WHERE forum_id = $new_forum) else if(!$result = $db->sql_query($sql_topic))
WHERE forum_id = ".$new_forum; {
$sql_forums_old = 'UPDATE '.FORUMS_TABLE." SET message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql_topic);
forum_posts = forum_posts - $posts + ".count($topics).", }
forum_last_post_id =
(select max(post_id) FROM ".POSTS_TABLE." // Sync the forum indexes
WHERE forum_id = $old_forum) sync("forum", $new_forum);
WHERE forum_id = ".$old_forum; sync("forum", $old_forum);
}
else
{ if($quick_op)
$sql_lastpost = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $new_forum"; {
if(!$result = $db->sql_query($sql_lastpost)) $next_page = "viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id";
{ $return_message = $lang['to_return_topic'];
message_die(GENERAL_ERROR, "Could not get last post id from posts table", "Error", __LINE__,__FILE__, $sql_lastpost); }
} else
else {
{ $next_page = "modcp.$phpEx?".POST_FORUM_URL."=$forum_id";
$last_post_row = $db->sql_fetchrowset($result); $return_message = $lang['Return_to_modcp'];
$last_post_new = $last_post_row[0]['last_post']; }
if($last_post_new == "") $msg = $lang['Topics_Moved'] . "<br />" . "<a href=\"".append_sid($next_page)."\">". $lang['Click']. " " . $lang['Here'] ."</a> " . $return_message;
{ message_die(GENERAL_MESSAGE, $msg);
$last_post_new = "''"; }
} else
} {
$sql_lastpost = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $old_forum"; $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.'">';
if(!$result = $db->sql_query($sql_lastpost)) $hidden_fields .= $lang['New_forum'] . ': ' . make_forum_box('new_forum'). '</select><br><br>';
{ if($HTTP_POST_VARS['preform_op'])
message_die(GENERAL_ERROR, "Could not get last post id from posts table", "Error", __LINE__,__FILE__, $sql_lastpost); {
} $topics = $HTTP_POST_VARS['preform_op'];
else for($x = 0; $x < count($topics); $x++)
{ {
$last_post_row = $db->sql_fetchrowset($result); $hidden_fields .= '<input type="hidden" name="preform_op[]" value="'.$topics[$x].'">';
$last_post_old = $last_post_row[0]['last_post']; }
if($last_post_old == "") }
{ else
$last_post_old = "''"; {
} $hidden_fields .= '<input type="hidden" name="'.POST_TOPIC_URL.'" value="'.$topic_id.'">';
} }
$sql_forums_new = 'UPDATE '.FORUMS_TABLE." SET $template->assign_vars(array("MESSAGE_TITLE" => $lang['Confirm'],
forum_posts = forum_posts + $posts, "MESSAGE_TEXT" => $lang['Confirm_move_topic'],
forum_topics = forum_topics + ".count($topics).", "L_YES" => $lang['Yes'],
forum_last_post_id = $last_post_new "L_NO" => $lang['No'],
WHERE forum_id = $new_forum"; "S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
$sql_forums_old = 'UPDATE '.FORUMS_TABLE." SET "S_HIDDEN_FIELDS" => $hidden_fields));
forum_posts = forum_posts - $posts + ".count($topics).", $template->pparse("confirm");
forum_last_post_id = $last_post_old include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
WHERE forum_id = $old_forum"; }
} break;
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;
case 'lock': case 'lock':
if($confirm) if($confirm)
@ -496,7 +429,7 @@ __FILE__, $sql);
{ {
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]); $topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
} }
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_LOCKED . " WHERE "; $sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_LOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++) for($x = 0; $x < count($topics); $x++)
{ {
@ -506,7 +439,7 @@ __FILE__, $sql);
} }
$sql .= "topic_id = " . $topics[$x]; $sql .= "topic_id = " . $topics[$x];
} }
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql);
@ -566,7 +499,7 @@ __FILE__, $sql);
{ {
$topics = array($HTTP_POST_VARS[POST_TOPIC_URL]); $topics = array($HTTP_POST_VARS[POST_TOPIC_URL]);
} }
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE "; $sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++) for($x = 0; $x < count($topics); $x++)
{ {
@ -576,7 +509,7 @@ __FILE__, $sql);
} }
$sql .= "topic_id = " . $topics[$x]; $sql .= "topic_id = " . $topics[$x];
} }
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not update topics table!", "Error", __LINE__, __FILE__, $sql);
@ -623,7 +556,7 @@ __FILE__, $sql);
"L_YES" => $lang['Yes'], "L_YES" => $lang['Yes'],
"L_NO" => $lang['No'], "L_NO" => $lang['No'],
"S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"), "S_CONFIRM_ACTION" => append_sid("modcp.$phpEx"),
"S_HIDDEN_FIELDS" => $hidden_fields) "S_HIDDEN_FIELDS" => $hidden_fields)
); );
@ -631,50 +564,50 @@ __FILE__, $sql);
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
} }
break; break;
case 'split': case 'split':
if($HTTP_POST_VARS['split_type_all'] || $HTTP_POST_VARS['split_type_beyond']) if($HTTP_POST_VARS['split_type_all'] || $HTTP_POST_VARS['split_type_beyond'])
{ {
$posts = $HTTP_POST_VARS['preform_op']; $posts = $HTTP_POST_VARS['preform_op'];
$sql = "SELECT poster_id, topic_id, post_time $sql = "SELECT poster_id, topic_id, post_time
FROM " . POSTS_TABLE . " FROM " . POSTS_TABLE . "
WHERE post_id = ".$posts[0]; WHERE post_id = ".$posts[0];
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
message_die(GENERAL_ERROR, "Could not get post information", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not get post information", "", __LINE__, __FILE__, $sql);
} }
$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']; $post_time = $post_rowset[0]['post_time'];
$subject = trim(strip_tags(htmlspecialchars(addslashes($HTTP_POST_VARS['subject'])))); $subject = trim(strip_tags(htmlspecialchars(addslashes($HTTP_POST_VARS['subject']))));
if(empty($subject)) if(empty($subject))
{ {
message_die(GENERAL_MESSAGE, $lang['Empty_subject']); message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
} }
$new_forum_id = $HTTP_POST_VARS['new_forum_id']; $new_forum_id = $HTTP_POST_VARS['new_forum_id'];
$topic_time = get_gmt_ts(); $topic_time = get_gmt_ts();
$sql = "INSERT INTO " . TOPICS_TABLE . " $sql = "INSERT INTO " . TOPICS_TABLE . "
(topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status, topic_type) (topic_title, topic_poster, topic_time, forum_id, topic_notify, topic_status, topic_type)
VALUES ('$subject', $first_poster, " . $topic_time . ", $new_forum_id, 0, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")"; VALUES ('$subject', $first_poster, " . $topic_time . ", $new_forum_id, 0, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION)) if(!$result = $db->sql_query($sql, BEGIN_TRANSACTION))
{ {
message_die(GENERAL_ERROR, "Could not insert new topic", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not insert new topic", "", __LINE__, __FILE__, $sql);
} }
$new_topic_id = $db->sql_nextid(); $new_topic_id = $db->sql_nextid();
if($HTTP_POST_VARS['split_type_all']) if($HTTP_POST_VARS['split_type_all'])
{ {
$sql = "UPDATE " . POSTS_TABLE . " $sql = "UPDATE " . POSTS_TABLE . "
SET topic_id = $new_topic_id SET topic_id = $new_topic_id
WHERE "; WHERE ";
for($x = 0; $x < count($posts); $x++) for($x = 0; $x < count($posts); $x++)
@ -689,18 +622,18 @@ __FILE__, $sql);
} }
else if($HTTP_POST_VARS['split_type_beyond']) else if($HTTP_POST_VARS['split_type_beyond'])
{ {
$sql = "UPDATE " . POSTS_TABLE . " $sql = "UPDATE " . POSTS_TABLE . "
SET topic_id = $new_topic_id SET topic_id = $new_topic_id
WHERE post_time >= $post_time WHERE post_time >= $post_time
AND topic_id = $topic_id"; AND topic_id = $topic_id";
} }
if(!$result = $db->sql_query($sql, END_TRANSACTION)) if(!$result = $db->sql_query($sql, END_TRANSACTION))
{ {
message_die(GENERAL_ERROR, "Could not update posts table!", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not update posts table!", "", __LINE__, __FILE__, $sql);
} }
else else
{ {
sync("topic", $new_topic_id); sync("topic", $new_topic_id);
sync("topic", $topic_id); sync("topic", $topic_id);
sync("forum", $forum_id); sync("forum", $forum_id);
@ -714,7 +647,7 @@ __FILE__, $sql);
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];
$sql = "SELECT u.username, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject, p.post_username $sql = "SELECT u.username, p.post_time, p.post_id, p.bbcode_uid, pt.post_text, pt.post_subject, p.post_username
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id WHERE p.topic_id = $topic_id
@ -725,13 +658,13 @@ __FILE__, $sql);
{ {
message_die(GENERAL_ERROR, "Could not get topic/post information", "", __LINE__, __FILE__, $sql); message_die(GENERAL_ERROR, "Could not get topic/post information", "", __LINE__, __FILE__, $sql);
} }
$s_hidden_fields = "<input type=\"hidden\" name=\"" . POST_FORUM_URL . "\" value=\"$forum_id\"><input type=\"hidden\" name=\"mode\" value=\"split\">"; $s_hidden_fields = "<input type=\"hidden\" name=\"" . POST_FORUM_URL . "\" value=\"$forum_id\"><input type=\"hidden\" name=\"mode\" value=\"split\">";
if( ( $total_posts = $db->sql_numrows($result) ) > 0 ) if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
{ {
$postrow = $db->sql_fetchrowset($result); $postrow = $db->sql_fetchrowset($result);
$template->assign_vars(array( $template->assign_vars(array(
"L_SPLIT_TOPIC" => $lang['Split_Topic'], "L_SPLIT_TOPIC" => $lang['Split_Topic'],
"L_SPLIT_TOPIC_EXPLAIN" => $lang['Split_Topic_explain'], "L_SPLIT_TOPIC_EXPLAIN" => $lang['Split_Topic_explain'],
@ -750,7 +683,7 @@ __FILE__, $sql);
"FORUM_INPUT" => make_forum_box("new_forum_id", $forum_id)) "FORUM_INPUT" => make_forum_box("new_forum_id", $forum_id))
); );
for($i = 0; $i < $total_posts; $i++) for($i = 0; $i < $total_posts; $i++)
{ {
$post_id = $postrow[$i]['post_id']; $post_id = $postrow[$i]['post_id'];
@ -758,7 +691,7 @@ __FILE__, $sql);
$poster = stripslashes($postrow[$i]['username']); $poster = stripslashes($postrow[$i]['username']);
$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['default_timezone']); $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['default_timezone']);
if($poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '') if($poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '')
{ {
$poster = stripslashes($postrow[$i]['post_username']); $poster = stripslashes($postrow[$i]['post_username']);
@ -766,30 +699,30 @@ __FILE__, $sql);
$post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : ""; $post_subject = ($postrow[$i]['post_subject'] != "") ? stripslashes($postrow[$i]['post_subject']) : "";
$bbcode_uid = $postrow[$i]['bbcode_uid']; $bbcode_uid = $postrow[$i]['bbcode_uid'];
$user_sig = stripslashes($postrow[$i]['user_sig']); $user_sig = stripslashes($postrow[$i]['user_sig']);
$message = stripslashes($postrow[$i]['post_text']); $message = stripslashes($postrow[$i]['post_text']);
if(!$board_config['allow_html']) if(!$board_config['allow_html'])
{ {
$user_sig = strip_tags($user_sig); $user_sig = strip_tags($user_sig);
$message = strip_tags($message); $message = strip_tags($message);
} }
if($board_config['allow_bbcode']) if($board_config['allow_bbcode'])
{ {
// do bbcode stuff here // do bbcode stuff here
$sig_uid = make_bbcode_uid(); $sig_uid = make_bbcode_uid();
$user_sig = bbencode_first_pass($user_sig, $sig_uid); $user_sig = bbencode_first_pass($user_sig, $sig_uid);
$user_sig = bbencode_second_pass($user_sig, $sig_uid); $user_sig = bbencode_second_pass($user_sig, $sig_uid);
$message = bbencode_second_pass($message, $bbcode_uid); $message = bbencode_second_pass($message, $bbcode_uid);
} }
$message = make_clickable($message); $message = make_clickable($message);
$message = str_replace("\n", "<br />", $message); $message = str_replace("\n", "<br />", $message);
$message = eregi_replace("\[addsig]$", "", $message); $message = eregi_replace("\[addsig]$", "", $message);
//$message = (strlen($message) > 100) ? substr($message, 0, 100) . " ..." : $message; //$message = (strlen($message) > 100) ? substr($message, 0, 100) . " ..." : $message;
if(!($i % 2)) if(!($i % 2))
@ -807,13 +740,13 @@ __FILE__, $sql);
"POST_SUBJECT" => $post_subject, "POST_SUBJECT" => $post_subject,
"MESSAGE" => $message, "MESSAGE" => $message,
"POST_ID" => $post_id, "POST_ID" => $post_id,
"ROW_COLOR" => $color) "ROW_COLOR" => $color)
); );
} }
$template->pparse("split_body"); $template->pparse("split_body");
} }
} }
break; break;
@ -828,7 +761,7 @@ __FILE__, $sql);
"L_LOCK" => $lang['Lock'], "L_LOCK" => $lang['Lock'],
"L_UNLOCK" => $lang['Unlock'], "L_UNLOCK" => $lang['Unlock'],
"S_HIDDEN_FIELDS" => "<input type=\"hidden\" name=\"" . POST_FORUM_URL . "\" value=\"$forum_id\">", "S_HIDDEN_FIELDS" => "<input type=\"hidden\" name=\"" . POST_FORUM_URL . "\" value=\"$forum_id\">",
"S_MODCP_ACTION" => append_sid("modcp.$phpEx")) "S_MODCP_ACTION" => append_sid("modcp.$phpEx"))
); );
@ -836,9 +769,9 @@ __FILE__, $sql);
{ {
$start = 0; $start = 0;
} }
$sql = "SELECT t.topic_title, t.topic_id, t.topic_replies, t.topic_status, t.topic_type, u.username, u.user_id, p.post_time $sql = "SELECT t.topic_title, t.topic_id, t.topic_replies, t.topic_status, t.topic_type, u.username, u.user_id, p.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id AND p.post_id = t.topic_last_post_id
@ -852,22 +785,22 @@ __FILE__, $sql);
} }
$total_topics = $db->sql_numrows($t_result); $total_topics = $db->sql_numrows($t_result);
$topics = $db->sql_fetchrowset($t_result); $topics = $db->sql_fetchrowset($t_result);
for($x = 0; $x < $total_topics; $x++) for($x = 0; $x < $total_topics; $x++)
{ {
if($topics[$x]['topic_status'] == TOPIC_LOCKED) if($topics[$x]['topic_status'] == TOPIC_LOCKED)
{ {
$folder_image = "<img src=\"" . $images['folder_locked'] . "\" alt=\"Topic Locked\">"; $folder_image = "<img src=\"" . $images['folder_locked'] . "\" alt=\"Topic Locked\">";
} }
else else
{ {
$folder_image = "<img src=\"" . $images['folder'] . "\">"; $folder_image = "<img src=\"" . $images['folder'] . "\">";
} }
$topic_id = $topics[$x]['topic_id']; $topic_id = $topics[$x]['topic_id'];
$topic_title = ""; $topic_title = "";
if($topics[$x]['topic_type'] == POST_STICKY) if($topics[$x]['topic_type'] == POST_STICKY)
{ {
$topic_title = $lang['Sticky'] . " "; $topic_title = $lang['Sticky'] . " ";
@ -876,14 +809,14 @@ __FILE__, $sql);
{ {
$topic_title = $lang['Annoucement'] . " "; $topic_title = $lang['Annoucement'] . " ";
} }
$topic_title .= stripslashes($topics[$x]['topic_title']); $topic_title .= stripslashes($topics[$x]['topic_title']);
$u_view_topic = append_sid("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id"); $u_view_topic = append_sid("viewtopic.$phpEx?".POST_TOPIC_URL."=$topic_id");
$topic_replies = $topics[$x]['topic_replies']; $topic_replies = $topics[$x]['topic_replies'];
$last_post_time = create_date($board_config['default_dateformat'], $topics[$x]['post_time'], $board_config['default_timezone']); $last_post_time = create_date($board_config['default_dateformat'], $topics[$x]['post_time'], $board_config['default_timezone']);
$template->assign_block_vars("topicrow", array( $template->assign_block_vars("topicrow", array(
"U_VIEW_TOPIC" => $u_view_topic, "U_VIEW_TOPIC" => $u_view_topic,
@ -894,7 +827,7 @@ __FILE__, $sql);
"TOPIC_ID" => $topic_id) "TOPIC_ID" => $topic_id)
); );
} }
$pagination = generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id", $forum_topics, $board_config['topics_per_page'], $start); $pagination = generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id", $forum_topics, $board_config['topics_per_page'], $start);
$template->assign_vars(array( $template->assign_vars(array(
@ -914,5 +847,5 @@ __FILE__, $sql);
} }
include($phpbb_root_path . 'includes/page_tail.'.$phpEx); include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
?> ?>

View file

@ -66,8 +66,8 @@ init_userprefs($userdata);
// //
if(isset($forum_id)) if(isset($forum_id))
{ {
$sql = "SELECT forum_name, forum_status, forum_topics, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_votecreate, auth_vote, prune_enable, prune_next $sql = "SELECT forum_name, forum_status, forum_topics, auth_view, auth_read, auth_post, auth_reply, auth_edit, auth_delete, auth_votecreate, auth_vote, prune_enable, prune_next
FROM " . FORUMS_TABLE . " FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id"; WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
{ {
@ -127,12 +127,12 @@ if( $is_auth['auth_mod'] && $board_config['prune_enable'] )
// //
// Obtain list of moderators of this forum // Obtain list of moderators of this forum
// //
$sql = "SELECT g.group_name, g.group_id, g.group_single_user, u.user_id, u.username $sql = "SELECT g.group_name, g.group_id, g.group_single_user, u.user_id, u.username
FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
WHERE aa.forum_id = $forum_id WHERE aa.forum_id = $forum_id
AND aa.auth_mod = " . TRUE . " AND aa.auth_mod = " . TRUE . "
AND ug.group_id = aa.group_id AND ug.group_id = aa.group_id
AND g.group_id = aa.group_id AND g.group_id = aa.group_id
AND u.user_id = ug.user_id"; AND u.user_id = ug.user_id";
if(!$result_mods = $db->sql_query($sql)) if(!$result_mods = $db->sql_query($sql))
{ {
@ -188,10 +188,10 @@ if(!empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']))
$min_topic_time = time() - ($topic_days * 86400); $min_topic_time = time() - ($topic_days * 86400);
$sql = "SELECT COUNT(t.topic_id) AS forum_topics $sql = "SELECT COUNT(t.topic_id) AS forum_topics
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.forum_id = $forum_id WHERE t.forum_id = $forum_id
AND p.post_id = t.topic_last_post_id AND p.post_id = t.topic_last_post_id
AND ( p.post_time >= $min_topic_time AND ( p.post_time >= $min_topic_time
OR t.topic_type = " . POST_ANNOUNCE . " )"; OR t.topic_type = " . POST_ANNOUNCE . " )";
if(!$result = $db->sql_query($sql)) if(!$result = $db->sql_query($sql))
@ -224,7 +224,7 @@ for($i = 0; $i < count($previous_days); $i++)
$select_topic_days .= "</select>"; $select_topic_days .= "</select>";
// //
// Grab all the basic data (all topics except announcements) // Grab all the basic data (all topics except announcements)
// for this forum // for this forum
// //
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
@ -233,8 +233,8 @@ $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as i
AND t.topic_poster = u.user_id AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id AND p.poster_id = u2.user_id
AND t.topic_type <> " . POST_GLOBAL_ANNOUNCE . " AND t.topic_type <> " . POST_GLOBAL_ANNOUNCE . "
AND t.topic_type <> " . POST_ANNOUNCE . " AND t.topic_type <> " . POST_ANNOUNCE . "
$limit_topics_time $limit_topics_time
ORDER BY t.topic_type DESC, p.post_time DESC ORDER BY t.topic_type DESC, p.post_time DESC
LIMIT $start, ".$board_config['topics_per_page']; LIMIT $start, ".$board_config['topics_per_page'];
@ -245,17 +245,17 @@ if(!$t_result = $db->sql_query($sql))
$total_topics = $db->sql_numrows($t_result); $total_topics = $db->sql_numrows($t_result);
// //
// All announcement data, this keeps announcements // All announcement data, this keeps announcements
// on each viewforum page ... // on each viewforum page ...
// //
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username $sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2 FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
WHERE ( t.forum_id = $forum_id WHERE ( t.forum_id = $forum_id
OR t.forum_id = -1 ) OR t.forum_id = -1 )
AND t.topic_poster = u.user_id AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id AND p.poster_id = u2.user_id
AND ( t.topic_type = " . POST_GLOBAL_ANNOUNCE . " AND ( t.topic_type = " . POST_GLOBAL_ANNOUNCE . "
OR t.topic_type = " . POST_ANNOUNCE . " ) OR t.topic_type = " . POST_ANNOUNCE . " )
ORDER BY p.post_time DESC"; ORDER BY p.post_time DESC";
if(!$ta_result = $db->sql_query($sql)) if(!$ta_result = $db->sql_query($sql))
@ -268,7 +268,7 @@ $total_announcements = $db->sql_numrows($ta_result);
// Post URL generation for templating vars // Post URL generation for templating vars
// //
$template->assign_vars(array( $template->assign_vars(array(
"L_DISPLAY_TOPICS" => $lang['Display_topics'], "L_DISPLAY_TOPICS" => $lang['Display_topics'],
"U_POST_NEW_TOPIC" => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"), "U_POST_NEW_TOPIC" => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"),
@ -317,9 +317,9 @@ $template->set_filenames(array(
$jumpbox = make_jumpbox(); $jumpbox = make_jumpbox();
$template->assign_vars(array( $template->assign_vars(array(
"L_GO" => $lang['Go'], "L_GO" => $lang['Go'],
"L_JUMP_TO" => $lang['Jump_to'], "L_JUMP_TO" => $lang['Jump_to'],
"L_SELECT_FORUM" => $lang['Select_forum'], "L_SELECT_FORUM" => $lang['Select_forum'],
"JUMPBOX_LIST" => $jumpbox, "JUMPBOX_LIST" => $jumpbox,
"SELECT_NAME" => POST_FORUM_URL) "SELECT_NAME" => POST_FORUM_URL)
); );
@ -331,15 +331,15 @@ $template->assign_vars(array(
"MODERATORS" => $forum_moderators, "MODERATORS" => $forum_moderators,
"IMG_POST" => ($forum_row['forum_status'] == FORUM_LOCKED) ? $images['post_locked'] : $images['post_new'], "IMG_POST" => ($forum_row['forum_status'] == FORUM_LOCKED) ? $images['post_locked'] : $images['post_new'],
"L_MARK_TOPICS_READ" => $lang['Mark_all_topics'], "L_MARK_TOPICS_READ" => $lang['Mark_all_topics'],
"U_MARK_READ" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"), "U_MARK_READ" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"),
"S_AUTH_LIST" => $s_auth_can, "S_AUTH_LIST" => $s_auth_can,
"S_AUTH_READ_IMG" => $s_auth_read_img, "S_AUTH_READ_IMG" => $s_auth_read_img,
"S_AUTH_POST_IMG" => $s_auth_post_img, "S_AUTH_POST_IMG" => $s_auth_post_img,
"S_AUTH_REPLY_IMG" => $s_auth_reply_img, "S_AUTH_REPLY_IMG" => $s_auth_reply_img,
"S_AUTH_EDIT_IMG" => $s_auth_edit_img, "S_AUTH_EDIT_IMG" => $s_auth_edit_img,
"S_AUTH_MOD_IMG" => $s_auth_mod_img) "S_AUTH_MOD_IMG" => $s_auth_mod_img)
); );
// //
@ -380,18 +380,12 @@ if($total_topics || $total_announcements)
{ {
$topic_type = $lang['Topic_Sticky'] . " "; $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 else
{ {
$topic_type = ""; $topic_type = "";
} }
$topic_id = $topic_rowset[$i]['topic_id']; $topic_id = $topic_rowset[$i]['topic_id'];
$replies = $topic_rowset[$i]['topic_replies']; $replies = $topic_rowset[$i]['topic_replies'];
@ -428,9 +422,15 @@ if($total_topics || $total_announcements)
} }
if($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED) if($topic_rowset[$i]['topic_status'] == TOPIC_LOCKED)
{ {
$folder_image = "<img src=\"" . $images['folder_locked'] . "\" alt=\"" . $lang['Topic_locked'] . "\" />"; $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 else
{ {
@ -483,7 +483,7 @@ if($total_topics || $total_announcements)
} }
} }
$view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id"); $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
$topic_poster = stripslashes($topic_rowset[$i]['username']); $topic_poster = stripslashes($topic_rowset[$i]['username']);
@ -531,7 +531,7 @@ if($total_topics || $total_announcements)
"L_OF" => $lang['of'], "L_OF" => $lang['of'],
"L_PAGE" => $lang['Page'], "L_PAGE" => $lang['Page'],
"L_GOTO_PAGE" => $lang['Goto_page'], "L_GOTO_PAGE" => $lang['Goto_page'],
"S_NO_TOPICS" => FALSE) "S_NO_TOPICS" => FALSE)
); );
@ -542,8 +542,8 @@ else
// No topics // No topics
// //
$no_topics_msg = ($forum_row['forum_status'] == FORUM_LOCKED) ? $lang['Forum_locked'] : $lang['No_topics_post_one']; $no_topics_msg = ($forum_row['forum_status'] == FORUM_LOCKED) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
$template->assign_vars(array( $template->assign_vars(array(
"L_NO_TOPICS" => $no_topics_msg, "L_NO_TOPICS" => $no_topics_msg,
"S_NO_TOPICS" => TRUE) "S_NO_TOPICS" => TRUE)
); );