Making WordPress.org


Ignore:
Timestamp:
03/22/2016 06:21:26 AM (9 years ago)
Author:
dd32
Message:

Plugin Directory: Introduce the Plugin Committer/Review & Admin roles. Use the capabilities throughout the core flows of the admin.
This also has a few hacks to make plugin committers/authors only see plugins which they can manage, although a few core bugs remain which cause non-owner committers not to be able to edit plugins properly.

See #1571

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php

    r2638 r2777  
    4141    }
    4242
     43    public static function get_users_write_access_plugins( $user ) {
     44        global $wpdb;
     45        if ( ! $user instanceof \WP_User ) {
     46            $user = new \WP_User( $user );
     47        }
     48        if ( ! $user->exists() ) {
     49            return false;
     50        }
     51
     52        $plugins = $wpdb->get_col( $wpdb->prepare( 'SELECT path FROM `' . PLUGINS_TABLE_PREFIX . 'svn_access' . '` WHERE user = %s', $user->user_login ) );
     53        $plugins = array_map( function( $plugin ) { return trim( $plugin, '/' ); }, $plugins );
     54
     55        return $plugins;
     56
     57    }
     58
    4359    /**
    4460     * Grant a user RW access to a plugin.
     
    5571        }
    5672
    57         if ( ! $user->exists() || ! Plugin_Directory::instance()->get_plugin_post( $plugin_slug ) ) {
     73        if ( ! $user->exists() || ! Plugin_Directory::get_plugin_post( $plugin_slug ) ) {
    5874            return false;
    5975        }
    6076
    61         $existing_committers = wp_list_pluck( self::get_plugin_committers( $plugin_slug ), 'user_login' );
     77        $existing_committers = self::get_plugin_committers( $plugin_slug );
    6278        if ( in_array( $user->user_login, $existing_committers, true ) ) {
    6379            // User already has write access
     
    89105        }
    90106
    91         if ( ! $user->exists() || ! Plugin_Directory::instance()->get_plugin_post( $plugin_slug ) ) {
     107        if ( ! $user->exists() || ! Plugin_Directory::get_plugin_post( $plugin_slug ) ) {
    92108            return false;
    93109        }
Note: See TracChangeset for help on using the changeset viewer.