Changeset 2111
- Timestamp:
- 11/22/2015 09:24:33 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/locale.php
r2109 r2111 39 39 // Default to the Waiting or WordPress tabs 40 40 $default_project_tab = 'waiting'; 41 $user = GP::$user->current();41 $user_id = get_current_user_id(); 42 42 if ( 43 ! $user->id || // Not logged in44 ! isset( GP::$plugins->wporg_rosetta_roles) || // Rosetta Roles plugin is not enabled43 ! is_user_logged_in() || 44 ! function_exists( 'wporg_gp_rosetta_roles' ) || // Rosetta Roles plugin is not enabled 45 45 ! ( 46 GP::$plugins->wporg_rosetta_roles->is_global_administrator( $user->id ) || // Not a global admin47 GP::$plugins->wporg_rosetta_roles->is_approver_for_locale( $user->id, $locale_slug ) // Doesn't have project-level access either46 wporg_gp_rosetta_roles()->is_global_administrator( $user_id ) || // Not a global admin 47 wporg_gp_rosetta_roles()->is_approver_for_locale( $user_id, $locale_slug ) // Doesn't have project-level access either 48 48 ) 49 49 // Add check to see if there are any waiting translations for this locale? … … 101 101 $project_ids = array_merge( 102 102 $project_ids, 103 $wpdb->get_col( "SELECT id FROM {$wpdb-> projects} WHERE parent_project_id IN(" . implode(', ', $project_ids ) . ")" )103 $wpdb->get_col( "SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IN(" . implode(', ', $project_ids ) . ")" ) 104 104 ); 105 105 … … 249 249 $slugs = $wpdb->get_col( $wpdb->prepare( " 250 250 SELECT DISTINCT slug 251 FROM {$wpdb-> translation_sets}251 FROM {$wpdb->gp_translation_sets} 252 252 WHERE 253 253 project_id IN( $project_ids ) … … 328 328 $_projects = $project->many( " 329 329 SELECT * 330 FROM {$wpdb-> projects}330 FROM {$wpdb->gp_projects} 331 331 WHERE 332 332 parent_project_id = %d AND … … 343 343 $sub_projects = $project->many( " 344 344 SELECT * 345 FROM {$wpdb-> projects}345 FROM {$wpdb->gp_projects} 346 346 WHERE 347 347 parent_project_id = %d AND … … 407 407 // Special Waiting Project Tab 408 408 // This removes the parent_project_id restriction and replaces it with all-translation-editer-projects 409 if ( 'waiting' == $project->slug && GP::$user->current()->id && isset( GP::$plugins->wporg_rosetta_roles) ) {409 if ( 'waiting' == $project->slug && is_user_logged_in() && function_exists( 'wporg_gp_rosetta_roles' ) ) { 410 410 411 411 if ( ! $filter ) { … … 413 413 } 414 414 415 $user_id = GP::$user->current()->id;415 $user_id = get_current_user_id(); 416 416 417 417 // Global Admin or Locale-specific admin 418 $can_approve_for_all = GP::$plugins->wporg_rosetta_roles->is_global_administrator( $user_id );418 $can_approve_for_all = wporg_gp_rosetta_roles()->is_global_administrator( $user_id ); 419 419 420 420 // Check to see if they have any special approval permissions 421 421 $allowed_projects = array(); 422 if ( ! $can_approve_for_all && GP::$plugins->wporg_rosetta_roles->is_approver_for_locale( $user_id, $locale ) ) {423 $allowed_projects = GP::$plugins->wporg_rosetta_roles->get_project_id_access_list( $user_id, $locale, true );422 if ( ! $can_approve_for_all && wporg_gp_rosetta_roles()->is_approver_for_locale( $user_id, $locale ) ) { 423 $allowed_projects = wporg_gp_rosetta_roles()->get_project_id_access_list( $user_id, $locale, true ); 424 424 425 425 // Check to see if they can approve for all projects in this locale. … … 448 448 449 449 // Limit to only showing base-level projects 450 $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb-> projects} WHERE parent_project_id IS NULL AND active = 1) )";450 $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb->gp_projects} WHERE parent_project_id IS NULL AND active = 1) )"; 451 451 452 452 } … … 463 463 case 'special': 464 464 // Float favorites to the start, but only if they have untranslated strings 465 $user_fav_projects = array_map( array( $wpdb, 'escape' ), $this->get_user_favorites( $project->slug ) );465 $user_fav_projects = array_map( 'esc_sql', $this->get_user_favorites( $project->slug ) ); 466 466 467 467 // Float Favorites to the start, float fully translated to the bottom, order the rest by name … … 475 475 case 'favorites': 476 476 // Only list favorites 477 $user_fav_projects = array_map( array( $wpdb, 'escape' ), $this->get_user_favorites( $project->slug ) );477 $user_fav_projects = array_map( 'esc_sql', $this->get_user_favorites( $project->slug ) ); 478 478 479 479 if ( $user_fav_projects ) { … … 513 513 $_projects = $project->many( " 514 514 SELECT SQL_CALC_FOUND_ROWS tp.* 515 FROM {$wpdb-> projects} tp515 FROM {$wpdb->gp_projects} tp 516 516 LEFT JOIN {$wpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.locale = %s AND stats.locale_slug = %s 517 517 WHERE … … 547 547 function get_user_favorites( $project_slug = false ) { 548 548 global $wpdb; 549 $user = GP::$user->current(); 550 551 if ( ! $user->id ) { 549 550 if ( ! is_user_logged_in() ) { 552 551 return array(); 553 552 } 553 554 $user_id = get_current_user_id(); 554 555 555 556 switch ( $project_slug ) { … … 560 561 $theme_favorites = array_map( function( $slug ) { 561 562 return "wp-themes/$slug"; 562 }, (array) $user->get_meta( 'theme_favorites') );563 }, (array) get_user_meta( $user_id, 'theme_favorites', true ) ); 563 564 564 565 if ( 'wp-themes' === $project_slug ) { … … 568 569 case 'wp-plugins': 569 570 // Plugin favorites are stored as topic ID's 570 $plugin_fav_ids = array_keys( (array) $user->get_meta( PLUGINS_TABLE_PREFIX . 'plugin_favorite') );571 $plugin_fav_ids = array_keys( (array) get_user_meta( $user_id, PLUGINS_TABLE_PREFIX . 'plugin_favorite', true ) ); 571 572 $plugin_fav_slugs = array(); 572 573 if ( $plugin_fav_ids ) { … … 598 599 return GP::$project->many( " 599 600 SELECT * 600 FROM {$wpdb-> projects}601 FROM {$wpdb->gp_projects} 601 602 WHERE 602 603 parent_project_id IS NULL
Note: See TracChangeset
for help on using the changeset viewer.