Added pad hooks (create, load, edit, remove)

pull/1034/head
d-a-n 2012-10-02 22:30:13 +03:00
parent c0f2e557d3
commit 64a3d60b94
1 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,7 @@ var padMessageHandler = require("../handler/PadMessageHandler");
var readOnlyManager = require("./ReadOnlyManager"); var readOnlyManager = require("./ReadOnlyManager");
var crypto = require("crypto"); var crypto = require("crypto");
var randomString = require("../utils/randomstring"); var randomString = require("../utils/randomstring");
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
//serialization/deserialization attributes //serialization/deserialization attributes
var attributeBlackList = ["id"]; var attributeBlackList = ["id"];
@ -86,6 +87,12 @@ Pad.prototype.appendRevision = function appendRevision(aChangeset, author) {
// set the author to pad // set the author to pad
if(author) if(author)
authorManager.addPad(author, this.id); authorManager.addPad(author, this.id);
if (this.head == 0) {
hooks.callAll("padCreated", this);
} else {
hooks.callAll("padUpdated", this);
}
}; };
//save all attributes to the database //save all attributes to the database
@ -368,6 +375,7 @@ Pad.prototype.init = function init(text, callback) {
_this.appendRevision(firstChangeset, ''); _this.appendRevision(firstChangeset, '');
} }
hooks.callAll("padLoaded", _this);
callback(null); callback(null);
}); });
}; };
@ -467,6 +475,7 @@ Pad.prototype.remove = function remove(callback) {
{ {
db.remove("pad:"+padID); db.remove("pad:"+padID);
padManager.unloadPad(padID); padManager.unloadPad(padID);
hooks.callAll("padRemoved", padID );
callback(); callback();
} }
], function(err) ], function(err)