finally closed #2887 -- added implicit privilege markers to client-side privileges table

v1.18.x
Julian Lam 10 years ago
parent 5a0ea28633
commit 9e994f3baf

@ -203,7 +203,9 @@ define('admin/manage/category', [
} else {
app.alertError('[[error:invalid-data]]');
}
})
});
Category.exposeAssumedPrivileges();
};
Category.refreshPrivilegeTable = function() {
@ -216,10 +218,33 @@ define('admin/manage/category', [
privileges: privileges
}, function(html) {
$('.privilege-table-container').html(html);
Category.exposeAssumedPrivileges();
});
});
};
Category.exposeAssumedPrivileges = function() {
/*
If registered-users has a privilege enabled, then all users and groups of that privilege
should be assumed to have that privilege as well, even if not set in the db, so reflect
this arrangement in the table
*/
var privs = [];
$('.privilege-table tr[data-group-name="registered-users"] td input[type="checkbox"]').parent().each(function(idx, el) {
if ($(el).find('input').prop('checked')) {
privs.push(el.getAttribute('data-privilege'));
}
});
for(var x=0,numPrivs=privs.length;x<numPrivs;x++) {
var inputs = $('.privilege-table tr[data-group-name]:not([data-group-name="registered-users"],[data-group-name="guests"]) td[data-privilege="' + privs[x] + '"] input');
inputs.each(function(idx, el) {
if (!el.checked) {
el.indeterminate = true;
}
});
}
};
Category.setPrivilege = function(member, privilege, state, checkboxEl) {
socket.emit('admin.categories.setPrivilege', {
cid: ajaxify.variables.get('cid'),

@ -1,7 +1,7 @@
<div class="row">
<div class="col-lg-9">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-heading"><i class="fa fa-folder"></i> Active Categories</div>
<div class="panel-body">
<table class="table table-striped table-hover table-reordering">
<thead>
@ -55,7 +55,7 @@
</div>
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
<div class="panel-heading"><i class="fa fa-folder"></i> Disabled Categories</div>
<div class="panel-body">
<table class="table table-striped table-hover table-reordering">
<thead>

@ -42,4 +42,10 @@
</tr>
<!-- END privileges.groups -->
</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>
</div>
Loading…
Cancel
Save