<!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>+<?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->user_id ) . 'settings/notifications/';
+
+                // Set up and send the message
+                $ud = get_userdata( $original_activity->user_id );
+                $to = $ud->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:
+
+"%s"
+
+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 );
+        }
+}
+
+?>
</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; ?>
+        <table class="notification-settings" id="activity-notification-settings">
+                <tr>
+                        <th class="icon"></th>
+                        <th class="title"><?php _e( 'Activity', 'buddypress' ) ?></th>
+                        <th class="yes"><?php _e( 'Yes', 'buddypress' ) ?></th>
+                        <th class="no"><?php _e( 'No', 'buddypress' )?></th>
+                </tr>
+
+                <tr>
+                        <td></td>
+                        <td><?php printf( __( 'A member mentions you in an update using "@%s"', 'buddypress' ), $current_user->user_login ) ?></td>
+                        <td class="yes"><input type="radio" name="notifications[notification_activity_new_mention]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $current_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
+                        <td class="no"><input type="radio" name="notifications[notification_activity_new_mention]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_activity_new_mention' ) ) { ?>checked="checked" <?php } ?>/></td>
+                </tr>
+                <tr>
+                        <td></td>
+                        <td><?php printf( __( "A member replies to an update you've posted", 'buddypress' ), $current_user->user_login ) ?></td>
+                        <td class="yes"><input type="radio" name="notifications[notification_activity_new_reply]" value="yes" <?php if ( !get_usermeta( $current_user->id, 'notification_activity_new_reply' ) || 'yes' == get_usermeta( $current_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
+                        <td class="no"><input type="radio" name="notifications[notification_activity_new_reply]" value="no" <?php if ( 'no' == get_usermeta( $current_user->id, 'notification_activity_new_reply' ) ) { ?>checked="checked" <?php } ?>/></td>
+                </tr>
+
+                <?php do_action( 'bp_activity_screen_notification_settings' ) ?>
+        </table>
+<?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' => 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 "time-since" placeholder */
</span><span class="cx">         if ( $content )
</span><span class="lines">@@ -404,7 +433,7 @@
</span><span class="cx">         if ( 'activity_comment' == $activity->component_action )
</span><span class="cx">                 BP_Activity_Activity::rebuild_activity_comment_tree( $activity->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->id;
</span><span class="cx"> }
</span><span class="lines">@@ -419,8 +448,8 @@
</span><span class="cx">                 'parent_id' => 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' => $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() { ?>
</span><span class="cx">         <div id="message" class="updated fade">
</span><del>-                <p><?php printf( __( 'Theme activated! This theme contains <a href="%s">customization options</a> and <a href="%s">custom header image</a> support. <a href="%s">Sidebar widgets</a> are also supported.', 'buddypress' ), '', admin_url( 'themes.php?page=custom-header' ), '' ) ?></p>
</del><ins>+                <p><?php printf( __( 'Theme activated! This theme contains <a href="%s">customization options</a> and <a href="%s">custom header image</a> support. <a href="%s">Sidebar widgets</a> are also supported.', 'buddypress' ), admin_url( 'themes.php?page=theme-options-page' ), admin_url( 'themes.php?page=custom-header' ), admin_url( 'widgets.php' ) ) ?></p>
</ins><span class="cx">         </div>
</span><span class="cx">
</span><span class="cx">         <style type="text/css">#message2, #message0 { display: none; }</style>
</span></span></pre>
</div>
</div>
</body>
</html>