Making WordPress.org


Ignore:
Timestamp:
03/24/2019 03:15:29 PM (6 years ago)
Author:
ocean90
Message:

Translate: Add a filter to limit waiting view to projects without an assigned editor.

Fixes #3586.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php

    r7770 r8496  
    4747        $search = gp_get( 's', '' );
    4848        $filter = gp_get( 'filter', false );
     49        $without_editors = gp_get( 'without-editors', false );
    4950
    5051        $locale = GP_Locales::by_slug( $locale_slug );
     
    100101                'search' => $search,
    101102                'filter' => $filter,
     103                'without_editors' => $without_editors,
    102104                'set_slug' => $set_slug,
    103105                'locale' => $locale_slug,
     
    698700
    699701        $defaults = array(
    700             'per_page' => 20,
    701             'page'     => 1,
    702             'search'   => false,
    703             'set_slug' => '',
    704             'locale'   => '',
    705             'filter'   => false,
     702            'per_page'        => 20,
     703            'page'            => 1,
     704            'search'          => false,
     705            'set_slug'        => '',
     706            'locale'          => '',
     707            'filter'          => false,
     708            'without_editors' => false,
    706709        );
    707710        $r = wp_parse_args( $args, $defaults );
     
    744747            // Check to see if they have any special approval permissions.
    745748            $allowed_projects = array();
     749            $allowed_base_level_projects = array();
    746750            if ( ! $can_approve_for_all && $role = $this->roles_adapter->is_approver_for_locale( $user_id, $locale ) ) {
    747751                $allowed_projects = $this->roles_adapter->get_project_id_access_list( $user_id, $locale );
     
    761765                $parent_project_sql = 'AND ( stats.waiting > 0 OR stats.fuzzy > 0 )';
    762766                $parent_project_sql .= $base_level_project_sql;
    763 
    764767            } elseif ( $allowed_projects || $allowed_base_level_projects ) {
    765                 $parent_project_sql = 'AND stats.waiting > 0 AND ( (';
     768                $parent_project_sql = 'AND ( stats.waiting > 0 OR stats.fuzzy > 0 ) AND ( (';
    766769
    767770                if ( $allowed_projects ) {
     
    795798                $parent_project_sql = 'AND 0=1';
    796799
     800            }
     801
     802            // Exclude projects which have an assigned editor.
     803            if ( $without_editors ) {
     804                $project_ids_with_editor = $wpdb->get_col( $wpdb->prepare(
     805                    "SELECT DISTINCT(project_id) FROM `translate_translation_editors` WHERE (locale = %s OR locale = 'all-locales') AND project_id != 0 AND user_id != %d",
     806                    $locale,
     807                    $user_id
     808                ) );
     809                if ( $project_ids_with_editor ) {
     810                    $project_ids_with_editor = implode( ', ', array_map( 'intval', $project_ids_with_editor ) );
     811                    $parent_project_sql .= " AND tp.id NOT IN( $project_ids_with_editor )";
     812                }
    797813            }
    798814        }
Note: See TracChangeset for help on using the changeset viewer.