Changeset 6321
- Timestamp:
- 09/08/2012 03:12:39 AM (12 years ago)
- Location:
- trunk/bp-groups
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-groups/bp-groups-classes.php
r6282 r6321 306 306 } 307 307 308 function get( $type = 'newest', $per_page = null, $page = null, $user_id = 0, $search_terms = false, $include = false, $populate_extras = true, $exclude = false, $show_hidden = false ) { 309 global $wpdb, $bp; 308 function get( $args = array() ) { 309 global $wpdb, $bp; 310 311 // Backward compatibility with old method of passing arguments 312 if ( ! is_array( $args ) || func_num_args() > 1 ) { 313 _deprecated_argument( __METHOD__, '1.7', 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__ ) ); 314 315 $old_args_keys = array( 316 0 => 'type', 317 1 => 'per_page', 318 2 => 'page', 319 3 => 'user_id', 320 4 => 'search_terms', 321 5 => 'include', 322 6 => 'populate_extras', 323 7 => 'exclude', 324 8 => 'show_hidden', 325 ); 326 327 $func_args = func_get_args(); 328 $args = bp_core_parse_args_array( $old_args_keys, $func_args ); 329 } 330 331 $defaults = array( 332 'type' => 'newest', 333 'per_page' => null, 334 'page' => null, 335 'user_id' => 0, 336 'search_terms' => false, 337 'include' => false, 338 'populate_extras' => true, 339 'exclude' => false, 340 'show_hidden' => false 341 ); 342 343 $r = wp_parse_args( $args, $defaults ); 344 extract( $r ); 310 345 311 346 $sql = array(); -
trunk/bp-groups/bp-groups-functions.php
r6259 r6321 390 390 /*** Group Fetching, Filtering & Searching *************************************/ 391 391 392 /** 393 * Get a collection of groups, based on the parameters passed 394 * 395 * @uses apply_filters_ref_array() Filter 'groups_get_groups' to modify return value 396 * @uses BP_Groups_Group::get() 397 * @param array $args See inline documentation for details 398 * @return array 399 */ 392 400 function groups_get_groups( $args = '' ) { 393 401 … … 404 412 ); 405 413 406 $params = wp_parse_args( $args, $defaults ); 407 extract( $params, EXTR_SKIP ); 408 409 $groups = BP_Groups_Group::get( $type, $per_page, $page, $user_id, $search_terms, $include, $populate_extras, $exclude, $show_hidden ); 410 411 return apply_filters_ref_array( 'groups_get_groups', array( &$groups, &$params ) ); 414 $r = wp_parse_args( $args, $defaults ); 415 416 $groups = BP_Groups_Group::get( array( 417 'type' => $r['type'], 418 'user_id' => $r['user_id'], 419 'include' => $r['include'], 420 'exclude' => $r['exclude'], 421 'search_terms' => $r['search_terms'], 422 'show_hidden' => $r['show_hidden'], 423 'per_page' => $r['per_page'], 424 'page' => $r['page'], 425 'populate_extras' => $r['populate_extras'] 426 ) ); 427 428 return apply_filters_ref_array( 'groups_get_groups', array( &$groups, &$r ) ); 412 429 } 413 430 -
trunk/bp-groups/bp-groups-template.php
r6259 r6321 108 108 var $order; 109 109 110 function __construct( $user_id, $type, $page, $per_page, $max, $slug, $search_terms, $populate_extras, $include = false, $exclude = false, $show_hidden = false, $page_arg = 'grpage' ){ 110 function __construct( $args = array() ){ 111 112 // Backward compatibility with old method of passing arguments 113 if ( ! is_array( $args ) || func_num_args() > 1 ) { 114 _deprecated_argument( __METHOD__, '1.7', 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__ ) ); 115 116 $old_args_keys = array( 117 0 => 'user_id', 118 1 => 'type', 119 2 => 'page', 120 3 => 'per_page', 121 4 => 'max', 122 5 => 'slug', 123 6 => 'search_terms', 124 7 => 'populate_extras', 125 8 => 'include', 126 9 => 'exclude', 127 10 => 'show_hidden', 128 11 => 'page_arg', 129 ); 130 131 $func_args = func_get_args(); 132 $args = bp_core_parse_args_array( $old_args_keys, $func_args ); 133 } 134 135 $defaults = array( 136 'type' => 'active', 137 'page' => 1, 138 'per_page' => 20, 139 'max' => false, 140 'show_hidden' => false, 141 'page_arg' => 'grpage', 142 'user_id' => 0, 143 'slug' => false, 144 'include' => false, 145 'exclude' => false, 146 'search_terms' => '', 147 'populate_extras' => true 148 ); 149 150 $r = wp_parse_args( $args, $defaults ); 151 extract( $r ); 111 152 112 153 $this->pag_page = isset( $_REQUEST[$page_arg] ) ? intval( $_REQUEST[$page_arg] ) : $page; … … 274 315 275 316 $r = wp_parse_args( $args, $defaults ); 276 extract( $r ); 277 278 if ( empty( $search_terms ) ) { 317 318 if ( empty( $r['search_terms'] ) ) { 279 319 if ( isset( $_REQUEST['group-filter-box'] ) && !empty( $_REQUEST['group-filter-box'] ) ) 280 $ search_terms= $_REQUEST['group-filter-box'];320 $r['search_terms'] = $_REQUEST['group-filter-box']; 281 321 elseif ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] ) ) 282 $ search_terms= $_REQUEST['s'];322 $r['search_terms'] = $_REQUEST['s']; 283 323 else 284 $search_terms = false; 285 } 286 287 $groups_template = new BP_Groups_Template( (int) $user_id, $type, (int) $page, (int) $per_page, (int) $max, $slug, $search_terms, (bool)$populate_extras, $include, $exclude, $show_hidden, $page_arg ); 288 return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template ); 324 $r['search_terms'] = false; 325 } 326 327 $groups_template = new BP_Groups_Template( array( 328 'type' => $r['type'], 329 'page' => (int) $r['page'], 330 'per_page' => (int) $r['per_page'], 331 'max' => (int) $r['max'], 332 'show_hidden' => $r['show_hidden'], 333 'page_arg' => $r['page_arg'], 334 'user_id' => (int) $r['user_id'], 335 'slug' => $r['slug'], 336 'search_terms' => $r['search_terms'], 337 'include' => $r['include'], 338 'exclude' => $r['exclude'], 339 'populate_extras' => (bool) $r['populate_extras'] 340 ) ); 341 342 return apply_filters( 'bp_has_groups', $groups_template->has_groups(), $groups_template, $r ); 289 343 } 290 344
Note: See TracChangeset
for help on using the changeset viewer.