Translations: English
Search on Docs:
   
ActionItem Search:

#1873: Filter comments plugin

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

It is interesting to have a Noosfero plugin where admins can define keywords to be filtered in comments.

This was partially developed as a Rails plugin, code below:

noosfero@aragorn:~/current$ cat vendor/plugins/noosfero_comment_filter/init.rb 
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)

-- JoenioCosta - 16 Feb 2011
Add comment
You need to login to be able to comment.
 

ActionItemForm edit

Title Filter comments plugin
ActionItemType FeatureItem
Priority Low
Tags colivre, dilmanarede
Feature ContentManagement, Plugins
ResponsibleDevelopers Nobody
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