Sha256: 1e270ecde7c83e335f500b1fd8a00413a8cf4ce21dfcec9d5529a62dba8cfe01

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

class Topic < ActiveRecord::Base
  has_site if respond_to? :has_site
  has_comments
  
  belongs_to :forum
  belongs_to :replied_by, :class_name => 'Reader'

  validates_presence_of :name
  validates_uniqueness_of :old_id, :allow_nil => true

  named_scope :bydate, :order => 'replied_at DESC'
  named_scope :imported, :conditions => "old_id IS NOT NULL"
  named_scope :stickyfirst, :order => "topics.sticky DESC, topics.replied_at DESC"
  named_scope :latest, lambda { |count|
    { :order => 'replied_at DESC', :limit => count }
  }

  # other extensions can attach chains here to limit access
  def self.visible_to(reader)
    self.scoped
  end

  def dom_id
    "topic_#{self.id}"
  end

  def visible_to?(reader=nil)
    return true if reader || Radiant::Config['forum.public?']
  end
  
  def reader
    posts.first.reader
  end
  
  def body
    posts.first.body
  end
    
  def title
    name
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radiant-forum-extension-2.1.6 app/models/topic.rb