Skip to content

Commit 1d2b7ad

Browse files
authored
Merge branch 'snipe:master' into feature/labels_Avery_5520_1DBarcode
2 parents 4a97a77 + ef8d5ff commit 1d2b7ad

File tree

89 files changed

+638
-275420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+638
-275420
lines changed

.all-contributorsrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,24 @@
32893289
"contributions": [
32903290
"code"
32913291
]
3292+
},
3293+
{
3294+
"login": "azmcnutt",
3295+
"name": "James M",
3296+
"avatar_url": "https://avatars.githubusercontent.com/u/31522486?v=4",
3297+
"profile": "https://github.com/azmcnutt",
3298+
"contributions": [
3299+
"code"
3300+
]
3301+
},
3302+
{
3303+
"login": "Fiala06",
3304+
"name": "Fiala06",
3305+
"avatar_url": "https://avatars.githubusercontent.com/u/5183146?v=4",
3306+
"profile": "https://github.com/Fiala06",
3307+
"contributions": [
3308+
"code"
3309+
]
32923310
}
32933311
]
32943312
}

CONTRIBUTORS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Thanks goes to all of these wonderful people ([emoji key](https://github.com/ken
5353
| [<img src="https://avatars.githubusercontent.com/u/55590532?v=4" width="110px;"/><br /><sub>squintfox</sub>](https://github.com/squintfox)<br />[💻](https://github.com/snipe/snipe-it/commits?author=squintfox "Code") | [<img src="https://avatars.githubusercontent.com/u/1380084?v=4" width="110px;"/><br /><sub>Jeff Clay</sub>](https://github.com/jeffclay)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jeffclay "Code") | [<img src="https://avatars.githubusercontent.com/u/52716446?v=4" width="110px;"/><br /><sub>Phil J R</sub>](https://github.com/PP-JN-RL)<br />[💻](https://github.com/snipe/snipe-it/commits?author=PP-JN-RL "Code") | [<img src="https://avatars.githubusercontent.com/u/1496725?v=4" width="110px;"/><br /><sub>i_virus</sub>](https://www.corelight.com/)<br />[💻](https://github.com/snipe/snipe-it/commits?author=chandanchowdhury "Code") | [<img src="https://avatars.githubusercontent.com/u/1020541?v=4" width="110px;"/><br /><sub>Paul Grime</sub>](https://github.com/gitgrimbo)<br />[💻](https://github.com/snipe/snipe-it/commits?author=gitgrimbo "Code") | [<img src="https://avatars.githubusercontent.com/u/922815?v=4" width="110px;"/><br /><sub>Lee Porte</sub>](https://leeporte.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=LeePorte "Code") | [<img src="https://avatars.githubusercontent.com/u/23613427?v=4" width="110px;"/><br /><sub>BRYAN </sub>](https://github.com/bryanlopezinc)<br />[💻](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Code") [⚠️](https://github.com/snipe/snipe-it/commits?author=bryanlopezinc "Tests") |
5454
| [<img src="https://avatars.githubusercontent.com/u/64061710?v=4" width="110px;"/><br /><sub>U-H-T</sub>](https://github.com/U-H-T)<br />[💻](https://github.com/snipe/snipe-it/commits?author=U-H-T "Code") | [<img src="https://avatars.githubusercontent.com/u/5395363?v=4" width="110px;"/><br /><sub>Matt Tyree</sub>](https://github.com/Tyree)<br />[📖](https://github.com/snipe/snipe-it/commits?author=Tyree "Documentation") | [<img src="https://avatars.githubusercontent.com/u/292081?v=4" width="110px;"/><br /><sub>Florent Bervas</sub>](http://spoontux.net)<br />[💻](https://github.com/snipe/snipe-it/commits?author=FlorentDotMe "Code") | [<img src="https://avatars.githubusercontent.com/u/4498077?v=4" width="110px;"/><br /><sub>Daniel Albertsen</sub>](https://ditscheri.com)<br />[💻](https://github.com/snipe/snipe-it/commits?author=dbakan "Code") | [<img src="https://avatars.githubusercontent.com/u/100710244?v=4" width="110px;"/><br /><sub>r-xyz</sub>](https://github.com/r-xyz)<br />[💻](https://github.com/snipe/snipe-it/commits?author=r-xyz "Code") | [<img src="https://avatars.githubusercontent.com/u/47491036?v=4" width="110px;"/><br /><sub>Steven Mainor</sub>](https://github.com/DrekiDegga)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DrekiDegga "Code") | [<img src="https://avatars.githubusercontent.com/u/65785975?v=4" width="110px;"/><br /><sub>arne-kroeger</sub>](https://github.com/arne-kroeger)<br />[💻](https://github.com/snipe/snipe-it/commits?author=arne-kroeger "Code") |
5555
| [<img src="https://avatars.githubusercontent.com/u/167117705?v=4" width="110px;"/><br /><sub>Glukose1</sub>](https://github.com/Glukose1)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Glukose1 "Code") | [<img src="https://avatars.githubusercontent.com/u/1197791?v=4" width="110px;"/><br /><sub>Scarzy</sub>](https://github.com/Scarzy)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Scarzy "Code") | [<img src="https://avatars.githubusercontent.com/u/37372069?v=4" width="110px;"/><br /><sub>setpill</sub>](https://github.com/setpill)<br />[💻](https://github.com/snipe/snipe-it/commits?author=setpill "Code") | [<img src="https://avatars.githubusercontent.com/u/3755203?v=4" width="110px;"/><br /><sub>swift2512</sub>](https://github.com/swift2512)<br />[🐛](https://github.com/snipe/snipe-it/issues?q=author%3Aswift2512 "Bug reports") | [<img src="https://avatars.githubusercontent.com/u/6136439?v=4" width="110px;"/><br /><sub>Darren Rainey</sub>](https://darrenraineys.co.uk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=DarrenRainey "Code") | [<img src="https://avatars.githubusercontent.com/u/133033121?v=4" width="110px;"/><br /><sub>maciej-poleszczyk</sub>](https://github.com/maciej-poleszczyk)<br />[💻](https://github.com/snipe/snipe-it/commits?author=maciej-poleszczyk "Code") | [<img src="https://avatars.githubusercontent.com/u/143394709?v=4" width="110px;"/><br /><sub>Sebastian Groß</sub>](https://github.com/sgross-emlix)<br />[💻](https://github.com/snipe/snipe-it/commits?author=sgross-emlix "Code") |
56-
| [<img src="https://avatars.githubusercontent.com/u/41107778?v=4" width="110px;"/><br /><sub>Anouar Touati</sub>](https://github.com/AnouarTouati)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") | [<img src="https://avatars.githubusercontent.com/u/25596663?v=4" width="110px;"/><br /><sub>aHVzY2g</sub>](https://github.com/aHVzY2g)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aHVzY2g "Code") | [<img src="https://avatars.githubusercontent.com/u/13408130?v=4" width="110px;"/><br /><sub>林博仁 Buo-ren Lin</sub>](https://brlin.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=brlin-tw "Code") | [<img src="https://avatars.githubusercontent.com/u/18550946?v=4" width="110px;"/><br /><sub>Adugna Gizaw</sub>](https://orbalia.pythonanywhere.com/)<br />[🌍](#translation-addex12 "Translation") | [<img src="https://avatars.githubusercontent.com/u/760989?v=4" width="110px;"/><br /><sub>Jesse Ostrander</sub>](https://github.com/jostrander)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jostrander "Code") |
56+
| [<img src="https://avatars.githubusercontent.com/u/41107778?v=4" width="110px;"/><br /><sub>Anouar Touati</sub>](https://github.com/AnouarTouati)<br />[💻](https://github.com/snipe/snipe-it/commits?author=AnouarTouati "Code") | [<img src="https://avatars.githubusercontent.com/u/25596663?v=4" width="110px;"/><br /><sub>aHVzY2g</sub>](https://github.com/aHVzY2g)<br />[💻](https://github.com/snipe/snipe-it/commits?author=aHVzY2g "Code") | [<img src="https://avatars.githubusercontent.com/u/13408130?v=4" width="110px;"/><br /><sub>林博仁 Buo-ren Lin</sub>](https://brlin.me)<br />[💻](https://github.com/snipe/snipe-it/commits?author=brlin-tw "Code") | [<img src="https://avatars.githubusercontent.com/u/18550946?v=4" width="110px;"/><br /><sub>Adugna Gizaw</sub>](https://orbalia.pythonanywhere.com/)<br />[🌍](#translation-addex12 "Translation") | [<img src="https://avatars.githubusercontent.com/u/760989?v=4" width="110px;"/><br /><sub>Jesse Ostrander</sub>](https://github.com/jostrander)<br />[💻](https://github.com/snipe/snipe-it/commits?author=jostrander "Code") | [<img src="https://avatars.githubusercontent.com/u/31522486?v=4" width="110px;"/><br /><sub>James M</sub>](https://github.com/azmcnutt)<br />[💻](https://github.com/snipe/snipe-it/commits?author=azmcnutt "Code") | [<img src="https://avatars.githubusercontent.com/u/5183146?v=4" width="110px;"/><br /><sub>Fiala06</sub>](https://github.com/Fiala06)<br />[💻](https://github.com/snipe/snipe-it/commits?author=Fiala06 "Code") |
5757
<!-- ALL-CONTRIBUTORS-LIST:END -->
5858

5959
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!

app/Console/Commands/LdapSync.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ public function handle()
434434
$item['note'] = $item['createorupdate'];
435435
$item['status'] = 'success';
436436
if ($item['createorupdate'] === 'created' && $ldap_default_group) {
437-
$user->groups()->attach($ldap_default_group);
437+
// Check if the relationship already exists
438+
if (!$user->groups()->where('group_id', $ldap_default_group)->exists()) {
439+
$user->groups()->attach($ldap_default_group);
440+
}
438441
}
442+
439443
//updates assets location based on user's location
440444
if ($user->wasChanged('location_id')) {
441445
foreach ($user->assets as $asset) {

app/Console/Commands/SendExpirationAlerts.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct()
4242
public function handle()
4343
{
4444
$settings = Setting::getSettings();
45-
$threshold = $settings->alert_interval;
45+
$alert_interval = $settings->alert_interval;
4646

4747
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
4848

@@ -51,18 +51,18 @@ public function handle()
5151
->map(fn($item) => trim($item)) // Trim each email
5252
->all();
5353
// Expiring Assets
54-
$assets = Asset::getExpiringWarrantee($threshold);
54+
$assets = Asset::getExpiringWarrantee($alert_interval);
5555

5656
if ($assets->count() > 0) {
57-
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $threshold]));
58-
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $threshold));
57+
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count' => $assets->count(), 'threshold' => $alert_interval]));
58+
Mail::to($recipients)->send(new ExpiringAssetsMail($assets, $alert_interval));
5959
}
6060

6161
// Expiring licenses
62-
$licenses = License::getExpiringLicenses($threshold);
62+
$licenses = License::getExpiringLicenses($alert_interval);
6363
if ($licenses->count() > 0) {
64-
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold]));
65-
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $threshold));
64+
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $alert_interval]));
65+
Mail::to($recipients)->send(new ExpiringLicenseMail($licenses, $alert_interval));
6666
}
6767
} else {
6868
if ($settings->alert_email == '') {

app/Console/Commands/SendUpcomingAuditReport.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
namespace App\Console\Commands;
44

5+
use App\Mail\SendUpcomingAuditMail;
56
use App\Models\Asset;
6-
use App\Models\Recipients\AlertRecipient;
77
use App\Models\Setting;
8-
use App\Notifications\SendUpcomingAuditNotification;
98
use Carbon\Carbon;
10-
use Illuminate\Support\Facades\DB;
119
use Illuminate\Console\Command;
10+
use Illuminate\Support\Facades\Mail;
1211

1312
class SendUpcomingAuditReport extends Command
1413
{
@@ -48,19 +47,19 @@ public function handle()
4847
$today = Carbon::now();
4948
$interval_date = $today->copy()->addDays($interval);
5049

51-
$assets = Asset::whereNull('deleted_at')->DueOrOverdueForAudit($settings)->orderBy('assets.next_audit_date', 'desc')->get();
52-
$this->info($assets->count().' assets must be audited in on or before '.$interval_date.' is deadline');
50+
$assets = Asset::whereNull('deleted_at')->dueOrOverdueForAudit($settings)->orderBy('assets.next_audit_date', 'desc')->get();
51+
$this->info($assets->count() . ' assets must be audited in on or before ' . $interval_date . ' is deadline');
5352

5453

55-
if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) {
54+
if ((count($assets) !== 0) && ($assets->count() > 0) && ($settings->alert_email != '')) {
5655
// Send a rollup to the admin, if settings dictate
57-
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item) {
58-
return new AlertRecipient($item);
59-
});
56+
$recipients = collect(explode(',', $settings->alert_email))
57+
->map(fn($item) => trim($item))
58+
->all();
6059

61-
$this->info('Sending Admin SendUpcomingAuditNotification to: '.$settings->alert_email);
62-
\Notification::send($recipients, new SendUpcomingAuditNotification($assets, $settings->audit_warning_days));
6360

61+
$this->info('Sending Admin SendUpcomingAuditNotification to: ' . $settings->alert_email);
62+
Mail::to($recipients)->send(new SendUpcomingAuditMail($assets, $settings->audit_warning_days));
6463
}
6564

6665
}

