<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [2450] trunk: Fixes #1686</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2450</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-01-25 14:48:13 +0000 (Mon, 25 Jan 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes #1686</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmessagesbpmessagesclassesphp">trunk/bp-messages/bp-messages-classes.php</a></li>
<li><a href="#trunkbpmessagesbpmessagesnotificationsphp">trunk/bp-messages/bp-messages-notifications.php</a></li>
<li><a href="#trunkbpmessagesphp">trunk/bp-messages.php</a></li>
<li><a href="#trunkbpthemesbpdefaultsidebarphp">trunk/bp-themes/bp-default/sidebar.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 (2449 => 2450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-classes.php        2010-01-25 14:26:43 UTC (rev 2449)
+++ trunk/bp-messages/bp-messages-classes.php        2010-01-25 14:48:13 UTC (rev 2450)
</span><span class="lines">@@ -294,7 +294,7 @@
</span><span class="cx">                 if ( $new_thread ) {
</span><span class="cx">                         /* Add an recipient entry for all recipients */
</span><span class="cx">                         foreach ( (array)$this-&gt;recipients as $recipient )
</span><del>-                                $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, $this-&gt;thread_id ) );
</del><ins>+                                $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 ) );
</ins><span class="cx"> 
</span><span class="cx">                         /* Add a sender recipient entry if the sender is not in the list of recipients */
</span><span class="cx">                         if ( !in_array( $this-&gt;sender_id, $this-&gt;recipients ) )
</span></span></pre></div>
<a id="trunkbpmessagesbpmessagesnotificationsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-notifications.php (2449 => 2450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-notifications.php        2010-01-25 14:26:43 UTC (rev 2449)
+++ trunk/bp-messages/bp-messages-notifications.php        2010-01-25 14:48:13 UTC (rev 2450)
</span><span class="lines">@@ -4,22 +4,20 @@
</span><span class="cx">         global $bp;
</span><span class="cx">         extract($args);
</span><span class="cx"> 
</span><del>-        $message = new BP_Messages_Message( $item_id );
</del><ins>+        $sender_name = bp_core_get_user_displayname( $sender_id );
</ins><span class="cx"> 
</span><del>-        $sender_name = bp_core_get_user_displayname( $message-&gt;sender_id );
-
</del><span class="cx">         for ( $i = 0; $i &lt; count($recipients); $i++ ) {
</span><del>-                if ( $message-&gt;sender_id == $recipients[$i]-&gt;user_id || 'no' == get_usermeta( $recipients[$i]-&gt;user_id, 'notification_messages_new_message' ) ) continue;
</del><ins>+                if ( $sender_id == $recipients[$i]-&gt;user_id || 'no' == get_usermeta( $recipients[$i]-&gt;user_id, 'notification_messages_new_message' ) ) continue;
</ins><span class="cx"> 
</span><span class="cx">                 $ud = get_userdata( $recipients[$i]-&gt;user_id );
</span><del>-                $message_link = bp_core_get_user_domain( $recipients[$i]-&gt;user_id ) . 'messages/view/' . $message-&gt;id;
</del><ins>+                $message_link = bp_core_get_user_domain( $recipients[$i]-&gt;user_id ) . 'messages/view/' . $message_id;
</ins><span class="cx">                 $settings_link = bp_core_get_user_domain( $recipients[$i]-&gt;user_id ) . 'settings/notifications';
</span><span class="cx"> 
</span><span class="cx">                 // Set up and send the message
</span><span class="cx">                 $to = $ud-&gt;user_email;
</span><del>-                $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
</del><ins>+                $email_subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) );
</ins><span class="cx"> 
</span><del>-                $content = sprintf( __(
</del><ins>+                $email_content = sprintf( __(
</ins><span class="cx"> '%s sent you a new message:
</span><span class="cx"> 
</span><span class="cx"> Subject: %s
</span><span class="lines">@@ -29,16 +27,15 @@
</span><span class="cx"> To view the message: %s
</span><span class="cx"> 
</span><span class="cx"> ---------------------
</span><del>-', 'buddypress' ), $sender_name, stripslashes( wp_filter_kses( $message-&gt;subject ) ), stripslashes( wp_filter_kses( $message-&gt;message ) ), $message_link );
</del><ins>+', 'buddypress' ), $sender_name, stripslashes( wp_filter_kses( $subject ) ), stripslashes( wp_filter_kses( $content ) ), $message_link );
</ins><span class="cx"> 
</span><span class="cx">                 $content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
</span><span class="cx"> 
</span><span class="cx">                 // Send it
</span><del>-                wp_mail( $to, $subject, $content );
</del><ins>+                wp_mail( $to, $email_subject, $email_content );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> /* This is too expensive to send on normal servers uncomment action at your own risk. */
</span><span class="cx"> function messages_notification_new_notice( $message_subject, $message ) {
</span><span class="cx">         global $bp, $wpdb;
</span></span></pre></div>
<a id="trunkbpmessagesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages.php (2449 => 2450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages.php        2010-01-25 14:26:43 UTC (rev 2449)
+++ trunk/bp-messages.php        2010-01-25 14:48:13 UTC (rev 2450)
</span><span class="lines">@@ -452,7 +452,11 @@
</span><span class="cx">                 if ( empty( $recipient_ids ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><del>-                $message-&gt;recipients = $recipient_ids;
</del><ins>+                /* Format this to match existing recipients */
+                foreach( $recipient_ids as $i =&gt; $recipient_id ) {
+                        $message-&gt;recipients[$i] = new stdClass;
+                        $message-&gt;recipients[$i]-&gt;user_id = $recipient_id;
+                }
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         if ( $message-&gt;send() ) {
</span><span class="lines">@@ -463,7 +467,7 @@
</span><span class="cx">                         bp_core_add_notification( $message-&gt;id, $recipient-&gt;user_id, 'messages', 'new_message' );
</span><span class="cx"> 
</span><span class="cx">                 // Send email notifications to the recipients
</span><del>-                messages_notification_new_message( array( 'item_id' =&gt; $message-&gt;id, 'recipient_ids' =&gt; $message-&gt;recipients, 'thread_id' =&gt; $message-&gt;thread_id, 'component_name' =&gt; $bp-&gt;messages-&gt;slug, 'component_action' =&gt; 'message_sent', 'is_private' =&gt; 1 ) );
</del><ins>+                messages_notification_new_message( array( 'message_id' =&gt; $message-&gt;id, 'sender_id' =&gt; $message-&gt;sender_id, 'subject' =&gt; $message-&gt;subject, 'content' =&gt; $message-&gt;message, 'recipients' =&gt; $message-&gt;recipients, 'thread_id' =&gt; $message-&gt;thread_id) );
</ins><span class="cx"> 
</span><span class="cx">                 do_action( 'messages_message_sent', &amp;$message );
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultsidebarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/sidebar.php (2449 => 2450)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/sidebar.php        2010-01-25 14:26:43 UTC (rev 2449)
+++ trunk/bp-themes/bp-default/sidebar.php        2010-01-25 14:48:13 UTC (rev 2450)
</span><span class="lines">@@ -8,7 +8,7 @@
</span><span class="cx">         &lt;?php if ( is_user_logged_in() ) : ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;div id=&quot;sidebar-me&quot;&gt;
</span><del>-                        &lt;a href=&quot;&lt;?php echo bp_loggedin_user_domain() ?&gt;&quot; title=&quot;&lt;?php _e( 'My Profile', 'buddypress' ) ?&gt;&quot;&gt;
</del><ins>+                        &lt;a href=&quot;&lt;?php echo bp_loggedin_user_domain() ?&gt;&quot;&gt;
</ins><span class="cx">                                 &lt;?php bp_loggedin_user_avatar( 'type=thumb&amp;width=40&amp;height=40' ) ?&gt;
</span><span class="cx">                         &lt;/a&gt;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>