2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-01-08 18:35:52 -05:00
|
|
|
#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)
|
2019-04-15 21:31:51 -04:00
|
|
|
!group.automatic && can_log_group_changes?(group)
|
2016-12-11 10:36:15 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_log_group_changes?(group)
|
|
|
|
(is_admin? || group.users.where('group_users.owner').include?(user))
|
2015-12-07 17:19:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_see_group_messages?(group)
|
2018-02-12 01:26:22 -05:00
|
|
|
SiteSetting.enable_personal_messages? && (
|
2018-02-02 16:35:32 -05:00
|
|
|
is_admin? || group.users.include?(user)
|
|
|
|
)
|
2015-01-08 18:35:52 -05:00
|
|
|
end
|
|
|
|
end
|