- Timestamp:
- 09/22/2016 01:28:23 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-thread.php
r11028 r11153 327 327 * 328 328 * @since 1.0.0 329 * @since 2.7.0 The $user_id parameter was added. Previously the current user 330 * was always assumed. 329 331 * 330 332 * @param int $thread_id The message thread ID. 333 * @param int $user_id The ID of the user in the thread to mark messages as 334 * deleted for. Defaults to the current logged-in user. 335 * 331 336 * @return bool 332 337 */ 333 public static function delete( $thread_id = 0 ) {338 public static function delete( $thread_id = 0, $user_id = 0 ) { 334 339 global $wpdb; 335 340 336 341 $thread_id = (int) $thread_id; 342 $user_id = (int) $user_id; 343 344 if ( empty( $user_id ) ) { 345 $user_id = bp_loggedin_user_id(); 346 } 337 347 338 348 /** … … 340 350 * 341 351 * @since 2.2.0 352 * @since 2.7.0 The $user_id parameter was added. 342 353 * 343 354 * @param int $thread_id ID of the thread being deleted. 355 * @param int $user_id ID of the user that the thread is being deleted for. 344 356 */ 345 do_action( 'bp_messages_thread_before_mark_delete', $thread_id );357 do_action( 'bp_messages_thread_before_mark_delete', $thread_id, $user_id ); 346 358 347 359 $bp = buddypress(); 348 360 349 361 // Mark messages as deleted 350 // 351 // @todo the reliance on bp_loggedin_user_id() sucks for plugins 352 // refactor this method to accept a $user_id parameter. 353 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) ); 362 $wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) ); 354 363 355 364 // Get the message ids in order to pass to the action. … … 399 408 * 400 409 * @since 2.2.0 410 * @since 2.7.0 The $user_id parameter was added. 401 411 * 402 412 * @param int $thread_id ID of the thread being deleted. 403 413 * @param array $message_ids IDs of messages being deleted. 414 * @param int $user_id ID of the user the threads were deleted for. 404 415 */ 405 do_action( 'bp_messages_thread_after_delete', $thread_id, $message_ids );416 do_action( 'bp_messages_thread_after_delete', $thread_id, $message_ids, $user_id ); 406 417 407 418 return true;
Note: See TracChangeset
for help on using the changeset viewer.