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; $asset->supplier_id = null;
} }
if ($request->has('requestable')) { // If the box isn't checked, it's not in the request at all.
$asset->requestable = e($request->input('requestable')); $asset->requestable = $request->has('requestable');
} else {
$asset->requestable = null;
}
if ($request->has('rtd_location_id')) { if ($request->has('rtd_location_id')) {
$asset->rtd_location_id = e($request->input('rtd_location_id')); $asset->rtd_location_id = e($request->input('rtd_location_id'));
} else { } else {
$asset->requestable = null; $asset->rtd_location_id = null;
} }
if ($request->has('image_delete')) { if ($request->has('image_delete')) {
@ -836,7 +833,15 @@ class AssetsController extends Controller
$date = date('Y-m-d-his'); $date = date('Y-m-d-his');
$fixed_filename = str_replace(' ', '-', $file->getClientOriginalName()); $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; $name = date('Y-m-d-his').'-'.$fixed_filename;
$filesize = Setting::fileSizeConvert(filesize($path.'/'.$name)); $filesize = Setting::fileSizeConvert(filesize($path.'/'.$name));
$results[] = compact('name', 'filesize'); $results[] = compact('name', 'filesize');
@ -850,7 +855,6 @@ class AssetsController extends Controller
} else { } else {
$results['error']=trans('general.feature_disabled'); $results['error']=trans('general.feature_disabled');
return $results; return $results;
} }

View file

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

View file

@ -155,7 +155,7 @@ class Asset extends Depreciable
'fields' => [ 'fields' => [
[ [
'title' => 'Checked Out:', '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:', 'title' => 'Note:',