Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Nov 13, 2024
2 parents 24456f7 + 5084843 commit 3bf33aa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
34 changes: 16 additions & 18 deletions app/Http/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,33 +288,31 @@ public function update(SaveUserRequest $request, User $user)
$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());
}

/**
Expand Down
10 changes: 8 additions & 2 deletions app/Listeners/CheckoutableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use Illuminate\Support\Facades\Notification;
use Exception;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Osama\LaravelTeamsNotification\TeamsNotification;

class CheckoutableListener
Expand Down Expand Up @@ -94,7 +95,7 @@ public function onCheckedOut($event)
// 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
Expand Down Expand Up @@ -176,7 +177,7 @@ public function onCheckedIn($event)
// 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
Expand Down Expand Up @@ -345,4 +346,9 @@ private function checkoutableShouldSendEmail($event): bool
}
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');
}
}
7 changes: 3 additions & 4 deletions app/Livewire/SlackSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ public function updatedWebhookSelected() {
$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');
}

Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/CheckoutAssetNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function toSlack() :SlackMessage
->content($note);
});
}
public function toMicrosoftTeams() : array

public function toMicrosoftTeams()
{
$target = $this->target;
$admin = $this->admin;
Expand Down

0 comments on commit 3bf33aa

Please sign in to comment.