<!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] [2230] trunk:
  Added email notifications of replies to updates you have posted.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2230</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2009-12-31 10:14:47 +0000 (Thu, 31 Dec 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Added email notifications of replies to updates you have posted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpthemesbpdefaultfunctionsphp">trunk/bp-themes/bp-default/functions.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivitynotificationsphp">trunk/bp-activity/bp-activity-notifications.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivitynotificationsphp"></a>
<div class="addfile"><h4>Added: trunk/bp-activity/bp-activity-notifications.php (0 => 2230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-notifications.php                                (rev 0)
+++ trunk/bp-activity/bp-activity-notifications.php        2009-12-31 10:14:47 UTC (rev 2230)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;?php
+
+function bp_activity_new_comment_notification( $comment_id, $params ) {
+        global $bp;
+
+        extract( $params );
+        $original_activity = new BP_Activity_Activity( $activity_id );
+
+        if ( !get_usermeta( $user_id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $user_id, 'notification_activity_new_reply' ) ) {
+                $poster_name = bp_core_get_user_displayname( $user_id );
+                $thread_link = bp_activity_get_permalink( $activity_id );
+                $settings_link = bp_core_get_user_domain( $original_activity-&gt;user_id ) . 'settings/notifications/';
+
+                // Set up and send the message
+                $ud = get_userdata( $original_activity-&gt;user_id );
+                $to = $ud-&gt;user_email;
+                $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), stripslashes($poster_name) );
+
+$message = sprintf( __(
+'%s replied to one of your updates:
+
+&quot;%s&quot;
+
+To view your original update and all comments, log in and visit: %s
+
+---------------------
+', 'buddypress' ), $poster_name, wp_filter_kses( stripslashes($content) ), $thread_link );
+
+                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
+
+                // Send it
+                wp_mail( $to, $subject, $message );
+        }
+}
+
+?&gt;
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (2229 => 2230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2009-12-30 15:36:28 UTC (rev 2229)
+++ trunk/bp-activity.php        2009-12-31 10:14:47 UTC (rev 2230)
</span><span class="lines">@@ -186,6 +186,35 @@
</span><span class="cx"> /* This screen is not attached to a nav item, so we need to add an action for it. */
</span><span class="cx"> add_action( 'wp', 'bp_activity_screen_single_activity_permalink', 3 );
</span><span class="cx"> 
</span><ins>+function bp_activity_screen_notification_settings() {
+        global $current_user; ?&gt;
+        &lt;table class=&quot;notification-settings&quot; id=&quot;activity-notification-settings&quot;&gt;
+                &lt;tr&gt;
+                        &lt;th class=&quot;icon&quot;&gt;&lt;/th&gt;
+                        &lt;th class=&quot;title&quot;&gt;&lt;?php _e( 'Activity', 'buddypress' ) ?&gt;&lt;/th&gt;
+                        &lt;th class=&quot;yes&quot;&gt;&lt;?php _e( 'Yes', 'buddypress' ) ?&gt;&lt;/th&gt;
+                        &lt;th class=&quot;no&quot;&gt;&lt;?php _e( 'No', 'buddypress' )?&gt;&lt;/th&gt;
+                &lt;/tr&gt;
+
+                &lt;tr&gt;
+                        &lt;td&gt;&lt;/td&gt;
+                        &lt;td&gt;&lt;?php printf( __( 'A member mentions you in an update using &quot;@%s&quot;', 'buddypress' ), $current_user-&gt;user_login ) ?&gt;&lt;/td&gt;
+                        &lt;td class=&quot;yes&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;notifications[notification_activity_new_mention]&quot; value=&quot;yes&quot; &lt;?php if ( !get_usermeta( $current_user-&gt;id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $current_user-&gt;id, 'notification_activity_new_mention' ) ) { ?&gt;checked=&quot;checked&quot; &lt;?php } ?&gt;/&gt;&lt;/td&gt;
+                        &lt;td class=&quot;no&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;notifications[notification_activity_new_mention]&quot; value=&quot;no&quot; &lt;?php if ( 'no' == get_usermeta( $current_user-&gt;id, 'notification_activity_new_mention' ) ) { ?&gt;checked=&quot;checked&quot; &lt;?php } ?&gt;/&gt;&lt;/td&gt;
+                &lt;/tr&gt;
+                &lt;tr&gt;
+                        &lt;td&gt;&lt;/td&gt;
+                        &lt;td&gt;&lt;?php printf( __( &quot;A member replies to an update you've posted&quot;, 'buddypress' ), $current_user-&gt;user_login ) ?&gt;&lt;/td&gt;
+                        &lt;td class=&quot;yes&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;notifications[notification_activity_new_reply]&quot; value=&quot;yes&quot; &lt;?php if ( !get_usermeta( $current_user-&gt;id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $current_user-&gt;id, 'notification_activity_new_reply' ) ) { ?&gt;checked=&quot;checked&quot; &lt;?php } ?&gt;/&gt;&lt;/td&gt;
+                        &lt;td class=&quot;no&quot;&gt;&lt;input type=&quot;radio&quot; name=&quot;notifications[notification_activity_new_reply]&quot; value=&quot;no&quot; &lt;?php if ( 'no' == get_usermeta( $current_user-&gt;id, 'notification_activity_new_reply' ) ) { ?&gt;checked=&quot;checked&quot; &lt;?php } ?&gt;/&gt;&lt;/td&gt;
+                &lt;/tr&gt;
+
+                &lt;?php do_action( 'bp_activity_screen_notification_settings' ) ?&gt;
+        &lt;/table&gt;
+&lt;?php
+}
+add_action( 'bp_notification_settings', 'bp_activity_screen_notification_settings', 1 );
+
</ins><span class="cx"> /********************************************************************************
</span><span class="cx">  * Action Functions
</span><span class="cx">  *
</span><span class="lines">@@ -377,8 +406,8 @@
</span><span class="cx">                 'hide_sitewide' =&gt; false // Should this be hidden on the sitewide activity stream?
</span><span class="cx">         );
</span><span class="cx"> 
</span><del>-        $r = wp_parse_args( $args, $defaults );
-        extract( $r, EXTR_SKIP );
</del><ins>+        $params = wp_parse_args( $args, $defaults );
+        extract( $params, EXTR_SKIP );
</ins><span class="cx"> 
</span><span class="cx">         /* Insert the &quot;time-since&quot; placeholder */
</span><span class="cx">         if ( $content )
</span><span class="lines">@@ -404,7 +433,7 @@
</span><span class="cx">         if ( 'activity_comment' == $activity-&gt;component_action )
</span><span class="cx">                 BP_Activity_Activity::rebuild_activity_comment_tree( $activity-&gt;item_id );
</span><span class="cx"> 
</span><del>-        do_action( 'bp_activity_add', $r );
</del><ins>+        do_action( 'bp_activity_add', $params );
</ins><span class="cx"> 
</span><span class="cx">         return $activity-&gt;id;
</span><span class="cx"> }
</span><span class="lines">@@ -419,8 +448,8 @@
</span><span class="cx">                 'parent_id' =&gt; false // ID of a parent comment (optional)
</span><span class="cx">         );
</span><span class="cx"> 
</span><del>-        $r = wp_parse_args( $args, $defaults );
-        extract( $r, EXTR_SKIP );
</del><ins>+        $params = wp_parse_args( $args, $defaults );
+        extract( $params, EXTR_SKIP );
</ins><span class="cx"> 
</span><span class="cx">         if ( empty($content) || empty($user_id) || empty($activity_id) )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -442,6 +471,12 @@
</span><span class="cx">                 'secondary_item_id' =&gt; $parent_id
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><ins>+        /* Send an email notification if settings allow */
+        require_once( BP_PLUGIN_DIR . '/bp-activity/bp-activity-notifications.php' );
+        bp_activity_new_comment_notification( $comment_id, $params );
+
+        do_action( 'bp_activity_comment_posted', $comment_id, $params );
+
</ins><span class="cx">         return $comment_id;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/functions.php (2229 => 2230)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/functions.php        2009-12-30 15:36:28 UTC (rev 2229)
+++ trunk/bp-themes/bp-default/functions.php        2009-12-31 10:14:47 UTC (rev 2230)
</span><span class="lines">@@ -196,7 +196,7 @@
</span><span class="cx"> 
</span><span class="cx"> function bp_dtheme_show_notice() { ?&gt;
</span><span class="cx">         &lt;div id=&quot;message&quot; class=&quot;updated fade&quot;&gt;
</span><del>-                &lt;p&gt;&lt;?php printf( __( 'Theme activated! This theme contains &lt;a href=&quot;%s&quot;&gt;customization options&lt;/a&gt; and &lt;a href=&quot;%s&quot;&gt;custom header image&lt;/a&gt; support. &lt;a href=&quot;%s&quot;&gt;Sidebar widgets&lt;/a&gt; are also supported.', 'buddypress' ), '', admin_url( 'themes.php?page=custom-header' ), '' ) ?&gt;&lt;/p&gt;
</del><ins>+                &lt;p&gt;&lt;?php printf( __( 'Theme activated! This theme contains &lt;a href=&quot;%s&quot;&gt;customization options&lt;/a&gt; and &lt;a href=&quot;%s&quot;&gt;custom header image&lt;/a&gt; support. &lt;a href=&quot;%s&quot;&gt;Sidebar widgets&lt;/a&gt; are also supported.', 'buddypress' ), admin_url( 'themes.php?page=theme-options-page' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?&gt;&lt;/p&gt;
</ins><span class="cx">         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;style type=&quot;text/css&quot;&gt;#message2, #message0 { display: none; }&lt;/style&gt;
</span></span></pre>
</div>
</div>

</body>
</html>