Skip to:
Content

BuddyPress.org

Changeset 8150


Ignore:
Timestamp:
03/24/2014 07:11:16 PM (11 years ago)
Author:
boonebgorges
Message:

Add AJAX-powered pagination for group membership requests admin pages

Fixes #5440

Props dcavins

Location:
trunk
Files:
1 added
4 edited

Legend:

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

    r8142 r8150  
    30743074 */
    30753075function bp_group_has_membership_requests( $args = '' ) {
    3076     global $requests_template, $groups_template;
     3076    global $requests_template;
    30773077
    30783078    $defaults = array(
    3079         'group_id' => $groups_template->group->id,
     3079        'group_id' => bp_get_current_group_id(),
    30803080        'per_page' => 10,
    30813081        'page'     => 1,
     
    31113111}
    31123112    function bp_get_group_request_reject_link() {
    3113         global $requests_template, $groups_template;
    3114 
    3115         return apply_filters( 'bp_get_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . 'admin/membership-requests/reject/' . $requests_template->request->id, 'groups_reject_membership_request' ) );
     3113        global $requests_template;
     3114
     3115        return apply_filters( 'bp_get_group_request_reject_link', wp_nonce_url( bp_get_group_permalink( groups_get_current_group() ) . 'admin/membership-requests/reject/' . $requests_template->request->membership_id, 'groups_reject_membership_request' ) );
    31163116    }
    31173117
     
    31203120}
    31213121    function bp_get_group_request_accept_link() {
    3122         global $requests_template, $groups_template;
    3123 
    3124         return apply_filters( 'bp_get_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( $groups_template->group ) . 'admin/membership-requests/accept/' . $requests_template->request->id, 'groups_accept_membership_request' ) );
     3122        global $requests_template;
     3123
     3124        return apply_filters( 'bp_get_group_request_accept_link', wp_nonce_url( bp_get_group_permalink( groups_get_current_group() ) . 'admin/membership-requests/accept/' . $requests_template->request->membership_id, 'groups_accept_membership_request' ) );
    31253125    }
    31263126
     
    31453145    echo apply_filters( 'bp_group_request_comment', strip_tags( stripslashes( $requests_template->request->comments ) ) );
    31463146}
     3147
     3148/**
     3149 * Output pagination links for group membership requests.
     3150 *
     3151 * @since BuddyPress (2.0.0)
     3152 */
     3153function bp_group_requests_pagination_links() {
     3154    echo bp_get_group_requests_pagination_links();
     3155}
     3156    /**
     3157     * Get pagination links for group membership requests.
     3158     *
     3159     * @since BuddyPress (2.0.0)
     3160     *
     3161     * @return string
     3162     */
     3163    function bp_get_group_requests_pagination_links() {
     3164        global $requests_template;
     3165        return apply_filters( 'bp_get_group_requests_pagination_links', $requests_template->pag_links );
     3166    }
     3167
     3168/**
     3169 * Output pagination count text for group membership requests.
     3170 *
     3171 * @since BuddyPress (2.0.0)
     3172 */
     3173function bp_group_requests_pagination_count() {
     3174    echo bp_get_group_requests_pagination_count();
     3175}
     3176    /**
     3177     * Get pagination count text for group membership requests.
     3178     *
     3179     * @since BuddyPress (2.0.0)
     3180     *
     3181     * @return string
     3182     */
     3183    function bp_get_group_requests_pagination_count() {
     3184        global $requests_template;
     3185
     3186        $start_num = intval( ( $requests_template->pag_page - 1 ) * $requests_template->pag_num ) + 1;
     3187        $from_num  = bp_core_number_format( $start_num );
     3188        $to_num    = bp_core_number_format( ( $start_num + ( $requests_template->pag_num - 1 ) > $requests_template->total_request_count ) ? $requests_template->total_request_count : $start_num + ( $requests_template->pag_num - 1 ) );
     3189        $total     = bp_core_number_format( $requests_template->total_request_count );
     3190
     3191        return apply_filters( 'bp_get_group_requests_pagination_count', sprintf( _n( 'Viewing requests %1$s to %2$s (of %3$s request)', 'Viewing request %1$s to %2$s (of %3$s requests)', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     3192    }
    31473193
    31483194/************************************************************************************
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r8141 r8150  
    141141            'messages_filter' => 'bp_legacy_theme_messages_template_loader',
    142142            'invite_filter'   => 'bp_legacy_theme_invite_template_loader',
     143            'requests_filter' => 'bp_legacy_theme_requests_template_loader',
    143144
    144145            // Friends
     
    613614
    614615/**
     616 * Load group membership requests loop to handle pagination requests sent via AJAX.
     617 *
     618 * @since BuddyPress (2.0.0)
     619 */
     620function bp_legacy_theme_requests_template_loader() {
     621    bp_get_template_part( 'groups/single/requests-loop' );
     622    exit();
     623}
     624
     625/**
    615626 * Load the activity loop template when activity is requested via AJAX,
    616627 *
  • trunk/bp-templates/bp-legacy/buddypress/groups/single/admin.php

    r7965 r8150  
    304304    <?php do_action( 'bp_before_group_membership_requests_admin' ); ?>
    305305
    306     <?php if ( bp_group_has_membership_requests() ) : ?>
    307 
    308         <ul id="request-list" class="item-list">
    309             <?php while ( bp_group_membership_requests() ) : bp_group_the_membership_request(); ?>
    310 
    311                 <li>
    312                     <?php bp_group_request_user_avatar_thumb(); ?>
    313                     <h4><?php bp_group_request_user_link(); ?> <span class="comments"><?php bp_group_request_comment(); ?></span></h4>
    314                     <span class="activity"><?php bp_group_request_time_since_requested(); ?></span>
    315 
    316                     <?php do_action( 'bp_group_membership_requests_admin_item' ); ?>
    317 
    318                     <div class="action">
    319 
    320                         <?php bp_button( array( 'id' => 'group_membership_accept', 'component' => 'groups', 'wrapper_class' => 'accept', 'link_href' => bp_get_group_request_accept_link(), 'link_title' => __( 'Accept', 'buddypress' ), 'link_text' => __( 'Accept', 'buddypress' ) ) ); ?>
    321 
    322                         <?php bp_button( array( 'id' => 'group_membership_reject', 'component' => 'groups', 'wrapper_class' => 'reject', 'link_href' => bp_get_group_request_reject_link(), 'link_title' => __( 'Reject', 'buddypress' ), 'link_text' => __( 'Reject', 'buddypress' ) ) ); ?>
    323 
    324                         <?php do_action( 'bp_group_membership_requests_admin_item_action' ); ?>
    325 
    326                     </div>
    327                 </li>
    328 
    329             <?php endwhile; ?>
    330         </ul>
    331 
    332     <?php else: ?>
    333 
    334         <div id="message" class="info">
    335             <p><?php _e( 'There are no pending membership requests.', 'buddypress' ); ?></p>
     306        <div class="requests">
     307
     308            <?php bp_get_template_part( 'groups/single/requests-loop' ); ?>
     309
    336310        </div>
    337 
    338     <?php endif; ?>
    339311
    340312    <?php do_action( 'bp_after_group_membership_requests_admin' ); ?>
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r8138 r8150  
    852852                object = 'group_members';
    853853                template = 'groups/single/members';
     854            }
     855
     856            // On the Admin > Requests page, we need to reset the object,
     857            // since "admin" isn't specific enough
     858            if ( 'admin' == object && jq( 'body' ).hasClass( 'membership-requests' ) ) {
     859                object = 'requests';
    854860            }
    855861
Note: See TracChangeset for help on using the changeset viewer.