Merge branch 'v3' of github.com:snipe/snipe-it into v3

This commit is contained in:
snipe 2016-06-27 21:15:18 -07:00
commit 084db22cd5
3 changed files with 66 additions and 50 deletions

View file

@ -352,16 +352,13 @@ class AssetsController extends Controller
$asset->supplier_id = null;
}
if ($request->has('requestable')) {
$asset->requestable = e($request->input('requestable'));
} else {
$asset->requestable = null;
}
// If the box isn't checked, it's not in the request at all.
$asset->requestable = $request->has('requestable');
if ($request->has('rtd_location_id')) {
$asset->rtd_location_id = e($request->input('rtd_location_id'));
} else {
$asset->requestable = null;
$asset->rtd_location_id = null;
}
if ($request->has('image_delete')) {
@ -836,7 +833,15 @@ class AssetsController extends Controller
$date = date('Y-m-d-his');
$fixed_filename = str_replace(' ', '-', $file->getClientOriginalName());
$file->move($path, $date.'-'.$fixed_filename);
try {
$file->move($path, $date.'-'.$fixed_filename);
} catch (\Symfony\Component\HttpFoundation\File\Exception\FileException $exception) {
$results['error']=trans('admin/hardware/message.upload.error');
if( config('app.debug')) {
$results['error'].= ' ' . $exception->getMessage();
}
return $results;
}
$name = date('Y-m-d-his').'-'.$fixed_filename;
$filesize = Setting::fileSizeConvert(filesize($path.'/'.$name));
$results[] = compact('name', 'filesize');
@ -850,7 +855,6 @@ class AssetsController extends Controller
} else {
$results['error']=trans('general.feature_disabled');
return $results;
}

View file

@ -102,20 +102,40 @@ class UsersController extends Controller
{
$user = new User;
$user->first_name = $data['first_name']= e($request->input('first_name'));
$user->last_name = e($request->input('last_name'));
//Username, email, and password need to be handled specially because the need to respect config values on an edit.
$user->email = $data['email'] = e($request->input('email'));
$user->activated = 1;
$user->locale = e($request->input('locale'));
$user->username = $data['username'] = e($request->input('username'));
$user->permissions = json_encode($request->input('permission'));
if ($request->has('password')) {
$user->password = bcrypt($request->input('password'));
$data['password'] = $request->input('password');
}
// Update the user
$user->first_name = e($request->input('first_name'));
$user->last_name = e($request->input('last_name'));
$user->locale = e($request->input('locale'));
$user->employee_num = e($request->input('employee_num'));
$user->activated = e($request->input('activated', $user->activated));
$user->jobtitle = e($request->input('jobtitle'));
$user->phone = e($request->input('phone'));
$user->location_id = e($request->input('location_id'));
$user->company_id = e(Company::getIdForUser($request->input('company_id')));
$user->manager_id = e($request->input('manager_id'));
$user->notes = e($request->input('notes'));
$user->permissions = json_encode($request->input('permission'));
if ($user->manager_id == "") {
$user->manager_id = null;
}
if ($user->location_id == "") {
$user->location_id = null;
}
if ($user->company_id == "") {
$user->company_id = null;
}
if ($user->save()) {
@ -279,26 +299,35 @@ class UsersController extends Controller
return redirect()->route('users')->with('error', $error);
}
// Update the user
$user->first_name = e($request->input('first_name'));
$user->last_name = e($request->input('last_name'));
$user->locale = e($request->input('locale'));
if (Input::has('username')) {
// First handle anything exclusive to editing.
if ($request->has('groups')) {
$user->groups()->sync($request->input('groups'));
} else {
$user->groups()->sync(array());
}
// Do we want to update the user password?
if ($request->has('password')) {
$user->password = bcrypt($request->input('password'));
}
if ( $request->has('username')) {
$user->username = e($request->input('username'));
}
$user->email = e($request->input('email'));
$user->employee_num = e($request->input('employee_num'));
$user->activated = e($request->input('activated', $user->activated));
$user->jobtitle = e($request->input('jobtitle'));
$user->phone = e($request->input('phone'));
$user->location_id = e($request->input('location_id'));
$user->company_id = e(Company::getIdForUser($request->input('company_id')));
$user->manager_id = e($request->input('manager_id'));
$user->notes = e($request->input('notes'));
$user->permissions = json_encode($request->input('permission'));
$user->email = e($request->input('email'));
// Update the user
$user->first_name = e($request->input('first_name'));
$user->last_name = e($request->input('last_name'));
$user->locale = e($request->input('locale'));
$user->employee_num = e($request->input('employee_num'));
$user->activated = e($request->input('activated', $user->activated));
$user->jobtitle = e($request->input('jobtitle'));
$user->phone = e($request->input('phone'));
$user->location_id = e($request->input('location_id'));
$user->company_id = e(Company::getIdForUser($request->input('company_id')));
$user->manager_id = e($request->input('manager_id'));
$user->notes = e($request->input('notes'));
$user->permissions = json_encode($request->input('permission'));
if ($user->manager_id == "") {
@ -309,28 +338,11 @@ class UsersController extends Controller
$user->location_id = null;
}
if ($request->has('groups')) {
$user->groups()->sync($request->input('groups'));
} else {
$user->groups()->sync(array());
if ($user->company_id == "") {
$user->company_id = null;
}
// Do we want to update the user password?
if (($request->has('password')) && (!config('app.lock_passwords'))) {
$user->password = bcrypt($request->input('password'));
}
// Do we want to update the user email?
if (!config('app.lock_passwords')) {
$user->email = e($request->input('email'));
}
if (!config('app.lock_passwords')) {
}
// Was the user updated?
if ($user->save()) {

View file

@ -155,7 +155,7 @@ class Asset extends Depreciable
'fields' => [
[
'title' => 'Checked Out:',
'value' => 'HARDWARE asset <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$this->showAssetName().'> checked out to <'.config('app.url').'/admin/users/'.$this->assigned_to.'/view|'.$this->assigneduser->fullName().'> by <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$admin->fullName().'>.'
'value' => 'HARDWARE asset <'.config('app.url').'/hardware/'.$this->id.'/view'.'|'.$this->showAssetName().'> checked out to <'.config('app.url').'/admin/users/'.$this->assigned_to.'/view|'.$this->assigneduser->fullName().'> by <'.config('app.url').'/admin/users/'.Auth::user()->id.'/view'.'|'.$admin->fullName().'>.'
],
[
'title' => 'Note:',