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



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

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

#editable_by?(user) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#monitor_topicObject



35
36
37
38
39
40
41
# File 'app/models/sb_post.rb', line 35

def monitor_topic
  return unless user    
  monitorship = Monitorship.find_or_initialize_by_user_id_and_topic_id(self.user.id, self.topic.id)
  if monitorship.new_record?
    monitorship.update_attribute :active, true
  end
end

#notify_monitoring_usersObject



43
44
45
# File 'app/models/sb_post.rb', line 43

def notify_monitoring_users
  topic.notify_of_new_post(self)
end

#usernameObject



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

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