Changeset 11310
- Timestamp:
- 12/19/2016 10:51:10 PM (8 years ago)
- Location:
- trunk/src/bp-messages
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-functions.php
r11309 r11310 326 326 * 327 327 * @param int $thread_id ID of the thread. 328 * 329 * @return false|int Number of threads marked as read or false on error. 328 330 */ 329 331 function messages_mark_thread_read( $thread_id ) { … … 337 339 * 338 340 * @param int $thread_id ID of the thread. 341 * 342 * @return false|int Number of threads marked as unread or false on error. 339 343 */ 340 344 function messages_mark_thread_unread( $thread_id ) { -
trunk/src/bp-messages/classes/class-bp-messages-thread.php
r11153 r11310 609 609 * 610 610 * @param int $thread_id The message thread ID. 611 * 612 * @return false|int Number of threads marked as read or false on error. 611 613 */ 612 614 public static function mark_as_read( $thread_id = 0 ) { 613 615 global $wpdb; 614 616 615 $bp = buddypress(); 616 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 617 $wpdb->query( $sql ); 617 $bp = buddypress(); 618 $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 0 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ) ); 618 619 619 620 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 620 621 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 622 623 /** 624 * Fires when messages thread was marked as read. 625 * 626 * @since 2.8.0 627 * 628 * @param int $thread_id The message thread ID. 629 */ 630 do_action( 'messages_thread_mark_as_read', $thread_id ); 631 632 return $retval; 621 633 } 622 634 … … 627 639 * 628 640 * @param int $thread_id The message thread ID. 641 * 642 * @return false|int Number of threads marked as unread or false on error. 629 643 */ 630 644 public static function mark_as_unread( $thread_id = 0 ) { 631 645 global $wpdb; 632 646 633 $bp = buddypress(); 634 $sql = $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ); 635 $wpdb->query( $sql ); 647 $bp = buddypress(); 648 $retval = $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET unread_count = 1 WHERE user_id = %d AND thread_id = %d", bp_loggedin_user_id(), $thread_id ) ); 636 649 637 650 wp_cache_delete( 'thread_recipients_' . $thread_id, 'bp_messages' ); 638 651 wp_cache_delete( bp_loggedin_user_id(), 'bp_messages_unread_count' ); 652 653 /** 654 * Fires when messages thread was marked as unread. 655 * 656 * @since 2.8.0 657 * 658 * @param int $thread_id The message thread ID. 659 */ 660 do_action( 'messages_thread_mark_as_unread', $thread_id ); 661 662 return $retval; 639 663 } 640 664
Note: See TracChangeset
for help on using the changeset viewer.