www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 715584dca1417c6d7a95c69e46321b6fa2bef791
parent 3014263c89cff0e10f7cef540e5f7667144c8226
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 12 Apr 2010 15:33:14 +0000

Show only collections and saved searches from current library when creating a saved search


Diffstat:
Mchrome/content/zotero/bindings/zoterosearch.xml | 9+++++++--
Mchrome/content/zotero/xpcom/data_access.js | 14++++++++++----
2 files changed, 17 insertions(+), 6 deletions(-)

diff --git 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 @@ -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);