|
|
@ -40,43 +40,43 @@ define('admin/manage/privileges', [
|
|
|
|
|
|
|
|
|
|
|
|
Privileges.setupPrivilegeTable = function () {
|
|
|
|
Privileges.setupPrivilegeTable = function () {
|
|
|
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]:not(.checkbox-helper)', function () {
|
|
|
|
$('.privilege-table-container').on('change', 'input[type="checkbox"]:not(.checkbox-helper)', function () {
|
|
|
|
const checkboxEl = $(this);
|
|
|
|
const $checkboxEl = $(this);
|
|
|
|
const wrapperEl = checkboxEl.parent();
|
|
|
|
const $wrapperEl = $checkboxEl.parent();
|
|
|
|
const columnNo = wrapperEl.index() + 1;
|
|
|
|
const columnNo = $wrapperEl.index() + 1;
|
|
|
|
const privilege = wrapperEl.attr('data-privilege');
|
|
|
|
const privilege = $wrapperEl.attr('data-privilege');
|
|
|
|
const state = checkboxEl.prop('checked');
|
|
|
|
const state = $checkboxEl.prop('checked');
|
|
|
|
const rowEl = checkboxEl.parents('tr');
|
|
|
|
const $rowEl = $checkboxEl.parents('tr');
|
|
|
|
const member = rowEl.attr('data-group-name') || rowEl.attr('data-uid');
|
|
|
|
const member = $rowEl.attr('data-group-name') || $rowEl.attr('data-uid');
|
|
|
|
const isPrivate = parseInt(rowEl.attr('data-private') || 0, 10);
|
|
|
|
const isPrivate = parseInt($rowEl.attr('data-private') || 0, 10);
|
|
|
|
const isGroup = rowEl.attr('data-group-name') !== undefined;
|
|
|
|
const isGroup = $rowEl.attr('data-group-name') !== undefined;
|
|
|
|
const isBanned = (isGroup && rowEl.attr('data-group-name') === 'banned-users') || rowEl.attr('data-banned') !== undefined;
|
|
|
|
const isBanned = (isGroup && $rowEl.attr('data-group-name') === 'banned-users') || $rowEl.attr('data-banned') !== undefined;
|
|
|
|
const sourceGroupName = isBanned ? 'banned-users' : 'registered-users';
|
|
|
|
const sourceGroupName = isBanned ? 'banned-users' : 'registered-users';
|
|
|
|
const delta = checkboxEl.prop('checked') === (wrapperEl.attr('data-value') === 'true') ? null : state;
|
|
|
|
const delta = $checkboxEl.prop('checked') === ($wrapperEl.attr('data-value') === 'true') ? null : state;
|
|
|
|
|
|
|
|
|
|
|
|
if (member) {
|
|
|
|
if (member) {
|
|
|
|
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
|
|
|
if (isGroup && privilege === 'groups:moderate' && !isPrivate && state) {
|
|
|
|
bootbox.confirm('[[admin/manage/privileges:alert.confirm-moderate]]', function (confirm) {
|
|
|
|
bootbox.confirm('[[admin/manage/privileges:alert.confirm-moderate]]', function (confirm) {
|
|
|
|
if (confirm) {
|
|
|
|
if (confirm) {
|
|
|
|
wrapperEl.attr('data-delta', delta);
|
|
|
|
$wrapperEl.attr('data-delta', delta);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
checkboxEl.prop('checked', !checkboxEl.prop('checked'));
|
|
|
|
$checkboxEl.prop('checked', !$checkboxEl.prop('checked'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (privilege.endsWith('admin:admins-mods') && state) {
|
|
|
|
} else if (privilege.endsWith('admin:admins-mods') && state) {
|
|
|
|
bootbox.confirm('[[admin/manage/privileges:alert.confirm-admins-mods]]', function (confirm) {
|
|
|
|
bootbox.confirm('[[admin/manage/privileges:alert.confirm-admins-mods]]', function (confirm) {
|
|
|
|
if (confirm) {
|
|
|
|
if (confirm) {
|
|
|
|
wrapperEl.attr('data-delta', delta);
|
|
|
|
$wrapperEl.attr('data-delta', delta);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
checkboxEl.prop('checked', !checkboxEl.prop('checked'));
|
|
|
|
$checkboxEl.prop('checked', !$checkboxEl.prop('checked'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wrapperEl.attr('data-delta', delta);
|
|
|
|
$wrapperEl.attr('data-delta', delta);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
Privileges.exposeSingleAssumedPriv(columnNo, sourceGroupName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
checkboxRowSelector.updateState(checkboxEl);
|
|
|
|
checkboxRowSelector.updateState($checkboxEl);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
app.alertError('[[error:invalid-data]]');
|
|
|
|
app.alertError('[[error:invalid-data]]');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -369,12 +369,12 @@ define('admin/manage/privileges', [
|
|
|
|
|
|
|
|
|
|
|
|
function hightlightRowByDataAttr(attrName, attrValue) {
|
|
|
|
function hightlightRowByDataAttr(attrName, attrValue) {
|
|
|
|
if (attrValue) {
|
|
|
|
if (attrValue) {
|
|
|
|
const el = $('[' + attrName + ']').filter(function () {
|
|
|
|
const $el = $('[' + attrName + ']').filter(function () {
|
|
|
|
return $(this).attr(attrName) === String(attrValue);
|
|
|
|
return $(this).attr(attrName) === String(attrValue);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (el.length) {
|
|
|
|
if ($el.length) {
|
|
|
|
el.addClass('selected');
|
|
|
|
$el.addClass('selected');
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|