Changeset 4738 for trunk/bp-groups/bp-groups-notifications.php
- Timestamp:
- 07/20/2011 11:29:25 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-notifications.php
r4648 r4738 250 250 } 251 251 252 function groups_at_message_notification( $content, $poster_user_id, $group_id, $activity_id ) {253 global $bp;254 255 /* Scan for @username strings in an activity update. Notify each user. */256 $pattern = '/[@]+([A-Za-z0-9-_\.@]+)/';257 preg_match_all( $pattern, $content, $usernames );258 259 /* Make sure there's only one instance of each username */260 if ( !$usernames = array_unique( $usernames[1] ) )261 return false;262 263 $group = new BP_Groups_Group( $group_id );264 265 foreach( (array)$usernames as $username ) {266 if ( !$receiver_user_id = bp_core_get_userid( $username ) )267 continue;268 269 /* Check the user is a member of the group before sending the update. */270 if ( !groups_is_user_member( $receiver_user_id, $group_id ) )271 continue;272 273 // Now email the user with the contents of the message (if they have enabled email notifications)274 if ( 'no' != bp_get_user_meta( $user_id, 'notification_activity_new_mention', true ) ) {275 $poster_name = bp_core_get_user_displayname( $poster_user_id );276 277 $message_link = bp_activity_get_permalink( $activity_id );278 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . bp_get_settings_slug() . '/notifications/';279 280 $poster_name = stripslashes( $poster_name );281 $content = bp_groups_filter_kses( stripslashes( $content ) );282 283 // Set up and send the message284 $ud = bp_core_get_core_userdata( $receiver_user_id );285 $to = $ud->user_email;286 $sitename = wp_specialchars_decode( get_blog_option( bp_get_root_blog_id(), 'blogname' ), ENT_QUOTES );287 $subject = '[' . $sitename . '] ' . sprintf( __( '%1$s mentioned you in the group "%2$s"', 'buddypress' ), $poster_name, $group->name );288 289 $message = sprintf( __(290 '%1$s mentioned you in the group "%2$s":291 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 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );300 301 /* Send the message */302 $to = apply_filters( 'groups_at_message_notification_to', $to );303 $subject = apply_filters( 'groups_at_message_notification_subject', $subject, $group, $poster_name );304 $message = apply_filters( 'groups_at_message_notification_message', $message, $group, $poster_name, $content, $message_link, $settings_link );305 306 wp_mail( $to, $subject, $message );307 }308 }309 310 do_action( 'bp_groups_sent_mention_email', $usernames, $subject, $message, $content, $poster_user_id, $group_id, $activity_id );311 }312 add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 );313 314 315 252 ?>
Note: See TracChangeset
for help on using the changeset viewer.