Fix bugs when anonymous uses member-only shortcuts

This commit is contained in:
Toks
2016-01-13 11:48:25 -05:00
parent e9d79b7ae0
commit af2167ea32
5 changed files with 22 additions and 2 deletions

View File

@@ -20,6 +20,10 @@
});
var open_favgroup_dialog = function(e) {
if (Danbooru.meta("current-user-id") == "") { // anonymous
return;
}
if ($(".add-to-favgroup").length === 1) {
// If the user only has one favorite group we don't need to ask which group to add the post to.
$(".add-to-favgroup").click();

View File

@@ -560,6 +560,11 @@ Danbooru.Note = {
start: function(e) {
e.preventDefault();
if (Danbooru.meta("current-user-id") == "") {
Danbooru.notice("You must be logged in to edit notes");
return;
}
if (Danbooru.Note.TranslationMode.active) {
return;
}

View File

@@ -189,7 +189,11 @@
if ($("#add-to-favorites").is(":visible")) {
$("#add-to-favorites").click();
} else {
Danbooru.notice("You have already favorited this post")
if (Danbooru.meta("current-user-id") == "") {
Danbooru.notice("You must be logged in to favorite posts");
} else {
Danbooru.notice("You have already favorited this post");
}
}
e.preventDefault();
});

View File

@@ -17,6 +17,10 @@
if ($("#image").length) { // post page or bookmarklet upload page
$(document).bind("keydown", "shift+e", function(e) {
if (Danbooru.meta("current-user-id") == "") { // anonymous
return;
}
if (!$("#edit-dialog").length) {
$("#edit").show();
$("#comments").hide();
@@ -33,7 +37,9 @@
if ($("#c-posts").length && $("#a-show").length) {
$(document).bind("keydown", "shift+o", function(e) {
Danbooru.Post.approve(Danbooru.meta("post-id"));
if (Danbooru.meta("current-user-can-approve-posts") === "true") {
Danbooru.Post.approve(Danbooru.meta("post-id"));
}
});
$(document).bind("keydown", "r", function(e) {

View File

@@ -7,6 +7,7 @@
<%= csrf_meta_tag %>
<meta name="current-user-name" content="<%= CurrentUser.name %>">
<meta name="current-user-id" content="<%= CurrentUser.id %>">
<meta name="current-user-can-approve-posts" content="<%= CurrentUser.can_approve_posts? %>">
<meta name="user-comment-threshold" content="<%= CurrentUser.comment_threshold %>">
<% if CurrentUser.user.blacklisted_tags.present? %>
<meta name="blacklisted-tags" content="<%= CurrentUser.user.blacklisted_tags.gsub(/(?:\r|\n)+/, ",") %>">