diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 9b0e948..f4cd4f1 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -119,7 +119,7 @@ class ContentViewerController < ApplicationController def add_comment @comment.author = user if logged_in? @comment.article = @page - if (logged_in? || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save + if (pass_without_comment_captcha? || verify_recaptcha(:model => @comment, :message => _('Please type the words correctly'))) && @comment.save @page.touch @comment = nil # clear the comment form redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] @@ -128,6 +128,11 @@ class ContentViewerController < ApplicationController end end + def pass_without_comment_captcha? + logged_in? && !environment.enabled?('captcha_for_logged_users') + end + helper_method :pass_without_comment_captcha? + def remove_comment @comment = @page.comments.find(params[:remove_comment]) if (user == @comment.author || user == @page.profile || user.has_permission?(:moderate_comments, @page.profile)) diff --git a/app/models/environment.rb b/app/models/environment.rb index 0896682..a7a30d0 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -120,7 +120,8 @@ class Environment < ActiveRecord::Base 'enterprises_are_validated_when_created' => __('Enterprises are validated when created'), 'show_balloon_with_profile_links_when_clicked' => _('Show a balloon with profile links when a profile image is clicked'), 'xmpp_chat' => _('XMPP/Jabber based chat'), - 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images') + 'show_zoom_button_on_article_images' => _('Show a zoom link on all article images'), + 'captcha_for_logged_users' => _('Ask captcha to comment for logged users too'), } end diff --git a/app/views/content_viewer/_comment_form.rhtml b/app/views/content_viewer/_comment_form.rhtml index e6a842d..8ca838c 100644 --- a/app/views/content_viewer/_comment_form.rhtml +++ b/app/views/content_viewer/_comment_form.rhtml @@ -1,6 +1,6 @@