From 24507a73f6a4f7198fef1fbd5ab26545758c7896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Mon, 6 Nov 2017 12:57:01 +0200 Subject: [PATCH] Save to current collection from /connectors/savePage. Closes #1351 --- chrome/content/zotero/xpcom/server_connector.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/server_connector.js b/chrome/content/zotero/xpcom/server_connector.js index 29fea0585..8fc7daf22 100644 --- a/chrome/content/zotero/xpcom/server_connector.js +++ b/chrome/content/zotero/xpcom/server_connector.js @@ -269,6 +269,12 @@ Zotero.Server.Connector.SavePage.prototype = { * @param {Function} sendResponseCallback function to send HTTP response */ init: function(url, data, sendResponseCallback) { + var { library, collection, editable } = Zotero.Server.Connector.getSaveTarget(); + if (!library.editable) { + Zotero.logError("Can't add item to read-only library " + library.name); + return sendResponseCallback(500, "application/json", JSON.stringify({ libraryEditable: false })); + } + this.sendResponse = sendResponseCallback; Zotero.Server.Connector.Detect.prototype.init.apply(this, [url, data, sendResponseCallback]) }, @@ -318,11 +324,7 @@ Zotero.Server.Connector.SavePage.prototype = { var jsonItems = []; translate.setHandler("select", function(obj, item, callback) { return me._selectItems(obj, item, callback) }); translate.setHandler("itemDone", function(obj, item, jsonItem) { - if(collection) { - collection.addItem(item.id); - } Zotero.Server.Connector.AttachmentProgressManager.add(jsonItem.attachments); - jsonItems.push(jsonItem); }); translate.setHandler("attachmentProgress", function(obj, attachment, progress, error) { @@ -342,7 +344,7 @@ Zotero.Server.Connector.SavePage.prototype = { } else { translate.setTranslator(translators[0]); } - translate.translate(libraryID); + translate.translate({libraryID, collections: collection ? [collection.id] : false}); } }