Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/30/2013 06:14:08 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Refactor Groups component's approach to Notifications and Activity integration:

  • Introduce helper functions for handling the adding/marking/deleting of notifications and adding/deleting activity stream entries. Hook these new functions into their respective actions rather than have them hardcoded and interspersed amongst the first-class code.
  • Inadvertently fixes a bug where banning or removing a member from a group within 5 minutes of their having joined would not delete the recent activity stream update.
  • See #5266.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-screens.php

    r7537 r7624  
    2828function groups_screen_my_groups() {
    2929
    30     $bp = buddypress();
    31 
    32     // Delete group request notifications for the user
    33     if ( isset( $_GET['n'] ) ) {
    34         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
    35         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
    36         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
    37         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
    38     }
    39 
    4030    do_action( 'groups_screen_my_groups' );
    4131
     
    9484    }
    9585
    96     // Remove notifications
    97     bp_core_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->groups->id, 'group_invite' );
    98 
    9986    do_action( 'groups_screen_group_invites', $group_id );
    10087
     
    10491function groups_screen_group_home() {
    10592
    106     if ( ! bp_is_single_item() )
    107         return false;
    108 
    109     $bp = buddypress();
    110 
    111     if ( isset( $_GET['n'] ) ) {
    112         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_accepted' );
    113         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'membership_request_rejected' );
    114         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_mod'      );
    115         bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'member_promoted_to_admin'    );
     93    if ( ! bp_is_single_item() ) {
     94        return false;
    11695    }
    11796
     
    805784
    806785function groups_screen_group_admin_requests() {
    807     global $bp;
    808 
    809     if ( 'membership-requests' != bp_get_group_current_admin_tab() )
    810         return false;
    811 
    812     if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) )
    813         return false;
    814 
    815     // Remove any screen notifications
    816     bp_core_mark_notifications_by_type( bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request' );
    817 
    818     $request_action = (string)bp_action_variable( 1 );
    819     $membership_id  = (int)bp_action_variable( 2 );
     786    $bp = buddypress();
     787
     788    if ( 'membership-requests' != bp_get_group_current_admin_tab() ) {
     789        return false;
     790    }
     791
     792    if ( ! bp_is_item_admin() || ( 'public' == $bp->groups->current_group->status ) ) {
     793        return false;
     794    }
     795
     796    $request_action = (string) bp_action_variable( 1 );
     797    $membership_id  = (int) bp_action_variable( 2 );
    820798
    821799    if ( !empty( $request_action ) && !empty( $membership_id ) ) {
Note: See TracChangeset for help on using the changeset viewer.