check mod+ rank when dealing with forum threads
This commit is contained in:
@@ -11,7 +11,7 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
unless mod? || @thread.author.is?(current_user)
|
unless (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
||||||
flash[:alert] = "You are not allowed to edit this thread!"
|
flash[:alert] = "You are not allowed to edit this thread!"
|
||||||
redirect_to @thread
|
redirect_to @thread
|
||||||
end
|
end
|
||||||
@@ -46,7 +46,7 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if mod? || @thread.author.is?(current_user)
|
if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
||||||
@thread.user_editor = current_user
|
@thread.user_editor = current_user
|
||||||
@thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params)
|
@thread.attributes = (mod? ? thread_params([:sticky, :locked, :forum_id, :label_id]) : thread_params)
|
||||||
old_content = @thread.content_was
|
old_content = @thread.content_was
|
||||||
@@ -64,7 +64,7 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if mod? || @thread.author.is?(current_user)
|
if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
||||||
if @thread.destroy
|
if @thread.destroy
|
||||||
flash[:notice] = "Thread deleted!"
|
flash[:notice] = "Thread deleted!"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user