Changeset 4738 for trunk/bp-activity/bp-activity-notifications.php
- Timestamp:
- 07/20/2011 11:29:25 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-activity/bp-activity-notifications.php
r4638 r4738 9 9 * @param int $activity_id The id of the activity update 10 10 */ 11 function bp_activity_at_message_notification( $ content, $poster_user_id, $activity_id ) {11 function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) { 12 12 global $bp; 13 13 14 /* Scan for @username strings in an activity update. Notify each user. */ 15 $pattern = '/[@]+([A-Za-z0-9-_\.@]+)/'; 16 preg_match_all( $pattern, $content, $usernames ); 14 $activity = new BP_Activity_Activity( $activity_id ); 17 15 18 /* Make sure there's only one instance of each username */ 19 if ( !$usernames = array_unique( $usernames[1] ) ) 20 return false; 16 $subject = ''; 17 $message = ''; 18 19 // Add the BP notification 20 bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $activity->user_id ); 21 22 // Now email the user with the contents of the message (if they have enabled email notifications) 23 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 24 $poster_name = bp_core_get_user_displayname( $activity->user_id ); 21 25 22 foreach( (array)$usernames as $username ) { 23 if ( bp_is_username_compatibility_mode() ) 24 $receiver_user_id = bp_core_get_userid( $username ); 25 else 26 $receiver_user_id = bp_core_get_userid_from_nicename( $username ); 26 $message_link = bp_activity_get_permalink( $activity_id ); 27 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . bp_get_settings_slug() . '/notifications/'; 27 28 28 if ( empty( $receiver_user_id ) )29 continue;29 $poster_name = stripslashes( $poster_name ); 30 $content = bp_activity_filter_kses( strip_tags( stripslashes( $activity->content ) ) ); 30 31 31 bp_core_add_notification( $activity_id, $receiver_user_id, 'activity', 'new_at_mention', $poster_user_id ); 32 // Set up and send the message 33 $ud = bp_core_get_core_userdata( $receiver_user_id ); 34 $to = $ud->user_email; 35 $sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES ); 36 $subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ); 32 37 33 $subject = ''; 34 $message = ''; 38 if ( bp_is_active( 'groups' ) && bp_is_group() ) { 39 $message = sprintf( __( 40 '%1$s mentioned you in the group "%2$s": 35 41 36 // Now email the user with the contents of the message (if they have enabled email notifications) 37 if ( 'no' != bp_get_user_meta( $receiver_user_id, 'notification_activity_new_mention', true ) ) { 38 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 42 "%3$s" 39 43 40 $message_link = bp_activity_get_permalink( $activity_id ); 41 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . bp_get_settings_slug() . '/notifications/'; 44 To view and respond to the message, log in and visit: %4$s 42 45 43 $poster_name = stripslashes( $poster_name ); 44 $content = bp_activity_filter_kses( stripslashes($content) ); 45 46 // Set up and send the message 47 $ud = bp_core_get_core_userdata( $receiver_user_id ); 48 $to = $ud->user_email; 49 $sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES ); 50 $subject = '[' . $sitename . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), $poster_name ); 51 52 $message = sprintf( __( 46 --------------------- 47 ', 'buddypress' ), $poster_name, bp_get_current_group_name(), $content, $message_link ); 48 } else { 49 $message = sprintf( __( 53 50 '%1$s mentioned you in an update: 54 51 … … 59 56 --------------------- 60 57 ', 'buddypress' ), $poster_name, $content, $message_link ); 58 } 61 59 62 60 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 63 61 64 65 $to= apply_filters( 'bp_activity_at_message_notification_to', $to );66 67 62 /* Send the message */ 63 $to = apply_filters( 'bp_activity_at_message_notification_to', $to ); 64 $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name ); 65 $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link ); 68 66 69 wp_mail( $to, $subject, $message ); 70 } 71 72 do_action( 'bp_activity_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $activity_id ); 67 wp_mail( $to, $subject, $message ); 73 68 } 69 70 do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content ); 74 71 } 75 add_action( 'bp_activity_posted_update', 'bp_activity_at_message_notification', 10, 3 );76 72 77 73 function bp_activity_new_comment_notification( $comment_id, $commenter_id, $params ) {
Note: See TracChangeset
for help on using the changeset viewer.