Translations: English
Search on Docs:
   
ActionItem Search:

#1790: Comments filter plugin

Type: FeatureItem Feature: ContentManagement, Infrastructure, Plugins Tags: asl, colivre
ScheduledFor: N/A Assigned to:   Sites:  
Priority: 0 Status: Pending  

Plugin to filter bad words on comments

module NoosferoCommentFilter
  def self.included(c)
    c.send(:before_filter, :noosfero_comment_filter)
  end
  def noosfero_comment_filter
    if params[:controller] == 'content_viewer' && request.post? && params[:comment] && !logged_in?
      blacklist = Article.find(59705).body.lines.map(&:strip).reject(&:blank?).map do |word|
        Regexp.new(word, Regexp::IGNORECASE)
      end
      list = [
          params[:comment][:title],
          params[:comment][:body],
          params[:comment][:name],
          params[:comment][:email],
      ].compact
      list.each do |input|
        blacklist.each do |pattern|
          if input =~ pattern
            session[:notice] = 'Oops... o seu comentário não pôde ser enviado. Qualquer dúvida, entre em contato com a comunidade "Ajuda".'
            redirect_to('/')
            return
          end
        end
      end
    end
  end
end

ActionController::Base.send(:include, NoosferoCommentFilter)

Add comment
You need to login to be able to comment.
 

ActionItemForm edit

Title Comments filter plugin
ActionItemType FeatureItem
Priority Low
Tags asl, colivre
Feature ContentManagement, Infrastructure, Plugins
ResponsibleDevelopers
ScheduledFor N/A
AffectsVersion
Status Pending
Ticket SAC:
Topic revision: r1 - 22 May 2015, UnknownUser

irc Talk with Devs Now!

Copyright © 2007-2019 by the Noosfero contributors
Colivre - Cooperativa de Tecnologias Livres