From 8bfd7b408fdb0c993c01ee687a3d02f57126ec55 Mon Sep 17 00:00:00 2001 From: albert Date: Fri, 22 Mar 2013 10:18:05 -0700 Subject: [PATCH] remove links that are not usable by anon users, fixes #977 --- app/controllers/application_controller.rb | 2 +- app/views/artist_versions/index.html.erb | 4 +++- app/views/artists/_secondary_links.html.erb | 4 +++- app/views/comments/partials/index/_list.html.erb | 10 ++++++---- app/views/forum_posts/_forum_post.html.erb | 4 ++-- app/views/forum_topics/_secondary_links.html.erb | 10 +++++++--- app/views/forum_topics/show.html.erb | 10 ++++++---- app/views/pools/_secondary_links.html.erb | 2 +- app/views/posts/show.html.erb | 4 ++-- 9 files changed, 31 insertions(+), 19 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 688b5e79b..cb491d1d0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -85,7 +85,7 @@ protected end end - %w(member banned privileged platinum contributor janitor moderator admin).each do |level| + %w(member banned builder privileged platinum contributor janitor moderator admin).each do |level| define_method("#{level}_only") do if CurrentUser.user.__send__("is_#{level}?") true diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb index efaca2894..1df403f22 100644 --- a/app/views/artist_versions/index.html.erb +++ b/app/views/artist_versions/index.html.erb @@ -37,7 +37,9 @@ - <%= link_to "Revert", revert_artist_path(artist_version.artist_id, :version_id => artist_version.id), :method => :put, :confirm => "Are you sure you want to revert this artist?" %> + <% if CurrentUser.is_member? %> + <%= link_to "Revert", revert_artist_path(artist_version.artist_id, :version_id => artist_version.id), :method => :put, :confirm => "Are you sure you want to revert this artist?" %> + <% end %> <% end %> diff --git a/app/views/artists/_secondary_links.html.erb b/app/views/artists/_secondary_links.html.erb index 4f477f30d..6721088d7 100644 --- a/app/views/artists/_secondary_links.html.erb +++ b/app/views/artists/_secondary_links.html.erb @@ -10,7 +10,9 @@
  • |
  • <%= link_to "Posts", posts_path(:tags => @artist.name) %>
  • <%= link_to "Show", artist_path(@artist) %>
  • -
  • <%= link_to "Edit", edit_artist_path(@artist) %>
  • + <% if CurrentUser.is_member? %> +
  • <%= link_to "Edit", edit_artist_path(@artist) %>
  • + <% end %>
  • <%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %>
  • <% if CurrentUser.is_admin? %> <%= link_to "Ban", ban_artist_path(@artist), :method => :put %> diff --git a/app/views/comments/partials/index/_list.html.erb b/app/views/comments/partials/index/_list.html.erb index 0f84ca39f..ef1bf14b3 100644 --- a/app/views/comments/partials/index/_list.html.erb +++ b/app/views/comments/partials/index/_list.html.erb @@ -21,8 +21,10 @@
    -
    -

    <%= link_to "Post comment", new_comment_path, :class => "expand-comment-response" %>

    - <%= render "comments/partials/new/form", :post => post %> -
    + <% if CurrentUser.is_member? %> +
    +

    <%= link_to "Post comment", new_comment_path, :class => "expand-comment-response" %>

    + <%= render "comments/partials/new/form", :post => post %> +
    + <% end %> diff --git a/app/views/forum_posts/_forum_post.html.erb b/app/views/forum_posts/_forum_post.html.erb index 6e597192a..2bbd650f2 100644 --- a/app/views/forum_posts/_forum_post.html.erb +++ b/app/views/forum_posts/_forum_post.html.erb @@ -20,10 +20,10 @@ <% end %>
  • ID: <%= forum_post.id %>
  • - <% if @forum_topic %> + <% if CurrentUser.is_member? && @forum_topic %>
  • <%= link_to "Quote", new_forum_post_path(:post_id => forum_post.id), :method => :get, :remote => true %>
  • <% end %> - <% if CurrentUser.user.is_janitor? %> + <% if CurrentUser.is_janitor? %> <% if forum_post.is_deleted %>
  • <%= link_to "Undelete", undelete_forum_post_path(forum_post.id), :method => :post, :remote => true %>
  • <% else %> diff --git a/app/views/forum_topics/_secondary_links.html.erb b/app/views/forum_topics/_secondary_links.html.erb index 2bccebc80..e7dc908ed 100644 --- a/app/views/forum_topics/_secondary_links.html.erb +++ b/app/views/forum_topics/_secondary_links.html.erb @@ -1,11 +1,15 @@ <% content_for(:secondary_links) do %>
  • <%= link_to "Listing", forum_topics_path %>
  • -
  • <%= link_to "New", new_forum_topic_path %>
  • + + <% if CurrentUser.is_member? %> +
  • <%= link_to "New", new_forum_topic_path %>
  • +
  • <%= link_to "Mark all as read", mark_all_as_read_forum_topics_path, :method => :post %>
  • + <% end %> +
  • <%= link_to "Search", search_forum_posts_path %>
  • -
  • <%= link_to "Mark all as read", mark_all_as_read_forum_topics_path, :method => :post %>
  • <%= link_to "Help", wiki_pages_path(:title => "help:forum") %>
  • - <% if @forum_topic && !@forum_topic.new_record? %> + <% if CurrentUser.is_member? && @forum_topic && !@forum_topic.new_record? %>
  • |
  • <%= link_to "Reply", new_forum_post_path(:topic_id => @forum_topic.id) %>
  • <% if !@forum_topic.new_record? && @forum_topic.editable_by?(CurrentUser.user) %> diff --git a/app/views/forum_topics/show.html.erb b/app/views/forum_topics/show.html.erb index 72786e069..3b4321c6d 100644 --- a/app/views/forum_topics/show.html.erb +++ b/app/views/forum_topics/show.html.erb @@ -15,11 +15,13 @@ <%= render "forum_posts/listing", :forum_posts => @forum_posts %> -

    <%= link_to "Reply »".html_safe, new_forum_post_path(:topic_id => @forum_topic.id), :id => "new-response-link" %>

    + <% if CurrentUser.is_member? %> +

    <%= link_to "Reply »".html_safe, new_forum_post_path(:topic_id => @forum_topic.id), :id => "new-response-link" %>

    - + + <% end %> <%= numbered_paginator(@forum_posts) %> diff --git a/app/views/pools/_secondary_links.html.erb b/app/views/pools/_secondary_links.html.erb index 37af67780..03fd8b8c5 100644 --- a/app/views/pools/_secondary_links.html.erb +++ b/app/views/pools/_secondary_links.html.erb @@ -4,7 +4,7 @@
  • <%= link_to "Listing", pools_path %>
  • <%= link_to "Search", search_pools_path %>
  • <%= link_to "New", new_pool_path %>
  • - <% if @pool && !@pool.new_record? %> + <% if CurrentUser.is_member? && @pool && !@pool.new_record? %>
  • |
  • <%= link_to "Show", pool_path(@pool) %>
  • <%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %>
  • diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index ca63942fe..bdd9a0446 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -51,7 +51,7 @@
  • Comments
  • - <% if Danbooru.config.can_user_see_post?(CurrentUser.user, @post) %> + <% if CurrentUser.is_member? && Danbooru.config.can_user_see_post?(CurrentUser.user, @post) %>
  • Edit
  • <% end %>
  • Share
  • @@ -65,7 +65,7 @@ <%= render :partial => "notes/note", :collection => @post.notes.active %> - <% if Danbooru.config.can_user_see_post?(CurrentUser.user, @post) %> + <% if CurrentUser.is_member? && Danbooru.config.can_user_see_post?(CurrentUser.user, @post) %>