commit 24507a73f6a4f7198fef1fbd5ab26545758c7896
parent 80128299922cc1b2140dba6d85309764a49e1964
Author: Adomas VenĨkauskas <adomas.ven@gmail.com>
Date: Mon, 6 Nov 2017 12:57:01 +0200
Save to current collection from /connectors/savePage.
Closes #1351
Diffstat:
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
@@ -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});
}
}