From 2db70379a663c6f752f7c79e6d2f0ef8306f62b0 Mon Sep 17 00:00:00 2001 From: Tobias Regnery Date: Thu, 7 Nov 2024 09:18:27 +0100 Subject: [PATCH 1/4] Fix Indentation in UsersController The indentation in the update-function of the UsersController is partially wrong. Fix this to avoid confusion. --- .../Controllers/Users/UsersController.php | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.php index 051db1f4ef..397bfd16d8 100755 --- a/app/Http/Controllers/Users/UsersController.php +++ b/app/Http/Controllers/Users/UsersController.php @@ -288,33 +288,31 @@ class UsersController extends Controller $user->password = bcrypt($request->input('password')); } - // Update the location of any assets checked out to this user Asset::where('assigned_type', User::class) ->where('assigned_to', $user->id) ->update(['location_id' => $user->location_id]); - $permissions_array = $request->input('permission'); + $permissions_array = $request->input('permission'); + // Strip out the superuser permission if the user isn't a superadmin + if (! auth()->user()->isSuperUser()) { + unset($permissions_array['superuser']); + $permissions_array['superuser'] = $orig_superuser; + } - // Strip out the superuser permission if the user isn't a superadmin - if (! auth()->user()->isSuperUser()) { - unset($permissions_array['superuser']); - $permissions_array['superuser'] = $orig_superuser; - } + $user->permissions = json_encode($permissions_array); - $user->permissions = json_encode($permissions_array); + // Handle uploaded avatar + app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar'); + session()->put(['redirect_option' => $request->get('redirect_option')]); - // Handle uploaded avatar - app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar'); - session()->put(['redirect_option' => $request->get('redirect_option')]); - - if ($user->save()) { - // Redirect to the user page - return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users')) - ->with('success', trans('admin/users/message.success.update')); - } - return redirect()->back()->withInput()->withErrors($user->getErrors()); + if ($user->save()) { + // Redirect to the user page + return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users')) + ->with('success', trans('admin/users/message.success.update')); + } + return redirect()->back()->withInput()->withErrors($user->getErrors()); } /** From ac3ae651b1e84d375597e3fca9e4b72cf2de52d8 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 13 Nov 2024 14:15:43 -0800 Subject: [PATCH 2/4] Remove incorrect typehint --- app/Notifications/CheckoutAssetNotification.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Notifications/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.php index 83011e5c8e..f55d3dc1e0 100644 --- a/app/Notifications/CheckoutAssetNotification.php +++ b/app/Notifications/CheckoutAssetNotification.php @@ -111,7 +111,8 @@ class CheckoutAssetNotification extends Notification ->content($note); }); } - public function toMicrosoftTeams() : array + + public function toMicrosoftTeams() { $target = $this->target; $admin = $this->admin; From c399d797b4c7de9d627f4c8fd31384641cfdddb4 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 13 Nov 2024 14:29:01 -0800 Subject: [PATCH 3/4] Add conditional for microsoft team integration version --- app/Listeners/CheckoutableListener.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index c5499784b7..6037ee1ec4 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Exception; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Str; use Osama\LaravelTeamsNotification\TeamsNotification; class CheckoutableListener @@ -94,7 +95,7 @@ class CheckoutableListener // Send Webhook notification try{ if ($this->shouldSendWebhookNotification()) { - if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->newMicrosoftTeamsWebhookEnabled()) { $message = $this->getCheckoutNotification($event)->toMicrosoftTeams(); $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams @@ -176,7 +177,7 @@ class CheckoutableListener // Send Webhook notification try { if ($this->shouldSendWebhookNotification()) { - if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->newMicrosoftTeamsWebhookEnabled()) { $message = $this->getCheckinNotification($event)->toMicrosoftTeams(); $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams @@ -345,4 +346,9 @@ class CheckoutableListener } return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email()); } + + private function newMicrosoftTeamsWebhookEnabled(): bool + { + return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'); + } } From e80a456e04c6c69086b7134923f31e3b747f1a86 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 13 Nov 2024 14:35:20 -0800 Subject: [PATCH 4/4] Remove duplicate method --- app/Livewire/SlackSettingsForm.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Livewire/SlackSettingsForm.php b/app/Livewire/SlackSettingsForm.php index 8d330bafbe..909b2223ad 100644 --- a/app/Livewire/SlackSettingsForm.php +++ b/app/Livewire/SlackSettingsForm.php @@ -114,10 +114,9 @@ class SlackSettingsForm extends Component $this->webhook_channel = '#NA'; } } - public function updatedwebhookEndpoint() { - $this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows'); - } - public function updatedwebhookEndpoint() { + + public function updatedwebhookEndpoint() + { $this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows'); }