mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-22 08:20:36 +01:00
show admin link in header if user is admin, closes #459
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
"logout": "Logout",
|
"logout": "Logout",
|
||||||
"logout.title": "You are now logged out.",
|
"logout.title": "You are now logged out.",
|
||||||
"logout.message": "You have successfully logged out of NodeBB",
|
"logout.message": "You have successfully logged out of NodeBB",
|
||||||
|
"header.admin": "Admin",
|
||||||
"header.recent": "Recent",
|
"header.recent": "Recent",
|
||||||
"header.unread": "Unread",
|
"header.unread": "Unread",
|
||||||
"header.users": "Users",
|
"header.users": "Users",
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ var ajaxify = {};
|
|||||||
|
|
||||||
window.onpopstate = function (event) {
|
window.onpopstate = function (event) {
|
||||||
// "quiet": If set to true, will not call pushState
|
// "quiet": If set to true, will not call pushState
|
||||||
if (event !== null && event.state && event.state.url !== undefined) ajaxify.go(event.state.url, null, null, true);
|
if (event !== null && event.state && event.state.url !== undefined)
|
||||||
|
ajaxify.go(event.state.url, null, null, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
var pagination;
|
var pagination;
|
||||||
|
|||||||
@@ -62,6 +62,10 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="/users">[[global:header.users]]</a>
|
<a href="/users">[[global:header.users]]</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="{adminDisplay}">
|
||||||
|
|
||||||
|
<a href="/admin"><i class="icon-cogs"></i> [[global:header.admin]]</a>
|
||||||
|
</li>
|
||||||
<li class="visible-xs">
|
<li class="visible-xs">
|
||||||
<a href="/search">[[global:header.search]]</a>
|
<a href="/search">[[global:header.search]]</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -85,9 +85,20 @@ var express = require('express'),
|
|||||||
navigation: custom_header.navigation
|
navigation: custom_header.navigation
|
||||||
};
|
};
|
||||||
|
|
||||||
translator.translate(templates.header.parse(templateValues), function(template) {
|
var uid = '0';
|
||||||
callback(null, template);
|
|
||||||
});
|
if(options.req.user && options.req.user.uid)
|
||||||
|
uid = options.req.user.uid;
|
||||||
|
|
||||||
|
user.isAdministrator(uid, function(isAdmin) {
|
||||||
|
templateValues.adminDisplay = isAdmin ? 'show' : 'hide';
|
||||||
|
|
||||||
|
translator.translate(templates.header.parse(templateValues), function(template) {
|
||||||
|
callback(null, template);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user