diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index f36124b82..7fcc0cc89 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -1513,8 +1513,13 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) { } } - if (this._inPublications && !this.isRegularItem() && !parentItemID) { - throw new Error("Top-level attachments and notes cannot be added to My Publications"); + if (this._inPublications) { + if (!this.isRegularItem() && !parentItemID) { + throw new Error("Top-level attachments and notes cannot be added to My Publications"); + } + if (this.isAttachment() && this.attachmentLinkMode == Zotero.Attachments.LINK_MODE_LINKED_FILE) { + throw new Error("Linked-file attachments cannot be added to My Publications"); + } } // Trashed status diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js index f7abd99ca..c915ac9a6 100644 --- a/test/tests/itemTest.js +++ b/test/tests/itemTest.js @@ -363,7 +363,19 @@ describe("Zotero.Item", function () { "SELECT COUNT(*) FROM publicationsItems WHERE itemID=?", item.id)), 0 ); - }) + }); + + it("should be invalid for linked-file attachments", function* () { + var item = yield createDataObject('item', { inPublications: true }); + var attachment = yield Zotero.Attachments.linkFromFile({ + file: OS.Path.join(getTestDataDirectory().path, 'test.png'), + parentItemID: item.id + }); + attachment.inPublications = true; + var e = yield getPromiseError(attachment.saveTx()); + assert.ok(e); + assert.include(e.message, "Linked-file attachments cannot be added to My Publications"); + }); }); describe("#parentID", function () {