Beispiel #1
0
<?php

require_once 'config.php';
$session->requireAdmin();
if (empty($_GET['id']) || !is_numeric($_GET['id'])) {
    die;
}
//invalid request
$itemId = $_GET['id'];
require 'design_head.php';
echo xhtmlMenu($forum_menu, 'blog_menu');
echo getForumDepthHTML(FORUM_FOLDER, $itemId);
$item = getForumItem($itemId);
if ($item) {
    echo showForumPost($item, '', false);
}
if (confirmed('Are you sure you want to delete this forum post?', 'id', $itemId)) {
    deleteForumItemRecursive($itemId);
    echo 'The forum and all subforums has been deleted';
}
require 'design_foot.php';
/**
 * Deletes itemId and everything below it. also deletes associated moderation queue entries
 */
function deleteForumItemRecursive($itemId, $loop = false)
{
    global $db;
    if (!is_numeric($itemId)) {
        return false;
    }
    $q = 'SELECT itemId FROM tblForums WHERE parentId=' . $itemId . ' AND deletedBy=0';
    $arr = $db->getArray($q);
    foreach ($arr as $row) {
        $q = 'DELETE FROM tblForums WHERE itemId=' . $row['itemId'];
        if ($db->delete($q)) {
            removeFromModerationQueueByType(MODERATION_FORUM, $row['itemId']);
            deleteForumItemRecursive($row['itemId'], true);
        }
    }
    if ($loop != true) {
        $q = 'DELETE FROM tblForums WHERE itemId=' . $itemId;
        if ($db->delete($q)) {
            removeFromModerationQueueByType(MODERATION_FORUM, $itemId);
        }
    }
}