Making WordPress.org


Ignore:
Timestamp:
09/04/2016 07:57:05 PM (8 years ago)
Author:
ocean90
Message:

Translate, Rosetta Roles: Refactor the plugin to use an autoloader and add an initial list table to manage translators.

See #1770.

File:
1 edited

Legend:

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

    r3277 r3952  
    88use GP_Route;
    99use stdClass;
     10use WordPressdotorg\GlotPress\Rosetta_Roles\Plugin as Rosetta_Roles;
    1011
    1112/**
     
    1718
    1819    /**
     20     * Adapter for the rosetta roles plugin.
     21     *
     22     * @var null|Rosetta_Roles
     23     */
     24    private $roles_adapter = null;
     25
     26    public function __construct() {
     27        parent::__construct();
     28
     29        if ( method_exists( Rosetta_Roles::class, 'get_instance' ) ) {
     30            $this->roles_adapter = Rosetta_Roles::get_instance();
     31        }
     32    }
     33
     34    /**
    1935     * Prints projects/translation sets of a top level project.
    2036     *
     
    4561        if (
    4662            ! is_user_logged_in() ||
    47             ! function_exists( 'wporg_gp_rosetta_roles' ) || // Rosetta Roles plugin is not enabled
     63            ! $this->roles_adapter || // Rosetta Roles plugin is not enabled
    4864            ! (
    49                 wporg_gp_rosetta_roles()->is_global_administrator( $user_id ) || // Not a global admin
    50                 wporg_gp_rosetta_roles()->is_approver_for_locale( $user_id, $locale_slug ) // Doesn't have project-level access either
     65                $this->roles_adapter->is_global_administrator( $user_id ) || // Not a global admin
     66                $this->roles_adapter->is_approver_for_locale( $user_id, $locale_slug ) // Doesn't have project-level access either
    5167            )
    5268            // Add check to see if there are any waiting translations for this locale?
     
    565581        // Special Waiting Project Tab
    566582        // This removes the parent_project_id restriction and replaces it with all-translation-editer-projects
    567         if ( 'waiting' == $project->slug && is_user_logged_in() && function_exists( 'wporg_gp_rosetta_roles' ) ) {
     583        if ( 'waiting' == $project->slug && is_user_logged_in() && $this->roles_adapter ) {
    568584
    569585            if ( ! $filter ) {
     
    574590
    575591            // Global Admin or Locale-specific admin
    576             $can_approve_for_all = wporg_gp_rosetta_roles()->is_global_administrator( $user_id );
     592            $can_approve_for_all = $this->roles_adapter->is_global_administrator( $user_id );
    577593
    578594            // Check to see if they have any special approval permissions
    579595            $allowed_projects = array();
    580             if ( ! $can_approve_for_all && wporg_gp_rosetta_roles()->is_approver_for_locale( $user_id, $locale ) ) {
    581                 $allowed_projects = wporg_gp_rosetta_roles()->get_project_id_access_list( $user_id, $locale, true );
     596            if ( ! $can_approve_for_all && $this->roles_adapter->is_approver_for_locale( $user_id, $locale ) ) {
     597                $allowed_projects = $this->roles_adapter->get_project_id_access_list( $user_id, $locale, true );
    582598
    583599                // Check to see if they can approve for all projects in this locale.
     
    588604            }
    589605
    590             $parent_project_sql = '';
    591606            if ( $can_approve_for_all ) {
    592607                // The current user can approve for all projects, so just grab all with any waiting strings.
     
    607622            // Limit to only showing base-level projects
    608623            $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1) )";
    609 
    610624        }
    611625
Note: See TracChangeset for help on using the changeset viewer.