function groups_screen_group_invites() { $group_id = (int) bp_action_variable(1); if (bp_is_action_variable('accept') && is_numeric($group_id)) { // Check the nonce if (!check_admin_referer('groups_accept_invite')) { return false; } if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite accepted', 'buddypress')); // Record this in activity streams $group = groups_get_group(array('group_id' => $group_id)); groups_record_activity(array('type' => 'joined_group', 'item_id' => $group->id)); } if (isset($_GET['redirect_to'])) { $redirect_to = urldecode($_GET['redirect_to']); } else { $redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } bp_core_redirect($redirect_to); } else { if (bp_is_action_variable('reject') && is_numeric($group_id)) { // Check the nonce if (!check_admin_referer('groups_reject_invite')) { return false; } if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite rejected', 'buddypress')); } if (isset($_GET['redirect_to'])) { $redirect_to = urldecode($_GET['redirect_to']); } else { $redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } bp_core_redirect($redirect_to); } } do_action('groups_screen_group_invites', $group_id); bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home')); }
function groups_screen_group_invites() { $group_id = (int) bp_action_variable(1); if (bp_is_action_variable('accept') && is_numeric($group_id)) { // Check the nonce if (!check_admin_referer('groups_accept_invite')) { return false; } if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite accepted', 'buddypress')); // Record this in activity streams $group = new BP_Groups_Group($group_id); groups_record_activity(array('action' => apply_filters_ref_array('groups_activity_accepted_invite_action', array(sprintf(__('%1$s joined the group %2$s', 'buddypress'), bp_core_get_userlink(bp_loggedin_user_id()), '<a href="' . bp_get_group_permalink($group) . '">' . esc_attr($group->name) . '</a>'), bp_loggedin_user_id(), &$group)), 'type' => 'joined_group', 'item_id' => $group->id)); } bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } else { if (bp_is_action_variable('reject') && is_numeric($group_id)) { // Check the nonce if (!check_admin_referer('groups_reject_invite')) { return false; } if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite rejected', 'buddypress')); } bp_core_redirect(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } } // Remove notifications bp_core_delete_notifications_by_type(bp_loggedin_user_id(), 'groups', 'group_invite'); do_action('groups_screen_group_invites', $group_id); bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home')); }
/** * Handle the loading of a user's Groups > Invites page. */ function groups_screen_group_invites() { $group_id = (int) bp_action_variable(1); if (bp_is_action_variable('accept') && is_numeric($group_id)) { // Check the nonce. if (!check_admin_referer('groups_accept_invite')) { return false; } if (!groups_accept_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite accepted', 'buddypress')); // Record this in activity streams. $group = groups_get_group(array('group_id' => $group_id)); groups_record_activity(array('type' => 'joined_group', 'item_id' => $group->id)); } if (isset($_GET['redirect_to'])) { $redirect_to = urldecode($_GET['redirect_to']); } else { $redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } bp_core_redirect($redirect_to); } elseif (bp_is_action_variable('reject') && is_numeric($group_id)) { // Check the nonce. if (!check_admin_referer('groups_reject_invite')) { return false; } if (!groups_reject_invite(bp_loggedin_user_id(), $group_id)) { bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite rejected', 'buddypress')); } if (isset($_GET['redirect_to'])) { $redirect_to = urldecode($_GET['redirect_to']); } else { $redirect_to = trailingslashit(bp_loggedin_user_domain() . bp_get_groups_slug() . '/' . bp_current_action()); } bp_core_redirect($redirect_to); } /** * Fires before the loading of a users Groups > Invites template. * * @since 1.0.0 * * @param int $group_id ID of the group being displayed */ do_action('groups_screen_group_invites', $group_id); /** * Filters the template to load for a users Groups > Invites page. * * @since 1.0.0 * * @param string $value Path to a users Groups > Invites page template. */ bp_core_load_template(apply_filters('groups_template_group_invites', 'members/single/home')); }
/** * @group groups_reject_invite * @group group_invitations * @group group_membership */ public function test_bp_groups_reject_invite_leave_requests_intact() { $u1 = $this->factory->user->create(); $g = $this->factory->group->create(array('status' => 'private')); // Membership requests should be left intact. self::create_group_membership_request($u1, $g); groups_reject_invite($u1, $g); $u1_has_request = groups_check_for_membership_request($u1, $g); $this->assertTrue(is_numeric($u1_has_request) && $u1_has_request > 0); }
function groups_screen_group_invites() { global $bp; $group_id = $bp->action_variables[1]; if ( isset($bp->action_variables) && in_array( 'accept', (array)$bp->action_variables ) && is_numeric($group_id) ) { /* Check the nonce */ if ( !check_admin_referer( 'groups_accept_invite' ) ) return false; if ( !groups_accept_invite( $bp->loggedin_user->id, $group_id ) ) { bp_core_add_message( __('Group invite could not be accepted', 'buddypress'), 'error' ); } else { bp_core_add_message( __('Group invite accepted', 'buddypress') ); /* Record this in activity streams */ $group = new BP_Groups_Group( $group_id ); groups_record_activity( array( 'action' => apply_filters( 'groups_activity_accepted_invite_action', sprintf( __( '%s joined the group %s', 'buddypress'), bp_core_get_userlink( $bp->loggedin_user->id ), '<a href="' . bp_get_group_permalink( $group ) . '">' . esc_attr( $group->name ) . '</a>' ), $bp->loggedin_user->id, &$group ), 'type' => 'joined_group', 'item_id' => $group->id ) ); } bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); } else if ( isset($bp->action_variables) && in_array( 'reject', (array)$bp->action_variables ) && is_numeric($group_id) ) { /* Check the nonce */ if ( !check_admin_referer( 'groups_reject_invite' ) ) return false; if ( !groups_reject_invite( $bp->loggedin_user->id, $group_id ) ) { bp_core_add_message( __('Group invite could not be rejected', 'buddypress'), 'error' ); } else { bp_core_add_message( __('Group invite rejected', 'buddypress') ); } bp_core_redirect( $bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action ); } // Remove notifications bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'group_invite' ); do_action( 'groups_screen_group_invites', $group_id ); bp_core_load_template( apply_filters( 'groups_template_group_invites', 'members/single/home' ) ); }
function groups_screen_group_invites() { global $bp; $group_id = $bp->action_variables[1]; if (isset($bp->action_variables) && in_array('accept', $bp->action_variables) && is_numeric($group_id)) { if (!groups_accept_invite($bp->loggedin_user->id, $group_id)) { bp_core_add_message(__('Group invite could not be accepted', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite accepted', 'buddypress')); /* Record this in activity streams */ groups_record_activity(array('item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'joined_group', 'is_private' => 0)); } bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action); } else { if (isset($bp->action_variables) && in_array('reject', $bp->action_variables) && is_numeric($group_id)) { if (!groups_reject_invite($bp->loggedin_user->id, $group_id)) { bp_core_add_message(__('Group invite could not be rejected', 'buddypress'), 'error'); } else { bp_core_add_message(__('Group invite rejected', 'buddypress')); } bp_core_redirect($bp->loggedin_user->domain . $bp->current_component . '/' . $bp->current_action); } } // Remove notifications bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, $bp->groups->slug, 'group_invite'); do_action('groups_screen_group_invites', $group_id); bp_core_load_template(apply_filters('groups_template_group_invites', 'groups/list-invites')); }
/** * @group cache */ public function test_cache_should_be_invalidated_on_group_invite_reject() { groups_invite_user(array('user_id' => self::$user, 'group_id' => self::$groups[2], 'inviter_id' => self::$admin_user)); // Populate cache. $g1 = bp_get_user_groups(self::$user, array('is_confirmed' => null)); groups_reject_invite(self::$user, self::$groups[2]); $expected = array(self::$groups[0], self::$groups[1]); $found = bp_get_user_groups(self::$user, array('is_confirmed' => null)); $this->assertEqualSets($expected, array_keys($found)); }