Store inter-group linked-item relations with target, not source, library

User may not have write access to source library
This commit is contained in:
Dan Stillman 2013-10-28 23:35:28 -04:00
parent d76a395a38
commit 05fef08a63
4 changed files with 9 additions and 6 deletions

View File

@ -1251,7 +1251,7 @@ Zotero.Attachments = new function(){
Zotero.File.copyDirectory(dir, newDir);
}
attachment.addLinkedItem(newAttachment);
newAttachment.addLinkedItem(attachment);
return newAttachment.id;
}

View File

@ -1429,7 +1429,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
//var newItem = Zotero.Items.get(id);
// Record link
item.addLinkedItem(newItem);
newItem.addLinkedItem(item);
var newID = id;
if (item.isNote()) {
@ -1452,7 +1452,7 @@ Zotero.CollectionTreeView.prototype.drop = function(row, orient)
newNote.setSource(newItem.id);
newNote.save();
note.addLinkedItem(newNote);
newNote.addLinkedItem(note);
}
}

View File

@ -4006,9 +4006,10 @@ Zotero.Item.prototype.addLinkedItem = function (item) {
return false;
}
// If both group libraries, store relation with source group.
// Otherwise, store with personal library.
var libraryID = (this.libraryID && item.libraryID) ? this.libraryID : null;
// 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) ? null : this.libraryID;
Zotero.Relations.add(libraryID, url1, predicate, url2);
}

View File

@ -158,6 +158,8 @@ Zotero.Relation.prototype.save = function () {
throw ("Missing object in Zotero.Relation.save()");
}
Zotero.Relations.editCheck(this);
var sql = "INSERT INTO relations "
+ "(libraryID, subject, predicate, object, clientDateModified) "
+ "VALUES (?, ?, ?, ?, ?)";