<!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] [3403] trunk: Adds notifications for new activity at-mentions.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>3403</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2010-11-12 22:35:06 +0000 (Fri, 12 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Adds notifications for new activity at-mentions. Fixes #2155</pre>

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

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivitynotificationsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-notifications.php (3402 => 3403)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-notifications.php        2010-11-12 21:38:13 UTC (rev 3402)
+++ trunk/bp-activity/bp-activity-notifications.php        2010-11-12 22:35:06 UTC (rev 3403)
</span><span class="lines">@@ -14,6 +14,8 @@
</span><span class="cx">         foreach( (array)$usernames as $username ) {
</span><span class="cx">                 if ( !$receiver_user_id = bp_core_get_userid( $username ) )
</span><span class="cx">                         continue;
</span><ins>+                        
+                bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id ); 
</ins><span class="cx"> 
</span><span class="cx">                 // Now email the user with the contents of the message (if they have enabled email notifications)
</span><span class="cx">                 if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
</span></span></pre></div>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (3402 => 3403)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2010-11-12 21:38:13 UTC (rev 3402)
+++ trunk/bp-activity.php        2010-11-12 22:35:06 UTC (rev 3403)
</span><span class="lines">@@ -136,6 +136,23 @@
</span><span class="cx">         bp_core_load_template( apply_filters( 'bp_activity_template_mention_activity', 'members/single/home' ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * bp_activity_remove_screen_notifications()
+ *
+ * Removes activity notifications from the notification menu when a user clicks on them and
+ * is taken to a specific screen.
+ *
+ * @package BuddyPress Activity
+ */
+function bp_activity_remove_screen_notifications() {
+        global $bp;
+
+        bp_core_delete_notifications_for_user_by_type( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;activity-&gt;id, 'new_at_mention' );
+}
+add_action( 'bp_activity_screen_my_activity', 'bp_activity_remove_screen_notifications' );
+add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications' );
+add_action( 'bp_activity_screen_mentions', 'bp_activity_remove_screen_notifications' );
+
</ins><span class="cx"> function bp_activity_screen_single_activity_permalink() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><span class="lines">@@ -484,6 +501,43 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'wp', 'bp_activity_action_favorites_feed', 3 );
</span><span class="cx"> 
</span><ins>+/**
+ * bp_activity_format_notifications()
+ *
+ * Formats notifications related to activity
+ *
+ * @package BuddyPress Activity
+ * @param $action The type of activity item. Just 'new_at_mention' for now
+ * @param $item_id The activity id
+ * @param $secondary_item_id In the case of at-mentions, this is the mentioner's id
+ * @param $total_items The total number of notifications to format
+ */
+function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
+        global $bp;
+
+        switch ( $action ) {
+                case 'new_at_mention':
+                        $activity_id = $item_id;
+                        $poster_user_id = $secondary_item_id;
+
+                        $at_mention_link = $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;activity-&gt;slug . '/mentions/';
+                        $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), $bp-&gt;loggedin_user-&gt;userdata-&gt;user_nicename );
+
+                        if ( (int)$total_items &gt; 1 ) {
+                                return apply_filters( 'bp_activity_multiple_at_mentions_notification', '&lt;a href=&quot;' . $at_mention_link . '&quot; title=&quot;' . $at_mention_title . '&quot;&gt;' . sprintf( __( 'You have %1$d new activity mentions', 'buddypress' ), (int)$total_items ) . '&lt;/a&gt;', $at_mention_link, $total_items, $activity_id, $poster_user_id );
+                        } else {
+                                $user_fullname = bp_core_get_user_displayname( $poster_user_id );
+                                
+                                return apply_filters( 'bp_activity_single_at_mentions_notification', '&lt;a href=&quot;' . $at_mention_link . '&quot; title=&quot;' . $at_mention_title . '&quot;&gt;' . sprintf( __( '%1$s mentioned you in an activity update', 'buddypress' ), $user_fullname ) . '&lt;/a&gt;', $at_mention_link, $total_items, $activity_id, $poster_user_id );
+                        }
+                break;
+        }
+
+        do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
+
+        return false;
+}
+
</ins><span class="cx"> /********************************************************************************
</span><span class="cx">  * Business Functions
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkbpxprofilephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile.php (3402 => 3403)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile.php        2010-11-12 21:38:13 UTC (rev 3402)
+++ trunk/bp-xprofile.php        2010-11-12 22:35:06 UTC (rev 3403)
</span><span class="lines">@@ -873,23 +873,7 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'user_profile_update_errors', 'xprofile_sync_bp_profile', 10, 3 );
</span><span class="cx"> 
</span><del>-/**
- * xprofile_remove_screen_notifications()
- *
- * Removes notifications from the notification menu when a user clicks on them and
- * is taken to a specific screen.
- *
- * @package BuddyPress Core
- */
-function xprofile_remove_screen_notifications() {
-        global $bp;
</del><span class="cx"> 
</span><del>-        bp_core_delete_notifications_for_user_by_type( $bp-&gt;loggedin_user-&gt;id, $bp-&gt;profile-&gt;id, 'new_at_mention' );
-}
-add_action( 'bp_activity_screen_my_activity', 'xprofile_remove_screen_notifications' );
-add_action( 'bp_activity_screen_single_activity_permalink', 'xprofile_remove_screen_notifications' );
-
-
</del><span class="cx"> /**
</span><span class="cx">  * xprofile_remove_data_on_user_deletion()
</span><span class="cx">  *
</span></span></pre>
</div>
</div>

</body>
</html>