Ticket #2255: 2255.patch
File 2255.patch, 4.3 KB (added by , 8 years ago) |
---|
-
trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/inc/routes/class-locale.php
591 591 // Global Admin or Locale-specific admin 592 592 $can_approve_for_all = $this->roles_adapter->is_global_administrator( $user_id ); 593 593 594 // Limit to only showing base-level projects 595 $base_level_project_sql = ''; 596 $base_level_project_ids = $wpdb->get_col( "SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1" ); 597 if ( $base_level_project_ids ) { 598 $ids = implode( ', ', array_map( 'intval', $base_level_project_ids ) ); 599 $base_level_project_sql = " AND tp.parent_project_id IN( $ids )"; 600 } 601 594 602 // Check to see if they have any special approval permissions 595 603 $allowed_projects = array(); 596 604 if ( ! $can_approve_for_all && $role = $this->roles_adapter->is_approver_for_locale( $user_id, $locale ) ) { 597 605 $allowed_projects = $this->roles_adapter->get_project_id_access_list( $user_id, $locale ); 598 606 607 $allowed_base_level_projects = array_intersect( $allowed_projects, $base_level_project_ids ); 608 $allowed_projects = array_diff( $allowed_projects, $base_level_project_ids ); 609 599 610 // Check to see if they can approve for all projects in this locale. 600 611 if ( Rosetta_Roles::LOCALE_MANAGER_ROLE === $role || in_array( 'all', $allowed_projects ) ) { 601 612 $can_approve_for_all = true; … … 605 616 606 617 if ( $can_approve_for_all ) { 607 618 // The current user can approve for all projects, so just grab all with any waiting strings. 608 $parent_project_sql = 'AND ( stats.waiting > 0 OR stats.fuzzy > 0 )'; 619 $parent_project_sql = 'AND ( stats.waiting > 0 OR stats.fuzzy > 0 )'; 620 $parent_project_sql .= $base_level_project_sql; 609 621 610 } elseif ( $allowed_projects ) { 611 // The current user can approve for a small set of projects. 612 // We only need to check against tp.id and not tp_sub.id in this case as we've overriding the parent_project_id check 613 $ids = implode( ', ', array_map( 'intval', $allowed_projects ) ); 614 $parent_project_sql = "AND tp.id IN( $ids ) AND stats.waiting > 0"; 622 } elseif ( $allowed_projects || $allowed_base_level_projects ) { 623 $parent_project_sql = 'AND stats.waiting > 0 AND ( ('; 615 624 625 if ( $allowed_projects ) { 626 /* 627 * The current user can approve for a small set of projects. 628 * We only need to check against tp.id and not tp_sub.id in this case as we've overriding the parent_project_id check. 629 */ 630 $ids = implode( ', ', array_map( 'intval', $allowed_projects ) ); 631 $parent_project_sql .= "tp.id IN( $ids )"; 632 $parent_project_sql .= $base_level_project_sql; 633 } else { 634 $parent_project_sql .= '0=1'; 635 } 636 637 $parent_project_sql .= ") OR ("; 638 639 if ( $allowed_base_level_projects ) { 640 /* 641 * The current user can approve all sub-projects of a base level project. 642 */ 643 $ids = implode( ', ', array_map( 'intval', $allowed_base_level_projects ) ); 644 $parent_project_sql .= "tp.parent_project_id IN( $ids )"; 645 } else { 646 $parent_project_sql .= '0=1'; 647 } 648 649 $parent_project_sql .= ") )"; 650 616 651 } else { 617 652 // The current user can't approve for any locale projects, or is logged out. 618 653 $parent_project_sql = 'AND 0=1'; 619 654 620 655 } 621 622 // Limit to only showing base-level projects623 $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1) )";624 656 } 625 657 626 658 $filter_order_by = $filter_where = ''; … … 667 699 $filter_order_by = "tp.path LIKE 'wp/%%' AND (stats.fuzzy + stats.waiting) > 0 DESC, (stats.fuzzy + stats.waiting) $sort_order, tp.name ASC"; 668 700 break; 669 701 702 case 'strings-waiting-and-fuzzy-recently-modified': 703 $filter_where = 'AND (stats.waiting > 0 OR stats.fuzzy > 0 )'; 704 $filter_order_by = "date(stats.date_modified) DESC, (stats.fuzzy + stats.waiting) $sort_order"; 705 break; 706 670 707 case 'percent-completed': 671 708 $filter_where = 'AND stats.untranslated > 0'; 672 709 $filter_order_by = "( stats.current / stats.all ) $sort_order, tp.name ASC";