mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-23 19:50:40 -05:00
Merge branch '6.x.x' into pr/2517
This commit is contained in:
Executable → Regular
-623
@@ -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;
|
||||
@@ -284,102 +283,6 @@ class UserController extends Controller
|
||||
->withSuccess('Your Email Was Updated Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Privacy Level.
|
||||
*/
|
||||
public function makePrivate(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->private_profile = 1;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Gone Private!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Privacy Level.
|
||||
*/
|
||||
public function makePublic(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->private_profile = 0;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Gone Public!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 Hidden Value.
|
||||
*/
|
||||
public function makeHidden(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->hidden = 1;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Disappeared Like A Ninja!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User Hidden Value.
|
||||
*/
|
||||
public function makeVisible(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$user->hidden = 0;
|
||||
$user->save();
|
||||
|
||||
return \to_route('users.show', ['username' => $user->username])
|
||||
->withSuccess('You Have Given Up Your Ninja Ways And Become Visible!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User PID.
|
||||
*
|
||||
@@ -400,504 +303,6 @@ class UserController extends Controller
|
||||
->withSuccess('Your PID Was Changed Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Other Privacy Change.
|
||||
*/
|
||||
protected function changeOther(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_other_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_online = ($request->input('show_online') && $request->input('show_online') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#other'])
|
||||
->withSuccess('Your Other Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Request Privacy Change.
|
||||
*/
|
||||
protected function changeRequest(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_request_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_requested = ($request->input('show_requested') && $request->input('show_requested') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#request'])
|
||||
->withSuccess('Your Request Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Achievement Privacy Change.
|
||||
*/
|
||||
protected function changeAchievement(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_achievement_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_achievement = ($request->input('show_achievement') && $request->input('show_achievement') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#achievement'])
|
||||
->withSuccess('Your Achievement Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Forum Privacy Change.
|
||||
*/
|
||||
protected function changeForum(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_forum_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_topic = ($request->input('show_topic') && $request->input('show_topic') == 1 ? 1 : 0);
|
||||
$privacy->show_post = ($request->input('show_post') && $request->input('show_post') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#forum'])
|
||||
->withSuccess('Your Forum History Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Follower Privacy Change.
|
||||
*/
|
||||
protected function changeFollower(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_follower_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_follower = ($request->input('show_follower') && $request->input('show_follower') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#follower'])
|
||||
->withSuccess('Your Follower Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Torrent Privacy Change.
|
||||
*/
|
||||
protected function changeTorrent(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_torrent_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_upload = ($request->input('show_upload') && $request->input('show_upload') == 1 ? 1 : 0);
|
||||
$privacy->show_download = ($request->input('show_download') && $request->input('show_download') == 1 ? 1 : 0);
|
||||
$privacy->show_peer = ($request->input('show_peer') && $request->input('show_peer') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
$user->peer_hidden = 0;
|
||||
$user->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#torrent'])
|
||||
->withSuccess('Your Torrent History Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Profile Privacy Change.
|
||||
*/
|
||||
protected function changeProfile(Request $request, string $username): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$privacy = $user->privacy;
|
||||
if (! $privacy) {
|
||||
$privacy = new UserPrivacy();
|
||||
$privacy->setDefaultValues();
|
||||
$privacy->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;
|
||||
}
|
||||
|
||||
$privacy->json_profile_groups = \array_merge($privacy->expected_groups, ['default_groups' => $tomerge]);
|
||||
$privacy->show_profile_torrent_count = ($request->input('show_profile_torrent_count') && $request->input('show_profile_torrent_count') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_torrent_ratio = ($request->input('show_profile_torrent_ratio') && $request->input('show_profile_torrent_ratio') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_torrent_seed = ($request->input('show_profile_torrent_seed') && $request->input('show_profile_torrent_seed') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_torrent_extra = ($request->input('show_profile_torrent_extra') && $request->input('show_profile_torrent_extra') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_about = ($request->input('show_profile_about') && $request->input('show_profile_about') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_achievement = ($request->input('show_profile_achievement') && $request->input('show_profile_achievement') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_badge = ($request->input('show_profile_badge') && $request->input('show_profile_badge') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_follower = ($request->input('show_profile_follower') && $request->input('show_profile_follower') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_title = ($request->input('show_profile_title') && $request->input('show_profile_title') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_bon_extra = ($request->input('show_profile_bon_extra') && $request->input('show_profile_bon_extra') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_comment_extra = ($request->input('show_profile_comment_extra') && $request->input('show_profile_comment_extra') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_forum_extra = ($request->input('show_profile_forum_extra') && $request->input('show_profile_forum_extra') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_request_extra = ($request->input('show_profile_request_extra') && $request->input('show_profile_request_extra') == 1 ? 1 : 0);
|
||||
$privacy->show_profile_warning = ($request->input('show_profile_warning') && $request->input('show_profile_warning') == 1 ? 1 : 0);
|
||||
$privacy->save();
|
||||
|
||||
return \to_route('user_privacy', ['username' => $user->username, 'hash' => '#profile'])
|
||||
->withSuccess('Your Profile Privacy Settings Have Been Saved!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change User RID.
|
||||
*/
|
||||
@@ -930,34 +335,6 @@ class UserController extends Controller
|
||||
->withSuccess('Your API Token Was Changed Successfully!');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Privacy Settings.
|
||||
*/
|
||||
public function privacy(Request $request, string $username): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$groups = Group::where('level', '>', 0)->latest('level')->get();
|
||||
|
||||
return \view('user.settings.privacy.index', ['user' => $user, 'groups'=> $groups]);
|
||||
}
|
||||
|
||||
/**
|
||||
* User Notification Settings.
|
||||
*/
|
||||
public function notification(Request $request, string $username): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$user = User::where('username', '=', $username)->firstOrFail();
|
||||
|
||||
\abort_unless($request->user()->id == $user->id, 403);
|
||||
|
||||
$groups = Group::where('level', '>', 0)->latest('level')->get();
|
||||
|
||||
return \view('user.settings.notification.index', ['user' => $user, 'groups'=> $groups]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept Site Rules.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user