You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -28,7 +28,16 @@ class GuestbookController extends Controller
|
||||
|
||||
public function destroy(User $user, WebsiteUserGuestbook $guestbook): RedirectResponse
|
||||
{
|
||||
if ($guestbook->user_id !== Auth::id() && $guestbook->profile_id !== $user->id && Auth::user()->rank < (int) setting('min_staff_rank')) {
|
||||
/** @var \App\Models\User|null $currentUser */
|
||||
$currentUser = Auth::user();
|
||||
|
||||
if ($currentUser === null) {
|
||||
return back()->withErrors([
|
||||
'message' => __('You must be logged in.'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($guestbook->user_id !== $currentUser->id && $guestbook->profile_id !== $user->id && $currentUser->rank < (int) setting('min_staff_rank')) {
|
||||
return back()->withErrors([
|
||||
'message' => __('Do do not have permission to delete this message'),
|
||||
]);
|
||||
@@ -41,12 +50,19 @@ class GuestbookController extends Controller
|
||||
|
||||
private function validateGuestbookPost(User $user, GuestbookFormRequest $request): ?RedirectResponse
|
||||
{
|
||||
if ($user->id === $request->user()->id) {
|
||||
/** @var \App\Models\User|null $currentUser */
|
||||
$currentUser = $request->user();
|
||||
|
||||
if ($currentUser === null) {
|
||||
return $this->redirectWithError(__('You must be logged in.'));
|
||||
}
|
||||
|
||||
if ($user->id === $currentUser->id) {
|
||||
return $this->redirectWithError(__('You cannot post a message on your own profile.'));
|
||||
}
|
||||
|
||||
$maxAllowedPostCount = in_array(setting('max_guestbook_posts_per_profile'), ['', '0'], true) ? 3 : (int) setting('max_guestbook_posts_per_profile');
|
||||
if ($user->profileGuestbook()->where('user_id', $request->user()->id)->count() >= $maxAllowedPostCount) {
|
||||
$maxAllowedPostCount = in_array((string) setting('max_guestbook_posts_per_profile'), ['', '0'], true) ? 3 : (int) setting('max_guestbook_posts_per_profile');
|
||||
if ($user->profileGuestbook()->where('user_id', $currentUser->id)->count() >= $maxAllowedPostCount) {
|
||||
return $this->redirectWithError(__('You have already posted :count messages on this profile.', ['count' => $maxAllowedPostCount]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user