[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-messages/actions/ -> view.php (source)

   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  function messages_action_conversation() {
  14  
  15      // Bail if not viewing a single conversation.
  16      if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) {
  17          return false;
  18      }
  19  
  20      // Get the thread ID from the action variable.
  21      $thread_id = (int) bp_action_variable( 0 );
  22  
  23      if ( ! messages_is_valid_thread( $thread_id ) || ( ! messages_check_thread_access( $thread_id ) && ! bp_current_user_can( 'bp_moderate' ) ) ) {
  24          return;
  25      }
  26  
  27      // Check if a new reply has been submitted.
  28      if ( isset( $_POST['send'] ) ) {
  29  
  30          // Check the nonce.
  31          check_admin_referer( 'messages_send_message', 'send_message_nonce' );
  32  
  33          $new_reply = messages_new_message( array(
  34              'thread_id' => $thread_id,
  35              'subject'   => ! empty( $_POST['subject'] ) ? $_POST['subject'] : false,
  36              'content'   => $_POST['content']
  37          ) );
  38  
  39          // Send the reply.
  40          if ( ! empty( $new_reply ) ) {
  41              bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
  42          } else {
  43              bp_core_add_message( __( 'There was a problem sending your reply. Please try again.', 'buddypress' ), 'error' );
  44          }
  45  
  46          bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
  47      }
  48  
  49      /*
  50       * Mark message read, but only run on the logged-in user's profile.
  51       * If an admin visits a thread, it shouldn't change the read status.
  52       */
  53      if ( bp_is_my_profile() ) {
  54          messages_mark_thread_read( $thread_id );
  55      }
  56  
  57      /**
  58       * Fires after processing a view request for a single message thread.
  59       *
  60       * @since 1.7.0
  61       */
  62      do_action( 'messages_action_conversation' );
  63  }
  64  add_action( 'bp_actions', 'messages_action_conversation' );


Generated: Mon Oct 21 01:01:35 2019 Cross-referenced by PHPXref 0.7.1