Sha256: 2d36360ae8fcca56acdae61a48d79245d2a5a4bee9ed3c6d9ef80b902bdc842e

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

module ForumPage

  def self.included(base)
    base.class_eval {
      has_comments
      include InstanceMethods
    }
  end

  module InstanceMethods     
    
    def show_comments?
      !virtual? && !self.is_a?(RailsPage) && commentable?
    end
    
    # commentable? is a boolean model column
    def still_commentable?
      return false if virtual? or self.is_a? RailsPage
      return false unless Radiant::Config['forum.allow_page_comments?'] && commentable?
      return false if comments_closed?
      return true unless commentable_period && commentable_period > 0
      return Time.now - self.published_at < commentable_period
    end
    
    def locked?
      !still_commentable?
    end

  private
  
    def commentable_period
      Radiant::Config['forum.commentable_period'].to_i.days if Radiant::Config['forum.commentable_period']
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-forum-extension-3.0.0.rc4 lib/forum_page.rb
radiant-forum-extension-3.0.0.rc3 lib/forum_page.rb