Sha256: 305b629ee90ae76aaed3de808e1213c0a5a55d9c7c8b4424a4783d7ccfb9ce17

Contents?: true

Size: 866 Bytes

Versions: 14

Compression:

Stored size: 866 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 :imported, :conditions => "old_id IS NOT NULL"
  named_scope :stickyfirst, :order => "topics.sticky DESC, topics.replied_at DESC"
  named_scope :bydate, :order => 'replied_at DESC'
  named_scope :latest, lambda { |count|
    { :order => 'replied_at DESC', :limit => count }
  }

  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 created_at
    posts.first.created_at if posts.first
  end
  
  def title
    name
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
radiant-forum-extension-2.1.4 app/models/topic.rb
radiant-forum-extension-2.1.3 app/models/topic.rb
radiant-forum-extension-2.1.2 app/models/topic.rb
radiant-forum-extension-2.1.1 app/models/topic.rb
radiant-forum-extension-2.0.9 app/models/topic.rb
radiant-forum-extension-2.0.8 app/models/topic.rb
radiant-forum-extension-2.0.7 app/models/topic.rb
radiant-forum-extension-2.0.6 app/models/topic.rb
radiant-forum-extension-2.0.5 app/models/topic.rb
radiant-forum-extension-2.0.4 app/models/topic.rb
radiant-forum-extension-2.0.3 app/models/topic.rb
radiant-forum-extension-2.0.2 app/models/topic.rb
radiant-forum-extension-2.0.1 app/models/topic.rb
radiant-forum-extension-2.0.0 app/models/topic.rb