mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-05 10:11:25 -05:00
Merge branch '6.x.x' into update-user-privacy
This commit is contained in:
Executable → Regular
-295
@@ -21,7 +21,6 @@ use App\Models\Invite;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\TorrentRequest;
|
||||
use App\Models\User;
|
||||
use App\Models\UserNotification;
|
||||
use App\Models\UserPrivacy;
|
||||
use App\Models\Warning;
|
||||
use App\Rules\EmailBlacklist;
|
||||
@@ -341,38 +340,6 @@ class UserController extends Controller
|
||||
->withSuccess('Your Email Was Updated Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Notification Setting.
|
||||
*/
|
||||
public function disableNotifications(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->block_notifications = 1;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Disabled Notifications!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Notification Setting.
|
||||
*/
|
||||
public function enableNotifications(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->block_notifications = 0;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Enabled Notifications!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User PID.
|
||||
*
|
||||
@@ -393,268 +360,6 @@ class UserController extends Controller
|
||||
->withSuccess('Your PID Was Changed Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Account Notification Change.
|
||||
*/
|
||||
protected function changeAccountNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_account_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_account_follow = ($request->input('show_account_follow') && $request->input('show_account_follow') == 1 ? 1 : 0);
|
||||
$notification->show_account_unfollow = ($request->input('show_account_unfollow') && $request->input('show_account_unfollow') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#account'])
|
||||
->withSuccess('Your Account Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Following Notification Change.
|
||||
*/
|
||||
protected function changeFollowingNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_following_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_following_upload = ($request->input('show_following_upload') && $request->input('show_following_upload') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#following'])
|
||||
->withSuccess('Your Followed User Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User BON Notification Change.
|
||||
*/
|
||||
protected function changeBonNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_bon_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_bon_gift = ($request->input('show_bon_gift') && $request->input('show_bon_gift') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#bon'])
|
||||
->withSuccess('Your BON Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Subscription Notification Change.
|
||||
*/
|
||||
protected function changeSubscriptionNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_subscription_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_subscription_forum = ($request->input('show_subscription_forum') && $request->input('show_subscription_forum') == 1 ? 1 : 0);
|
||||
$notification->show_subscription_topic = ($request->input('show_subscription_topic') && $request->input('show_subscription_topic') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#subscription'])
|
||||
->withSuccess('Your Subscription Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Request Notification Change.
|
||||
*/
|
||||
protected function changeRequestNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_request_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_request_comment = ($request->input('show_request_comment') && $request->input('show_request_comment') == 1 ? 1 : 0);
|
||||
$notification->show_request_bounty = ($request->input('show_request_bounty') && $request->input('show_request_bounty') == 1 ? 1 : 0);
|
||||
$notification->show_request_fill = ($request->input('show_request_fill') && $request->input('show_request_fill') == 1 ? 1 : 0);
|
||||
$notification->show_request_fill_approve = ($request->input('show_request_fill_approve') && $request->input('show_request_fill_approve') == 1 ? 1 : 0);
|
||||
$notification->show_request_fill_reject = ($request->input('show_request_fill_reject') && $request->input('show_request_fill_reject') == 1 ? 1 : 0);
|
||||
$notification->show_request_claim = ($request->input('show_request_claim') && $request->input('show_request_claim') == 1 ? 1 : 0);
|
||||
$notification->show_request_unclaim = ($request->input('show_request_unclaim') && $request->input('show_request_unclaim') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#request'])
|
||||
->withSuccess('Your Request Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Torrent Notification Change.
|
||||
*/
|
||||
protected function changeTorrentNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_torrent_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_torrent_comment = ($request->input('show_torrent_comment') && $request->input('show_torrent_comment') == 1 ? 1 : 0);
|
||||
$notification->show_torrent_thank = ($request->input('show_torrent_thank') && $request->input('show_torrent_thank') == 1 ? 1 : 0);
|
||||
$notification->show_torrent_tip = ($request->input('show_torrent_tip') && $request->input('show_torrent_tip') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#torrent'])
|
||||
->withSuccess('Your Torrent Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Mention Notification Change.
|
||||
*/
|
||||
protected function changeMentionNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_mention_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_mention_torrent_comment = ($request->input('show_mention_torrent_comment') && $request->input('show_mention_torrent_comment') == 1 ? 1 : 0);
|
||||
$notification->show_mention_request_comment = ($request->input('show_mention_request_comment') && $request->input('show_mention_request_comment') == 1 ? 1 : 0);
|
||||
$notification->show_mention_article_comment = ($request->input('show_mention_article_comment') && $request->input('show_mention_article_comment') == 1 ? 1 : 0);
|
||||
$notification->show_mention_forum_post = ($request->input('show_mention_forum_post') && $request->input('show_mention_forum_post') == 1 ? 1 : 0);
|
||||
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#mention'])
|
||||
->withSuccess('Your @Mention Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Forum Notification Change.
|
||||
*/
|
||||
protected function changeForumNotification(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$notification = $user->notification;
|
||||
if (! $notification) {
|
||||
$notification = new UserNotification();
|
||||
$notification->setDefaultValues();
|
||||
$notification->user_id = $user->id;
|
||||
}
|
||||
|
||||
$approved = $request->input('approved');
|
||||
$groups = Group::all();
|
||||
$tomerge = [];
|
||||
foreach ($groups as $group) {
|
||||
$tomerge[$group->id] = \is_array($approved) && \in_array($group->id, $approved) ? 1 : 0;
|
||||
}
|
||||
|
||||
$notification->json_forum_groups = \array_merge($notification->expected_groups, ['default_groups' => $tomerge]);
|
||||
$notification->show_forum_topic = ($request->input('show_forum_topic') && $request->input('show_forum_topic') == 1 ? 1 : 0);
|
||||
$notification->save();
|
||||
|
||||
return \to_route('user_notification', ['username' => $user->username, 'hash' => '#forum'])
|
||||
->withSuccess('Your Forum Notification Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User RID.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user