app/Console/Kernel.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use App\Console\Commands\ImportLocations;
66
use App\Console\Commands\ReEncodeCustomFieldNames;
77
use App\Console\Commands\RestoreDeletedUsers;
8+
use App\Models\Setting;
89
use Illuminate\Console\Scheduling\Schedule;
910
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
1011

@@ -18,12 +19,14 @@ class Kernel extends ConsoleKernel
1819
*/
1920
protected function schedule(Schedule $schedule)
2021
{
21-
$schedule->command('snipeit:inventory-alerts')->daily();
22-
$schedule->command('snipeit:expiring-alerts')->daily();
23-
$schedule->command('snipeit:expected-checkin')->daily();
22+
if(Setting::getSettings()->alerts_enabled === 1) {
23+
$schedule->command('snipeit:inventory-alerts')->daily();
24+
$schedule->command('snipeit:expiring-alerts')->daily();
25+
$schedule->command('snipeit:expected-checkin')->daily();
26+
$schedule->command('snipeit:upcoming-audits')->daily();
27+
}
2428
$schedule->command('snipeit:backup')->weekly();
2529
$schedule->command('backup:clean')->daily();
26-
$schedule->command('snipeit:upcoming-audits')->daily();
2730
$schedule->command('auth:clear-resets')->everyFifteenMinutes();
2831
$schedule->command('saml:clear_expired_nonces')->weekly();
2932
}

