Making WordPress.org

Changeset 1839


Ignore:
Timestamp:
08/20/2015 02:04:27 AM (9 years ago)
Author:
dd32
Message:

Translate: Fix non-translation-editors from being able to view non-wp project tabs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/locale.php

    r1837 r1839  
    1414     * @param string $project_path     Path of a project.
    1515     */
    16     public function get_locale_projects( $locale_slug, $set_slug = 'default', $project_path = 'waiting' ) {
     16    public function get_locale_projects( $locale_slug, $set_slug = 'default', $project_path = false ) {
    1717        global $gpdb;
    1818
     
    3131        usort( $top_level_projects, array( $this, '_sort_reverse_name_callback' ) );
    3232
    33         // Filter out the Waiting Tab if the current user cannot validate strings
     33        // Default to the Waiting or WordPress tabs
     34        $default_project_tab = 'waiting';
    3435        $user = GP::$user->current();
    3536        if (
     
    3940                GP::$plugins->wporg_rosetta_roles->is_global_administrator( $user->id ) || // Not a global admin
    4041                GP::$plugins->wporg_rosetta_roles->is_approver_for_locale( $user->id, $locale_slug ) // Doesn't have project-level access either
    41             ) ) { // Add check to see if there are any waiting translations for this locale?
     42            )
     43            // Add check to see if there are any waiting translations for this locale?
     44            ) {
     45            $default_project_tab = 'wp';
     46        }
     47
     48        // Filter out the Waiting Tab if the current user cannot validate strings
     49        if ( 'waiting' != $default_project_tab ) {
    4250            foreach ( $top_level_projects as $i => $project ) {
    4351                if ( 'waiting' == $project->slug ) {
     
    4654                }
    4755            }
    48 
    49             // Reset to default path of wp if the Waiting tab shouldn't be shown for this user.
    50             $project_path = 'wp';
    51         }
     56        }
     57
     58        $project_path = $project_path ?: $default_project_tab;
    5259
    5360        $project = GP::$project->by_path( $project_path );
Note: See TracChangeset for help on using the changeset viewer.