5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/gluttonberg/public/comments_controller.rb', line 5
def create
@blog = Gluttonberg::Blog.first(:conditions => {:slug => params[:blog_id]})
@article = Gluttonberg::Article.first(:conditions => {:slug => params[:article_id], :blog_id => @blog.id})
@comment = @article..new(params[:comment])
@comment.blog_slug = params[:blog_id]
@comment.author_id = current_member.id if current_member
if @comment.save
if Setting.get_setting("comment_notification") == "Yes" || @blog.moderation_required == true
User.all_super_admin_and_admins.each do |user|
Notifier.(user , @article , @comment).deliver
end
end
@subscription = CommentSubscription.find(:first , :conditions => {:article_id => @article.id , :author_email => @comment.writer_email })
if @comment. == "1" && @subscription.blank?
@subscription = CommentSubscription.create( {:article_id => @article.id , :author_email => @comment.writer_email , :author_name => @comment.writer_name } )
elsif (@comment..blank? || @comment. == "0") && !@subscription.blank?
@subscription.destroy
end
else
end
if Gluttonberg.localized?
redirect_to blog_article_path(current_localization_slug , @blog.slug, @article.slug)
else
redirect_to blog_article_path(:blog_id => @blog.slug, :id => @article.slug)
end
end
|