Class: Gluttonberg::Admin::Content::CommentsController

Inherits:
BaseController
  • Object
show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
app/controllers/gluttonberg/admin/content/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#approvedObject



55
56
57
58
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 55

def approved
  @comments = Comment.all_approved.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
  render :template => "/gluttonberg/admin/content/comments/index"
end

#block_comment_authorObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 75

def block_comment_author
  @comment = Comment.find(params[:id])

  author_string = ""
  unless @comment.author_name.blank? || @comment.author_name == "NULL" || @comment.author_name.length < 3
    author_string += @comment.author_name
  end
  unless @comment.author_email.blank? || @comment.author_email == "NULL" || @comment.author_email.length < 3
    author_string += ", " unless author_string.blank?
    author_string += @comment.author_email
  end
  unless @comment.author_website.blank? || @comment.author_website == "NULL" || @comment.author_website.length < 3
    author_string += ", " unless author_string.blank?
    author_string += @comment.author_website
  end
  unless author_string.blank?
    author_string
    gb_blacklist_settings = Gluttonberg::Setting.get_setting("comment_blacklist")
    if gb_blacklist_settings.blank?
      gb_blacklist_settings = author_string
    else
      gb_blacklist_settings = gb_blacklist_settings + ", " + author_string
    end
    Gluttonberg::Setting.update_settings("comment_blacklist" => gb_blacklist_settings)
    Comment.spam_detection_for_all
  end
  redirect_to admin_pending_comments_path
end

#deleteObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 19

def delete
  @comment = Comment.find(params[:id])
  display_delete_confirmation(
    :title      => "Delete Comment ?",
    :url        => admin_comment_destroy_path(@comment),
    :return_url => :back,
    :warning    => ""
  )
end

#destroyObject



37
38
39
40
41
42
43
44
45
46
47
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 37

def destroy
  @comment = Comment.find(params[:id])
  if @comment.delete
    flash[:notice] = "The comment was successfully deleted."
    Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , "deleted")
    redirect_to admin_pending_comments_path()
  else
    flash[:error] = "There was an error deleting the comment."
    redirect_to admin_pending_comments_path()
  end
end

#indexObject



14
15
16
17
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 14

def index
  find_article([:comments])
  @comments = @article.comments.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
end

#moderationObject



29
30
31
32
33
34
35
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 29

def moderation
  authorize_user_for_moderation
  @comment = Comment.find(params[:id])
  @comment.moderate(params[:moderation])
  Gluttonberg::Feed.log(current_user,@comment, truncate(@comment.body, :length => 100) , params[:moderation])
  redirect_to :back
end

#pendingObject



50
51
52
53
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 50

def pending
  @comments = Comment.all_pending.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
  render :template => "/gluttonberg/admin/content/comments/index"
end

#rejectedObject



60
61
62
63
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 60

def rejected
  @comments = Comment.all_rejected.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
  render :template => "/gluttonberg/admin/content/comments/index"
end

#spamObject



65
66
67
68
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 65

def spam
  @comments = Comment.all_spam.order("created_at DESC").paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page] , :order => "created_at DESC")
  render :template => "/gluttonberg/admin/content/comments/index"
end

#spam_detection_for_all_pendingObject



70
71
72
73
# File 'app/controllers/gluttonberg/admin/content/comments_controller.rb', line 70

def spam_detection_for_all_pending
  Comment.spam_detection_for_all
  redirect_to admin_pending_comments_path
end