mirror of
https://github.com/e107inc/e107.git
synced 2025-08-24 07:03:06 +02:00
Forum topic delete routine: more checks
This commit is contained in:
@@ -1826,7 +1826,10 @@ class e107forum
|
|||||||
if ($threadInfo = $this->threadGet($threadId))
|
if ($threadInfo = $this->threadGet($threadId))
|
||||||
{
|
{
|
||||||
// delete poll if there is one
|
// delete poll if there is one
|
||||||
|
if($sql->select('polls', '*', 'poll_datestamp='.$threadId))
|
||||||
|
{
|
||||||
$sql->delete('polls', 'poll_datestamp='.$threadId);
|
$sql->delete('polls', 'poll_datestamp='.$threadId);
|
||||||
|
}
|
||||||
|
|
||||||
// decrement user post counts
|
// decrement user post counts
|
||||||
if ($postCount = $this->threadGetUserPostcount($threadId))
|
if ($postCount = $this->threadGetUserPostcount($threadId))
|
||||||
@@ -1838,14 +1841,14 @@ class e107forum
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete all posts
|
// delete all posts
|
||||||
$qry = 'SELECT post_id FROM `#forum_post` WHERE post_thread = '.$threadId;
|
if($sql->select('forum_post', 'post_id', 'post_thread = '.$threadId))
|
||||||
if($sql->gen($qry))
|
|
||||||
{
|
{
|
||||||
$postList = array();
|
$postList = array();
|
||||||
while($row = $sql->fetch(MYSQL_ASSOC))
|
while($row = $sql->fetch(MYSQL_ASSOC))
|
||||||
{
|
{
|
||||||
$postList[] = $row['post_id'];
|
$postList[] = $row['post_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($postList as $postId)
|
foreach($postList as $postId)
|
||||||
{
|
{
|
||||||
$this->postDelete($postId, false);
|
$this->postDelete($postId, false);
|
||||||
@@ -1859,7 +1862,10 @@ class e107forum
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Delete any thread tracking
|
//Delete any thread tracking
|
||||||
|
if($sql->select('forum_track', '*', 'track_thread='.$threadId))
|
||||||
|
{
|
||||||
$sql->delete('forum_track', 'track_thread='.$threadId);
|
$sql->delete('forum_track', 'track_thread='.$threadId);
|
||||||
|
}
|
||||||
|
|
||||||
// update forum with correct thread/reply counts
|
// update forum with correct thread/reply counts
|
||||||
$sql->update('forum', "forum_threads=GREATEST(forum_threads-1,0), forum_replies=GREATEST(forum_replies-{$threadInfo['thread_total_replies']},0) WHERE forum_id=".$threadInfo['thread_forum_id']);
|
$sql->update('forum', "forum_threads=GREATEST(forum_threads-1,0), forum_replies=GREATEST(forum_replies-{$threadInfo['thread_total_replies']},0) WHERE forum_id=".$threadInfo['thread_forum_id']);
|
||||||
@@ -1873,7 +1879,6 @@ class e107forum
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a Post
|
* Delete a Post
|
||||||
* @param $postId integer
|
* @param $postId integer
|
||||||
|
Reference in New Issue
Block a user