mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closes #4344
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
if (properties) {
|
||||
if ((properties.loggedIn && !data.config.loggedIn) ||
|
||||
(properties.globalMod && !data.isGlobalMod && !data.isAdmin) ||
|
||||
(properties.adminOnly && !data.isAdmin) ||
|
||||
(properties.installed && properties.installed.search && !data.searchEnabled)) {
|
||||
return false;
|
||||
|
||||
@@ -68,21 +68,14 @@ module.exports = function(app, middleware) {
|
||||
|
||||
async.parallel({
|
||||
scripts: function(next) {
|
||||
plugins.fireHook('filter:scripts.get', [], function(err, scripts) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var arr = [];
|
||||
scripts.forEach(function(script) {
|
||||
arr.push({src: script});
|
||||
});
|
||||
|
||||
next(null, arr);
|
||||
});
|
||||
plugins.fireHook('filter:scripts.get', [], next);
|
||||
},
|
||||
isAdmin: function(next) {
|
||||
user.isAdministrator(req.uid, next);
|
||||
},
|
||||
isGlobalMod: function(next) {
|
||||
user.isGlobalModerator(req.uid, next);
|
||||
},
|
||||
user: function(next) {
|
||||
if (req.uid) {
|
||||
user.getUserFields(req.uid, ['username', 'userslug', 'email', 'picture', 'status', 'email:confirmed', 'banned'], next);
|
||||
@@ -110,6 +103,7 @@ module.exports = function(app, middleware) {
|
||||
}
|
||||
|
||||
results.user.isAdmin = results.isAdmin;
|
||||
results.user.isGlobalMod = results.isGlobalMod;
|
||||
results.user.uid = parseInt(results.user.uid, 10);
|
||||
results.user['email:confirmed'] = parseInt(results.user['email:confirmed'], 10) === 1;
|
||||
|
||||
@@ -122,6 +116,7 @@ module.exports = function(app, middleware) {
|
||||
templateValues.metaTags = results.tags.meta;
|
||||
templateValues.linkTags = results.tags.link;
|
||||
templateValues.isAdmin = results.user.isAdmin;
|
||||
templateValues.isGlobalMod = results.user.isGlobalMod;
|
||||
templateValues.user = results.user;
|
||||
templateValues.userJSON = JSON.stringify(results.user);
|
||||
templateValues.useCustomCSS = parseInt(meta.config.useCustomCSS, 10) === 1 && meta.config.customCSS;
|
||||
@@ -136,7 +131,9 @@ module.exports = function(app, middleware) {
|
||||
templateValues.template = {name: res.locals.template};
|
||||
templateValues.template[res.locals.template] = true;
|
||||
|
||||
templateValues.scripts = results.scripts;
|
||||
templateValues.scripts = results.scripts.map(function(script) {
|
||||
return {src: script};
|
||||
});
|
||||
|
||||
if (req.route && req.route.path === '/') {
|
||||
modifyTitle(templateValues);
|
||||
|
||||
@@ -66,6 +66,12 @@
|
||||
<span class="mdl-switch__label"><strong>Only display to Admins</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" name="property:globalMod" <!-- IF enabled.properties.globalMod -->checked<!-- ENDIF enabled.properties.globalMod -->/>
|
||||
<span class="mdl-switch__label"><strong>Only display to Global Moderators and Admins</strong></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||
<input class="mdl-switch__input" type="checkbox" name="property:loggedIn" <!-- IF enabled.properties.loggedIn -->checked<!-- ENDIF enabled.properties.loggedIn -->/> <span class="mdl-switch__label"><strong>Only display to logged in users</strong></span>
|
||||
|
||||
Reference in New Issue
Block a user