app/Exceptions/Handler.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public function render($request, Throwable $e)
125125
// This is traaaaash but it handles models that are not found while using route model binding :(
126126
// The only alternative is to set that at *each* route, which is crazypants
127127
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
128-
$model_name = last(explode('\\', $e->getModel()));
128+
129+
// This gets the MVC model name from the exception and formats in a way that's less fugly
130+
$model_name = strtolower(implode(" ", preg_split('/(?=[A-Z])/', last(explode('\\', $e->getModel())))));
129131
$route = str_plural(strtolower(last(explode('\\', $e->getModel())))).'.index';
130132

131133
// Sigh.
@@ -137,6 +139,8 @@ public function render($request, Throwable $e)
137139
$route = 'models.index';
138140
} elseif ($route == 'predefinedkits.index') {
139141
$route = 'kits.index';
142+
} elseif ($route == 'assetmaintenances.index') {
143+
$route = 'maintenances.index';
140144
}
141145

142146
return redirect()

app/Http/Controllers/SettingsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,8 +850,8 @@ public function postLdapSettings(StoreLdapSettings $request) : RedirectResponse
850850
$setting->ldap_fname_field = $request->input('ldap_fname_field');
851851
$setting->ldap_auth_filter_query = $request->input('ldap_auth_filter_query');
852852
$setting->ldap_version = $request->input('ldap_version', 3);
853-
$setting->ldap_active_flag = $request->input('ldap_active_flag');
854-
$setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag');
853+
$setting->ldap_active_flag = $request->input('ldap_active_flag', 0);
854+
$setting->ldap_invert_active_flag = $request->input('ldap_invert_active_flag', 0);
855855
$setting->ldap_emp_num = $request->input('ldap_emp_num');
856856
$setting->ldap_email = $request->input('ldap_email');
857857
$setting->ldap_manager = $request->input('ldap_manager');

