case 'move': if ($newforum > 0) { $sql = "SELECT * FROM " . $xoopsDB->prefix("xhnewbb_forums") . " WHERE forum_id={$newforum}"; if (!($r = $xoopsDB->query($sql)) || $xoopsDB->getRowsNum($r) != 1) { exit(_MD_XHNEWBB_EPGBATA); } $sql = sprintf("UPDATE %s SET forum_id = %u WHERE topic_id = %u", $xoopsDB->prefix("xhnewbb_topics"), $newforum, $topic_id); if (!($r = $xoopsDB->query($sql))) { exit(_MD_XHNEWBB_EPGBATA); } $sql = sprintf("UPDATE %s SET forum_id = %u WHERE topic_id = %u", $xoopsDB->prefix("xhnewbb_posts"), $newforum, $topic_id); if (!($r = $xoopsDB->query($sql))) { exit(_MD_XHNEWBB_EPGBATA); } xhnewbb_sync($newforum, 'forum'); xhnewbb_sync($forum, 'forum'); } echo _MD_XHNEWBB_TTHBM . "<p><a href='" . XOOPS_URL . "/modules/xhnewbb/viewtopic.php?topic_id={$topic_id}'>" . _MD_XHNEWBB_VTUT . "</a></p><p><a href='" . XOOPS_URL . "/modules/xhnewbb/index.php'>" . _MD_XHNEWBB_RTTFI . "</a></p>"; break; case 'lock': $sql = sprintf("UPDATE %s SET topic_status = 1 WHERE topic_id = %u", $xoopsDB->prefix("xhnewbb_topics"), $topic_id); if (!($r = $xoopsDB->query($sql))) { exit(_MD_XHNEWBB_EPGBATA); } echo _MD_XHNEWBB_TTHBL . "<p><a href='" . XOOPS_URL . "/modules/xhnewbb/viewtopic.php?topic_id={$topic_id}'>" . _MD_XHNEWBB_VIEWTHETOPIC . "</a></p><p><a href='" . XOOPS_URL . "/modules/xhnewbb/index.php'>" . _MD_XHNEWBB_RTTFI . "</a></p>"; break; case 'unlock': $sql = sprintf("UPDATE %s SET topic_status = 0 WHERE topic_id = %u", $xoopsDB->prefix("xhnewbb_topics"), $topic_id); if (!($r = $xoopsDB->query($sql))) { exit("Error - Could not unlock the selected topic. Please go back and try again."); }
} $new_topic_id = intval($targetpost->topic()); $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET pid={$pid} WHERE post_id={$post_id}"; if (!$xoopsDB->query($sql)) { die(_MD_XHNEWBB_DATABASEERROR); } } foreach ($children as $child_post_id) { $child_post_id = intval($child_post_id); $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_posts") . " SET topic_id={$new_topic_id},forum_id={$new_forum} WHERE post_id={$child_post_id}"; $xoopsDB->query($sql); } xhnewbb_sync($new_forum, "forum"); xhnewbb_sync($forum, "forum"); xhnewbb_sync($topic_id, "topic"); xhnewbb_sync($new_topic_id, "topic"); redirect_header(XOOPS_URL . "/modules/xhnewbb/viewtopic.php?topic_id={$new_topic_id}", 2, _MD_XHNEWBB_CUTPASTESUCCESS); exit; } else { // FORM PART include XOOPS_ROOT_PATH . "/header.php"; $xoopsOption['template_main'] = 'xhnewbb_cutpasteposts.html'; // references to confirm the post will be cut/paste $reference_message4html = $forumpost->text('Show'); $reference_date4html = formatTimestamp($forumpost->posttime()); $reference_name4html = $forumpost->uid() ? XoopsUser::getUnameFromId($forumpost->uid()) : $xoopsConfig['anonymous']; $reference_subject4html = $forumpost->subject('Show'); $xoopsTpl->assign(array('post_id' => $post_id, 'topic_id' => $topic_id, 'forum' => $forum, 'forumdata' => $forumdata, 'reference_subject' => @$reference_subject4html, 'reference_message' => @$reference_message4html, 'reference_name' => @$reference_name4html, 'reference_date' => @$reference_date4html, 'children_count' => count($children), 'forum_index_title' => _MD_XHNEWBB_FORUMINDEX, 'lang_alltopicsindex' => _MD_XHNEWBB_ALLTOPICSINDEX, 'mod_url' => XOOPS_URL . '/modules/xhnewbb', 'img_hotfolder' => $bbImage['newposts_forum'])); $xoopsTpl->assign(array("xoops_module_header" => "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" . $xoopsModuleConfig['xhnewbb_css_uri'] . "\" />" . $xoopsTpl->get_template_vars("xoops_module_header"), "xoops_pagetitle" => _MD_XHNEWBB_CUTPASTEPOSTS)); include XOOPS_ROOT_PATH . '/footer.php'; }
} } else { // after time limit redirect_header(XOOPS_URL . "/modules/xhnewbb/viewtopic.php?topic_id={$topic_id}&viewmode={$viewmode}&order={$order}", 2, _MD_XHNEWBB_DELTIMELIMITED); exit; } } else { // no perm die(_MD_XHNEWBB_DELNOTALLOWED); } } if (!empty($_POST['deletepostsok'])) { // TRANSACTION PART $forumpost->delete(); xhnewbb_sync($forumpost->forum(), "forum"); xhnewbb_sync($forumpost->topic(), "topic"); if ($forumpost->istopic()) { redirect_header(XOOPS_URL . "/modules/xhnewbb/viewforum.php?forum={$forum}", 2, _MD_XHNEWBB_POSTSDELETED); exit; } else { redirect_header(XOOPS_URL . "/modules/xhnewbb/viewtopic.php?topic_id={$topic_id}&viewmode={$viewmode}&order={$order}", 2, _MD_XHNEWBB_POSTSDELETED); exit; } } else { // FORM PART include XOOPS_ROOT_PATH . "/header.php"; $xoopsOption['template_main'] = 'xhnewbb_delete.html'; // references to confirm the post will be deleted $reference_message4html = $forumpost->text('Show'); $reference_date4html = formatTimestamp($forumpost->posttime()); $reference_name4html = $forumpost->uid() ? XoopsUser::getUnameFromId($forumpost->uid()) : $xoopsConfig['anonymous'];
} echo "\">\n"; echo "<input type=\"hidden\" name=\"current_order\" value=\"" . $m['cat_order'] . "\"><input type=\"submit\" name=\"up\" value=\"" . _MD_XHNEWBB_A_MOVEUP . "\"></td>\n"; echo "<td><input type=\"submit\" name=\"down\" value=\"" . _MD_XHNEWBB_A_MOVEDOWN . "\"></td></tr></form>\n<!-- End of Row -->\n"; $last_id = $m['cat_id']; } ?> </TABLE></TABLE> <?php break; case 'sync': if (!empty($_POST['submit'])) { flush(); xhnewbb_sync(null, "all forums"); flush(); xhnewbb_sync(null, "all topics"); redirect_header("./index.php", 1, _MD_XHNEWBB_A_SYNCHING); } else { xoops_cp_header(); include './mymenu.php'; echo "<table width='100%' border='0' cellspacing='1' class='outer'>" . "<tr><td class=\"odd\">"; echo "<a href='./index.php'><h4>" . _MD_XHNEWBB_A_FORUMCONF . "</h4></a>"; ?> <table border="0" cellpadding="1" cellspacing="0" align="center" width="95%"><tr><td class='bg2'> <table border="0" cellpadding="1" cellspacing="1" width="100%"> <tr class='bg3' align='left'> <td><?php echo _MD_XHNEWBB_A_CLICKBELOWSYNC; ?> </td> </tr>
function xhnewbb_sync($id, $type) { global $xoopsDB; $id = intval($id); switch ($type) { case 'forum': $sql = "SELECT MAX(post_id) AS last_post FROM " . $xoopsDB->prefix("xhnewbb_posts") . " WHERE forum_id = {$id}"; if (!($result = $xoopsDB->query($sql))) { exit("Could not get post ID"); } if ($row = $xoopsDB->fetchArray($result)) { $last_post = $row['last_post']; } $sql = "SELECT COUNT(post_id) AS total FROM " . $xoopsDB->prefix("xhnewbb_posts") . " WHERE forum_id = {$id}"; if (!($result = $xoopsDB->query($sql))) { exit("Could not get post count"); } if ($row = $xoopsDB->fetchArray($result)) { $total_posts = $row['total']; } $sql = "SELECT COUNT(topic_id) AS total FROM " . $xoopsDB->prefix("xhnewbb_topics") . " WHERE forum_id = {$id}"; if (!($result = $xoopsDB->query($sql))) { exit("Could not get topic count"); } if ($row = $xoopsDB->fetchArray($result)) { $total_topics = $row['total']; } $sql = sprintf("UPDATE %s SET forum_last_post_id = %u, forum_posts = %u, forum_topics = %u WHERE forum_id = %u", $xoopsDB->prefix("xhnewbb_forums"), $last_post, $total_posts, $total_topics, $id); if (!($result = $xoopsDB->queryF($sql))) { exit("Could not update forum {$id}"); } break; case 'topic': $sql = "SELECT MAX(post_id),COUNT(post_id) FROM " . $xoopsDB->prefix("xhnewbb_posts") . " WHERE topic_id = {$id}"; if (!($result = $xoopsDB->query($sql))) { exit("Could not get post ID"); } list($last_post_id, $total_posts) = $xoopsDB->fetchRow($result); if ($last_post_id > 0) { $sql = "SELECT post_time FROM " . $xoopsDB->prefix("xhnewbb_posts") . " WHERE post_id = {$last_post_id}"; if (!($result = $xoopsDB->query($sql))) { exit("Could not get post ID"); } list($topic_time) = $xoopsDB->fetchRow($result); $sql = "UPDATE " . $xoopsDB->prefix("xhnewbb_topics") . " SET topic_replies = " . ($total_posts - 1) . ", topic_last_post_id = {$last_post_id}, topic_time={$topic_time} WHERE topic_id = {$id}"; if (!($result = $xoopsDB->queryF($sql))) { exit("Could not update topic {$id}"); } } break; case 'all forums': $sql = "SELECT forum_id FROM " . $xoopsDB->prefix("xhnewbb_forums"); if (!($result = $xoopsDB->query($sql))) { exit("Could not get forum IDs"); } while ($row = $xoopsDB->fetchArray($result)) { $id = $row['forum_id']; xhnewbb_sync($id, "forum"); } break; case 'all topics': $sql = "SELECT topic_id FROM " . $xoopsDB->prefix("xhnewbb_topics"); if (!($result = $xoopsDB->query($sql))) { exit("Could not get topic ID's"); } while ($row = $xoopsDB->fetchArray($result)) { $id = $row['topic_id']; xhnewbb_sync($id, "topic"); } break; } return true; }