Skip to content

Node.js based forum software built for the modern web

closes #4344

barisusaklic156d1cb34fb
diff --git a/public/src/modules/helpers.js b/public/src/modules/helpers.js
index 38737ceaa1..cd5c27734d 100644
--- a/public/src/modules/helpers.js
+++ b/public/src/modules/helpers.js
@@ -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;
diff --git a/src/middleware/header.js b/src/middleware/header.js
index c2149c16d1..5d981ffeda 100644
--- a/src/middleware/header.js
+++ b/src/middleware/header.js
@@ -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);
diff --git a/src/views/admin/general/navigation.tpl b/src/views/admin/general/navigation.tpl
index 2fdf04560c..116a0fd0f5 100644
--- a/src/views/admin/general/navigation.tpl
+++ b/src/views/admin/general/navigation.tpl
@@ -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>