Fixes #2062 - old permissions masks to new

This commit is contained in:
snipe 2016-05-20 12:23:31 -07:00
parent f6cdd90e41
commit 7fd6051514
2 changed files with 9 additions and 8 deletions

View file

@ -47,11 +47,11 @@ class GroupsController extends Controller
$group = new Group; $group = new Group;
// Get all the available permissions // Get all the available permissions
$permissions = config('permissions'); $permissions = config('permissions');
$groupPermissions = array();
$selectedPermissions = Input::old('permissions', array()); $selectedPermissions = Input::old('permissions', $groupPermissions);
// Show the page // Show the page
return View::make('groups/edit', compact('permissions', 'selectedPermissions'))->with('group', $group); return View::make('groups/edit', compact('permissions', 'selectedPermissions', 'groupPermissions'))->with('group', $group);
} }
/** /**
@ -91,9 +91,9 @@ class GroupsController extends Controller
{ {
$group = Group::find($id); $group = Group::find($id);
$permissions = config('permissions'); $permissions = config('permissions');
$group->permissions = $group->decodePermissions(); $groupPermissions = $group->decodePermissions();
$selected_array = Helper::selectedPermissionsArray($permissions, $group->permissions); $selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
return View::make('groups/edit', compact('group', 'permissions','selected_array')); return View::make('groups/edit', compact('group', 'permissions','selected_array','groupPermissions'));
} }
/** /**

View file

@ -67,11 +67,12 @@
<div class="form-group" style="padding-left: 15px;"> <div class="form-group" style="padding-left: 15px;">
<label class="radio-padding"> <label class="radio-padding">
{{ Form::radio('permission['.$permission_name.']', 1, $group->permissions[$permission_name], ['class' => 'minimal']) }} {{ Form::radio('permission['.$permission_name.']', 1,
(array_key_exists($permission_name, $groupPermissions) && $groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Grant</label> Grant</label>
<label class="radio-padding"> <label class="radio-padding">
{{ Form::radio('permission['.$permission_name.']', 0, !$group->permissions[$permission_name], ['class' => 'minimal']) }} {{ Form::radio('permission['.$permission_name.']', 0, (!array_key_exists($permission_name, $groupPermissions) || !$groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Deny</label> Deny</label>
</div> </div>
<hr> <hr>