newswriter
Version:
NewsWriter is a generic tool for maintaining news and announcements on a website news page. Details are held in an SQLite database, from which the tool generates the index page (typically the top page of the target site), individual pages for events and a
35 lines (29 loc) • 1.08 kB
JavaScript
(function () {
var cogClass = function () {};
cogClass.prototype.exec = function (params, request, response) {
var oops = this.sys.apiError;
var sys = this.sys;
var eventID = params.eventid;
var data = {
eventID:eventID
};
checkEvent();
function checkEvent() {
var sql = 'SELECT status FROM events WHERE eventID=?;';
sys.db.get(sql,[eventID],function(err,row){
if (err||!row) {return oops(response,err,'confirmevent(1)')};
data.status = 1;
restoreEvent();
});
}
function restoreEvent () {
var sql = 'UPDATE events SET status=1 WHERE eventID=?;';
sys.db.run(sql,[eventID],function(err){
if (err) {return oops(response,err,'confirmevent(2)')};
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(JSON.stringify(data));
});
};
}
exports.cogClass = cogClass;
})();