Skip to content

Node.js based forum software built for the modern web

Merge branch 'plugins' of github.com:designcreateplay/NodeBB into plugins

Julian Lamc2d7bf87e9d9
diff --cc src/plugins.js
index f512c6a270,829bb7412f..1995f08dd8
--- a/src/plugins.js
+++ b/src/plugins.js
@@@ -117,35 -109,15 +117,39 @@@ var fs = require('fs')
// Do nothing...
break;
}
+ } else {
+ // Otherwise, this hook contains no methods
+ var returnVal = (Array.isArray(args) ? args[0] : args);
+ if (callback) callback(returnVal);
}
},
- showInstalled: function() {
+ isActive: function(id, callback) {
+ RDB.sismember('plugins:active', id, callback);
+ },
+ toggleActive: function(id, callback) {
+ this.isActive(id, function(err, active) {
+ if (err) {
+ if (global.env === 'development') console.log('Info: [plugins] Could not toggle active state on plugin \'' + id + '\'');
+ return;
+ }
+
+ RDB[(active ? 'srem' : 'sadd')]('plugins:active', id, function(err, success) {
+ if (err) {
+ if (global.env === 'development') console.log('Info: [plugins] Could not toggle active state on plugin \'' + id + '\'');
+ return;
+ }
+
+ callback({
+ id: id,
+ active: !active
+ });
+ });
+ });
+ },
+ showInstalled: function(callback) {
// TODO: Also check /node_modules
- var moduleBasePath = path.join(__dirname, '../plugins');
+ var _self = this;
+ moduleBasePath = path.join(__dirname, '../plugins');
async.waterfall([
function(next) {