mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE - Moderators can create and manage groups (#10432)
Enabling the moderators_manage_categories_and_groups site setting will allow moderator users to create/manage groups. * show New Group form to moderators * Allow moderators to update groups and read logs, where appropriate * Rename site setting from create -> manage * improved tests * Migration should rename old log entries * Log group changes, even if those changes mean you can no longer see the group * Slight reshuffle * RouteTo /g if they no longer have permissions to view group
This commit is contained in:
@@ -7,7 +7,7 @@ module CategoryGuardian
|
||||
def can_create_category?(parent = nil)
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.moderators_create_categories &&
|
||||
SiteSetting.moderators_manage_categories_and_groups &&
|
||||
is_moderator?
|
||||
)
|
||||
end
|
||||
@@ -16,7 +16,7 @@ module CategoryGuardian
|
||||
def can_edit_category?(category)
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.moderators_create_categories &&
|
||||
SiteSetting.moderators_manage_categories_and_groups &&
|
||||
is_moderator? &&
|
||||
can_see_category?(category)
|
||||
)
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
#mixin for all guardian methods dealing with group permissions
|
||||
module GroupGuardian
|
||||
|
||||
# Creating Method
|
||||
def can_create_group?
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.moderators_manage_categories_and_groups &&
|
||||
is_moderator?
|
||||
)
|
||||
end
|
||||
|
||||
# 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.
|
||||
@@ -11,7 +20,17 @@ module GroupGuardian
|
||||
end
|
||||
|
||||
def can_log_group_changes?(group)
|
||||
(is_admin? || group.users.where('group_users.owner').include?(user))
|
||||
can_admin_group?(group) || group.users.where('group_users.owner').include?(user)
|
||||
end
|
||||
|
||||
def can_admin_group?(group)
|
||||
is_admin? ||
|
||||
(
|
||||
SiteSetting.moderators_manage_categories_and_groups &&
|
||||
is_moderator? &&
|
||||
can_see?(group) &&
|
||||
group.id != Group::AUTO_GROUPS[:admins]
|
||||
)
|
||||
end
|
||||
|
||||
def can_see_group_messages?(group)
|
||||
|
||||
@@ -9,7 +9,8 @@ module SiteSettings::DeprecatedSettings
|
||||
['disable_edit_notifications', 'disable_system_edit_notifications', true, '2.4'],
|
||||
['enable_category_group_review', 'enable_category_group_moderation', true, '2.7'],
|
||||
['newuser_max_images', 'newuser_max_embedded_media', true, '2.7'],
|
||||
['min_trust_to_post_images', 'min_trust_to_post_embedded_media', true, '2.7']
|
||||
['min_trust_to_post_images', 'min_trust_to_post_embedded_media', true, '2.7'],
|
||||
['moderators_create_categories', 'moderators_manage_categories_and_groups', '2.7']
|
||||
]
|
||||
|
||||
def setup_deprecated_methods
|
||||
|
||||
Reference in New Issue
Block a user