Update code to use 0 instead of NULL for libraryID
This commit is contained in:
parent
368e568fe1
commit
4ea5e2d426
28 changed files with 213 additions and 313 deletions
|
@ -207,7 +207,7 @@
|
||||||
this.id('addButton').hidden = !this.editable;
|
this.id('addButton').hidden = !this.editable;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
return Zotero.Tags.getColors(self.item.libraryIDInt)
|
return Zotero.Tags.getColors(self.item.libraryID)
|
||||||
.then(function (colors) {
|
.then(function (colors) {
|
||||||
self._tagColors = colors;
|
self._tagColors = colors;
|
||||||
|
|
||||||
|
|
|
@ -77,9 +77,6 @@
|
||||||
<property name="libraryID" onget="return this._libraryID">
|
<property name="libraryID" onget="return this._libraryID">
|
||||||
<setter>
|
<setter>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// TEMP: libraryIDInt
|
|
||||||
val = val ? parseInt(val) : 0;
|
|
||||||
|
|
||||||
if (this._libraryID != val) {
|
if (this._libraryID != val) {
|
||||||
this._dirty = true;
|
this._dirty = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,7 +442,6 @@
|
||||||
var rows = [];
|
var rows = [];
|
||||||
|
|
||||||
var libraryID = this.parent.search.libraryID;
|
var libraryID = this.parent.search.libraryID;
|
||||||
libraryID = libraryID ? libraryID : null;
|
|
||||||
var cols = Zotero.getCollections(false, true, libraryID);
|
var cols = Zotero.getCollections(false, true, libraryID);
|
||||||
for (var i in cols) {
|
for (var i in cols) {
|
||||||
// Indent subcollections
|
// Indent subcollections
|
||||||
|
@ -461,7 +460,6 @@
|
||||||
case 'savedSearch':
|
case 'savedSearch':
|
||||||
var rows = [];
|
var rows = [];
|
||||||
var libraryID = this.parent.search.libraryID;
|
var libraryID = this.parent.search.libraryID;
|
||||||
libraryID = libraryID ? libraryID : null;
|
|
||||||
var searches = Zotero.Searches.getAll(libraryID);
|
var searches = Zotero.Searches.getAll(libraryID);
|
||||||
for (var i in searches) {
|
for (var i in searches) {
|
||||||
if (searches[i].id != this.parent.search.id) {
|
if (searches[i].id != this.parent.search.id) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ const Zotero_Lookup = new function () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var libraryID = null;
|
var libraryID = false;
|
||||||
var collection = false;
|
var collection = false;
|
||||||
try {
|
try {
|
||||||
libraryID = ZoteroPane_Local.getSelectedLibraryID();
|
libraryID = ZoteroPane_Local.getSelectedLibraryID();
|
||||||
|
|
|
@ -64,7 +64,7 @@ var Zotero_RecognizePDF = new function() {
|
||||||
* Retrieves metadata for a PDF and saves it as an item
|
* Retrieves metadata for a PDF and saves it as an item
|
||||||
*
|
*
|
||||||
* @param {nsIFile} file The PDF file to retrieve metadata for
|
* @param {nsIFile} file The PDF file to retrieve metadata for
|
||||||
* @param {Integer|null} libraryID The library in which to save the PDF
|
* @param {Integer} libraryID The library in which to save the PDF
|
||||||
* @param {Function} stopCheckCallback Function that returns true if the
|
* @param {Function} stopCheckCallback Function that returns true if the
|
||||||
* process is to be interrupted
|
* process is to be interrupted
|
||||||
* @return {Promise} A promise resolved when PDF metadata has been retrieved
|
* @return {Promise} A promise resolved when PDF metadata has been retrieved
|
||||||
|
|
|
@ -139,27 +139,27 @@ Zotero.CollectionTreeView.prototype.refresh = function()
|
||||||
|
|
||||||
if (this.hideSources.indexOf('duplicates') == -1) {
|
if (this.hideSources.indexOf('duplicates') == -1) {
|
||||||
try {
|
try {
|
||||||
this._duplicateLibraries = Zotero.Prefs.get('duplicateLibraries').split(',');
|
this._duplicateLibraries = Zotero.Prefs.get('duplicateLibraries').split(',').map(function (val) parseInt(val));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Add to personal library by default
|
// Add to personal library by default
|
||||||
Zotero.Prefs.set('duplicateLibraries', '0');
|
Zotero.Prefs.set('duplicateLibraries', '0');
|
||||||
this._duplicateLibraries = ['0'];
|
this._duplicateLibraries = [0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._unfiledLibraries = Zotero.Prefs.get('unfiledLibraries').split(',');
|
this._unfiledLibraries = Zotero.Prefs.get('unfiledLibraries').split(',').map(function (val) parseInt(val));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Add to personal library by default
|
// Add to personal library by default
|
||||||
Zotero.Prefs.set('unfiledLibraries', '0');
|
Zotero.Prefs.set('unfiledLibraries', '0');
|
||||||
this._unfiledLibraries = ['0'];
|
this._unfiledLibraries = [0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var library = {
|
var library = {
|
||||||
libraryID: null
|
libraryID: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// itemgroup, level, beforeRow, startOpen
|
// itemgroup, level, beforeRow, startOpen
|
||||||
|
@ -436,7 +436,7 @@ Zotero.CollectionTreeView.prototype.getImageSrc = function(row, col)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'trash':
|
case 'trash':
|
||||||
if (this._trashNotEmpty[itemGroup.ref.libraryID ? itemGroup.ref.libraryID : 0]) {
|
if (this._trashNotEmpty[itemGroup.ref.libraryID]) {
|
||||||
collectionType += '-full';
|
collectionType += '-full';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -490,7 +490,6 @@ Zotero.CollectionTreeView.prototype.isContainerEmpty = function(row)
|
||||||
}
|
}
|
||||||
if (itemGroup.isGroup()) {
|
if (itemGroup.isGroup()) {
|
||||||
var libraryID = itemGroup.ref.libraryID;
|
var libraryID = itemGroup.ref.libraryID;
|
||||||
libraryID = (libraryID ? libraryID : 0) + '';
|
|
||||||
|
|
||||||
return !itemGroup.ref.hasCollections()
|
return !itemGroup.ref.hasCollections()
|
||||||
&& !itemGroup.ref.hasSearches()
|
&& !itemGroup.ref.hasSearches()
|
||||||
|
@ -701,7 +700,7 @@ Zotero.CollectionTreeView.prototype.expandToCollection = function(collectionID)
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/**
|
/**
|
||||||
* @param {Integer|null} libraryID Library to select, or null for local library
|
* @param {Integer} libraryID Library to select
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
|
Zotero.CollectionTreeView.prototype.selectLibrary = function (libraryID) {
|
||||||
if (Zotero.suppressUIUpdates) {
|
if (Zotero.suppressUIUpdates) {
|
||||||
|
@ -884,7 +883,6 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
|
||||||
var isCollection = itemGroup.isCollection();
|
var isCollection = itemGroup.isCollection();
|
||||||
var level = this.getLevel(row);
|
var level = this.getLevel(row);
|
||||||
var libraryID = itemGroup.ref.libraryID;
|
var libraryID = itemGroup.ref.libraryID;
|
||||||
var intLibraryID = libraryID ? libraryID : 0;
|
|
||||||
|
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
var group = Zotero.Groups.getByLibraryID(libraryID);
|
var group = Zotero.Groups.getByLibraryID(libraryID);
|
||||||
|
@ -897,8 +895,8 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
|
||||||
if (isLibrary) {
|
if (isLibrary) {
|
||||||
var savedSearches = Zotero.Searches.getAll(libraryID);
|
var savedSearches = Zotero.Searches.getAll(libraryID);
|
||||||
var showDuplicates = (this.hideSources.indexOf('duplicates') == -1
|
var showDuplicates = (this.hideSources.indexOf('duplicates') == -1
|
||||||
&& this._duplicateLibraries.indexOf(intLibraryID) != -1);
|
&& this._duplicateLibraries.indexOf(libraryID) != -1);
|
||||||
var showUnfiled = this._unfiledLibraries.indexOf(intLibraryID) != -1;
|
var showUnfiled = this._unfiledLibraries.indexOf(libraryID) != -1;
|
||||||
var showTrash = this.hideSources.indexOf('trash') == -1;
|
var showTrash = this.hideSources.indexOf('trash') == -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -959,7 +957,7 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
|
||||||
|
|
||||||
// Duplicate items
|
// Duplicate items
|
||||||
if (showDuplicates) {
|
if (showDuplicates) {
|
||||||
var d = new Zotero.Duplicates(intLibraryID);
|
var d = new Zotero.Duplicates(libraryID);
|
||||||
this._showRow(new Zotero.ItemGroup('duplicates', d), level + 1, row + 1 + newRows);
|
this._showRow(new Zotero.ItemGroup('duplicates', d), level + 1, row + 1 + newRows);
|
||||||
newRows++;
|
newRows++;
|
||||||
}
|
}
|
||||||
|
@ -967,9 +965,7 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
|
||||||
// Unfiled items
|
// Unfiled items
|
||||||
if (showUnfiled) {
|
if (showUnfiled) {
|
||||||
var s = new Zotero.Search;
|
var s = new Zotero.Search;
|
||||||
if (isGroup) {
|
s.libraryID = libraryID;
|
||||||
s.libraryID = libraryID;
|
|
||||||
}
|
|
||||||
s.name = Zotero.getString('pane.collections.unfiled');
|
s.name = Zotero.getString('pane.collections.unfiled');
|
||||||
s.addCondition('libraryID', 'is', libraryID);
|
s.addCondition('libraryID', 'is', libraryID);
|
||||||
s.addCondition('unfiled', 'true');
|
s.addCondition('unfiled', 'true');
|
||||||
|
@ -986,7 +982,7 @@ Zotero.CollectionTreeView.prototype._expandRow = function (row, forceOpen) {
|
||||||
this._showRow(new Zotero.ItemGroup('trash', ref), level + 1, row + 1 + newRows);
|
this._showRow(new Zotero.ItemGroup('trash', ref), level + 1, row + 1 + newRows);
|
||||||
newRows++;
|
newRows++;
|
||||||
}
|
}
|
||||||
this._trashNotEmpty[intLibraryID] = !!deletedItems.length;
|
this._trashNotEmpty[libraryID] = !!deletedItems.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newRows;
|
return newRows;
|
||||||
|
@ -1071,12 +1067,12 @@ Zotero.CollectionTreeView.prototype.rememberSelection = function(selection)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns libraryID, null for personal library, or false if not a library
|
* Returns libraryID or FALSE if not a library
|
||||||
*/
|
*/
|
||||||
Zotero.CollectionTreeView.prototype.getSelectedLibraryID = function() {
|
Zotero.CollectionTreeView.prototype.getSelectedLibraryID = function() {
|
||||||
var itemGroup = this._getItemAtRow(this.selection.currentIndex);
|
var itemGroup = this._getItemAtRow(this.selection.currentIndex);
|
||||||
return itemGroup && itemGroup.ref && itemGroup.ref.libraryID !== undefined
|
return itemGroup && itemGroup.ref && itemGroup.ref.libraryID !== undefined
|
||||||
&& (itemGroup.ref.libraryID ? itemGroup.ref.libraryID : null);
|
&& itemGroup.ref.libraryID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1550,7 +1546,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient, dataTransfer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var targetLibraryID = itemGroup.isWithinGroup() ? itemGroup.ref.libraryID : null;
|
var targetLibraryID = itemGroup.ref.libraryID;
|
||||||
var targetCollectionID = itemGroup.isCollection() ? itemGroup.ref.id : false;
|
var targetCollectionID = itemGroup.isCollection() ? itemGroup.ref.id : false;
|
||||||
|
|
||||||
if (dataType == 'zotero/collection') {
|
if (dataType == 'zotero/collection') {
|
||||||
|
@ -1741,12 +1737,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient, dataTransfer)
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
}
|
}
|
||||||
else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') {
|
else if (dataType == 'text/x-moz-url' || dataType == 'application/x-moz-file') {
|
||||||
if (itemGroup.isWithinGroup()) {
|
var targetLibraryID = itemGroup.ref.libraryID;
|
||||||
var targetLibraryID = itemGroup.ref.libraryID;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var targetLibraryID = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (itemGroup.isCollection()) {
|
if (itemGroup.isCollection()) {
|
||||||
var parentCollectionID = itemGroup.ref.id;
|
var parentCollectionID = itemGroup.ref.id;
|
||||||
|
@ -1915,13 +1906,13 @@ Zotero.ItemGroup.prototype.__defineGetter__('id', function () {
|
||||||
return 'S' + this.ref.id;
|
return 'S' + this.ref.id;
|
||||||
|
|
||||||
case 'duplicates':
|
case 'duplicates':
|
||||||
return 'D' + (this.ref.libraryID ? this.ref.libraryID : 0);
|
return 'D' + this.ref.libraryID;
|
||||||
|
|
||||||
case 'unfiled':
|
case 'unfiled':
|
||||||
return 'U' + (this.ref.libraryID ? this.ref.libraryID : 0);
|
return 'U' + this.ref.libraryID;
|
||||||
|
|
||||||
case 'trash':
|
case 'trash':
|
||||||
return 'T' + (this.ref.libraryID ? this.ref.libraryID : 0);
|
return 'T' + this.ref.libraryID;
|
||||||
|
|
||||||
case 'header':
|
case 'header':
|
||||||
if (this.ref.id == 'group-libraries-header') {
|
if (this.ref.id == 'group-libraries-header') {
|
||||||
|
@ -2156,12 +2147,8 @@ Zotero.ItemGroup.prototype.getSearchObject = function() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var s = new Zotero.Search();
|
var s = new Zotero.Search();
|
||||||
if (this.isLibrary()) {
|
// Library root
|
||||||
s.addCondition('libraryID', 'is', null);
|
if (this.isLibrary(true)) {
|
||||||
s.addCondition('noChildren', 'true');
|
|
||||||
includeScopeChildren = true;
|
|
||||||
}
|
|
||||||
else if (this.isGroup()) {
|
|
||||||
s.addCondition('libraryID', 'is', this.ref.libraryID);
|
s.addCondition('libraryID', 'is', this.ref.libraryID);
|
||||||
s.addCondition('noChildren', 'true');
|
s.addCondition('noChildren', 'true');
|
||||||
includeScopeChildren = true;
|
includeScopeChildren = true;
|
||||||
|
|
|
@ -101,6 +101,10 @@ Zotero.Collection.prototype._set = function (field, val) {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
case 'key':
|
case 'key':
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
val = Zotero.DataObjectUtilities.checkLibraryID(val);
|
||||||
|
}
|
||||||
|
|
||||||
if (val == this['_' + field]) {
|
if (val == this['_' + field]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +112,9 @@ Zotero.Collection.prototype._set = function (field, val) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
throw ("Cannot set " + field + " after object is already loaded in Zotero.Collection._set()");
|
throw ("Cannot set " + field + " after object is already loaded in Zotero.Collection._set()");
|
||||||
}
|
}
|
||||||
|
|
||||||
//this._checkValue(field, val);
|
//this._checkValue(field, val);
|
||||||
|
|
||||||
this['_' + field] = val;
|
this['_' + field] = val;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -183,15 +189,8 @@ Zotero.Collection.prototype.load = function() {
|
||||||
var params = id;
|
var params = id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "key=?";
|
sql += "key=? AND libraryID=?";
|
||||||
var params = [key];
|
var params = [key, libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var data = Zotero.DB.rowQuery(sql, params);
|
var data = Zotero.DB.rowQuery(sql, params);
|
||||||
|
|
||||||
|
@ -434,12 +433,12 @@ Zotero.Collection.prototype.save = function () {
|
||||||
this._changed.dateModified ?
|
this._changed.dateModified ?
|
||||||
this.dateModified : Zotero.DB.transactionDateTime,
|
this.dateModified : Zotero.DB.transactionDateTime,
|
||||||
Zotero.DB.transactionDateTime,
|
Zotero.DB.transactionDateTime,
|
||||||
this.libraryID ? this.libraryID : null,
|
this.libraryID ? this.libraryID : 0,
|
||||||
key
|
key
|
||||||
];
|
];
|
||||||
|
|
||||||
var sql = "REPLACE INTO collections (" + columns.join(', ') + ") VALUES ("
|
var sql = "REPLACE INTO collections (" + columns.join(', ') + ") "
|
||||||
+ placeholders.join(', ') + ")";
|
+ "VALUES (" + placeholders + ")";
|
||||||
var insertID = Zotero.DB.query(sql, sqlValues);
|
var insertID = Zotero.DB.query(sql, sqlValues);
|
||||||
if (!collectionID) {
|
if (!collectionID) {
|
||||||
collectionID = insertID;
|
collectionID = insertID;
|
||||||
|
@ -1192,7 +1191,7 @@ Zotero.Collection.prototype.addLinkedCollection = function (collection) {
|
||||||
|
|
||||||
// If both group libraries, store relation with source group.
|
// If both group libraries, store relation with source group.
|
||||||
// Otherwise, store with personal library.
|
// Otherwise, store with personal library.
|
||||||
var libraryID = (this.libraryID && collection.libraryID) ? this.libraryID : null;
|
var libraryID = (this.libraryID && collection.libraryID) ? this.libraryID : 0;
|
||||||
|
|
||||||
Zotero.Relations.add(libraryID, url1, predicate, url2);
|
Zotero.Relations.add(libraryID, url1, predicate, url2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,10 @@ Zotero.Creator.prototype._set = function (field, val) {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
case 'key':
|
case 'key':
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
val = Zotero.DataObjectUtilities.checkLibraryID(val);
|
||||||
|
}
|
||||||
|
|
||||||
if (val == this['_' + field]) {
|
if (val == this['_' + field]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +100,9 @@ Zotero.Creator.prototype._set = function (field, val) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
throw ("Cannot set " + field + " after object is already loaded in Zotero.Creator._set()");
|
throw ("Cannot set " + field + " after object is already loaded in Zotero.Creator._set()");
|
||||||
}
|
}
|
||||||
|
|
||||||
this._checkValue(field, val);
|
this._checkValue(field, val);
|
||||||
|
|
||||||
this['_' + field] = val;
|
this['_' + field] = val;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -241,7 +247,7 @@ Zotero.Creator.prototype.save = function () {
|
||||||
'libraryID',
|
'libraryID',
|
||||||
'key'
|
'key'
|
||||||
];
|
];
|
||||||
var placeholders = ['?', '?', '?', '?', '?', '?', '?'];
|
var placeholders = columns.map(function () '?').join();
|
||||||
var sqlValues = [
|
var sqlValues = [
|
||||||
creatorID ? { int: creatorID } : null,
|
creatorID ? { int: creatorID } : null,
|
||||||
{ int: creatorDataID },
|
{ int: creatorDataID },
|
||||||
|
@ -251,13 +257,13 @@ Zotero.Creator.prototype.save = function () {
|
||||||
this._changed.dateModified ?
|
this._changed.dateModified ?
|
||||||
this.dateModified : Zotero.DB.transactionDateTime,
|
this.dateModified : Zotero.DB.transactionDateTime,
|
||||||
Zotero.DB.transactionDateTime,
|
Zotero.DB.transactionDateTime,
|
||||||
this.libraryID ? this.libraryID : null,
|
this.libraryID ? this.libraryID : 0,
|
||||||
key
|
key
|
||||||
];
|
];
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
var sql = "INSERT INTO creators (" + columns.join(', ') + ") VALUES ("
|
var sql = "INSERT INTO creators (" + columns.join(', ') + ") "
|
||||||
+ placeholders.join(', ') + ")";
|
+ "VALUES (" + placeholders + ")";
|
||||||
var insertID = Zotero.DB.query(sql, sqlValues);
|
var insertID = Zotero.DB.query(sql, sqlValues);
|
||||||
if (!creatorID) {
|
if (!creatorID) {
|
||||||
creatorID = insertID;
|
creatorID = insertID;
|
||||||
|
@ -456,21 +462,14 @@ Zotero.Creator.prototype.load = function (allowFail) {
|
||||||
throw ("ID or key not set in Zotero.Creator.load()");
|
throw ("ID or key not set in Zotero.Creator.load()");
|
||||||
}
|
}
|
||||||
|
|
||||||
var sql = "SELECT C.*, CD.* FROM creators C NATURAL JOIN creatorData CD WHERE ";
|
var sql = "SELECT O.*, CD.* FROM creators O NATURAL JOIN creatorData CD WHERE ";
|
||||||
if (id) {
|
if (id) {
|
||||||
sql += "creatorID=?";
|
sql += "creatorID=?";
|
||||||
var params = id;
|
var params = id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "key=?";
|
sql += "key=? AND libraryID=?";
|
||||||
var params = [key];
|
var params = [key, libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var row = Zotero.DB.rowQuery(sql, params);
|
var row = Zotero.DB.rowQuery(sql, params);
|
||||||
|
|
||||||
|
@ -500,7 +499,7 @@ Zotero.Creator.prototype.loadFromRow = function (row) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
this['_' + col] = row[col] ? row[col] : null;
|
this['_' + col] = row[col];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this['_' + col] = row[col] ? row[col] : '';
|
this['_' + col] = row[col] ? row[col] : '';
|
||||||
|
@ -524,7 +523,7 @@ Zotero.Creator.prototype._checkValue = function (field, value) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
if (value && parseInt(value) != value) {
|
if (parseInt(value) != value) {
|
||||||
this._invalidValueError(field, value);
|
this._invalidValueError(field, value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -122,26 +122,17 @@ Zotero.Creators = new function() {
|
||||||
|
|
||||||
function getCreatorsWithData(creatorDataID, libraryID) {
|
function getCreatorsWithData(creatorDataID, libraryID) {
|
||||||
var sql = "SELECT creatorID FROM creators WHERE creatorDataID=?";
|
var sql = "SELECT creatorID FROM creators WHERE creatorDataID=?";
|
||||||
var params = [creatorDataID];
|
if (libraryID !== undefined) {
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
sql += " AND libraryID=?";
|
||||||
params.push(libraryID);
|
return Zotero.DB.columnQuery(sql, [creatorDataID, libraryID])
|
||||||
}
|
}
|
||||||
else {
|
return Zotero.DB.columnQuery(sql, [creatorDataID]);
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
return Zotero.DB.columnQuery(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function countCreatorsWithData(creatorDataID, libraryID) {
|
function countCreatorsWithData(creatorDataID, libraryID) {
|
||||||
var sql = "SELECT COUNT(*) FROM creators WHERE creatorDataID=?";
|
var sql = "SELECT COUNT(*) FROM creators WHERE creatorDataID=?";
|
||||||
var params = [creatorDataID];
|
return Zotero.DB.valueQuery(sql, [creatorDataID]);
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
return Zotero.DB.valueQuery(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
51
chrome/content/zotero/xpcom/data/dataObjectUtilities.js
Normal file
51
chrome/content/zotero/xpcom/data/dataObjectUtilities.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
***** BEGIN LICENSE BLOCK *****
|
||||||
|
|
||||||
|
Copyright © 2009 Center for History and New Media
|
||||||
|
George Mason University, Fairfax, Virginia, USA
|
||||||
|
http://zotero.org
|
||||||
|
|
||||||
|
This file is part of Zotero.
|
||||||
|
|
||||||
|
Zotero is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Zotero is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
***** END LICENSE BLOCK *****
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Zotero.DataObjectUtilities = {
|
||||||
|
"checkLibraryID": function (libraryID) {
|
||||||
|
if (libraryID === null) {
|
||||||
|
Zotero.debug("Deprecated: libraryID cannot be NULL\n\n" + Components.stack, 2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var intValue = parseInt(libraryID);
|
||||||
|
if (libraryID != intValue) {
|
||||||
|
throw new Error("libraryID must be an integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return intValue;
|
||||||
|
},
|
||||||
|
|
||||||
|
"getObjectTypePlural": function getObjectTypePlural(objectType) {
|
||||||
|
return objectType == 'search' ? 'searches' : objectType + 's';
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"getClassForObjectType": function getClassForObjectType(objectType) {
|
||||||
|
var objectTypePlural = this.getObjectTypePlural(objectType);
|
||||||
|
var className = objectTypePlural[0].toUpperCase() + objectTypePlural.substr(1);
|
||||||
|
return Zotero[className]
|
||||||
|
}
|
||||||
|
};
|
|
@ -55,7 +55,6 @@ Zotero.DataObjects = function (object, objectPlural, id, table) {
|
||||||
|
|
||||||
|
|
||||||
this.makeLibraryKeyHash = function (libraryID, key) {
|
this.makeLibraryKeyHash = function (libraryID, key) {
|
||||||
var libraryID = libraryID ? libraryID : 0;
|
|
||||||
return libraryID + '_' + key;
|
return libraryID + '_' + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,57 +69,29 @@ Zotero.DataObjects = function (object, objectPlural, id, table) {
|
||||||
if (!key) {
|
if (!key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
libraryID = parseInt(libraryID);
|
|
||||||
return {
|
return {
|
||||||
libraryID: libraryID ? libraryID : null,
|
libraryID: parseInt(libraryID),
|
||||||
key: key
|
key: key
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves an object of the current by its key
|
|
||||||
*
|
|
||||||
* @param {String} key
|
|
||||||
* @return {Zotero.DataObject} Zotero data object, or FALSE if not found
|
|
||||||
*/
|
|
||||||
this.getByKey = function (key) {
|
|
||||||
if (arguments.length > 1) {
|
|
||||||
throw ("getByKey() takes only one argument");
|
|
||||||
}
|
|
||||||
|
|
||||||
Components.utils.reportError("Zotero." + this._ZDO_Objects
|
|
||||||
+ ".getByKey() is deprecated -- use getByLibraryAndKey()");
|
|
||||||
|
|
||||||
return this.getByLibraryAndKey(null, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves an object by its libraryID and key
|
* Retrieves an object by its libraryID and key
|
||||||
*
|
*
|
||||||
* @param {Integer|NULL} libraryID
|
* @param {Integer} libraryID
|
||||||
* @param {String} key
|
* @param {String} key
|
||||||
* @return {Zotero.DataObject} Zotero data object, or FALSE if not found
|
* @return {Zotero.DataObject} Zotero data object, or FALSE if not found
|
||||||
*/
|
*/
|
||||||
this.getByLibraryAndKey = function (libraryID, key) {
|
this.getByLibraryAndKey = function (libraryID, key) {
|
||||||
var sql = "SELECT ROWID FROM " + this._ZDO_table + " WHERE ";
|
var sql = "SELECT ROWID FROM " + this._ZDO_table + " WHERE ";
|
||||||
var params = [];
|
|
||||||
if (this._ZDO_idOnly) {
|
if (this._ZDO_idOnly) {
|
||||||
sql += "ROWID=?";
|
sql += "ROWID=?";
|
||||||
params.push(key);
|
var params = [key]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "libraryID";
|
sql += "libraryID=? AND key=?";
|
||||||
if (libraryID && libraryID !== '0') {
|
var params = [libraryID, key];
|
||||||
sql += "=? ";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL ";
|
|
||||||
}
|
|
||||||
sql += "AND key=?";
|
|
||||||
params.push(key);
|
|
||||||
}
|
}
|
||||||
var id = Zotero.DB.valueQuery(sql, params);
|
var id = Zotero.DB.valueQuery(sql, params);
|
||||||
if (!id) {
|
if (!id) {
|
||||||
|
|
|
@ -112,8 +112,6 @@ Zotero.Item.prototype.__defineGetter__('itemID', function () {
|
||||||
});
|
});
|
||||||
Zotero.Item.prototype.__defineSetter__('id', function (val) { this.setField('id', val); });
|
Zotero.Item.prototype.__defineSetter__('id', function (val) { this.setField('id', val); });
|
||||||
Zotero.Item.prototype.__defineGetter__('libraryID', function () { return this.getField('libraryID'); });
|
Zotero.Item.prototype.__defineGetter__('libraryID', function () { return this.getField('libraryID'); });
|
||||||
// Temporary until everything expects an integer
|
|
||||||
Zotero.Item.prototype.__defineGetter__('libraryIDInt', function () { var libraryID = this.getField('libraryID'); return libraryID ? parseInt(libraryID) : 0; });
|
|
||||||
Zotero.Item.prototype.__defineSetter__('libraryID', function (val) { this.setField('libraryID', val); });
|
Zotero.Item.prototype.__defineSetter__('libraryID', function (val) { this.setField('libraryID', val); });
|
||||||
Zotero.Item.prototype.__defineGetter__('key', function () { return this.getField('key'); });
|
Zotero.Item.prototype.__defineGetter__('key', function () { return this.getField('key'); });
|
||||||
Zotero.Item.prototype.__defineSetter__('key', function (val) { this.setField('key', val) });
|
Zotero.Item.prototype.__defineSetter__('key', function (val) { this.setField('key', val) });
|
||||||
|
@ -132,7 +130,7 @@ Zotero.Item.prototype.__defineSetter__('relatedItems', function (arr) { this._se
|
||||||
Zotero.Item.prototype.__defineGetter__('relatedItemsReverse', function () { var ids = this._getRelatedItemsReverse(); return ids; });
|
Zotero.Item.prototype.__defineGetter__('relatedItemsReverse', function () { var ids = this._getRelatedItemsReverse(); return ids; });
|
||||||
Zotero.Item.prototype.__defineGetter__('relatedItemsBidirectional', function () { var ids = this._getRelatedItemsBidirectional(); return ids; });
|
Zotero.Item.prototype.__defineGetter__('relatedItemsBidirectional', function () { var ids = this._getRelatedItemsBidirectional(); return ids; });
|
||||||
|
|
||||||
Zotero.Item.prototype.__defineGetter__('libraryKey', function () this.libraryIDInt + "/" + this.key);
|
Zotero.Item.prototype.__defineGetter__('libraryKey', function () this.libraryID + "/" + this.key);
|
||||||
|
|
||||||
Zotero.Item.prototype.getID = function() {
|
Zotero.Item.prototype.getID = function() {
|
||||||
Zotero.debug('Item.getID() is deprecated -- use Item.id');
|
Zotero.debug('Item.getID() is deprecated -- use Item.id');
|
||||||
|
@ -344,15 +342,8 @@ Zotero.Item.prototype.loadPrimaryData = function(allowFail) {
|
||||||
var params = id;
|
var params = id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "key=? ";
|
sql += "key=? AND libraryID=? ";
|
||||||
var params = [key];
|
var params = [key, libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += "AND libraryID=? ";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += "AND libraryID IS NULL ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sql += (where.length ? ' AND ' + where.join(' AND ') : '');
|
sql += (where.length ? ' AND ' + where.join(' AND ') : '');
|
||||||
var row = Zotero.DB.rowQuery(sql, params);
|
var row = Zotero.DB.rowQuery(sql, params);
|
||||||
|
@ -398,7 +389,7 @@ Zotero.Item.prototype.loadFromRow = function(row, reload) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
this['_' + col] = row[col] ? row[col] : null;
|
this['_' + col] = row[col];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'numNotes':
|
case 'numNotes':
|
||||||
|
@ -707,6 +698,10 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
case 'key':
|
case 'key':
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
value = Zotero.DataObjectUtilities.checkLibraryID(value);
|
||||||
|
}
|
||||||
|
|
||||||
if (value == this['_' + field]) {
|
if (value == this['_' + field]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +709,6 @@ Zotero.Item.prototype.setField = function(field, value, loadIn) {
|
||||||
if (this._primaryDataLoaded) {
|
if (this._primaryDataLoaded) {
|
||||||
throw ("Cannot set " + field + " after object is already loaded in Zotero.Item.setField()");
|
throw ("Cannot set " + field + " after object is already loaded in Zotero.Item.setField()");
|
||||||
}
|
}
|
||||||
//this._checkValue(field, val);
|
|
||||||
this['_' + field] = value;
|
this['_' + field] = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1323,7 +1317,7 @@ Zotero.Item.prototype.save = function(options) {
|
||||||
this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime,
|
this.dateAdded ? this.dateAdded : Zotero.DB.transactionDateTime,
|
||||||
this.dateModified ? this.dateModified : Zotero.DB.transactionDateTime,
|
this.dateModified ? this.dateModified : Zotero.DB.transactionDateTime,
|
||||||
Zotero.DB.transactionDateTime,
|
Zotero.DB.transactionDateTime,
|
||||||
this.libraryID ? this.libraryID : null,
|
this.libraryID ? this.libraryID : 0,
|
||||||
key
|
key
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2181,7 +2175,7 @@ Zotero.Item.prototype.save = function(options) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Refresh trash
|
// Refresh trash
|
||||||
Zotero.Notifier.trigger('refresh', 'trash', this.libraryID ? this.libraryID : 0);
|
Zotero.Notifier.trigger('refresh', 'trash', this.libraryID);
|
||||||
if (this._deleted) {
|
if (this._deleted) {
|
||||||
Zotero.Notifier.trigger('trash', 'item', this.id);
|
Zotero.Notifier.trigger('trash', 'item', this.id);
|
||||||
}
|
}
|
||||||
|
@ -3784,7 +3778,7 @@ Zotero.Item.prototype.addTag = function(name, type) {
|
||||||
var tagID = Zotero.Tags.getID(name, type, this.libraryID);
|
var tagID = Zotero.Tags.getID(name, type, this.libraryID);
|
||||||
if (!tagID) {
|
if (!tagID) {
|
||||||
var tag = new Zotero.Tag;
|
var tag = new Zotero.Tag;
|
||||||
tag.libraryID = this.libraryID ? this.libraryID : null;
|
tag.libraryID = this.libraryID;
|
||||||
tag.name = name;
|
tag.name = name;
|
||||||
tag.type = type;
|
tag.type = type;
|
||||||
var tagID = tag.save();
|
var tagID = tag.save();
|
||||||
|
@ -4025,7 +4019,7 @@ Zotero.Item.prototype.addLinkedItem = function (item) {
|
||||||
// If one of the items is a personal library, store relation with that.
|
// 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
|
// Otherwise, use current item's library (which in calling code is the
|
||||||
// new, copied item).
|
// new, copied item).
|
||||||
var libraryID = (!this.libraryID || !item.libraryID) ? null : this.libraryID;
|
var libraryID = (!this.libraryID || !item.libraryID) ? 0 : this.libraryID;
|
||||||
|
|
||||||
Zotero.Relations.add(libraryID, url1, predicate, url2);
|
Zotero.Relations.add(libraryID, url1, predicate, url2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,31 +132,20 @@ Zotero.Items = new function() {
|
||||||
/**
|
/**
|
||||||
* Return items marked as deleted
|
* Return items marked as deleted
|
||||||
*
|
*
|
||||||
* @param {Number|NULL} libraryID
|
* @param {Integer} libraryID
|
||||||
* @param {Boolean} asIDs Return itemIDs instead of
|
* @param {Boolean} asIDs Return itemIDs instead of
|
||||||
* Zotero.Item objects
|
* Zotero.Item objects
|
||||||
* @return {Zotero.Item[]|Integer[]}
|
* @return {Zotero.Item[]|Integer[]}
|
||||||
*/
|
*/
|
||||||
this.getDeleted = function (libraryID, asIDs, days) {
|
this.getDeleted = function (libraryID, asIDs, days) {
|
||||||
// Throw warning for pre-3.0b3 arguments
|
|
||||||
if (typeof libraryID == 'boolean') {
|
|
||||||
throw new Error("libraryID must be a number or null");
|
|
||||||
}
|
|
||||||
|
|
||||||
var sql = "SELECT itemID FROM items JOIN deletedItems USING (itemID) "
|
var sql = "SELECT itemID FROM items JOIN deletedItems USING (itemID) "
|
||||||
+ "WHERE libraryID" + (libraryID ? "=?" : " IS NULL");
|
+ "WHERE libraryID=?";
|
||||||
|
|
||||||
if (days) {
|
if (days) {
|
||||||
sql += " AND dateDeleted<=DATE('NOW', '-" + parseInt(days) + " DAYS')";
|
sql += " AND dateDeleted<=DATE('NOW', '-" + parseInt(days) + " DAYS')";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libraryID) {
|
var ids = Zotero.DB.columnQuery(sql, [libraryID]);
|
||||||
var ids = Zotero.DB.columnQuery(sql, [libraryID]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var ids = Zotero.DB.columnQuery(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -185,14 +174,8 @@ Zotero.Items = new function() {
|
||||||
if (!includeDeleted) {
|
if (!includeDeleted) {
|
||||||
sql += " AND A.itemID NOT IN (SELECT itemID FROM deletedItems)";
|
sql += " AND A.itemID NOT IN (SELECT itemID FROM deletedItems)";
|
||||||
}
|
}
|
||||||
if (libraryID) {
|
sql += " AND libraryID=?";
|
||||||
sql += " AND libraryID=?";
|
var ids = Zotero.DB.columnQuery(sql, libraryID);
|
||||||
var ids = Zotero.DB.columnQuery(sql, libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
var ids = Zotero.DB.columnQuery(sql);
|
|
||||||
}
|
|
||||||
return this.get(ids);
|
return this.get(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +488,7 @@ Zotero.Items = new function() {
|
||||||
deletedIDs = deletedIDs.slice(0, limit - 1)
|
deletedIDs = deletedIDs.slice(0, limit - 1)
|
||||||
}
|
}
|
||||||
this.erase(deletedIDs);
|
this.erase(deletedIDs);
|
||||||
Zotero.Notifier.trigger('refresh', 'trash', libraryID ? libraryID : 0);
|
Zotero.Notifier.trigger('refresh', 'trash', libraryID);
|
||||||
}
|
}
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,10 @@ Zotero.Relation.prototype._set = function (field, val) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
throw ("Cannot set " + field + " after object is already loaded in Zotero.Relation._set()");
|
throw ("Cannot set " + field + " after object is already loaded in Zotero.Relation._set()");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
val = parseInt(val);
|
||||||
|
}
|
||||||
this['_' + field] = val;
|
this['_' + field] = val;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,10 @@ Zotero.Tag.prototype._set = function (field, val) {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
case 'key':
|
case 'key':
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
val = Zotero.DataObjectUtilities.checkLibraryID(val);
|
||||||
|
}
|
||||||
|
|
||||||
if (val == this['_' + field]) {
|
if (val == this['_' + field]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +97,9 @@ Zotero.Tag.prototype._set = function (field, val) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
throw ("Cannot set " + field + " after object is already loaded in Zotero.Tag._set()");
|
throw ("Cannot set " + field + " after object is already loaded in Zotero.Tag._set()");
|
||||||
}
|
}
|
||||||
|
|
||||||
//this._checkValue(field, val);
|
//this._checkValue(field, val);
|
||||||
|
|
||||||
this['_' + field] = val;
|
this['_' + field] = val;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -158,15 +164,8 @@ Zotero.Tag.prototype.load = function() {
|
||||||
var params = id;
|
var params = id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "key=?";
|
sql += "key=? AND libraryID=?";
|
||||||
var params = [key];
|
var params = [key, libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var row = Zotero.DB.rowQuery(sql, params);
|
var row = Zotero.DB.rowQuery(sql, params);
|
||||||
|
|
||||||
|
@ -192,7 +191,7 @@ Zotero.Tag.prototype.loadFromRow = function (row) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
this['_' + col] = row[col] ? row[col] : null;
|
this['_' + col] = row[col];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this['_' + col] = (!row[col] && row[col] !== 0) ? '' : row[col];
|
this['_' + col] = (!row[col] && row[col] !== 0) ? '' : row[col];
|
||||||
|
@ -321,7 +320,7 @@ Zotero.Tag.prototype.save = function (full) {
|
||||||
'libraryID',
|
'libraryID',
|
||||||
'key'
|
'key'
|
||||||
];
|
];
|
||||||
var placeholders = ['?', '?', '?', '?', '?', '?', '?', '?'];
|
var placeholders = columns.map(function () '?').join();
|
||||||
var sqlValues = [
|
var sqlValues = [
|
||||||
tagID ? { int: tagID } : null,
|
tagID ? { int: tagID } : null,
|
||||||
{ string: this.name },
|
{ string: this.name },
|
||||||
|
@ -332,14 +331,14 @@ Zotero.Tag.prototype.save = function (full) {
|
||||||
this._changed.dateModified ?
|
this._changed.dateModified ?
|
||||||
this.dateModified : Zotero.DB.transactionDateTime,
|
this.dateModified : Zotero.DB.transactionDateTime,
|
||||||
Zotero.DB.transactionDateTime,
|
Zotero.DB.transactionDateTime,
|
||||||
this.libraryID ? this.libraryID : null,
|
this.libraryID ? this.libraryID : 0,
|
||||||
key
|
key
|
||||||
];
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
var sql = "INSERT INTO tags (" + columns.join(', ') + ") VALUES ("
|
var sql = "INSERT INTO tags (" + columns.join(', ') + ") "
|
||||||
+ placeholders.join(', ') + ")";
|
+ "VALUES (" + placeholders + ")";
|
||||||
var insertID = Zotero.DB.query(sql, sqlValues);
|
var insertID = Zotero.DB.query(sql, sqlValues);
|
||||||
if (!tagID) {
|
if (!tagID) {
|
||||||
tagID = insertID;
|
tagID = insertID;
|
||||||
|
@ -381,8 +380,8 @@ Zotero.Tag.prototype.save = function (full) {
|
||||||
|
|
||||||
// Save again
|
// Save again
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
var sql = "INSERT INTO tags (" + columns.join(', ') + ") VALUES ("
|
var sql = "INSERT INTO tags (" + columns.join(', ') + ") "
|
||||||
+ placeholders.join(', ') + ")";
|
+ "VALUES (" + placeholders + ")";
|
||||||
var insertID = Zotero.DB.query(sql, sqlValues);
|
var insertID = Zotero.DB.query(sql, sqlValues);
|
||||||
if (!tagID) {
|
if (!tagID) {
|
||||||
tagID = insertID;
|
tagID = insertID;
|
||||||
|
|
|
@ -98,16 +98,8 @@ Zotero.Tags = new function() {
|
||||||
// FIXME: COLLATE NOCASE doesn't work for Unicode characters, so this
|
// FIXME: COLLATE NOCASE doesn't work for Unicode characters, so this
|
||||||
// won't find Äbc if "äbc" is entered and will allow a duplicate tag
|
// won't find Äbc if "äbc" is entered and will allow a duplicate tag
|
||||||
// to be created
|
// to be created
|
||||||
var sql = "SELECT tagID FROM tags WHERE name=? AND type=? AND libraryID";
|
var sql = "SELECT tagID FROM tags WHERE name=? AND type=? AND libraryID=?";
|
||||||
var params = [name, type];
|
var tagID = Zotero.DB.valueQuery(sql, [name, type, libraryID]);
|
||||||
if (libraryID) {
|
|
||||||
sql += "=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL";
|
|
||||||
}
|
|
||||||
var tagID = Zotero.DB.valueQuery(sql, params);
|
|
||||||
if (tagID) {
|
if (tagID) {
|
||||||
if (!_tags[libraryID]) {
|
if (!_tags[libraryID]) {
|
||||||
_tags[libraryID] = {};
|
_tags[libraryID] = {};
|
||||||
|
@ -127,16 +119,8 @@ Zotero.Tags = new function() {
|
||||||
*/
|
*/
|
||||||
function getIDs(name, libraryID) {
|
function getIDs(name, libraryID) {
|
||||||
name = Zotero.Utilities.trim(name);
|
name = Zotero.Utilities.trim(name);
|
||||||
var sql = "SELECT tagID FROM tags WHERE name=? AND libraryID";
|
var sql = "SELECT tagID FROM tags WHERE name=? AND libraryID=?";
|
||||||
var params = [name];
|
return Zotero.DB.columnQuery(sql, [name, libraryID]);
|
||||||
if (libraryID) {
|
|
||||||
sql += "=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL";
|
|
||||||
}
|
|
||||||
return Zotero.DB.columnQuery(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,16 +129,8 @@ Zotero.Tags = new function() {
|
||||||
*/
|
*/
|
||||||
function getTypes(name, libraryID) {
|
function getTypes(name, libraryID) {
|
||||||
name = Zotero.Utilities.trim(name);
|
name = Zotero.Utilities.trim(name);
|
||||||
var sql = "SELECT type FROM tags WHERE name=? AND libraryID";
|
var sql = "SELECT type FROM tags WHERE name=? AND libraryID=?";
|
||||||
var params = [name];
|
return Zotero.DB.columnQuery(sql, [name, libraryID]);
|
||||||
if (libraryID) {
|
|
||||||
sql += "=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL";
|
|
||||||
}
|
|
||||||
return Zotero.DB.columnQuery(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -164,15 +140,8 @@ Zotero.Tags = new function() {
|
||||||
* _types_ is an optional array of tag types to fetch
|
* _types_ is an optional array of tag types to fetch
|
||||||
*/
|
*/
|
||||||
function getAll(types, libraryID) {
|
function getAll(types, libraryID) {
|
||||||
var sql = "SELECT tagID, name FROM tags WHERE libraryID";
|
var sql = "SELECT tagID, name FROM tags WHERE libraryID=?";
|
||||||
var params = [];
|
var params = [libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += "=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL";
|
|
||||||
}
|
|
||||||
if (types) {
|
if (types) {
|
||||||
sql += " AND type IN (" + types.join() + ")";
|
sql += " AND type IN (" + types.join() + ")";
|
||||||
}
|
}
|
||||||
|
@ -314,7 +283,7 @@ Zotero.Tags = new function() {
|
||||||
|
|
||||||
// We need to know if the old tag has a color assigned so that
|
// We need to know if the old tag has a color assigned so that
|
||||||
// we can assign it to the new name
|
// we can assign it to the new name
|
||||||
return self.getColor(libraryID ? parseInt(libraryID) : 0, oldName);
|
return self.getColor(libraryID, oldName);
|
||||||
})
|
})
|
||||||
.then(function (oldColorData) {
|
.then(function (oldColorData) {
|
||||||
Zotero.DB.beginTransaction();
|
Zotero.DB.beginTransaction();
|
||||||
|
@ -400,14 +369,12 @@ Zotero.Tags = new function() {
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
|
||||||
if (oldColorData) {
|
if (oldColorData) {
|
||||||
var libraryIDInt = libraryID ? parseInt(libraryID) : 0
|
|
||||||
|
|
||||||
// Remove color from old tag
|
// Remove color from old tag
|
||||||
return self.setColor(libraryIDInt, oldName)
|
return self.setColor(libraryID, oldName)
|
||||||
// Add color to new tag
|
// Add color to new tag
|
||||||
.then(function () {
|
.then(function () {
|
||||||
return self.setColor(
|
return self.setColor(
|
||||||
libraryIDInt,
|
libraryID,
|
||||||
newName,
|
newName,
|
||||||
oldColorData.color,
|
oldColorData.color,
|
||||||
oldColorData.position
|
oldColorData.position
|
||||||
|
@ -493,7 +460,7 @@ Zotero.Tags = new function() {
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
this.setColor = function (libraryID, name, color, position) {
|
this.setColor = function (libraryID, name, color, position) {
|
||||||
if (libraryID === null) {
|
if (!Number.isInteger(libraryID)) {
|
||||||
throw new Error("libraryID must be an integer");
|
throw new Error("libraryID must be an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -828,7 +795,7 @@ Zotero.Tags = new function() {
|
||||||
var tag = this.get(id);
|
var tag = this.get(id);
|
||||||
if (tag) {
|
if (tag) {
|
||||||
deleted.push({
|
deleted.push({
|
||||||
libraryID: tag.libraryID ? parseInt(tag.libraryID) : 0,
|
libraryID: tag.libraryID,
|
||||||
name: tag.name
|
name: tag.name
|
||||||
});
|
});
|
||||||
tag.erase();
|
tag.erase();
|
||||||
|
@ -950,7 +917,7 @@ Zotero.Tags = new function() {
|
||||||
for each(var id in ids) {
|
for each(var id in ids) {
|
||||||
var tag = this._objectCache[id];
|
var tag = this._objectCache[id];
|
||||||
delete this._objectCache[id];
|
delete this._objectCache[id];
|
||||||
var libraryID = tag.libraryID ? tag.libraryID : 0;
|
var libraryID = tag.libraryID;
|
||||||
if (tag && _tags[libraryID] && _tags[libraryID][tag.type]) {
|
if (tag && _tags[libraryID] && _tags[libraryID][tag.type]) {
|
||||||
delete _tags[libraryID][tag.type]['_' + tag.name];
|
delete _tags[libraryID][tag.type]['_' + tag.name];
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,17 +41,8 @@ Zotero.getCollections = function(parent, recursive, libraryID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var sql = "SELECT collectionID AS id, collectionName AS name FROM collections C "
|
var sql = "SELECT collectionID AS id, collectionName AS name FROM collections C "
|
||||||
+ "WHERE parentCollectionID " + (parent ? '=' + parent : 'IS NULL');
|
+ "WHERE libraryID=? AND parentCollectionID " + (parent ? '=' + parent : 'IS NULL');
|
||||||
if (libraryID) {
|
var children = Zotero.DB.query(sql, [libraryID ? libraryID : 0]);
|
||||||
sql += " AND libraryID=?";
|
|
||||||
var children = Zotero.DB.query(sql, libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!parent) {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
var children = Zotero.DB.query(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!children) {
|
if (!children) {
|
||||||
Zotero.debug('No child collections of collection ' + parent, 5);
|
Zotero.debug('No child collections of collection ' + parent, 5);
|
||||||
|
|
|
@ -29,7 +29,7 @@ Zotero.Duplicates = function (libraryID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!libraryID) {
|
if (!libraryID) {
|
||||||
libraryID = null;
|
libraryID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._libraryID = libraryID;
|
this._libraryID = libraryID;
|
||||||
|
|
|
@ -2309,7 +2309,8 @@ Zotero.Integration.Session.prototype.lookupItems = function(citation, index) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(citationItem.key) {
|
if(citationItem.key) {
|
||||||
zoteroItem = Zotero.Items.getByKey(citationItem.key);
|
// DEBUG: why no library id?
|
||||||
|
zoteroItem = Zotero.Items.getByLibraryAndKey(0, citationItem.key);
|
||||||
} else if(citationItem.itemID) {
|
} else if(citationItem.itemID) {
|
||||||
zoteroItem = Zotero.Items.get(citationItem.itemID);
|
zoteroItem = Zotero.Items.get(citationItem.itemID);
|
||||||
} else if(citationItem.id) {
|
} else if(citationItem.id) {
|
||||||
|
@ -2705,7 +2706,8 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
} else {
|
} else {
|
||||||
for(var itemID in documentData.uncited) {
|
for(var itemID in documentData.uncited) {
|
||||||
// if not yet in item set, add to item set
|
// if not yet in item set, add to item set
|
||||||
var zoteroItem = Zotero.Items.getByKey(itemID);
|
// DEBUG: why no libraryID?
|
||||||
|
var zoteroItem = Zotero.Items.getByLibraryAndKey(0, itemID);
|
||||||
if(!zoteroItem) zoteroItem = Zotero.Items.get(itemID);
|
if(!zoteroItem) zoteroItem = Zotero.Items.get(itemID);
|
||||||
if(zoteroItem) this.uncitedItems[zoteroItem.id] = true;
|
if(zoteroItem) this.uncitedItems[zoteroItem.id] = true;
|
||||||
}
|
}
|
||||||
|
@ -2733,7 +2735,8 @@ Zotero.Integration.Session.prototype.loadBibliographyData = function(json) {
|
||||||
} else {
|
} else {
|
||||||
// old style hash
|
// old style hash
|
||||||
for(var itemID in documentData.custom) {
|
for(var itemID in documentData.custom) {
|
||||||
var zoteroItem = Zotero.Items.getByKey(itemID);
|
// DEBUG: why no libraryID?
|
||||||
|
var zoteroItem = Zotero.Items.getByLibraryAndKey(0, itemID);
|
||||||
if(!zoteroItem) zoteroItem = Zotero.Items.get(itemID);
|
if(!zoteroItem) zoteroItem = Zotero.Items.get(itemID);
|
||||||
if(!zoteroItem) continue;
|
if(!zoteroItem) continue;
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,6 @@ Zotero.ItemTreeView.prototype._setTreeGenerator = function(treebox)
|
||||||
Q.fcall(function () {
|
Q.fcall(function () {
|
||||||
if (coloredTagsRE.test(key)) {
|
if (coloredTagsRE.test(key)) {
|
||||||
let libraryID = self._itemGroup.ref.libraryID;
|
let libraryID = self._itemGroup.ref.libraryID;
|
||||||
libraryID = libraryID ? parseInt(libraryID) : 0;
|
|
||||||
let position = parseInt(key) - 1;
|
let position = parseInt(key) - 1;
|
||||||
return Zotero.Tags.getColorByPosition(libraryID, position)
|
return Zotero.Tags.getColorByPosition(libraryID, position)
|
||||||
.then(function (colorData) {
|
.then(function (colorData) {
|
||||||
|
@ -1038,8 +1037,7 @@ Zotero.ItemTreeView.prototype.getImageSrc = function(row, col)
|
||||||
|
|
||||||
var colorData = [];
|
var colorData = [];
|
||||||
for (let i=0, len=tags.length; i<len; i++) {
|
for (let i=0, len=tags.length; i<len; i++) {
|
||||||
let libraryIDInt = item.libraryIDInt; // TEMP
|
colorData.push(Zotero.Tags.getColor(item.libraryID, tags[i].name));
|
||||||
colorData.push(Zotero.Tags.getColor(libraryIDInt, tags[i].name));
|
|
||||||
}
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
Q.all(colorData)
|
Q.all(colorData)
|
||||||
|
@ -3014,7 +3012,7 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient, dataTransfer) {
|
||||||
var dataType = dragData.dataType;
|
var dataType = dragData.dataType;
|
||||||
var data = dragData.data;
|
var data = dragData.data;
|
||||||
var itemGroup = this.itemGroup;
|
var itemGroup = this.itemGroup;
|
||||||
var targetLibraryID = itemGroup.isWithinGroup() ? itemGroup.ref.libraryID : null;
|
var targetLibraryID = itemGroup.ref.libraryID;
|
||||||
|
|
||||||
if (dataType == 'zotero/item') {
|
if (dataType == 'zotero/item') {
|
||||||
var ids = data;
|
var ids = data;
|
||||||
|
@ -3102,12 +3100,7 @@ Zotero.ItemTreeView.prototype.drop = function(row, orient, dataTransfer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemGroup.isWithinGroup()) {
|
var targetLibraryID = itemGroup.ref.libraryID;
|
||||||
var targetLibraryID = itemGroup.ref.libraryID;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var targetLibraryID = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var sourceItemID = false;
|
var sourceItemID = false;
|
||||||
var parentCollectionID = false;
|
var parentCollectionID = false;
|
||||||
|
|
|
@ -102,6 +102,10 @@ Zotero.Search.prototype._set = function (field, val) {
|
||||||
case 'id':
|
case 'id':
|
||||||
case 'libraryID':
|
case 'libraryID':
|
||||||
case 'key':
|
case 'key':
|
||||||
|
if (field == 'libraryID') {
|
||||||
|
val = Zotero.DataObjectUtilities.checkLibraryID(val);
|
||||||
|
}
|
||||||
|
|
||||||
if (val == this['_' + field]) {
|
if (val == this['_' + field]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +113,9 @@ Zotero.Search.prototype._set = function (field, val) {
|
||||||
if (this._loaded) {
|
if (this._loaded) {
|
||||||
throw new Error("Cannot set " + field + " after object is already loaded");
|
throw new Error("Cannot set " + field + " after object is already loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
//this._checkValue(field, val);
|
//this._checkValue(field, val);
|
||||||
|
|
||||||
this['_' + field] = val;
|
this['_' + field] = val;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -176,15 +182,8 @@ Zotero.Search.prototype.load = function() {
|
||||||
var params = id;
|
var params = id;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sql += "key=?";
|
sql += "key=? AND libraryID=?";
|
||||||
var params = [key];
|
var params = [key, libraryID];
|
||||||
if (libraryID) {
|
|
||||||
sql += " AND libraryID=?";
|
|
||||||
params.push(libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sql += " GROUP BY savedSearchID";
|
sql += " GROUP BY savedSearchID";
|
||||||
var data = Zotero.DB.rowQuery(sql, params);
|
var data = Zotero.DB.rowQuery(sql, params);
|
||||||
|
@ -290,12 +289,12 @@ Zotero.Search.prototype.save = function(fixGaps) {
|
||||||
this._changed.dateModified ?
|
this._changed.dateModified ?
|
||||||
this.dateModified : Zotero.DB.transactionDateTime,
|
this.dateModified : Zotero.DB.transactionDateTime,
|
||||||
Zotero.DB.transactionDateTime,
|
Zotero.DB.transactionDateTime,
|
||||||
this.libraryID ? this.libraryID : this.libraryID,
|
this.libraryID ? this.libraryID : 0,
|
||||||
key
|
key
|
||||||
];
|
];
|
||||||
|
|
||||||
var sql = "REPLACE INTO savedSearches (" + columns.join(', ') + ") VALUES ("
|
var sql = "REPLACE INTO savedSearches (" + columns.join(', ') + ") "
|
||||||
+ placeholders.join(', ') + ")";
|
+ "VALUES (" + placeholders + ")";
|
||||||
var insertID = Zotero.DB.query(sql, sqlValues);
|
var insertID = Zotero.DB.query(sql, sqlValues);
|
||||||
if (!searchID) {
|
if (!searchID) {
|
||||||
searchID = insertID;
|
searchID = insertID;
|
||||||
|
@ -1720,21 +1719,13 @@ Zotero.Searches = new function(){
|
||||||
/**
|
/**
|
||||||
* Returns an array of Zotero.Search objects, ordered by name
|
* Returns an array of Zotero.Search objects, ordered by name
|
||||||
*
|
*
|
||||||
* @param {Integer|null} [libraryID=null]
|
* @param {Integer} [libraryID=0]
|
||||||
*/
|
*/
|
||||||
this.getAll = function (libraryID) {
|
this.getAll = function (libraryID) {
|
||||||
var sql = "SELECT savedSearchID AS id, savedSearchName AS name "
|
var sql = "SELECT savedSearchID AS id, savedSearchName AS name "
|
||||||
+ "FROM savedSearches WHERE libraryID";
|
+ "FROM savedSearches WHERE libraryID=?";
|
||||||
if (libraryID) {
|
|
||||||
sql += "=?";
|
|
||||||
var params = [libraryID];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql += " IS NULL";
|
|
||||||
var params = null;
|
|
||||||
}
|
|
||||||
sql += " ORDER BY name COLLATE NOCASE";
|
sql += " ORDER BY name COLLATE NOCASE";
|
||||||
var rows = Zotero.DB.query(sql, params);
|
var rows = Zotero.DB.query(sql, [libraryID ? libraryID : 0]);
|
||||||
if (!rows) {
|
if (!rows) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,10 +259,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
+ "WHERE libraryID=? AND syncState=?";
|
+ "WHERE libraryID=? AND syncState=?";
|
||||||
var downloadForced = !!Zotero.DB.valueQuery(
|
var downloadForced = !!Zotero.DB.valueQuery(
|
||||||
sql,
|
sql,
|
||||||
[
|
[libraryID, Zotero.Sync.Storage.SYNC_STATE_FORCE_DOWNLOAD]
|
||||||
libraryID == 0 ? null : libraryID,
|
|
||||||
Zotero.Sync.Storage.SYNC_STATE_FORCE_DOWNLOAD
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// If we don't have any forced downloads, we can skip
|
// If we don't have any forced downloads, we can skip
|
||||||
|
@ -414,12 +411,11 @@ Zotero.Sync.Storage = new function () {
|
||||||
// Public methods
|
// Public methods
|
||||||
//
|
//
|
||||||
this.queueItem = function (item, highPriority) {
|
this.queueItem = function (item, highPriority) {
|
||||||
if (item.libraryID) {
|
var library = item.libraryID;
|
||||||
var library = item.libraryID;
|
if (libraryID) {
|
||||||
var mode = Zotero.Sync.Storage.ZFS;
|
var mode = Zotero.Sync.Storage.ZFS;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var library = 0;
|
|
||||||
var mode = Zotero.Sync.Storage.ZFS.includeUserFiles
|
var mode = Zotero.Sync.Storage.ZFS.includeUserFiles
|
||||||
? Zotero.Sync.Storage.ZFS : Zotero.Sync.Storage.WebDAV;
|
? Zotero.Sync.Storage.ZFS : Zotero.Sync.Storage.WebDAV;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +447,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
|
|
||||||
var queue = Zotero.Sync.Storage.QueueManager.get(queue, library);
|
var queue = Zotero.Sync.Storage.QueueManager.get(queue, library);
|
||||||
var request = new Zotero.Sync.Storage.Request(
|
var request = new Zotero.Sync.Storage.Request(
|
||||||
(item.libraryID ? item.libraryID : 0) + '/' + item.key, callbacks
|
item.libraryID + '/' + item.key, callbacks
|
||||||
);
|
);
|
||||||
if (queue.type == 'upload') {
|
if (queue.type == 'upload') {
|
||||||
try {
|
try {
|
||||||
|
@ -653,7 +649,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {NULL|Integer|'groups'} [libraryID]
|
* @param {Integer|'groups'} [libraryID]
|
||||||
*/
|
*/
|
||||||
this.downloadAsNeeded = function (libraryID) {
|
this.downloadAsNeeded = function (libraryID) {
|
||||||
// Personal library
|
// Personal library
|
||||||
|
@ -668,7 +664,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {NULL|Integer|'groups'} [libraryID]
|
* @param {Integer|'groups'} [libraryID]
|
||||||
*/
|
*/
|
||||||
this.downloadOnSync = function (libraryID) {
|
this.downloadOnSync = function (libraryID) {
|
||||||
// Personal library
|
// Personal library
|
||||||
|
@ -768,7 +764,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
);
|
);
|
||||||
if (libraryID !== false) {
|
if (libraryID !== false) {
|
||||||
sql += " AND libraryID=?";
|
sql += " AND libraryID=?";
|
||||||
params.push(libraryID == 0 ? null : libraryID);
|
params.push(libraryID);
|
||||||
}
|
}
|
||||||
if (chunk.length) {
|
if (chunk.length) {
|
||||||
sql += " AND itemID IN (" + chunk.map(function () '?').join() + ")";
|
sql += " AND itemID IN (" + chunk.map(function () '?').join() + ")";
|
||||||
|
@ -1018,10 +1014,6 @@ Zotero.Sync.Storage = new function () {
|
||||||
.then(function () {
|
.then(function () {
|
||||||
// TODO: start sync icon
|
// TODO: start sync icon
|
||||||
var library = item.libraryID;
|
var library = item.libraryID;
|
||||||
if (!library) {
|
|
||||||
library = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
var queue = Zotero.Sync.Storage.QueueManager.get(
|
var queue = Zotero.Sync.Storage.QueueManager.get(
|
||||||
'download', library
|
'download', library
|
||||||
);
|
);
|
||||||
|
@ -1201,7 +1193,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
this.getItemDownloadImageNumber = function (item) {
|
this.getItemDownloadImageNumber = function (item) {
|
||||||
var numImages = 64;
|
var numImages = 64;
|
||||||
|
|
||||||
var lk = (item.libraryID ? item.libraryID : 0) + "/" + item.key;
|
var lk = item.libraryID + "/" + item.key;
|
||||||
|
|
||||||
if (typeof _itemDownloadPercentages[lk] == 'undefined') {
|
if (typeof _itemDownloadPercentages[lk] == 'undefined') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1267,10 +1259,10 @@ Zotero.Sync.Storage = new function () {
|
||||||
//var sql = "UPDATE itemAttachments SET syncState=?, storageModTime=NULL, storageHash=NULL";
|
//var sql = "UPDATE itemAttachments SET syncState=?, storageModTime=NULL, storageHash=NULL";
|
||||||
var sql = "UPDATE itemAttachments SET syncState=?";
|
var sql = "UPDATE itemAttachments SET syncState=?";
|
||||||
if (includeUserFiles && !includeGroupFiles) {
|
if (includeUserFiles && !includeGroupFiles) {
|
||||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID IS NULL)";
|
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID = 0)";
|
||||||
}
|
}
|
||||||
else if (!includeUserFiles && includeGroupFiles) {
|
else if (!includeUserFiles && includeGroupFiles) {
|
||||||
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID IS NOT NULL)";
|
sql += " WHERE itemID IN (SELECT itemID FROM items WHERE libraryID != 0)";
|
||||||
}
|
}
|
||||||
Zotero.DB.query(sql, [syncState]);
|
Zotero.DB.query(sql, [syncState]);
|
||||||
|
|
||||||
|
@ -1880,10 +1872,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
function _getFilesToDownload(libraryID, forcedOnly) {
|
function _getFilesToDownload(libraryID, forcedOnly) {
|
||||||
var sql = "SELECT itemID FROM itemAttachments JOIN items USING (itemID) "
|
var sql = "SELECT itemID FROM itemAttachments JOIN items USING (itemID) "
|
||||||
+ "WHERE libraryID=? AND syncState IN (?";
|
+ "WHERE libraryID=? AND syncState IN (?";
|
||||||
var params = [
|
var params = [libraryID, Zotero.Sync.Storage.SYNC_STATE_FORCE_DOWNLOAD];
|
||||||
libraryID == 0 ? null : libraryID,
|
|
||||||
Zotero.Sync.Storage.SYNC_STATE_FORCE_DOWNLOAD
|
|
||||||
];
|
|
||||||
if (!forcedOnly) {
|
if (!forcedOnly) {
|
||||||
sql += ",?";
|
sql += ",?";
|
||||||
params.push(Zotero.Sync.Storage.SYNC_STATE_TO_DOWNLOAD);
|
params.push(Zotero.Sync.Storage.SYNC_STATE_TO_DOWNLOAD);
|
||||||
|
@ -1916,7 +1905,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
];
|
];
|
||||||
if (typeof libraryID != 'undefined') {
|
if (typeof libraryID != 'undefined') {
|
||||||
sql += " AND libraryID=?";
|
sql += " AND libraryID=?";
|
||||||
params.push(libraryID == 0 ? null : libraryID);
|
params.push(libraryID);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("libraryID not specified");
|
throw new Error("libraryID not specified");
|
||||||
|
@ -1943,7 +1932,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
+ "WHERE libraryID=? AND linkMode IN (?,?) AND syncState IN (?) AND "
|
+ "WHERE libraryID=? AND linkMode IN (?,?) AND syncState IN (?) AND "
|
||||||
+ "storageModTime>=?";
|
+ "storageModTime>=?";
|
||||||
var params = [
|
var params = [
|
||||||
libraryID == 0 ? null : libraryID,
|
libraryID,
|
||||||
Zotero.Attachments.LINK_MODE_IMPORTED_FILE,
|
Zotero.Attachments.LINK_MODE_IMPORTED_FILE,
|
||||||
Zotero.Attachments.LINK_MODE_IMPORTED_URL,
|
Zotero.Attachments.LINK_MODE_IMPORTED_URL,
|
||||||
Zotero.Sync.Storage.SYNC_STATE_IN_SYNC,
|
Zotero.Sync.Storage.SYNC_STATE_IN_SYNC,
|
||||||
|
|
|
@ -1074,7 +1074,7 @@ Zotero.Translate.Base.prototype = {
|
||||||
* translators, but new code should use {@link Zotero.Translate.Base#setHandler} to register a
|
* 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.
|
* "done" handler to determine when execution of web/search translators is complete.
|
||||||
*
|
*
|
||||||
* @param {NULL|Integer|FALSE} [libraryID=null] Library in which to save items,
|
* @param {Integer|FALSE} [libraryID=0] Library in which to save items,
|
||||||
* or NULL for default library;
|
* or NULL for default library;
|
||||||
* if FALSE, don't save items
|
* if FALSE, don't save items
|
||||||
* @param {Boolean} [saveAttachments=true] Exclude attachments (e.g., snapshots) on import
|
* @param {Boolean} [saveAttachments=true] Exclude attachments (e.g., snapshots) on import
|
||||||
|
|
|
@ -83,7 +83,6 @@ Zotero.URI = new function () {
|
||||||
* Get path portion of library URI (e.g., users/6 or groups/1)
|
* Get path portion of library URI (e.g., users/6 or groups/1)
|
||||||
*/
|
*/
|
||||||
this.getLibraryPath = function (libraryID) {
|
this.getLibraryPath = function (libraryID) {
|
||||||
libraryID = libraryID ? parseInt(libraryID) : 0;
|
|
||||||
var libraryType = Zotero.Libraries.getType(libraryID);
|
var libraryType = Zotero.Libraries.getType(libraryID);
|
||||||
|
|
||||||
switch (libraryType) {
|
switch (libraryType) {
|
||||||
|
|
|
@ -761,7 +761,7 @@ var ZoteroPane = new function()
|
||||||
var libraryID = itemGroup.ref.libraryID;
|
var libraryID = itemGroup.ref.libraryID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var libraryID = null;
|
var libraryID = 0;
|
||||||
var itemGroup = null;
|
var itemGroup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,12 +885,12 @@ var ZoteroPane = new function()
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'duplicates':
|
case 'duplicates':
|
||||||
var prefKey = 'duplicateLibraries';
|
var prefKey = 'duplicateLibraries';
|
||||||
var lastViewedFolderID = 'D' + (libraryID ? libraryID : 0);
|
var lastViewedFolderID = 'D' + libraryID;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'unfiled':
|
case 'unfiled':
|
||||||
var prefKey = 'unfiledLibraries';
|
var prefKey = 'unfiledLibraries';
|
||||||
var lastViewedFolderID = 'U' + (libraryID ? libraryID : 0);
|
var lastViewedFolderID = 'U' + libraryID;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -2491,8 +2491,7 @@ var ZoteroPane = new function()
|
||||||
// on a library sync error icon
|
// on a library sync error icon
|
||||||
if (itemGroup.isLibrary(true)) {
|
if (itemGroup.isLibrary(true)) {
|
||||||
if (col.value.id == 'zotero-collections-sync-status-column') {
|
if (col.value.id == 'zotero-collections-sync-status-column') {
|
||||||
var libraryID = itemGroup.isLibrary() ? 0 : itemGroup.ref.libraryID;
|
var errors = Zotero.Sync.Runner.getErrors(itemGroup.ref.libraryID);
|
||||||
var errors = Zotero.Sync.Runner.getErrors(libraryID);
|
|
||||||
if (errors) {
|
if (errors) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
return;
|
return;
|
||||||
|
@ -2569,8 +2568,7 @@ var ZoteroPane = new function()
|
||||||
// sync error icon
|
// sync error icon
|
||||||
if (itemGroup.isLibrary(true)) {
|
if (itemGroup.isLibrary(true)) {
|
||||||
if (col.value.id == 'zotero-collections-sync-status-column') {
|
if (col.value.id == 'zotero-collections-sync-status-column') {
|
||||||
var libraryID = itemGroup.isLibrary() ? 0 : itemGroup.ref.libraryID;
|
var errors = Zotero.Sync.Runner.getErrors(itemGroup.ref.libraryID);
|
||||||
var errors = Zotero.Sync.Runner.getErrors(libraryID);
|
|
||||||
if (!errors) {
|
if (!errors) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3195,7 +3193,7 @@ var ZoteroPane = new function()
|
||||||
var libraryID = itemGroup.ref.libraryID;
|
var libraryID = itemGroup.ref.libraryID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var libraryID = null;
|
var libraryID = 0;
|
||||||
var itemGroup = null;
|
var itemGroup = null;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -3317,7 +3315,7 @@ var ZoteroPane = new function()
|
||||||
var libraryID = itemGroup.ref.libraryID;
|
var libraryID = itemGroup.ref.libraryID;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var libraryID = null;
|
var libraryID = 0;
|
||||||
var itemGroup = null;
|
var itemGroup = null;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
|
@ -156,13 +156,8 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
|
||||||
fromSQL += ")";
|
fromSQL += ")";
|
||||||
}
|
}
|
||||||
if (typeof searchParams.libraryID != 'undefined') {
|
if (typeof searchParams.libraryID != 'undefined') {
|
||||||
if (searchParams.libraryID) {
|
fromSQL += " AND libraryID=?";
|
||||||
fromSQL += " AND libraryID=?";
|
sqlParams.push(searchParams.libraryID);
|
||||||
sqlParams.push(searchParams.libraryID);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fromSQL += " AND libraryID IS NULL";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sql += fromSQL;
|
sql += fromSQL;
|
||||||
|
|
|
@ -696,7 +696,7 @@ function ChromeExtensionHandler() {
|
||||||
default:
|
default:
|
||||||
type = 'library';
|
type = 'library';
|
||||||
var s = new Zotero.Search();
|
var s = new Zotero.Search();
|
||||||
s.addCondition('libraryID', 'is', id ? id : null);
|
s.addCondition('libraryID', 'is', id ? id : 0);
|
||||||
s.addCondition('noChildren', 'true');
|
s.addCondition('noChildren', 'true');
|
||||||
var ids = s.search();
|
var ids = s.search();
|
||||||
var results = Zotero.Items.get(ids);
|
var results = Zotero.Items.get(ids);
|
||||||
|
|
|
@ -61,6 +61,7 @@ const xpcomFilesLocal = [
|
||||||
'cookieSandbox',
|
'cookieSandbox',
|
||||||
'data_access',
|
'data_access',
|
||||||
'data/dataObjects',
|
'data/dataObjects',
|
||||||
|
'data/dataObjectUtilities',
|
||||||
'data/cachedTypes',
|
'data/cachedTypes',
|
||||||
'data/item',
|
'data/item',
|
||||||
'data/items',
|
'data/items',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue