Making WordPress.org


Ignore:
Timestamp:
11/27/2016 11:15:12 AM (10 years ago)
Author:
ocean90
Message:

Translate, Rosetta Roles: In the waiting tab, restore showing projects for validators of base level projects like wp-plugins or wp-themes.

This is a follow-up to [4378] which removed support for including thousands of project IDs in one query. The request queries now parent_project_id directly.

See #2255.

File:
1 edited

Legend:

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

    r4378 r4427  
    592592                        $can_approve_for_all = $this->roles_adapter->is_global_administrator( $user_id );
    593593
    594                         // Check to see if they have any special approval permissions
     594                        // Limit to only showing base-level projects.
     595                        $base_level_project_sql = '';
     596                        $base_level_project_ids = $wpdb->get_col( "SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1" );
     597                        if ( $base_level_project_ids ) {
     598                                $ids = implode( ', ', array_map( 'intval', $base_level_project_ids ) );
     599                                $base_level_project_sql = " AND tp.parent_project_id IN( $ids )";
     600                        }
     601
     602                        // Check to see if they have any special approval permissions.
    595603                        $allowed_projects = array();
    596604                        if ( ! $can_approve_for_all && $role = $this->roles_adapter->is_approver_for_locale( $user_id, $locale ) ) {
    597605                                $allowed_projects = $this->roles_adapter->get_project_id_access_list( $user_id, $locale );
     606
     607                                $allowed_base_level_projects = array_intersect( $allowed_projects, $base_level_project_ids );
     608                                $allowed_projects = array_diff( $allowed_projects, $base_level_project_ids );
    598609
    599610                                // Check to see if they can approve for all projects in this locale.
     
    607618                                // The current user can approve for all projects, so just grab all with any waiting strings.
    608619                                $parent_project_sql = 'AND ( stats.waiting > 0 OR stats.fuzzy > 0 )';
    609 
    610                         } elseif ( $allowed_projects ) {
    611                                 // The current user can approve for a small set of projects.
    612                                 // We only need to check against tp.id and not tp_sub.id in this case as we've overriding the parent_project_id check
    613                                 $ids = implode( ', ', array_map( 'intval', $allowed_projects ) );
    614                                 $parent_project_sql = "AND tp.id IN( $ids ) AND stats.waiting > 0";
     620                                $parent_project_sql .= $base_level_project_sql;
     621
     622                        } elseif ( $allowed_projects || $allowed_base_level_projects ) {
     623                                $parent_project_sql = 'AND stats.waiting > 0 AND ( (';
     624
     625                                if ( $allowed_projects ) {
     626                                        /*
     627                                         * The current user can approve for a small set of projects.
     628                                         * We only need to check against tp.id and not tp_sub.id in this case as we've overriding the parent_project_id check.
     629                                         */
     630                                        $ids = implode( ', ', array_map( 'intval', $allowed_projects ) );
     631                                        $parent_project_sql .= "tp.id IN( $ids )";
     632                                        $parent_project_sql .= $base_level_project_sql;
     633                                } else {
     634                                        $parent_project_sql .= '0=1';
     635                                }
     636
     637                                $parent_project_sql .= ") OR (";
     638
     639                                if ( $allowed_base_level_projects ) {
     640                                        /*
     641                                         * The current user can approve all sub-projects of a base level project.
     642                                         */
     643                                        $ids = implode( ', ', array_map( 'intval', $allowed_base_level_projects ) );
     644                                        $parent_project_sql .= "tp.parent_project_id IN( $ids )";
     645                                } else {
     646                                        $parent_project_sql .= '0=1';
     647                                }
     648
     649                                $parent_project_sql .= ") )";
    615650
    616651                        } else {
     
    619654
    620655                        }
    621 
    622                         // Limit to only showing base-level projects
    623                         $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1) )";
    624656                }
    625657
Note: See TracChangeset for help on using the changeset viewer.