aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/refinery/blog_comment.rb
diff options
context:
space:
mode:
authorPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
committerPhilip Arndt <parndt@gmail.com>2011-11-09 22:19:07 +1300
commit36c005ecd112b76d3c9c2d7092f22d6e06755d73 (patch)
tree23e37055e6c6aa79a9c5285387052acdc708ba30 /app/models/refinery/blog_comment.rb
parentd18364d359359fa6564ad187d7303f8c167154cd (diff)
downloadrefinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.gz
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.tar.bz2
refinerycms-blog-36c005ecd112b76d3c9c2d7092f22d6e06755d73.zip
Refactored everything (models, helpers) into proper namespace of Refinery::Blog. Requires refinery commit 25162b585b9c4023d39fd1a9796140bfa4ecb909
Diffstat (limited to 'app/models/refinery/blog_comment.rb')
-rw-r--r--app/models/refinery/blog_comment.rb135
1 files changed, 0 insertions, 135 deletions
diff --git a/app/models/refinery/blog_comment.rb b/app/models/refinery/blog_comment.rb
deleted file mode 100644
index f7c1c84..0000000
--- a/app/models/refinery/blog_comment.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-module Refinery
- class BlogComment < ActiveRecord::Base
-
- attr_accessible :name, :email, :message
-
- filters_spam :author_field => :name,
- :email_field => :email,
- :message_field => :body
-
- belongs_to :post, :class_name => 'Refinery::BlogPost', :foreign_key => 'blog_post_id'
-
- acts_as_indexed :fields => [:name, :email, :message]
-
- alias_attribute :message, :body
-
- validates :name, :message, :presence => true
- validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
-
- scope :unmoderated, :conditions => {:state => nil}
- scope :approved, :conditions => {:state => 'approved'}
- scope :rejected, :conditions => {:state => 'rejected'}
-
- self.per_page = Setting.find_or_set(:blog_comments_per_page, 10)
-
- def avatar_url(options = {})
- options = {:size => 60}
- require 'digest/md5'
- size = ("?s=#{options[:size]}" if options[:size])
- "http://gravatar.com/avatar/#{Digest::MD5.hexdigest(self.email.to_s.strip.downcase)}#{size}.jpg"
- end
-
- def approve!
- self.update_attribute(:state, 'approved')
- end
-
- def reject!
- self.update_attribute(:state, 'rejected')
- end
-
- def rejected?
- self.state == 'rejected'
- end
-
- def approved?
- self.state == 'approved'
- end
-
- def unmoderated?
- self.state.nil?
- end
-
- def self.toggle!
- currently = Refinery::Setting.find_or_set(:comments_allowed, true, {
- :scoping => 'blog'
- })
- Refinery::Setting.set(:comments_allowed, {:value => !currently, :scoping => 'blog'})
- end
-
- before_create do |comment|
- unless Moderation.enabled?
- comment.state = comment.ham? ? 'approved' : 'rejected'
- end
- end
-
- module Moderation
- class << self
- def enabled?
- Refinery::Setting.find_or_set(:comment_moderation, true, {
- :scoping => 'blog',
- :restricted => false
- })
- end
-
- def toggle!
- new_value = {
- :value => !BlogComment::Moderation.enabled?,
- :scoping => 'blog',
- :restricted => false
- }
- if Refinery::Setting.respond_to?(:set)
- Refinery::Setting.set(:comment_moderation, new_value)
- else
- Refinery::Setting[:comment_moderation] = new_value
- end
- end
- end
- end
-
- module Notification
- class << self
- def recipients
- Refinery::Setting.find_or_set(:comment_notification_recipients, (Refinery::Role[:refinery].users.first.email rescue ''),
- {
- :scoping => 'blog',
- :restricted => false
- })
- end
-
- def recipients=(emails)
- new_value = {
- :value => emails,
- :scoping => 'blog',
- :restricted => false
- }
- if Refinery::Setting.respond_to?(:set)
- Refinery::Setting.set(:comment_notification_recipients, new_value)
- else
- Refinery::Setting[:comment_notification_recipients] = new_value
- end
- end
-
- def subject
- Refinery::Setting.find_or_set(:comment_notification_subject, "New inquiry from your website", {
- :scoping => 'blog',
- :restricted => false
- })
- end
-
- def subject=(subject_line)
- new_value = {
- :value => subject_line,
- :scoping => 'blog',
- :restricted => false
- }
- if Refinery::Setting.respond_to?(:set)
- Refinery::Setting.set(:comment_notification_subject, new_value)
- else
- Refinery::Setting[:comment_notification_subject] = new_value
- end
- end
- end
- end
-
- end
-end \ No newline at end of file