Changeset 8069
- Timestamp:
- 03/06/2014 07:58:49 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r8061 r8069 1455 1455 * - *Pending and unsent invitations* are entries with is_confirmed = 0 and 1456 1456 * inviter_id != 0 and invite_sent = 0 1457 * - *Membership requests* are entries with is_confirmed = 0 and 1458 * inviter_id = 0 (and invite_sent = 0) 1457 1459 * 1458 1460 * @since BuddyPress (1.8.0) … … 1723 1725 1724 1726 $bp = buddypress(); 1725 $extras = $wpdb->get_results( $wpdb->prepare( "SELECT user_id, date_modified, is_banned FROM {$bp->groups->table_name_members} WHERE user_id IN ({$user_ids_sql}) AND group_id = %d", $this->query_vars['group_id'] ) );1727 $extras = $wpdb->get_results( $wpdb->prepare( "SELECT id, user_id, date_modified, is_admin, is_mod, comments, user_title, invite_sent, is_confirmed, inviter_id, is_banned FROM {$bp->groups->table_name_members} WHERE user_id IN ({$user_ids_sql}) AND group_id = %d", $this->query_vars['group_id'] ) ); 1726 1728 1727 1729 foreach ( (array) $extras as $extra ) { … … 1729 1731 // user_id is provided for backward compatibility 1730 1732 $this->results[ $extra->user_id ]->user_id = (int) $extra->user_id; 1733 $this->results[ $extra->user_id ]->is_admin = (int) $extra->is_admin; 1734 $this->results[ $extra->user_id ]->is_mod = (int) $extra->is_mod; 1731 1735 $this->results[ $extra->user_id ]->is_banned = (int) $extra->is_banned; 1732 1736 $this->results[ $extra->user_id ]->date_modified = $extra->date_modified; 1737 $this->results[ $extra->user_id ]->user_title = $extra->user_title; 1738 $this->results[ $extra->user_id ]->comments = $extra->comments; 1739 $this->results[ $extra->user_id ]->invite_sent = (int) $extra->invite_sent; 1740 $this->results[ $extra->user_id ]->inviter_id = (int) $extra->inviter_id; 1741 $this->results[ $extra->user_id ]->is_confirmed = (int) $extra->is_confirmed; 1742 $this->results[ $extra->user_id ]->membership_id = (int) $extra->id; 1733 1743 } 1734 1744 } -
trunk/bp-groups/bp-groups-template.php
r8066 r8069 2937 2937 * @type int $per_page Number of records to return per page of 2938 2938 * results. Default: 10. 2939 * @type int $page Page of results to show. Default: 1. 2939 2940 * @type int $max Max items to return. Default: false (show all) 2940 2941 * } … … 2959 2960 'group_id' => bp_get_current_group_id(), 2960 2961 'per_page' => 10, 2961 'max' => false, 2962 'page' => 1, 2963 'max' => false, 2964 'type' => 'first_joined', 2962 2965 ) ); 2963 2966 2964 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : 1;2967 $this->pag_page = isset( $_REQUEST['mrpage'] ) ? intval( $_REQUEST['mrpage'] ) : $r['page']; 2965 2968 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $r['per_page']; 2966 $this->requests = BP_Groups_Group::get_membership_requests( $r['group_id'], $this->pag_num, $this->pag_page ); 2967 2968 if ( !$r['max'] || $r['max'] >= (int) $this->requests['total'] ) 2969 $this->total_request_count = (int) $this->requests['total']; 2969 2970 $mquery = new BP_Group_Member_Query( array( 2971 'group_id' => $r['group_id'], 2972 'type' => $r['type'], 2973 'per_page' => $this->pag_num, 2974 'page' => $this->pag_page, 2975 2976 // These filters ensure we only get pending requests 2977 'is_confirmed' => false, 2978 'inviter_id' => 0, 2979 ) ); 2980 2981 $this->requests = array_values( $mquery->results ); 2982 $this->request_count = count( $this->requests ); 2983 2984 // Compatibility with legacy format of request data objects 2985 foreach ( $this->requests as $rk => $rv ) { 2986 // For legacy reasons, the 'id' property of each 2987 // request must match the membership id, not the ID of 2988 // the user (as it's returned by BP_Group_Member_Query) 2989 $this->requests[ $rk ]->user_id = $rv->ID; 2990 $this->requests[ $rk ]->id = $rv->membership_id; 2991 2992 // Miscellaneous values 2993 $this->requests[ $rk ]->group_id = $r['group_id']; 2994 } 2995 2996 if ( !$r['max'] || $r['max'] >= (int) $mquery->total_users ) 2997 $this->total_request_count = (int) $mquery->total_users; 2970 2998 else 2971 2999 $this->total_request_count = (int) $r['max']; 2972 2973 $this->requests = $this->requests['requests'];2974 3000 2975 3001 if ( $r['max'] ) { … … 3036 3062 } 3037 3063 3064 /** 3065 * Initialize a group membership request template loop. 3066 * 3067 * @param array $args { 3068 * @type int $group_id ID of the group. Defaults to current group. 3069 * @type int $per_page Number of records to return per page. Default: 10. 3070 * @type int $page Page of results to return. Default: 1. 3071 * @type int $max Max number of items to return. Default: false. 3072 * } 3073 * @return bool True if there are requests, otherwise false. 3074 */ 3038 3075 function bp_group_has_membership_requests( $args = '' ) { 3039 3076 global $requests_template, $groups_template; … … 3042 3079 'group_id' => $groups_template->group->id, 3043 3080 'per_page' => 10, 3081 'page' => 1, 3044 3082 'max' => false 3045 3083 ); -
trunk/tests/testcases/groups/template.php
r8065 r8069 548 548 for ( $i = 1; $i < 15; $i++ ) { 549 549 $users[ $i ] = $this->create_user( array( 550 'last_activity' => gmdate( 'Y-m-d H:i:s', time() - $i),550 'last_activity' => gmdate( 'Y-m-d H:i:s', time() - ( 100 - $i ) ), 551 551 ) ); 552 552 553 553 $memberships[ $i ] = $this->add_user_to_group( $users[ $i ], $g, array( 554 'date_modified' => gmdate( 'Y-m-d H:i:s', time() - $i ), 554 // this date_modified ensures that order will match 555 // id order. necessary due to a quirk in the legacy 556 // implementation 557 'date_modified' => gmdate( 'Y-m-d H:i:s', time() - ( 100 - $i ) ), 555 558 'is_confirmed' => 0, 556 559 'inviter_id' => 0,
Note: See TracChangeset
for help on using the changeset viewer.