app/Http/Controllers/Users/UsersController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,9 @@ public function edit(User $user)
198198
$userPermissions = Helper::selectedPermissionsArray($permissions, $user->permissions);
199199
$permissions = $this->filterDisplayable($permissions);
200200

201-
return view('users/edit', compact('user', 'groups', 'userGroups', 'permissions', 'userPermissions'));
201+
return view('users/edit', compact('user', 'groups', 'userGroups', 'permissions', 'userPermissions'))->with('item', $user);
202202
}
203203

204-
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
205204
}
206205

207206
/**
@@ -456,10 +455,10 @@ public function getClone(Request $request, User $user)
456455
->with('user', $user)
457456
->with('groups', Group::pluck('name', 'id'))
458457
->with('userGroups', $userGroups)
459-
->with('clone_user', $user_to_clone);
458+
->with('clone_user', $user_to_clone)
459+
->with('item', $user);
460460
}
461461

462-
return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', compact('id')));
463462

464463
}
465464

app/Http/Requests/SaveUserRequest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public function response(array $errors)
3333
public function rules()
3434
{
3535
$rules = [
36-
'department_id' => 'nullable|exists:departments,id',
36+
'department_id' => 'nullable|integer|exists:departments,id',
3737
'manager_id' => 'nullable|exists:users,id',
38-
'company_id' => ['nullable','exists:companies,id']
38+
'company_id' => ['nullable', 'integer', 'exists:companies,id']
3939
];
4040

4141
switch ($this->method()) {

0 commit comments

Comments
 (0)