Merge branch 'master' of github.com:nodebb/NodeBB

v1.18.x
Julian Lam 10 years ago
commit 4984f2f449

@ -323,7 +323,7 @@ function resetThemes(callback) {
function resetPlugin(pluginId) { function resetPlugin(pluginId) {
var db = require('./src/database'); var db = require('./src/database');
db.setRemove('plugins:active', pluginId, function(err) { db.sortedSetRemove('plugins:active', pluginId, function(err) {
if (err) { if (err) {
winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message); winston.error('[reset] Could not disable plugin: %s encountered error %s', pluginId, err.message);
} else { } else {

@ -24,6 +24,7 @@
"email-taken": "Email taken", "email-taken": "Email taken",
"email-not-confirmed": "Your email has not been confirmed yet, please click here to confirm your email.", "email-not-confirmed": "Your email has not been confirmed yet, please click here to confirm your email.",
"email-not-confirmed-chat": "You are unable to chat until your email is confirmed", "email-not-confirmed-chat": "You are unable to chat until your email is confirmed",
"no-email-to-confirm": "This forum requires email confirmation, please click here to enter an email",
"username-too-short": "Username too short", "username-too-short": "Username too short",
"username-too-long": "Username too long", "username-too-long": "Username too long",

@ -11,50 +11,48 @@ define('admin/extend/rewards', function() {
conditionals; conditionals;
rewards.init = function() { rewards.init = function() {
$(window).on('action:ajaxify.end', function() { available = JSON.parse(ajaxify.variables.get('rewards'));
available = JSON.parse(ajaxify.variables.get('rewards')); active = JSON.parse(ajaxify.variables.get('active'));
active = JSON.parse(ajaxify.variables.get('active')); conditions = JSON.parse(ajaxify.variables.get('conditions'));
conditions = JSON.parse(ajaxify.variables.get('conditions')); conditionals = JSON.parse(ajaxify.variables.get('conditionals'));
conditionals = JSON.parse(ajaxify.variables.get('conditionals'));
$('[data-selected]').each(function() {
$('[data-selected]').each(function() { select($(this));
select($(this)); });
});
$('#active') $('#active')
.on('change', '[data-selected]', function() { .on('change', '[data-selected]', function() {
update($(this)); update($(this));
}) })
.on('click', '.delete', function() { .on('click', '.delete', function() {
var parent = $(this).parents('[data-id]'), var parent = $(this).parents('[data-id]'),
id = parent.attr('data-id'); id = parent.attr('data-id');
socket.emit('admin.rewards.delete', {id: id}, function(err) { socket.emit('admin.rewards.delete', {id: id}, function(err) {
if (err) { if (err) {
app.alertError(err.message); app.alertError(err.message);
} else { } else {
app.alertSuccess('Successfully deleted reward'); app.alertSuccess('Successfully deleted reward');
} }
});
parent.remove();
return false;
})
.on('click', '.toggle', function() {
var btn = $(this),
disabled = btn.html() === 'Enable',
id = $(this).parents('[data-id]').attr('data-id');
btn.toggleClass('btn-warning').toggleClass('btn-success').html(disabled ? 'Enable' : 'Disable');
// send disable api call
return false;
}); });
$('#new').on('click', newReward); parent.remove();
$('#save').on('click', saveRewards); return false;
})
.on('click', '.toggle', function() {
var btn = $(this),
disabled = btn.html() === 'Enable',
id = $(this).parents('[data-id]').attr('data-id');
btn.toggleClass('btn-warning').toggleClass('btn-success').html(disabled ? 'Enable' : 'Disable');
// send disable api call
return false;
});
populateInputs(); $('#new').on('click', newReward);
}); $('#save').on('click', saveRewards);
populateInputs();
}; };
function select(el) { function select(el) {

@ -570,7 +570,21 @@ app.cacheBuster = null;
}; };
function showEmailConfirmWarning() { function showEmailConfirmWarning() {
if (config.requireEmailConfirmation && app.user.uid && !app.user['email:confirmed']) { if (!config.requireEmailConfirmation || !app.user.uid) {
return;
}
if (!app.user.email) {
app.alert({
alert_id: 'email_confirm',
message: '[[error:no-email-to-confirm]]',
type: 'warning',
timeout: 0,
clickfn: function() {
app.removeAlert('email_confirm');
ajaxify.go('user/' + app.user.userslug + '/edit');
}
});
} else if (!app.user['email:confirmed']) {
app.alert({ app.alert({
alert_id: 'email_confirm', alert_id: 'email_confirm',
message: '[[error:email-not-confirmed]]', message: '[[error:email-not-confirmed]]',

@ -426,7 +426,10 @@ function enableDefaultPlugins(next) {
'nodebb-plugin-soundpack-default' 'nodebb-plugin-soundpack-default'
]; ];
var db = require('./database'); var db = require('./database');
db.setAdd('plugins:active', defaultEnabled, next); var order = defaultEnabled.map(function(plugin, index) {
return index;
});
db.sortedSetAdd('plugins:active', order, defaultEnabled, next);
} }
function setCopyrightWidget(next) { function setCopyrightWidget(next) {

@ -40,13 +40,14 @@ middleware.buildHeader = function(req, res, next) {
'authentication': [] 'authentication': []
}; };
user.getUserFields(uid, ['username', 'userslug', 'picture', 'email:confirmed'], function(err, userData) { user.getUserFields(uid, ['username', 'userslug', 'email', 'picture', 'email:confirmed'], function(err, userData) {
if (err) { if (err) {
return next(err); return next(err);
} }
userData.uid = uid; userData.uid = uid;
userData['email:confirmed'] = parseInt(userData['email:confirmed'], 10) === 1;
async.parallel({ async.parallel({
scripts: function(next) { scripts: function(next) {
plugins.fireHook('filter:admin.scripts.get', [], function(err, scripts) { plugins.fireHook('filter:admin.scripts.get', [], function(err, scripts) {
@ -72,16 +73,15 @@ middleware.buildHeader = function(req, res, next) {
return next(err); return next(err);
} }
res.locals.config = results.config; res.locals.config = results.config;
var data = { var data = {
relative_path: nconf.get('relative_path'), relative_path: nconf.get('relative_path'),
configJSON: JSON.stringify(results.config), configJSON: JSON.stringify(results.config),
user: userData,
userJSON: JSON.stringify(userData), userJSON: JSON.stringify(userData),
plugins: results.custom_header.plugins, plugins: results.custom_header.plugins,
authentication: results.custom_header.authentication, authentication: results.custom_header.authentication,
scripts: results.scripts, scripts: results.scripts,
userpicture: userData.picture,
username: userData.username,
userslug: userData.userslug,
'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '', 'cache-buster': meta.config['cache-buster'] ? 'v=' + meta.config['cache-buster'] : '',
env: process.env.NODE_ENV ? true : false env: process.env.NODE_ENV ? true : false
}; };

@ -318,7 +318,7 @@ middleware.renderHeader = function(req, res, callback) {
}, },
user: function(next) { user: function(next) {
if (uid) { if (uid) {
user.getUserFields(uid, ['username', 'userslug', 'picture', 'status', 'email:confirmed', 'banned'], next); user.getUserFields(uid, ['username', 'userslug', 'email', 'picture', 'status', 'email:confirmed', 'banned'], next);
} else { } else {
next(null, { next(null, {
username: '[[global:guest]]', username: '[[global:guest]]',
@ -343,7 +343,7 @@ middleware.renderHeader = function(req, res, callback) {
results.user.isAdmin = results.isAdmin || false; results.user.isAdmin = results.isAdmin || false;
results.user.uid = parseInt(results.user.uid, 10); results.user.uid = parseInt(results.user.uid, 10);
results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1; results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1;
templateValues.browserTitle = results.title; templateValues.browserTitle = results.title;
templateValues.isAdmin = results.user.isAdmin; templateValues.isAdmin = results.user.isAdmin;
templateValues.user = results.user; templateValues.user = results.user;

@ -92,13 +92,12 @@ var fs = require('fs'),
Plugins.clientScripts.length = 0; Plugins.clientScripts.length = 0;
Plugins.libraryPaths.length = 0; Plugins.libraryPaths.length = 0;
// Read the list of activated plugins and require their libraries
async.waterfall([ async.waterfall([
function(next) { function(next) {
db.getSetMembers('plugins:active', next); db.getSortedSetRange('plugins:active', 0, -1, next);
}, },
function(plugins, next) { function(plugins, next) {
if (!plugins || !Array.isArray(plugins)) { if (!Array.isArray(plugins)) {
return next(); return next();
} }

@ -38,7 +38,16 @@ module.exports = function(Plugins) {
}, },
function(_isActive, next) { function(_isActive, next) {
isActive = _isActive; isActive = _isActive;
db[isActive ? 'setRemove' : 'setAdd']('plugins:active', id, next); if (isActive) {
db.sortedSetRemove('plugins:active', id, next);
} else {
db.sortedSetCard('plugins:active', function(err, count) {
if (err) {
return next(err);
}
db.sortedSetAdd('plugins:active', count, id, next);
});
}
}, },
function(next) { function(next) {
meta.reloadRequired = true; meta.reloadRequired = true;
@ -119,6 +128,6 @@ module.exports = function(Plugins) {
}; };
Plugins.isActive = function(id, callback) { Plugins.isActive = function(id, callback) {
db.isSetMember('plugins:active', id, callback); db.isSortedSetMember('plugins:active', id, callback);
}; };
}; };

@ -21,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate, schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
latestSchema = Date.UTC(2015, 1, 17); latestSchema = Date.UTC(2015, 1, 24);
Upgrade.check = function(callback) { Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) { db.get('schemaDate', function(err, value) {
@ -859,10 +859,65 @@ Upgrade.upgrade = function(callback) {
winston.info('[2015/02/17] renaming home.tpl to categories.tpl skipped'); winston.info('[2015/02/17] renaming home.tpl to categories.tpl skipped');
next(); next();
} }
},
function(next) {
thisSchemaDate = Date.UTC(2015, 1, 23);
if (schemaDate < thisSchemaDate) {
db.setAdd('plugins:active', 'nodebb-rewards-essentials', function(err) {
winston.info('[2015/2/23] Activating NodeBB Essential Rewards');
Plugins.reload(function() {
if (err) {
next(err);
} else {
Upgrade.update(thisSchemaDate, next);
}
});
});
} else {
winston.info('[2015/2/23] Activating NodeBB Essential Rewards - skipped');
next();
}
},
function(next) {
thisSchemaDate = Date.UTC(2015, 1, 24);
if (schemaDate < thisSchemaDate) {
updatesMade = true;
winston.info('[2015/02/24] Upgrading plugins:active to sorted set');
db.getSetMembers('plugins:active', function(err, activePlugins) {
if (err) {
return next(err);
}
if (!Array.isArray(activePlugins) || !activePlugins.length) {
winston.info('[2015/02/24] Upgrading plugins:active to sorted set done');
Upgrade.update(thisSchemaDate, next);
}
db.delete('plugins:active', function(err) {
if (err) {
return next(err);
}
var order = -1;
async.eachSeries(activePlugins, function(plugin, next) {
++order;
db.sortedSetAdd('plugins:active', order, plugin, next);
}, function(err) {
if (err) {
return next(err);
}
winston.info('[2015/02/24] Upgrading plugins:active to sorted set done');
Upgrade.update(thisSchemaDate, next);
});
});
});
} else {
winston.info('[2015/02/24] Upgrading plugins:active to sorted set skipped');
next();
}
} }
// Add new schema updates here // Add new schema updates here
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 22!!! // IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema IN LINE 24!!!
], function(err) { ], function(err) {
if (!err) { if (!err) {
if(updatesMade) { if(updatesMade) {

@ -85,11 +85,11 @@
</li> </li>
<li id="user_label" class="dropdown pull-right"> <li id="user_label" class="dropdown pull-right">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" id="user_dropdown"> <a class="dropdown-toggle" data-toggle="dropdown" href="#" id="user_dropdown">
<img src="{userpicture}"/> <img src="{user.picture}"/>
</a> </a>
<ul id="user-control-list" class="dropdown-menu" aria-labelledby="user_dropdown"> <ul id="user-control-list" class="dropdown-menu" aria-labelledby="user_dropdown">
<li> <li>
<a id="user-profile-link" href="{relative_path}/user/{userslug}" target="_top"><span>Profile</span></a> <a id="user-profile-link" href="{relative_path}/user/{user.userslug}" target="_top"><span>Profile</span></a>
</li> </li>
<li id="logout-link"> <li id="logout-link">
<a href="#">Log out</a> <a href="#">Log out</a>

Loading…
Cancel
Save