Sha256: bc46a275c24a9dbdc064b94c50e105d8968cdd57245ee16fafe859e87a67cfaa

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

require 'commontator/shared_helper'
require 'commontator/security_transgression'

module Commontator
  module Controllers
    def self.included(base)
      base.helper Commontator::SharedHelper
    end
    
    protected

    def commontator_set_new_comment(thread, user)
      return if thread.nil? || thread.config.new_comment_style != :t
      new_comment = Comment.new
      new_comment.thread = thread
      new_comment.creator = user
      @new_comment = new_comment if new_comment.can_be_created_by?(user)
    end
    
    def commontator_thread_show(commontable)
      user = Commontator.current_user_proc.call(self)	
      thread = commontable.thread
      raise Commontator::SecurityTransgression unless thread.can_be_read_by?(user)
      thread.mark_as_read_for(user)
      @commontator_page = params[:page] || 1
      @commontator_per_page = params[:per_page] || thread.config.comments_per_page
      @commontator_thread_show = true
      commontator_set_new_comment(thread, user)
    end
  end
end

ActionController::Base.send :include, Commontator::Controllers

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
commontator-5.1.0 lib/commontator/controllers.rb
commontator-5.0.0 lib/commontator/controllers.rb
commontator-4.11.1 lib/commontator/controllers.rb
commontator-4.11.0 lib/commontator/controllers.rb