feat(acp): added new admin privilege for groups management

v1.18.x
Julian Lam 4 years ago
parent 3959a7bd9c
commit da191341e8

@ -39,6 +39,7 @@
"admin-categories": "Categories",
"admin-privileges": "Privileges",
"admin-users": "Users",
"admin-groups": "Groups",
"admin-settings": "Settings",
"alert.confirm-moderate": "<strong>Are you sure you wish to grant the moderation privilege to this user group?</strong> This group is public, and any users can join at will.",

@ -42,6 +42,8 @@ adminController.routeIndex = async (req, res) => {
return helpers.redirect(res, 'admin/manage/privileges');
} else if (privilegeSet['admin:users']) {
return helpers.redirect(res, 'admin/manage/users');
} else if (privilegeSet['admin:groups']) {
return helpers.redirect(res, 'admin/manage/groups');
} else if (privilegeSet['admin:settings']) {
return helpers.redirect(res, 'admin/settings/general');
}

@ -73,7 +73,7 @@ middleware.renderHeader = async (req, res, data) => {
version: version,
latestVersion: results.latestVersion,
upgradeAvailable: results.latestVersion && semver.gt(results.latestVersion, version),
showManageMenu: results.privileges.superadmin || ['categories', 'privileges', 'users', 'settings'].some(priv => results.privileges[`admin:${priv}`]),
showManageMenu: results.privileges.superadmin || ['categories', 'privileges', 'users', 'groups', 'settings'].some(priv => results.privileges[`admin:${priv}`]),
};
templateValues.template = { name: res.locals.template };

@ -17,6 +17,7 @@ module.exports = function (privileges) {
{ name: '[[admin/manage/privileges:admin-categories]]' },
{ name: '[[admin/manage/privileges:admin-privileges]]' },
{ name: '[[admin/manage/privileges:admin-users]]' },
{ name: '[[admin/manage/privileges:admin-groups]]' },
{ name: '[[admin/manage/privileges:admin-settings]]' },
];
@ -25,6 +26,7 @@ module.exports = function (privileges) {
'admin:categories',
'admin:privileges',
'admin:users',
'admin:groups',
'admin:settings',
];
@ -36,6 +38,7 @@ module.exports = function (privileges) {
'manage/categories': 'admin:categories',
'manage/privileges': 'admin:privileges',
'manage/users': 'admin:users',
'manage/groups': 'admin:groups',
'extend/plugins': 'admin:settings',
'extend/widgets': 'admin:settings',
'extend/rewards': 'admin:settings',
@ -43,6 +46,7 @@ module.exports = function (privileges) {
privileges.admin.routeRegexpMap = {
'^manage/categories/\\d+': 'admin:categories',
'^manage/privileges/(\\d+|admin)': 'admin:privileges',
'^manage/groups/.+$': 'admin:groups',
'^settings/[\\w\\-]+$': 'admin:settings',
'^appearance/[\\w]+$': 'admin:settings',
'^plugins/[\\w\\-]+$': 'admin:settings',
@ -138,7 +142,7 @@ module.exports = function (privileges) {
payload.keys = keys;
// This is a hack because I can't do {labels.users.length} to echo the count in templates.js
payload.columnCount = payload.labels.users.length + 2;
payload.columnCount = payload.labels.users.length + 3;
return payload;
};

@ -18,8 +18,8 @@
{{{ if user.privileges.admin:categories }}}<li><a href="{relative_path}/admin/manage/categories">[[admin/menu:manage/categories]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:privileges }}}<li><a href="{relative_path}/admin/manage/privileges">[[admin/menu:manage/privileges]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:users }}}<li><a href="{relative_path}/admin/manage/users">[[admin/menu:manage/users]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:groups }}}<li><a href="{relative_path}/admin/manage/groups">[[admin/menu:manage/groups]]</a></li>{{{ end }}}
{{{ if user.privileges.superadmin }}}
<li><a href="{relative_path}/admin/manage/groups">[[admin/menu:manage/groups]]</a></li>
<li><a href="{relative_path}/admin/manage/admins-mods">[[admin/menu:manage/admins-mods]]</a></li>
<li><a href="{relative_path}/admin/manage/registration">[[admin/menu:manage/registration]]</a></li>
<li><a href="{relative_path}/admin/manage/tags">[[admin/menu:manage/tags]]</a></li>
@ -189,8 +189,8 @@
{{{ if user.privileges.admin:categories }}}<li><a id="manage-categories" href="{relative_path}/admin/manage/categories">[[admin/menu:manage/categories]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:privileges }}}<li><a href="{relative_path}/admin/manage/privileges">[[admin/menu:manage/privileges]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:users }}}<li><a id="manage-users" href="{relative_path}/admin/manage/users">[[admin/menu:manage/users]]</a></li>{{{ end }}}
{{{ if user.privileges.admin:groups }}}<li><a href="{relative_path}/admin/manage/groups">[[admin/menu:manage/groups]]</a></li>{{{ end }}}
{{{ if user.privileges.superadmin }}}
<li><a href="{relative_path}/admin/manage/groups">[[admin/menu:manage/groups]]</a></li>
<li><a href="{relative_path}/admin/manage/admins-mods">[[admin/menu:manage/admins-mods]]</a></li>
<li><a href="{relative_path}/admin/manage/registration">[[admin/menu:manage/registration]]</a></li>
<li><a href="{relative_path}/admin/manage/tags">[[admin/menu:manage/tags]]</a></li>

Loading…
Cancel
Save