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
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'));
}
}

View file

@ -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) {

View file

@ -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);

View file

@ -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))
)

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

View file

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

View file

@ -109,7 +109,7 @@
<div class="checkbox-inline">
<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>
</label>
</div>

View file

@ -47,7 +47,7 @@
</div>
<div class="col-md-5">
<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)]) }}
</label>
</div>
@ -66,7 +66,7 @@
</div>
<div class="col-md-5">
<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)]) }}
</label>
</div>
@ -85,7 +85,7 @@
</div>
<div class="col-md-5">
<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)]) }}
</label>
</div>
@ -103,7 +103,7 @@
</div>
<div class="col-md-5">
<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)]) }}
</label>
</div>
@ -112,7 +112,7 @@
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('calc_eol', '1', false) }}
<input type="checkbox" name="calc_eol" value="1">
{{ trans('admin/hardware/form.calc_eol') }}
</label>
</div>
@ -215,7 +215,7 @@
</div>
<div class="col-md-5">
<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)]) }}
</label>
</div>