2015-01-08 17:35:52 -06: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)
|
2016-12-11 09:36:15 -06:00
|
|
|
can_log_group_changes?(group) && !group.automatic
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_log_group_changes?(group)
|
|
|
|
(is_admin? || group.users.where('group_users.owner').include?(user))
|
2015-12-07 16:19:33 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def can_see_group_messages?(group)
|
|
|
|
is_admin? || group.users.include?(user)
|
2015-01-08 17:35:52 -06:00
|
|
|
end
|
|
|
|
end
|