From 1fd71bb23796c96dd550a6ce40210a1a8f7900d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 21 Jan 2014 15:21:38 +0100 Subject: [PATCH] BUGFIX: make the system_user an elder (TL=4) Otherwise it won't be able to create topic when the `min_trust_to_create_topic` is > 0 --- db/fixtures/005_users.rb | 1 + lib/guardian/topic_guardian.rb | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/db/fixtures/005_users.rb b/db/fixtures/005_users.rb index 8122c3c1e..d71aae88d 100644 --- a/db/fixtures/005_users.rb +++ b/db/fixtures/005_users.rb @@ -22,4 +22,5 @@ User.seed do |u| u.email_direct = false u.approved = true u.email_private_messages = false + u.trust_level = TrustLevel.levels[:elder] end diff --git a/lib/guardian/topic_guardian.rb b/lib/guardian/topic_guardian.rb index 9a6cc285b..50d240de2 100644 --- a/lib/guardian/topic_guardian.rb +++ b/lib/guardian/topic_guardian.rb @@ -27,18 +27,17 @@ module TopicGuardian # Creating Methods def can_create_topic?(parent) - user && user.trust_level >= SiteSetting.min_trust_to_create_topic.to_i && can_create_post?(parent) + user && + user.trust_level >= SiteSetting.min_trust_to_create_topic.to_i && + can_create_post?(parent) end def can_create_topic_on_category?(category) - can_create_topic?(nil) && ( - !category || - Category.topic_create_allowed(self).where(:id => category.id).count == 1 - ) + can_create_topic?(nil) && + (!category || Category.topic_create_allowed(self).where(:id => category.id).count == 1) end def can_create_post_on_topic?(topic) - # No users can create posts on deleted topics return false if topic.trashed? @@ -82,4 +81,4 @@ module TopicGuardian (not(topic.private_message?) || authenticated? && (topic.all_allowed_users.where(id: @user.id).exists? || is_staff?)) end end -end \ No newline at end of file +end