diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index f4ac8be929..af5f392406 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -2482,12 +2482,8 @@ var ZoteroPane = new function() return; } - // FIXME: temporarily disable file attachment options for groups - var itemGroup = this.collectionsView._getItemAtRow(this.collectionsView.selection.currentIndex); - if (itemGroup.isWithinGroup()) { - var pr = Components.classes["@mozilla.org/network/default-prompt;1"] - .getService(Components.interfaces.nsIPrompt); - pr.alert("", "Files cannot currently be added to group libraries."); + if (!this.canEditFiles()) { + this.displayCannotEditLibraryFilesMessage(); return; } @@ -2597,10 +2593,8 @@ var ZoteroPane = new function() // // - if (libraryID) { - var pr = Components.classes["@mozilla.org/network/default-prompt;1"] - .getService(Components.interfaces.nsIPrompt); - pr.alert("", "Files cannot currently be added to group libraries."); + if (!this.canEditFiles(row)) { + this.displayCannotEditLibraryFilesMessage(); return; } @@ -2611,7 +2605,7 @@ var ZoteroPane = new function() var collectionID = false; } - Zotero.Attachments.importFromDocument(doc, false, false, collectionID); + Zotero.Attachments.importFromDocument(doc, false, false, collectionID, null, libraryID); return; } } @@ -2935,10 +2929,14 @@ var ZoteroPane = new function() this.displayCannotEditLibraryMessage = function () { var pr = Components.classes["@mozilla.org/network/default-prompt;1"] .getService(Components.interfaces.nsIPrompt); - pr.alert( - Zotero.getString('general.accessDenied'), - "You cannot make changes to the currently selected library." - ); + pr.alert("", "You cannot make changes to the currently selected library."); + } + + + this.displayCannotEditLibraryFilesMessage = function () { + var pr = Components.classes["@mozilla.org/network/default-prompt;1"] + .getService(Components.interfaces.nsIPrompt); + pr.alert("", "You cannot add files to the currently selected library."); } diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index f52819ccbe..4ae4d9ee83 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -475,7 +475,7 @@ Zotero.Attachments = new function(){ /* * Save a snapshot -- uses synchronous WebPageDump or asynchronous saveURI() */ - function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback) { + function importFromDocument(document, sourceItemID, forceTitle, parentCollectionIDs, callback, libraryID) { Zotero.debug('Importing attachment from document'); if (sourceItemID && parentCollectionIDs) { @@ -507,7 +507,10 @@ Zotero.Attachments = new function(){ try { // Create a new attachment var attachmentItem = new Zotero.Item('attachment'); - if (sourceItemID) { + if (libraryID) { + attachmentItem.libraryID = libraryID; + } + else if (sourceItemID) { var parentItem = Zotero.Items.get(sourceItemID); attachmentItem.libraryID = parentItem.libraryID; }