Changeset 9950
- Timestamp:
- 06/16/2015 10:58:07 PM (9 years ago)
- Location:
- branches/2.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.3/src/bp-messages/bp-messages-star.php
r9931 r9950 351 351 */ 352 352 function bp_messages_filter_starred_message_threads( $r = array() ) { 353 $r[' user_id'] = 0;353 $r['box'] = 'starred'; 354 354 $r['meta_query'] = array( array( 355 355 'key' => 'starred_by_user', 356 'value' => bp_loggedin_user_id()356 'value' => $r['user_id'] 357 357 ) ); 358 358 -
branches/2.3/src/bp-messages/classes/class-bp-messages-thread.php
r9949 r9950 456 456 $r['user_id'] = (int) $r['user_id']; 457 457 458 // Default deleted SQL 459 $deleted_sql = 'r.is_deleted = 0'; 460 458 461 switch ( $r['box'] ) { 459 462 case 'sentbox' : … … 463 466 464 467 case 'inbox' : 465 default :466 468 $user_id_sql = 'AND ' . $wpdb->prepare( 'r.user_id = %d', $r['user_id'] ); 467 469 $sender_sql = 'AND r.sender_only = 0'; 470 break; 471 472 // Omit user-deleted threads from all other custom message boxes 473 default : 474 $deleted_sql = $wpdb->prepare( '( r.user_id = %d AND r.is_deleted = 0 )', $r['user_id'] ); 468 475 break; 469 476 } … … 484 491 $sql['select'] = 'SELECT m.thread_id, MAX(m.date_sent) AS date_sent'; 485 492 $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']}"; 486 $sql['where'] = "WHERE r.is_deleted = 0{$user_id_sql} {$sender_sql} {$type_sql} {$search_sql} {$meta_query_sql['where']}";493 $sql['where'] = "WHERE {$deleted_sql} {$user_id_sql} {$sender_sql} {$type_sql} {$search_sql} {$meta_query_sql['where']}"; 487 494 $sql['misc'] = "GROUP BY m.thread_id ORDER BY date_sent DESC {$pag_sql}"; 488 495 -
branches/2.3/tests/phpunit/testcases/messages/star.php
r9846 r9950 108 108 109 109 /** 110 * @group bp_messages_filter_starred_message_threads 111 */ 112 public function test_get_starred_threads_should_not_include_deleted_thread() { 113 $old_current_user = get_current_user_id(); 114 $u1 = $this->factory->user->create(); 115 $u2 = $this->factory->user->create(); 116 117 // create three threads 118 $t1 = $this->factory->message->create( array( 119 'sender_id' => $u1, 120 'recipients' => array( $u2 ), 121 'subject' => 'A', 122 ) ); 123 $t2 = $this->factory->message->create( array( 124 'sender_id' => $u1, 125 'recipients' => array( $u2 ), 126 'subject' => 'B', 127 ) ); 128 $t3 = $this->factory->message->create( array( 129 'sender_id' => $u1, 130 'recipients' => array( $u2 ), 131 'subject' => 'C', 132 ) ); 133 134 // grab the message ids as individual variables 135 list( $m1 ) = $this->get_message_ids( $t1 ); 136 list( $m2 ) = $this->get_message_ids( $t2 ); 137 list( $m3 ) = $this->get_message_ids( $t3 ); 138 139 // star all threads 140 bp_messages_star_set_action( array( 141 'user_id' => $u2, 142 'message_id' => $m1, 143 ) ); 144 bp_messages_star_set_action( array( 145 'user_id' => $u2, 146 'message_id' => $m2, 147 ) ); 148 bp_messages_star_set_action( array( 149 'user_id' => $u2, 150 'message_id' => $m3, 151 ) ); 152 153 // delete the second thread 154 $this->set_current_user( $u2 ); 155 messages_delete_thread( $t2 ); 156 157 // load the starred threads loop 158 global $messages_template; 159 add_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); 160 bp_has_message_threads(); 161 remove_filter( 'bp_after_has_message_threads_parse_args', 'bp_messages_filter_starred_message_threads' ); 162 163 // assert that second thread isn't in starred thread loop 164 $thread_ids = wp_list_pluck( $messages_template->threads, 'thread_id' ); 165 $this->assertFalse( in_array( $t2, $thread_ids ) ); 166 167 // reset 168 $this->set_current_user( $old_current_user ); 169 } 170 171 /** 110 172 * Helper method to grab the message IDs from a message thread. 111 173 *
Note: See TracChangeset
for help on using the changeset viewer.