mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
parent
ba01b20ad4
commit
d40289fbc9
|
@ -7,6 +7,7 @@ use App\Helpers\Helper;
|
|||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Group;
|
||||
use App\Models\Company;
|
||||
use App\Models\Location;
|
||||
use App\Models\Setting;
|
||||
|
@ -64,24 +65,21 @@ class UsersController extends Controller
|
|||
{
|
||||
|
||||
// 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');
|
||||
$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();
|
||||
$manager_list = Helper::managerList();
|
||||
$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'))
|
||||
->with('location_list', $location_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]
|
||||
* @return string JSON
|
||||
*/
|
||||
|
@ -185,25 +183,17 @@ class UsersController extends Controller
|
|||
try {
|
||||
// Get the user information
|
||||
$user = User::find($id);
|
||||
$permissions = config('permissions');
|
||||
|
||||
if (!Company::isCurrentUserHasAccess($user)) {
|
||||
return redirect()->route('users')->with('error', trans('general.insufficient_permissions'));
|
||||
}
|
||||
|
||||
// Get this user groups
|
||||
$userGroups = $user->groups()->lists('group_id', 'name');
|
||||
//$userGroups = null;
|
||||
$groups = Group::pluck('name', 'id');
|
||||
|
||||
// Get this user permissions
|
||||
$userPermissions = null;
|
||||
//$this->encodePermissions($userPermissions);
|
||||
|
||||
// Get a list of all the available groups
|
||||
//$groups = Sentry::getGroupProvider()->findAll();
|
||||
|
||||
// Get all the available permissions
|
||||
$permissions = config('permissions');
|
||||
//$this->encodeAllPermissions($permissions);
|
||||
$userGroups = $user->groups()->pluck('name', 'id');
|
||||
$user->permissions = $user->decodePermissions();
|
||||
$userPermissions = Helper::selectedPermissionsArray($permissions, $user->permissions);
|
||||
|
||||
$location_list = Helper::locationsList();
|
||||
$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
|
||||
*
|
||||
|
|
|
@ -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' : '' }}">
|
||||
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
|
||||
<div class="col-md-9">
|
||||
|
@ -242,7 +242,7 @@ input[type='text'][disabled], input[disabled], textarea[disabled], input[readonl
|
|||
</div>
|
||||
|
||||
<!-- 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>
|
||||
<div class="col-md-9">
|
||||
<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>
|
||||
|
||||
<!-- Groups -->
|
||||
<div class="form-group {{ $errors->has('groups') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="groups">{{ trans('general.groups') }}</label>
|
||||
<div class="col-md-5">
|
||||
<div class="controls">
|
||||
<div class="form-group {{ $errors->has('groups') ? 'has-error' : '' }}">
|
||||
<label class="col-md-3 control-label" for="groups"> {{ trans('general.groups') }}</label>
|
||||
<div class="col-md-5">
|
||||
<div class="controls">
|
||||
|
||||
<span class="help-block">
|
||||
{{ trans('admin/users/table.groupnotes') }}
|
||||
<select name="groups[]" id="groups[]" multiple="multiple" class="form-control" {{ ((Config::get('app.lock_passwords') && ($user->id)) ? ' disabled' : '') }}>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@foreach ($groups as $id => $group)
|
||||
<option value="{{ $id }}"
|
||||
{{ ($userGroups->keys()->contains($id) ? ' selected="selected"' : '') }}>
|
||||
{{ $group }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
<span class="help-block">
|
||||
{{ trans('admin/users/table.groupnotes') }}
|
||||
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Email user -->
|
||||
@if (!$user->id)
|
||||
|
||||
|
|
Loading…
Reference in a new issue