diff --git a/app/models/post.rb b/app/models/post.rb index a8e8fbc40..9f3c2b269 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -838,11 +838,20 @@ class Post < ActiveRecord::Base favorited_user_ids.map {|id| User.find(id)} end - def favorite_groups + def favorite_groups(active_id=nil) @favorite_groups ||= begin - CurrentUser.user.favorite_groups.select do |favgroup| + groups = [] + + if active_id.present? + active_group = FavoriteGroup.where(:id => active_id.to_i).first + groups << active_group if active_group && active_group.contains?(self.id) + end + + groups += CurrentUser.user.favorite_groups.select do |favgroup| favgroup.contains?(self.id) end + + groups.uniq end end end diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 81a518fe7..e469a25f3 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -205,7 +205,7 @@ class PostPresenter < Presenter end def has_nav_links?(template) - (CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups.any? + (CurrentUser.user.enable_sequential_post_navigation && template.params[:tags].present? && template.params[:tags] !~ /(?:^|\s)(?:order|ordfav|ordpool):/) || @post.pools.any? || @post.favorite_groups(active_id=template.params[:favgroup_id]).any? end def post_footer_for_pool_html(template) diff --git a/app/views/posts/partials/show/_favorite_groups.html.erb b/app/views/posts/partials/show/_favorite_groups.html.erb index f962ae62c..581df4169 100644 --- a/app/views/posts/partials/show/_favorite_groups.html.erb +++ b/app/views/posts/partials/show/_favorite_groups.html.erb @@ -1,6 +1,6 @@