mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
work in progress, add fidelity to category group permissions (full, create posts, readonly)
This commit is contained in:
@ -7,6 +7,7 @@ class Guardian
|
||||
def staff?; false; end
|
||||
def approved?; false; end
|
||||
def secure_category_ids; []; end
|
||||
def topic_create_allowed_category_ids; []; end
|
||||
def has_trust_level?(level); false; end
|
||||
end
|
||||
|
||||
@ -328,7 +329,7 @@ class Guardian
|
||||
topic.deleted_at.nil? &&
|
||||
|
||||
# not secure, or I can see it
|
||||
(not(topic.secure_category?) || can_see_category?(topic.category)) &&
|
||||
(not(topic.read_restricted_category?) || can_see_category?(topic.category)) &&
|
||||
|
||||
# not private, or I am allowed (or an admin)
|
||||
(not(topic.private_message?) || authenticated? && (topic.all_allowed_users.where(id: @user.id).exists? || is_admin?))
|
||||
@ -340,7 +341,7 @@ class Guardian
|
||||
end
|
||||
|
||||
def can_see_category?(category)
|
||||
not(category.secure) || secure_category_ids.include?(category.id)
|
||||
not(category.read_restricted) || secure_category_ids.include?(category.id)
|
||||
end
|
||||
|
||||
def can_vote?(post, opts={})
|
||||
@ -378,6 +379,10 @@ class Guardian
|
||||
@secure_category_ids ||= @user.secure_category_ids
|
||||
end
|
||||
|
||||
def topic_create_allowed_category_ids
|
||||
@topic_create_allowed_category_ids ||= @user.topic_create_allowed_category_ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def is_my_own?(obj)
|
||||
|
Reference in New Issue
Block a user