Archived
remove annoying permission check for comments, forums, threads, replies
This commit is contained in:
@@ -4,7 +4,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
def edit
|
def edit
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user)
|
if mod? || @comment.author.is?(current_user)
|
||||||
else
|
else
|
||||||
flash[:alert] = "You are not allowed to edit this comment"
|
flash[:alert] = "You are not allowed to edit this comment"
|
||||||
redirect_to @comment.blogpost
|
redirect_to @comment.blogpost
|
||||||
@@ -33,7 +33,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user)
|
if mod? || @comment.author.is?(current_user)
|
||||||
@comment.user_editor = current_user
|
@comment.user_editor = current_user
|
||||||
@comment.attributes = comment_params
|
@comment.attributes = comment_params
|
||||||
old_content = @comment.content_was
|
old_content = @comment.content_was
|
||||||
@@ -55,7 +55,7 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@comment = Comment.find(params[:id])
|
@comment = Comment.find(params[:id])
|
||||||
if (mod? && current_user.role >= @comment.author.role) || @comment.author.is?(current_user)
|
if mod? || @comment.author.is?(current_user)
|
||||||
if @comment.destroy
|
if @comment.destroy
|
||||||
flash[:notice] = "Comment deleted!"
|
flash[:notice] = "Comment deleted!"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ForumthreadsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
unless (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
unless mod? || @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? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
if mod? || @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? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user)
|
if mod? || @thread.author.is?(current_user)
|
||||||
if @thread.destroy
|
if @thread.destroy
|
||||||
flash[:notice] = "Thread deleted!"
|
flash[:notice] = "Thread deleted!"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ class ThreadrepliesController < ApplicationController
|
|||||||
|
|
||||||
def edit
|
def edit
|
||||||
@reply = Threadreply.find(params[:id])
|
@reply = Threadreply.find(params[:id])
|
||||||
if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user)
|
if mod? || @reply.author.is?(current_user)
|
||||||
else
|
else
|
||||||
flash[:alert] = "You are not allowed to edit this reply"
|
flash[:alert] = "You are not allowed to edit this reply"
|
||||||
redirect_to @reply.thread
|
redirect_to @reply.thread
|
||||||
@@ -32,7 +32,7 @@ class ThreadrepliesController < ApplicationController
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@reply = Threadreply.find(params[:id])
|
@reply = Threadreply.find(params[:id])
|
||||||
if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user)
|
if mod? || @reply.author.is?(current_user)
|
||||||
old_content = @reply.content_was
|
old_content = @reply.content_was
|
||||||
if @reply.update_attributes(reply_params)
|
if @reply.update_attributes(reply_params)
|
||||||
@reply.send_new_reply_mail(old_content)
|
@reply.send_new_reply_mail(old_content)
|
||||||
@@ -52,7 +52,7 @@ class ThreadrepliesController < ApplicationController
|
|||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@reply = Threadreply.find(params[:id])
|
@reply = Threadreply.find(params[:id])
|
||||||
if (mod? && current_user.role >= @reply.author.role) || @reply.author.is?(current_user)
|
if mod? || @reply.author.is?(current_user)
|
||||||
if @reply.destroy
|
if @reply.destroy
|
||||||
flash[:notice] = "Reply deleted!"
|
flash[:notice] = "Reply deleted!"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<%= ago c.created_at %>
|
<%= ago c.created_at %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if (mod? && current_user.role >= c.author.role) || c.author.is?(current_user) %>
|
<%= link_to "edit", edit_blogpost_comment_path(c.blogpost, c), class: "editlink" if mod? || c.author.is?(current_user) %>
|
||||||
<div class="clear-right"></div>
|
<div class="clear-right"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<%= link_to p do %>
|
<%= link_to p do %>
|
||||||
<%= ago @thread.created_at %>
|
<%= ago @thread.created_at %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if (mod? && current_user.role >= @thread.author.role) || @thread.author.is?(current_user) %>
|
<%= link_to "edit", edit_forumthread_path( @thread), class: "editlink" if mod? || @thread.author.is?(current_user) %>
|
||||||
<div class="clear-right"></div>
|
<div class="clear-right"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<%= ago reply.created_at %>
|
<%= ago reply.created_at %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if (mod? && current_user.role >= reply.author.role) || reply.author.is?(current_user) %>
|
<%= link_to "edit", edit_forumthread_threadreply_path(reply.thread, reply), class: "editlink" if mod? || reply.author.is?(current_user) %>
|
||||||
<div class="clear-right"></div>
|
<div class="clear-right"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="items">
|
<div class="items">
|
||||||
|
|||||||
Reference in New Issue
Block a user