mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
updated acp category privilege settings so that not all groups are shown in privilege table, closes #3036
This commit is contained in:
@@ -283,6 +283,11 @@
|
|||||||
#taskbar {
|
#taskbar {
|
||||||
display: none; /* not sure why I have to do this, but it only seems to show up on prod */
|
display: none; /* not sure why I have to do this, but it only seems to show up on prod */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allows the autocomplete dropbox to appear on top of a modal's backdrop */
|
||||||
|
.ui-autocomplete {
|
||||||
|
z-index: @zindex-popover;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allowing text to the right of an image-type brand
|
// Allowing text to the right of an image-type brand
|
||||||
|
|||||||
@@ -158,26 +158,6 @@ define('admin/manage/category', [
|
|||||||
};
|
};
|
||||||
|
|
||||||
Category.setupPrivilegeTable = function() {
|
Category.setupPrivilegeTable = function() {
|
||||||
var searchEl = $('.privilege-search'),
|
|
||||||
searchObj = autocomplete.user(searchEl);
|
|
||||||
|
|
||||||
// User search + addition to table
|
|
||||||
searchObj.on('autocompleteselect', function(ev, ui) {
|
|
||||||
socket.emit('admin.categories.setPrivilege', {
|
|
||||||
cid: ajaxify.variables.get('cid'),
|
|
||||||
privilege: 'read',
|
|
||||||
set: true,
|
|
||||||
member: ui.item.user.uid
|
|
||||||
}, function(err) {
|
|
||||||
if (err) {
|
|
||||||
return app.alertError(err.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
Category.refreshPrivilegeTable();
|
|
||||||
searchEl.val('');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Checkbox event capture
|
// Checkbox event capture
|
||||||
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]', function() {
|
||||||
var checkboxEl = $(this),
|
var checkboxEl = $(this),
|
||||||
@@ -205,6 +185,9 @@ define('admin/manage/category', [
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.privilege-table-container').on('click', '[data-action="search.user"]', Category.addUserToPrivilegeTable);
|
||||||
|
$('.privilege-table-container').on('click', '[data-action="search.group"]', Category.addGroupToPrivilegeTable);
|
||||||
|
|
||||||
Category.exposeAssumedPrivileges();
|
Category.exposeAssumedPrivileges();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -292,5 +275,65 @@ define('admin/manage/category', [
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Category.addUserToPrivilegeTable = function() {
|
||||||
|
var modal = bootbox.dialog({
|
||||||
|
title: 'Find a User',
|
||||||
|
message: '<input class="form-control input-lg" placeholder="Search for a user here..." />',
|
||||||
|
show: true
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.on('shown.bs.modal', function() {
|
||||||
|
var inputEl = modal.find('input'),
|
||||||
|
searchObj = autocomplete.user(inputEl);
|
||||||
|
|
||||||
|
searchObj.on('autocompleteselect', function(ev, ui) {
|
||||||
|
socket.emit('admin.categories.setPrivilege', {
|
||||||
|
cid: ajaxify.variables.get('cid'),
|
||||||
|
privilege: ['find', 'read'],
|
||||||
|
set: true,
|
||||||
|
member: ui.item.user.uid
|
||||||
|
}, function(err) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Category.refreshPrivilegeTable();
|
||||||
|
modal.modal('hide');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Category.addGroupToPrivilegeTable = function() {
|
||||||
|
var modal = bootbox.dialog({
|
||||||
|
title: 'Find a Group',
|
||||||
|
message: '<input class="form-control input-lg" placeholder="Search for a group here..." />',
|
||||||
|
show: true
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.on('shown.bs.modal', function() {
|
||||||
|
var inputEl = modal.find('input'),
|
||||||
|
searchObj = autocomplete.group(inputEl);
|
||||||
|
|
||||||
|
searchObj.on('autocompleteselect', function(ev, ui) {
|
||||||
|
console.log(ui);
|
||||||
|
socket.emit('admin.categories.setPrivilege', {
|
||||||
|
cid: ajaxify.variables.get('cid'),
|
||||||
|
privilege: ['groups:find', 'groups:read'],
|
||||||
|
set: true,
|
||||||
|
member: ui.item.group.name
|
||||||
|
}, function(err) {
|
||||||
|
console.log(arguments);
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Category.refreshPrivilegeTable();
|
||||||
|
modal.modal('hide');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return Category;
|
return Category;
|
||||||
});
|
});
|
||||||
@@ -35,5 +35,36 @@ define('autocomplete', function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.group = function(input) {
|
||||||
|
return input.autocomplete({
|
||||||
|
delay: 100,
|
||||||
|
source: function(request, response) {
|
||||||
|
socket.emit('groups.search', {
|
||||||
|
query: request.term,
|
||||||
|
options: {}
|
||||||
|
}, function(err, results) {
|
||||||
|
if (err) {
|
||||||
|
return app.alertError(err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results && results.length) {
|
||||||
|
var names = results.map(function(group) {
|
||||||
|
return group && {
|
||||||
|
label: group.name,
|
||||||
|
value: group.name,
|
||||||
|
group: {
|
||||||
|
name: group.name,
|
||||||
|
slug: group.slug
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
response(names);
|
||||||
|
}
|
||||||
|
$('.ui-autocomplete a').attr('data-ajaxify', 'false');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,9 +86,9 @@
|
|||||||
these settings.
|
these settings.
|
||||||
</p>
|
</p>
|
||||||
<hr />
|
<hr />
|
||||||
<input class="form-control privilege-search" type="text" placeholder="Add a user or group to this list..." />
|
<div class="privilege-table-container">
|
||||||
<hr />
|
<!-- IMPORT admin/partials/categories/privileges.tpl -->
|
||||||
<!-- IMPORT admin/partials/categories/privileges.tpl -->
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,51 +1,74 @@
|
|||||||
<div class="privilege-table-container">
|
<table class="table table-striped table-hover privilege-table">
|
||||||
<table class="table table-striped table-hover privilege-table">
|
<tr>
|
||||||
<tr>
|
<th colspan="2">User</th>
|
||||||
<th colspan="2">User</th>
|
<!-- BEGIN privileges.labels.users -->
|
||||||
<!-- BEGIN privileges.labels.users -->
|
<th class="text-center">{privileges.labels.users.name}</th>
|
||||||
<th class="text-center">{privileges.labels.users.name}</th>
|
<!-- END privileges.labels.users -->
|
||||||
<!-- END privileges.labels.users -->
|
</tr>
|
||||||
</tr>
|
<!-- IF privileges.users.length -->
|
||||||
<!-- IF privileges.users.length -->
|
<!-- BEGIN privileges.users -->
|
||||||
<!-- BEGIN privileges.users -->
|
<tr data-uid="{privileges.users.uid}">
|
||||||
<tr data-uid="{privileges.users.uid}">
|
<td><img src="{privileges.users.picture}" title="{privileges.users.username}" /></td>
|
||||||
<td><img src="{privileges.users.picture}" title="{privileges.users.username}" /></td>
|
<td>{privileges.users.username}</td>
|
||||||
<td>{privileges.users.username}</td>
|
{function.spawnPrivilegeStates, privileges.users.username, privileges}
|
||||||
{function.spawnPrivilegeStates, privileges.users.username, privileges}
|
</tr>
|
||||||
</tr>
|
<!-- END privileges.users -->
|
||||||
<!-- END privileges.users -->
|
<tr>
|
||||||
<!-- ELSE -->
|
<td colspan="{privileges.columnCount}">
|
||||||
<tr>
|
<button type="button" class="btn btn-primary btn-xs pull-right" data-ajaxify="false" data-action="search.user"><i class="fa fa-plus"></i> Add User</button>
|
||||||
<td colspan="{privileges.columnCount}">
|
</td>
|
||||||
<div class="alert alert-info">No user-specific privileges in this category.</div>
|
</tr>
|
||||||
</td>
|
<!-- ELSE -->
|
||||||
</tr>
|
<tr>
|
||||||
<!-- ENDIF privileges.users.length -->
|
<td colspan="{privileges.columnCount}">
|
||||||
</table>
|
<div class="alert alert-info">
|
||||||
|
<button type="button" class="btn btn-primary btn-xs pull-right" data-ajaxify="false" data-action="search.user"><i class="fa fa-plus"></i> Add User</button>
|
||||||
|
No user-specific privileges in this category.
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- ENDIF privileges.users.length -->
|
||||||
|
</table>
|
||||||
|
|
||||||
<table class="table table-striped table-hover privilege-table">
|
<table class="table table-striped table-hover privilege-table">
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="1">Group</th>
|
<th colspan="2">Group</th>
|
||||||
<!-- BEGIN privileges.labels.groups -->
|
<!-- BEGIN privileges.labels.groups -->
|
||||||
<th class="text-center">{privileges.labels.groups.name}</th>
|
<th class="text-center">{privileges.labels.groups.name}</th>
|
||||||
<!-- END privileges.labels.groups -->
|
<!-- END privileges.labels.groups -->
|
||||||
</tr>
|
</tr>
|
||||||
<!-- BEGIN privileges.groups -->
|
<!-- IF privileges.groups.length -->
|
||||||
<tr data-group-name="{privileges.groups.name}" data-private="<!-- IF privileges.groups.isPrivate -->1<!-- ELSE -->0<!-- ENDIF privileges.groups.isPrivate -->">
|
<!-- BEGIN privileges.groups -->
|
||||||
<td>
|
<tr data-group-name="{privileges.groups.name}" data-private="<!-- IF privileges.groups.isPrivate -->1<!-- ELSE -->0<!-- ENDIF privileges.groups.isPrivate -->">
|
||||||
<!-- IF privileges.groups.isPrivate -->
|
<td>
|
||||||
<i class="fa fa-lock text-muted" title="This group is private"></i>
|
<!-- IF privileges.groups.isPrivate -->
|
||||||
<!-- ENDIF privileges.groups.isPrivate -->
|
<i class="fa fa-lock text-muted" title="This group is private"></i>
|
||||||
{privileges.groups.name}
|
<!-- ENDIF privileges.groups.isPrivate -->
|
||||||
</td>
|
{privileges.groups.name}
|
||||||
{function.spawnPrivilegeStates, name, privileges}
|
</td>
|
||||||
</tr>
|
<td></td>
|
||||||
<!-- END privileges.groups -->
|
{function.spawnPrivilegeStates, name, privileges}
|
||||||
</table>
|
</tr>
|
||||||
<div class="help-block">
|
<!-- END privileges.groups -->
|
||||||
If the <code>registered-users</code> group is granted a specific privilege, all other groups receive an
|
<tr>
|
||||||
<strong>implicit privilege</strong>, even if they are not explicitly defined/checked. This implicit
|
<td colspan="{privileges.columnCount}">
|
||||||
privilege is shown to you because all users are part of the <code>registered-users</code> user group,
|
<button type="button" class="btn btn-primary btn-xs pull-right" data-ajaxify="false" data-action="search.group"><i class="fa fa-plus"></i> Add Group</button>
|
||||||
and so, privileges for additional groups need not be explicitly granted.
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
</div>
|
<!-- ELSE -->
|
||||||
|
<tr>
|
||||||
|
<td colspan="{privileges.columnCount}">
|
||||||
|
<div class="alert alert-info">
|
||||||
|
<button type="button" class="btn btn-primary btn-xs pull-right" data-ajaxify="false" data-action="search.group"><i class="fa fa-plus"></i> Add Group</button>
|
||||||
|
No group-specific privileges in this category.
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- ENDIF privileges.groups.length -->
|
||||||
|
</table>
|
||||||
|
<div class="help-block">
|
||||||
|
If the <code>registered-users</code> group is granted a specific privilege, all other groups receive an
|
||||||
|
<strong>implicit privilege</strong>, even if they are not explicitly defined/checked. This implicit
|
||||||
|
privilege is shown to you because all users are part of the <code>registered-users</code> user group,
|
||||||
|
and so, privileges for additional groups need not be explicitly granted.
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user