Change user library from 0 to 1
0 allowed for some accidental behavior due to old code expecting NULL, and it prevented easy checks (``if (!libraryID)``) for a passed libraryID. Code now uses Zotero.Libraries.userLibraryID instead of a hard-coded value (except in schema.js). Functions can still make libraryID optional, but they should then use Zotero.Libraries.userLibraryID if that's to mean the user library. There might be some code that still expects 0 that I missed.
This commit is contained in:
parent
9d353b4e25
commit
1c8abf3841
29 changed files with 134 additions and 152 deletions
|
@ -99,11 +99,12 @@
|
|||
});
|
||||
}
|
||||
var collation = Zotero.getLocaleCollation();
|
||||
let userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
libraryNames.sort(function (a, b) {
|
||||
if (a.libraryID == 0) {
|
||||
if (a.libraryID == userLibraryID) {
|
||||
return -1;
|
||||
}
|
||||
if (b.libraryID == 0) {
|
||||
if (b.libraryID == userLibraryID) {
|
||||
return 1;
|
||||
}
|
||||
return collation.compareString(1, a.name, b.name);
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
// Add My Library
|
||||
var menuitem = document.createElement('menuitem');
|
||||
menuitem.setAttribute('label', Zotero.getString('pane.collections.library'));
|
||||
menuitem.setAttribute('libraryID', 0);
|
||||
menuitem.setAttribute('libraryID', Zotero.Libraries.userLibraryID);
|
||||
menupopup.appendChild(menuitem);
|
||||
|
||||
// Add groups
|
||||
|
|
|
@ -375,7 +375,7 @@ var Zotero_QuickFormat = new function () {
|
|||
var citedItem = citedItems[i];
|
||||
// Tabulate number of items in document for each library
|
||||
if(!citedItem.cslItemID) {
|
||||
var libraryID = citedItem.libraryID ? citedItem.libraryID : 0;
|
||||
var libraryID = citedItem.libraryID;
|
||||
if(libraryID in nCitedItemsFromLibrary) {
|
||||
nCitedItemsFromLibrary[libraryID]++;
|
||||
} else {
|
||||
|
@ -399,7 +399,7 @@ var Zotero_QuickFormat = new function () {
|
|||
for each(var citationItem in io.citation.citationItems) {
|
||||
var citedItem = Zotero.Cite.getItem(citationItem.id);
|
||||
if(!citedItem.cslItemID) {
|
||||
var libraryID = citedItem.libraryID ? citedItem.libraryID : 0;
|
||||
var libraryID = citedItem.libraryID;
|
||||
if(libraryID in nCitedItemsFromLibrary) {
|
||||
nCitedItemsFromLibrary[libraryID]++;
|
||||
} else {
|
||||
|
@ -412,7 +412,7 @@ var Zotero_QuickFormat = new function () {
|
|||
var items = Zotero.Items.get(searchResultIDs);
|
||||
|
||||
items.sort(function _itemSort(a, b) {
|
||||
var libA = a.libraryID ? a.libraryID : 0, libB = b.libraryID ? b.libraryID : 0;
|
||||
var libA = a.libraryID, libB = b.libraryID;
|
||||
if(libA !== libB) {
|
||||
// Sort by number of cites for library
|
||||
if(nCitedItemsFromLibrary[libA] && !nCitedItemsFromLibrary[libB]) {
|
||||
|
|
|
@ -157,12 +157,13 @@ Zotero.API.Data = {
|
|||
* Parse a relative URI path and return parameters for the request
|
||||
*/
|
||||
parsePath: function (path) {
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
var params = {};
|
||||
var router = new Zotero.Router(params);
|
||||
|
||||
// Top-level objects
|
||||
router.add('library/:controller/top', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.subset = 'top';
|
||||
});
|
||||
router.add('groups/:groupID/:controller/top', function () {
|
||||
|
@ -170,7 +171,7 @@ Zotero.API.Data = {
|
|||
});
|
||||
|
||||
router.add('library/:scopeObject/:scopeObjectKey/items/:objectKey/:subset', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.controller = 'items';
|
||||
});
|
||||
router.add('groups/:groupID/:scopeObject/:scopeObjectKey/items/:objectKey/:subset', function () {
|
||||
|
@ -179,7 +180,7 @@ Zotero.API.Data = {
|
|||
|
||||
// All objects
|
||||
router.add('library/:controller', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
router.add('groups/:groupID/:controller', function () {});
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ Zotero.CollectionTreeView.prototype.refresh = Zotero.Promise.coroutine(function*
|
|||
|
||||
var self = this;
|
||||
var library = {
|
||||
libraryID: 0
|
||||
libraryID: Zotero.Libraries.userLibraryID
|
||||
};
|
||||
|
||||
// treeRow, level, beforeRow, startOpen
|
||||
|
@ -948,11 +948,6 @@ Zotero.CollectionTreeView.prototype._expandRow = Zotero.Promise.coroutine(functi
|
|||
|
||||
// Add collections
|
||||
for (var i = 0, len = collections.length; i < len; i++) {
|
||||
// In personal library root, skip group collections
|
||||
if (!isGroup && !isCollection && collections[i].libraryID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var newRow = this._addRow(
|
||||
rows,
|
||||
new Zotero.CollectionTreeRow('collection', collections[i]),
|
||||
|
@ -1758,10 +1753,8 @@ Zotero.CollectionTreeView.prototype.drop = Zotero.Promise.coroutine(function* (r
|
|||
}
|
||||
|
||||
if (toReconcile.length) {
|
||||
var sourceName = items[0].libraryID ? Zotero.Libraries.getName(items[0].libraryID)
|
||||
: Zotero.getString('pane.collections.library');
|
||||
var targetName = targetLibraryID ? Zotero.Libraries.getName(libraryID)
|
||||
: Zotero.getString('pane.collections.library');
|
||||
var sourceName = Zotero.Libraries.getName(items[0].libraryID);
|
||||
var targetName = Zotero.Libraries.getName(targetLibraryID);
|
||||
|
||||
var io = {
|
||||
dataIn: {
|
||||
|
|
|
@ -287,7 +287,7 @@ Zotero.Collection.prototype._saveData = Zotero.Promise.coroutine(function* (env)
|
|||
var isNew = env.isNew;
|
||||
|
||||
var collectionID = env.id = this._id = this.id ? this.id : yield Zotero.ID.get('collections');
|
||||
var libraryID = env.libraryID = this.libraryID;
|
||||
var libraryID = env.libraryID = this.libraryID || Zotero.Libraries.userLibraryID;
|
||||
var key = env.key = this._key = this.key ? this.key : this._generateKey();
|
||||
|
||||
Zotero.debug("Saving collection " + this.id);
|
||||
|
@ -307,7 +307,7 @@ Zotero.Collection.prototype._saveData = Zotero.Promise.coroutine(function* (env)
|
|||
{ string: this.name },
|
||||
env.parent ? env.parent : null,
|
||||
Zotero.DB.transactionDateTime,
|
||||
this.libraryID ? this.libraryID : 0,
|
||||
this.libraryID,
|
||||
key,
|
||||
this.version ? this.version : 0,
|
||||
this.synced ? 1 : 0
|
||||
|
@ -829,7 +829,10 @@ Zotero.Collection.prototype.addLinkedCollection = Zotero.Promise.coroutine(funct
|
|||
|
||||
// If both group libraries, store relation with source group.
|
||||
// Otherwise, store with personal library.
|
||||
var libraryID = (this.libraryID && collection.libraryID) ? this.libraryID : 0;
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
var libraryID = (this.libraryID != userLibraryID && collection.libraryID != userLibraryID)
|
||||
? this.libraryID
|
||||
: Zotero.Libraries.userLibraryID;
|
||||
|
||||
yield Zotero.Relations.add(libraryID, url1, predicate, url2);
|
||||
});
|
||||
|
|
|
@ -86,10 +86,8 @@ Zotero.Collections = function() {
|
|||
let parent = yield this.getAsync(parentID);
|
||||
yield parent.loadChildCollections();
|
||||
children = parent.getChildCollections();
|
||||
if (!children.length) Zotero.debug('No child collections in collection ' + parentID, 5);
|
||||
} else if (libraryID || libraryID === 0) {
|
||||
children = this.getCollectionsInLibrary(libraryID);
|
||||
if (!children.length) Zotero.debug('No child collections in library ' + libraryID, 5);
|
||||
} else if (libraryID) {
|
||||
children = yield this.getCollectionsInLibrary(libraryID);
|
||||
} else {
|
||||
throw new Error("Either library ID or parent collection ID must be provided to getNumCollectionsByParent");
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ Zotero.DataObject.prototype.setRelations = function (newRelations) {
|
|||
|
||||
/**
|
||||
* Return an object in the specified library equivalent to this object
|
||||
* @param {Integer} [libraryID=0]
|
||||
* @param {Integer} [libraryID]
|
||||
* @return {Object|false} Linked item, or false if not found
|
||||
*/
|
||||
Zotero.DataObject.prototype._getLinkedObject = Zotero.Promise.coroutine(function* (libraryID) {
|
||||
|
|
|
@ -26,21 +26,19 @@
|
|||
|
||||
Zotero.DataObjectUtilities = {
|
||||
"checkLibraryID": function (libraryID) {
|
||||
if (libraryID === null) {
|
||||
Zotero.debug("Deprecated: libraryID cannot be NULL", 2, 1);
|
||||
if (!libraryID) {
|
||||
throw new Error("libraryID not provided");
|
||||
}
|
||||
else {
|
||||
var intValue = parseInt(libraryID);
|
||||
if (libraryID != intValue || intValue < 0) {
|
||||
throw new Error("libraryID must be a positive integer");
|
||||
}
|
||||
var intValue = parseInt(libraryID);
|
||||
if (libraryID != intValue || intValue <= 0) {
|
||||
throw new Error("libraryID must be a positive integer");
|
||||
}
|
||||
return intValue;
|
||||
},
|
||||
|
||||
"checkDataID": function(dataID) {
|
||||
var intValue = parseInt(dataID);
|
||||
if (dataID != intValue || dataID < 0)
|
||||
if (dataID != intValue || dataID <= 0)
|
||||
throw new Error("id must be a positive integer");
|
||||
return intValue;
|
||||
},
|
||||
|
|
|
@ -278,8 +278,8 @@ Zotero.DataObjects.prototype.getLibraryAndKeyFromID = function (id) {
|
|||
|
||||
|
||||
Zotero.DataObjects.prototype.getIDFromLibraryAndKey = function (libraryID, key) {
|
||||
if (libraryID === null) {
|
||||
throw new Error("libraryID cannot be NULL (did you mean 0?)");
|
||||
if (!libraryID) {
|
||||
throw new Error("libraryID not provided");
|
||||
}
|
||||
return (this._objectIDs[libraryID] && this._objectIDs[libraryID][key])
|
||||
? this._objectIDs[libraryID][key] : false;
|
||||
|
|
|
@ -349,7 +349,7 @@ Zotero.Group.prototype.erase = Zotero.Promise.coroutine(function* () {
|
|||
|
||||
// Delete settings
|
||||
sql = "DELETE FROM syncedSettings WHERE libraryID=?";
|
||||
yield Zotero.DB.queryAsync(sql, this.libraryID ? parseInt(this.libraryID) : 0);
|
||||
yield Zotero.DB.queryAsync(sql, this.libraryID);
|
||||
|
||||
// Delete group
|
||||
sql = "DELETE FROM groups WHERE groupID=?";
|
||||
|
|
|
@ -1155,8 +1155,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
//
|
||||
// If available id value, use it -- otherwise we'll use autoincrement
|
||||
var itemID = env.id = this._id = this.id ? this.id : yield Zotero.ID.get('items');
|
||||
Zotero.debug('=');
|
||||
var libraryID = env.libraryID = this.libraryID;
|
||||
var libraryID = env.libraryID = this.libraryID || Zotero.Libraries.userLibraryID;
|
||||
var key = env.key = this._key = this.key ? this.key : this._generateKey();
|
||||
|
||||
sqlColumns.push(
|
||||
|
@ -1171,7 +1170,7 @@ Zotero.Item.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
sqlValues.push(
|
||||
{ int: itemTypeID },
|
||||
this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime,
|
||||
this.libraryID ? this.libraryID : 0,
|
||||
this.libraryID,
|
||||
key,
|
||||
this.version ? this.version : 0,
|
||||
this.synced ? 1 : 0
|
||||
|
@ -3444,7 +3443,10 @@ Zotero.Item.prototype.addLinkedItem = Zotero.Promise.coroutine(function* (item)
|
|||
// If one of the items is a personal library, store relation with that.
|
||||
// Otherwise, use current item's library (which in calling code is the
|
||||
// new, copied item).
|
||||
var libraryID = (!this.libraryID || !item.libraryID) ? 0 : this.libraryID;
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
var libraryID = (this.libraryID == userLibraryID || item.libraryID == userLibraryID)
|
||||
? userLibraryID
|
||||
: this.libraryID;
|
||||
|
||||
yield Zotero.Relations.add(libraryID, url1, predicate, url2);
|
||||
});
|
||||
|
|
|
@ -76,10 +76,6 @@ Zotero.Libraries = new function () {
|
|||
return row;
|
||||
});
|
||||
|
||||
this.dbLibraryID = function (libraryID) {
|
||||
return (libraryID == Zotero.Users.getCurrentLibraryID()) ? 0 : libraryID;
|
||||
}
|
||||
|
||||
|
||||
this.getName = function (libraryID) {
|
||||
var type = this.getType(libraryID);
|
||||
|
@ -98,9 +94,6 @@ Zotero.Libraries = new function () {
|
|||
|
||||
|
||||
this.getType = function (libraryID) {
|
||||
if (libraryID === Zotero.Libraries.userLibraryID) {
|
||||
return 'user';
|
||||
}
|
||||
if (!this.exists(libraryID)) {
|
||||
throw new Error("Library data not loaded for library " + libraryID);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ Zotero.Relation.prototype._set = function (field, val) {
|
|||
case 'id':
|
||||
case 'libraryID':
|
||||
if (field == 'libraryID' && !val) {
|
||||
throw ("libraryID cannot be empty in Zotero.Relation._set()");
|
||||
throw new Error("libraryID cannot be empty in Zotero.Relation._set()");
|
||||
}
|
||||
|
||||
if (val == this['_' + field]) {
|
||||
|
|
|
@ -141,15 +141,7 @@ Zotero.Relations = function () {
|
|||
predicate = this._getPrefixAndValue(predicate).join(':');
|
||||
|
||||
var relation = new Zotero.Relation;
|
||||
if (!libraryID) {
|
||||
libraryID = Zotero.Users.getCurrentLibraryID();
|
||||
}
|
||||
if (libraryID) {
|
||||
relation.libraryID = parseInt(libraryID);
|
||||
}
|
||||
else {
|
||||
relation.libraryID = "local/" + Zotero.Users.getLocalUserKey();
|
||||
}
|
||||
relation.libraryID = parseInt(libraryID);
|
||||
relation.subject = subject;
|
||||
relation.predicate = predicate;
|
||||
relation.object = object;
|
||||
|
|
|
@ -42,7 +42,7 @@ Zotero.getCollections = function(parent, recursive, libraryID) {
|
|||
|
||||
var sql = "SELECT collectionID AS id, collectionName AS name FROM collections C "
|
||||
+ "WHERE libraryID=? AND parentCollectionID " + (parent ? '=' + parent : 'IS NULL');
|
||||
var children = Zotero.DB.query(sql, [libraryID ? libraryID : 0]);
|
||||
var children = Zotero.DB.query(sql, [libraryID ? libraryID : Zotero.Libraries.userLibraryID]);
|
||||
|
||||
if (!children) {
|
||||
Zotero.debug('No child collections of collection ' + parent, 5);
|
||||
|
|
|
@ -29,7 +29,7 @@ Zotero.Duplicates = function (libraryID) {
|
|||
}
|
||||
|
||||
if (!libraryID) {
|
||||
libraryID = 0;
|
||||
libraryID = Zotero.Libraries.userLibraryID;
|
||||
}
|
||||
|
||||
this._libraryID = libraryID;
|
||||
|
|
|
@ -672,7 +672,6 @@ Zotero.Fulltext = new function(){
|
|||
let itemID = itemIDs[i];
|
||||
let item = yield Zotero.Items.getAsync(itemID);
|
||||
let libraryID = item.libraryID
|
||||
libraryID = libraryID ? libraryID : Zotero.Users.getCurrentLibraryID();
|
||||
if (!undownloaded[libraryID]) {
|
||||
undownloaded[libraryID] = [];
|
||||
}
|
||||
|
|
|
@ -1104,6 +1104,8 @@ Zotero.Schema = new function(){
|
|||
|
||||
|
||||
this.integrityCheck = Zotero.Promise.coroutine(function* (fix) {
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
// Just as a sanity check, make sure combined field tables are populated,
|
||||
// so that we don't try to wipe out all data
|
||||
if (!(yield Zotero.DB.valueQueryAsync("SELECT COUNT(*) FROM fieldsCombined"))
|
||||
|
@ -1233,9 +1235,15 @@ Zotero.Schema = new function(){
|
|||
|
||||
// Wrong library tags
|
||||
[
|
||||
"SELECT COUNT(*) FROM tags NATURAL JOIN itemTags JOIN items USING (itemID) WHERE IFNULL(tags.libraryID, 0)!=IFNULL(items.libraryID,0)",
|
||||
"SELECT COUNT(*) FROM tags NATURAL JOIN itemTags JOIN items USING (itemID) WHERE "
|
||||
+ "IFNULL(tags.libraryID, " + userLibraryID + ") != IFNULL(items.libraryID, " + userLibraryID + ")",
|
||||
[
|
||||
"CREATE TEMPORARY TABLE tmpWrongLibraryTags AS SELECT itemTags.ROWID AS tagRowID, tagID, name, itemID, IFNULL(tags.libraryID,0) AS tagLibraryID, IFNULL(items.libraryID,0) AS itemLibraryID FROM tags NATURAL JOIN itemTags JOIN items USING (itemID) WHERE IFNULL(tags.libraryID, 0)!=IFNULL(items.libraryID,0)",
|
||||
"CREATE TEMPORARY TABLE tmpWrongLibraryTags AS "
|
||||
+ "SELECT itemTags.ROWID AS tagRowID, tagID, name, itemID, "
|
||||
+ "IFNULL(tags.libraryID, " + userLibraryID + ") AS tagLibraryID, "
|
||||
+ "IFNULL(items.libraryID, " + userLibraryID + ") AS itemLibraryID "
|
||||
+ "FROM tags NATURAL JOIN itemTags JOIN items USING (itemID) "
|
||||
+ "WHERE IFNULL(tags.libraryID, " + userLibraryID + ") != IFNULL(items.libraryID, " + userLibraryID + ")",
|
||||
"DELETE FROM itemTags WHERE ROWID IN (SELECT tagRowID FROM tmpWrongLibraryTags)",
|
||||
"DROP TABLE tmpWrongLibraryTags"
|
||||
]
|
||||
|
@ -1255,8 +1263,8 @@ Zotero.Schema = new function(){
|
|||
// migration step to delete 'libraries' rows not in 'groups'
|
||||
//"SELECT COUNT(*) FROM syncDeleteLog WHERE libraryID != 0 AND libraryID NOT IN (SELECT libraryID FROM libraries)"
|
||||
[
|
||||
"SELECT COUNT(*) FROM syncDeleteLog WHERE libraryID != 0 AND libraryID NOT IN (SELECT libraryID FROM groups)",
|
||||
"DELETE FROM syncDeleteLog WHERE libraryID != 0 AND libraryID NOT IN (SELECT libraryID FROM libraries)",
|
||||
"SELECT COUNT(*) FROM syncDeleteLog WHERE libraryID != " + userLibraryID + " AND libraryID NOT IN (SELECT libraryID FROM groups)",
|
||||
"DELETE FROM syncDeleteLog WHERE libraryID != " + userLibraryID + " AND libraryID NOT IN (SELECT libraryID FROM libraries)",
|
||||
],
|
||||
|
||||
|
||||
|
@ -1280,8 +1288,8 @@ Zotero.Schema = new function(){
|
|||
"DELETE FROM fulltextItems WHERE itemID NOT IN (SELECT itemID FROM items WHERE itemTypeID=14)"
|
||||
],
|
||||
[
|
||||
"SELECT COUNT(*) FROM syncedSettings WHERE libraryID != 0 AND libraryID NOT IN (SELECT libraryID FROM libraries)",
|
||||
"DELETE FROM syncedSettings WHERE libraryID != 0 AND libraryID NOT IN (SELECT libraryID FROM libraries)"
|
||||
"SELECT COUNT(*) FROM syncedSettings WHERE libraryID != " + userLibraryID + " AND libraryID NOT IN (SELECT libraryID FROM libraries)",
|
||||
"DELETE FROM syncedSettings WHERE libraryID != " + userLibraryID + " AND libraryID NOT IN (SELECT libraryID FROM libraries)"
|
||||
]
|
||||
];
|
||||
|
||||
|
@ -1382,6 +1390,8 @@ Zotero.Schema = new function(){
|
|||
*/
|
||||
function _initializeSchema(){
|
||||
return Zotero.DB.executeTransaction(function* (conn) {
|
||||
var userLibraryID = 1;
|
||||
|
||||
// Enable auto-vacuuming
|
||||
yield Zotero.DB.queryAsync("PRAGMA page_size = 4096");
|
||||
yield Zotero.DB.queryAsync("PRAGMA encoding = 'UTF-8'");
|
||||
|
@ -1409,12 +1419,12 @@ Zotero.Schema = new function(){
|
|||
});
|
||||
yield _updateDBVersion('compatibility', _maxCompatibility);
|
||||
|
||||
yield Zotero.DB.queryAsync("INSERT INTO libraries (libraryID, libraryType) VALUES (0, 'user')");
|
||||
yield Zotero.DB.queryAsync("INSERT INTO libraries (libraryID, libraryType) VALUES (?, 'user')", userLibraryID);
|
||||
|
||||
if (!Zotero.Schema.skipDefaultData) {
|
||||
// Quick Start Guide web page item
|
||||
var sql = "INSERT INTO items VALUES(1, 13, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'ABCD2345', 0, 0)";
|
||||
yield Zotero.DB.queryAsync(sql);
|
||||
var sql = "INSERT INTO items VALUES(1, 13, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, 'ABCD2345', 0, 0)";
|
||||
yield Zotero.DB.queryAsync(sql, userLibraryID);
|
||||
var sql = "INSERT INTO itemDataValues VALUES (1, ?)";
|
||||
yield Zotero.DB.queryAsync(sql, Zotero.getString('install.quickStartGuide'));
|
||||
var sql = "INSERT INTO itemData VALUES (1, 110, 1)";
|
||||
|
@ -1431,8 +1441,8 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.queryAsync(sql);
|
||||
|
||||
// Welcome note
|
||||
var sql = "INSERT INTO items VALUES(2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 0, 'ABCD3456', 0, 0)";
|
||||
yield Zotero.DB.queryAsync(sql);
|
||||
var sql = "INSERT INTO items VALUES(2, 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?, 'ABCD3456', 0, 0)";
|
||||
yield Zotero.DB.queryAsync(sql, userLibraryID);
|
||||
var welcomeTitle = Zotero.getString('install.quickStartGuide.message.welcome');
|
||||
var welcomeMsg = '<div class="zotero-note znv1"><p><strong>' + welcomeTitle + '</strong></p>'
|
||||
+ '<p>' + Zotero.getString('install.quickStartGuide.message.view') + '</p>'
|
||||
|
@ -1764,11 +1774,13 @@ Zotero.Schema = new function(){
|
|||
if (i == 80) {
|
||||
yield _updateDBVersion('compatibility', 1);
|
||||
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE IF NOT EXISTS syncedSettings (\n setting TEXT NOT NULL,\n libraryID INT NOT NULL,\n value NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n PRIMARY KEY (setting, libraryID)\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT INTO libraries VALUES (1, 'user')");
|
||||
|
||||
let oldUserLibraryID = yield Zotero.DB.valueQueryAsync("SELECT value FROM settings WHERE setting='account' AND key='libraryID'");
|
||||
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO syncObjectTypes VALUES (7, 'setting')");
|
||||
yield Zotero.DB.queryAsync("DELETE FROM version WHERE schema IN ('userdata2', 'userdata3')");
|
||||
|
||||
yield Zotero.DB.queryAsync("INSERT INTO libraries VALUES (0, 'user')");
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE libraries ADD COLUMN version INT NOT NULL DEFAULT 0");
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE libraries ADD COLUMN lastsync INT NOT NULL DEFAULT 0");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE syncCache (\n libraryID INT NOT NULL,\n key TEXT NOT NULL,\n syncObjectTypeID INT NOT NULL,\n version INT NOT NULL,\n data TEXT,\n PRIMARY KEY (libraryID, key, syncObjectTypeID),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE,\n FOREIGN KEY (syncObjectTypeID) REFERENCES syncObjectTypes(syncObjectTypeID)\n)");
|
||||
|
@ -1919,12 +1931,12 @@ Zotero.Schema = new function(){
|
|||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE collections RENAME TO collectionsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE collections (\n collectionID INTEGER PRIMARY KEY,\n collectionName TEXT NOT NULL,\n parentCollectionID INT DEFAULT NULL,\n clientDateModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n libraryID INT NOT NULL,\n key TEXT NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n UNIQUE (libraryID, key),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE,\n FOREIGN KEY (parentCollectionID) REFERENCES collections(collectionID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO collections SELECT collectionID, collectionName, parentCollectionID, clientDateModified, IFNULL(libraryID, 0), key, 0, 0 FROM collectionsOld ORDER BY collectionID DESC");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO collections SELECT collectionID, collectionName, parentCollectionID, clientDateModified, IFNULL(libraryID, 1), key, 0, 0 FROM collectionsOld ORDER BY collectionID DESC");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX collections_synced ON collections(synced)");
|
||||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE items RENAME TO itemsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE items (\n itemID INTEGER PRIMARY KEY,\n itemTypeID INT NOT NULL,\n dateAdded TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n dateModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n clientDateModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n libraryID INT NOT NULL,\n key TEXT NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n UNIQUE (libraryID, key),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO items SELECT itemID, itemTypeID, dateAdded, dateModified, clientDateModified, IFNULL(libraryID, 0), key, 0, 0 FROM itemsOld ORDER BY dateAdded DESC");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO items SELECT itemID, itemTypeID, dateAdded, dateModified, clientDateModified, IFNULL(libraryID, 1), key, 0, 0 FROM itemsOld ORDER BY dateAdded DESC");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX items_synced ON items(synced)");
|
||||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE creators RENAME TO creatorsOld");
|
||||
|
@ -1937,20 +1949,22 @@ Zotero.Schema = new function(){
|
|||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE savedSearches RENAME TO savedSearchesOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE savedSearches (\n savedSearchID INTEGER PRIMARY KEY,\n savedSearchName TEXT NOT NULL,\n clientDateModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n libraryID INT NOT NULL,\n key TEXT NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n UNIQUE (libraryID, key),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO savedSearches SELECT savedSearchID, savedSearchName, clientDateModified, IFNULL(libraryID, 0), key, 0, 0 FROM savedSearchesOld ORDER BY savedSearchID DESC");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO savedSearches SELECT savedSearchID, savedSearchName, clientDateModified, IFNULL(libraryID, 1), key, 0, 0 FROM savedSearchesOld ORDER BY savedSearchID DESC");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX savedSearches_synced ON savedSearches(synced)");
|
||||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE tags RENAME TO tagsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE tags (\n tagID INTEGER PRIMARY KEY,\n libraryID INT NOT NULL,\n name TEXT NOT NULL,\n UNIQUE (libraryID, name)\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO tags SELECT tagID, IFNULL(libraryID, 0), name FROM tagsOld");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO tags SELECT tagID, IFNULL(libraryID, 1), name FROM tagsOld");
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE itemTags RENAME TO itemTagsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE itemTags (\n itemID INT NOT NULL,\n tagID INT NOT NULL,\n type INT NOT NULL,\n PRIMARY KEY (itemID, tagID),\n FOREIGN KEY (itemID) REFERENCES items(itemID) ON DELETE CASCADE,\n FOREIGN KEY (tagID) REFERENCES tags(tagID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO itemTags SELECT itemID, T.tagID, TOld.type FROM itemTagsOld ITO JOIN tagsOld TOld USING (tagID) JOIN tags T ON (IFNULL(TOld.libraryID, 0)=T.libraryID AND TOld.name=T.name COLLATE BINARY)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO itemTags SELECT itemID, T.tagID, TOld.type FROM itemTagsOld ITO JOIN tagsOld TOld USING (tagID) JOIN tags T ON (IFNULL(TOld.libraryID, 1)=T.libraryID AND TOld.name=T.name COLLATE BINARY)");
|
||||
yield Zotero.DB.queryAsync("DROP INDEX IF EXISTS itemTags_tagID");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX itemTags_tagID ON itemTags(tagID)");
|
||||
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE IF NOT EXISTS syncedSettings (\n setting TEXT NOT NULL,\n libraryID INT NOT NULL,\n value NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n PRIMARY KEY (setting, libraryID)\n)");
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE syncedSettings RENAME TO syncedSettingsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE syncedSettings (\n setting TEXT NOT NULL,\n libraryID INT NOT NULL,\n value NOT NULL,\n version INT NOT NULL DEFAULT 0,\n synced INT NOT NULL DEFAULT 0,\n PRIMARY KEY (setting, libraryID),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("UPDATE syncedSettingsOld SET libraryID=1 WHERE libraryID=0");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO syncedSettings SELECT * FROM syncedSettingsOld");
|
||||
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE itemData RENAME TO itemDataOld");
|
||||
|
@ -1996,7 +2010,7 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.queryAsync("DROP INDEX IF EXISTS deletedItems_dateDeleted");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX deletedItems_dateDeleted ON deletedItems(dateDeleted)");
|
||||
|
||||
yield Zotero.DB.queryAsync("UPDATE relations SET libraryID=0 WHERE libraryID=(SELECT value FROM settings WHERE setting='account' AND key='libraryID')");
|
||||
yield Zotero.DB.queryAsync("UPDATE relations SET libraryID=1 WHERE libraryID=?", oldUserLibraryID);
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE relations RENAME TO relationsOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE relations (\n libraryID INT NOT NULL,\n subject TEXT NOT NULL,\n predicate TEXT NOT NULL,\n object TEXT NOT NULL,\n clientDateModified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (subject, predicate, object),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO relations SELECT * FROM relationsOld");
|
||||
|
@ -2029,7 +2043,7 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.queryAsync("CREATE INDEX fulltextItems_version ON fulltextItems(version)");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX fulltextItemWords_itemID ON fulltextItemWords(itemID)");
|
||||
|
||||
yield Zotero.DB.queryAsync("UPDATE syncDeleteLog SET libraryID=0 WHERE libraryID=(SELECT value FROM settings WHERE setting='account' AND key='libraryID')");
|
||||
yield Zotero.DB.queryAsync("UPDATE syncDeleteLog SET libraryID=1 WHERE libraryID=?", oldUserLibraryID);
|
||||
yield Zotero.DB.queryAsync("ALTER TABLE syncDeleteLog RENAME TO syncDeleteLogOld");
|
||||
yield Zotero.DB.queryAsync("CREATE TABLE syncDeleteLog (\n syncObjectTypeID INT NOT NULL,\n libraryID INT NOT NULL,\n key TEXT NOT NULL,\n synced INT NOT NULL DEFAULT 0,\n UNIQUE (syncObjectTypeID, libraryID, key),\n FOREIGN KEY (syncObjectTypeID) REFERENCES syncObjectTypes(syncObjectTypeID),\n FOREIGN KEY (libraryID) REFERENCES libraries(libraryID) ON DELETE CASCADE\n)");
|
||||
yield Zotero.DB.queryAsync("INSERT OR IGNORE INTO syncDeleteLog SELECT * FROM syncDeleteLogOld");
|
||||
|
@ -2062,6 +2076,8 @@ Zotero.Schema = new function(){
|
|||
yield Zotero.DB.queryAsync("CREATE INDEX customBaseFieldMappings_baseFieldID ON customBaseFieldMappings(baseFieldID)");
|
||||
yield Zotero.DB.queryAsync("CREATE INDEX customBaseFieldMappings_customFieldID ON customBaseFieldMappings(customFieldID)");
|
||||
|
||||
yield Zotero.DB.queryAsync("DELETE FROM settings WHERE setting='account' AND key='libraryID'");
|
||||
|
||||
yield Zotero.DB.queryAsync("DROP TABLE annotationsOld");
|
||||
yield Zotero.DB.queryAsync("DROP TABLE collectionItemsOld");
|
||||
yield Zotero.DB.queryAsync("DROP TABLE customBaseFieldMappingsOld");
|
||||
|
|
|
@ -183,7 +183,7 @@ Zotero.Search.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
var isNew = env.isNew;
|
||||
|
||||
var searchID = env.id = this._id = this.id ? this.id : yield Zotero.ID.get('savedSearches');
|
||||
var libraryID = env.libraryID = this.libraryID;
|
||||
var libraryID = env.libraryID = this.libraryID || Zotero.Libraries.userLibraryID;
|
||||
var key = env.key = this._key = this.key ? this.key : this._generateKey();
|
||||
|
||||
var columns = [
|
||||
|
@ -200,7 +200,7 @@ Zotero.Search.prototype._saveData = Zotero.Promise.coroutine(function* (env) {
|
|||
searchID ? { int: searchID } : null,
|
||||
{ string: this.name },
|
||||
Zotero.DB.transactionDateTime,
|
||||
this.libraryID ? this.libraryID : 0,
|
||||
this.libraryID,
|
||||
key,
|
||||
this.version ? this.version : 0,
|
||||
this.synced ? 1 : 0
|
||||
|
@ -1663,16 +1663,15 @@ Zotero.Searches = function() {
|
|||
/**
|
||||
* Returns an array of Zotero.Search objects, ordered by name
|
||||
*
|
||||
* @param {Integer} [libraryID=0]
|
||||
* @param {Integer} [libraryID]
|
||||
*/
|
||||
this.getAll = Zotero.Promise.coroutine(function* (libraryID) {
|
||||
var sql = "SELECT savedSearchID AS id, savedSearchName AS name "
|
||||
+ "FROM savedSearches WHERE libraryID=?";
|
||||
sql += " ORDER BY name COLLATE NOCASE";
|
||||
var rows = yield Zotero.DB.queryAsync(sql, [libraryID ? libraryID : 0]);
|
||||
if (!rows) {
|
||||
return [];
|
||||
var sql = "SELECT savedSearchID AS id, savedSearchName AS name FROM savedSearches ";
|
||||
if (libraryID) {
|
||||
sql += "WHERE libraryID=? ";
|
||||
var params = libraryID;
|
||||
}
|
||||
var rows = yield Zotero.DB.queryAsync(sql, params);
|
||||
|
||||
// Do proper collation sort
|
||||
var collation = Zotero.getLocaleCollation();
|
||||
|
|
|
@ -360,7 +360,8 @@ Zotero.Sync.Storage = new function () {
|
|||
}
|
||||
|
||||
// If WebDAV sync enabled, purge deleted and orphaned files
|
||||
if (libraryID == 0 && Zotero.Sync.Storage.WebDAV.includeUserFiles) {
|
||||
if (libraryID == Zotero.Libraries.userLibraryID
|
||||
&& Zotero.Sync.Storage.WebDAV.includeUserFiles) {
|
||||
Zotero.Sync.Storage.WebDAV.purgeDeletedStorageFiles()
|
||||
.then(function () {
|
||||
return Zotero.Sync.Storage.WebDAV.purgeOrphanedStorageFiles();
|
||||
|
@ -1259,11 +1260,14 @@ Zotero.Sync.Storage = new function () {
|
|||
|
||||
//var sql = "UPDATE itemAttachments SET syncState=?, storageModTime=NULL, storageHash=NULL";
|
||||
var sql = "UPDATE itemAttachments SET syncState=?";
|
||||
var params = [syncState];
|
||||
if (includeUserFiles && !includeGroupFiles) {
|
||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID = 0)";
|
||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID = ?)";
|
||||
params.push(Zotero.Libraries.userLibraryID);
|
||||
}
|
||||
else if (!includeUserFiles && includeGroupFiles) {
|
||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID != 0)";
|
||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID != ?)";
|
||||
params.push(Zotero.Libraries.userLibraryID);
|
||||
}
|
||||
Zotero.DB.query(sql, [syncState]);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ Zotero.Sync.Storage.QueueManager = new function () {
|
|||
var _currentQueues = [];
|
||||
|
||||
this.start = function (libraryID) {
|
||||
if (libraryID === 0 || libraryID) {
|
||||
if (libraryID) {
|
||||
var queues = this.getAll(libraryID);
|
||||
var suffix = " for library " + libraryID;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ Zotero.Sync.Storage.QueueManager = new function () {
|
|||
};
|
||||
|
||||
this.stop = function (libraryID) {
|
||||
if (libraryID === 0 || libraryID) {
|
||||
if (libraryID) {
|
||||
var queues = this.getAll(libraryID);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1073,8 +1073,8 @@ Zotero.Sync.Storage.WebDAV = (function () {
|
|||
|
||||
|
||||
obj._setLastSyncTime = function (libraryID, localLastSyncID) {
|
||||
if (libraryID) {
|
||||
throw new Error("libraryID must be 0");
|
||||
if (libraryID != Zotero.Libraries.userLibraryID) {
|
||||
throw new Error("libraryID must be user library");
|
||||
}
|
||||
|
||||
// DEBUG: is this necessary for WebDAV?
|
||||
|
|
|
@ -1065,7 +1065,7 @@ Zotero.Sync.Storage.ZFS = (function () {
|
|||
|
||||
|
||||
obj._getLastSyncURI = function (libraryID) {
|
||||
if (libraryID === 0) {
|
||||
if (libraryID === Zotero.Libraries.userLibraryID) {
|
||||
var lastSyncURI = this.userURI;
|
||||
}
|
||||
else if (libraryID) {
|
||||
|
|
|
@ -1074,7 +1074,7 @@ Zotero.Translate.Base.prototype = {
|
|||
* translators, but new code should use {@link Zotero.Translate.Base#setHandler} to register a
|
||||
* "done" handler to determine when execution of web/search translators is complete.
|
||||
*
|
||||
* @param {Integer|FALSE} [libraryID=0] Library in which to save items,
|
||||
* @param {Integer|FALSE} [libraryID] Library in which to save items,
|
||||
* or NULL for default library;
|
||||
* if FALSE, don't save items
|
||||
* @param {Boolean} [saveAttachments=true] Exclude attachments (e.g., snapshots) on import
|
||||
|
|
|
@ -33,14 +33,15 @@ Zotero.Users = new function () {
|
|||
var sql = "SELECT value FROM settings WHERE setting='account' AND key='userID'";
|
||||
_userID = yield Zotero.DB.valueQueryAsync(sql);
|
||||
|
||||
sql = "SELECT value FROM settings WHERE setting='account' AND key='libraryID'";
|
||||
_libraryID = yield Zotero.DB.valueQueryAsync(sql);
|
||||
|
||||
sql = "SELECT value FROM settings WHERE setting='account' AND key='username'";
|
||||
_username = yield Zotero.DB.valueQueryAsync(sql);
|
||||
|
||||
if (_userID) {
|
||||
sql = "SELECT value FROM settings WHERE setting='account' AND key='libraryID'";
|
||||
_libraryID = yield Zotero.DB.valueQueryAsync(sql);
|
||||
|
||||
sql = "SELECT value FROM settings WHERE setting='account' AND key='username'";
|
||||
_username = yield Zotero.DB.valueQueryAsync(sql);
|
||||
}
|
||||
// If we don't have a global user id, generate a local user key
|
||||
if (!_userID) {
|
||||
else {
|
||||
sql = "SELECT value FROM settings WHERE setting='account' AND key='localUserKey'";
|
||||
let key = yield Zotero.DB.valueQueryAsync(sql);
|
||||
// Generate a local user key if we don't have one
|
||||
|
@ -54,42 +55,21 @@ Zotero.Users = new function () {
|
|||
});
|
||||
|
||||
|
||||
this.getCurrentUserID = function () {
|
||||
return _userID;
|
||||
};
|
||||
|
||||
|
||||
this.setCurrentUserID = Zotero.Promise.coroutine(function* (val) {
|
||||
this.getCurrentUserID = () => _userID;
|
||||
this.setCurrentUserID = function (val) {
|
||||
val = parseInt(val);
|
||||
_userID = val;
|
||||
var sql = "REPLACE INTO settings VALUES ('account', 'userID', ?)";
|
||||
Zotero.DB.queryAsync(sql, val);
|
||||
_userID = val;
|
||||
});
|
||||
|
||||
|
||||
this.getCurrentLibraryID = function () {
|
||||
return _libraryID;
|
||||
return Zotero.DB.queryAsync(sql, val);
|
||||
};
|
||||
|
||||
|
||||
this.setCurrentLibraryID = Zotero.Promise.coroutine(function* (val) {
|
||||
val = parseInt(val);
|
||||
var sql = "REPLACE INTO settings VALUES ('account', 'libraryID', ?)";
|
||||
Zotero.DB.queryAsync(sql, val);
|
||||
this.getCurrentUsername = () => _username;
|
||||
this.setCurrentUsername = function (val) {
|
||||
_userID = val;
|
||||
});
|
||||
|
||||
|
||||
this.getCurrentUsername = function () {
|
||||
return _username;
|
||||
};
|
||||
|
||||
|
||||
this.setCurrentUsername = Zotero.Promise.coroutine(function* (val) {
|
||||
var sql = "REPLACE INTO settings VALUES ('account', 'username', ?)";
|
||||
Zotero.DB.queryAsync(sql, val);
|
||||
_userID = val;
|
||||
});
|
||||
return Zotero.DB.queryAsync(sql, val);
|
||||
};
|
||||
|
||||
|
||||
this.getLocalUserKey = function () {
|
||||
|
|
|
@ -133,9 +133,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm");
|
|||
var _startupErrorHandler;
|
||||
var _zoteroDirectory = false;
|
||||
var _localizedStringBundle;
|
||||
var _userID;
|
||||
var _libraryID;
|
||||
var _localUserKey;
|
||||
var _waiting = 0;
|
||||
|
||||
var _locked = false;
|
||||
|
|
|
@ -746,7 +746,7 @@ var ZoteroPane = new function()
|
|||
var libraryID = collectionTreeRow.ref.libraryID;
|
||||
}
|
||||
else {
|
||||
var libraryID = 0;
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
var collectionTreeRow = null;
|
||||
}
|
||||
|
||||
|
@ -883,7 +883,7 @@ var ZoteroPane = new function()
|
|||
}
|
||||
|
||||
if (!libraryID) {
|
||||
libraryID = 0;
|
||||
libraryID = Zotero.Libraries.userLibraryID;
|
||||
}
|
||||
|
||||
var newids = [];
|
||||
|
@ -3291,7 +3291,7 @@ var ZoteroPane = new function()
|
|||
var libraryID = collectionTreeRow.ref.libraryID;
|
||||
}
|
||||
else {
|
||||
var libraryID = 0;
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
var collectionTreeRow = null;
|
||||
}
|
||||
//
|
||||
|
@ -3418,7 +3418,7 @@ var ZoteroPane = new function()
|
|||
var libraryID = collectionTreeRow.ref.libraryID;
|
||||
}
|
||||
else {
|
||||
var libraryID = 0;
|
||||
var libraryID = Zotero.Libraries.userLibraryID;
|
||||
var collectionTreeRow = null;
|
||||
}
|
||||
//
|
||||
|
|
|
@ -90,6 +90,8 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
newChannel: function (uri) {
|
||||
return new AsyncChannel(uri, function* () {
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
var path = uri.path;
|
||||
if (!path) {
|
||||
return 'Invalid URL';
|
||||
|
@ -118,13 +120,13 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
// Items within a collection or search
|
||||
router.add('library/:scopeObject/:scopeObjectKey/items/report.html', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
router.add('groups/:groupID/:scopeObject/:scopeObjectKey/items/report.html');
|
||||
|
||||
// All items
|
||||
router.add('library/items/report.html', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
router.add('groups/:groupID/items/report.html');
|
||||
|
||||
|
@ -472,6 +474,8 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
newChannel: function (uri) {
|
||||
return new AsyncChannel(uri, function* () {
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
path = uri.spec.match(/zotero:\/\/[^/]+(.*)/)[1];
|
||||
if (!path) {
|
||||
this.contentType = 'text/html';
|
||||
|
@ -483,14 +487,14 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
// HTML
|
||||
router.add('library/:scopeObject/:scopeObjectKey', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.controller = 'html';
|
||||
});
|
||||
router.add('groups/:groupID/:scopeObject/:scopeObjectKey', function () {
|
||||
params.controller = 'html';
|
||||
});
|
||||
router.add('library', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.controller = 'html';
|
||||
});
|
||||
router.add('groups/:groupID', function () {
|
||||
|
@ -499,14 +503,14 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
// Data
|
||||
router.add('data/library/:scopeObject/:scopeObjectKey', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.controller = 'data';
|
||||
});
|
||||
router.add('data/groups/:groupID/:scopeObject/:scopeObjectKey', function () {
|
||||
params.controller = 'data';
|
||||
});
|
||||
router.add('data/library', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
params.controller = 'data';
|
||||
});
|
||||
router.add('data/groups/:groupID', function () {
|
||||
|
@ -542,7 +546,7 @@ function ZoteroProtocolHandler() {
|
|||
});
|
||||
router.add('/', function () {
|
||||
params.controller = 'html';
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
|
||||
var parsed = router.run(path);
|
||||
|
@ -794,6 +798,8 @@ function ZoteroProtocolHandler() {
|
|||
var SelectExtension = {
|
||||
newChannel: function (uri) {
|
||||
return new AsyncChannel(uri, function* () {
|
||||
var userLibraryID = Zotero.Libraries.userLibraryID;
|
||||
|
||||
var path = uri.path;
|
||||
if (!path) {
|
||||
return 'Invalid URL';
|
||||
|
@ -809,13 +815,13 @@ function ZoteroProtocolHandler() {
|
|||
|
||||
// Item within a collection or search
|
||||
router.add('library/:scopeObject/:scopeObjectKey/items/:objectKey', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
router.add('groups/:groupID/:scopeObject/:scopeObjectKey/items/:objectKey');
|
||||
|
||||
// All items
|
||||
router.add('library/items/:objectKey', function () {
|
||||
params.libraryID = 0;
|
||||
params.libraryID = userLibraryID;
|
||||
});
|
||||
router.add('groups/:groupID/items/:objectKey');
|
||||
|
||||
|
|
Loading…
Reference in a new issue