- Timestamp:
- 11/22/2015 04:58:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-group-member-query.php
r10248 r10373 58 58 // Take this early opportunity to set the default 'type' param 59 59 // to 'last_joined', which will ensure that BP_User_Query 60 // trusts our order and does not try to apply its own 60 // trusts our order and does not try to apply its own. 61 61 if ( empty( $this->query_vars_raw['type'] ) ) { 62 62 $this->query_vars_raw['type'] = 'last_joined'; 63 63 } 64 64 65 // Set the sort order 65 // Set the sort order. 66 66 add_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) ); 67 67 68 // Set up our populate_extras method 68 // Set up our populate_extras method. 69 69 add_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 ); 70 70 } … … 100 100 101 101 // If the group member query returned no users, bail with an 102 // array that will guarantee no matches for BP_User_Query 102 // array that will guarantee no matches for BP_User_Query. 103 103 if ( empty( $group_member_ids ) ) { 104 104 return array( 0 ); … … 134 134 ); 135 135 136 /* *WHERE clauses *****************************************************/137 138 // Group id 136 /* WHERE clauses *****************************************************/ 137 138 // Group id. 139 139 $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] ); 140 140 141 // is_confirmed141 // If is_confirmed. 142 142 $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0; 143 143 $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed ); 144 144 145 // invite_sent145 // If invite_sent. 146 146 if ( ! is_null( $this->query_vars['invite_sent'] ) ) { 147 147 $invite_sent = ! empty( $this->query_vars['invite_sent'] ) ? 1 : 0; … … 149 149 } 150 150 151 // inviter_id151 // If inviter_id. 152 152 if ( ! is_null( $this->query_vars['inviter_id'] ) ) { 153 153 $inviter_id = $this->query_vars['inviter_id']; 154 154 155 // Empty: inviter_id = 0. (pass false, 0, or empty array) 155 // Empty: inviter_id = 0. (pass false, 0, or empty array). 156 156 if ( empty( $inviter_id ) ) { 157 157 $sql['where'][] = "inviter_id = 0"; 158 158 159 // The string 'any' matches any non-zero value (inviter_id != 0) 159 // The string 'any' matches any non-zero value (inviter_id != 0). 160 160 } elseif ( 'any' === $inviter_id ) { 161 161 $sql['where'][] = "inviter_id != 0"; 162 162 163 // Assume that a list of inviter IDs has been passed 163 // Assume that a list of inviter IDs has been passed. 164 164 } else { 165 // Parse and sanitize 165 // Parse and sanitize. 166 166 $inviter_ids = wp_parse_id_list( $inviter_id ); 167 167 if ( ! empty( $inviter_ids ) ) { … … 180 180 } 181 181 182 // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid 182 // Sanitize: Only 'admin', 'mod', 'member', and 'banned' are valid. 183 183 $allowed_roles = array( 'admin', 'mod', 'member', 'banned' ); 184 184 foreach ( $roles as $role_key => $role_value ) { … … 192 192 // When querying for a set of roles containing 'member' (for 193 193 // which there is no dedicated is_ column), figure out a list 194 // of columns *not* to match 194 // of columns *not* to match. 195 195 $roles_sql = ''; 196 196 if ( in_array( 'member', $roles ) ) { … … 205 205 206 206 // When querying for a set of roles *not* containing 'member', 207 // simply construct a list of is_* = 1 clauses 207 // simply construct a list of is_* = 1 clauses. 208 208 } else { 209 209 $role_columns = array(); … … 226 226 // of 'type'. If the 'type' value is not 'last_joined' or 227 227 // 'first_joined', the order will be overridden in 228 // BP_Group_Member_Query::set_orderby() 228 // BP_Group_Member_Query::set_orderby(). 229 229 $sql['orderby'] = "ORDER BY date_modified"; 230 230 $sql['order'] = 'first_joined' === $this->query_vars['type'] ? 'ASC' : 'DESC'; … … 272 272 if ( in_array( $query->query_vars['type'], array( 'last_joined', 'first_joined', 'group_activity' ) ) ) { 273 273 274 // Group Activity DESC 274 // Group Activity DESC. 275 275 if ( 'group_activity' == $query->query_vars['type'] ) { 276 276 $gm_ids = $this->get_gm_ids_ordered_by_activity( $query, $gm_ids ); 277 277 } 278 278 279 // The first param in the FIELD() clause is the sort column id 279 // The first param in the FIELD() clause is the sort column id. 280 280 $gm_ids = array_merge( array( 'u.id' ), wp_parse_id_list( $gm_ids ) ); 281 281 $gm_ids_sql = implode( ',', $gm_ids ); … … 285 285 286 286 // Prevent this filter from running on future BP_User_Query 287 // instances on the same page 287 // instances on the same page. 288 288 remove_action( 'bp_pre_user_query', array( $this, 'set_orderby' ) ); 289 289 } … … 293 293 * 294 294 * Additional data fetched: 295 *296 295 * - is_banned 297 296 * - date_modified … … 313 312 foreach ( (array) $extras as $extra ) { 314 313 if ( isset( $this->results[ $extra->user_id ] ) ) { 315 // user_id is provided for backward compatibility314 // The user_id is provided for backward compatibility. 316 315 $this->results[ $extra->user_id ]->user_id = (int) $extra->user_id; 317 316 $this->results[ $extra->user_id ]->is_admin = (int) $extra->is_admin; … … 328 327 } 329 328 330 // Don't filter other BP_User_Query objects on the same page 329 // Don't filter other BP_User_Query objects on the same page. 331 330 remove_action( 'bp_user_query_populate_extras', array( $this, 'populate_group_member_extras' ), 10, 2 ); 332 331 } … … 339 338 * @param BP_User_Query $query BP_User_Query object. 340 339 * @param array $gm_ids array of group member ids. 341 *342 340 * @return array 343 341 */
Note: See TracChangeset
for help on using the changeset viewer.