Ticket #2703: 2703.002.diff
File 2703.002.diff, 35.5 KB (added by , 14 years ago) |
---|
-
bp-friends/bp-friends-notifications.php
1 1 <?php 2 2 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 */ 3 12 function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) { 4 13 global $bp; 5 14 … … 8 17 if ( 'no' == get_user_meta( (int)$friend_id, 'notification_friends_friendship_request', true ) ) 9 18 return false; 10 19 11 $ud = get_userdata( $friend_id );20 $ud = get_userdata( $friend_id ); 12 21 $initiator_ud = get_userdata( $initiator_id ); 13 22 14 23 $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'; 16 25 17 26 $initiator_link = bp_core_get_user_domain( $initiator_id ); 18 27 … … 21 30 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 22 31 $subject = '[' . $sitename . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name ); 23 32 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 ); 26 34 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 ); 28 36 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 ); 38 39 $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name ); 39 40 $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link ); 40 41 … … 43 44 do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id ); 44 45 } 45 46 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 */ 46 56 function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) { 47 57 global $bp; 48 58 … … 55 65 56 66 $ud = get_userdata( $initiator_id ); 57 67 58 $friend_link = bp_core_get_user_domain( $friend_id );59 $settings_link = bp_core_get_user_domain( $initiator_id ) . 68 $friend_link = bp_core_get_user_domain( $friend_id ); 69 $settings_link = bp_core_get_user_domain( $initiator_id ) . BP_SETTINGS_SLUG . '/notifications'; 60 70 61 71 // Set up and send the message 62 72 $to = $ud->user_email; 63 73 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 64 74 $subject = '[' . $sitename . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name ); 65 75 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 ); 68 77 69 To view %2$s\'s profile: %3$s70 71 ---------------------72 ', 'buddypress' ), $friend_name, $friend_name, $friend_link );73 74 78 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 75 79 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 ); 78 82 $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name ); 79 83 $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link ); 80 84 -
bp-activity/bp-activity-notifications.php
4 4 * Sends an email notification and a BP notification when someone mentions you in an update 5 5 * 6 6 * @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 8 10 * @param int $poster_user_id The unique user_id of the user who sent the update 9 11 * @param int $activity_id The id of the activity update 10 12 */ 11 13 function bp_activity_at_message_notification( $content, $poster_user_id, $activity_id ) { 12 14 global $bp; 13 15 14 / * Scan for @username strings in an activity update. Notify each user. */16 // Scan for @username strings in an activity update. Notify each user. 15 17 $pattern = '/[@]+([A-Za-z0-9-_\.]+)/'; 16 18 preg_match_all( $pattern, $content, $usernames ); 17 19 18 / * Make sure there's only one instance of each username */20 // Make sure there's only one instance of each username 19 21 if ( !$usernames = array_unique( $usernames[1] ) ) 20 22 return false; 21 23 … … 32 34 if ( 'no' != get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 33 35 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 34 36 35 $message_link = bp_activity_get_permalink( $activity_id );37 $message_link = bp_activity_get_permalink( $activity_id ); 36 38 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 37 39 38 40 $poster_name = stripslashes( $poster_name ); 39 $content = bp_activity_filter_kses( stripslashes($content) );41 $content = bp_activity_filter_kses( stripslashes($content) ); 40 42 41 43 // Set up and send the message 42 44 $ud = bp_core_get_core_userdata( $receiver_user_id ); … … 44 46 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 45 47 $subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ); 46 48 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 ); 49 50 50 "%2$s"51 52 To view and respond to the message, log in and visit: %3$s53 54 ---------------------55 ', 'buddypress' ), $poster_name, $content, $message_link );56 57 51 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 58 52 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 ); 61 55 $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name ); 62 56 $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link ); 63 57 64 58 wp_mail( $to, $subject, $message ); 65 59 } 66 60 67 61 do_action( 'bp_activity_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $activity_id ); 68 62 } 69 63 } 70 64 add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 ); 71 65 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 */ 72 76 function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) { 73 77 global $bp; 74 78 … … 77 81 $original_activity = new BP_Activity_Activity( $activity_id ); 78 82 79 83 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 ); 82 86 $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 83 87 84 88 $poster_name = stripslashes( $poster_name ); … … 88 92 $ud = bp_core_get_core_userdata( $original_activity->user_id ); 89 93 $to = $ud->user_email; 90 94 $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 ); 92 96 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 ); 95 98 96 "%2$s"97 98 To view your original update and all comments, log in and visit: %3$s99 100 ---------------------101 ', 'buddypress' ), $poster_name, $content, $thread_link );102 103 99 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 104 100 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 ); 107 103 $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name ); 108 104 $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link ); 109 105 … … 112 108 do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params ); 113 109 } 114 110 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. 119 113 if ( $activity_id == $parent_id ) 120 114 return false; 121 115 122 116 $parent_comment = new BP_Activity_Activity( $parent_id ); 123 117 124 118 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 ); 127 121 $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 128 122 129 123 // Set up and send the message 130 124 $ud = bp_core_get_core_userdata( $parent_comment->user_id ); 131 125 $to = $ud->user_email; 132 126 $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 ); 134 128 135 129 $poster_name = stripslashes( $poster_name ); 136 $content = bp_activity_filter_kses( stripslashes( $content ) );130 $content = bp_activity_filter_kses( stripslashes( $content ) ); 137 131 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 ); 140 133 141 "%2$s"142 143 To view the original activity, your comment and all replies, log in and visit: %3$s144 145 ---------------------146 ', 'buddypress' ), $poster_name, $content, $thread_link );147 148 134 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 149 135 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 ); 152 138 $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name ); 153 139 $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content ); 154 140 … … 158 144 } 159 145 } 160 146 161 ?> 147 ?> 148 No newline at end of file -
bp-messages/bp-messages-notifications.php
1 1 <?php 2 2 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 */ 3 10 function messages_notification_new_message( $args ) { 4 11 global $bp; 5 extract( $args);12 extract( $args ); 6 13 7 14 $sender_name = bp_core_get_user_displayname( $sender_id ); 8 15 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; 11 19 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 ) . 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/'; 15 23 16 24 $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 ) ); 19 27 20 28 // Set up and send the message 21 29 $email_to = $ud->user_email; 22 30 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 23 31 $email_subject = '[' . $sitename . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), $sender_name ); 24 32 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 ); 27 34 28 Subject: %s29 30 "%s"31 32 To view and read your messages please log in and visit: %s33 34 ---------------------35 ', 'buddypress' ), $sender_name, $subject, $content, $message_link );36 37 35 $email_content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 38 36 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 ); 41 39 $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject, $sender_name ); 42 40 $email_content = apply_filters( 'messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link ); 43 41 -
bp-forums/bp-forums-admin.php
75 75 } else { 76 76 ?> 77 77 <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> 80 79 <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> 81 80 <?php 82 81 } … … 257 256 258 257 return 1; 259 258 } 260 ?> 261 No newline at end of file 259 ?> -
bp-groups/bp-groups-notifications.php
1 1 <?php 2 2 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 */ 3 10 function groups_notification_group_updated( $group_id ) { 4 11 global $bp; 5 12 … … 9 16 10 17 $user_ids = BP_Groups_Member::get_group_member_ids( $group->id ); 11 18 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; 13 21 14 22 $ud = bp_core_get_core_userdata( $user_id ); 15 23 16 24 // Set up and send the message 17 25 $to = $ud->user_email; 18 26 19 $group_link = site_url( $bp->groups->slug . '/' . $group->slug );20 $settings_link = bp_core_get_user_domain( $user_id ) . 27 $group_link = site_url( $bp->groups->slug . '/' . $group->slug ); 28 $settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 21 29 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 ); 24 31 25 To view the group: %2$s26 27 ---------------------28 ', 'buddypress' ), $group->name, $group_link );29 30 32 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 31 33 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 ); 34 36 $subject = apply_filters( 'groups_notification_group_updated_subject', $subject, &$group ); 35 37 $message = apply_filters( 'groups_notification_group_updated_message', $message, &$group, $group_link ); 36 38 … … 42 44 do_action( 'bp_groups_sent_updated_email', $user_ids, $subject, $message, $group_id ); 43 45 } 44 46 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 */ 45 57 function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) { 46 58 global $bp; 47 59 … … 51 63 return false; 52 64 53 65 $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 ); 55 67 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 ); 58 70 59 71 $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/'; 62 74 63 75 // Set up and send the message 64 76 $to = $ud->user_email; 65 77 $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 66 78 $subject = '[' . $sitename . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ); 67 79 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 ); 70 81 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$s75 76 To view %4$s\'s profile: %5$s77 78 ---------------------79 ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $requesting_user_name, $profile_link );80 81 82 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 82 83 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 ); 85 86 $subject = apply_filters( 'groups_notification_new_membership_request_subject', $subject, &$group ); 86 87 $message = apply_filters( 'groups_notification_new_membership_request_message', $message, &$group, $requesting_user_name, $profile_link, $group_requests ); 87 88 … … 90 91 do_action( 'bp_groups_sent_membership_request_email', $admin_id, $subject, $message, $requesting_user_id, $group_id, $membership_id ); 91 92 } 92 93 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 */ 93 103 function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) { 94 104 global $bp; 95 105 … … 104 114 105 115 $group = new BP_Groups_Group( $group_id ); 106 116 107 $ud = bp_core_get_core_userdata( $requesting_user_id);117 $ud = bp_core_get_core_userdata( $requesting_user_id ); 108 118 109 $group_link = bp_get_group_permalink( $group );110 $settings_link = bp_core_get_user_domain( $requesting_user_id ) . 119 $group_link = bp_get_group_permalink( $group ); 120 $settings_link = bp_core_get_user_domain( $requesting_user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 111 121 112 122 // Set up and send the message 113 123 $to = $ud->user_email; … … 115 125 116 126 if ( $accepted ) { 117 127 $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 ); 120 129 121 To view the group please login and visit: %2$s122 123 ---------------------124 ', 'buddypress' ), $group->name, $group_link );125 126 130 } else { 127 131 $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 ); 135 133 } 136 134 137 135 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 138 136 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 ); 141 139 $subject = apply_filters( 'groups_notification_membership_request_completed_subject', $subject, &$group ); 142 140 $message = apply_filters( 'groups_notification_membership_request_completed_message', $message, &$group, $group_link ); 143 141 … … 146 144 do_action( 'bp_groups_sent_membership_approved_email', $requesting_user_id, $subject, $message, $group_id ); 147 145 } 148 146 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 */ 149 155 function groups_notification_promoted_member( $user_id, $group_id ) { 150 156 global $bp; 151 157 152 158 if ( groups_is_user_admin( $user_id, $group_id ) ) { 153 159 $promoted_to = __( 'an administrator', 'buddypress' ); 154 $type = 'member_promoted_to_admin';160 $type = 'member_promoted_to_admin'; 155 161 } else { 156 162 $promoted_to = __( 'a moderator', 'buddypress' ); 157 $type = 'member_promoted_to_mod';163 $type = 'member_promoted_to_mod'; 158 164 } 159 165 160 166 // Post a screen notification first. … … 164 170 return false; 165 171 166 172 $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 ); 168 174 169 $group_link = bp_get_group_permalink( $group );170 $settings_link = bp_core_get_user_domain( $user_id ) . 175 $group_link = bp_get_group_permalink( $group ); 176 $settings_link = bp_core_get_user_domain( $user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 171 177 172 178 // Set up and send the message 173 179 $to = $ud->user_email; 174 180 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 175 181 $subject = '[' . $sitename . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ); 176 182 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 ); 179 184 180 To view the group please visit: %3$s181 182 ---------------------183 ', 'buddypress' ), $promoted_to, $group->name, $group_link );184 185 185 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 186 186 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 ); 189 189 $subject = apply_filters( 'groups_notification_promoted_member_subject', $subject, &$group ); 190 190 $message = apply_filters( 'groups_notification_promoted_member_message', $message, &$group, $promoted_to, $group_link ); 191 191 … … 195 195 } 196 196 add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 ); 197 197 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 */ 198 207 function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) { 199 208 global $bp; 200 209 201 $inviter_ud = bp_core_get_core_userdata( $inviter_user_id );210 $inviter_ud = bp_core_get_core_userdata( $inviter_user_id ); 202 211 $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true ); 203 212 $inviter_link = bp_core_get_user_domain( $inviter_user_id ); 204 213 … … 215 224 216 225 $invited_ud = bp_core_get_core_userdata($invited_user_id); 217 226 218 $settings_link = bp_core_get_user_domain( $invited_user_id ) . 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/'; 221 230 222 231 // Set up and send the message 223 232 $to = $invited_ud->user_email; 224 233 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 225 234 $subject = '[' . $sitename . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ); 226 235 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 ); 229 237 230 To view your group invites visit: %3$s231 232 To view the group visit: %4$s233 234 To view %5$s\'s profile visit: %6$s235 236 ---------------------237 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link );238 239 238 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 240 239 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 ); 243 242 $subject = apply_filters( 'groups_notification_group_invites_subject', $subject, &$group ); 244 243 $message = apply_filters( 'groups_notification_group_invites_message', $message, &$group, $inviter_name, $inviter_link, $invites_link, $group_link ); 245 244 … … 249 248 do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group ); 250 249 } 251 250 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 */ 252 261 function groups_at_message_notification( $content, $poster_user_id, $group_id, $activity_id ) { 253 262 global $bp; 254 263 255 / * Scan for @username strings in an activity update. Notify each user. */264 // Scan for @username strings in an activity update. Notify each user. 256 265 $pattern = '/[@]+([A-Za-z0-9-_\.]+)/'; 257 266 preg_match_all( $pattern, $content, $usernames ); 258 267 259 / * Make sure there's only one instance of each username */268 // Make sure there's only one instance of each username 260 269 if ( !$usernames = array_unique( $usernames[1] ) ) 261 270 return false; 262 271 … … 266 275 if ( !$receiver_user_id = bp_core_get_userid( $username ) ) 267 276 continue; 268 277 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. 270 279 if ( !groups_is_user_member( $receiver_user_id, $group_id ) ) 271 280 continue; 272 281 … … 274 283 if ( 'no' != get_user_meta( $user_id, 'notification_activity_new_mention', true ) ) { 275 284 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 276 285 277 $message_link = bp_activity_get_permalink( $activity_id );278 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . 286 $message_link = bp_activity_get_permalink( $activity_id ); 287 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . BP_SETTINGS_SLUG . '/notifications/'; 279 288 280 289 $poster_name = stripslashes( $poster_name ); 281 $content = bp_groups_filter_kses( stripslashes( $content ) );290 $content = bp_groups_filter_kses( stripslashes( $content ) ); 282 291 283 292 // 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; 286 295 $sitename = wp_specialchars_decode( get_blog_option( BP_ROOT_BLOG, 'blogname' ), ENT_QUOTES ); 287 296 $subject = '[' . $sitename . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name ); 288 297 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 ); 291 299 292 "%3$s"293 294 To view and respond to the message, log in and visit: %4$s295 296 ---------------------297 ', 'buddypress' ), $poster_name, $group->name, $content, $message_link );298 299 300 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 300 301 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 ); 303 304 $subject = apply_filters( 'groups_at_message_notification_subject', $subject, &$group, $poster_name ); 304 305 $message = apply_filters( 'groups_at_message_notification_message', $message, &$group, $poster_name, $content, $message_link ); 305 306 … … 311 312 } 312 313 add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 ); 313 314 314 315 ?> 315 ?> 316 No newline at end of file