[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Messages: View action handler. 4 * 5 * @package BuddyPress 6 * @subpackage MessageActions 7 * @since 3.0.0 8 */ 9 10 /** 11 * Process a request to view a single message thread. 12 * 13 * @return bool False if not a single conversation. 14 */ 15 function messages_action_conversation() { 16 17 // Bail if not viewing a single conversation. 18 if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) { 19 return false; 20 } 21 22 // Get the thread ID from the action variable. 23 $thread_id = (int) bp_action_variable( 0 ); 24 25 if ( ! messages_is_valid_thread( $thread_id ) || ( ! messages_check_thread_access( $thread_id ) && ! bp_current_user_can( 'bp_moderate' ) ) ) { 26 return; 27 } 28 29 // Check if a new reply has been submitted. 30 if ( isset( $_POST['send'] ) ) { 31 32 // Check the nonce. 33 check_admin_referer( 'messages_send_message', 'send_message_nonce' ); 34 35 $new_reply = messages_new_message( array( 36 'thread_id' => $thread_id, 37 'subject' => ! empty( $_POST['subject'] ) ? $_POST['subject'] : false, 38 'content' => $_POST['content'] 39 ) ); 40 41 // Send the reply. 42 if ( ! empty( $new_reply ) ) { 43 bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) ); 44 } else { 45 bp_core_add_message( __( 'There was a problem sending your reply. Please try again.', 'buddypress' ), 'error' ); 46 } 47 48 bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' ); 49 } 50 51 /* 52 * Mark message read, but only run on the logged-in user's profile. 53 * If an admin visits a thread, it shouldn't change the read status. 54 */ 55 if ( bp_is_my_profile() ) { 56 messages_mark_thread_read( $thread_id ); 57 } 58 59 /** 60 * Fires after processing a view request for a single message thread. 61 * 62 * @since 1.7.0 63 */ 64 do_action( 'messages_action_conversation' ); 65 } 66 add_action( 'bp_actions', 'messages_action_conversation' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 22 01:00:54 2024 | Cross-referenced by PHPXref 0.7.1 |