diff options
Diffstat (limited to 'app/controllers/forumthreads_controller.rb')
-rw-r--r-- | app/controllers/forumthreads_controller.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b1dffd9..e21c6d4 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -3,9 +3,14 @@ class ForumthreadsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index - redirect_to forum_path(@thread.forum.forumgroup, f) + if params[:label] && !Label.where("lower(name) = ?", params[:label].downcase).try(:first) && params[:label].downcase != "no label" + flash[:alert] = "'#{params[:label]}' is not a valid label." + redirect_to forumthreads_path(params.except(:label, :controller, :action)) + return + end + @threads = Forumthread.filter(current_user, params[:title], params[:content], params[:reply], params[:label], User.where("lower(ign) = ?", params[:author].to_s.downcase).try(:first), params[:query], Forum.where(id: params[:id]).try(:first)) + .page(params[:page]).per(30) end - def show if params[:reverse] @replies = @thread.replies.reverse_order.page(params[:page]) @@ -80,6 +85,20 @@ class ForumthreadsController < ApplicationController redirect_to @thread.forum end + def search + end + + def search_redirect + params.each do |key, value| + params[key] = nil if params[key] == "" + end + params[:id] = nil if params[:id] == "Search All Threads" + params[:label] = nil if params[:label] && params[:label].downcase == "label" + params[:author] = params[:author].tr("@ ", "") if params[:author] + params_list = Hash[params.except(:commit, :utf8, :authenticity_token)] + redirect_to forumthreads_path(params_list) + end + private def check_permission |