function sp_move_topic() { global $spVars, $spThisUser; $currentforumid = sp_esc_int($_POST['currentforumid']); $currenttopicid = sp_esc_int($_POST['currenttopicid']); $targetforumid = sp_esc_int($_POST['forumid']); if (!sp_get_auth('move_topics', $targetforumid)) { if (!is_user_logged_in()) { $msg = sp_text('Access denied - are you logged in?'); } else { $msg = sp_text('Access denied - you do not have permission'); } sp_notify(SPFAILURE, $msg); return; } # change topic record to new forum id $sql = 'UPDATE ' . SFTOPICS . ' SET forum_id = ' . $targetforumid . "\n\t\t\tWHERE topic_id={$currenttopicid}"; if (spdb_query($sql) == false) { sp_notify(SPFAILURE, sp_text('Topic move failed')); return; } # change posts record(s) to new forum spdb_query('UPDATE ' . SFPOSTS . " SET\n\t\t\t\tforum_id={$targetforumid}\n\t\t\t\tWHERE topic_id={$currenttopicid}"); # update post if in sfwaiting spdb_query("UPDATE " . SFWAITING . " SET forum_id={$targetforumid} WHERE topic_id={$currenttopicid}"); # flush and rebuild topic cache (since one or more posts approved) sp_rebuild_topic_cache(); # rebuild forum counts for old and new forums sp_build_forum_index($currentforumid); sp_build_forum_index($targetforumid); # Ok - do not like doing this but.... # There seems to have been times when a new post is made to the old forum id so we will now double check... $checkposts = spdb_table(SFPOSTS, "forum_id={$currentforumid} AND topic_id={$currenttopicid}", 'post_id'); if ($checkposts) { # made after most were moved sp_move_topic(); } else { sp_notify(SPSUCCESS, sp_text('Topic moved')); # notify author of move $thisTopic = spdb_table(SFTOPICS, "topic_id={$currenttopicid}", 'row'); $sfadminsettings = sp_get_option('sfadminsettings'); if ($sfadminsettings['movenotice'] && $spThisUser->ID != $thisTopic->user_id) { $thisPost = spdb_table(SFPOSTS, "post_id={$thisTopic->post_id}", 'row'); $forumslug = spdb_table(SFFORUMS, "forum_id={$thisTopic->forum_id}", 'forum_slug'); $nData = array(); $nData['user_id'] = $thisTopic->user_id; $nData['guest_email'] = $thisPost->guest_email; $nData['post_id'] = $thisPost->post_id; $nData['link'] = sp_build_url($forumslug, $thisTopic->topic_slug, 1); $nData['link_text'] = $thisTopic->topic_name; $nData['message'] = sp_text('A topic of yours was moved to'); $nData['expires'] = time() + 30 * 24 * 60 * 60; # 30 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); } } do_action('sph_move_topic', $currenttopicid, $currentforumid, $targetforumid, $spThisUser->ID); }
function sp_render_forum($content) { global $spIsForum, $spContentLoaded, $spVars, $spGlobals, $spThisUser, $spStatus; # make sure we are at least in the html body before outputting any content if (!sp_get_option('sfwpheadbypass') && !did_action('wp_head')) { return ''; } if ($spIsForum && !post_password_required(get_post(sp_get_option('sfpage')))) { # Limit forum display to within the wp loop? if (sp_get_option('sfinloop') && !in_the_loop()) { return $content; } # Has forum content already been loaded and are we limiting? if (!sp_get_option('sfmultiplecontent') && $spContentLoaded) { return $content; } $spContentLoaded = true; sp_set_server_timezone(); # offer a way for forum display to be short circuited but always show for admins unless an upgrade $message = sp_abort_display_forum(); $content .= $message; if (!empty($message) && (!$spThisUser->admin || $spStatus != 'ok')) { return $content; } # process query arg actions # check for edit operation. Need tp check for '_x' in case using mobile as buttin is an image if (isset($_POST['editpost']) || isset($_POST['editpost_x'])) { sp_save_edited_post(); } if (isset($_POST['edittopic'])) { sp_save_edited_topic(); } if (isset($_POST['ordertopicpins'])) { sp_promote_pinned_topic(); } if (isset($_POST['makepostreassign'])) { sp_reassign_post(); } if (isset($_POST['approvepost'])) { sp_approve_post(false, sp_esc_int($_POST['approvepost']), $spVars['topicid']); } if (isset($_POST['unapprovepost'])) { sp_unapprove_post(sp_esc_int($_POST['unapprovepost'])); } if (isset($_POST['doqueue'])) { sp_remove_waiting_queue(); } if (isset($_POST['notifyuser'])) { sp_post_notification(sp_esc_str($_POST['sp_notify_user']), sp_esc_str($_POST['message']), sp_esc_int($_POST['postid'])); } # move a topic and redirect to that topic if (isset($_POST['maketopicmove'])) { if (empty($_POST['forumid'])) { sp_notify(1, sp_text('Destination forum not selected')); return; } sp_move_topic(); $forumslug = spdb_table(SFFORUMS, 'forum_id=' . sp_esc_int(sp_esc_int($_POST['forumid'])), 'forum_slug'); $topicslug = spdb_table(SFTOPICS, 'topic_id=' . sp_esc_int(sp_esc_int($_POST['currenttopicid'])), 'topic_slug'); $returnURL = sp_build_url($forumslug, $topicslug, 0); sp_redirect($returnURL); } # move a post and redirect to the post if (isset($_POST['makepostmove1']) || isset($_POST['makepostmove2']) || isset($_POST['makepostmove3'])) { sp_move_post(); if (isset($_POST['makepostmove1'])) { $returnURL = sp_permalink_from_postid(sp_esc_int($_POST['postid'])); sp_redirect($returnURL); } } # cancel a post move if (isset($_POST['cancelpostmove'])) { $meta = sp_get_sfmeta('post_move', 'post_move'); if ($meta) { $id = $meta[0]['meta_id']; sp_delete_sfmeta($id); unset($spGlobals['post_move']); } } # rebuild the forum and post indexes if (isset($_POST['rebuildforum']) || isset($_POST['rebuildtopic'])) { sp_build_post_index(sp_esc_int($_POST['topicid']), true); sp_build_forum_index(sp_esc_int($_POST['forumid']), false); } # Set display mode if topic view (for editing posts) if ($spVars['pageview'] == 'topic' && isset($_POST['postedit'])) { $spVars['displaymode'] = 'edit'; $spVars['postedit'] = $_POST['postedit']; } else { $spVars['displaymode'] = 'posts'; } # clean cache of timed our records sp_clean_cache(); #--Scratch Pad Area---Please Leave Here--------- #--End Scratch Pad Area------------------------- # let other plugins check for posted actions do_action('sph_setup_forum'); # do we use output buffering? $ob = sp_get_option('sfuseob'); if ($ob) { ob_start(); } # set up some stuff before wp page content $content .= sp_display_banner(); $content = apply_filters('sph_before_wp_page_content', $content); # run any other wp filters on page content but exclude ours if (!$ob) { remove_filter('the_content', 'sp_render_forum', 1); $content = apply_filters('the_content', $content); $content = wpautop($content); add_filter('the_content', 'sp_render_forum', 1); } # set up some stuff after wp page content $content = apply_filters('sph_after_wp_page_content', $content); $content .= '<div id="dialogcontainer" style="display:none;"></div>'; $content .= sp_js_check(); # echo any wp page content echo $content; # now add our content do_action('sph_before_template_processing'); sp_process_template(); do_action('sph_after_template_processing'); # Return if using output buffering if ($ob) { $forum = ob_get_contents(); ob_end_clean(); return $forum; } } # not returning any content since we output it already unless password needed if (post_password_required(get_post(sp_get_option('sfpage')))) { return $content; } }