Changeset 5567
- Timestamp:
- 12/17/2011 03:33:32 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-forums/bp-forums-functions.php
r5305 r5567 302 302 303 303 /** 304 * Check to see whether a user has already left this particular reply on a given post. 305 * Prevents dupes. 306 * 307 * @since 1.6 308 * 309 * @param str $text The text of the comment 310 * @param int $topic_id The topic id 311 * @param int $user_id The user id 312 */ 313 function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) { 314 $reply_exists = false; 315 316 if ( $text && $topic_id && $user_id ) { 317 do_action( 'bbpress_init' ); 318 319 $args = array( 320 'post_author_id' => $user_id, 321 'topic_id' => $topic_id 322 ); 323 324 // BB_Query's post_text parameter does a MATCH, while we need exact matches 325 add_filter( 'get_posts_where', create_function( '$q', 'return $q . " AND p.post_text = \'' . $text . '\'";' ) ); 326 327 $query = new BB_Query( 'post', $args ); 328 329 $reply_exists = !empty( $query->results ); 330 } 331 332 return apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id ); 333 } 334 335 /** 304 336 * Get a total "Topics Started" count for a given user 305 337 * -
trunk/bp-groups/bp-groups-screens.php
r5431 r5567 145 145 146 146 $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 ); 157 167 } 158 168
Note: See TracChangeset
for help on using the changeset viewer.