discourse/lib/guardian/group_guardian.rb

Failed to ignore revisions in .git-blame-ignore-revs.

23 lines
641 B
Ruby
Raw Normal View History

# frozen_string_literal: true
#mixin for all guardian methods dealing with group permissions
module GroupGuardian
# Edit authority for groups means membership changes only.
# Automatic groups are not represented in the GROUP_USERS
# table and thus do not allow membership changes.
def can_edit_group?(group)
!group.automatic && can_log_group_changes?(group)
2016-12-11 23:36:15 +08:00
end
def can_log_group_changes?(group)
(is_admin? || group.users.where('group_users.owner').include?(user))
end
def can_see_group_messages?(group)
2018-02-12 14:26:22 +08:00
SiteSetting.enable_personal_messages? && (
is_admin? || group.users.include?(user)
)
end
end