only staff should be able to see bookmarks and favs of other users

ensure that when they click on them they see the correct topics (topics for user they are looking at, not current user)
This commit is contained in:
Sam 2013-08-22 09:18:54 +10:00
parent 38e80b999f
commit d7596840e5
3 changed files with 8 additions and 4 deletions

View File

@ -190,6 +190,6 @@ Discourse.UserActivityFavoritesRoute = Discourse.UserTopicListRoute.extend({
userActionType: Discourse.UserAction.TYPES.favorites,
model: function() {
return Discourse.TopicList.find('favorited');
return Discourse.TopicList.find('favorited?user_id=' + this.modelFor('user').get('id'));
}
});

View File

@ -8,7 +8,11 @@ class ListController < ApplicationController
[:latest, :hot, :favorited, :read, :posted, :unread, :new].each do |filter|
define_method(filter) do
list_opts = build_topic_list_options
list = TopicQuery.new(current_user, list_opts).public_send("list_#{filter}")
user = current_user
if params[:user_id] && guardian.is_staff?
user = User.find(params[:user_id].to_i)
end
list = TopicQuery.new(user, list_opts).public_send("list_#{filter}")
list.more_topics_url = url_for(self.public_send "#{filter}_path".to_sym, list_opts.merge(format: 'json', page: next_page))
respond(list)

View File

@ -301,8 +301,8 @@ SQL
builder.where("p.deleted_at is null and p2.deleted_at is null and t.deleted_at is null")
end
unless guardian.user && guardian.user.id == user_id
builder.where("a.action_type not in (#{BOOKMARK})")
unless (guardian.user && guardian.user.id == user_id) || guardian.is_staff?
builder.where("a.action_type not in (#{BOOKMARK},#{STAR})")
end
if !guardian.can_see_private_messages?(user_id) || ignore_private_messages