Changeset 9752
- Timestamp:
- 04/15/2015 10:38:41 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp_messages-thread.php
r9714 r9752 207 207 * 208 208 * @since BuddyPress (1.0.0) 209 * 209 * @since BuddyPress (2.3.0) Added $thread_id as a parameter. 210 * 211 * @param int $thread_id The thread ID 210 212 * @return array 211 213 */ 212 public function get_recipients() { 213 global $wpdb; 214 215 $recipients = wp_cache_get( 'thread_recipients_' . $this->thread_id, 'bp_messages' ); 214 public function get_recipients( $thread_id = 0 ) { 215 global $wpdb; 216 217 if ( empty( $thread_id ) ) { 218 $thread_id = $this->thread_id; 219 } 220 221 $recipients = wp_cache_get( 'thread_recipients_' . $thread_id, 'bp_messages' ); 216 222 if ( false === $recipients ) { 217 223 $bp = buddypress(); 218 224 219 225 $recipients = array(); 220 $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $th is->thread_id ) );226 $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$bp->messages->table_name_recipients} WHERE thread_id = %d", $thread_id ) ); 221 227 222 228 foreach ( (array) $results as $recipient ) { … … 224 230 } 225 231 226 wp_cache_set( 'thread_recipients_' . $th is->thread_id, $recipients, 'bp_messages' );232 wp_cache_set( 'thread_recipients_' . $thread_id, $recipients, 'bp_messages' ); 227 233 } 228 234 … … 235 241 * @param int $thread_id ID of the current thread. 236 242 */ 237 return apply_filters( 'bp_messages_thread_get_recipients', $recipients, $th is->thread_id );243 return apply_filters( 'bp_messages_thread_get_recipients', $recipients, $thread_id ); 238 244 } 239 245 240 246 /** Static Functions ******************************************************/ 247 248 /** 249 * Static method to get message recipients by thread ID. 250 * 251 * @since BuddyPress (2.3.0) 252 * 253 * @param int $thread_id The thread ID 254 * @return array 255 */ 256 public static function get_recipients_for_thread( $thread_id = 0 ) { 257 $thread = new self( false ); 258 return $thread->get_recipients( $thread_id ); 259 } 241 260 242 261 /**
Note: See TracChangeset
for help on using the changeset viewer.