Changeset 3952 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
- Timestamp:
- 09/04/2016 07:57:05 PM (9 years ago)
- 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 8 8 use GP_Route; 9 9 use stdClass; 10 use WordPressdotorg\GlotPress\Rosetta_Roles\Plugin as Rosetta_Roles; 10 11 11 12 /** … … 17 18 18 19 /** 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 /** 19 35 * Prints projects/translation sets of a top level project. 20 36 * … … 45 61 if ( 46 62 ! is_user_logged_in() || 47 ! function_exists( 'wporg_gp_rosetta_roles' )|| // Rosetta Roles plugin is not enabled63 ! $this->roles_adapter || // Rosetta Roles plugin is not enabled 48 64 ! ( 49 wporg_gp_rosetta_roles()->is_global_administrator( $user_id ) || // Not a global admin50 wporg_gp_rosetta_roles()->is_approver_for_locale( $user_id, $locale_slug ) // Doesn't have project-level access either65 $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 51 67 ) 52 68 // Add check to see if there are any waiting translations for this locale? … … 565 581 // Special Waiting Project Tab 566 582 // 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 ) { 568 584 569 585 if ( ! $filter ) { … … 574 590 575 591 // 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 ); 577 593 578 594 // Check to see if they have any special approval permissions 579 595 $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 ); 582 598 583 599 // Check to see if they can approve for all projects in this locale. … … 588 604 } 589 605 590 $parent_project_sql = '';591 606 if ( $can_approve_for_all ) { 592 607 // The current user can approve for all projects, so just grab all with any waiting strings. … … 607 622 // Limit to only showing base-level projects 608 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) )"; 609 610 624 } 611 625
Note: See TracChangeset
for help on using the changeset viewer.