mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
parent
ba01b20ad4
commit
d40289fbc9
|
@ -7,6 +7,7 @@ use App\Helpers\Helper;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
|
use App\Models\Group;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
@ -64,24 +65,21 @@ class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
|
||||||
// Selected groups
|
// Selected groups
|
||||||
$userGroups = Input::old('groups', array());
|
if (Input::has('groups')) {
|
||||||
|
$userGroups = Group::pluck('name', 'id')->whereIn('id',Input::get('groups'));
|
||||||
|
} else {
|
||||||
|
$userGroups = collect();
|
||||||
|
}
|
||||||
|
|
||||||
// Get all the available permissions
|
|
||||||
$permissions = config('permissions');
|
$permissions = config('permissions');
|
||||||
|
$groups = Group::pluck('name', 'id');
|
||||||
|
$userPermissions = Helper::selectedPermissionsArray($permissions, Input::old('groups', array()));
|
||||||
|
|
||||||
|
|
||||||
// Selected permissions
|
|
||||||
$userPermissions = Input::old('permissions', array('superuser' => -1));
|
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$manager_list = Helper::managerList();
|
$manager_list = Helper::managerList();
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
|
|
||||||
/* echo '<pre>';
|
|
||||||
print_r($userPermissions);
|
|
||||||
echo '</pre>';
|
|
||||||
exit;
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Show the page
|
|
||||||
return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
|
return View::make('users/edit', compact('groups', 'userGroups', 'permissions', 'userPermissions'))
|
||||||
->with('location_list', $location_list)
|
->with('location_list', $location_list)
|
||||||
->with('manager_list', $manager_list)
|
->with('manager_list', $manager_list)
|
||||||
|
@ -132,9 +130,9 @@ class UsersController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON handler for creating a user through a modal
|
* JSON handler for creating a user through a modal popup
|
||||||
*
|
*
|
||||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
* @author [B. Wetherington] [<uberbrady@gmail.com>]
|
||||||
* @since [v1.8]
|
* @since [v1.8]
|
||||||
* @return string JSON
|
* @return string JSON
|
||||||
*/
|
*/
|
||||||
|
@ -185,25 +183,17 @@ class UsersController extends Controller
|
||||||
try {
|
try {
|
||||||
// Get the user information
|
// Get the user information
|
||||||
$user = User::find($id);
|
$user = User::find($id);
|
||||||
|
$permissions = config('permissions');
|
||||||
|
|
||||||
if (!Company::isCurrentUserHasAccess($user)) {
|
if (!Company::isCurrentUserHasAccess($user)) {
|
||||||
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get this user groups
|
$groups = Group::pluck('name', 'id');
|
||||||
$userGroups = $user->groups()->lists('group_id', 'name');
|
|
||||||
//$userGroups = null;
|
|
||||||
|
|
||||||
// Get this user permissions
|
$userGroups = $user->groups()->pluck('name', 'id');
|
||||||
$userPermissions = null;
|
$user->permissions = $user->decodePermissions();
|
||||||
//$this->encodePermissions($userPermissions);
|
$userPermissions = Helper::selectedPermissionsArray($permissions, $user->permissions);
|
||||||
|
|
||||||
// Get a list of all the available groups
|
|
||||||
//$groups = Sentry::getGroupProvider()->findAll();
|
|
||||||
|
|
||||||
// Get all the available permissions
|
|
||||||
$permissions = config('permissions');
|
|
||||||
//$this->encodeAllPermissions($permissions);
|
|
||||||
|
|
||||||
$location_list = Helper::locationsList();
|
$location_list = Helper::locationsList();
|
||||||
$company_list = Helper::companyList();
|
$company_list = Helper::companyList();
|
||||||
|
|
|
@ -39,5 +39,5 @@ class Group extends Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,6 +307,12 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function decodePermissions()
|
||||||
|
{
|
||||||
|
return json_decode($this->permissions, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query builder scope to search on text
|
* Query builder scope to search on text
|
||||||
*
|
*
|
||||||
|
|
|
@ -162,7 +162,7 @@ input[type='text'][disabled], input[disabled], textarea[disabled], input[readonl
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Language -->
|
<!-- language -->
|
||||||
<div class="form-group {{ $errors->has('locale') ? 'has-error' : '' }}">
|
<div class="form-group {{ $errors->has('locale') ? 'has-error' : '' }}">
|
||||||
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
|
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
|
@ -242,7 +242,7 @@ input[type='text'][disabled], input[disabled], textarea[disabled], input[readonl
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Notes -->
|
<!-- Notes -->
|
||||||
<div class="form-group {{ $errors->has('notes') ? ' has-error' : '' }}">
|
<div class="form-group {!! $errors->has('notes') ? ' has-error' : '' !!}">
|
||||||
<label for="notes" class="col-md-3 control-label">{{ trans('admin/users/table.notes') }}</label>
|
<label for="notes" class="col-md-3 control-label">{{ trans('admin/users/table.notes') }}</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<textarea class="form-control" id="notes" name="notes">{{ Input::old('notes', $user->notes) }}</textarea>
|
<textarea class="form-control" id="notes" name="notes">{{ Input::old('notes', $user->notes) }}</textarea>
|
||||||
|
@ -251,19 +251,28 @@ input[type='text'][disabled], input[disabled], textarea[disabled], input[readonl
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Groups -->
|
<!-- Groups -->
|
||||||
<div class="form-group {{ $errors->has('groups') ? 'has-error' : '' }}">
|
<div class="form-group {{ $errors->has('groups') ? 'has-error' : '' }}">
|
||||||
<label class="col-md-3 control-label" for="groups">{{ trans('general.groups') }}</label>
|
<label class="col-md-3 control-label" for="groups"> {{ trans('general.groups') }}</label>
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
||||||
<span class="help-block">
|
<select name="groups[]" id="groups[]" multiple="multiple" class="form-control" {{ ((Config::get('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}>
|
||||||
{{ trans('admin/users/table.groupnotes') }}
|
|
||||||
|
|
||||||
</span>
|
@foreach ($groups as $id => $group)
|
||||||
</div>
|
<option value="{{ $id }}"
|
||||||
</div>
|
{{ ($userGroups->keys()->contains($id) ? ' selected="selected"' : '') }}>
|
||||||
</div>
|
{{ $group }}
|
||||||
|
</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<span class="help-block">
|
||||||
|
{{ trans('admin/users/table.groupnotes') }}
|
||||||
|
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- Email user -->
|
<!-- Email user -->
|
||||||
@if (!$user->id)
|
@if (!$user->id)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue