function sp_post_notification($user, $message, $postid) { global $spThisUser; if (!$spThisUser->admin && !$spThisUser->moderator) { return; } $userid = spdb_table(SFMEMBERS, "display_name='{$user}'", 'user_id'); if (empty($userid)) { return; } $topic_id = spdb_table(SFPOSTS, "post_id={$postid}", 'topic_id'); $nData = array(); $nData['user_id'] = $userid; $nData['guest_email'] = ''; $nData['post_id'] = $postid; $nData['link'] = sp_permalink_from_postid($postid); $nData['link_text'] = spdb_table(SFTOPICS, "topic_id={$topic_id}", 'topic_name'); $nData['message'] = sp_filter_title_save($message); $nData['expires'] = $time; # 30 days; 24 hours; 60 mins; 60secs sp_add_notice($nData); }
function sp_notify_user() { global $spThisUser; $thisPost = sp_esc_int($_GET['pid']); if (empty($thisPost)) { die; } if (!$spThisUser->admin && !$spThisUser->moderator) { if (!is_user_logged_in()) { sp_etext('Access denied - are you logged in?'); } else { sp_etext('Access denied - you do not have permission'); } die; } $site = SFHOMEURL . 'index.php?sp_ahah=admintools&sfnonce=' . wp_create_nonce('forum-ahah') . '&action=notify-search&rand=' . rand(); ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#sp_notify_user').autocomplete({ source : '<?php echo $site; ?> ', disabled : false, delay : 200, minLength: 1, }); }); </script> <div id="spMainContainer" class="spForumToolsPopup"> <div class="spForumToolsHeader"> <div class="spForumToolsHeaderTitle"><?php echo sp_text('Notify user of this post'); ?> </div> </div> <form action="<?php echo sp_permalink_from_postid($thisPost); ?> " method="post" name="notifyuserform"> <div class="spCenter"> <input type="hidden" name="postid" value="<?php echo $thisPost; ?> " /> <label class='spLabel' for='sp_notify_user'><?php sp_etext('User to notify'); ?> : </label> <input type='text' id='sp_notify_user' class='spControl' name='sp_notify_user' /> <p class="spLabelSmall"><?php sp_etext("Start typing a member's name above and it will auto-complete"); ?> </p> <label class='spLabel' for='sp_notify_user'><?php sp_etext('Message'); ?> : </label> <input type='text' id='message' class='spControl' name='message' /> <input type="submit" class="spSubmit" name="notifyuser" value="<?php sp_etext('Notify'); ?> " /> <input type="button" class="spSubmit" name="cancel" value="<?php sp_etext('Cancel'); ?> " onclick="jQuery('#dialog').dialog('close');" /> </div> </form> </div> <?php }
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; } }