Merge remote-tracking branch 'origin/develop'

This commit is contained in:
snipe 2025-02-10 22:42:58 +00:00
commit e37a990820
8 changed files with 56 additions and 47 deletions

View file

@ -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 // Prepare the error message
return redirect()->route('accessories.index') return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
->with('error', trans('general.file_does_not_exist'));
} }
/** /**
@ -72,29 +72,27 @@ class AccessoriesFilesController extends Controller
*/ */
public function destroy($accessoryId = null, $fileId = null) : RedirectResponse public function destroy($accessoryId = null, $fileId = null) : RedirectResponse
{ {
$accessory = Accessory::find($accessoryId); if ($accessory = Accessory::find($accessoryId)) {
// the asset is valid
if (isset($accessory->id)) {
$this->authorize('update', $accessory); $this->authorize('update', $accessory);
$log = Actionlog::find($fileId);
// Remove the file if one exists if ($log = Actionlog::find($fileId)) {
if (Storage::exists('accessories/'.$log->filename)) {
try { if (Storage::exists('private_uploads/accessories/'.$log->filename)) {
Storage::delete('accessories/'.$log->filename); try {
} catch (\Exception $e) { Storage::delete('private_uploads/accessories/' . $log->filename);
Log::debug($e); $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'));
}
} }
} }
return redirect()->route('accessories.show', ['accessory' => $accessory])->withFragment('files')->with('error', trans('general.log_record_not_found'));
$log->delete();
return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success'));
} }
// Redirect to the licence management page return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
return redirect()->route('accessories.index')->with('error', trans('general.file_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'));
} }
} }

View file

