Class: SbPost
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SbPost
- Includes:
- Rakismet::Model
- Defined in:
- app/models/sb_post.rb
Instance Method Summary collapse
- #check_spam ⇒ Object
- #dom_id ⇒ Object
- #editable_by?(user) ⇒ Boolean
- #monitor_topic ⇒ Object
- #notify_monitoring_users ⇒ Object
- #username ⇒ Object
Instance Method Details
#check_spam ⇒ Object
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 |
#dom_id ⇒ Object
66 67 68 |
# File 'app/models/sb_post.rb', line 66 def dom_id ['sb_posts', id].join('-') end |
#editable_by?(user) ⇒ 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_topic ⇒ Object
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_users ⇒ Object
48 49 50 |
# File 'app/models/sb_post.rb', line 48 def notify_monitoring_users topic.notify_of_new_post(self) end |
#username ⇒ Object
56 57 58 |
# File 'app/models/sb_post.rb', line 56 def username user ? user.login : (.blank? ? :anonymous.l : ) end |