Skip to content

Commit 3bf33aa

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 24456f7 + 5084843 commit 3bf33aa

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

app/Http/Controllers/Users/UsersController.php

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,31 @@ public function update(SaveUserRequest $request, User $user)
288288
$user->password = bcrypt($request->input('password'));
289289
}
290290

291-
292291
// Update the location of any assets checked out to this user
293292
Asset::where('assigned_type', User::class)
294293
->where('assigned_to', $user->id)
295294
->update(['location_id' => $user->location_id]);
296295

297-
$permissions_array = $request->input('permission');
298-
296+
$permissions_array = $request->input('permission');
299297

300-
// Strip out the superuser permission if the user isn't a superadmin
301-
if (! auth()->user()->isSuperUser()) {
302-
unset($permissions_array['superuser']);
303-
$permissions_array['superuser'] = $orig_superuser;
304-
}
298+
// Strip out the superuser permission if the user isn't a superadmin
299+
if (! auth()->user()->isSuperUser()) {
300+
unset($permissions_array['superuser']);
301+
$permissions_array['superuser'] = $orig_superuser;
302+
}
305303

306-
$user->permissions = json_encode($permissions_array);
304+
$user->permissions = json_encode($permissions_array);
307305

308-
// Handle uploaded avatar
309-
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
310-
session()->put(['redirect_option' => $request->get('redirect_option')]);
306+
// Handle uploaded avatar
307+
app(ImageUploadRequest::class)->handleImages($user, 600, 'avatar', 'avatars', 'avatar');
308+
session()->put(['redirect_option' => $request->get('redirect_option')]);
311309

312-
if ($user->save()) {
313-
// Redirect to the user page
314-
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
315-
->with('success', trans('admin/users/message.success.update'));
316-
}
317-
return redirect()->back()->withInput()->withErrors($user->getErrors());
310+
if ($user->save()) {
311+
// Redirect to the user page
312+
return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))
313+
->with('success', trans('admin/users/message.success.update'));
314+
}
315+
return redirect()->back()->withInput()->withErrors($user->getErrors());
318316
}
319317

320318
/**

app/Listeners/CheckoutableListener.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Illuminate\Support\Facades\Notification;
3232
use Exception;
3333
use Illuminate\Support\Facades\Log;
34+
use Illuminate\Support\Str;
3435
use Osama\LaravelTeamsNotification\TeamsNotification;
3536

3637
class CheckoutableListener
@@ -94,7 +95,7 @@ public function onCheckedOut($event)
9495
// Send Webhook notification
9596
try{
9697
if ($this->shouldSendWebhookNotification()) {
97-
if (Setting::getSettings()->webhook_selected === 'microsoft') {
98+
if ($this->newMicrosoftTeamsWebhookEnabled()) {
9899
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
99100
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
100101
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
@@ -176,7 +177,7 @@ public function onCheckedIn($event)
176177
// Send Webhook notification
177178
try {
178179
if ($this->shouldSendWebhookNotification()) {
179-
if (Setting::getSettings()->webhook_selected === 'microsoft') {
180+
if ($this->newMicrosoftTeamsWebhookEnabled()) {
180181
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
181182
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
182183
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
@@ -345,4 +346,9 @@ private function checkoutableShouldSendEmail($event): bool
345346
}
346347
return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email());
347348
}
349+
350+
private function newMicrosoftTeamsWebhookEnabled(): bool
351+
{
352+
return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows');
353+
}
348354
}

app/Livewire/SlackSettingsForm.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ public function updatedWebhookSelected() {
114114
$this->webhook_channel = '#NA';
115115
}
116116
}
117-
public function updatedwebhookEndpoint() {
118-
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
119-
}
120-
public function updatedwebhookEndpoint() {
117+
118+
public function updatedwebhookEndpoint()
119+
{
121120
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
122121
}
123122

app/Notifications/CheckoutAssetNotification.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public function toSlack() :SlackMessage
111111
->content($note);
112112
});
113113
}
114-
public function toMicrosoftTeams() : array
114+
115+
public function toMicrosoftTeams()
115116
{
116117
$target = $this->target;
117118
$admin = $this->admin;

0 commit comments

Comments
 (0)