- Timestamp:
- 12/19/2016 10:27:48 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/classes/class-bp-messages-message.php
r11306 r11307 73 73 $this->sender_id = bp_loggedin_user_id(); 74 74 75 if ( ! empty( $id ) ) {75 if ( ! empty( $id ) ) { 76 76 $this->populate( $id ); 77 77 } … … 110 110 $this->sender_id = apply_filters( 'messages_message_sender_id_before_save', $this->sender_id, $this->id ); 111 111 $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 ); 114 114 $this->date_sent = apply_filters( 'messages_message_date_sent_before_save', $this->date_sent, $this->id ); 115 115 … … 126 126 127 127 // Make sure we have at least one recipient before sending. 128 if ( empty( $this->recipients ) ) 128 if ( empty( $this->recipients ) ) { 129 129 return false; 130 } 130 131 131 132 $new_thread = false; … … 134 135 if ( empty( $this->thread_id ) ) { 135 136 $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; 137 138 } 138 139 139 140 // 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 ) ) ) { 141 142 return false; 143 } 142 144 143 145 $this->id = $wpdb->insert_id; … … 153 155 154 156 // 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 ) ) { 156 158 $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 } 157 160 } else { 158 161 // Update the unread count for all recipients. … … 228 231 * 229 232 * @param int $thread_id ID of the thread. 233 * 230 234 * @return int|null ID of the message if found, otherwise null. 231 235 */ … … 243 247 * Check whether a user is the sender of a message. 244 248 * 245 * @param int $user_id 249 * @param int $user_id ID of the user. 246 250 * @param int $message_id ID of the message. 251 * 247 252 * @return int|null Returns the ID of the message if the user is the 248 253 * sender, otherwise null. … … 262 267 * 263 268 * @param int $message_id ID of the message. 269 * 264 270 * @return int|null The ID of the sender if found, otherwise null. 265 271 */
Note: See TracChangeset
for help on using the changeset viewer.