Fixes #3634 - use new routes for groups

This commit is contained in:
snipe 2017-06-08 20:24:26 -07:00
parent da2d9b2374
commit 041b794e1f
4 changed files with 49 additions and 44 deletions

View file

@ -28,7 +28,7 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/
public function getIndex()
public function index()
{
// Show the page
return View::make('groups/index', compact('groups'));
@ -42,7 +42,7 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/
public function getCreate()
public function create()
{
$group = new Group;
// Get all the available permissions
@ -62,7 +62,7 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function postCreate()
public function store()
{
// create a new group instance
$group = new Group();
@ -84,13 +84,13 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Contracts\View\View
*/
public function getEdit($id = null)
public function edit($id = null)
{
$group = Group::find($id);
$permissions = config('permissions');
$groupPermissions = $group->decodePermissions();
$selected_array = Helper::selectedPermissionsArray($permissions, $groupPermissions);
return View::make('groups/edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
return View::make('groups.edit', compact('group', 'permissions', 'selected_array', 'groupPermissions'));
}
/**
@ -102,7 +102,7 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function postEdit($id = null)
public function update($id = null)
{
$permissions = config('permissions');
if (!$group = Group::find($id)) {
@ -113,11 +113,11 @@ class GroupsController extends Controller
if (!config('app.lock_passwords')) {
if ($group->save()) {
return redirect()->to("admin/groups")->with('success', trans('admin/groups/message.success.update'));
return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.update'));
}
return redirect()->back()->withInput()->withErrors($group->getErrors());
}
return redirect()->route('groups')->with('error', trans('general.feature_disabled'));
return redirect()->route('groups.index')->with('error', trans('general.feature_disabled'));
}
/**
@ -129,7 +129,7 @@ class GroupsController extends Controller
* @since [v1.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function getDelete($id = null)
public function destroy($id = null)
{
if (!config('app.lock_passwords')) {
if (!$group = Group::find($id)) {
@ -137,9 +137,9 @@ class GroupsController extends Controller
}
$group->delete();
// Redirect to the group management page
return redirect()->route('groups')->with('success', trans('admin/groups/message.success.delete'));
return redirect()->route('groups.index')->with('success', trans('admin/groups/message.success.delete'));
}
return redirect()->route('groups')->with('error', trans('general.feature_disabled'));
return redirect()->route('groups.index')->with('error', trans('general.feature_disabled'));
}
}

View file

@ -1,10 +1,8 @@
@extends('layouts/edit-form', [
'createText' => trans('admin/groups/titles.create') ,
'updateText' => trans('admin/groups/titles.update'),
'helpTitle' => trans('admin/groups/general.about_groups_title'),
'helpText' => trans('admin/groups/general.about_groups_text'),
'item' => $group,
'formAction' => ($group !== null && $group->id !== null) ? route('groups.update', ['accessory' => $group->id]) : route('groups.store'),
'formAction' => ($group !== null && $group->id !== null) ? route('groups.update', ['group' => $group->id]) : route('groups.store'),
])
@section('content')
@ -28,34 +26,40 @@
</div>
</div>
<div class="col-md-8 col-md-offset-3">
@foreach ($permissions as $area => $permission)
@for ($i = 0; $i < count($permission); $i++)
<?php
$permission_name = $permission[$i]['permission'];
?>
@if ($permission[$i]['display'])
<h3>{{ $area }}: {{ $permission[$i]['label'] }}</h3>
<p>{{ $permission[$i]['note'] }}</p>
<div class="col-md-12 col-md-offset-2">
<h3>{{ $area }}: {{ $permission[$i]['label'] }}</h3>
<p>{{ $permission[$i]['note'] }}</p>
<!-- radio -->
<div class="form-group" style="padding-left: 15px;">
<label class="radio-padding">
{{ Form::radio('permission['.$permission_name.']', 1,
(is_array($groupPermissions))
&& (array_key_exists($permission_name, $groupPermissions)
&& $groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Grant
</label>
<label class="radio-padding">
{{ Form::radio('permission['.$permission_name.']', 0, ((is_array($groupPermissions) && !array_key_exists($permission_name, $groupPermissions)) || !$groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Deny
</label>
<!-- radio -->
<div class="form-group" style="padding-left: 15px;">
<label class="radio-padding col-md-3">
{{ Form::radio('permission['.$permission_name.']', 1,
(is_array($groupPermissions))
&& (array_key_exists($permission_name, $groupPermissions)
&& $groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Grant
</label>
<label class="radio-padding col-md-3">
{{ Form::radio('permission['.$permission_name.']', 0, ((is_array($groupPermissions) && !array_key_exists($permission_name, $groupPermissions)) || !$groupPermissions[$permission_name]), ['class' => 'minimal']) }}
Deny
</label>
</div>
<hr>
</div>
<hr>
@endif
@endfor
@endforeach
</div>
@stop

View file

@ -30,9 +30,11 @@
{{ $item->display_name }}
@endif
</h3>
<div class="box-tools pull-right">
<button class="slideout-menu-toggle btn btn-box-tool btn-box-tool-lg" data-toggle="tooltip" title="Help"><i class="fa fa-question"></i></button>
</div>
@if (isset($helpText))
<div class="box-tools pull-right">
<button class="slideout-menu-toggle btn btn-box-tool btn-box-tool-lg" data-toggle="tooltip" title="Help"><i class="fa fa-question"></i></button>
</div>
@endif
</div><!-- /.box-header -->
<div class="box-body">
@ -51,6 +53,8 @@
</div>
</div>
</div>
@if ((isset($helpText)) && (isset($helpTitle)))
<div class="slideout-menu">
<a href="#" class="slideout-menu-toggle pull-right">×</a>
<h3>
@ -58,6 +62,7 @@
</h3>
<p>{{ $helpText }} </p>
</div>
@endif
</div>
@stop

View file

@ -165,17 +165,13 @@ Route::group([ 'prefix' => 'admin','middleware' => ['auth']], function () {
});
# Group Management
Route::group([ 'prefix' => 'groups', 'middleware' => ['auth'] ], function () {
Route::get('/', [ 'as' => 'groups.index', 'uses' => 'GroupsController@getIndex' ]);
Route::get('create', [ 'as' => 'groups.create', 'uses' => 'GroupsController@getCreate']);
Route::post('create', [ 'as' => 'groups.store', 'uses' => 'GroupsController@postCreate' ]);
Route::get('{groupId}/edit', [ 'as' => 'groups.edit', 'uses' => 'GroupsController@getEdit' ]);
Route::post('{groupId}/edit', [ 'as' => 'groups.update', 'uses' => 'GroupsController@postEdit' ]);
Route::get('{groupId}/delete', [ 'as' => 'groups.delete', 'uses' => 'GroupsController@getDelete' ]);
Route::resource('groups', 'GroupsController', [
'middleware' => ['auth'],
'parameters' => ['group' => 'group_id']
]);
});
/*