www

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

commit 05fef08a6378a7dde1ca8320e268f7a2d8323517
parent d76a395a3853ea0fc8be40590f7852fd8a9986f3
Author: Dan Stillman <dstillman@zotero.org>
Date:   Mon, 28 Oct 2013 23:35:28 -0400

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

User may not have write access to source library

Diffstat:
Mchrome/content/zotero/xpcom/attachments.js | 2+-
Mchrome/content/zotero/xpcom/collectionTreeView.js | 4++--
Mchrome/content/zotero/xpcom/data/item.js | 7++++---
Mchrome/content/zotero/xpcom/data/relation.js | 2++
4 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js @@ -1251,7 +1251,7 @@ Zotero.Attachments = new function(){ Zotero.File.copyDirectory(dir, newDir); } - attachment.addLinkedItem(newAttachment); + newAttachment.addLinkedItem(attachment); return newAttachment.id; } diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -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); } } diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js @@ -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); } diff --git a/chrome/content/zotero/xpcom/data/relation.js b/chrome/content/zotero/xpcom/data/relation.js @@ -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 (?, ?, ?, ?, ?)";