Skip to:
Content

BuddyPress.org

Ticket #5282: 5282.diff

File 5282.diff, 4.5 KB (added by imath, 11 years ago)
  • bp-groups/bp-groups-notifications.php

     
    5959function groups_notification_new_membership_request( $requesting_user_id, $admin_id, $group_id, $membership_id ) {
    6060
    6161        if ( bp_is_active( 'notifications' ) ) {
    62                 bp_notifications_add_notification( $requesting_user_id, $admin_id, 'groups', 'new_membership_request', $group_id );
     62                bp_notifications_add_notification( array(
     63                        'user_id'           => $admin_id,
     64                        'item_id'           => $requesting_user_id,
     65                        'secondary_item_id' => $group_id,
     66                        'component_name'    => buddypress()->groups->id,
     67                        'component_action'  => 'new_membership_request',
     68                        'date_notified'     => bp_core_current_time(),
     69                        'is_new'            => 1,
     70                ) );
    6371        }
    6472
    6573        if ( 'no' == bp_get_user_meta( $admin_id, 'notification_groups_membership_request', true ) )
     
    110118
    111119        // Post a screen notification first.
    112120        if ( bp_is_active( 'notifications' ) ) {
    113                 if ( $accepted ) {
    114                         bp_notifications_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' );
    115                 } else {
    116                         bp_notifications_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_rejected' );
    117                 }
     121
     122                $type = ! empty( $accepted ) ? 'membership_request_accepted' : 'membership_request_rejected' ;
     123
     124                bp_notifications_add_notification( array(
     125                        'user_id'           => $requesting_user_id,
     126                        'item_id'           => $group_id,
     127                        'component_name'    => buddypress()->groups->id,
     128                        'component_action'  => $type,
     129                        'date_notified'     => bp_core_current_time(),
     130                        'is_new'            => 1,
     131                ) );
    118132        }
    119133
    120134        if ( 'no' == bp_get_user_meta( $requesting_user_id, 'notification_membership_request_completed', true ) )
     
    181195
    182196        // Post a screen notification first.
    183197        if ( bp_is_active( 'notifications' ) ) {
    184                 bp_notifications_add_notification( $group_id, $user_id, 'groups', $type );
     198                bp_notifications_add_notification( array(
     199                        'user_id'           => $user_id,
     200                        'item_id'           => $group_id,
     201                        'component_name'    => buddypress()->groups->id,
     202                        'component_action'  => $type,
     203                        'date_notified'     => bp_core_current_time(),
     204                        'is_new'            => 1,
     205                ) );
    185206        }
    186207
    187208        if ( 'no' == bp_get_user_meta( $user_id, 'notification_groups_admin_promotion', true ) )
     
    234255
    235256                // Post a screen notification first.
    236257                if ( bp_is_active( 'notifications' ) ) {
    237                         bp_notifications_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' );
     258                        bp_notifications_add_notification( array(
     259                                'user_id'           => $invited_user_id,
     260                                'item_id'           => $group->id,
     261                                'component_name'    => buddypress()->groups->id,
     262                                'component_action'  => 'group_invite',
     263                                'date_notified'     => bp_core_current_time(),
     264                                'is_new'            => 1,
     265                        ) );
    238266                }
    239267
    240268                if ( 'no' == bp_get_user_meta( $invited_user_id, 'notification_groups_invite', true ) )
     
    568596                bp_notifications_mark_notifications_by_type( $user_id, $group_id, 'member_promoted_to_admin'    );
    569597        }
    570598}
    571 add_action( 'groups_screen_my_groups', 'bp_groups_screen_my_groups_mark_notifications', 10 );
    572 add_action( 'groups_screen_home',      'bp_groups_screen_my_groups_mark_notifications', 10 );
     599add_action( 'groups_screen_my_groups',  'bp_groups_screen_my_groups_mark_notifications', 10 );
     600add_action( 'groups_screen_group_home', 'bp_groups_screen_my_groups_mark_notifications', 10 );
    573601
    574602/**
    575603 * Mark group invitation notifications read when a member views their invitations
     
    581609                bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
    582610        }
    583611}
    584 add_action( 'groups_screen_invites', 'bp_groups_screen_invites_mark_notifications', 10 );
     612add_action( 'groups_screen_group_invites', 'bp_groups_screen_invites_mark_notifications', 10 );
    585613
    586614/**
    587615 * Mark group join requests read when an admin or moderator visits the group
     
    592620 */
    593621function bp_groups_screen_group_admin_requests_mark_notifications( $group_id ) {
    594622        if ( bp_is_active( 'notifications' ) ) {
    595                 bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), $group_id, 'new_membership_request' );
     623                bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'new_membership_request' );
    596624        }
    597625}
    598626add_action( 'groups_screen_group_admin_requests', 'bp_groups_screen_group_admin_requests_mark_notifications', 10 );