Making WordPress.org

Changeset 8496


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.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/locale-projects.php

    r7617 r8496  
    8686<div class="sort-bar">
    8787    <form id="sort-filter" action="" method="GET">
     88        <input type="hidden" name="s" value="<?php echo esc_attr( $search ?? '' ); ?>"
    8889        <input type="hidden" name="page" value="1">
     90
     91        <?php if ( 'waiting' === $project->slug && is_user_logged_in() ) { ?>
     92            <input id="filter-without-editors" type="checkbox" name="without-editors" value="1"<?php checked( isset( $_GET['without-editors'] ) ); ?>>
     93            <label for="filter-without-editors">Limit to projects without editors</label>
     94            <span class="filter-sep" aria-hidden="true">|</span>
     95        <?php } ?>
     96
     97        <label for="filter">Filter:</label>
    8998        <select id="filter" name="filter">
    9099            <?php
     
    111120            ?>
    112121        </select>
     122        <button type="submit">Submit</button>
    113123    </form>
    114124</div>
    115 <script>
    116     var filterForm  = document.getElementById( 'sort-filter' );
    117     var filterSelect = document.getElementById( 'filter' );
    118     filterSelect.addEventListener( 'change', function() {
    119         filterForm.submit()
    120     } );
    121 </script>
    122 
    123125<div id="projects" class="projects">
    124126    <?php
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css

    r7371 r8496  
    14281428    border: 1px solid #dfdfdf;
    14291429    border-top: none;
     1430}
     1431
     1432.sort-bar label {
     1433    font-size: 12px;
     1434    line-height: 14px;
     1435}
     1436
     1437.sort-bar .filter-sep {
     1438    color: #ccc;
    14301439}
    14311440
  • 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.