summaryrefslogtreecommitdiff
path: root/src/node/db/Pad.js
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2012-06-27 18:23:17 +0200
committerMarcel Klehr <mklehr@gmx.net>2012-06-27 18:23:17 +0200
commit6f9d7a5db79076747584ebd289bf380b2bb95038 (patch)
treec0703fee5c77bcc445e14a060bd5b48cd68e13ea /src/node/db/Pad.js
parent0bc01feb72f116c95faafd78df2eb87b6fae3143 (diff)
downloadetherpad-lite-6f9d7a5db79076747584ebd289bf380b2bb95038.zip
Add 2 new APIs: listPadsOfAuthor and listAuthorsOfPad
Return all pads that a given author has contributed to (not just created) and return all authors who has contributed to a given pad.
Diffstat (limited to 'src/node/db/Pad.js')
-rw-r--r--src/node/db/Pad.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js
index b4a39c17..5e005606 100644
--- a/src/node/db/Pad.js
+++ b/src/node/db/Pad.js
@@ -82,6 +82,10 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
db.set("pad:"+this.id+":revs:"+newRev, newRevData);
this.saveToDatabase();
+
+ // set the author to pad
+ if(author != '')
+ authorManager.addPad(author, this.id);
};
//save all attributes to the database
@@ -437,6 +441,18 @@ Pad.prototype.remove = function remove(callback) {
}
callback();
+ },
+ //remove pad from all authors who contributed
+ function(callback)
+ {
+ var authorIDs = _this.getAllAuthors();
+
+ authorIDs.forEach(function (authorID)
+ {
+ authorManager.removePad(authorID, padID);
+ });
+
+ callback();
}
], callback);
},