Changeset 2463 for trunk/bp-groups/bp-groups-notifications.php
- Timestamp:
- 01/27/2010 11:24:01 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/bp-groups/bp-groups-notifications.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-notifications.php
r2413 r2463 10 10 if ( 'no' == get_usermeta( $user->user_id, 'notification_groups_group_updated' ) ) continue; 11 11 12 $ud = get_userdata( $user->user_id );12 $ud = bp_core_get_core_userdata( $user->user_id ); 13 13 14 14 // Set up and send the message … … 46 46 $group = new BP_Groups_Group( $group_id, false, false ); 47 47 48 $ud = get_userdata($admin_id);49 $requesting_ud = get_userdata($requesting_user_id);48 $ud = bp_core_get_core_userdata($admin_id); 49 $requesting_ud = bp_core_get_core_userdata($requesting_user_id); 50 50 51 51 $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests'; … … 90 90 $group = new BP_Groups_Group( $group_id, false, false ); 91 91 92 $ud = get_userdata($requesting_user_id);92 $ud = bp_core_get_core_userdata($requesting_user_id); 93 93 94 94 $group_link = bp_get_group_permalink( $group ); … … 143 143 144 144 $group = new BP_Groups_Group( $group_id, false, false ); 145 $ud = get_userdata($user_id);145 $ud = bp_core_get_core_userdata($user_id); 146 146 147 147 $group_link = bp_get_group_permalink( $group ); … … 171 171 global $bp; 172 172 173 $inviter_ud = get_userdata( $inviter_user_id );173 $inviter_ud = bp_core_get_core_userdata( $inviter_user_id ); 174 174 $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true ); 175 175 $inviter_link = bp_core_get_user_domain( $inviter_user_id ); … … 186 186 return false; 187 187 188 $invited_ud = get_userdata($invited_user_id);188 $invited_ud = bp_core_get_core_userdata($invited_user_id); 189 189 190 190 $settings_link = bp_core_get_user_domain( $invited_user_id ) . 'settings/notifications/'; … … 216 216 } 217 217 218 function groups_at_message_notification( $content, $poster_user_id, $group_id, $activity_id ) { 219 global $bp; 220 221 /* Scan for @username strings in an activity update. Notify each user. */ 222 $pattern = '/[@]+([A-Za-z0-9-_]+)/'; 223 preg_match_all( $pattern, $content, $usernames ); 224 225 /* Make sure there's only one instance of each username */ 226 if ( !$usernames = array_unique( $usernames[1] ) ) 227 return false; 228 229 $group = new BP_Groups_Group( $group_id, false, false ); 230 231 foreach( (array)$usernames as $username ) { 232 if ( !$receiver_user_id = bp_core_get_userid($username) ) 233 continue; 234 235 /* Check the user is a member of the group before sending the update. */ 236 if ( !groups_is_user_member( $receiver_user_id, $group_id ) ) 237 continue; 238 239 // Now email the user with the contents of the message (if they have enabled email notifications) 240 if ( !get_usermeta( $user_id, 'notification_activity_new_mention' ) || 'yes' == get_usermeta( $user_id, 'notification_activity_new_mention' ) ) { 241 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 242 243 $message_link = bp_activity_get_permalink( $activity_id ); 244 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . 'settings/notifications/'; 245 246 // Set up and send the message 247 $ud = bp_core_get_core_userdata( $receiver_user_id ); 248 $to = $ud->user_email; 249 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in the group "%s"', 'buddypress' ), stripslashes( $poster_name ), wp_filter_kses( stripslashes( $group->name ) ) ); 250 251 $message = sprintf( __( 252 '%s mentioned you in the group "%s": 253 254 "%s" 255 256 To view and respond to the message, log in and visit: %s 257 258 --------------------- 259 ', 'buddypress' ), $poster_name, wp_filter_kses( stripslashes( $group->name ) ), wp_filter_kses( stripslashes($content) ), $message_link ); 260 261 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 262 263 // Send it 264 wp_mail( $to, $subject, $message ); 265 } 266 } 267 } 268 add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 ); 269 270 218 271 ?>
Note:
See TracChangeset
for help on using the changeset viewer.