function d3forum_delete_category($mydirname, $cat_id, $delete_also_forums = true)
{
    global $xoopsModule;
    $db =& Database::getInstance();
    $cat_id = intval($cat_id);
    // delete forums
    if ($delete_also_forums) {
        $sql = "SELECT forum_id FROM " . $db->prefix($mydirname . "_forums") . " WHERE cat_id={$cat_id}";
        if (!($result = $db->query($sql))) {
            die(_MD_D3FORUM_ERR_SQL . __LINE__);
        }
        while (list($forum_id) = $db->fetchRow($result)) {
            d3forum_delete_forum($mydirname, $forum_id);
        }
    }
    // delete notifications about this category
    $notification_handler =& xoops_gethandler('notification');
    $notification_handler->unsubscribeByItem($xoopsModule->getVar('mid'), 'category', $cat_id);
    // delete category
    if (!$db->query("DELETE FROM " . $db->prefix($mydirname . "_categories") . " WHERE cat_id={$cat_id}")) {
        die(_MD_D3FORUM_ERR_SQL . __LINE__);
    }
    // delete category_access
    if (!$db->query("DELETE FROM " . $db->prefix($mydirname . "_category_access") . " WHERE cat_id={$cat_id}")) {
        die(_MD_D3FORUM_ERR_SQL . __LINE__);
    }
}
    }
    // options, weight and external_link_format can be modified only by admin
    if (!$isadmin) {
        $_POST['options'] = '';
        $_POST['weight'] = 0;
        $_POST['external_link_format'] = '';
    }
    d3forum_updateforum($mydirname, $forum_id, $isadmin);
    redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?forum_id={$forum_id}", 2, _MD_D3FORUM_MSG_FORUMUPDATED);
    exit;
}
if (isset($_POST['forumman_delete'])) {
    if (!$xoopsGTicket->check(true, 'd3forum')) {
        redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
    }
    d3forum_delete_forum($mydirname, $forum_id);
    redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?cat_id={$cat_id}", 2, _MD_D3FORUM_MSG_FORUMDELETED);
    exit;
}
if (!empty($_POST['forumman_export_copy']) || !empty($_POST['forumman_export_move'])) {
    require_once dirname(dirname(__FILE__)) . '/include/import_functions.php';
    if (!$xoopsGTicket->check(true, 'd3forum')) {
        redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors());
    }
    $export_mid = intval(@$_POST['export_mid']);
    $export_cat_id = intval(@$_POST['export_cat_id'][$export_mid]);
    if (!empty($exportable_modules[$export_mid]) && $export_cat_id > 0) {
        d3forum_export_forum_to_d3forum($mydirname, $export_mid, $export_cat_id, $cat_id, $forum_id, !empty($_POST['forumman_export_move']));
        redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?cat_id={$cat_id}", 2, _MD_D3FORUM_MSG_FORUMUPDATED);
        exit;
    }