Skip to:
Content

BuddyPress.org

Changeset 1082


Ignore:
Timestamp:
02/12/2009 09:14:59 PM (17 years ago)
Author:
apeatling
Message:

Fixed bug with rejecting group invites. Added support for mass deleting notifications and invites when a group is deleted.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-classes.php

    r1052 r1082  
    309309    }
    310310   
     311    function delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id ) {
     312        global $wpdb, $bp;
     313       
     314        if ( $component_action )
     315            $component_action_sql = $wpdb->prepare( "AND component_action = %s", $compoennt_action );
     316       
     317        if ( $secondary_item_id )
     318            $secondary_item_sql = $wpdb->prepare( "AND secondary_item_id = %d", $secondary_item_id );
     319       
     320        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->core->table_name_notifications} WHERE item_id = %d AND component_name = %s {$component_action_sql} {$secondary_item_sql}", $item_id, $component_name ) );
     321    }
    311322}   
    312323
  • trunk/bp-core/bp-core-notifications.php

    r1052 r1082  
    8181}
    8282
     83function bp_core_delete_all_notifications_by_type( $item_id, $component_name, $component_action = false, $secondary_item_id = false ) {
     84    return BP_Core_Notification::delete_all_by_type( $item_id, $component_name, $component_action, $secondary_item_id );
     85}
     86
    8387function bp_core_check_notification_access( $user_id, $notification_id ) {
    8488    if ( !BP_Core_Notification::check_access( $user_id, $notification_id ) )
  • trunk/bp-groups.php

    r1072 r1082  
    324324    } else if ( isset($bp->action_variables) && in_array( 'reject', $bp->action_variables ) && is_numeric($group_id) ) {
    325325       
    326         if ( !groups_reject_invite( $group_id, $bp->loggedin_user->id ) ) {
     326        if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) {
    327327            bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' );                         
    328328        } else {           
     
    515515           
    516516            bp_core_add_message( __('Group invites sent.', 'buddypress') );
     517
     518            do_action( 'groups_screen_group_invite', $group_obj->id );
     519
    517520            bp_core_redirect( bp_group_permalink( $group_obj, false ) );
    518521        } else {
    519             do_action( 'groups_screen_group_invite', $group_obj->id );
    520            
    521522            // Show send invite page
    522523            bp_core_load_template( 'groups/send-invite' ); 
     
    843844            } else {
    844845                bp_core_add_message( __( 'The group was deleted successfully', 'buddypress' ) );
     846
     847                do_action( 'groups_group_deleted', $_POST['group-id'] );
     848
    845849                bp_core_redirect( $bp->loggedin_user->domain . $bp->groups->slug . '/' );
    846850            }
    847 
    848             do_action( 'groups_group_deleted', $_POST['group-id'] );
    849851
    850852            bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component );
     
    16471649   
    16481650    do_action( 'groups_reject_invite', $user_id, $group_id );
     1651   
    16491652    return true;
    16501653}
     
    16721675
    16731676    if ( !$skip_check ) {
    1674         if ( !check_admin_referer( 'groups_send_invites' ) )
     1677        if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
    16751678            return false;
    16761679    }
     
    16881691   
    16891692    do_action( 'groups_send_invites', $group_obj->id, $invited_users );
     1693}
     1694
     1695function groups_delete_all_group_invites( $group_id ) {
     1696    return BP_Groups_Group::delete_all_invites( $group_id );
    16901697}
    16911698
     
    20402047    // Remove the activity stream item
    20412048    groups_delete_activity( array( 'item_id' => $group_id, 'component_name' => 'groups', 'component_action' => 'created_group', 'user_id' => $bp->loggedin_user->id ) );
    2042    
     2049 
     2050    // Remove all outstanding invites for this group
     2051    groups_delete_all_group_invites( $group_id );
     2052
     2053    // Remove all notifications for any user belonging to this group
     2054    bp_core_delete_all_notifications_by_type( $group_id, $bp->groups->slug );
     2055   
    20432056    do_action( 'groups_delete_group', $group_id );
    20442057   
     
    22402253add_action( 'wpmu_delete_user', 'groups_remove_data', 1 );
    22412254add_action( 'delete_user', 'groups_remove_data', 1 );
     2255
    22422256
    22432257// List actions to clear super cached pages on, if super cache is installed
  • trunk/bp-groups/bp-groups-classes.php

    r1054 r1082  
    476476        return array( 'groups' => $paged_groups, 'total' => $total_groups );
    477477    }
     478   
     479    function delete_all_invites( $group_id ) {
     480        global $wpdb, $bp;
     481       
     482        return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE group_id = %d AND invite_sent = 1", $group_id ) );
     483    }
    478484}
    479485
     
    616622    function delete( $user_id, $group_id, $check_empty = true ) {
    617623        global $wpdb, $bp;
    618        
     624
    619625        $delete_result = $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $user_id, $group_id ) );
    620626       
Note: See TracChangeset for help on using the changeset viewer.