Changeset 5286
- Timestamp:
- 04/07/2017 09:16:09 PM (8 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
r5162 r5286 816 816 $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'repopackage' LIMIT 1", WPORG_THEME_DIRECTORY_BLOGID, $slug ) ); 817 817 } elseif ( $type == 'plugin' ) { 818 // @todo Update this when the Plugin Directory switches over to WordPress. 819 $_compat_topic = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . PLUGINS_TABLE_PREFIX . "topics WHERE topic_slug = %s", $slug ) ); 820 if ( $_compat_topic ) { 821 $_compat_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . PLUGINS_TABLE_PREFIX . "posts WHERE topic_id = %d AND post_position = 1 LIMIT 1", $_compat_topic->topic_id ) ); 822 } 823 if ( $_compat_topic && $_compat_post ) { 824 $compat_object = (object) array( 825 'post_title' => $_compat_topic->topic_title, 826 'post_name' => $slug, 827 'post_author' => $_compat_topic->topic_poster, 828 'post_content' => $_compat_post->post_text, 829 ); 830 } 818 $compat_object = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->base_prefix}%d_posts WHERE post_name = %s AND post_type = 'plugin' LIMIT 1", WPORG_PLUGIN_DIRECTORY_BLOGID, $slug ) ); 831 819 } 832 820 … … 854 842 $authors = array( $author->user_login ); 855 843 } else { 856 $authors = $wpdb->get_col( $wpdb->prepare( " SELECT user FROM " . PLUGINS_TABLE_PREFIX . "svn_access WHERE `path` = %s", '/' . $slug ) ); 844 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 845 // Note: Intentionally not considering posts of 'plugin' post_type with 846 // 'post_author' matching this author because the field only relates to 847 // the user who submitted the plugin. It does not confer special access, 848 // rights, or ownership. 849 $authors = $wpdb->get_col( $wpdb->prepare( 850 "SELECT slug 851 FROM {$prefix}terms AS t 852 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 853 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 854 WHERE tt.taxonomy = 'plugin_committers' AND tr.object_id = %d", 855 $this->plugin->ID 856 ) ); 857 857 } 858 858 … … 880 880 $contributors = wp_cache_get( $cache_key, $cache_group ); 881 881 if ( false === $contributors ) { 882 // @todo Update this when the Plugin Directory switches over to WordPress. 883 $contributors = $wpdb->get_var( $wpdb->prepare( 884 "SELECT meta_value FROM " . PLUGINS_TABLE_PREFIX . "meta m LEFT JOIN " . PLUGINS_TABLE_PREFIX . "topics t ON m.object_id = t.topic_id WHERE t.topic_slug = %s AND m.object_type = %s AND m.meta_key = %s", 885 $slug, 'bb_topic', 'contributors' ) ); 886 if ( $contributors ) { 887 $contributors = unserialize( $contributors ); 888 } 882 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 883 $contributors = $wpdb->get_col( $wpdb->prepare( 884 "SELECT slug 885 FROM {$prefix}terms AS t 886 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 887 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 888 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d", 889 $this->plugin->ID 890 ) ); 889 891 890 892 wp_cache_set( $cache_key, $contributors, $cache_group, HOUR_IN_SECONDS ); -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
r5097 r5286 133 133 'taxonomy' => 'topic-plugin', 134 134 'field' => 'slug', 135 'terms' => self::get_plugin_slugs_by_committer( $this->user->user_ login),135 'terms' => self::get_plugin_slugs_by_committer( $this->user->user_nicename ), 136 136 ) ), 137 137 'show_stickies' => false, … … 145 145 'taxonomy' => 'topic-plugin', 146 146 'field' => 'slug', 147 'terms' => $this->get_plugin_slugs_by_contributor( $this->user ),147 'terms' => $this->get_plugin_slugs_by_contributor( $this->user->user_nicename ), 148 148 ) ), 149 149 'show_stickies' => false, … … 168 168 if ( $view == 'plugin-committer' ) { 169 169 170 $slugs = self::get_plugin_slugs_by_committer( $this->user->user_ login);170 $slugs = self::get_plugin_slugs_by_committer( $this->user->user_nicename ); 171 171 172 172 // Add plugin-committer view. … … 191 191 } elseif ( $view == 'plugin-contributor' ) { 192 192 193 $slugs = self::get_plugin_slugs_by_contributor( $this->user );193 $slugs = self::get_plugin_slugs_by_contributor( $this->user->user_nicename ); 194 194 195 195 // Add plugin-contributor view. … … 453 453 } 454 454 455 public static function get_plugin_slugs_by_committer( $user_ login) {455 public static function get_plugin_slugs_by_committer( $user_nicename ) { 456 456 global $wpdb; 457 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `path` FROM `" . PLUGINS_TABLE_PREFIX . "svn_access` WHERE `user` = %s AND `access` = 'rw'", $user_login ) ); 458 return self::clean_slugs( $slugs ); 459 } 460 461 public static function get_plugin_slugs_by_contributor( $user ) { 457 458 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 459 $slugs = $wpdb->get_col( $wpdb->prepare( 460 "SELECT post_name 461 FROM {$prefix}posts AS p 462 LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id 463 LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id 464 LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id 465 WHERE tt.taxonomy = 'plugin_committers' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s 466 ORDER BY p.post_title ASC", 467 $user_nicename 468 ) ); 469 470 return $slugs; 471 } 472 473 public static function get_plugin_slugs_by_contributor( $user_nicename ) { 462 474 global $wpdb; 463 $slugs = (array) $wpdb->get_col( $wpdb->prepare( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_poster` = %d AND topic_open = 1 AND topic_status = 0", $user->ID ) ); 464 $slugs = self::clean_slugs( $slugs ); 465 if ( $contributor = $wpdb->get_col( $wpdb->prepare( "SELECT `object_id` FROM `" . PLUGINS_TABLE_PREFIX . "meta` WHERE `object_type` = 'bb_topic' AND `meta_key` = 'contributors' AND `meta_value` LIKE %s", '%"' . str_replace( array( '%', '_' ), array( '\\%', '\\_' ), $user->user_login ) . '"%' ) ) ) { 466 if ( $contributor_slugs = $wpdb->get_col( "SELECT `topic_slug` FROM `" . PLUGINS_TABLE_PREFIX . "topics` WHERE `topic_id` IN (" . join( ',', $contributor ) . ") AND topic_open = 1 AND topic_status = 0" ) ) { 467 $slugs = array_unique( array_merge( $slugs, $contributor_slugs ) ); 468 } 469 } 475 476 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 477 $slugs = $wpdb->get_col( $wpdb->prepare( 478 "SELECT post_name 479 FROM {$prefix}posts AS p 480 LEFT JOIN {$prefix}term_relationships AS tr ON p.ID = tr.object_id 481 LEFT JOIN {$prefix}term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id 482 LEFT JOIN {$prefix}terms AS t ON tt.term_id = t.term_id 483 WHERE tt.taxonomy = 'plugin_contributors' AND p.post_status = 'publish' AND p.post_type = 'plugin' AND t.slug = %s 484 ORDER BY p.post_title ASC", 485 $user_nicename 486 ) ); 487 470 488 return $slugs; 471 489 }
Note: See TracChangeset
for help on using the changeset viewer.