Ticket #4758: 4758.2.patch
| File 4758.2.patch, 1.8 KB (added by , 14 years ago) |
|---|
-
bp-forums/bp-forums-functions.php
352 352 * @param int $user_id The user id 353 353 */ 354 354 function bp_forums_reply_exists( $text = '', $topic_id = 0, $user_id = 0 ) { 355 global $wpdb;356 355 357 356 $reply_exists = false; 358 357 … … 364 363 'topic_id' => $topic_id 365 364 ); 366 365 367 // BB_Query's post_text parameter does a MATCH, while we need exact matches368 add_filter( 'get_posts_where', create_function( '$q', 'return $q . " AND p.post_text = \'' . $wpdb->escape( $text ) . '\'";' ) );366 // Set the reply_exists_text so we can check it in the filter below 367 buddypress()->forums->reply_exists_text = $text; 369 368 369 // BB_Query's post_text parameter does a MATCH, while we need exact matches 370 add_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' ); 370 371 $query = new BB_Query( 'post', $args ); 372 remove_filter( 'get_posts_where', '_bp_forums_reply_exists_posts_where' ); 371 373 372 $reply_exists = !empty( $query->results ); 374 // Cleanup 375 unset( buddypress()->forums->reply_exists_text ); 376 377 $reply_exists = (bool) !empty( $query->results ); 373 378 } 374 379 375 return apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id );380 return (bool) apply_filters( 'bp_forums_reply_exists', $reply_exists, $text, $topic_id, $user_id ); 376 381 } 382 /** 383 * Private one-time-use function used in conjunction with bp_forums_reply_exists() 384 * 385 * @since BuddyPress (1.7) 386 * @access private 387 * @global WPDB $wpdb 388 * @param string $where 389 * @return string 390 */ 391 function _bp_forums_reply_exists_posts_where( $where = '' ) { 392 return $where . " AND p.post_text = '" . buddypress()->forums->reply_exists_text . "'"; 393 } 377 394 378 395 /** 379 396 * Get a total "Topics Started" count for a given user
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)