Skip to:
Content

BuddyPress.org

Changeset 11307


Ignore:
Timestamp:
12/19/2016 10:27:48 PM (7 years ago)
Author:
slaffik
Message:

Messages: improved code formatting for BP_Messages_Message.

Spaces, new lines etc, according to WordPress standards.

See #5193.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/classes/class-bp-messages-message.php

    r11306 r11307  
    7373        $this->sender_id = bp_loggedin_user_id();
    7474
    75         if ( !empty( $id ) ) {
     75        if ( ! empty( $id ) ) {
    7676            $this->populate( $id );
    7777        }
     
    110110        $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id );
    111111        $this->thread_id = apply_filters( 'messages_message_thread_id_before_save', $this->thread_id, $this->id );
    112         $this->subject   = apply_filters( 'messages_message_subject_before_save',   $this->subject,  $this->id );
    113         $this->message   = apply_filters( 'messages_message_content_before_save',   $this->message,  $this->id );
     112        $this->subject   = apply_filters( 'messages_message_subject_before_save', $this->subject, $this->id );
     113        $this->message   = apply_filters( 'messages_message_content_before_save', $this->message, $this->id );
    114114        $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id );
    115115
     
    126126
    127127        // Make sure we have at least one recipient before sending.
    128         if ( empty( $this->recipients ) )
     128        if ( empty( $this->recipients ) ) {
    129129            return false;
     130        }
    130131
    131132        $new_thread = false;
     
    134135        if ( empty( $this->thread_id ) ) {
    135136            $this->thread_id = (int) $wpdb->get_var( "SELECT MAX(thread_id) FROM {$bp->messages->table_name_messages}" ) + 1;
    136             $new_thread = true;
     137            $new_thread      = true;
    137138        }
    138139
    139140        // First insert the message into the messages table.
    140         if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, %s )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )
     141        if ( ! $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, %s )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) ) {
    141142            return false;
     143        }
    142144
    143145        $this->id = $wpdb->insert_id;
     
    153155
    154156            // Add a sender recipient entry if the sender is not in the list of recipients.
    155             if ( !in_array( $this->sender_id, $recipient_ids ) )
     157            if ( ! in_array( $this->sender_id, $recipient_ids ) ) {
    156158                $wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_recipients} ( user_id, thread_id, sender_only ) VALUES ( %d, %d, 1 )", $this->sender_id, $this->thread_id ) );
     159            }
    157160        } else {
    158161            // Update the unread count for all recipients.
     
    228231     *
    229232     * @param int $thread_id ID of the thread.
     233     *
    230234     * @return int|null ID of the message if found, otherwise null.
    231235     */
     
    243247     * Check whether a user is the sender of a message.
    244248     *
    245      * @param int $user_id    ID of the user.
     249     * @param int $user_id ID of the user.
    246250     * @param int $message_id ID of the message.
     251     *
    247252     * @return int|null Returns the ID of the message if the user is the
    248253     *                  sender, otherwise null.
     
    262267     *
    263268     * @param int $message_id ID of the message.
     269     *
    264270     * @return int|null The ID of the sender if found, otherwise null.
    265271     */
Note: See TracChangeset for help on using the changeset viewer.