Skip to:
Content

BuddyPress.org

Changeset 8621


Ignore:
Timestamp:
07/15/2014 10:57:17 PM (10 years ago)
Author:
johnjamesjacoby
Message:

Add brackets to conditions and do some general code clean up in bp-messages-actions.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-actions.php

    r8479 r8621  
    2020function messages_action_conversation() {
    2121
    22     if ( !bp_is_messages_component() || !bp_is_current_action( 'view' ) )
     22    // Bail if not viewing a single conversation
     23    if ( ! bp_is_messages_component() || ! bp_is_current_action( 'view' ) ) {
    2324        return false;
     25    }
    2426
    25     $thread_id = (int)bp_action_variable( 0 );
     27    // Get the thread ID from the action variable
     28    $thread_id = (int) bp_action_variable( 0 );
    2629
    27     if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access( $thread_id ) && !bp_current_user_can( 'bp_moderate' ) ) )
     30    if ( ! messages_is_valid_thread( $thread_id ) || ( ! messages_check_thread_access( $thread_id ) && ! bp_current_user_can( 'bp_moderate' ) ) ) {
    2831        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ) );
     32    }
    2933
    3034    // Check if a new reply has been submitted
     
    3438        check_admin_referer( 'messages_send_message', 'send_message_nonce' );
    3539
     40        $new_reply = messages_new_message( array(
     41            'thread_id' => $thread_id,
     42            'subject'   => ! empty( $_POST['subject'] ) ? $_POST['subject'] : false,
     43            'content'   => $_POST['content']
     44        ) );
     45
    3646        // Send the reply
    37         if ( messages_new_message( array( 'thread_id' => $thread_id, 'subject' => ! empty( $_POST['subject'] ) ? $_POST['subject'] : false, 'content' => $_POST['content'] ) ) ) {
     47        if ( ! empty( $new_reply ) ) {
    3848            bp_core_add_message( __( 'Your reply was sent successfully', 'buddypress' ) );
    3949        } else {
     
    5868function messages_action_delete_message() {
    5969
    60     if ( !bp_is_messages_component() || bp_is_current_action( 'notices' ) || !bp_is_action_variable( 'delete', 0 ) )
     70    if ( ! bp_is_messages_component() || bp_is_current_action( 'notices' ) || ! bp_is_action_variable( 'delete', 0 ) ) {
    6171        return false;
     72    }
    6273
    6374    $thread_id = bp_action_variable( 1 );
     
    6677        bp_core_redirect( trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() ) );
    6778    } else {
    68         if ( !check_admin_referer( 'messages_delete_thread' ) )
     79        if ( ! check_admin_referer( 'messages_delete_thread' ) ) {
    6980            return false;
     81        }
    7082
    7183        // Delete message
     
    8799function messages_action_bulk_delete() {
    88100
    89     if ( !bp_is_messages_component() || !bp_is_action_variable( 'bulk-delete', 0 ) )
     101    if ( ! bp_is_messages_component() || ! bp_is_action_variable( 'bulk-delete', 0 ) ) {
    90102        return false;
     103    }
    91104
    92105    $thread_ids = $_POST['thread_ids'];
Note: See TracChangeset for help on using the changeset viewer.