Changeset 6770 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
- Timestamp:
- 02/26/2018 08:14:23 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
r6692 r6770 372 372 global $wpdb; 373 373 374 $editors = [ 375 'project' => [], 376 'inherited' => [], 377 ]; 378 374 379 // Get the translation editors of the project. 375 $editors = (array) $wpdb->get_col( $wpdb->prepare( "380 $editors['project'] = (array) $wpdb->get_col( $wpdb->prepare( " 376 381 SELECT 377 382 `user_id` … … 382 387 ", $project->id, $locale_slug ) ); 383 388 389 // Get the translation editors of parent projects. 384 390 if ( $project->parent_project_id ) { 385 391 $parent_project_id = $project->parent_project_id; 386 392 $parent_project = GP::$project->get( $parent_project_id ); 387 393 while ( $parent_project_id ) { 388 $editors = $editors +(array) $wpdb->get_col( $wpdb->prepare( "394 $editors['inherited'] = array_merge( $editors['inherited'], (array) $wpdb->get_col( $wpdb->prepare( " 389 395 SELECT 390 396 `user_id` … … 393 399 `project_id` = %d 394 400 AND `locale` IN (%s, 'all-locales') 395 ", $parent_project->id, $locale_slug ) ) ;401 ", $parent_project->id, $locale_slug ) ) ); 396 402 397 403 $parent_project = GP::$project->get( $parent_project_id ); … … 399 405 } 400 406 } 407 408 // Get the translation editors for all projects. 409 $editors['inherited'] = array_merge( $editors['inherited'], (array) $wpdb->get_col( $wpdb->prepare( " 410 SELECT 411 `user_id` 412 FROM {$wpdb->wporg_translation_editors} 413 WHERE 414 `project_id` = '0' 415 AND `locale` = %s 416 ", $locale_slug ) ) ); 401 417 402 418 return $editors; … … 414 430 global $wpdb; 415 431 416 $locale_contributors = array( 417 'editors' => array(), 418 'contributors' => array(), 419 ); 432 $locale_contributors = [ 433 'editors' => [ 434 'project' => [], 435 'inherited' => [], 436 ], 437 'contributors' => [], 438 ]; 420 439 421 440 // Get the translation editors of the project. 422 441 $editors = $this->get_translation_editors( $project, $locale_slug ); 423 442 443 $editor_ids = []; 444 424 445 // Get the names of the translation editors. 425 foreach ( $editors as $editor_id ) { 426 $user = get_user_by( 'id', $editor_id ); 427 if ( ! $user ) { 428 continue; 429 } 430 431 $locale_contributors['editors'][ $editor_id ] = (object) array( 432 'nicename' => $user->user_nicename, 433 'display_name' => $this->_encode( $user->display_name ), 434 'email' => $user->user_email, 435 ); 436 } 446 foreach ( [ 'project', 'inherited'] as $editor_source ) { 447 foreach ( $editors[ $editor_source ] as $editor_id ) { 448 $user = get_user_by( 'id', $editor_id ); 449 if ( ! $user ) { 450 continue; 451 } 452 453 $locale_contributors['editors'][ $editor_source ][ $editor_id ] = (object) array( 454 'nicename' => $user->user_nicename, 455 'display_name' => $this->_encode( $user->display_name ), 456 'email' => $user->user_email, 457 ); 458 459 $editor_ids[] = $editor_id; 460 } 461 462 uasort( $locale_contributors['editors'][ $editor_source ], function( $a, $b ) { 463 return strcasecmp( $a->display_name, $b->display_name ); 464 } ); 465 } 466 437 467 unset( $editors ); 438 468 … … 469 499 ); 470 500 } 471 472 $editors = array_keys( $locale_contributors['editors'] );473 501 474 502 // Get the names of the contributors. … … 502 530 'waiting_count' => $contributor->waiting_count, 503 531 'fuzzy_count' => $contributor->fuzzy_count, 504 'is_editor' => in_array( $user->ID, $editor s ),532 'is_editor' => in_array( $user->ID, $editor_ids ), 505 533 ); 506 534 } 507 unset( $contributors, $editor s );535 unset( $contributors, $editor_ids ); 508 536 509 537 uasort( $locale_contributors['contributors'], function( $a, $b ) { 510 538 return $a->total_count < $b->total_count; 511 } );512 513 uasort( $locale_contributors['editors'], function( $a, $b ) {514 return strcasecmp( $a->display_name, $b->display_name );515 539 } ); 516 540
Note: See TracChangeset
for help on using the changeset viewer.