Making WordPress.org


Ignore:
Timestamp:
05/10/2022 04:35:32 AM (3 years ago)
Author:
dd32
Message:

Helpscout: List plugins the emailer has commit access to, in addition to being the owner of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/dotorg/helpscout/plugins-themes.php

    r11823 r11825  
    2525
    2626    switch_to_blog( $site_id );
     27
     28    $slugs = [];
     29    if ( 'plugin' === $type ) {
     30        // Committer to a plugin.
     31        $slugs = $wpdb->get_col( $wpdb->prepare( 'SELECT path FROM `' . PLUGINS_TABLE_PREFIX . 'svn_access' . '` WHERE user = %s', $user->user_login ) );
     32        $slugs = array_filter( array_map( function( $slug ) {
     33            return ltrim( $slug, '/' ) ?: false;
     34        }, $slugs ) );
     35
     36        // TODO: Would be nice to pull for support reps too, but that's less common.
     37    }
     38
     39    $slugs    = $slugs ? '"' . implode( '", "', array_map( 'esc_sql', $slugs ) ) . '"' : '';
     40    $or_slugs = $slugs ? "OR post_name IN( {$slugs} )" : '';
     41
    2742    $counts = $wpdb->get_results( $wpdb->prepare(
    28         "SELECT post_status, COUNT(*) as count, group_concat( ID ) as ids, group_concat( post_title SEPARATOR ', ' ) as titles FROM $wpdb->posts WHERE post_type = %s AND post_author = %s GROUP BY post_status",
     43        "SELECT post_status, COUNT(*) as count, group_concat( ID ) as ids, group_concat( post_title SEPARATOR ', ' ) as titles
     44        FROM $wpdb->posts
     45        WHERE post_type = %s AND ( post_author = %s {$or_slugs} )
     46        GROUP BY post_status",
    2947        $post_type,
    3048        $user->ID
    3149    ) );
     50
    3251    if ( $counts ) {
    3352        $total       = array_sum( wp_list_pluck( $counts, 'count' ) );
     
    4766            add_query_arg( [ 'post_type' => $post_type, 'author' => $user->ID ], admin_url( 'edit.php' ) ),
    4867            esc_attr( $post_statii ),
    49             ucwords( _n( "$total $type", "{$total} {$type}s", $total ) ) // Real bad internationalisation where internationalisation will bever be used.
     68            ucwords( _n( "$total $type", "{$total} {$type}s", $total ) ) // Real bad internationalisation where internationalisation will never be used.
    5069        );
    5170
Note: See TracChangeset for help on using the changeset viewer.