<!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][4620] trunk: Provides initial support for Notifications menu in WP Admin Bar.</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>4620</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-07-06 19:10:08 +0000 (Wed, 06 Jul 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Provides initial support for Notifications menu in WP Admin Bar. Refactors group and friendship notifications to return values compatible with the WP Admin Bar constructor. Modifies bp_core_get_notifications_for_user() in order to provide WP Admin Bar support in addition to BuddyBar backpat. References #3294</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorecssadminbarcss">trunk/bp-core/css/admin-bar.css</a></li>
<li><a href="#trunkbpfriendsbpfriendsactivityphp">trunk/bp-friends/bp-friends-activity.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsactivityphp">trunk/bp-groups/bp-groups-activity.php</a></li>
<li><a href="#trunkbpgroupsbpgroupsloaderphp">trunk/bp-groups/bp-groups-loader.php</a></li>
<li><a href="#trunkbpmembersbpmembersadminbarphp">trunk/bp-members/bp-members-adminbar.php</a></li>
<li><a href="#trunkbpmembersbpmembersnotificationsphp">trunk/bp-members/bp-members-notifications.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorecssadminbarcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/css/admin-bar.css (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/css/admin-bar.css        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-core/css/admin-bar.css        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -72,7 +72,8 @@
</span><span class="cx">         background: url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a img {
</del><ins>+#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a img,
+#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar > a img {
</ins><span class="cx">         width: 16px;
</span><span class="cx">         height: 16px;
</span><span class="cx">         display: inline;
</span><span class="lines">@@ -84,11 +85,13 @@
</span><span class="cx">         float: none;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul {
-        left: 0;
</del><ins>+#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul,
+#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul {
+        left: 30px;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul ul {
</del><ins>+#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul ul,
+#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
</ins><span class="cx">         left: 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -118,3 +121,17 @@
</span><span class="cx"> #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
</span><span class="cx">         left: 0;
</span><span class="cx"> }
</span><ins>+
+#wpadminbar .quicklinks li#wp-admin-bar-notifications #ab-pending-notifications {
+        background: #eee;
+        color: #333;
+        text-shadow: none;
+        display: inline;
+        padding: 2px 5px;
+        font-size: 10px;
+        font-weight: bold;
+        -moz-border-radius: 10px;
+        -khtml-border-radius: 10px;
+        -webkit-border-radius: 10px;
+        border-radius: 10px;
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpfriendsbpfriendsactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-friends/bp-friends-activity.php (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-friends/bp-friends-activity.php        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-friends/bp-friends-activity.php        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -51,33 +51,52 @@
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_register_activity_actions', 'friends_register_activity_actions' );
</span><span class="cx">
</span><del>-function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
</del><ins>+function friends_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
</ins><span class="cx">         global $bp;
</span><span class="cx">
</span><span class="cx">         switch ( $action ) {
</span><span class="cx">                 case 'friendship_accepted':
</span><del>-                $user_fullname = bp_core_get_user_displayname( $item_id );
-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_friends_multiple_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest">' . sprintf( __('%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', (int)$total_items );
-                        else
-                                return apply_filters( 'bp_friends_single_friendship_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/my-friends/newest">' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
-
</del><ins>+                        $link = bp_loggedin_user_domain() . $bp->friends->slug . '/my-friends/newest';
+                        
+                        // Set up the string and the filter
+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( '%d friends accepted your friendship requests', 'buddypress' ), (int)$total_items );
+                                $filter = 'bp_friends_multiple_friendship_accepted_notification';
+                        } else {
+                                $text = sprintf( __( '%s accepted your friendship request', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
+                                $filter = 'bp_friends_single_friendship_accepted_notification';
+                        }
+                        
</ins><span class="cx">                         break;
</span><span class="cx">
</span><span class="cx">                 case 'friendship_request':
</span><ins>+                        $link = bp_loggedin_user_domain() . $bp->friends->slug . '/requests';
+                        
+                        // Set up the string and the filter
</ins><span class="cx">                         if ( (int)$total_items > 1 ) {
</span><del>-                                return apply_filters( 'bp_friends_multiple_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have %d pending friendship requests', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
</del><ins>+                                $text = sprintf( __( 'You have %d pending friendship requests', 'buddypress' ), (int)$total_items );
+                                $filter = 'bp_friends_multiple_friendship_request_notification';
</ins><span class="cx">                         } else {
</span><del>-                                $user_fullname = bp_core_get_user_displayname( $item_id );
-                                $user_url = bp_core_get_user_domain( $item_id );
-                                return apply_filters( 'bp_friends_single_friendship_request_notification', '<a href="' . $bp->loggedin_user->domain . $bp->friends->slug . '/requests/?new" title="' . __( 'Friendship requests', 'buddypress' ) . '">' . sprintf( __('You have a friendship request from %s', 'buddypress' ), $user_fullname ) . '</a>', $user_fullname );
</del><ins>+                                $text = sprintf( __( 'You have a friendship request from %s', 'buddypress' ), bp_core_get_user_displayname( $item_id ) );
+                                $filter = 'bp_friends_single_friendship_request_notification';
</ins><span class="cx">                         }
</span><ins>+                
</ins><span class="cx">                         break;
</span><span class="cx">         }
</span><ins>+                
+        // Return either an HTML link or an array, depending on the requested format
+        if ( 'string' == $format ) {
+                $return = apply_filters( $filter, '<a href="' . $link . '">' . $text . '</a>', (int)$total_items );
+        } else {
+                $return = apply_filters( $filter, array(
+                        'link' => $link,
+                        'text' => $text
+                ), (int)$total_items );
+        }
</ins><span class="cx">
</span><del>-        do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
</del><ins>+        do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return );
</ins><span class="cx">
</span><del>-        return false;
</del><ins>+        return $return;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-activity.php (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-activity.php        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-groups/bp-groups-activity.php        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> add_action( 'groups_new_forum_topic', 'groups_update_last_activity' );
</span><span class="cx"> add_action( 'groups_new_forum_topic_post', 'groups_update_last_activity' );
</span><span class="cx">
</span><del>-function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
</del><ins>+function groups_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
</ins><span class="cx">         global $bp;
</span><span class="cx">
</span><span class="cx">         switch ( $action ) {
</span><span class="lines">@@ -82,15 +82,40 @@
</span><span class="cx">                         $requesting_user_id = $item_id;
</span><span class="cx">
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id );
</span><del>-
</del><span class="cx">                         $group_link = bp_get_group_permalink( $group );
</span><span class="cx">
</span><ins>+                        // Set up the string and the filter
+                        // Because different values are passed to the filters, we'll return the
+                        // values inline
</ins><span class="cx">                         if ( (int)$total_items > 1 ) {
</span><del>-                                return apply_filters( 'bp_groups_multiple_new_membership_requests_notification', '<a href="' . $group_link . '/admin/membership-requests/?n=1" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $group_link, $total_items, $group->name );
</del><ins>+                                $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int)$total_items, $group->name );
+                                $filter = 'bp_groups_multiple_new_membership_requests_notification';
+                                $notification_link = $group_link . 'admin/membership-requests/?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Membership Requests', 'buddypress' ) . '">' . $text . '</a>', $group_link, $total_items, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $total_items, $group->name, $text, $notification_link );
+                                }
</ins><span class="cx">                         } else {
</span><span class="cx">                                 $user_fullname = bp_core_get_user_displayname( $requesting_user_id );
</span><del>-                                return apply_filters( 'bp_groups_single_new_membership_request_notification', '<a href="' . $group_link . 'admin/membership-requests/?n=1" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . sprintf( __( '%1$s requests membership for the group "%2$s"', 'buddypress' ), $user_fullname, $group->name ) . '</a>', $group_link, $user_fullname, $group->name );
</del><ins>+                                $text = sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname );
+                                $filter = 'bp_groups_single_new_membership_request_notification';
+                                $notification_link = $group_link . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . sprintf( __( '%s requests group membership', 'buddypress' ), $user_fullname ) . '">' . $text . '</a>', $group_link, $user_fullname, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $user_fullname, $group->name, $text, $notification_link );
+                                }
</ins><span class="cx">                         }
</span><ins>+                        
</ins><span class="cx">                         break;
</span><span class="cx">
</span><span class="cx">                 case 'membership_request_accepted':
</span><span class="lines">@@ -99,10 +124,33 @@
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id );
</span><span class="cx">                         $group_link = bp_get_group_permalink( $group );
</span><span class="cx">
</span><del>-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_groups_multiple_membership_request_accepted_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
-                        else
-                                return apply_filters( 'bp_groups_single_membership_request_accepted_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
</del><ins>+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( '%d accepted group membership requests', 'buddypress' ), (int)$total_items, $group->name );
+                                $filter = 'bp_groups_multiple_membership_request_accepted_notification';                                 
+                                $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $total_items, $group->name, $text, $notification_link );
+                                }
+                        } else {
+                                $text = sprintf( __( 'Membership for group "%s" accepted', 'buddypress' ), $group->name );
+                                $filter = 'bp_groups_single_membership_request_accepted_notification';
+                                $notification_link = $group_link . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $group->name, $text, $notification_link );
+                                }
+                        }
</ins><span class="cx">
</span><span class="cx">                         break;
</span><span class="cx">
</span><span class="lines">@@ -111,12 +159,35 @@
</span><span class="cx">
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id );
</span><span class="cx">                         $group_link = bp_get_group_permalink( $group );
</span><ins>+                        
+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name );
+                                $filter = 'bp_groups_multiple_membership_request_rejected_notification';
+                                $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $group->name );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $total_items, $group->name, $text, $notification_link );
+                                }
+                        } else {
+                                $text = sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name );
+                                $filter = 'bp_groups_single_membership_request_rejected_notification';
+                                $notification_link = $group_link . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $group->name, $text, $notification_link );
+                                }
+                        }
</ins><span class="cx">
</span><del>-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_groups_multiple_membership_request_rejected_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( '%d rejected group membership requests', 'buddypress' ), (int)$total_items, $group->name ) . '</a>', $total_items, $group->name );
-                        else
-                                return apply_filters( 'bp_groups_single_membership_request_rejected_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'Membership for group "%s" rejected', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
-
</del><span class="cx">                         break;
</span><span class="cx">
</span><span class="cx">                 case 'member_promoted_to_admin':
</span><span class="lines">@@ -125,10 +196,33 @@
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id );
</span><span class="cx">                         $group_link = bp_get_group_permalink( $group );
</span><span class="cx">
</span><del>-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_groups_multiple_member_promoted_to_admin_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
-                        else
-                                return apply_filters( 'bp_groups_single_member_promoted_to_admin_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to an admin in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
</del><ins>+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( 'You were promoted to an admin in %d groups', 'buddypress' ), (int)$total_items );
+                                $filter = 'bp_groups_multiple_member_promoted_to_admin_notification';
+                                $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $total_items, $text, $notification_link );
+                                }
+                        } else {
+                                $text = sprintf( __( 'You were promoted to an admin in the group "%s"', 'buddypress' ), $group->name );
+                                $filter = 'bp_groups_single_member_promoted_to_admin_notification';
+                                $notification_link = $group_link . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $group->name, $text, $notification_link );
+                                }
+                        }
</ins><span class="cx">
</span><span class="cx">                         break;
</span><span class="cx">
</span><span class="lines">@@ -138,21 +232,68 @@
</span><span class="cx">                         $group = new BP_Groups_Group( $group_id );
</span><span class="cx">                         $group_link = bp_get_group_permalink( $group );
</span><span class="cx">
</span><del>-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_groups_multiple_member_promoted_to_mod_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/?n=1" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
-                        else
-                                return apply_filters( 'bp_groups_single_member_promoted_to_mod_notification', '<a href="' . $group_link . '?n=1">' . sprintf( __( 'You were promoted to a mod in the group %s', 'buddypress' ), $group->name ) . '</a>', $group_link, $group->name );
</del><ins>+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( 'You were promoted to a mod in %d groups', 'buddypress' ), (int)$total_items );
+                                $filter = 'bp_groups_multiple_member_promoted_to_mod_notification';
+                                $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Groups', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $total_items, $text, $notification_link );
+                                }
+                        } else {
+                                $text = sprintf( __( 'You were promoted to a mod in the group "%s"', 'buddypress' ), $group->name );
+                                $filter = 'bp_groups_single_member_promoted_to_mod_notification';
+                                $notification_link = $group_link . '?n=1';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $group->name, $text, $notification_link );
+                                }
+                        }
</ins><span class="cx">
</span><span class="cx">                         break;
</span><span class="cx">
</span><span class="cx">                 case 'group_invite':
</span><span class="cx">                         $group_id = $item_id;
</span><del>-                        $group = new BP_Groups_Group( $group_id );
</del><ins>+                        $group = new BP_Groups_Group( $group_id );        
+                        $group_link = bp_get_group_permalink( $group );
+                        
+                        $notification_link = bp_loggedin_user_domain() . bp_get_groups_slug() . '/invites/?n=1';
</ins><span class="cx">
</span><del>-                        if ( (int)$total_items > 1 )
-                                return apply_filters( 'bp_groups_multiple_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int)$total_items ) . '</a>', $total_items );
-                        else
-                                return apply_filters( 'bp_groups_single_group_invite_notification', '<a href="' . $bp->loggedin_user->domain . $bp->groups->slug . '/invites/?n=1" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name ) . '</a>', $group->name );
</del><ins>+                        if ( (int)$total_items > 1 ) {
+                                $text = sprintf( __( 'You have %d new group invitations', 'buddypress' ), (int)$total_items );
+                                $filter = 'bp_groups_multiple_group_invite_notification';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '" title="' . __( 'Group Invites', 'buddypress' ) . '">' . $text . '</a>', $total_items, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $total_items, $text, $notification_link );
+                                }
+                        } else {
+                                $text = sprintf( __( 'You have an invitation to the group: %s', 'buddypress' ), $group->name );
+                                $filter = 'bp_groups_single_group_invite_notification';
+                                
+                                if ( 'string' == $format ) {
+                                        return apply_filters( $filter, '<a href="' . $notification_link . '">' . $text . '</a>', $group_link, $group->name, $text, $notification_link );
+                                } else {
+                                        return apply_filters( $filter, array(
+                                                'link' => $notification_link,
+                                                'text' => $text
+                                        ), $group_link, $group->name, $text, $notification_link );
+                                }
+                        }
</ins><span class="cx">
</span><span class="cx">                         break;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupsloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-loader.php (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-loader.php        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-groups/bp-groups-loader.php        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -47,7 +47,8 @@
</span><span class="cx">                         'template',
</span><span class="cx">                         'buddybar',
</span><span class="cx">                         'adminbar',
</span><del>-                        'functions'
</del><ins>+                        'functions',
+                        'notifications'
</ins><span class="cx">                 );
</span><span class="cx">                 parent::_includes( $includes );
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpmembersbpmembersadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-adminbar.php (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-adminbar.php        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-members/bp-members-adminbar.php        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> * @package BuddyPress
</span><span class="cx"> * @since 1.3
</span><span class="cx"> */
</span><del>-function bp_members_user_admin_menu() {
</del><ins>+function bp_members_admin_bar_user_admin_menu() {
</ins><span class="cx">         global $bp, $wp_admin_bar;
</span><span class="cx">
</span><span class="cx">         // Only show if viewing a user
</span><span class="lines">@@ -145,9 +145,56 @@
</span><span class="cx">                 'meta' => array( 'onclick' => 'confirm(" ' . __( "Are you sure you want to delete this user's account?", 'buddypress' ) . '");' )
</span><span class="cx">         ) );
</span><span class="cx"> }
</span><del>-add_action( 'bp_setup_admin_bar', 'bp_members_user_admin_menu', 99 );
</del><ins>+add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_user_admin_menu', 99 );
</ins><span class="cx">
</span><span class="cx"> /**
</span><ins>+ * Build the "Notifications" dropdown
+ *
+ * @package Buddypress
+ * @since 1.3
+ */
+function bp_members_admin_bar_notifications_menu() {
+        global $bp, $wp_admin_bar;
+
+        if ( !is_user_logged_in() )
+                return false;
+                
+        if ( $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' ) ) {
+                $menu_title = sprintf( __( 'Notifications <span id="ab-pending-notifications" class="pending-count">%s</span>', 'buddypress' ), count( $notifications ) );
+        } else {
+                $menu_title = __( 'Notifications', 'buddypress' );
+        }
+        
+        // Add the top-level Notifications button
+        $wp_admin_bar->add_menu( array(
+                'id' => 'notifications',
+                'title' => $menu_title,
+                'href' => bp_loggedin_user_domain()
+        ) );
+        
+        if ( !empty( $notifications ) ) {
+                foreach ( (array)$notifications as $notification ) {
+                        $wp_admin_bar->add_menu( array(
+                                'parent' => 'notifications',
+                                'id' => 'notification-' . $notification->id,
+                                'title' => $notification->content,
+                                'href' => $notification->href
+                        ) );
+                }
+        } else {
+                $wp_admin_bar->add_menu( array(
+                        'parent' => 'notifications',
+                        'id'         => 'no-notifications',
+                        'title' => __( 'No new notifications', 'buddypress' ),
+                        'href'         => bp_loggedin_user_domain()
+                ) );
+        }
+        
+        return;
+}
+add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_notifications_menu', 999 );
+
+/**
</ins><span class="cx"> * Make sure the logout link is at the bottom of the "My Account" menu
</span><span class="cx"> *
</span><span class="cx"> * @since BuddyPress (r4151)
</span></span></pre></div>
<a id="trunkbpmembersbpmembersnotificationsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-members/bp-members-notifications.php (4619 => 4620)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-members/bp-members-notifications.php        2011-07-06 11:36:11 UTC (rev 4619)
+++ trunk/bp-members/bp-members-notifications.php        2011-07-06 19:10:08 UTC (rev 4620)
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">         return new BP_Core_Notification( $id );
</span><span class="cx"> }
</span><span class="cx">
</span><del>-function bp_core_get_notifications_for_user( $user_id ) {
</del><ins>+function bp_core_get_notifications_for_user( $user_id, $format = 'simple' ) {
</ins><span class="cx">         global $bp;
</span><span class="cx">
</span><span class="cx">         $notifications = BP_Core_Notification::get_all_for_user( $user_id );
</span><span class="lines">@@ -71,8 +71,25 @@
</span><span class="cx">                         // @deprecated format_notification_function - 1.3
</span><span class="cx">                         if ( isset( $bp->{$component_name}->format_notification_function ) && function_exists( $bp->{$component_name}->format_notification_function ) ) {
</span><span class="cx">                                 $renderable[] = call_user_func( $bp->{$component_name}->format_notification_function, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
</span><del>-                        } elseif ( isset( $bp->{$component_name}->notification_callback ) && function_exists( $bp->{$component_name}->notification_callback ) ) {
-                                $renderable[] = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
</del><ins>+                        } elseif ( isset( $bp->{$component_name}->notification_callback ) && function_exists( $bp->{$component_name}->notification_callback ) ) {
+                                if ( 'object' == $format ) {
+                                        $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count, 'array' );
+                                        
+                                        // Minimal backpat with non-compatible notification
+                                        // callback functions
+                                        if ( is_string( $content ) ) {
+                                                $notification->content = $content;
+                                                $notification->href = bp_loggedin_user_domain();
+                                        } else {
+                                                $notification->content = $content['text'];
+                                                $notification->href = $content['link'];
+                                        }
+                                        
+                                        $renderable[]          = $notification;
+                                } else {
+                                        $content = call_user_func( $bp->{$component_name}->notification_callback, $component_action_name, $component_action_items[0]->item_id, $component_action_items[0]->secondary_item_id, $action_item_count );
+                                        $renderable[] = $content;
+                                }
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre>
</div>
</div>
</body>
</html>