From 64a3d60b943bdf7ae643f3fcb5791ffbc95b77ae Mon Sep 17 00:00:00 2001 From: d-a-n Date: Tue, 2 Oct 2012 22:30:13 +0300 Subject: [PATCH] Added pad hooks (create, load, edit, remove) --- src/node/db/Pad.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index ad2d59f38..cf04f9bc0 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -16,6 +16,7 @@ var padMessageHandler = require("../handler/PadMessageHandler"); var readOnlyManager = require("./ReadOnlyManager"); var crypto = require("crypto"); var randomString = require("../utils/randomstring"); +var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); //serialization/deserialization attributes var attributeBlackList = ["id"]; @@ -86,6 +87,12 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) { // set the author to pad if(author) authorManager.addPad(author, this.id); + + if (this.head == 0) { + hooks.callAll("padCreated", this); + } else { + hooks.callAll("padUpdated", this); + } }; //save all attributes to the database @@ -368,6 +375,7 @@ Pad.prototype.init = function init(text, callback) { _this.appendRevision(firstChangeset, ''); } + hooks.callAll("padLoaded", _this); callback(null); }); }; @@ -467,6 +475,7 @@ Pad.prototype.remove = function remove(callback) { { db.remove("pad:"+padID); padManager.unloadPad(padID); + hooks.callAll("padRemoved", padID ); callback(); } ], function(err)