Skip to content

Commit e37a990

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 29311b1 + b54d68e commit e37a990

File tree

8 files changed

+56
-47
lines changed

8 files changed

+56
-47
lines changed

app/Http/Controllers/Accessories/AccessoriesFilesController.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public function store(UploadFileRequest $request, $accessoryId = null) : Redirec
5555

5656
}
5757

58-
return redirect()->route('accessories.show', $accessory->id)->with('error', trans('general.no_files_uploaded'));
58+
return redirect()->route('accessories.show', $accessory->id)->withFragment('files')->with('error', trans('general.no_files_uploaded'));
5959
}
6060
// Prepare the error message
61-
return redirect()->route('accessories.index')
62-
->with('error', trans('general.file_does_not_exist'));
61+
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
62+
6363
}
6464

6565
/**
@@ -72,29 +72,27 @@ public function store(UploadFileRequest $request, $accessoryId = null) : Redirec
7272
*/
7373
public function destroy($accessoryId = null, $fileId = null) : RedirectResponse
7474
{
75-
$accessory = Accessory::find($accessoryId);
76-
77-
// the asset is valid
78-
if (isset($accessory->id)) {
75+
if ($accessory = Accessory::find($accessoryId)) {
7976
$this->authorize('update', $accessory);
80-
$log = Actionlog::find($fileId);
8177

82-
// Remove the file if one exists
83-
if (Storage::exists('accessories/'.$log->filename)) {
84-
try {
85-
Storage::delete('accessories/'.$log->filename);
86-
} catch (\Exception $e) {
87-
Log::debug($e);
78+
if ($log = Actionlog::find($fileId)) {
79+
80+
if (Storage::exists('private_uploads/accessories/'.$log->filename)) {
81+
try {
82+
Storage::delete('private_uploads/accessories/' . $log->filename);
83+
$log->delete();
84+
return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success'));
85+
} catch (\Exception $e) {
86+
Log::debug($e);
87+
return redirect()->route('accessories.index')->with('error', trans('general.file_does_not_exist'));
88+
}
8889
}
89-
}
90-
91-
$log->delete();
9290

93-
return redirect()->back()->withFragment('files')->with('success', trans('admin/hardware/message.deletefile.success'));
91+
}
92+
return redirect()->route('accessories.show', ['accessory' => $accessory])->withFragment('files')->with('error', trans('general.log_record_not_found'));
9493
}
9594

96-
// Redirect to the licence management page
97-
return redirect()->route('accessories.index')->with('error', trans('general.file_does_not_exist'));
95+
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
9896
}
9997

10098
/**
@@ -124,10 +122,11 @@ public function show($accessoryId = null, $fileId = null) : View | RedirectRespo
124122
}
125123
}
126124

127-
return redirect()->route('accessories.show', ['accessory' => $accessory])->with('error', trans('general.log_record_not_found'));
125+
return redirect()->route('accessories.show', ['accessory' => $accessory])->withFragment('files')->with('error', trans('general.log_record_not_found'));
128126

129127
}
130128

131-
return redirect()->route('accessories.index')->with('error', trans('general.file_not_found'));
129+
return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist'));
130+
132131
}
133132
}

app/Http/Requests/SettingsSamlRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function withValidator($validator)
6262
$custom_privateKey = '';
6363
$custom_x509certNew = '';
6464
if (! empty($this->input('saml_custom_settings'))) {
65-
$req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings'));
65+
$req_custom_settings = preg_split('/\r\n|\r|\n/', $this->input('saml_custom_settings', ''));
6666
$custom_settings = [];
6767

6868
foreach ($req_custom_settings as $custom_setting) {

app/Models/CustomField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public function setFormatAttribute($value)
307307
public function formatFieldValuesAsArray()
308308
{
309309
$result = [];
310-
$arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values);
310+
$arr = preg_split('/\\r\\n|\\r|\\n/', $this->field_values ?? '');
311311

312312
if (($this->element != 'checkbox') && ($this->element != 'radio')) {
313313
$result[''] = 'Select '.strtolower($this->format);

app/Notifications/CheckinAssetNotification.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function toSlack()
7979

8080
$fields = [
8181
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',
82-
trans('general.status') => $item->assetstatus->name,
82+
trans('general.status') => $item->assetstatus?->name,
8383
trans('general.location') => ($item->location) ? $item->location->name : '',
8484
];
8585

@@ -106,19 +106,19 @@ public function toMicrosoftTeams()
106106
->title(trans('mail.Asset_Checkin_Notification'))
107107
->addStartGroupToSection('activityText')
108108
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
109-
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '')
109+
->fact(trans('mail.checked_into'), ($item->location) ? $item->location->name : '')
110110
->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName())
111-
->fact(trans('admin/hardware/form.status'), $item->assetstatus->name)
111+
->fact(trans('admin/hardware/form.status'), $item->assetstatus?->name)
112112
->fact(trans('mail.notes'), $note ?: '');
113113
}
114114

115115

116116
$message = trans('mail.Asset_Checkin_Notification');
117117
$details = [
118118
trans('mail.asset') => htmlspecialchars_decode($item->present()->name),
119-
trans('mail.checked_into') => $item->location->name ? $item->location->name : '',
119+
trans('mail.checked_into') => ($item->location) ? $item->location->name : '',
120120
trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(),
121-
trans('admin/hardware/form.status') => $item->assetstatus->name,
121+
trans('admin/hardware/form.status') => $item->assetstatus?->name,
122122
trans('mail.notes') => $note ?: '',
123123
];
124124

@@ -142,8 +142,8 @@ public function toGoogleChat()
142142
Section::create(
143143
KeyValue::create(
144144
trans('mail.checked_into') ?: '',
145-
$item->location->name ? $item->location->name : '',
146-
trans('admin/hardware/form.status').": ".$item->assetstatus->name,
145+
($item->location) ? $item->location->name : '',
146+
trans('admin/hardware/form.status').": ".$item->assetstatus?->name,
147147
)
148148
->onClick(route('hardware.show', $item->id))
149149
)

app/Services/Saml.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ private function loadSettings()
209209
}
210210
}
211211

212-
$custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings);
212+
$custom_settings = preg_split('/\r\n|\r|\n/', $setting->saml_custom_settings ?? '');
213213
if ($custom_settings) {
214214
foreach ($custom_settings as $custom_setting) {
215215
$split = explode('=', $custom_setting, 2);

resources/views/account/profile.blade.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
<div class="form-group{{ $errors->has('image_delete') ? ' has-error' : '' }}">
129129
<div class="col-md-9 col-md-offset-3">
130130
<label for="image_delete" class="form-control">
131-
{{ Form::checkbox('image_delete', '1', old('image_delete'), ['id' => 'image_delete', 'aria-label'=>'image_delete']) }}
131+
<input type="checkbox" name="image_delete" id="image_delete" value="1" @checked(old('image_delete')) aria-label="image_delete">
132132
{{ trans('general.image_delete') }}
133133
</label>
134134
{!! $errors->first('image_delete', '<span class="alert-msg">:message</span>') !!}
@@ -150,13 +150,23 @@
150150
@if ($snipeSettings->two_factor_enabled=='1')
151151
<div class="form-group {{ $errors->has('two_factor_optin') ? 'has-error' : '' }}">
152152
<div class="col-md-7 col-md-offset-3">
153-
@can('self.two_factor')
154-
<label class="form-control">{{ Form::checkbox('two_factor_optin', '1', old('two_factor_optin', $user->two_factor_optin)) }}
155-
@else
156-
<label class="form-control form-control--disabled">{{ Form::checkbox('two_factor_optin', '1', old('two_factor_optin', $user->two_factor_optin),['disabled' => 'disabled']) }}
157-
@endcan
158-
159-
{{ trans('admin/settings/general.two_factor_enabled_text') }}</label>
153+
<label
154+
for="two_factor_optin"
155+
@class([
156+
'form-control',
157+
'form-control--disabled' => auth()->user()->cannot('self.two_factor'),
158+
])
159+
>
160+
<input
161+
type="checkbox"
162+
name="two_factor_optin"
163+
id="two_factor_optin"
164+
value="1"
165+
@checked(old('two_factor_optin', $user->two_factor_optin))
166+
@disabled(auth()->user()->cannot('self.two_factor'))
167+
>
168+
{{ trans('admin/settings/general.two_factor_enabled_text') }}
169+
</label>
160170
@can('self.two_factor')
161171
<p class="help-block">{{ trans('admin/settings/general.two_factor_enabled_warning') }}</p>
162172
@else

resources/views/custom_fields/fieldsets/view.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

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

resources/views/hardware/bulk.blade.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
</div>
4848
<div class="col-md-5">
4949
<label class="form-control">
50-
{{ Form::checkbox('null_name', '1', false) }}
50+
<input type="checkbox" name="null_name" value="1">
5151
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
5252
</label>
5353
</div>
@@ -66,7 +66,7 @@
6666
</div>
6767
<div class="col-md-5">
6868
<label class="form-control">
69-
{{ Form::checkbox('null_purchase_date', '1', false) }}
69+
<input type="checkbox" name="null_purchase_date" value="1">
7070
{{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }}
7171
</label>
7272
</div>
@@ -85,7 +85,7 @@
8585
</div>
8686
<div class="col-md-5">
8787
<label class="form-control">
88-
{{ Form::checkbox('null_expected_checkin_date', '1', false) }}
88+
<input type="checkbox" name="null_expected_checkin_date" value="1">
8989
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
9090
</label>
9191
</div>
@@ -103,7 +103,7 @@
103103
</div>
104104
<div class="col-md-5">
105105
<label class="form-control">
106-
{{ Form::checkbox('null_asset_eol_date', '1', false) }}
106+
<input type="checkbox" name="null_asset_eol_date" value="1">
107107
{{ trans_choice('general.set_to_null', count($assets),['selection_count' => count($assets)]) }}
108108
</label>
109109
</div>
@@ -112,7 +112,7 @@
112112
<div class="form-group">
113113
<div class="col-md-9 col-md-offset-3">
114114
<label class="form-control">
115-
{{ Form::checkbox('calc_eol', '1', false) }}
115+
<input type="checkbox" name="calc_eol" value="1">
116116
{{ trans('admin/hardware/form.calc_eol') }}
117117
</label>
118118
</div>
@@ -215,7 +215,7 @@
215215
</div>
216216
<div class="col-md-5">
217217
<label class="form-control">
218-
{{ Form::checkbox('null_next_audit_date', '1', false) }}
218+
<input type="checkbox" name="null_next_audit_date" value="1">
219219
{{ trans_choice('general.set_to_null', count($assets), ['selection_count' => count($assets)]) }}
220220
</label>
221221
</div>

0 commit comments

Comments
 (0)