Skip to:
Content

BuddyPress.org

Ticket #2703: 2703.002.diff

File 2703.002.diff, 35.5 KB (added by cnorris23, 14 years ago)
  • bp-friends/bp-friends-notifications.php

     
    11<?php
    22
     3/**
     4 * Sends an email notification when a user's friendship is requested
     5 *
     6 * @since 1.0
     7 *
     8 * @param int $friendship_id The id of friendship request
     9 * @param int $initiator_id The unique user_id of the user who requested friendship
     10 * @param int $friend_id The unique user_id of person who's friendship is requested
     11 */
    312function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) {
    413        global $bp;
    514
     
    817        if ( 'no' == get_user_meta( (int)$friend_id, 'notification_friends_friendship_request', true ) )
    918                return false;
    1019
    11         $ud = get_userdata( $friend_id );
     20        $ud           = get_userdata( $friend_id );
    1221        $initiator_ud = get_userdata( $initiator_id );
    1322
    1423        $all_requests_link = bp_core_get_user_domain( $friend_id ) . BP_FRIENDS_SLUG . '/requests/';
    15         $settings_link = bp_core_get_user_domain( $friend_id ) . BP_SETTINGS_SLUG . '/notifications';
     24        $settings_link     = bp_core_get_user_domain( $friend_id ) . BP_SETTINGS_SLUG . '/notifications';
    1625
    1726        $initiator_link = bp_core_get_user_domain( $initiator_id );
    1827
     
    2130        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    2231        $subject  = '[' . $sitename . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name );
    2332
    24         $message = sprintf( __(
    25 '%1$s wants to add you as a friend.
     33        $message = sprintf( __( "%1\$s wants to add you as a friend.\n\nTo view all of your pending friendship requests: %2\$s\n\nTo view %3\$s's profile: %4\$s\n\n---------------------\n", 'buddypress' ), $initiator_name, $all_requests_link, $initiator_name, $initiator_link );
    2634
    27 To view all of your pending friendship requests: %2$s
     35        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    2836
    29 To view %3$s\'s profile: %4$s
    30 
    31 ---------------------
    32 ', 'buddypress' ), $initiator_name, $all_requests_link, $initiator_name, $initiator_link );
    33 
    34         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    35        
    36         /* Send the message */
    37         $to = apply_filters( 'friends_notification_new_request_to', $to );
     37        // Send the message
     38        $to      = apply_filters( 'friends_notification_new_request_to'     , $to );
    3839        $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name );
    3940        $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link );
    4041
     
    4344        do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id );
    4445}
    4546
     47/**
     48 * Sends an email notification when a user accepts your friendship request
     49 *
     50 * @since 1.0
     51 *
     52 * @param int $friendship_id The id of friendship request
     53 * @param int $initiator_id The unique user_id of the user who requested friendship
     54 * @param int $friend_id The unique user_id of person who's accepted the friendship request
     55 */
    4656function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) {
    4757        global $bp;
    4858
     
    5565
    5666        $ud = get_userdata( $initiator_id );
    5767
    58         $friend_link = bp_core_get_user_domain( $friend_id );
    59         $settings_link = bp_core_get_user_domain( $initiator_id ) .  BP_SETTINGS_SLUG . '/notifications';
     68        $friend_link   = bp_core_get_user_domain( $friend_id );
     69        $settings_link = bp_core_get_user_domain( $initiator_id ) . BP_SETTINGS_SLUG . '/notifications';
    6070
    6171        // Set up and send the message
    6272        $to       = $ud->user_email;
    6373        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    6474        $subject  = '[' . $sitename . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );
    6575
    66         $message = sprintf( __(
    67 '%1$s accepted your friend request.
     76        $message = sprintf( __( "%1\$s accepted your friend request.\n\nTo view %2\$s's profile: %3\$s\n\n---------------------\n", 'buddypress' ), $friend_name, $friend_name, $friend_link );
    6877
    69 To view %2$s\'s profile: %3$s
    70 
    71 ---------------------
    72 ', 'buddypress' ), $friend_name, $friend_name, $friend_link );
    73 
    7478        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    7579
    76         /* Send the message */
    77         $to = apply_filters( 'friends_notification_accepted_request_to', $to );
     80        // Send the message
     81        $to      = apply_filters( 'friends_notification_accepted_request_to'     , $to );
    7882        $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name );
    7983        $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link );
    8084
  • bp-activity/bp-activity-notifications.php

     
    44 * Sends an email notification and a BP notification when someone mentions you in an update
    55 *
    66 * @package BuddyPress Activity
    7  * @param str $content The content of the activity update
     7 * @since 1.2
     8 *
     9 * @param str $content The content of the activity update
    810 * @param int $poster_user_id The unique user_id of the user who sent the update
    911 * @param int $activity_id The id of the activity update
    1012 */
    1113function bp_activity_at_message_notification( $content, $poster_user_id, $activity_id ) {
    1214        global $bp;
    1315
    14         /* Scan for @username strings in an activity update. Notify each user. */
     16        // Scan for @username strings in an activity update. Notify each user.
    1517        $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
    1618        preg_match_all( $pattern, $content, $usernames );
    1719
    18         /* Make sure there's only one instance of each username */
     20        // Make sure there's only one instance of each username
    1921        if ( !$usernames = array_unique( $usernames[1] ) )
    2022                return false;
    2123
     
    3234                if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) {
    3335                        $poster_name = bp_core_get_user_displayname( $poster_user_id );
    3436
    35                         $message_link = bp_activity_get_permalink( $activity_id );
     37                        $message_link  = bp_activity_get_permalink( $activity_id );
    3638                        $settings_link = bp_core_get_user_domain( $receiver_user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
    3739
    3840                        $poster_name = stripslashes( $poster_name );
    39                         $content = bp_activity_filter_kses( stripslashes($content) );
     41                        $content     = bp_activity_filter_kses( stripslashes($content) );
    4042
    4143                        // Set up and send the message
    4244                        $ud       = bp_core_get_core_userdata( $receiver_user_id );
     
    4446                        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    4547                        $subject  = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name );
    4648
    47 $message = sprintf( __(
    48 '%1$s mentioned you in an update:
     49                        $message = sprintf( __( "%1\$s mentioned you in an update:\n\n\"%2\$s\"\n\nTo view and respond to the message, log in and visit: %3\$s\n\n---------------------\n", 'buddypress' ), $poster_name, $content, $message_link );
    4950
    50 "%2$s"
    51 
    52 To view and respond to the message, log in and visit: %3$s
    53 
    54 ---------------------
    55 ', 'buddypress' ), $poster_name, $content, $message_link );
    56 
    5751                        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    5852
    59                         /* Send the message */
    60                         $to = apply_filters( 'bp_activity_at_message_notification_to', $to );
     53                        // Send the message
     54                        $to      = apply_filters( 'bp_activity_at_message_notification_to'     , $to );
    6155                        $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name );
    6256                        $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link );
    6357
    6458                        wp_mail( $to, $subject, $message );
    6559                }
    66                
     60
    6761                do_action( 'bp_activity_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $activity_id );
    6862        }
    6963}
    7064add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );
    7165
     66/**
     67 * Sends an email notification and a BP notification when someone replies to your activity update or comment
     68 *
     69 * @package BuddyPress Activity
     70 * @since 1.2
     71 *
     72 * @param int $comment_id The comment_id of the activity update
     73 * @param int $commenter_id The unique commenter_id of the user who replied the update
     74 * @param array $params Array of new comment information (      'id', 'content', 'user_id', 'activity_id', 'parent_id' )
     75 */
    7276function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
    7377        global $bp;
    7478
     
    7781        $original_activity = new BP_Activity_Activity( $activity_id );
    7882
    7983        if ( $original_activity->user_id != $commenter_id && 'no' != get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) {
    80                 $poster_name = bp_core_get_user_displayname( $commenter_id );
    81                 $thread_link = bp_activity_get_permalink( $activity_id );
     84                $poster_name   = bp_core_get_user_displayname( $commenter_id );
     85                $thread_link   = bp_activity_get_permalink( $activity_id );
    8286                $settings_link = bp_core_get_user_domain( $original_activity->user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
    8387
    8488                $poster_name = stripslashes( $poster_name );
     
    8892                $ud       = bp_core_get_core_userdata( $original_activity->user_id );
    8993                $to       = $ud->user_email;
    9094                $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    91                 $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
     95                $subject  = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name );
    9296
    93 $message = sprintf( __(
    94 '%1$s replied to one of your updates:
     97                $message = sprintf( __( "%1\$s replied to one of your updates:\n\n\"%2\$s\"\n\nTo view your original update and all comments, log in and visit: %3\$s\n\n---------------------\n", 'buddypress' ), $poster_name, $content, $thread_link );
    9598
    96 "%2$s"
    97 
    98 To view your original update and all comments, log in and visit: %3$s
    99 
    100 ---------------------
    101 ', 'buddypress' ), $poster_name, $content, $thread_link );
    102 
    10399                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    104100
    105                 /* Send the message */
    106                 $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
     101                // Send the message
     102                $to      = apply_filters( 'bp_activity_new_comment_notification_to'     , $to );
    107103                $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name );
    108104                $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link );
    109105
     
    112108                do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params );
    113109        }
    114110
    115         /***
    116          * If this is a reply to another comment, send an email notification to the
    117          * author of the immediate parent comment.
    118          */
     111         // If this is a reply to another comment, send an email notification to the
     112         // author of the immediate parent comment.
    119113        if ( $activity_id == $parent_id )
    120114                return false;
    121115
    122116        $parent_comment = new BP_Activity_Activity( $parent_id );
    123117
    124118        if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
    125                 $poster_name = bp_core_get_user_displayname( $commenter_id );
    126                 $thread_link = bp_activity_get_permalink( $activity_id );
     119                $poster_name   = bp_core_get_user_displayname( $commenter_id );
     120                $thread_link   = bp_activity_get_permalink( $activity_id );
    127121                $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
    128122
    129123                // Set up and send the message
    130124                $ud       = bp_core_get_core_userdata( $parent_comment->user_id );
    131125                $to       = $ud->user_email;
    132126                $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    133                 $subject = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
     127                $subject  = '[' . $sitename . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name );
    134128
    135129                $poster_name = stripslashes( $poster_name );
    136                 $content = bp_activity_filter_kses( stripslashes( $content ) );
     130                $content     = bp_activity_filter_kses( stripslashes( $content ) );
    137131
    138 $message = sprintf( __(
    139 '%1$s replied to one of your comments:
     132                $message = sprintf( __( "%1\$s replied to one of your comments:\n\n\"%2\$s\"\n\nTo view the original activity, your comment and all replies, log in and visit: %3\$s\n\n---------------------\n", 'buddypress' ), $poster_name, $content, $thread_link );
    140133
    141 "%2$s"
    142 
    143 To view the original activity, your comment and all replies, log in and visit: %3$s
    144 
    145 ---------------------
    146 ', 'buddypress' ), $poster_name, $content, $thread_link );
    147 
    148134                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    149135
    150                 /* Send the message */
    151                 $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to );
     136                // Send the message
     137                $to      = apply_filters( 'bp_activity_new_comment_notification_comment_author_to'     , $to );
    152138                $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name );
    153139                $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content );
    154140
     
    158144        }
    159145}
    160146
    161 ?>
     147?>
     148 No newline at end of file
  • bp-messages/bp-messages-notifications.php

     
    11<?php
    22
     3/**
     4 * Sends an email notification when a user receives a new message
     5 *
     6 * @since 1.0
     7 *
     8 * @param array $args An array of new message args ('message_id', 'sender_id', 'subject', 'content', 'recipients', 'thread_id')
     9 */
    310function messages_notification_new_message( $args ) {
    411        global $bp;
    5         extract($args);
     12        extract( $args );
    613
    714        $sender_name = bp_core_get_user_displayname( $sender_id );
    815
    9         foreach( $recipients as $recipient ) {
    10                 if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) ) continue;
     16        foreach( (array)$recipients as $recipient ) {
     17                if ( $sender_id == $recipient->user_id || 'no' == get_user_meta( $recipient->user_id, 'notification_messages_new_message', true ) )
     18                        continue;
    1119
    12                 $ud = get_userdata( $recipient->user_id );
    13                 $message_link = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
    14                 $settings_link = bp_core_get_user_domain( $recipient->user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
     20                $ud            = get_userdata( $recipient->user_id );
     21                $message_link  = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/';
     22                $settings_link = bp_core_get_user_domain( $recipient->user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    1523
    1624                $sender_name = stripslashes( $sender_name );
    17                 $subject = stripslashes( wp_filter_kses( $subject ) );
    18                 $content = stripslashes( wp_filter_kses( $content ) );
     25                $subject     = stripslashes( wp_filter_kses( $subject ) );
     26                $content     = stripslashes( wp_filter_kses( $content ) );
    1927
    2028                // Set up and send the message
    2129                $email_to      = $ud->user_email;
    2230                $sitename      = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    2331                $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name );
    2432
    25                 $email_content = sprintf( __(
    26 '%s sent you a new message:
     33                $email_content = sprintf( __( "%1\$s sent you a new message:\n\nSubject: %2\$s\n\n\"%3\$s\"\n\nTo view and read your messages please log in and visit: %4\$s\n\n---------------------\n", 'buddypress' ), $sender_name, $subject, $content, $message_link );
    2734
    28 Subject: %s
    29 
    30 "%s"
    31 
    32 To view and read your messages please log in and visit: %s
    33 
    34 ---------------------
    35 ', 'buddypress' ), $sender_name, $subject, $content, $message_link );
    36 
    3735                $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3836
    39                 /* Send the message */
    40                 $email_to = apply_filters( 'messages_notification_new_message_to', $email_to );
     37                // Send the message
     38                $email_to      = apply_filters( 'messages_notification_new_message_to'     , $email_to );
    4139                $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name );
    4240                $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link );
    4341
  • bp-forums/bp-forums-admin.php

     
    7575                        } else {
    7676                        ?>
    7777                                <h3><?php _e( 'New bbPress Installation', 'buddypress' ) ?></h3>
    78                                 <p><?php _e( "You've decided to set up a new installation of bbPress for forum management in BuddyPress. This is very simple and is usually just a one click
    79                                 process. When you're ready, hit the link below.", 'buddypress' ) ?></p>
     78                                <p><?php _e( "You've decided to set up a new installation of bbPress for forum management in BuddyPress. This is very simple and is usually just a one click process. When you're ready, hit the link below.", 'buddypress' ) ?></p>
    8079                                <p><a class="button-primary" href="<?php echo wp_nonce_url( $post_url . '&step=new&doinstall=1', 'bp_forums_new_install_init' ) ?>"><?php _e( 'Complete Installation', 'buddypress' ) ?></a></p>
    8180                        <?php
    8281                        }
     
    257256
    258257        return 1;
    259258}
    260 ?>
    261  No newline at end of file
     259?>
  • bp-groups/bp-groups-notifications.php

     
    11<?php
    22
     3/**
     4 * Sends an email notification when a user's group is updated
     5 *
     6 * @since 1.0
     7 *
     8 * @param int $group_id The group_id of the group updated
     9 */
    310function groups_notification_group_updated( $group_id ) {
    411        global $bp;
    512
     
    916
    1017        $user_ids = BP_Groups_Member::get_group_member_ids( $group->id );
    1118        foreach ( (array)$user_ids as $user_id ) {
    12                 if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) continue;
     19                if ( 'no' == get_user_meta( $user_id, 'notification_groups_group_updated', true ) )
     20                        continue;
    1321
    1422                $ud = bp_core_get_core_userdata( $user_id );
    1523
    1624                // Set up and send the message
    1725                $to = $ud->user_email;
    1826
    19                 $group_link = site_url( $bp->groups->slug . '/' . $group->slug );
    20                 $settings_link = bp_core_get_user_domain( $user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
     27                $group_link    = site_url( $bp->groups->slug . '/' . $group->slug );
     28                $settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    2129
    22                 $message = sprintf( __(
    23 'Group details for the group "%1$s" were updated:
     30                $message = sprintf( __( "Group details for the group \"%1\$s\" were updated:\n\nTo view the group: %2\$s\n\n---------------------\n", 'buddypress' ), $group->name, $group_link );
    2431
    25 To view the group: %2$s
    26 
    27 ---------------------
    28 ', 'buddypress' ), $group->name, $group_link );
    29 
    3032                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    3133
    32                 /* Send the message */
    33                 $to = apply_filters( 'groups_notification_group_updated_to', $to );
     34                // Send the message
     35                $to      = apply_filters( 'groups_notification_group_updated_to'     , $to );
    3436                $subject = apply_filters( 'groups_notification_group_updated_subject', $subject, &$group );
    3537                $message = apply_filters( 'groups_notification_group_updated_message', $message, &$group, $group_link );
    3638
     
    4244        do_action( 'bp_groups_sent_updated_email', $user_ids, $subject, $message, $group_id );
    4345}
    4446
     47/**
     48 * Sends an email notification to the group admin when a user requests to join a group
     49 *
     50 * @since 1.0
     51 *
     52 * @param int $requesting_user_id The unique user_id of the user requesting to join the group
     53 * @param int $admin_id The unique user_id of the group admin who'll receive the notification
     54 * @param int $group_id The group_id of the group the user wishes to join
     55 * @param int $membership_id The user's membership_id for the group they wish to join
     56 */
    4557function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) {
    4658        global $bp;
    4759
     
    5163                return false;
    5264
    5365        $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );
    54         $group = new BP_Groups_Group( $group_id );
     66        $group                = new BP_Groups_Group( $group_id );
    5567
    56         $ud = bp_core_get_core_userdata($admin_id);
    57         $requesting_ud = bp_core_get_core_userdata($requesting_user_id);
     68        $ud            = bp_core_get_core_userdata( $admin_id );
     69        $requesting_ud = bp_core_get_core_userdata( $requesting_user_id );
    5870
    5971        $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests';
    60         $profile_link = bp_core_get_user_domain( $requesting_user_id );
    61         $settings_link = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
     72        $profile_link   = bp_core_get_user_domain( $requesting_user_id );
     73        $settings_link  = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    6274
    6375        // Set up and send the message
    6476        $to       = $ud->user_email;
    6577        $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    6678        $subject  = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name );
    6779
    68 $message = sprintf( __(
    69 '%1$s wants to join the group "%2$s".
     80        $message = sprintf( __( "%1\$s wants to join the group \"%2\$s\".\n\nBecause you are the administrator of this group, you must either accept or reject the membership request.\n\nTo view all pending membership requests for this group, please visit:\n%3\$s\n\nTo view %4\$s's profile: %5\$s\n\n---------------------\n", 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
    7081
    71 Because you are the administrator of this group, you must either accept or reject the membership request.
    72 
    73 To view all pending membership requests for this group, please visit:
    74 %3$s
    75 
    76 To view %4$s\'s profile: %5$s
    77 
    78 ---------------------
    79 ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );
    80 
    8182        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    8283
    83         /* Send the message */
    84         $to = apply_filters( 'groups_notification_new_membership_request_to', $to );
     84        // Send the message
     85        $to      = apply_filters( 'groups_notification_new_membership_request_to'     , $to );
    8586        $subject = apply_filters( 'groups_notification_new_membership_request_subject', $subject, &$group );
    8687        $message = apply_filters( 'groups_notification_new_membership_request_message', $message, &$group, $requesting_user_name, $profile_link, $group_requests );
    8788
     
    9091        do_action( 'bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id );
    9192}
    9293
     94/**
     95 * Sends an email and adds a BP notification when a user is accepted to or rejected from group membership
     96 *
     97 * @since 1.0
     98 *
     99 * @param int $requesting_user_id The unique user_id of the user requesting to join the group
     100 * @param int $group_id The group_id of the group the user wishes to join
     101 * @param bool $accepted Whether or not the user has been accepted. Defaults to true.
     102 */
    93103function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) {
    94104        global $bp;
    95105
     
    104114
    105115        $group = new BP_Groups_Group( $group_id );
    106116
    107         $ud = bp_core_get_core_userdata($requesting_user_id);
     117        $ud = bp_core_get_core_userdata( $requesting_user_id );
    108118
    109         $group_link = bp_get_group_permalink( $group );
    110         $settings_link = bp_core_get_user_domain( $requesting_user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
     119        $group_link    = bp_get_group_permalink( $group );
     120        $settings_link = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    111121
    112122        // Set up and send the message
    113123        $to       = $ud->user_email;
     
    115125
    116126        if ( $accepted ) {
    117127                $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );
    118                 $message = sprintf( __(
    119 'Your membership request for the group "%1$s" has been accepted.
     128                $message = sprintf( __( "Your membership request for the group \"%1\$s\" has been accepted.\n\nTo view the group please login and visit: %2\$s\n\n---------------------\n", 'buddypress' ), $group->name, $group_link );
    120129
    121 To view the group please login and visit: %2$s
    122 
    123 ---------------------
    124 ', 'buddypress' ), $group->name, $group_link );
    125 
    126130        } else {
    127131                $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );
    128                 $message = sprintf( __(
    129 'Your membership request for the group "%1$s" has been rejected.
    130 
    131 To submit another request please log in and visit: %2$s
    132 
    133 ---------------------
    134 ', 'buddypress' ), $group->name, $group_link );
     132                $message = sprintf( __( "Your membership request for the group \"%1\$s\" has been rejected.\n\nTo submit another request please log in and visit: %2\$s\n\n---------------------\n", 'buddypress' ), $group->name, $group_link );
    135133        }
    136134
    137135        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    138136
    139         /* Send the message */
    140         $to = apply_filters( 'groups_notification_membership_request_completed_to', $to );
     137        // Send the message
     138        $to      = apply_filters( 'groups_notification_membership_request_completed_to'     , $to );
    141139        $subject = apply_filters( 'groups_notification_membership_request_completed_subject', $subject, &$group );
    142140        $message = apply_filters( 'groups_notification_membership_request_completed_message', $message, &$group, $group_link  );
    143141
     
    146144        do_action( 'bp_groups_sent_membership_approved_email', $requesting_user_id, $subject, $message, $group_id );
    147145}
    148146
     147/**
     148 * Sends an email and adds a BP notification when a user is promoted within a group
     149 *
     150 * @since 1.0
     151 *
     152 * @param int $user_id The unique user_id of user being promoted
     153 * @param int $group_id The the group_id in which the user has been promoted
     154 */
    149155function groups_notification_promoted_member( $user_id, $group_id ) {
    150156        global $bp;
    151157
    152158        if ( groups_is_user_admin( $user_id, $group_id ) ) {
    153159                $promoted_to = __( 'an administrator', 'buddypress' );
    154                 $type = 'member_promoted_to_admin';
     160                $type        = 'member_promoted_to_admin';
    155161        } else {
    156162                $promoted_to = __( 'a moderator', 'buddypress' );
    157                 $type = 'member_promoted_to_mod';
     163                $type        = 'member_promoted_to_mod';
    158164        }
    159165
    160166        // Post a screen notification first.
     
    164170                return false;
    165171
    166172        $group = new BP_Groups_Group( $group_id );
    167         $ud = bp_core_get_core_userdata($user_id);
     173        $ud    = bp_core_get_core_userdata( $user_id );
    168174
    169         $group_link = bp_get_group_permalink( $group );
    170         $settings_link = bp_core_get_user_domain( $user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
     175        $group_link    = bp_get_group_permalink( $group );
     176        $settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    171177
    172178        // Set up and send the message
    173179        $to       = $ud->user_email;
    174180        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    175181        $subject  = '[' . $sitename . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name );
    176182
    177         $message = sprintf( __(
    178 'You have been promoted to %1$s for the group: "%2$s".
     183        $message = sprintf( __( "You have been promoted to %1\$s for the group: \"%2\$s\".\n\nTo view the group please visit: %3\$s\n\n---------------------\n", 'buddypress' ), $promoted_to, $group->name, $group_link );
    179184
    180 To view the group please visit: %3$s
    181 
    182 ---------------------
    183 ', 'buddypress' ), $promoted_to, $group->name, $group_link );
    184 
    185185        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    186186
    187         /* Send the message */
    188         $to = apply_filters( 'groups_notification_promoted_member_to', $to );
     187        // Send the message
     188        $to      = apply_filters( 'groups_notification_promoted_member_to'     , $to );
    189189        $subject = apply_filters( 'groups_notification_promoted_member_subject', $subject, &$group );
    190190        $message = apply_filters( 'groups_notification_promoted_member_message', $message, &$group, $promoted_to, $group_link );
    191191
     
    195195}
    196196add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 );
    197197
     198/**
     199 * Sends an email and adds a BP notification when a user is invited to a group by a friend
     200 *
     201 * @since 1.0
     202 *
     203 * @param obj $group BP group object
     204 * @param obj $member BP member object
     205 * @param int $inviter_user_id The unique user_id of user initiating the invite
     206 */
    198207function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) {
    199208        global $bp;
    200209
    201         $inviter_ud = bp_core_get_core_userdata( $inviter_user_id );
     210        $inviter_ud   = bp_core_get_core_userdata( $inviter_user_id );
    202211        $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true );
    203212        $inviter_link = bp_core_get_user_domain( $inviter_user_id );
    204213
     
    215224
    216225                $invited_ud = bp_core_get_core_userdata($invited_user_id);
    217226
    218                 $settings_link = bp_core_get_user_domain( $invited_user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
    219                 $invited_link = bp_core_get_user_domain( $invited_user_id );
    220                 $invites_link = $invited_link . $bp->groups->slug . '/invites';
     227                $settings_link = bp_core_get_user_domain( $invited_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
     228                $invited_link  = bp_core_get_user_domain( $invited_user_id );
     229                $invites_link  = $invited_link . $bp->groups->slug . '/invites/';
    221230
    222231                // Set up and send the message
    223232                $to       = $invited_ud->user_email;
    224233                $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    225234                $subject  = '[' . $sitename . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name );
    226235
    227                 $message = sprintf( __(
    228 'One of your friends %1$s has invited you to the group: "%2$s".
     236                $message = sprintf( __( "One of your friends %1\$s has invited you to the group: \"%2\$s\".\n\nTo view your group invites visit: %3\$s\n\nTo view the group visit: %4\$s\n\nTo view %5\$s\'s profile visit: %6\$s\n\n---------------------\n", 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
    229237
    230 To view your group invites visit: %3$s
    231 
    232 To view the group visit: %4$s
    233 
    234 To view %5$s\'s profile visit: %6$s
    235 
    236 ---------------------
    237 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );
    238 
    239238                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    240239
    241                 /* Send the message */
    242                 $to = apply_filters( 'groups_notification_group_invites_to', $to );
     240                // Send the message
     241                $to      = apply_filters( 'groups_notification_group_invites_to'     , $to );
    243242                $subject = apply_filters( 'groups_notification_group_invites_subject', $subject, &$group );
    244243                $message = apply_filters( 'groups_notification_group_invites_message', $message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link );
    245244
     
    249248        do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
    250249}
    251250
     251/**
     252 * Sends an email notification when a user is mentioned in a group activity update
     253 *
     254 * @since 1.0
     255 *
     256 * @param string $content The content of the group update containing the mention
     257 * @param int $poster_user_id The unique user_id of the user who post the update
     258 * @param int $group_id The group_id of the group where mention occured
     259 * @param int $activity_id The activity_id of the update containing the mention
     260 */
    252261function groups_at_message_notification( $content, $poster_user_id, $group_id, $activity_id ) {
    253262        global $bp;
    254263
    255         /* Scan for @username strings in an activity update. Notify each user. */
     264        // Scan for @username strings in an activity update. Notify each user.
    256265        $pattern = '/[@]+([A-Za-z0-9-_\.]+)/';
    257266        preg_match_all( $pattern, $content, $usernames );
    258267
    259         /* Make sure there's only one instance of each username */
     268        // Make sure there's only one instance of each username
    260269        if ( !$usernames = array_unique( $usernames[1] ) )
    261270                return false;
    262271
     
    266275                if ( !$receiver_user_id = bp_core_get_userid( $username ) )
    267276                        continue;
    268277
    269                 /* Check the user is a member of the group before sending the update. */
     278                // Check the user is a member of the group before sending the update.
    270279                if ( !groups_is_user_member( $receiver_user_id, $group_id ) )
    271280                        continue;
    272281
     
    274283                if ( 'no' != get_user_meta( $user_id, 'notification_activity_new_mention', true ) ) {
    275284                        $poster_name = bp_core_get_user_displayname( $poster_user_id );
    276285
    277                         $message_link = bp_activity_get_permalink( $activity_id );
    278                         $settings_link = bp_core_get_user_domain( $receiver_user_id ) .  BP_SETTINGS_SLUG . '/notifications/';
     286                        $message_link  = bp_activity_get_permalink( $activity_id );
     287                        $settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/';
    279288
    280289                        $poster_name = stripslashes( $poster_name );
    281                         $content = bp_groups_filter_kses( stripslashes( $content ) );
     290                        $content     = bp_groups_filter_kses( stripslashes( $content ) );
    282291
    283292                        // Set up and send the message
    284                         $ud = bp_core_get_core_userdata( $receiver_user_id );
    285                         $to = $ud->user_email;
     293                        $ud       = bp_core_get_core_userdata( $receiver_user_id );
     294                        $to       = $ud->user_email;
    286295                        $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES );
    287296                        $subject  = '[' . $sitename . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name );
    288297
    289 $message = sprintf( __(
    290 '%1$s mentioned you in the group "%2$s":
     298$message = sprintf( __( "%1\$s mentioned you in the group \"%2\$s\":\n\n\"%3\$s\"\n\nTo view and respond to the message, log in and visit: %4\$s\n\n---------------------\n", 'buddypress' ), $poster_name, $group->name, $content, $message_link );
    291299
    292 "%3$s"
    293 
    294 To view and respond to the message, log in and visit: %4$s
    295 
    296 ---------------------
    297 ', 'buddypress' ), $poster_name, $group->name, $content, $message_link );
    298 
    299300                        $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    300301
    301                         /* Send the message */
    302                         $to = apply_filters( 'groups_at_message_notification_to', $to );
     302                        // Send the message
     303                        $to      = apply_filters( 'groups_at_message_notification_to'     , $to );
    303304                        $subject = apply_filters( 'groups_at_message_notification_subject', $subject, &$group, $poster_name );
    304305                        $message = apply_filters( 'groups_at_message_notification_message', $message, &$group, $poster_name, $content, $message_link );
    305306
     
    311312}
    312313add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 );
    313314
    314 
    315 ?>
     315?>
     316 No newline at end of file