Changeset 7930
- Timestamp:
- 02/18/2014 09:44:25 PM (11 years ago)
- Location:
- trunk/bp-groups
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-functions.php
r7903 r7930 363 363 364 364 /** 365 * Fetch the members of a group 365 * Fetch the members of a group. 366 366 * 367 367 * Since BuddyPress 1.8, a procedural wrapper for BP_Group_Member_Query. … … 371 371 * returning true. 372 372 * 373 * @param array $args { 374 * An array of optional arguments. 375 * @type int $group_id ID of the group whose members are being queried. 376 * Default: current group ID. 377 * @type int $page Page of results to be queried. Default: 1. 378 * @type int $per_page Number of items to return per page of results. 379 * Default: 20. 380 * @type int $max Optional. Max number of items to return. 381 * @type array $exclude Optional. Array of user IDs to exclude. 382 * @type bool|int True (or 1) to exclude admins and mods from results. 383 * Default: 1. 384 * @type bool|int True (or 1) to exclude banned users from results. 385 * Default: 1. 386 * @type array $group_role Optional. Array of group roles to include. 387 * } 373 388 * @param int $group_id 374 389 * @param int $limit Maximum members to return … … 379 394 * @return array Multi-d array of 'members' list and 'count' 380 395 */ 381 function groups_get_group_members( $group_id, $limit = false, $page = false, $exclude_admins_mods = true, $exclude_banned = true, $exclude = false, $group_role = false ) { 396 function groups_get_group_members( $args = array() ) { 397 398 // Backward compatibility with old method of passing arguments 399 if ( ! is_array( $args ) || func_num_args() > 1 ) { 400 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 401 402 $old_args_keys = array( 403 0 => 'group_id', 404 1 => 'per_page', 405 2 => 'page', 406 3 => 'exclude_admins_mods', 407 4 => 'exclude_banned', 408 5 => 'exclude', 409 6 => 'group_role', 410 ); 411 412 $func_args = func_get_args(); 413 $args = bp_core_parse_args_array( $old_args_keys, $func_args ); 414 } 415 416 $r = wp_parse_args( $args, array( 417 'group_id' => bp_get_current_group_id(), 418 'per_page' => false, 419 'page' => false, 420 'exclude_admins_mods' => true, 421 'exclude_banned' => true, 422 'exclude' => false, 423 'group_role' => array(), 424 ) ); 382 425 383 426 // For legacy users. Use of BP_Groups_Member::get_all_for_group() … … 386 429 $func_args = func_get_args(); 387 430 if ( apply_filters( 'bp_use_legacy_group_member_query', false, __FUNCTION__, $func_args ) ) { 388 $retval = BP_Groups_Member::get_all_for_group( $ group_id, $limit, $page, $exclude_admins_mods, $exclude_banned, $exclude);431 $retval = BP_Groups_Member::get_all_for_group( $r['group_id'], $r['per_page'], $r['page'], $r['exclude_admins_mods'], $r['exclude_banned'], $r['exclude'] ); 389 432 } else { 390 433 391 434 // exclude_admins_mods and exclude_banned are legacy arguments. 392 435 // Convert to group_role 393 if ( empty( $ group_role) ) {394 $ group_role= array( 'member' );395 396 if ( ! $ exclude_admins_mods) {397 $ group_role[] = 'mod';398 $ group_role[] = 'admin';436 if ( empty( $r['group_role'] ) ) { 437 $r['group_role'] = array( 'member' ); 438 439 if ( ! $r['exclude_admins_mods'] ) { 440 $r['group_role'][] = 'mod'; 441 $r['group_role'][] = 'admin'; 399 442 } 400 443 401 if ( ! $ exclude_banned) {402 $ group_role[] = 'banned';444 if ( ! $r['exclude_banned'] ) { 445 $r['group_role'][] = 'banned'; 403 446 } 404 447 } … … 406 449 // Perform the group member query (extends BP_User_Query) 407 450 $members = new BP_Group_Member_Query( array( 408 'group_id' => $ group_id,409 'per_page' => $ limit,410 'page' => $ page,411 'group_role' => $ group_role,412 'exclude' => $ exclude,451 'group_id' => $r['group_id'], 452 'per_page' => $r['per_page'], 453 'page' => $r['page'], 454 'group_role' => $r['group_role'], 455 'exclude' => $r['exclude'], 413 456 'type' => 'last_modified', 414 457 ) ); -
trunk/bp-groups/bp-groups-template.php
r7897 r7930 1933 1933 var $total_group_count; 1934 1934 1935 function __construct( $group_id, $per_page, $max, $exclude_admins_mods, $exclude_banned, $exclude, $group_role = false ) { 1935 /** 1936 * Constructor. 1937 * 1938 * @param array $args { 1939 * An array of optional arguments. 1940 * @type int $group_id ID of the group whose members are being 1941 * queried. Default: current group ID. 1942 * @type int $page Page of results to be queried. Default: 1. 1943 * @type int $per_page Number of items to return per page of 1944 * results. Default: 20. 1945 * @type int $max Optional. Max number of items to return. 1946 * @type array $exclude Optional. Array of user IDs to exclude. 1947 * @type bool|int True (or 1) to exclude admins and mods from 1948 * results. Default: 1. 1949 * @type bool|int True (or 1) to exclude banned users from results. 1950 * Default: 1. 1951 * @type array $group_role Optional. Array of group roles to include. 1952 * @type string $search_terms Optional. Search terms to match. 1953 * } 1954 */ 1955 function __construct( $args = array() ) { 1956 1957 // Backward compatibility with old method of passing arguments 1958 if ( ! is_array( $args ) || func_num_args() > 1 ) { 1959 _deprecated_argument( __METHOD__, '2.0.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 1960 1961 $old_args_keys = array( 1962 0 => 'group_id', 1963 1 => 'per_page', 1964 2 => 'max', 1965 3 => 'exclude_admins_mods', 1966 4 => 'exclude_banned', 1967 5 => 'exclude', 1968 6 => 'group_role', 1969 ); 1970 1971 $func_args = func_get_args(); 1972 $args = bp_core_parse_args_array( $old_args_keys, $func_args ); 1973 } 1974 1975 $r = wp_parse_args( $args, array( 1976 'group_id' => bp_get_current_group_id(), 1977 'page' => 1, 1978 'per_page' => 20, 1979 'max' => false, 1980 'exclude' => false, 1981 'exclude_admins_mods' => 1, 1982 'exclude_banned' => 1, 1983 'group_role' => false, 1984 'search_terms' => false, 1985 ) ); 1986 1987 // @todo No 1988 extract( $r ); 1936 1989 1937 1990 $this->pag_page = isset( $_REQUEST['mlpage'] ) ? intval( $_REQUEST['mlpage'] ) : 1; 1938 1991 $this->pag_num = isset( $_REQUEST['num'] ) ? intval( $_REQUEST['num'] ) : $per_page; 1939 $this->members = groups_get_group_members( $group_id, $this->pag_num, $this->pag_page, $exclude_admins_mods, $exclude_banned, $exclude, $group_role ); 1992 1993 $members_args = $r; 1994 1995 $members_args['page'] = $this->pag_page; 1996 $members_args['per_page'] = $this->pag_num; 1997 1998 $this->members = groups_get_group_members( $members_args ); 1940 1999 1941 2000 if ( !$max || $max >= (int) $this->members['count'] ) … … 2010 2069 } 2011 2070 2071 /** 2072 * Initialize a group member query loop. 2073 * 2074 * @param array $args { 2075 * An array of optional arguments. 2076 * @type int $group_id ID of the group whose members are being queried. 2077 * Default: current group ID. 2078 * @type int $page Page of results to be queried. Default: 1. 2079 * @type int $per_page Number of items to return per page of results. 2080 * Default: 20. 2081 * @type int $max Optional. Max number of items to return. 2082 * @type array $exclude Optional. Array of user IDs to exclude. 2083 * @type bool|int True (or 1) to exclude admins and mods from results. 2084 * Default: 1. 2085 * @type bool|int True (or 1) to exclude banned users from results. 2086 * Default: 1. 2087 * @type array $group_role Optional. Array of group roles to include. 2088 * @type string $search_terms Optional. Search terms to match. 2089 * } 2090 */ 2012 2091 function bp_group_has_members( $args = '' ) { 2013 2092 global $members_template; 2014 2093 2015 2094 $r = wp_parse_args( $args, array( 2016 'group_id' => bp_get_current_group_id(), 2017 'per_page' => 20, 2018 'max' => false, 2019 'exclude' => false, 2095 'group_id' => bp_get_current_group_id(), 2096 'page' => 1, 2097 'per_page' => 20, 2098 'max' => false, 2099 'exclude' => false, 2020 2100 'exclude_admins_mods' => 1, 2021 'exclude_banned' => 1, 2022 'group_role' => false, 2101 'exclude_banned' => 1, 2102 'group_role' => false, 2103 'search_terms' => false, 2023 2104 ) ); 2024 2105 2025 $members_template = new BP_Groups_Group_Members_Template( $r['group_id'], $r['per_page'], $r['max'], (int) $r['exclude_admins_mods'], (int) $r['exclude_banned'], $r['exclude'], $r['group_role'] ); 2106 if ( empty( $r['search_terms'] ) && ! empty( $_REQUEST['s'] ) ) 2107 $r['search_terms'] = $_REQUEST['s']; 2108 2109 $members_template = new BP_Groups_Group_Members_Template( $r ); 2026 2110 return apply_filters( 'bp_group_has_members', $members_template->has_members(), $members_template ); 2027 2111 }
Note: See TracChangeset
for help on using the changeset viewer.