diff --git a/app/Http/Controllers/Accessories/AccessoriesFilesController.php b/app/Http/Controllers/Accessories/AccessoriesFilesController.php index c251166ce2..9dbb16d83a 100644 --- a/app/Http/Controllers/Accessories/AccessoriesFilesController.php +++ b/app/Http/Controllers/Accessories/AccessoriesFilesController.php @@ -55,11 +55,11 @@ class AccessoriesFilesController extends Controller } - return redirect()->route('accessories.show', $accessory->id)->with('error', trans('general.no_files_uploaded')); + return redirect()->route('accessories.show', $accessory->id)->withFragment('files')->with('error', trans('general.no_files_uploaded')); } // Prepare the error message - return redirect()->route('accessories.index') - ->with('error', trans('general.file_does_not_exist')); + return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); + } /** @@ -72,29 +72,27 @@ class AccessoriesFilesController extends Controller */ public function destroy($accessoryId = null, $fileId = null) : RedirectResponse { - $accessory = Accessory::find($accessoryId); - - // the asset is valid - if (isset($accessory->id)) { + if ($accessory = Accessory::find($accessoryId)) { $this->authorize('update', $accessory); - $log = Actionlog::find($fileId); - // Remove the file if one exists - if (Storage::exists('accessories/'.$log->filename)) { - try { - Storage::delete('accessories/'.$log->filename); - } catch (\Exception $e) { - Log::debug($e); + if ($log = Actionlog::find($fileId)) { + + if (Storage::exists('private_uploads/accessories/'.$log->filename)) { + try { + Storage::delete('private_uploads/accessories/' . $log->filename); + $log->delete(); + return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); + } catch (\Exception $e) { + Log::debug($e); + return redirect()->route('accessories.index')->with('error', trans('general.file_does_not_exist')); + } } + } - - $log->delete(); - - return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success')); + return redirect()->route('accessories.show', ['accessory' => $accessory])->withFragment('files')->with('error', trans('general.log_record_not_found')); } - // Redirect to the licence management page - return redirect()->route('accessories.index')->with('error', trans('general.file_does_not_exist')); + return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); } /** @@ -124,10 +122,11 @@ class AccessoriesFilesController extends Controller } } - return redirect()->route('accessories.show', ['accessory' => $accessory])->with('error', trans('general.log_record_not_found')); + return redirect()->route('accessories.show', ['accessory' => $accessory])->withFragment('files')->with('error', trans('general.log_record_not_found')); } - return redirect()->route('accessories.index')->with('error', trans('general.file_not_found')); + return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); + } } diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 6fd27ed03c..8f3b1f054b 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -535,7 +535,7 @@ class AssetsController extends Controller { $settings = Setting::getSettings(); - if ($settings->qr_code == '1') { + if (($settings->qr_code === '1') && ($settings->label2_2d_type !== 'none')) { $asset = Asset::withTrashed()->find($assetId); if ($asset) { $size = Helper::barcodeDimensions($settings->label2_2d_type); diff --git a/app/Http/Requests/SettingsSamlRequest.php b/app/Http/Requests/SettingsSamlRequest.php index 8f02d64f03..2ab876141a 100644 --- a/app/Http/Requests/SettingsSamlRequest.php +++ b/app/Http/Requests/SettingsSamlRequest.php @@ -62,7 +62,7 @@ class SettingsSamlRequest extends FormRequest $custom_privateKey = ''; $custom_x509certNew = ''; if (! empty($this->input('saml_custom_settings'))) { - $req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings')); + $req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings', '')); $custom_settings = []; foreach ($req_custom_settings as $custom_setting) { diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index b297a4f720..0811e9ee57 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -106,7 +106,13 @@ class CheckoutableListener } } } catch (ClientException $e) { - Log::error("ClientException caught during checkin notification: " . $e->getMessage()); + if (strpos($e->getMessage(), 'channel_not_found') !== false) { + Log::warning(Setting::getSettings()->webhook_selected." notification failed: " . $e->getMessage()); + return redirect()->back()->with('warning', ucfirst(Setting::getSettings()->webhook_selected) .trans('admin/settings/message.webhook.webhook_channel_not_found') ); + } + else { + Log::error("ClientException caught during checkin notification: " . $e->getMessage()); + } return redirect()->back()->with('warning', ucfirst(Setting::getSettings()->webhook_selected) .trans('admin/settings/message.webhook.webhook_fail') ); } catch (Exception $e) { Log::error(ucfirst(Setting::getSettings()->webhook_selected) . ' webhook notification failed:', [ @@ -156,7 +162,7 @@ class CheckoutableListener $ccEmails = array_filter($adminCcEmailsArray); $mailable = $this->getCheckinMailType($event); $notifiable = $this->getNotifiables($event); - if ($event->checkedOutTo->locale){ + if ($event->checkedOutTo?->locale) { $mailable->locale($event->checkedOutTo->locale); } // Send email notifications @@ -196,8 +202,14 @@ class CheckoutableListener } } } catch (ClientException $e) { - Log::error("ClientException caught during checkin notification: " . $e->getMessage()); - return redirect()->back()->with('warning', ucfirst(Setting::getSettings()->webhook_selected) .trans('admin/settings/message.webhook.webhook_fail')); + if (strpos($e->getMessage(), 'channel_not_found') !== false) { + Log::warning(Setting::getSettings()->webhook_selected." notification failed: " . $e->getMessage()); + return redirect()->back()->with('warning', ucfirst(Setting::getSettings()->webhook_selected) .trans('admin/settings/message.webhook.webhook_channel_not_found') ); + } + else { + Log::error("ClientException caught during checkin notification: " . $e->getMessage()); + return redirect()->back()->with('warning', ucfirst(Setting::getSettings()->webhook_selected) . trans('admin/settings/message.webhook.webhook_fail')); + } } catch (Exception $e) { Log::error(ucfirst(Setting::getSettings()->webhook_selected) . ' webhook notification failed:', [ 'error' => $e->getMessage(), diff --git a/app/Models/CustomField.php b/app/Models/CustomField.php index dfa4971367..81eff9b4cd 100644 --- a/app/Models/CustomField.php +++ b/app/Models/CustomField.php @@ -307,7 +307,7 @@ class CustomField extends Model public function formatFieldValuesAsArray() { $result = []; - $arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values); + $arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values ?? ''); if (($this->element != 'checkbox') && ($this->element != 'radio')) { $result[''] = 'Select '.strtolower($this->format); diff --git a/app/Notifications/CheckinAssetNotification.php b/app/Notifications/CheckinAssetNotification.php index fa4780c1fd..c6828ef8e9 100644 --- a/app/Notifications/CheckinAssetNotification.php +++ b/app/Notifications/CheckinAssetNotification.php @@ -79,7 +79,7 @@ class CheckinAssetNotification extends Notification $fields = [ trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', - trans('general.status') => $item->assetstatus->name, + trans('general.status') => $item->assetstatus?->name, trans('general.location') => ($item->location) ? $item->location->name : '', ]; @@ -106,9 +106,9 @@ class CheckinAssetNotification extends Notification ->title(trans('mail.Asset_Checkin_Notification')) ->addStartGroupToSection('activityText') ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText') - ->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '') + ->fact(trans('mail.checked_into'), ($item->location) ? $item->location->name : '') ->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName()) - ->fact(trans('admin/hardware/form.status'), $item->assetstatus->name) + ->fact(trans('admin/hardware/form.status'), $item->assetstatus?->name) ->fact(trans('mail.notes'), $note ?: ''); } @@ -116,9 +116,9 @@ class CheckinAssetNotification extends Notification $message = trans('mail.Asset_Checkin_Notification'); $details = [ trans('mail.asset') => htmlspecialchars_decode($item->present()->name), - trans('mail.checked_into') => $item->location->name ? $item->location->name : '', + trans('mail.checked_into') => ($item->location) ? $item->location->name : '', trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(), - trans('admin/hardware/form.status') => $item->assetstatus->name, + trans('admin/hardware/form.status') => $item->assetstatus?->name, trans('mail.notes') => $note ?: '', ]; @@ -142,8 +142,8 @@ class CheckinAssetNotification extends Notification Section::create( KeyValue::create( trans('mail.checked_into') ?: '', - $item->location->name ? $item->location->name : '', - trans('admin/hardware/form.status').": ".$item->assetstatus->name, + ($item->location) ? $item->location->name : '', + trans('admin/hardware/form.status').": ".$item->assetstatus?->name, ) ->onClick(route('hardware.show', $item->id)) ) diff --git a/app/Services/Saml.php b/app/Services/Saml.php index 860ec76171..222c2c2ea3 100644 --- a/app/Services/Saml.php +++ b/app/Services/Saml.php @@ -209,7 +209,7 @@ class Saml } } - $custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings); + $custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings ?? ''); if ($custom_settings) { foreach ($custom_settings as $custom_setting) { $split = explode('=', $custom_setting, 2); diff --git a/app/View/Label.php b/app/View/Label.php index bafe97ffef..22dbe6d26e 100644 --- a/app/View/Label.php +++ b/app/View/Label.php @@ -116,12 +116,9 @@ class Label implements View } } - if ($template->getSupport2DBarcode()) { + if ($template->getSupport2DBarcode()) { $barcode2DType = $settings->label2_2d_type; - $barcode2DType = ($barcode2DType == 'default') ? - $settings->barcode_type : - $barcode2DType; - if (($barcode2DType != 'none') && (!is_null($barcode2DType))) { + if (($barcode2DType != 'none') && (!is_null($barcode2DType))) { switch ($settings->label2_2d_target) { case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); diff --git a/package-lock.json b/package-lock.json index 7de7aaea76..ed97eb48c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "less-loader": "^6.0", "list.js": "^1.5.0", "morris.js": "github:morrisjs/morris.js", - "papaparse": "5.4.1", + "papaparse": "5.5.1", "select2": "4.0.13", "sheetjs": "^2.0.0", "signature_pad": "^4.2.0", @@ -8368,9 +8368,9 @@ "license": "(MIT AND Zlib)" }, "node_modules/papaparse": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", - "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==" + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.5.1.tgz", + "integrity": "sha512-EuEKUhyxrHVozD7g3/ztsJn6qaKse8RPfR6buNB2dMJvdtXNhcw8jccVi/LxNEY3HVrV6GO6Z4OoeCG9Iy9wpA==" }, "node_modules/param-case": { "version": "3.0.4", diff --git a/package.json b/package.json index e86bf90660..db5f72189d 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "less-loader": "^6.0", "list.js": "^1.5.0", "morris.js": "github:morrisjs/morris.js", - "papaparse": "5.4.1", + "papaparse": "5.5.1", "select2": "4.0.13", "sheetjs": "^2.0.0", "signature_pad": "^4.2.0", diff --git a/resources/lang/en-US/admin/settings/message.php b/resources/lang/en-US/admin/settings/message.php index 98a8893937..a256402c68 100644 --- a/resources/lang/en-US/admin/settings/message.php +++ b/resources/lang/en-US/admin/settings/message.php @@ -46,5 +46,6 @@ return [ 'error_redirect' => 'ERROR: 301/302 :endpoint returns a redirect. For security reasons, we don’t follow redirects. Please use the actual endpoint.', 'error_misc' => 'Something went wrong. :( ', 'webhook_fail' => ' webhook notification failed: Check to make sure the URL is still valid.', + 'webhook_channel_not_found' => ' webhook channel not found.' ] ]; diff --git a/resources/views/account/profile.blade.php b/resources/views/account/profile.blade.php index d27367192a..b745c19360 100755 --- a/resources/views/account/profile.blade.php +++ b/resources/views/account/profile.blade.php @@ -128,7 +128,7 @@