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

This commit is contained in:
Dan Stillman 2010-04-12 15:33:14 +00:00
parent 3014263c89
commit 715584dca1
2 changed files with 17 additions and 6 deletions

View file

@ -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])]);

View file

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