diff --git a/chrome/content/zotero/bindings/zoterosearch.xml b/chrome/content/zotero/bindings/zoterosearch.xml index bb20016e86..10ec36a63e 100644 --- a/chrome/content/zotero/bindings/zoterosearch.xml +++ b/chrome/content/zotero/bindings/zoterosearch.xml @@ -367,7 +367,10 @@ switch (conditionsMenu.value){ case 'collection': var rows = []; - var cols = Zotero.getCollections(false, true); + + var libraryID = this.parent.search.libraryID; + libraryID = libraryID ? libraryID : null; + var cols = Zotero.getCollections(false, true, libraryID); for (var i in cols) { // Indent subcollections var indent = ''; @@ -384,7 +387,9 @@ case 'savedSearch': var rows = []; - var searches = Zotero.Searches.getAll(); + var libraryID = this.parent.search.libraryID; + libraryID = libraryID ? libraryID : null; + var searches = Zotero.Searches.getAll(libraryID); for (var i in searches) { if (searches[i].id != this.parent.search.id) { rows.push([searches[i].name, 'S' + Zotero.Searches.getLibraryKeyHash(searches[i])]); diff --git a/chrome/content/zotero/xpcom/data_access.js b/chrome/content/zotero/xpcom/data_access.js index f898e1e444..42684e72ab 100644 --- a/chrome/content/zotero/xpcom/data_access.js +++ b/chrome/content/zotero/xpcom/data_access.js @@ -33,7 +33,7 @@ * Takes parent collectionID as optional parameter; * by default, returns root collections */ -Zotero.getCollections = function(parent, recursive) { +Zotero.getCollections = function(parent, recursive, libraryID) { var toReturn = new Array(); if (!parent) { @@ -42,10 +42,16 @@ Zotero.getCollections = function(parent, recursive) { var sql = "SELECT collectionID AS id, collectionName AS name FROM collections C " + "WHERE parentCollectionID " + (parent ? '=' + parent : 'IS NULL'); - if (!parent) { - sql += " AND libraryID IS NULL"; + if (libraryID) { + sql += " AND libraryID=?"; + var children = Zotero.DB.query(sql, libraryID); + } + else { + if (!parent) { + sql += " AND libraryID IS NULL"; + } + var children = Zotero.DB.query(sql); } - var children = Zotero.DB.query(sql); if (!children) { Zotero.debug('No child collections of collection ' + parent, 5);