Skip to:
Content

BuddyPress.org

Changeset 548 for trunk/bp-groups.php


Ignore:
Timestamp:
11/17/2008 10:54:11 AM (16 years ago)
Author:
apeatling
Message:

Updated and fixed group invites and group invite email notifications.
Added screen notifications of group invites.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups.php

    r545 r548  
    33
    44define ( 'BP_GROUPS_IS_INSTALLED', 1 );
    5 define ( 'BP_GROUPS_VERSION', '0.2.5' );
     5define ( 'BP_GROUPS_VERSION', '0.2.6' );
    66
    77include_once( 'bp-groups/bp-groups-classes.php' );
     
    5858            is_confirmed tinyint(1) NOT NULL DEFAULT '0',
    5959            is_banned tinyint(1) NOT NULL DEFAULT '0',
     60            invite_sent tinyint(1) NOT NULL DEFAULT '0',
    6061            KEY group_id (group_id),
    6162            KEY is_admin (is_admin),
     
    309310    }
    310311   
     312    // Remove notifications
     313    bp_core_delete_notifications_for_user_by_type( $bp['loggedin_userid'], 'groups', 'group_invite' );
     314   
    311315    bp_catch_uri( 'groups/list-invites' ); 
    312316}
     
    458462   
    459463    if ( $is_single_group ) {
    460         if ( isset($bp['action_variables']) && $bp['action_variables'][1] == 'send' ) {
     464        if ( isset($bp['action_variables']) && $bp['action_variables'][0] == 'send' ) {
    461465            // Send the invites.
    462466            groups_send_invites($group_obj);
     
    865869            } else {
    866870                $user_fullname = bp_core_global_user_fullname( $requesting_user_id );
    867                 $user_url = bp_core_get_userurl( $requesting_user_id );
    868871                return '<a href="' . bp_group_permalink( $group, false ) . '/admin/membership-requests/" title="' . $user_fullname .' requests group membership">' . sprintf( __('%s requests membership for the group "%s"'), $user_fullname, $group->name ) . '</a>';
    869872            }   
     
    876879           
    877880            if ( (int)$total_items > 1 ) {
    878                 return '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests'), (int)$total_items, $group->name ) . '</a>';     
     881                return '<a href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d accepted group membership requests'), (int)$total_items, $group->name ) . '</a>';     
    879882            } else {
    880883                return '<a href="' . bp_group_permalink( $group, false ) . '/?new">' . sprintf( __('Membership for group "%s" accepted'), $group->name ) . '</a>';
     
    886889           
    887890            $group = new BP_Groups_Group( $group_id, false, false );
    888 
     891           
    889892            if ( (int)$total_items > 1 ) {
    890893                return '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('%d rejected group membership requests'), (int)$total_items, $group->name ) . '</a>';     
     
    901904
    902905            if ( (int)$total_items > 1 ) {
    903                 return '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups'), (int)$total_items ) . '</a>';       
     906                return '<a href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to an admin in %d groups'), (int)$total_items ) . '</a>';     
    904907            } else {
    905908                return '<a href="' . bp_group_permalink( $group, false ) . '/?new">' . sprintf( __('You were promoted to an admin in the group %s'), $group->name ) . '</a>';
     
    913916
    914917            if ( (int)$total_items > 1 ) {
    915                 return '<a href="' . site_url() . '/' . MEMBERS_SLUG . '/' . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups'), (int)$total_items ) . '</a>';     
     918                return '<a href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '" title="' . __( 'Groups', 'buddypress' ) . '">' . sprintf( __('You were promoted to a mod in %d groups'), (int)$total_items ) . '</a>';     
    916919            } else {
    917920                return '<a href="' . bp_group_permalink( $group, false ) . '/?new">' . sprintf( __('You were promoted to a mod in the group %s'), $group->name ) . '</a>';
     921            }   
     922        break;
     923       
     924        case 'group_invite':
     925            $group_id = $item_id;
     926
     927            $group = new BP_Groups_Group( $group_id, false, false );
     928            $user_url = bp_core_get_userurl( $user_id );
     929           
     930            if ( (int)$total_items > 1 ) {
     931                return '<a href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have %d new group invitations'), (int)$total_items ) . '</a>';       
     932            } else {
     933                return '<a href="' . $bp['loggedin_domain'] . $bp['groups']['slug'] . '/invites" title="' . __( 'Group Invites', 'buddypress' ) . '">' . sprintf( __('You have an invitation to the group: %s'), $group->name ) . '</a>';
    918934            }   
    919935        break;
     
    12421258
    12431259
    1244 function groups_get_invites_for_group( $group_id ) {
    1245     return BP_Groups_Group::get_invites( $group_id );
    1246 }
    1247 
    1248 
    1249 function groups_get_invites_for_user( $user_id = false ) {
     1260function groups_get_invites_for_group( $user_id, $group_id ) {
     1261    return BP_Groups_Group::get_invites( $user_id, $group_id );
     1262}
     1263
     1264function groups_check_user_has_invite( $user_id, $group_id ) {
     1265    BP_Groups_Member::check_has_invite( $user_id, $group_id );
     1266}
     1267
     1268function groups_get_invites_for_user( $user_id = false, $group_id = false ) {
    12501269    global $bp;
    12511270   
     
    12531272        $user_id = $bp['loggedin_userid'];
    12541273   
    1255     return BP_Groups_Member::get_invites($user_id);
     1274    return BP_Groups_Member::get_invites( $user_id, $group_id );
    12561275}
    12571276
     
    12611280   
    12621281    // Send friend invites.
    1263     $invited_users = groups_get_invites_for_group( $group_obj->id );
    1264    
    1265     for ( $i = 0; $i < count( $invited_users); $i++ ) {
    1266         $user_id = $invited_users[$i];
    1267 
    1268         // Send the email
    1269 
    1270         $invited_user = new BP_Core_User( $user_id );
    1271         $inviter_name = bp_core_get_userlink( $bp['loggedin_userid'], true, false, true );
    1272        
    1273         $message = "You have been invited to join the group '" . $group_obj->name . "' by " . $inviter_name . '.';
    1274         $message .= "\n\n";
    1275         $message .= "View the group: " . $invited_user->user_url . $bp['groups']['slug'] . "/" . $group_obj->slug . "\n";
    1276         $message .= "Accept the invite: " . $invited_user->user_url . $bp['groups']['slug'] . "/invites/accept/" . $group_obj->id . "\n";
    1277         $message .= "Reject the invite: " . $invited_user->user_url . $bp['groups']['slug'] . "/invites/reject/" . $group_obj->id . "\n";
    1278 
    1279         wp_mail( $invited_user->email, __("New Group Invitation:", 'buddypress') . $group_obj->name, $message, "From: noreply@" . $_SERVER[ 'HTTP_HOST' ]  );
    1280     }
    1281 
     1282    $invited_users = groups_get_invites_for_group( $bp['loggedin_userid'], $group_obj->id );
     1283
     1284    for ( $i = 0; $i < count( $invited_users ); $i++ ) {
     1285        $member = new BP_Groups_Member( $invited_users[$i], $group_obj->id );
     1286        $member->invite_sent = 1;
     1287        $member->save();
     1288    }
     1289   
     1290    groups_notification_group_invites( $group_obj->id, $invited_users, $bp['loggedin_userid'] );
     1291   
    12821292    do_action( 'groups_send_invites', $group_obj->id, $invited_users );
    12831293}
Note: See TracChangeset for help on using the changeset viewer.