Changeset 10373 for trunk/src/bp-groups/bp-groups-notifications.php
- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-notifications.php
r10148 r10373 66 66 foreach ( (array) $user_ids as $user_id ) { 67 67 68 // Continue if member opted out of receiving this email 68 // Continue if member opted out of receiving this email. 69 69 if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_group_updated', true ) ) { 70 70 continue; … … 73 73 $ud = bp_core_get_core_userdata( $user_id ); 74 74 75 // Set up and send the message 75 // Set up and send the message. 76 76 $to = $ud->user_email; 77 77 … … 150 150 * @param int $group_id ID of the group. 151 151 * @param int $membership_id ID of the group membership object. 152 *153 152 * @return false|null False on failure. 154 153 */ 155 154 function groups_notification_new_membership_request( $requesting_user_id = 0, $admin_id = 0, $group_id = 0, $membership_id = 0 ) { 156 155 157 // Trigger a BuddyPress Notification 156 // Trigger a BuddyPress Notification. 158 157 if ( bp_is_active( 'notifications' ) ) { 159 158 bp_notifications_add_notification( array( … … 166 165 } 167 166 168 // Bail if member opted out of receiving this email 167 // Bail if member opted out of receiving this email. 169 168 if ( 'no' === bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) ) { 170 169 return false; 171 170 } 172 171 173 // Username of the user requesting a membership: %1$s in mail 172 // Username of the user requesting a membership: %1$s in mail. 174 173 $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id ); 175 174 $group = groups_get_group( array( 'group_id' => $group_id ) ); 176 175 177 // Group Administrator user's data 176 // Group Administrator user's data. 178 177 $ud = bp_core_get_core_userdata( $admin_id ); 179 178 $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests'; 180 179 181 // Link to the user's profile who's requesting a membership: %3$s in mail 180 // Link to the user's profile who's requesting a membership: %3$s in mail. 182 181 $profile_link = bp_core_get_user_domain( $requesting_user_id ); 183 182 184 183 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; 185 // Link to the group administrator email settings: %s in "disable notifications" part of the email 184 // Link to the group administrator email settings: %s in "disable notifications" part of the email. 186 185 $settings_link = bp_core_get_user_domain( $admin_id ) . $settings_slug . '/notifications/'; 187 186 … … 189 188 $membership = new BP_Groups_Member( false, false, $membership_id ); 190 189 191 // Set up and send the message 190 // Set up and send the message. 192 191 $to = $ud->user_email; 193 192 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ) ) ); … … 225 224 } 226 225 227 // Only show the disable notifications line if the settings component is enabled 226 // Only show the disable notifications line if the settings component is enabled. 228 227 if ( bp_is_active( 'settings' ) ) { 229 228 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 289 288 * @param bool $accepted Optional. Whether the membership request was accepted. 290 289 * Default: true. 291 *292 290 * @return false|null 293 291 */ 294 292 function groups_notification_membership_request_completed( $requesting_user_id = 0, $group_id = 0, $accepted = true ) { 295 293 296 // Trigger a BuddyPress Notification 294 // Trigger a BuddyPress Notification. 297 295 if ( bp_is_active( 'notifications' ) ) { 298 296 299 // What type of acknowledgement 297 // What type of acknowledgement. 300 298 $type = ! empty( $accepted ) 301 299 ? 'membership_request_accepted' … … 310 308 } 311 309 312 // Bail if member opted out of receiving this email 310 // Bail if member opted out of receiving this email. 313 311 if ( 'no' === bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) ) { 314 312 return false; … … 322 320 $to = $ud->user_email; 323 321 324 // Set up and send the message 322 // Set up and send the message. 325 323 if ( ! empty( $accepted ) ) { 326 324 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name ) ) ); … … 344 342 } 345 343 346 // Only show the disable notifications line if the settings component is enabled 344 // Only show the disable notifications line if the settings component is enabled. 347 345 if ( bp_is_active( 'settings' ) ) { 348 346 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 404 402 * @param int $user_id ID of the user. 405 403 * @param int $group_id ID of the group. 406 *407 404 * @return false|null False on failure. 408 405 */ … … 418 415 } 419 416 420 // Trigger a BuddyPress Notification 417 // Trigger a BuddyPress Notification. 421 418 if ( bp_is_active( 'notifications' ) ) { 422 419 bp_notifications_add_notification( array( … … 428 425 } 429 426 430 // Bail if admin opted out of receiving this email 427 // Bail if admin opted out of receiving this email. 431 428 if ( 'no' === bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) ) { 432 429 return false; … … 439 436 $settings_link = bp_core_get_user_domain( $user_id ) . $settings_slug . '/notifications/'; 440 437 441 // Set up and send the message 438 // Set up and send the message. 442 439 $to = $ud->user_email; 443 440 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ) ) ); … … 450 447 ', 'buddypress' ), $promoted_to, $group->name, $group_link ); 451 448 452 // Only show the disable notifications line if the settings component is enabled 449 // Only show the disable notifications line if the settings component is enabled. 453 450 if ( bp_is_active( 'settings' ) ) { 454 451 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 511 508 * @param BP_Groups_Member $member Member object. 512 509 * @param int $inviter_user_id ID of the user who sent the invite. 513 *514 510 * @return null|false False on failure. 515 511 */ 516 512 function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) { 517 513 518 // Bail if member has already been invited 514 // Bail if member has already been invited. 519 515 if ( ! empty( $member->invite_sent ) ) { 520 516 return; … … 527 523 $group_link = bp_get_group_permalink( $group ); 528 524 529 // Setup the ID for the invited user 525 // Setup the ID for the invited user. 530 526 $invited_user_id = $member->user_id; 531 527 532 // Trigger a BuddyPress Notification 528 // Trigger a BuddyPress Notification. 533 529 if ( bp_is_active( 'notifications' ) ) { 534 530 bp_notifications_add_notification( array( … … 540 536 } 541 537 542 // Bail if member opted out of receiving this email 538 // Bail if member opted out of receiving this email. 543 539 if ( 'no' === bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) ) { 544 540 return false; … … 551 547 $invites_link = trailingslashit( $invited_link . bp_get_groups_slug() . '/invites' ); 552 548 553 // Set up and send the message 549 // Set up and send the message. 554 550 $to = $invited_ud->user_email; 555 551 $subject = bp_get_email_subject( array( 'text' => sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ) ) ); … … 566 562 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link ); 567 563 568 // Only show the disable notifications line if the settings component is enabled 564 // Only show the disable notifications line if the settings component is enabled. 569 565 if ( bp_is_active( 'settings' ) ) { 570 566 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); … … 634 630 * @param string $format 'string' for BuddyBar-compatible notifications; 'array' 635 631 * for WP Toolbar. Default: 'string'. 636 *637 632 * @return string 638 633 */ … … 649 644 650 645 // Set up the string and the filter 651 // Because different values are passed to the filters, we'll return the652 // values inline646 // because different values are passed to the filters, 647 // we'll return values inline. 653 648 if ( (int) $total_items > 1 ) { 654 649 $text = sprintf( __( '%1$d new membership requests for the group "%2$s"', 'buddypress' ), (int) $total_items, $group->name ); … … 1261 1256 function bp_groups_screen_my_groups_mark_notifications() { 1262 1257 1263 // Delete group request notifications for the user 1258 // Delete group request notifications for the user. 1264 1259 if ( isset( $_GET['n'] ) && bp_is_active( 'notifications' ) ) { 1265 1260 1266 // Get the necessary ID's 1261 // Get the necessary ID's. 1267 1262 $group_id = buddypress()->groups->id; 1268 1263 $user_id = bp_loggedin_user_id(); 1269 1264 1270 // Mark notifications read 1265 // Mark notifications read. 1271 1266 bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_accepted' ); 1272 1267 bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'membership_request_rejected' );
Note: See TracChangeset
for help on using the changeset viewer.