예제 #1
0
/**
 * Handle the display of Admin > Membership Requests.
 */
function groups_screen_group_admin_requests()
{
    $bp = buddypress();
    if ('membership-requests' != bp_get_group_current_admin_tab()) {
        return false;
    }
    if (!bp_is_item_admin() || 'public' == $bp->groups->current_group->status) {
        return false;
    }
    $request_action = (string) bp_action_variable(1);
    $membership_id = (int) bp_action_variable(2);
    if (!empty($request_action) && !empty($membership_id)) {
        if ('accept' == $request_action && is_numeric($membership_id)) {
            // Check the nonce first.
            if (!check_admin_referer('groups_accept_membership_request')) {
                return false;
            }
            // Accept the membership request.
            if (!groups_accept_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error accepting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request accepted', 'buddypress'));
            }
        } elseif ('reject' == $request_action && is_numeric($membership_id)) {
            /* Check the nonce first. */
            if (!check_admin_referer('groups_reject_membership_request')) {
                return false;
            }
            // Reject the membership request.
            if (!groups_reject_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error rejecting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request rejected', 'buddypress'));
            }
        }
        /**
         * Fires before the redirect if a group membership request has been handled.
         *
         * @since 1.0.0
         *
         * @param int    $id             ID of the group that was edited.
         * @param string $request_action Membership request action being performed.
         * @param int    $membership_id  The key of the action_variables array that you want.
         */
        do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
        bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
    }
    /**
     * Fires before the loading of the group membership request page template.
     *
     * @since 1.0.0
     *
     * @param int $id ID of the group that is being displayed.
     */
    do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
    /**
     * Filters the template to load for a group's membership request page.
     *
     * @since 1.0.0
     *
     * @param string $value Path to a group's membership request template.
     */
    bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
예제 #2
0
/**
 * Handle the display of Admin > Membership Requests.
 */
function groups_screen_group_admin_requests()
{
    $bp = buddypress();
    if ('membership-requests' != bp_get_group_current_admin_tab()) {
        return false;
    }
    if (!bp_is_item_admin() || 'public' == $bp->groups->current_group->status) {
        return false;
    }
    $request_action = (string) bp_action_variable(1);
    $membership_id = (int) bp_action_variable(2);
    if (!empty($request_action) && !empty($membership_id)) {
        if ('accept' == $request_action && is_numeric($membership_id)) {
            // Check the nonce first.
            if (!check_admin_referer('groups_accept_membership_request')) {
                return false;
            }
            // Accept the membership request
            if (!groups_accept_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error accepting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request accepted', 'buddypress'));
            }
        } elseif ('reject' == $request_action && is_numeric($membership_id)) {
            /* Check the nonce first. */
            if (!check_admin_referer('groups_reject_membership_request')) {
                return false;
            }
            // Reject the membership request
            if (!groups_reject_membership_request($membership_id)) {
                bp_core_add_message(__('There was an error rejecting the membership request. Please try again.', 'buddypress'), 'error');
            } else {
                bp_core_add_message(__('Group membership request rejected', 'buddypress'));
            }
        }
        do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
        bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
    }
    do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
    bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
}
예제 #3
0
function groups_screen_group_admin_requests()
{
    global $bp;
    if (bp_is_groups_component() && bp_is_action_variable('membership-requests', 0)) {
        if (!$bp->is_item_admin || 'public' == $bp->groups->current_group->status) {
            return false;
        }
        // Remove any screen notifications
        bp_core_delete_notifications_by_type(bp_loggedin_user_id(), $bp->groups->id, 'new_membership_request');
        $request_action = (string) bp_action_variable(1);
        $membership_id = (int) bp_action_variable(2);
        if (!empty($request_action) && !empty($membership_id)) {
            if ('accept' == $request_action && is_numeric($membership_id)) {
                // Check the nonce first.
                if (!check_admin_referer('groups_accept_membership_request')) {
                    return false;
                }
                // Accept the membership request
                if (!groups_accept_membership_request($membership_id)) {
                    bp_core_add_message(__('There was an error accepting the membership request, please try again.', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Group membership request accepted', 'buddypress'));
                }
            } elseif ('reject' == $request_action && is_numeric($membership_id)) {
                /* Check the nonce first. */
                if (!check_admin_referer('groups_reject_membership_request')) {
                    return false;
                }
                // Reject the membership request
                if (!groups_reject_membership_request($membership_id)) {
                    bp_core_add_message(__('There was an error rejecting the membership request, please try again.', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Group membership request rejected', 'buddypress'));
                }
            }
            do_action('groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id);
            bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/membership-requests/');
        }
        do_action('groups_screen_group_admin_requests', $bp->groups->current_group->id);
        bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/single/home'));
    }
}
 /**
  * @group groups_reject_membership_request
  * @group group_membership_requests
  * @group group_membership
  */
 public function test_bp_groups_reject_membership_request_leave_invites_intact()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $g = $this->factory->group->create(array('status' => 'private'));
     $time = time() - 60;
     $this->add_user_to_group($u1, $g, array('date_modified' => date('Y-m-d H:i:s', $time)));
     // Outstanding invitations should be left intact.
     self::invite_user_to_group($u2, $g, $u1);
     groups_reject_membership_request(null, $u2, $g);
     $u2_has_invite = groups_check_user_has_invite($u2, $g);
     $this->assertTrue(is_numeric($u2_has_invite) && $u2_has_invite > 0);
 }
예제 #5
0
파일: bp-groups.php 프로젝트: n-sane/zaroka
function groups_screen_group_admin_requests() {
	global $bp;

	if ( $bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0] ) {

		/* Ask for a login if the user is coming here via an email notification */
		if ( !is_user_logged_in() )
			bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . $bp->root_domain . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests/' ) );

		if ( !$bp->is_item_admin || 'public' == $bp->groups->current_group->status )
			return false;

		// Remove any screen notifications
		bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->groups->id, 'new_membership_request' );

		$request_action = $bp->action_variables[1];
		$membership_id = $bp->action_variables[2];

		if ( isset($request_action) && isset($membership_id) ) {
			if ( 'accept' == $request_action && is_numeric($membership_id) ) {

				/* Check the nonce first. */
				if ( !check_admin_referer( 'groups_accept_membership_request' ) )
					return false;

				// Accept the membership request
				if ( !groups_accept_membership_request( $membership_id ) ) {
					bp_core_add_message( __( 'There was an error accepting the membership request, please try again.', 'buddypress' ), 'error' );
				} else {
					bp_core_add_message( __( 'Group membership request accepted', 'buddypress' ) );
				}

			} else if ( 'reject' == $request_action && is_numeric($membership_id) ) {
				/* Check the nonce first. */
				if ( !check_admin_referer( 'groups_reject_membership_request' ) )
					return false;

				// Reject the membership request
				if ( !groups_reject_membership_request( $membership_id ) ) {
					bp_core_add_message( __( 'There was an error rejecting the membership request, please try again.', 'buddypress' ), 'error' );
				} else {
					bp_core_add_message( __( 'Group membership request rejected', 'buddypress' ) );
				}

			}

			do_action( 'groups_group_request_managed', $bp->groups->current_group->id, $request_action, $membership_id );

			bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . 'admin/membership-requests/' );
		}

		do_action( 'groups_screen_group_admin_requests', $bp->groups->current_group->id );

		bp_core_load_template( apply_filters( 'groups_template_group_admin_requests', 'groups/single/home' ) );
	}
}
예제 #6
0
function groups_screen_group_admin_requests()
{
    global $bp, $group_obj;
    if ($bp->current_component == $bp->groups->slug && 'membership-requests' == $bp->action_variables[0]) {
        if (!$bp->is_item_admin || 'public' == $group_obj->status) {
            return false;
        }
        // Remove any screen notifications
        bp_core_delete_notifications_for_user_by_type($bp->loggedin_user->id, $bp->groups->slug, 'new_membership_request');
        $request_action = $bp->action_variables[1];
        $membership_id = $bp->action_variables[2];
        if (isset($request_action) && isset($membership_id)) {
            if ('accept' == $request_action && is_numeric($membership_id)) {
                // Accept the membership request
                if (!groups_accept_membership_request($membership_id)) {
                    bp_core_add_message(__('There was an error accepting the membership request, please try again.', 'buddypress'), 'error');
                } else {
                    bp_core_add_message(__('Group membership request accepted', 'buddypress'));
                }
            } else {
                if ('reject' == $request_action && is_numeric($membership_id)) {
                    // Reject the membership request
                    if (!groups_reject_membership_request($membership_id)) {
                        bp_core_add_message(__('There was an error rejecting the membership request, please try again.', 'buddypress'), 'error');
                    } else {
                        bp_core_add_message(__('Group membership request rejected', 'buddypress'));
                    }
                }
            }
            do_action('groups_group_request_managed', $group_obj->id, $request_action, $membership_id);
            bp_core_redirect(site_url() . '/' . $bp->current_component . '/' . $bp->current_item . '/admin/membership-requests');
        }
        do_action('groups_screen_group_admin_requests', $group_obj->id);
        bp_core_load_template(apply_filters('groups_template_group_admin_requests', 'groups/admin/membership-requests'));
    }
}