Class: SbPost

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Rakismet::Model
Defined in:
app/models/sb_post.rb

Instance Method Summary collapse

Instance Method Details

#check_spamObject


60
61
62
63
64
# File 'app/models/sb_post.rb', line 60

def check_spam
  if configatron.has_key?(:akismet_key) && self.spam?
    self.errors.add(:base, :comment_spam_error.l)
  end
end

#editable_by?(user) ⇒ Boolean

Returns:

  • (Boolean)

52
53
54
# File 'app/models/sb_post.rb', line 52

def editable_by?(user)
  user && (user.id == user_id || user.admin? || user.moderator_of?(topic.forum_id))
end

#monitor_topicObject


40
41
42
43
44
45
46
# File 'app/models/sb_post.rb', line 40

def monitor_topic
  return unless user    
  monitorship = Monitorship.where(:user_id => self.user.id, :topic_id => self.topic.id).first_or_initialize
  if monitorship.new_record?
    monitorship.update_attribute :active, true
  end
end

#notify_monitoring_usersObject


48
49
50
# File 'app/models/sb_post.rb', line 48

def notify_monitoring_users
  topic.notify_of_new_post(self)
end

#usernameObject


56
57
58
# File 'app/models/sb_post.rb', line 56

def username
  user ? user. : (author_name.blank? ? :anonymous.l : author_name)
end