Skip to content

A free open source IT asset/license management system

Merge branch 'develop' into v5-master-develop-integration

snipe5290c47e2a95
diff --cc README.md
index 3dcd3fc778,9ed53724fe..14c2347b54
--- a/README.md
+++ b/README.md
@@@ -105,7 -113,10 +114,10 @@@ Thanks goes to all of these wonderful p
| [<img src="https://avatars2.githubusercontent.com/u/982885?v=4" width="110px;"/><br /><sub>Martin Stub</sub>](http://martinstub.dk)<br />[🌍](#translation-stubben "Translation") | [<img src="https://avatars2.githubusercontent.com/u/28959963?v=4" width="110px;"/><br /><sub>Meyer Flavio</sub>](https://github.com/meyerf99)<br />[🌍](#translation-meyerf99 "Translation") | [<img src="https://avatars3.githubusercontent.com/u/796443?v=4" width="110px;"/><br /><sub>Micael Rodrigues</sub>](https://github.com/MicaelRodrigues)<br />[🌍](#translation-MicaelRodrigues "Translation") | [<img src="https://avatars0.githubusercontent.com/u/10481331?v=4" width="110px;"/><br /><sub>Mikael Rasmussen</sub>](http://rubixy.com/)<br />[🌍](#translation-mikaelssen "Translation") | [<img src="https://avatars1.githubusercontent.com/u/1544552?v=4" width="110px;"/><br /><sub>IxFail</sub>](https://github.com/IxFail)<br />[🌍](#translation-IxFail "Translation") | [<img src="https://avatars3.githubusercontent.com/u/18483118?v=4" width="110px;"/><br /><sub>Mohammed Fota</sub>](http://www.mohammedfota.com)<br />[🌍](#translation-MohammedFota "Translation") | [<img src="https://avatars0.githubusercontent.com/u/227080?v=4" width="110px;"/><br /><sub>Moayad Alserihi</sub>](https://github.com/omego)<br />[🌍](#translation-omego "Translation") |
| [<img src="https://avatars0.githubusercontent.com/u/1680266?v=4" width="110px;"/><br /><sub>saymd</sub>](https://github.com/saymd)<br />[🌍](#translation-saymd "Translation") | [<img src="https://avatars0.githubusercontent.com/u/1826808?v=4" width="110px;"/><br /><sub>Patrik Larsson</sub>](https://nordsken.se)<br />[🌍](#translation-pooot "Translation") | [<img src="https://avatars1.githubusercontent.com/u/20584746?v=4" width="110px;"/><br /><sub>drcryo</sub>](https://github.com/drcryo)<br />[🌍](#translation-drcryo "Translation") | [<img src="https://avatars1.githubusercontent.com/u/19408004?v=4" width="110px;"/><br /><sub>pawel1615</sub>](https://github.com/pawel1615)<br />[🌍](#translation-pawel1615 "Translation") | [<img src="https://avatars2.githubusercontent.com/u/23340468?v=4" width="110px;"/><br /><sub>bodrovics</sub>](https://github.com/bodrovics)<br />[🌍](#translation-bodrovics "Translation") | [<img src="https://avatars0.githubusercontent.com/u/3257654?v=4" width="110px;"/><br /><sub>priatna</sub>](https://github.com/priatna)<br />[🌍](#translation-priatna "Translation") | [<img src="https://avatars1.githubusercontent.com/u/5358374?v=4" width="110px;"/><br /><sub>Fan Jiang</sub>](https://amayume.net)<br />[🌍](#translation-ProfFan "Translation") |
| [<img src="https://avatars1.githubusercontent.com/u/22555451?v=4" width="110px;"/><br /><sub>ragnarcx</sub>](https://github.com/ragnarcx)<br />[🌍](#translation-ragnarcx "Translation") | [<img src="https://avatars2.githubusercontent.com/u/18654582?v=4" width="110px;"/><br /><sub>Rein van Haaren</sub>](http://www.reinvanhaaren.nl/)<br />[🌍](#translation-reinvanhaaren "Translation") | [<img src="https://avatars1.githubusercontent.com/u/386672?v=4" width="110px;"/><br /><sub>Teguh Dwicaksana</sub>](http://dheche.songolimo.net)<br />[🌍](#translation-dheche "Translation") | [<img src="https://avatars2.githubusercontent.com/u/2572552?v=4" width="110px;"/><br /><sub>fraccie</sub>](https://github.com/FRaccie)<br />[🌍](#translation-FRaccie "Translation") | [<img src="https://avatars0.githubusercontent.com/u/35182720?v=4" width="110px;"/><br /><sub>vinzruzell</sub>](https://github.com/vinzruzell)<br />[🌍](#translation-vinzruzell "Translation") | [<img src="https://avatars1.githubusercontent.com/u/7883603?v=4" width="110px;"/><br /><sub>Kevin Austin</sub>](http://kevinaustin.com)<br />[🌍](#translation-vipsystem "Translation") | [<img src="https://avatars3.githubusercontent.com/u/3861828?v=4" width="110px;"/><br /><sub>Wira Sandy</sub>](http://azuraweb.xyz)<br />[🌍](#translation-wira-sandy "Translation") |
-| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=takuy "Code") | [<img src="https://avatars1.githubusercontent.com/u/264022?v=4" width="110px;"/><br /><sub>Azerothian</sub>](https://www.illisian.com.au)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Azerothian "Code") | [<img src="https://avatars1.githubusercontent.com/u/4930051?v=4" width="110px;"/><br /><sub>Wes Hulette</sub>](http://macfoo.wordpress.com/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jwhulette "Code") | [<img src="https://avatars0.githubusercontent.com/u/8134591?v=4" width="110px;"/><br /><sub>patrict</sub>](https://github.com/patrict)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=patrict "Code") |
+| [<img src="https://avatars2.githubusercontent.com/u/8663789?v=4" width="110px;"/><br /><sub>Илья</sub>](https://github.com/GrayHoax)<br />[🌍](#translation-GrayHoax "Translation") | [<img src="https://avatars3.githubusercontent.com/u/30119111?v=4" width="110px;"/><br /><sub>GodUseVPN</sub>](https://github.com/godusevpn)<br />[🌍](#translation-godusevpn "Translation") | [<img src="https://avatars1.githubusercontent.com/u/745576?v=4" width="110px;"/><br /><sub>周周</sub>](https://github.com/EngrZhou)<br />[🌍](#translation-EngrZhou "Translation") | [<img src="https://avatars3.githubusercontent.com/u/1631095?v=4" width="110px;"/><br /><sub>Sam</sub>](https://github.com/takuy)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=takuy "Code") | [<img src="https://avatars1.githubusercontent.com/u/264022?v=4" width="110px;"/><br /><sub>Azerothian</sub>](https://www.illisian.com.au)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Azerothian "Code") | [<img src="https://avatars1.githubusercontent.com/u/7632599?v=4" width="110px;"/><br /><sub>Tim Farmer</sub>](https://github.com/timothyfarmer)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=timothyfarmer "Code") | [<img src="https://avatars0.githubusercontent.com/u/17459600?v=4" width="110px;"/><br /><sub>MariΓ‘n Skrip</sub>](https://github.com/mskrip)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=mskrip "Code") |
+ | [<img src="https://avatars3.githubusercontent.com/u/2611616?v=4" width="110px;"/><br /><sub>Dmitriy Minaev</sub>](https://github.com/VELIKII-DIVAN)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=VELIKII-DIVAN "Code") | [<img src="https://avatars0.githubusercontent.com/u/5132245?v=4" width="110px;"/><br /><sub>liquidhorse</sub>](https://github.com/liquidhorse)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=liquidhorse "Code") | [<img src="https://avatars1.githubusercontent.com/u/183678?v=4" width="110px;"/><br /><sub>Jordi Boggiano</sub>](https://seld.be/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Seldaek "Code") | [<img src="https://avatars0.githubusercontent.com/u/653557?v=4" width="110px;"/><br /><sub>Ivan Nieto</sub>](https://github.com/inietov)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=inietov "Code") | [<img src="https://avatars2.githubusercontent.com/u/6764151?v=4" width="110px;"/><br /><sub>Ben RUBSON</sub>](https://github.com/benrubson)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=benrubson "Code") | [<img src="https://avatars2.githubusercontent.com/u/8554558?v=4" width="110px;"/><br /><sub>NMathar</sub>](https://github.com/NMathar)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=NMathar "Code") | [<img src="https://avatars1.githubusercontent.com/u/139566?v=4" width="110px;"/><br /><sub>Steffen</sub>](https://github.com/smb)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=smb "Code") |
+ | [<img src="https://avatars0.githubusercontent.com/u/6609453?v=4" width="110px;"/><br /><sub>Sxderp</sub>](https://github.com/Sxderp)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Sxderp "Code") | [<img src="https://avatars1.githubusercontent.com/u/4807843?v=4" width="110px;"/><br /><sub>fanta8897</sub>](https://github.com/fanta8897)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=fanta8897 "Code") | [<img src="https://avatars2.githubusercontent.com/u/2576509?v=4" width="110px;"/><br /><sub>Andrey Bolonin</sub>](https://andreybolonin.com/phpconsulting/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=andreybolonin "Code") | [<img src="https://avatars3.githubusercontent.com/u/2173307?v=4" width="110px;"/><br /><sub>shinayoshi</sub>](http://www.shinayoshi.net/)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=shinayoshi "Code") | [<img src="https://avatars3.githubusercontent.com/u/2130159?v=4" width="110px;"/><br /><sub>Hubert</sub>](https://github.com/reuser)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=reuser "Code") | [<img src="https://avatars0.githubusercontent.com/u/6865789?v=4" width="110px;"/><br /><sub>KeenRivals</sub>](https://brashear.me)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=KeenRivals "Code") | [<img src="https://avatars3.githubusercontent.com/u/2902513?v=4" width="110px;"/><br /><sub>omyno</sub>](https://github.com/omyno)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=omyno "Code") |
+ | [<img src="https://avatars1.githubusercontent.com/u/6271335?v=4" width="110px;"/><br /><sub>Evgeny</sub>](https://github.com/jackka)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=jackka "Code") | [<img src="https://avatars2.githubusercontent.com/u/1169963?v=4" width="110px;"/><br /><sub>Colin Campbell</sub>](https://digitalist.se)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=colin-campbell "Code") | [<img src="https://avatars3.githubusercontent.com/u/2872098?v=4" width="110px;"/><br /><sub>Δ½ubomΓ­r Kučera</sub>](https://github.com/lubo)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=lubo "Code") | [<img src="https://avatars3.githubusercontent.com/u/570639?v=4" width="110px;"/><br /><sub>Martin Meredith</sub>](https://www.sourceguru.net)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=Mezzle "Code") | [<img src="https://avatars1.githubusercontent.com/u/7632599?v=4" width="110px;"/><br /><sub>Tim Farmer</sub>](https://github.com/timothyfarmer)<br />[πŸ’»](https://github.com/snipe/snipe-it/commits?author=timothyfarmer "Code") |
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
diff --cc app/Http/Controllers/Api/AssetsController.php
index 86a68aa686,a07f186620..9b388ddc61
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@@ -498,10 -515,30 +518,36 @@@ class AssetsController extends Controll
($request->filled('model_id')) ?
$asset->model()->associate(AssetModel::find($request->get('model_id'))) : null;
+ ($request->filled('rtd_location_id')) ?
+ $asset->location_id = $request->get('rtd_location_id') : '';
($request->filled('company_id')) ?
- $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : null;
+ $asset->company_id = Company::getIdForCurrentUser($request->get('company_id')) : '';
+
++($request->filled('rtd_location_id')) ?
++ $asset->location_id = $request->get('rtd_location_id') : null;
++
++
+ if ($request->filled('image_source')) {
+ if ($request->input('image_source') == "") {
+ ($request->filled('rtd_location_id')) ?
+ $asset->location_id = $request->get('rtd_location_id') : null;
+ $asset->image = null;
+ } else {
+ $saved_image_path = Helper::processUploadedImage(
+ $request->input('image_source'), 'uploads/assets/'
+ );
+
+ if (!$saved_image_path) {
+ return response()->json(Helper::formatStandardApiResponse(
+ 'error',
+ null,
+ trans('admin/hardware/message.update.error')
+ ), 200);
+ }
+
+ $asset->image = $saved_image_path;
+ }
+ }
// Update custom fields
if (($model = AssetModel::find($asset->model_id)) && (isset($model->fieldset))) {
diff --cc app/Http/Controllers/Api/LocationsController.php
index 2e08472bb4,3410a880b7..03ef65095d
--- a/app/Http/Controllers/Api/LocationsController.php
+++ b/app/Http/Controllers/Api/LocationsController.php
@@@ -2,14 -2,13 +2,15 @@@
namespace App\Http\Controllers\Api;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
use App\Helpers\Helper;
- use App\Models\Location;
+ use App\Http\Controllers\Controller;
use App\Http\Transformers\LocationsTransformer;
use App\Http\Transformers\SelectlistTransformer;
+ use App\Models\Location;
+use Illuminate\Pagination\LengthAwarePaginator;
+use Illuminate\Support\Collection;
+ use Illuminate\Http\Request;
+ use Illuminate\Support\Facades\Storage;
class LocationsController extends Controller
{
@@@ -226,33 -193,21 +227,33 @@@
'locations.image',
]);
+ $page = 1;
+ if ($request->filled('page')) {
+ $page = $request->input('page');
+ }
+
if ($request->filled('search')) {
- $locations = $locations->where('locations.name', 'LIKE', '%'.$request->get('search').'%');
+ \Log::debug('Searching... ');
+ $locations = $locations->where('locations.name', 'LIKE', '%'.$request->input('search').'%');
}
- $locations = $locations->orderBy('name', 'ASC')->paginate(50);
+ $locations = $locations->orderBy('name', 'ASC')->get();
- // Loop through and set some custom properties for the transformer to use.
- // This lets us have more flexibility in special cases like assets, where
- // they may not have a ->name value but we want to display something anyway
+ $locations_with_children = [];
foreach ($locations as $location) {
- if(!array_key_exists($location->parent_id, $locations_with_children)) {
- $locations_with_children[$location->parent_id] = [];
+ $location->use_text = $location->name;
+ $location->use_image = ($location->image) ? Storage::disk('public')->url('locations/'.$location->image, $location->image): null;
+ }
+ $locations_with_children[$location->parent_id][] = $location;
}
- return (new SelectlistTransformer)->transformSelectlist($locations);
+ $location_options = Location::indenter($locations_with_children);
+
+ $locations_formatted = new Collection($location_options);
+ $paginated_results = new LengthAwarePaginator($locations_formatted->forPage($page, 500), $locations_formatted->count(), 500, $page, []);
+
+ //return [];
+ return (new SelectlistTransformer)->transformSelectlist($paginated_results);
}
diff --cc app/Http/Controllers/Api/SettingsController.php
index c026224883,e008c3a877..7530972f2b
--- a/app/Http/Controllers/Api/SettingsController.php
+++ b/app/Http/Controllers/Api/SettingsController.php
@@@ -24,82 -35,52 +35,55 @@@ class SettingsController extends Contro
return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400);
}
- \Log::debug('Preparing to test LDAP connection');
+ // The connect, bind and resulting users message
+ $message = [];
+ Log::info('Preparing to test LDAP user login');
+ // Test user can connect to the LDAP server
try {
- $connection = Ldap::connectToLdap();
- try {
- \Log::debug('attempting to bind to LDAP for LDAP test');
- Ldap::bindAdminToLdap($connection);
- return response()->json(['message' => 'It worked!'], 200);
- } catch (\Exception $e) {
- \Log::debug('Bind failed');
- return response()->json(['message' => $e->getMessage()], 400);
- //return response()->json(['message' => $e->getMessage()], 500);
+ $ldap->testLdapAdUserConnection();
+ $message['login'] = [
+ 'message' => 'Successfully connected to LDAP server.'
+ ];
+ } catch (\Exception $ex) {
+ return response()->json([
+ 'message' => 'Error logging into LDAP server, error: ' . $ex->getMessage() . ' - Verify your that your username and password are correct'
+ }
+ } catch (\Exception $e) {
+ \Log::debug('Connection failed but we cannot debug it any further on our end.');
- return response()->json(['message' => $e->getMessage()], 600);
+ ], 400);
}
-
- }
-
- public function ldaptestlogin(Request $request)
- {
-
- if (Setting::getSettings()->ldap_enabled!='1') {
- \Log::debug('LDAP is not enabled. Cannot test.');
- return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400);
- }
-
-
- $rules = array(
- 'ldaptest_user' => 'required',
- 'ldaptest_password' => 'required'
- );
-
- $validator = Validator::make($request->all(), $rules);
- if ($validator->fails()) {
- \Log::debug('LDAP Validation test failed.');
- $validation_errors = implode(' ',$validator->errors()->all());
- return response()->json(['message' => $validator->errors()->all()], 400);
+ Log::info('Preparing to test LDAP bind connection');
+ // Test user can bind to the LDAP server
+ try {
+ $ldap->testLdapAdBindConnection();
+ $message['bind'] = [
+ 'message' => 'Successfully binded to LDAP server.'
+ ];
+ } catch (\Exception $ex) {
+ return response()->json([
+ 'message' => 'Error binding to LDAP server, error: ' . $ex->getMessage()
+ ], 400);
}
-
- \Log::debug('Preparing to test LDAP login');
+ Log::info('Preparing to get sample user set from LDAP directory');
+ // Get a sample of 10 users so user can verify the data is correct
try {
- $connection = Ldap::connectToLdap();
- try {
- Ldap::bindAdminToLdap($connection);
- \Log::debug('Attempting to bind to LDAP for LDAP test');
- try {
- $ldap_user = Ldap::findAndBindUserLdap($request->input('ldaptest_user'), $request->input('ldaptest_password'));
- if ($ldap_user) {
- \Log::debug('It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.');
- return response()->json(['message' => 'It worked! '. $request->input('ldaptest_user').' successfully binded to LDAP.'], 200);
- }
- return response()->json(['message' => 'Login Failed. '. $request->input('ldaptest_user').' did not successfully bind to LDAP.'], 400);
-
- } catch (\Exception $e) {
- \Log::debug('LDAP login failed');
- return response()->json(['message' => $e->getMessage()], 400);
- }
-
- } catch (\Exception $e) {
- \Log::debug('Bind failed');
- return response()->json(['message' => $e->getMessage()], 400);
- //return response()->json(['message' => $e->getMessage()], 500);
- }
- } catch (\Exception $e) {
- \Log::debug('Connection failed');
- return response()->json(['message' => $e->getMessage()], 500);
+ $users = $ldap->testUserImportSync();
+ $message['user_sync'] = [
+ 'users' => $users
+ ];
+ } catch (\Exception $ex) {
+ $message['user_sync'] = [
+ 'message' => 'Error getting users from LDAP directory, error: ' . $ex->getMessage()
+ ];
+ return response()->json($message, 400);
}
-
+ return response()->json($message, 200);
}
-
public function slacktest()
{
diff --cc app/Http/Controllers/Assets/AssetFilesController.php
index 4ce67fc84a,49b7af9cae..cbf15219b7
--- a/app/Http/Controllers/Assets/AssetFilesController.php
+++ b/app/Http/Controllers/Assets/AssetFilesController.php
@@@ -109,18 -114,13 +114,17 @@@ class AssetFilesController extends Cont
// the asset is valid
if (isset($asset->id)) {
$this->authorize('update', $asset);
-
$log = Actionlog::find($fileId);
+ if ($log) {
- $full_filename = $destinationPath.'/'.$log->filename;
- if (file_exists($full_filename)) {
- unlink($destinationPath.'/'.$log->filename);
+ if (file_exists(base_path().'/'.$rel_path.'/'.$log->filename)) {
+ Storage::disk('public')->delete($rel_path.'/'.$log->filename);
+ }
+ $log->delete();
+ return redirect()->back()->with('success', trans('admin/hardware/message.deletefile.success'));
}
- return redirect()->back()->with('error', 'Could not find matching upload log.');
-
+ $log->delete();
+ return redirect()->back()
+ ->with('success', trans('admin/hardware/message.deletefile.success'));
}
// Redirect to the hardware management page
diff --cc app/Http/Controllers/CategoriesController.php
index e487d9078c,6e174f9398..dfbaf10e34
--- a/app/Http/Controllers/CategoriesController.php
+++ b/app/Http/Controllers/CategoriesController.php
@@@ -151,39 -134,9 +134,9 @@@ class CategoriesController extends Cont
$category->use_default_eula = $request->input('use_default_eula', '0');
$category->require_acceptance = $request->input('require_acceptance', '0');
$category->checkin_email = $request->input('checkin_email', '0');
-
- $old_image = $category->image;
-
- // Set the model's image property to null if the image is being deleted
- if ($request->input('image_delete') == 1) {
- $category->image = null;
- }
-
- if ($request->file('image')) {
- $image = $request->file('image');
- $file_name = $category->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
-
- if ($image->getClientOriginalExtension()!='svg') {
- Image::make($image->getRealPath())->resize(800, null, function ($constraint) {
- $constraint->aspectRatio();
- $constraint->upsize();
- })->save(app('categories_upload_path').$file_name);
- } else {
- $image->move(app('categories_upload_path'), $file_name);
- }
- $category->image = $file_name;
-
- }
--
- if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
- try {
- unlink(app('categories_upload_path').$old_image);
- } catch (\Exception $e) {
- \Log::info($e);
- }
- }
+ $category = $request->handleImages($category);
+
if ($category->save()) {
// Redirect to the new category page
return redirect()->route('categories.index')->with('success', trans('admin/categories/message.update.success'));
diff --cc app/Http/Controllers/DepartmentsController.php
index f7087e2b8b,434ccc26dc..f3210257b0
--- a/app/Http/Controllers/DepartmentsController.php
+++ b/app/Http/Controllers/DepartmentsController.php
@@@ -51,18 -53,9 +53,9 @@@ class DepartmentsController extends Con
$department = new Department;
$department->fill($request->all());
$department->user_id = Auth::user()->id;
- $department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
+ $department->manager_id = ($request->filled('manager_id' ) ? $request->input('manager_id') : null);
- if ($request->file('image')) {
- $image = $request->file('image');
- $file_name = str_random(25).".".$image->getClientOriginalExtension();
- $path = public_path('uploads/departments/'.$file_name);
- Image::make($image->getRealPath())->resize(800, null, function ($constraint) {
- $constraint->aspectRatio();
- $constraint->upsize();
- })->save($path);
- $department->image = $file_name;
- }
+ $department = $request->handleImages($department);
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.create.success'));
diff --cc app/Http/Controllers/LocationsController.php
index bf8a279c2e,6f86bcae9f..77776084ba
--- a/app/Http/Controllers/LocationsController.php
+++ b/app/Http/Controllers/LocationsController.php
@@@ -163,38 -157,9 +149,34 @@@ class LocationsController extends Contr
$location->ldap_ou = $request->input('ldap_ou');
$location->manager_id = $request->input('manager_id');
- $old_image = $location->image;
+ $location = $request->handleImages($location, 'public/uploads/locations');
- // Set the model's image property to null if the image is being deleted
- if ($request->input('image_delete') == 1) {
- $location->image = null;
- }
+ if ($request->file('image')) {
+ $image = $request->file('image');
+ $file_name = $location->id.'-'.str_slug($image->getClientOriginalName()) . "." . $image->getClientOriginalExtension();
+
+ if ($image->getClientOriginalExtension()!='svg') {
+ Image::make($image->getRealPath())->resize(800, null, function ($constraint) {
+ $constraint->aspectRatio();
+ $constraint->upsize();
+ })->save(app('locations_upload_path').$file_name);
+ } else {
+ $image->move(app('locations_upload_path'), $file_name);
+ }
+ $location->image = $file_name;
+
+ }
+
+ if ((($request->file('image')) && (isset($old_image)) && ($old_image!='')) || ($request->input('image_delete') == 1)) {
+ try {
+ unlink(app('locations_upload_path').$old_image);
+ } catch (\Exception $e) {
+ \Log::info($e);
+ }
+ }
+
+
if ($location->save()) {
return redirect()->route("locations.index")->with('success', trans('admin/locations/message.update.success'));
}
@@@ -216,22 -182,29 +199,29 @@@
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found'));
}
- if ($location->users->count() > 0) {
+ if ($location->users()->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
- } elseif ($location->childLocations()->count() > 0) {
+ } elseif ($location->children->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc'));
- } elseif ($location->assets->count() > 0) {
+ } elseif ($location->assets()->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
- } elseif ($location->assignedassets->count() > 0) {
+ } elseif ($location->assignedassets()->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
- } else {
- $location->delete();
- return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
}
+
+ if ($location->image) {
+ try {
+ Storage::disk('public')->delete('locations/'.$location->image);
+ } catch (\Exception $e) {
+ \Log::error($e);
+ }
+ }
+ $location->delete();
+ return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
}
diff --cc app/Http/Controllers/ReportsController.php
index 727d04308d,c5870e52d0..ff5bc049ef
--- a/app/Http/Controllers/ReportsController.php
+++ b/app/Http/Controllers/ReportsController.php
@@@ -306,10 -310,7 +310,10 @@@ class ReportsController extends Control
*/
public function postCustom(Request $request)
{
-
+ ini_set('max_execution_time', 12000);
+ $this->authorize('reports.view');
+
+
\Debugbar::disable();
$customfields = CustomField::get();
$response = new StreamedResponse(function () use ($customfields, $request) {
diff --cc app/Http/Controllers/SettingsController.php
index 6e0cc055ea,0af5eb7425..c2d91fd5fd
--- a/app/Http/Controllers/SettingsController.php
+++ b/app/Http/Controllers/SettingsController.php
@@@ -240,22 -231,21 +231,21 @@@ class SettingsController extends Contro
}
/**
- * Migrate the database tables, and return the output
- * to a view for Setup
- *
- * @author [A. Gianotto] [<[email protected]>]
- * @since [v3.0]
- * @return View
- */
+ * Migrate the database tables, and return the output
+ * to a view for Setup.
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ *
+ * @since [v3.0]
+ *
+ * @return View
+ */
public function getSetupMigrate()
{
-
Artisan::call('migrate', ['--force' => true]);
-
+ if ((! file_exists(storage_path() . '/oauth-private.key')) || (! file_exists(storage_path() . '/oauth-public.key'))) {
+
- $output = Artisan::output();
-
- if ((!file_exists(storage_path().'/oauth-private.key')) || (!file_exists(storage_path().'/oauth-public.key'))) {
- Artisan::call('migrate', ['--force' => true]);
+ Artisan::call('migrate', ['--path' => 'vendor/laravel/passport/database/migrations', '--force' => true]);
Artisan::call('passport:install');
}
@@@ -360,12 -354,10 +354,11 @@@
return redirect()->route('settings.index')
->with('success', trans('admin/settings/message.update.success'));
}
- return redirect()->back()->withInput()->withErrors($setting->getErrors());
+ return redirect()->back()->withInput()->withErrors($setting->getErrors());
}
+
-
/**
* Return a form to allow a super admin to update settings.
*
@@@ -412,10 -405,10 +406,11 @@@
$setting->custom_css = $request->input('custom_css');
}
+
// If the user wants to clear the logo, reset the brand type
- if ($request->input('clear_logo')=='1') {
- $setting->logo = null;
+ if ('1' == $request->input('clear_logo')) {
+ Storage::disk('public')->delete($setting->logo);
+ $setting->logo = null;
$setting->brand = 1;
// If they are uploading an image, validate it and upload it
@@@ -441,12 -526,10 +528,11 @@@
return redirect()->route('settings.index')
->with('success', trans('admin/settings/message.update.success'));
}
- return redirect()->back()->withInput()->withErrors($setting->getErrors());
+ return redirect()->back()->withInput()->withErrors($setting->getErrors());
}
+
-
/**
* Return a form to allow a super admin to update settings.
*
@@@ -470,15 -557,12 +560,12 @@@
*/
public function postSecurity(Request $request)
{
-
- if (is_null($setting = Setting::first())) {
+ if (is_null($setting = Setting::getSettings())) {
return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error'));
}
-
+ if (! config('app.lock_passwords')) {
+
-
- if (!config('app.lock_passwords')) {
-
- if ($request->input('two_factor_enabled')=='') {
+ if ('' == $request->input('two_factor_enabled')) {
$setting->two_factor_enabled = null;
} else {
$setting->two_factor_enabled = $request->input('two_factor_enabled');
@@@ -810,13 -905,8 +908,13 @@@
$setting->labels_display_tag = 1;
} else {
$setting->labels_display_tag = 0;
- }
+ }
+ if ($request->filled('labels_display_tag')) {
+ $setting->labels_display_tag = 1;
+ } else {
+ $setting->labels_display_tag = 0;
+ }
if ($request->filled('labels_display_model')) {
$setting->labels_display_model = 1;
diff --cc app/Models/User.php
index 81a1fd6945,c17128d940..2a9e68a4e1
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@@ -99,9 -99,20 +100,20 @@@ class User extends SnipeModel implement
'userloc' => ['name'],
'department' => ['name'],
'groups' => ['name'],
+ 'company' => ['name'],
'manager' => ['first_name', 'last_name', 'username']
- ];
+ ];
+ /**
+ * Check user permissions
+ *
+ * Parses the user and group permission masks to see if the user
+ * is authorized to do the thing
+ *
+ * @author A. Gianotto <[email protected]>
+ * @since [v1.0]
+ * @return boolean
+ */
public function hasAccess($section)
{
if ($this->isSuperUser()) {
@@@ -258,9 -359,14 +360,13 @@@
return $this->belongsTo('\App\Models\Location', 'location_id')->withTrashed();
}
-
/**
- * Get the user's manager based on the assigned user
- **/
+ * Establishes the user -> manager relationship
+ *
+ * @author A. Gianotto <[email protected]>
+ * @since [v4.0]
+ * @return \Illuminate\Database\Eloquent\Relations\Relation
+ */
public function manager()
{
return $this->belongsTo('\App\Models\User', 'manager_id')->withTrashed();
diff --cc app/Providers/SettingsServiceProvider.php
index 7577b94f5b,e636846e32..5cc51d37db
--- a/app/Providers/SettingsServiceProvider.php
+++ b/app/Providers/SettingsServiceProvider.php
@@@ -108,15 -115,15 +115,43 @@@ class SettingsServiceProvider extends S
});
\App::singleton('companies_upload_url', function(){
- return url('/').'/uploads/companies/';
+ return 'storage/public_uploads/companies/';
+ });
+
+ // Accessories paths and URLs
+ \App::singleton('accessories_upload_path', function(){
+ return public_path('/uploads/accessories/');
+ });
+
+ \App::singleton('accessories_upload_url', function(){
++ return url('/').'/uploads/accessories/';
++ });
++
++ // Consumables paths and URLs
++ \App::singleton('consumables_upload_path', function(){
++ return public_path('/uploads/consumables/');
++ });
++
++ \App::singleton('consumables_upload_url', function(){
++ return url('/').'/uploads/consumables/';
++ });
++
++
++ // Components paths and URLs
++ \App::singleton('components_upload_path', function(){
++ return public_path('/uploads/components/');
++ });
++
++ \App::singleton('components_upload_url', function(){
++ return url('/').'/uploads/components/';
+ });
+
+ // Accessories paths and URLs
+ \App::singleton('accessories_upload_path', function(){
+ return public_path('/uploads/accessories/');
+ });
+
+ \App::singleton('accessories_upload_url', function(){
return url('/').'/uploads/accessories/';
});
diff --cc config/database.php
index a9ee17dd56,5ae449e758..97cf261f60
--- a/config/database.php
+++ b/config/database.php
@@@ -82,11 -82,12 +82,14 @@@ return
'unix_socket' => env('DB_SOCKET',''),
'dump' => [
'dump_binary_path' => env('DB_DUMP_PATH', '/usr/local/bin'), // only the path, so without 'mysqldump'
- 'use_single_transaction',
+ 'use_single_transaction' => false,
'timeout' => 60 * 5, // 5 minute timeout
+ //'exclude_tables' => ['table1', 'table2'],
+ //'add_extra_option' => '--optionname=optionvalue',
],
+
+ 'dump_command_timeout' => 60 * 5, // 5 minute timeout
+ 'dump_using_single_transaction' => true, // perform dump using a single transaction
'options' => (env('DB_SSL')) ? [
PDO::MYSQL_ATTR_SSL_KEY => env('DB_SSL_KEY_PATH'), // /path/to/key.pem
PDO::MYSQL_ATTR_SSL_CERT => env('DB_SSL_CERT_PATH'), // /path/to/cert.pem
diff --cc resources/views/hardware/view.blade.php
index a397044bc4,4d5f39bbb9..cd2e8abbd0
--- a/resources/views/hardware/view.blade.php
+++ b/resources/views/hardware/view.blade.php
@@@ -498,13 -499,9 +499,13 @@@
<div class="col-md-4">
@if ($asset->image)
+ <div class="col-md-12 text-center" style="padding-bottom: 15px;">
- <a href="{{ url('/') }}/uploads/assets/{{ $asset->image }}" data-toggle="lightbox"><img src="{{ url('/') }}/uploads/assets/{{{ $asset->image }}}" class="assetimg img-responsive"></a>
+ <img src="{{ Storage::disk('public')->url(app('assets_upload_path').e($asset->image)) }}" class="assetimg img-responsive">
+ </div>
@elseif (($asset->model) && ($asset->model->image!=''))
+ <div class="col-md-12 text-center" style="padding-bottom: 15px;">
- <a href="{{ url('/') }}/uploads/models/{{ $asset->model->image }}" data-toggle="lightbox"><img src="{{ url('/') }}/uploads/models/{{ $asset->model->image }}" class="assetimg img-responsive"></a>
+ <img src="{{ Storage::disk('public')->url(app('models_upload_url').e($asset->model->image )) }}" class="assetimg img-responsive">
+ </div>
@endif
@if ($snipeSettings->qr_code=='1')
diff --cc resources/views/layouts/default.blade.php
index 825236cb25,eabddf976c..43a59c746c
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@@ -11,25 -11,13 +11,13 @@@
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
- <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
<link rel="apple-touch-startup-image" href="{{ url('/') }}/uploads/{{ $snipeSettings->logo }}">
+ <link rel="shortcut icon" type="image/ico" href="{{ ($snipeSettings) && ($snipeSettings->favicon!='') ? Storage::disk('public')->url('').e($snipeSettings->favicon) : 'favicon.ico' }} ">
- <!-- Select2 -->
- <link rel="stylesheet" href="{{ url(asset('js/plugins/select2/select2.min.css')) }}">
-
- <!-- iCheck for checkboxes and radio inputs -->
- <link rel="stylesheet" href="{{ url(asset('js/plugins/iCheck/all.css')) }}">
-
- <!-- bootstrap tables CSS -->
- <link rel="stylesheet" href="{{ url(asset('css/bootstrap-table.css')) }}">
-
- <link rel="stylesheet" href="{{ url(mix('css/dist/all.css')) }}">
-
- <link rel="shortcut icon" type="image/ico" href="{{ url(asset('favicon.ico')) }}">
-
- <meta name="csrf-token" content="{{ csrf_token() }}">
+ <meta name="csrf-token" content="{{ csrf_token() }}">
<meta name="baseUrl" content="{{ url('/') }}/">
<script nonce="{{ csrf_token() }}">
diff --cc routes/web/hardware.php
index 35decdc2b5,1f34a661e8..2ed8e323fe
--- a/routes/web/hardware.php
+++ b/routes/web/hardware.php
@@@ -26,9 -26,19 +26,29 @@@ Route::group
Route::get('scan', [
'as' => 'asset.scan',
- 'uses' => 'AssetsController@scan'
+ 'uses' => 'Assets\AssetsController@scan'
+ ]);
+
+ Route::get('audit/due', [
+ 'as' => 'assets.audit.due',
+ 'uses' => 'Assets\AssetsController@dueForAudit'
+ ]);
+
+ Route::get('audit/overdue', [
+ 'as' => 'assets.audit.overdue',
+ 'uses' => 'Assets\AssetsController@overdueForAudit'
+ ]);
+
++ Route::get('audit/due', [
++ 'as' => 'assets.audit.due',
++ 'uses' => 'AssetsController@dueForAudit'
++ ]);
++
++ Route::get('audit/overdue', [
++ 'as' => 'assets.audit.overdue',
++ 'uses' => 'AssetsController@overdueForAudit'
+ ]);
+
Route::get('audit/due', [
'as' => 'assets.audit.due',
'uses' => 'AssetsController@dueForAudit'