Sha256: 871dcc99abd7d5776231ceb783645758310b25cf89bd1db8df85c8ecfd18bf77

Contents?: true

Size: 771 Bytes

Versions: 5

Compression:

Stored size: 771 Bytes

Contents

module ForumPage

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

  module InstanceMethods     
    
    def show_comments?
      commentable?
    end
    
    def still_commentable?
      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.created_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

5 entries across 5 versions & 1 rubygems

Version Path
radiant-forum-extension-2.1.6 lib/forum_page.rb
radiant-forum-extension-2.1.4 lib/forum_page.rb
radiant-forum-extension-2.1.3 lib/forum_page.rb
radiant-forum-extension-2.1.2 lib/forum_page.rb
radiant-forum-extension-2.1.1 lib/forum_page.rb