1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-18 22:58:10 +01:00

Fixed bug in posting (forum_topics was incremented on replies, not just new topics)

One click lock/unlock/delete works for modcp.


git-svn-id: file:///svn/phpbb/trunk@609 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
James Atkinson 2001-07-09 22:35:17 +00:00
parent a032864974
commit fe189c90de
3 changed files with 136 additions and 123 deletions

View File

@ -132,94 +132,94 @@ switch($mode)
if($HTTP_POST_VARS['preform_op'])
{
$topics = $HTTP_POST_VARS['preform_op'];
$sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE ";
$delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
$sql .= " OR ";
$delete_topics .= " OR ";
}
$sql .= "topic_id = ".$topics[$x];
$delete_topics .= "topic_id = ".$topics[$x];
}
$topics_removed = $x;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql);
}
$num_posts = $db->sql_numrows($result);
$rowset = $db->sql_fetchrowset($result);
$delete_posts = "DELETE FROM ".POSTS_TABLE." WHERE ";
$delete_text = "DELETE FROM ".POSTS_TEXT_TABLE." WHERE ";
for($x = 0; $x < $num_posts; $x++)
{
if($x > 0)
{
$delete_posts .= " OR ";
$delete_text .= " OR ";
}
$delete_posts .= "post_id = ".$rowset[$x]['post_id'];
$delete_text .= "post_id = ".$rowset[$x]['post_id'];
}
$posts_removed = $x;
if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text);
}
if(!$result = $db->sql_query($delete_posts))
{
message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts);
}
if(!$result = $db->sql_query($delete_topics))
{
message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics);
}
if(SQL_LAYER != "mysql")
{
$update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed,
forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE."
WHERE forum_id = $forum_id) WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics);
}
}
else
{
$sql = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql);
}
$last_post = $db->sql_fetchrowset($result);
$update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed,
forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $update_index);
}
}
$msg = $lang['Topics_Removed'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
}
else
{
echo "Here";
$topics = array($HTTP_GET_VARS[POST_TOPIC_URL]);
}
$sql = "SELECT post_id FROM ".POSTS_TABLE." WHERE ";
$delete_topics = "DELETE FROM ".TOPICS_TABLE." WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
$sql .= " OR ";
$delete_topics .= " OR ";
}
$sql .= "topic_id = ".$topics[$x];
$delete_topics .= "topic_id = ".$topics[$x];
}
$topics_removed = $x;
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not get posts lists for deletion!", "Error", __LINE__, __FILE__, $sql);
}
$num_posts = $db->sql_numrows($result);
$rowset = $db->sql_fetchrowset($result);
$delete_posts = "DELETE FROM ".POSTS_TABLE." WHERE ";
$delete_text = "DELETE FROM ".POSTS_TEXT_TABLE." WHERE ";
for($x = 0; $x < $num_posts; $x++)
{
if($x > 0)
{
$delete_posts .= " OR ";
$delete_text .= " OR ";
}
$delete_posts .= "post_id = ".$rowset[$x]['post_id'];
$delete_text .= "post_id = ".$rowset[$x]['post_id'];
}
$posts_removed = $x;
if(!$result = $db->sql_query($delete_text, BEGIN_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not delete posts text!", "Error", __LINE__, __FILE__, $delete_text);
}
if(!$result = $db->sql_query($delete_posts))
{
message_die(GENERAL_ERROR, "Could not delete posts!", "Error", __LINE__, __FILE__, $delete_posts);
}
if(!$result = $db->sql_query($delete_topics))
{
message_die(GENERAL_ERROR, "Could not delete topics!", "Error", __LINE__, __FILE__, $delete_topics);
}
if(SQL_LAYER != "mysql")
{
$update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed,
forum_last_post_id = (select max(post_id) FROM ".POSTS_TABLE."
WHERE forum_id = $forum_id) WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $delete_topics);
}
}
else
{
$sql = "select max(post_id) AS last_post FROM ".POSTS_TABLE." WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Could not get last post id", "Error", __LINE__, __FILE__, $sql);
}
$last_post = $db->sql_fetchrowset($result);
$update_index = "UPDATE ".FORUMS_TABLE."
SET forum_topics = forum_topics - $topics_removed,
forum_posts = forum_posts - $posts_removed,
forum_last_post_id = ".$last_post[0]['last_post']." WHERE forum_id = $forum_id";
if(!$result = $db->sql_query($update_index, END_TRANSACTION))
{
message_die(GENERAL_ERROR, "Could not update index!", "Error", __LINE__, __FILE__, $update_index);
}
}
$msg = $lang['Topics_Removed'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
break;
case 'move':
@ -230,53 +230,62 @@ switch($mode)
if($HTTP_POST_VARS['preform_op'])
{
$topics = $HTTP_POST_VARS['preform_op'];
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_LOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
$sql .= " OR ";
}
$sql .= "topic_id = " . $topics[$x];
}
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql);
}
else
{
$msg = $lang['Topics_Locked'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
}
}
else
{
$topics = array($HTTP_GET_VARS[POST_TOPIC_URL]);
}
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_LOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
$sql .= " OR ";
}
$sql .= "topic_id = " . $topics[$x];
}
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql);
}
else
{
$msg = $lang['Topics_Locked'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
}
break;
case 'unlock':
if($HTTP_POST_VARS['preform_op'])
{
$topics = $HTTP_POST_VARS['preform_op'];
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
$sql .= " OR ";
}
$sql .= "topic_id = " . $topics[$x];
}
}
else
{
$topics = array($HTTP_GET_VARS[POST_TOPIC_URL]);
}
if(!$result = $db->sql_query($sql))
$sql = "UPDATE " . TOPICS_TABLE . " SET topic_status = " . TOPIC_UNLOCKED . " WHERE ";
for($x = 0; $x < count($topics); $x++)
{
if($x > 0)
{
message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql);
}
else
{
$msg = $lang['Topics_Unlocked'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
$sql .= " OR ";
}
$sql .= "topic_id = " . $topics[$x];
}
if(!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, "Coule not update topics table!", "Error", __LINE__, __FILE__, $sql);
}
else
{
$msg = $lang['Topics_Unlocked'] . "<br />" . "<a href=\"".append_sid("modcp.$phpEx?".POST_FORUM_URL."=$forum_id")."\">". $lang['Click'] . " " . $lang['Here'] ."</a> " . $lang['Return_to_modcp'];
message_die(GENERAL_MESSAGE, $msg);
}
break;
default:

View File

@ -329,8 +329,12 @@ if($mode == "newtopic" || $mode == "reply")
if($db->sql_query($sql))
{
$sql = "UPDATE " . FORUMS_TABLE . "
SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1, forum_topics = forum_topics + 1
WHERE forum_id = $forum_id";
SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1";
if($mode == "newtopic")
{
$sql .= ", forum_topics = forum_topics + 1";
}
$sql .= " WHERE forum_id = $forum_id";
if($db->sql_query($sql))
{

View File

@ -455,7 +455,7 @@ if($is_auth['auth_mod'] || $userdata['user_level'] == ADMIN)
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move"). "\"><img src=\"images/topic_move.gif\" alt = \"" . $lang['Move_topic'] . "\" border=\"0\"></a>&nbsp;&nbsp;";
if($forum_row[0]['topic_status'] == UNLOCKED)
if($forum_row[0]['topic_status'] == TOPIC_UNLOCKED)
{
$topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock") . "\"><img src=\"images/topic_lock.gif\" alt = \"" . $lang['Lock_topic'] . "\" border=\"0\"></a>&nbsp;&nbsp;";
}