diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 84ccf9b..ce5f222 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -75,8 +75,14 @@ class ContentViewerController < ApplicationController @comment = Comment.new end - if request.post? && params[:remove_comment] - remove_comment + if request.post? + if params[:remove_comment] + remove_comment + return + elsif params[:mark_comment_as_spam] + mark_comment_as_spam + return + end end if @page.has_posts? @@ -107,8 +113,9 @@ class ContentViewerController < ApplicationController end end - @comments = @page.comments(true).as_thread - @comments_count = @page.comments.count + comments = @page.comments.without_spam + @comments = comments.as_thread + @comments_count = comments.count if params[:slideshow] render :action => 'slideshow', :layout => 'slideshow' end @@ -151,6 +158,15 @@ class ContentViewerController < ApplicationController redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] end + def mark_comment_as_spam + @comment = @page.comments.find(params[:mark_comment_as_spam]) + if logged_in? && (user == @page.profile || user.has_permission?(:moderate_comments, @page.profile)) + @comment.spam! + session[:notice] = _('Comment succesfully marked as SPAM') + end + redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] + end + def per_page 12 end diff --git a/app/helpers/content_viewer_helper.rb b/app/helpers/content_viewer_helper.rb index 524aa53..38b81b3 100644 --- a/app/helpers/content_viewer_helper.rb +++ b/app/helpers/content_viewer_helper.rb @@ -4,7 +4,7 @@ module ContentViewerHelper include ForumHelper def number_of_comments(article) - n = article.comments.size + n = article.comments.without_spam.count if n == 0 _('No comments yet') else diff --git a/app/models/comment.rb b/app/models/comment.rb index db383cb..de6991b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -198,4 +198,9 @@ class Comment < ActiveRecord::Base !spam.nil? && !spam end + def spam! + self.spam = true + self.save! + end + end diff --git a/app/views/content_viewer/_comment.rhtml b/app/views/content_viewer/_comment.rhtml index 1a9d895..3f1009f 100644 --- a/app/views/content_viewer/_comment.rhtml +++ b/app/views/content_viewer/_comment.rhtml @@ -29,17 +29,12 @@ <% end %> <% comment_balloon do %> - <% if logged_in? && (user == @page.profile || user == comment.author || user.has_permission?(:moderate_comments, @page.profile)) %> - <% button_bar(:style => 'float: right; margin-top: 0px;') do %> - <%= icon_button(:delete, _('Remove this comment and all its replies'), { :profile => params[:profile], :remove_comment => comment.id, :view => params[:view] }, :method => :post, :confirm => _('Are you sure you want to remove this comment and all its replies?')) %> - <% end %> - <% end %>
<%= comment.title %>
+<%= comment.title.blank? && ' ' || comment.title %>