Index: sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-dropin.php
===================================================================
--- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-dropin.php	(revision 4905)
+++ sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-dropin.php	(working copy)
@@ -40,6 +40,19 @@
 		if ( is_admin() ) {
 			remove_filter( 'the_title', 'bbp_get_reply_title_fallback', 2 );
 		}
+
+		if ( ! current_user_can( 'moderate' ) ) {
+			// Filter out hidden reply references from public views
+			add_filter( 'bbp_get_topic_last_reply_id',   array( $this, 'get_last_public_reply_id' ), 10, 2 );
+			add_filter( 'bbp_get_topic_last_active',     array( $this, 'get_last_public_post_time' ), 10, 2 );
+			add_filter( 'bbp_get_topic_last_active_id',  array( $this, 'get_last_public_post_id' ), 10, 2 );
+			add_filter( 'bbp_get_topic_reply_count_int', array( $this, 'get_public_reply_count' ), 10, 2 );
+		} else {
+			// Append 'view=all' to topics with hidden replies
+			add_filter( 'bbp_get_topic_permalink',       array( $this, 'append_view_all_to_topic_permalink' ), 10, 2 );
+			add_filter( 'bbp_get_topic_last_reply_url',  array( $this, 'append_view_all_to_last_reply_url' ), 10, 3 );
+			add_filter( 'paginate_links',                array( $this, 'append_view_all_to_topic_pagination' ), 10, 1 );
+		}
 	}
 
 	/**
@@ -328,4 +341,113 @@
 			}
 		}
 	}
+
+	/**
+	 * Return the ID of the last public reply in a topic.
+	 *
+	 * @param int $reply_id Reply ID.
+	 * @param int $topic_id Topic ID.
+	 * @return int Last public reply ID.
+	 */
+	function get_last_public_reply_id( $reply_id, $topic_id ) {
+		if ( 'publish' !== get_post_status( $reply_id ) ) {
+			$reply_id = bbp_get_public_child_last_id( $topic_id, bbp_get_reply_post_type() );
+		}
+
+		return $reply_id;
+	}
+
+	/**
+	 * Return last public activity time for a topic.
+	 *
+	 * @param string $last_active Last activity time.
+	 * @param int $topic_id Topic ID.
+	 * @return string Last public activity time.
+	 */
+	function get_last_public_post_time( $last_active, $topic_id ) {
+		if ( bbp_get_topic_reply_count_hidden( $topic_id ) ) {
+			$reply_id = bbp_get_topic_last_reply_id( $topic_id );
+
+			$last_active = get_post_field( 'post_date', $reply_id );
+			$last_active = ! empty( $last_active ) ? bbp_get_time_since( bbp_convert_date( $last_active ) ) : '';
+		}
+
+		return $last_active;
+	}
+
+	/**
+	 * Return the ID of the last public post in a topic.
+	 *
+	 * @param int $active_id Last post ID.
+	 * @param int $topic_id Topic ID.
+	 * @return int Last public post ID.
+	 */
+	function get_last_public_post_id( $active_id, $topic_id ) {
+		if ( bbp_get_topic_reply_count_hidden( $topic_id ) ) {
+			$active_id = bbp_get_topic_last_reply_id( $topic_id );
+		}
+
+		return $active_id;
+	}
+
+	/**
+	 * Return public reply counå for a topic.
+	 *
+	 * @param int $replies Reply count.
+	 * @param int $topic_id Topic ID.
+	 * @return int Public reply count.
+	 */
+	function get_public_reply_count( $replies, $topic_id ) {
+		if ( bbp_get_topic_reply_count_hidden( $topic_id ) ) {
+			$replies = bbp_get_public_child_count( $topic_id, bbp_get_reply_post_type() );
+		}
+
+		return $replies;
+	}
+
+	/**
+	 * Append 'view=all' to topic permalink if the topic has hidden replies.
+	 *
+	 * @param string $topic_permalink Topic permalink.
+	 * @param int $topic_id Topic ID.
+	 * @return string Filtered topic permalink.
+	 */
+	function append_view_all_to_topic_permalink( $topic_permalink, $topic_id ) {
+		if ( bbp_get_topic_reply_count_hidden( $topic_id ) ) {
+			$topic_permalink = add_query_arg( 'view', 'all', $topic_permalink );
+		}
+
+		return $topic_permalink;
+	}
+
+	/**
+	 * Append 'view=all' to last reply URL if the topic has hidden replies.
+	 *
+	 * @param string $reply_url Reply URL.
+	 * @param int $topic_id Topic ID.
+	 * @param int $reply_id Reply ID.
+	 * @return string Filtered reply URL.
+	 */
+	function append_view_all_to_last_reply_url( $reply_url, $topic_id, $reply_id ) {
+		if ( bbp_get_topic_reply_count_hidden( $topic_id ) ) {
+			$reply_url = add_query_arg( 'view', 'all', $reply_url );
+		}
+
+		return $reply_url;
+	}
+
+	/**
+	 * Append 'view=all' to topic pagination if the topic has hidden replies.
+	 *
+	 * @param string $link Paginated link URL.
+	 * @return string Filtered link URL.
+	 */
+	function append_view_all_to_topic_pagination( $link ) {
+		if ( bbp_get_topic_reply_count_hidden( bbp_get_topic_id() ) ) {
+			$link = add_query_arg( 'view', 'all', $link );
+		}
+
+		return $link;
+	}
+
 }
