<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][3760] trunk/bp-messages: Some messages code clean-up</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>3760</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-01-20 11:43:41 +0000 (Thu, 20 Jan 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Some messages code clean-up</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmessagesbpmessagesclassesphp">trunk/bp-messages/bp-messages-classes.php</a></li>
<li><a href="#trunkbpmessagesbpmessagesfunctionsphp">trunk/bp-messages/bp-messages-functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpmessagesbpmessagesclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-classes.php (3759 => 3760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-classes.php        2011-01-20 11:30:23 UTC (rev 3759)
+++ trunk/bp-messages/bp-messages-classes.php        2011-01-20 11:43:41 UTC (rev 3760)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx">                         $order= 'ASC';
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;messages_order = $order;
</span><del>-                $this-&gt;thread_id = $thread_id;
</del><ins>+                $this-&gt;thread_id      = $thread_id;
</ins><span class="cx"> 
</span><span class="cx">                 if ( !$this-&gt;messages = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;messages-&gt;table_name_messages} WHERE thread_id = %d ORDER BY date_sent &quot; . $order, $this-&gt;thread_id ) ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -28,10 +28,10 @@
</span><span class="cx">                 foreach ( (array)$this-&gt;messages as $key =&gt; $message )
</span><span class="cx">                         $this-&gt;sender_ids[$message-&gt;sender_id] = $message-&gt;sender_id;
</span><span class="cx"> 
</span><del>-                /* Fetch the recipients */
</del><ins>+                // Fetch the recipients
</ins><span class="cx">                 $this-&gt;recipients = $this-&gt;get_recipients();
</span><span class="cx"> 
</span><del>-                /* Get the unread count for the logged in user */
</del><ins>+                // Get the unread count for the logged in user
</ins><span class="cx">                 if ( isset( $this-&gt;recipients[$bp-&gt;loggedin_user-&gt;id] ) )
</span><span class="cx">                         $this-&gt;unread_count = $this-&gt;recipients[$bp-&gt;loggedin_user-&gt;id]-&gt;unread_count;
</span><span class="cx">         }
</span><span class="lines">@@ -67,10 +67,10 @@
</span><span class="cx">                 $recipients = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;messages-&gt;table_name_recipients} WHERE thread_id = %d AND is_deleted = 0&quot;, $thread_id ) );
</span><span class="cx"> 
</span><span class="cx">                 if ( empty( $recipients ) ) {
</span><del>-                        /* Delete all the messages */
</del><ins>+                        // Delete all the messages
</ins><span class="cx">                         $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;messages-&gt;table_name_messages} WHERE thread_id = %d&quot;, $thread_id ) );
</span><span class="cx"> 
</span><del>-                        /* Delete all the recipients */
</del><ins>+                        // Delete all the recipients
</ins><span class="cx">                         $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;messages-&gt;table_name_recipients} WHERE thread_id = %d&quot;, $thread_id ) );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -80,11 +80,10 @@
</span><span class="cx">         function get_current_threads_for_user( $user_id, $box = 'inbox', $type = 'all', $limit = null, $page = null ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><del>-                $pag_sql = '';
</del><ins>+                $pag_sql = $type_sql = '';
</ins><span class="cx">                 if ( $limit &amp;&amp; $page )
</span><span class="cx">                         $pag_sql = $wpdb-&gt;prepare( &quot; LIMIT %d, %d&quot;, intval( ( $page - 1 ) * $limit), intval( $limit ) );
</span><span class="cx"> 
</span><del>-                $type_sql = '';
</del><span class="cx">                 if ( $type == 'unread' )
</span><span class="cx">                         $type_sql = $wpdb-&gt;prepare( &quot; AND r.unread_count != 0 &quot; );
</span><span class="cx">                 elseif ( $type == 'read' )
</span><span class="lines">@@ -101,12 +100,12 @@
</span><span class="cx">                 if ( empty( $thread_ids ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><del>-                /* Sort threads by date_sent */
-                foreach( (array)$thread_ids as $thread ) {
-                        $sorted_threads[$thread-&gt;thread_id] = strtotime($thread-&gt;date_sent);
-                }
-                arsort($sorted_threads);
</del><ins>+                // Sort threads by date_sent
+                foreach( (array)$thread_ids as $thread )
+                        $sorted_threads[$thread-&gt;thread_id] = strtotime( $thread-&gt;date_sent );
</ins><span class="cx"> 
</span><ins>+                arsort( $sorted_threads );
+
</ins><span class="cx">                 $threads = false;
</span><span class="cx">                 foreach ( (array)$sorted_threads as $thread_id =&gt; $date_sent )
</span><span class="cx">                         $threads[] = new BP_Messages_Thread( $thread_id );
</span><span class="lines">@@ -172,17 +171,17 @@
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 $count = 0;
</span><del>-                for ( $i = 0; $i &lt; count($unread_counts); $i++ ) {
</del><ins>+                for ( $i = 0; $i &lt; count( $unread_counts ); $i++ ) {
</ins><span class="cx">                         $count += $unread_counts[$i]-&gt;unread_count;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="cx">                 return $count;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function check_access( $thread_id, $user_id = false ) {
</del><ins>+        function check_access( $thread_id, $user_id = 0 ) {
</ins><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><del>-                if ( !$user_id )
</del><ins>+                if ( empty( $user_id ) )
</ins><span class="cx">                         $user_id = $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx"> 
</span><span class="cx">                 return $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;messages-&gt;table_name_recipients} WHERE thread_id = %d AND user_id = %d&quot;, $thread_id, $user_id ) );
</span><span class="lines">@@ -198,14 +197,13 @@
</span><span class="cx">                 if ( count($recipients) &gt;= 5 )
</span><span class="cx">                         return count( $recipients ) . __(' Recipients', 'buddypress');
</span><span class="cx"> 
</span><del>-                foreach ( (array)$recipients as $recipient ) {
</del><ins>+                foreach ( (array)$recipients as $recipient )
</ins><span class="cx">                         $recipient_links[] = bp_core_get_userlink( $recipient-&gt;user_id );
</span><del>-                }
</del><span class="cx"> 
</span><span class="cx">                 return implode( ', ', (array) $recipient_links );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        /* Update Functions */
</del><ins>+        // Update Functions
</ins><span class="cx"> 
</span><span class="cx">         function update_tables() {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="lines">@@ -213,7 +211,7 @@
</span><span class="cx">                 $errors = false;
</span><span class="cx">                 $threads = $wpdb-&gt;get_results( $wpdb-&gt;prepare( &quot;SELECT * FROM {$wpdb-&gt;base_prefix}bp_messages_threads&quot; ) );
</span><span class="cx"> 
</span><del>-                /* Nothing to update, just return true to remove the table */
</del><ins>+                // Nothing to update, just return true to remove the table
</ins><span class="cx">                 if ( empty( $threads ) )
</span><span class="cx">                         return true;
</span><span class="cx"> 
</span><span class="lines">@@ -223,7 +221,7 @@
</span><span class="cx">                         if ( !empty( $message_ids ) ) {
</span><span class="cx">                                 $message_ids = implode( ',', $message_ids );
</span><span class="cx"> 
</span><del>-                                /* Add the thread_id to the messages table */
</del><ins>+                                // Add the thread_id to the messages table
</ins><span class="cx">                                 if ( !$wpdb-&gt;query( $wpdb-&gt;prepare( &quot;UPDATE {$bp-&gt;messages-&gt;table_name_messages} SET thread_id = %d WHERE id IN ({$message_ids})&quot;, $thread-&gt;id ) ) )
</span><span class="cx">                                         $errors = true;
</span><span class="cx">                         }
</span><span class="lines">@@ -252,20 +250,19 @@
</span><span class="cx">                 $this-&gt;date_sent = bp_core_current_time();
</span><span class="cx">                 $this-&gt;sender_id = $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx"> 
</span><del>-                if ( $id ) {
-                        $this-&gt;populate($id);
-                }
</del><ins>+                if ( !empty( $id ) )
+                        $this-&gt;populate( $id );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function populate( $id ) {
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 if ( $message = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;messages-&gt;table_name_messages} WHERE id = %d&quot;, $id ) ) ) {
</span><del>-                        $this-&gt;id = $message-&gt;id;
</del><ins>+                        $this-&gt;id        = $message-&gt;id;
</ins><span class="cx">                         $this-&gt;thread_id = $message-&gt;thread_id;
</span><span class="cx">                         $this-&gt;sender_id = $message-&gt;sender_id;
</span><del>-                        $this-&gt;subject = $message-&gt;subject;
-                        $this-&gt;message = $message-&gt;message;
</del><ins>+                        $this-&gt;subject   = $message-&gt;subject;
+                        $this-&gt;message   = $message-&gt;message;
</ins><span class="cx">                         $this-&gt;date_sent = $message-&gt;date_sent;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -275,19 +272,19 @@
</span><span class="cx"> 
</span><span class="cx">                 $this-&gt;sender_id = apply_filters( 'messages_message_sender_id_before_save', $this-&gt;sender_id, $this-&gt;id );
</span><span class="cx">                 $this-&gt;thread_id = apply_filters( 'messages_message_thread_id_before_save', $this-&gt;thread_id, $this-&gt;id );
</span><del>-                $this-&gt;subject = apply_filters( 'messages_message_subject_before_save', $this-&gt;subject, $this-&gt;id );
-                $this-&gt;message = apply_filters( 'messages_message_content_before_save', $this-&gt;message, $this-&gt;id );
</del><ins>+                $this-&gt;subject   = apply_filters( 'messages_message_subject_before_save', $this-&gt;subject, $this-&gt;id );
+                $this-&gt;message   = apply_filters( 'messages_message_content_before_save', $this-&gt;message, $this-&gt;id );
</ins><span class="cx">                 $this-&gt;date_sent = apply_filters( 'messages_message_date_sent_before_save', $this-&gt;date_sent, $this-&gt;id );
</span><span class="cx"> 
</span><span class="cx">                 do_action( 'messages_message_before_save', $this );
</span><span class="cx"> 
</span><del>-                /* Make sure we have at least one recipient before sending. */
</del><ins>+                // Make sure we have at least one recipient before sending.
</ins><span class="cx">                 if ( empty( $this-&gt;recipients ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 $new_thread = false;
</span><span class="cx"> 
</span><del>-                /* If we have no thread_id then this is the first message of a new thread. */
</del><ins>+                // If we have no thread_id then this is the first message of a new thread.
</ins><span class="cx">                 if ( empty( $this-&gt;thread_id ) ) {
</span><span class="cx">                         $this-&gt;thread_id = (int)$wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT MAX(thread_id) FROM {$bp-&gt;messages-&gt;table_name_messages}&quot; ) ) + 1;
</span><span class="cx">                         $new_thread = true;
</span><span class="lines">@@ -298,15 +295,15 @@
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 if ( $new_thread ) {
</span><del>-                        /* Add an recipient entry for all recipients */
</del><ins>+                        // Add an recipient entry for all recipients
</ins><span class="cx">                         foreach ( (array)$this-&gt;recipients as $recipient )
</span><span class="cx">                                 $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;INSERT INTO {$bp-&gt;messages-&gt;table_name_recipients} ( user_id, thread_id, unread_count ) VALUES ( %d, %d, 1 )&quot;, $recipient-&gt;user_id, $this-&gt;thread_id ) );
</span><span class="cx"> 
</span><del>-                        /* Add a sender recipient entry if the sender is not in the list of recipients */
</del><ins>+                        // Add a sender recipient entry if the sender is not in the list of recipients
</ins><span class="cx">                         if ( !in_array( $this-&gt;sender_id, $this-&gt;recipients ) )
</span><span class="cx">                                 $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;INSERT INTO {$bp-&gt;messages-&gt;table_name_recipients} ( user_id, thread_id, sender_only ) VALUES ( %d, %d, 1 )&quot;, $this-&gt;sender_id, $this-&gt;thread_id ) );
</span><span class="cx">                 } else {
</span><del>-                        /* Update the unread count for all recipients */
</del><ins>+                        // Update the unread count for all recipients
</ins><span class="cx">                         $wpdb-&gt;query( $wpdb-&gt;prepare( &quot;UPDATE {$bp-&gt;messages-&gt;table_name_recipients} SET unread_count = unread_count + 1, sender_only = 0, is_deleted = 0 WHERE thread_id = %d AND user_id != %d&quot;, $this-&gt;thread_id, $this-&gt;sender_id ) );
</span><span class="cx">                 }
</span><span class="cx"> 
</span><span class="lines">@@ -364,7 +361,7 @@
</span><span class="cx">         var $date_sent;
</span><span class="cx">         var $is_active;
</span><span class="cx"> 
</span><del>-        function bp_messages_notice($id = null) {
</del><ins>+        function bp_messages_notice( $id = null ) {
</ins><span class="cx">                 if ( $id ) {
</span><span class="cx">                         $this-&gt;id = $id;
</span><span class="cx">                         $this-&gt;populate($id);
</span><span class="lines">@@ -377,8 +374,8 @@
</span><span class="cx">                 $notice = $wpdb-&gt;get_row( $wpdb-&gt;prepare( &quot;SELECT * FROM {$bp-&gt;messages-&gt;table_name_notices} WHERE id = %d&quot;, $this-&gt;id ) );
</span><span class="cx"> 
</span><span class="cx">                 if ( $notice ) {
</span><del>-                        $this-&gt;subject = $notice-&gt;subject;
-                        $this-&gt;message = $notice-&gt;message;
</del><ins>+                        $this-&gt;subject   = $notice-&gt;subject;
+                        $this-&gt;message   = $notice-&gt;message;
</ins><span class="cx">                         $this-&gt;date_sent = $notice-&gt;date_sent;
</span><span class="cx">                         $this-&gt;is_active = $notice-&gt;is_active;
</span><span class="cx">                 }
</span><span class="lines">@@ -392,13 +389,12 @@
</span><span class="cx"> 
</span><span class="cx">                 do_action( 'messages_notice_before_save', $this );
</span><span class="cx"> 
</span><del>-                if ( !$this-&gt;id ) {
</del><ins>+                if ( empty( $this-&gt;id ) )
</ins><span class="cx">                         $sql = $wpdb-&gt;prepare( &quot;INSERT INTO {$bp-&gt;messages-&gt;table_name_notices} (subject, message, date_sent, is_active) VALUES (%s, %s, %s, %d)&quot;, $this-&gt;subject, $this-&gt;message, $this-&gt;date_sent, $this-&gt;is_active );
</span><del>-                } else {
</del><ins>+                else
</ins><span class="cx">                         $sql = $wpdb-&gt;prepare( &quot;UPDATE {$bp-&gt;messages-&gt;table_name_notices} SET subject = %s, message = %s, is_active = %d WHERE id = %d&quot;, $this-&gt;subject, $this-&gt;message, $this-&gt;is_active, $this-&gt;id );
</span><del>-                }
</del><span class="cx"> 
</span><del>-                if ( !$wpdb-&gt;query($sql) )
</del><ins>+                if ( !$wpdb-&gt;query( $sql ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 if ( !$id = $this-&gt;id )
</span><span class="lines">@@ -435,7 +431,7 @@
</span><span class="cx"> 
</span><span class="cx">                 $sql = $wpdb-&gt;prepare( &quot;DELETE FROM {$bp-&gt;messages-&gt;table_name_notices} WHERE id = %d&quot;, $this-&gt;id );
</span><span class="cx"> 
</span><del>-                if ( !$wpdb-&gt;query($sql) )
</del><ins>+                if ( !$wpdb-&gt;query( $sql ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 return true;
</span><span class="lines">@@ -462,7 +458,7 @@
</span><span class="cx">                 global $wpdb, $bp;
</span><span class="cx"> 
</span><span class="cx">                 $notice_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare( &quot;SELECT id FROM {$bp-&gt;messages-&gt;table_name_notices} WHERE is_active = 1&quot;) );
</span><del>-                return new BP_Messages_Notice($notice_id);
</del><ins>+                return new BP_Messages_Notice( $notice_id );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpmessagesbpmessagesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-functions.php (3759 => 3760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-functions.php        2011-01-20 11:30:23 UTC (rev 3759)
+++ trunk/bp-messages/bp-messages-functions.php        2011-01-20 11:43:41 UTC (rev 3760)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">         $r = wp_parse_args( $args, $defaults );
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx"> 
</span><del>-        if ( !$sender_id || !$content )
</del><ins>+        if ( empty( $sender_id ) || empty( $content ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         // Create a new message object
</span><span class="lines">@@ -34,7 +34,7 @@
</span><span class="cx">         $message-&gt;date_sent = $date_sent;
</span><span class="cx"> 
</span><span class="cx">         // If we have a thread ID, use the existing recipients, otherwise use the recipients passed
</span><del>-        if ( $thread_id ) {
</del><ins>+        if ( !empty( $thread_id ) ) {
</ins><span class="cx">                 $thread = new BP_Messages_Thread( $thread_id );
</span><span class="cx">                 $message-&gt;recipients = $thread-&gt;get_recipients();
</span><span class="cx"> 
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx"> 
</span><span class="cx">                 // Format this to match existing recipients
</span><span class="cx">                 foreach( (array)$recipient_ids as $i =&gt; $recipient_id ) {
</span><del>-                        $message-&gt;recipients[$i] = new stdClass;
</del><ins>+                        $message-&gt;recipients[$i]          = new stdClass;
</ins><span class="cx">                         $message-&gt;recipients[$i]-&gt;user_id = $recipient_id;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -126,7 +126,7 @@
</span><span class="cx">                                 $error = 1;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( $error )
</del><ins>+                if ( !empty( $error ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 do_action( 'messages_delete_thread', $thread_ids );
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx"> function messages_check_thread_access( $thread_id, $user_id = 0 ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !$user_id )
</del><ins>+        if ( empty( $user_id ) )
</ins><span class="cx">                 $user_id = $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx"> 
</span><span class="cx">         return BP_Messages_Thread::check_access( $thread_id, $user_id );
</span><span class="lines">@@ -160,21 +160,21 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function messages_add_callback_values( $recipients, $subject, $content ) {
</span><del>-        setcookie( 'bp_messages_send_to', $recipients, time()+60*60*24, COOKIEPATH );
-        setcookie( 'bp_messages_subject', $subject, time()+60*60*24, COOKIEPATH );
-        setcookie( 'bp_messages_content', $content, time()+60*60*24, COOKIEPATH );
</del><ins>+        @setcookie( 'bp_messages_send_to', $recipients, time() + 60 * 60 * 24, COOKIEPATH );
+        @setcookie( 'bp_messages_subject', $subject,    time() + 60 * 60 * 24, COOKIEPATH );
+        @setcookie( 'bp_messages_content', $content,    time() + 60 * 60 * 24, COOKIEPATH );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function messages_remove_callback_values() {
</span><del>-        setcookie( 'bp_messages_send_to', false, time()-1000, COOKIEPATH );
-        setcookie( 'bp_messages_subject', false, time()-1000, COOKIEPATH );
-        setcookie( 'bp_messages_content', false, time()-1000, COOKIEPATH );
</del><ins>+        @setcookie( 'bp_messages_send_to', false, time() - 1000, COOKIEPATH );
+        @setcookie( 'bp_messages_subject', false, time() - 1000, COOKIEPATH );
+        @setcookie( 'bp_messages_content', false, time() - 1000, COOKIEPATH );
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function messages_get_unread_count( $user_id = 0 ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !$user_id )
</del><ins>+        if ( empty( $user_id ) )
</ins><span class="cx">                 $user_id = $bp-&gt;loggedin_user-&gt;id;
</span><span class="cx"> 
</span><span class="cx">         return BP_Messages_Thread::get_inbox_count( $user_id );
</span></span></pre>
</div>
</div>

</body>
</html>