Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/16/2015 10:59:18 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Messages: Modify message thread queries to exclude messages in deleted threads from "Starred" messages.

This change ensures that deleted messages do not appear in the "Starred" section of a member's private messages. Previously, it was possible to delete a private message thread, and still have it come back to life in the "Starred" messages section.

Fixes #6483. Props r-a-y. (trunk, for 2.4.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/classes/class-bp-messages-thread.php

    r9948 r9951  
    463463        $r['user_id'] = (int) $r['user_id'];
    464464
     465        // Default deleted SQL
     466        $deleted_sql = 'r.is_deleted = 0';
     467
    465468        switch ( $r['box'] ) {
    466469            case 'sentbox' :
     
    470473
    471474            case 'inbox' :
    472             default :
    473475                $user_id_sql = 'AND ' . $wpdb->prepare( 'r.user_id = %d', $r['user_id'] );
    474476                $sender_sql  = 'AND r.sender_only = 0';
     477                break;
     478
     479            default :
     480                // Omit user-deleted threads from all other custom message boxes
     481                $deleted_sql = $wpdb->prepare( '( r.user_id = %d AND r.is_deleted = 0 )', $r['user_id'] );
    475482                break;
    476483        }
     
    491498        $sql['select'] = 'SELECT m.thread_id, MAX(m.date_sent) AS date_sent';
    492499        $sql['from']   = "FROM {$bp->messages->table_name_recipients} r INNER JOIN {$bp->messages->table_name_messages} m ON m.thread_id = r.thread_id {$meta_query_sql['join']}";
    493         $sql['where']  = "WHERE r.is_deleted = 0 {$user_id_sql} {$sender_sql} {$type_sql} {$search_sql} {$meta_query_sql['where']}";
     500        $sql['where']  = "WHERE {$deleted_sql} {$user_id_sql} {$sender_sql} {$type_sql} {$search_sql} {$meta_query_sql['where']}";
    494501        $sql['misc']   = "GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}";
    495502
Note: See TracChangeset for help on using the changeset viewer.