@ -62,7 +62,7 @@ class SettingsSamlRequest extends FormRequest
$custom_privateKey = ''; $custom_privateKey = '';
$custom_x509certNew = ''; $custom_x509certNew = '';
if (! empty($this->input('saml_custom_settings'))) { 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 = []; $custom_settings = [];
foreach ($req_custom_settings as $custom_setting) { foreach ($req_custom_settings as $custom_setting) {

View file

@ -307,7 +307,7 @@ class CustomField extends Model
public function formatFieldValuesAsArray() public function formatFieldValuesAsArray()
{ {
$result = []; $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')) { if (($this->element != 'checkbox') && ($this->element != 'radio')) {
$result[''] = 'Select '.strtolower($this->format); $result[''] = 'Select '.strtolower($this->format);

View file

@ -79,7 +79,7 @@ class CheckinAssetNotification extends Notification
$fields = [ $fields = [
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', 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 : '', trans('general.location') => ($item->location) ? $item->location->name : '',
]; ];
@ -106,9 +106,9 @@ class CheckinAssetNotification extends Notification
->title(trans('mail.Asset_Checkin_Notification')) ->title(trans('mail.Asset_Checkin_Notification'))
->addStartGroupToSection('activityText') ->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', '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('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 ?: ''); ->fact(trans('mail.notes'), $note ?: '');
} }
@ -116,9 +116,9 @@ class CheckinAssetNotification extends Notification
$message = trans('mail.Asset_Checkin_Notification'); $message = trans('mail.Asset_Checkin_Notification');
$details = [ $details = [
trans('mail.asset') => htmlspecialchars_decode($item->present()->name), 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('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 ?: '', trans('mail.notes') => $note ?: '',
]; ];
@ -142,8 +142,8 @@ class CheckinAssetNotification extends Notification
Section::create( Section::create(
KeyValue::create( KeyValue::create(
trans('mail.checked_into') ?: '', trans('mail.checked_into') ?: '',
$item->location->name ? $item->location->name : '', ($item->location) ? $item->location->name : '',
trans('admin/hardware/form.status').": ".$item->assetstatus->name, trans('admin/hardware/form.status').": ".$item->assetstatus?->name,
) )
->onClick(route('hardware.show', $item->id)) ->onClick(route('hardware.show', $item->id))
) )

View file

@ -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) { if ($custom_settings) {
foreach ($custom_settings as $custom_setting) { foreach ($custom_settings as $custom_setting) {
$split = explode('=', $custom_setting, 2); $split = explode('=', $custom_setting, 2);

View file

@ -128,7 +128,7 @@
<div class="form-group{{ $errors->has('image_delete') ? ' has-error' : '' }}"> <div class="form-group{{ $errors->has('image_delete') ? ' has-error' : '' }}">
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label for="image_delete" class="form-control"> <label for="image_delete" class="form-control">
{{ Form::checkbox('image_delete', '1', old('image_delete'), ['id' => 'image_delete', 'aria-label'=>'image_delete']) }} <input type="checkbox" name="image_delete" id="image_delete" value="1" @checked(old('image_delete')) aria-label="image_delete">
{{ trans('general.image_delete') }} {{ trans('general.image_delete') }}
</label> </label>
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!} {!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
@ -150,13 +150,23 @@
@if ($snipeSettings->two_factor_enabled=='1') @if ($snipeSettings->two_factor_enabled=='1')
<div class="form-group {{ $errors->has('two_factor_optin') ? 'has-error' : '' }}"> <div class="form-group {{ $errors->has('two_factor_optin') ? 'has-error' : '' }}">
<div class="col-md-7 col-md-offset-3"> <div class="col-md-7 col-md-offset-3">
@can('self.two_factor') <label
<label class="form-control">{{ Form::checkbox('two_factor_optin', '1', old('two_factor_optin', $user->two_factor_optin)) }} for="two_factor_optin"
@else @class([
<label class="form-control form-control--disabled">{{ Form::checkbox('two_factor_optin', '1', old('two_factor_optin', $user->two_factor_optin),['disabled' => 'disabled']) }} 'form-control',
@endcan 'form-control--disabled' => auth()->user()->cannot('self.two_factor'),
])
{{ trans('admin/settings/general.two_factor_enabled_text') }}</label> >
<input
type="checkbox"
name="two_factor_optin"
id="two_factor_optin"
value="1"
@checked(old('two_factor_optin', $user->two_factor_optin))
@disabled(auth()->user()->cannot('self.two_factor'))
>
{{ trans('admin/settings/general.two_factor_enabled_text') }}
</label>
@can('self.two_factor') @can('self.two_factor')
<p class="help-block">{{ trans('admin/settings/general.two_factor_enabled_warning') }}</p> <p class="help-block">{{ trans('admin/settings/general.two_factor_enabled_warning') }}</p>
@else @else

View file

@ -109,7 +109,7 @@
<div class="checkbox-inline"> <div class="checkbox-inline">
<label> <label>
{{ Form::checkbox('required', 'on', old('required')) }} <input type="checkbox" name="required" value="on" @checked(old('required'))>
<span style="padding-left: 10px;">{{ trans('admin/custom_fields/general.required') }}</span> <span style="padding-left: 10px;">{{ trans('admin/custom_fields/general.required') }}</span>
</label> </label>
</div> </div>

View file

@ -47,7 +47,7 @@
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('null_name', '1', false) }} <input type="checkbox" name="null_name" value="1">
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }} {{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
</label> </label>
</div> </div>
@ -66,7 +66,7 @@
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('null_purchase_date', '1', false) }} <input type="checkbox" name="null_purchase_date" value="1">
{{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }} {{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }}
</label> </label>
</div> </div>
@ -85,7 +85,7 @@
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('null_expected_checkin_date', '1', false) }} <input type="checkbox" name="null_expected_checkin_date" value="1">
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }} {{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
</label> </label>
</div> </div>
@ -103,7 +103,7 @@
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('null_asset_eol_date', '1', false) }} <input type="checkbox" name="null_asset_eol_date" value="1">
{{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }} {{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }}
</label> </label>
</div> </div>
@ -112,7 +112,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('calc_eol', '1', false) }} <input type="checkbox" name="calc_eol" value="1">
{{ trans('admin/hardware/form.calc_eol') }} {{ trans('admin/hardware/form.calc_eol') }}
</label> </label>
</div> </div>
@ -215,7 +215,7 @@
</div> </div>
<div class="col-md-5"> <div class="col-md-5">
<label class="form-control"> <label class="form-control">
{{ Form::checkbox('null_next_audit_date', '1', false) }} <input type="checkbox" name="null_next_audit_date" value="1">
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }} {{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
</label> </label>
</div> </div>