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