Skip to:
Content

BuddyPress.org

Changeset 4324


Ignore:
Timestamp:
05/02/2011 08:55:26 PM (14 years ago)
Author:
boonebgorges
Message:

Fixes group invitations so that they work when JavaScript is disabled. Fixes #2245. Moves bp_groups_sent_invited_email hook inside invitation loop so that it's actually sent for each invited member.

Location:
trunk/bp-groups
Files:
4 edited

Legend:

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

    r4211 r4324  
    889889    }
    890890
    891     function check_has_invite( $user_id, $group_id ) {
     891    function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
    892892        global $wpdb, $bp;
    893893
    894894        if ( !$user_id )
    895895            return false;
    896 
    897         return $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0 AND invite_sent = 1", $user_id, $group_id ) );
     896       
     897        $sql = "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0";
     898       
     899        if ( 'sent' == $type )
     900            $sql .= " AND invite_sent = 1";
     901
     902        return $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) );
    898903    }
    899904
  • trunk/bp-groups/bp-groups-functions.php

    r4230 r4324  
    525525        return false;
    526526
    527     if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id ) ) {
     527    if ( !groups_is_user_member( $user_id, $group_id ) && !groups_check_user_has_invite( $user_id, $group_id, 'all' ) ) {
    528528        $invite                = new BP_Groups_Member;
    529529        $invite->group_id      = $group_id;
     
    628628}
    629629
    630 function groups_check_user_has_invite( $user_id, $group_id ) {
    631     return BP_Groups_Member::check_has_invite( $user_id, $group_id );
     630/**
     631 * Check to see whether a user has already been invited to a group
     632 *
     633 * By default, the function checks for invitations that have been sent. Entering 'all' as the $type
     634 * parameter will return unsent invitations as well (useful to make sure AJAX requests are not
     635 * duplicated)
     636 *
     637 * @package BuddyPress Groups
     638 *
     639 * @param int $user_id Potential group member
     640 * @param int $group_id Potential group
     641 * @param str $type Optional. Use 'sent' to check for sent invites, 'all' to check for all
     642 * @return bool Returns true if an invitation is found
     643 */
     644function groups_check_user_has_invite( $user_id, $group_id, $type = 'sent' ) {
     645    return BP_Groups_Member::check_has_invite( $user_id, $group_id, $type );
    632646}
    633647
  • trunk/bp-groups/bp-groups-notifications.php

    r4144 r4324  
    245245
    246246        wp_mail( $to, $subject, $message );
    247     }
    248 
    249     do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
     247               
     248        do_action( 'bp_groups_sent_invited_email', $invited_user_id, $subject, $message, $group );
     249    }
    250250}
    251251
  • trunk/bp-groups/bp-groups-screens.php

    r4317 r4324  
    381381            if ( !check_admin_referer( 'groups_send_invites', '_wpnonce_send_invites' ) )
    382382                return false;
     383
     384            if ( !empty( $_POST['friends'] ) ) {
     385                foreach( (array)$_POST['friends'] as $friend ) {
     386                    groups_invite_user( array( 'user_id' => $friend, 'group_id' => $bp->groups->current_group->id ) );
     387                }
     388            }
    383389
    384390            // Send the invites.
Note: See TracChangeset for help on using the changeset viewer.