diff --git a/lib/guardian/category_guardian.rb b/lib/guardian/category_guardian.rb index 0696a41e428..6cbda0746ea 100644 --- a/lib/guardian/category_guardian.rb +++ b/lib/guardian/category_guardian.rb @@ -1,17 +1,27 @@ #mixin for all guardian methods dealing with category permisions module CategoryGuardian + # Creating Method - def can_create_category?(parent) - is_admin? || (SiteSetting.allow_moderators_to_create_categories && is_moderator?) + def can_create_category?(parent=nil) + is_admin? || + ( + SiteSetting.allow_moderators_to_create_categories && + is_moderator? + ) end # Editing Method def can_edit_category?(category) - is_admin? + is_admin? || + ( + SiteSetting.allow_moderators_to_create_categories && + is_moderator? && + can_see_category?(category) + ) end def can_delete_category?(category) - is_admin? && + can_edit_category?(category) && category.topic_count == 0 && !category.uncategorized? && !category.has_children?