Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/17/2011 03:33:32 PM (13 years ago)
Author:
boonebgorges
Message:

Prevents users from posting identical replies to the same forum topic, to prevent flooding and spam. Fixes #3556

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-screens.php

    r5431 r5567  
    145145
    146146                $topic_page = isset( $_GET['topic_page'] ) ? $_GET['topic_page'] : false;
    147 
    148                 if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) )
    149                     bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
    150                 else
    151                     bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
    152 
    153                 if ( isset( $_SERVER['QUERY_STRING'] ) )
    154                     $query_vars = '?' . $_SERVER['QUERY_STRING'];
    155 
    156                 bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic_slug . '/' . $query_vars . '#post-' . $post_id );
     147               
     148                // Don't allow reply flooding
     149                if ( bp_forums_reply_exists( $_POST['reply_text'], $topic_id, bp_loggedin_user_id() ) ) {
     150                    bp_core_add_message( __( 'It looks like you\'ve already said that!', 'buddypress' ), 'error' );
     151                } else {   
     152                    if ( !$post_id = groups_new_group_forum_post( $_POST['reply_text'], $topic_id, $topic_page ) )
     153                        bp_core_add_message( __( 'There was an error when replying to that topic', 'buddypress'), 'error' );
     154                    else
     155                        bp_core_add_message( __( 'Your reply was posted successfully', 'buddypress') );
     156                }
     157
     158                $query_vars = isset( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '';
     159               
     160                $redirect = bp_get_group_permalink( groups_get_current_group() ) . 'forum/topic/' . $topic_slug . '/' . $query_vars;
     161
     162                if ( !empty( $post_id ) ) {
     163                    $redirect .= '#post-' . $post_id;
     164                }
     165
     166                bp_core_redirect( $redirect );
    157167            }
    158168
Note: See TracChangeset for help on using the changeset viewer.