function d3forum_delete_topic($mydirname, $topic_id, $delete_also_posts = true) { global $xoopsModule; $db =& Database::getInstance(); $topic_id = intval($topic_id); // delete posts if ($delete_also_posts) { $sql = "SELECT post_id FROM " . $db->prefix($mydirname . "_posts") . " WHERE topic_id={$topic_id}"; if (!($result = $db->query($sql))) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } while (list($post_id) = $db->fetchRow($result)) { d3forum_delete_post_recursive($mydirname, $post_id); } } // delete notifications about this topic $notification_handler =& xoops_gethandler('notification'); $notification_handler->unsubscribeByItem($xoopsModule->getVar('mid'), 'topic', $topic_id); // delete topic if (!$db->query("DELETE FROM " . $db->prefix($mydirname . "_topics") . " WHERE topic_id={$topic_id}")) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } // delete u2t if (!$db->query("DELETE FROM " . $db->prefix($mydirname . "_users2topics") . " WHERE topic_id={$topic_id}")) { die(_MD_D3FORUM_ERR_SQL . __LINE__); } }
} } if (!empty($_POST['deletepostsok'])) { // TRANSACTION PART if (!$xoopsGTicket->check(true, 'd3forum')) { redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); } // guest's delete (check password) if (empty($uid)) { if (empty($_POST['guest_pass']) || md5($_POST['guest_pass'] . 'd3forum') != $post_row['guest_pass_md5']) { redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?post_id={$post_id}", 2, _MD_D3FORUM_ERR_GUESTPASSMISMATCH); exit; } } require_once dirname(dirname(__FILE__)) . '/include/transact_functions.php'; d3forum_delete_post_recursive($mydirname, $post_id); d3forum_sync_topic($mydirname, $topic_id); if ($topic_row['topic_first_post_id'] == $post_id) { redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?forum_id={$forum_id}", 2, _MD_D3FORUM_MSG_POSTSDELETED); exit; } else { redirect_header(XOOPS_URL . "/modules/{$mydirname}/index.php?topic_id={$topic_id}", 2, _MD_D3FORUM_MSG_POSTSDELETED); exit; } } else { // FORM PART // references to confirm the post will be deleted $reference_message4html = $myts->displayTarea($post_row['post_text'], $post_row['html'], $post_row['smiley'], $post_row['xcode'], $xoopsModuleConfig['allow_textimg'], $post_row['br'], 0, $post_row['number_entity'], $post_row['special_entity']); $reference_time = intval($post_row['post_time']); if (!empty($post_row['guest_name'])) { $reference_name4html = htmlspecialchars($post_row['guest_name'], ENT_QUOTES);