1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#
# limitdays.rb:
#
# Copyright (C) SHIBATA Hiroshi <shibata.hiroshi@gmail.com> 2008.
# Distributed under GPL2 or any later version.
#
module TDiary::Filter
class LimitdaysFilter < Filter
def comment_filter( diary, comment )
if @conf.options.include?('spamfilter.date_limit') &&
@conf.options['spamfilter.date_limit'] &&
/\A\d+\z/ =~ @conf.options['spamfilter.date_limit'].to_s
@date_limit = @conf.options['spamfilter.date_limit'].to_s.to_i
else
@date_limit = nil
end
if @date_limit
now = Time.now
today = Time.local(now.year, now.month, now.day)
limit = today - 24 * 60 * 60 * @date_limit
if diary.date < limit
debug( "too old: #{diary.date} (limit >= #{limit})" )
comment.show = false
return false
end
end
return true
end
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
|