isAdmin($xoopsModule->mid()) ) { if ( !is_moderator($forum, $xoopsUser->uid()) ) { $accesserror = 1; } } } else { $accesserror = 1; } if ( $accesserror == 1 ) { redirect_header("viewtopic.php?topic_id=$topic_id&post_id=$post_id&order=$order&viewmode=$viewmode&pid=$pid&forum=$forum",3,_MD_YANTMOTFTYCPTF); exit(); } include XOOPS_ROOT_PATH.'/header.php'; OpenTable(); if ( $HTTP_POST_VARS['submit'] ) { switch ($HTTP_POST_VARS['mode']) { case 'del': // Update the users's post count, this might be slow on big topics but it makes other parts of the // forum faster so we win out in the long run. $sql = "SELECT uid, post_id FROM ".$xoopsDB->prefix("bb_posts")." WHERE topic_id = $topic_id"; if ( !$r = $xoopsDB->query($sql) ) { exit(_MD_COULDNOTQUERY); } while ( $row = $xoopsDB->fetchArray($r) ) { if ( $row['uid'] != 0 ) { $sql = sprintf("UPDATE %s SET posts = posts - 1 WHERE uid = %u", $xoopsDB->prefix("users"), $row['uid']); $xoopsDB->query($sql); } } // Get the post ID's we have to remove. $sql = "SELECT post_id FROM ".$xoopsDB->prefix("bb_posts")." WHERE topic_id = $topic_id"; if ( !$r = $xoopsDB->query($sql) ) { exit(_MD_COULDNOTQUERY); } while ( $row = $xoopsDB->fetchArray($r) ) { $posts_to_remove[] = $row['post_id']; } $sql = sprintf("DELETE FROM %s WHERE topic_id = %u", $xoopsDB->prefix("bb_posts"), $topic_id); if ( !$result = $xoopsDB->query($sql) ) { exit(_MD_COULDNOTREMOVE); } $sql= sprintf("DELETE FROM %s WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $topic_id); if ( !$result = $xoopsDB->query($sql) ) { exit(_MD_COULDNOTQUERY); } $sql = "DELETE FROM ".$xoopsDB->prefix("bb_posts_text")." WHERE "; for ( $x = 0; $x < count($posts_to_remove); $x++ ) { if ( $set ) { $sql .= " OR "; } $sql .= "post_id = ".$posts_to_remove[$x]; $set = true; } if ( !$xoopsDB->query($sql) ) { exit(_MD_COULDNOTREMOVETXT); } sync($forum, 'forum'); // RMV-NOTIFY xoops_notification_deletebyitem ($xoopsModule->getVar('mid'), 'thread', $topic_id); echo _MD_TTHBRFTD."
"; break; case 'move': if ($newforum > 0) { $sql = sprintf("UPDATE %s SET forum_id = %u WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $newforum, $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit(_MD_EPGBATA); } $sql = sprintf("UPDATE %s SET forum_id = %u WHERE topic_id = %u", $xoopsDB->prefix("bb_posts"), $newforum, $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit(_MD_EPGBATA); } sync($newforum, 'forum'); sync($forum, 'forum'); } echo _MD_TTHBM.""; break; case 'lock': $sql = sprintf("UPDATE %s SET topic_status = 1 WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit(_MD_EPGBATA); } echo _MD_TTHBL.""; break; case 'unlock': $sql = sprintf("UPDATE %s SET topic_status = 0 WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit("Error - Could not unlock the selected topic. Please go back and try again."); } echo _MD_TTHBU.""; break; case 'sticky': $sql = sprintf("UPDATE %s SET topic_sticky = 1 WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit("Error - Could not sticky the selected topic. Please go back and try again."); } echo _MD_TTHBS.""; break; case 'unsticky': $sql = sprintf("UPDATE %s SET topic_sticky = 0 WHERE topic_id = %u", $xoopsDB->prefix("bb_topics"), $topic_id); if ( !$r = $xoopsDB->query($sql) ) { exit("Error - Could not unsticky the selected topic. Please go back and try again."); } echo _MD_TTHBUS.""; break; } } else { // No submit $mode = $HTTP_GET_VARS['mode']; echo "