Skip to content

Commit

Permalink
fix: fixed wrong check disabled permissions due to category selection,
Browse files Browse the repository at this point in the history
…closes #1675
  • Loading branch information
thorsten committed Mar 22, 2020
1 parent d8e9e84 commit 0480e49
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
6 changes: 3 additions & 3 deletions phpmyfaq/admin/assets/js/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function setPermissions(permissions) {
if (-1 === parseInt(perms.user[0])) {
$('#restrictedusers')
.prop('checked', false)
.prop('disabled', true);
.prop('disabled', false);
$('#allusers')
.prop('checked', true)
.prop('disabled', false);
Expand All @@ -68,15 +68,15 @@ function setPermissions(permissions) {
.prop('disabled', true);
$('#restrictedusers')
.prop('checked', true)
.prop('disabled', false);
.prop('disabled', true);
$.each(perms.user, function(key, value) {
$(".selected-users option[value='" + value + "']").prop('selected', true);
});
}
if (-1 === parseInt(perms.group[0])) {
$('#restrictedgroups')
.prop('checked', false)
.prop('disabled', true);
.prop('disabled', false);
$('#allgroups')
.prop('checked', true)
.prop('disabled', false);
Expand Down
64 changes: 33 additions & 31 deletions phpmyfaq/admin/record.edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,38 +516,40 @@ class="form-control">
<?php if ($faqConfig->get('security.permLevel') !== 'basic'): ?>
<fieldset class="form-group">
<div class="row">
<legend class="col-lg-2 col-form-label pt-0"><?= $PMF_LANG['ad_entry_grouppermission'] ?></legend>
<legend class="col-lg-2 col-form-label pt-0">
<?= $PMF_LANG['ad_entry_grouppermission'] ?>
</legend>
<div class="col-lg-10">
<div class="form-check">
<input type="radio" id="allgroups" name="grouppermission"
value="all" class="form-check-input"
<?php echo($allGroups ? 'checked' : ''); ?>>
<label class="form-check-label" for="allgroups">
<?= $PMF_LANG['ad_entry_all_groups'] ?>
</label>
</div>
<div class="form-check">
<input type="radio" id="restrictedgroups" name="grouppermission"
class="form-check-input"
value="restricted" <?php echo($restrictedGroups ? 'checked' : ''); ?>>
<label for="selected-groups" class="form-check-label"
for="restrictedgroups">
<?= $PMF_LANG['ad_entry_restricted_groups'] ?>
</label>
<select id="selected-groups" name="restricted_groups[]" size="3"
class="form-control" multiple>
<?php
if ($faqConfig->get('main.enableCategoryRestrictions')) {
echo $user->perm->getAllGroupsOptions(
$groupPermission,
$currentUserId
);
} else {
echo $user->perm->getAllGroupsOptions($groupPermission);
}
?>
</select>
</div>
<div class="form-check">
<input type="radio" id="allgroups" name="grouppermission"
value="all" class="form-check-input"
<?php echo($allGroups ? 'checked' : ''); ?>>
<label class="form-check-label" for="allgroups">
<?= $PMF_LANG['ad_entry_all_groups'] ?>
</label>
</div>
<div class="form-check">
<input type="radio" id="restrictedgroups" name="grouppermission"
class="form-check-input"
value="restricted" <?php echo($restrictedGroups ? 'checked' : ''); ?>>
<label for="selected-groups" class="form-check-label"
for="restrictedgroups">
<?= $PMF_LANG['ad_entry_restricted_groups'] ?>
</label>
<select id="selected-groups" name="restricted_groups[]" size="3"
class="form-control" multiple>
<?php
if ($faqConfig->get('main.enableCategoryRestrictions')) {
echo $user->perm->getAllGroupsOptions(
$groupPermission,
$currentUserId
);
} else {
echo $user->perm->getAllGroupsOptions($groupPermission);
}
?>
</select>
</div>
</div>
</div>
</fieldset>
Expand Down

0 comments on commit 0480e49

Please sign in to comment.