mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-02 00:10:02 -05:00
Allow internal options for internals in non-internal group
Internals that are not member of the internal group (e.g. Editor) but not Moderator+ should still be able to set the internal options on their uploads. Also, replace all group->is_internal with internals->exists in app & views.
This commit is contained in:
@@ -105,7 +105,7 @@ class TorrentController extends BaseController
|
||||
*/
|
||||
public function store(Request $request): \Illuminate\Http\JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
$user = $request->user()->loadExists('internals');
|
||||
abort_unless($user->can_upload ?? $user->group->can_upload, 403, __('torrent.cant-upload').' '.__('torrent.cant-upload-desc'));
|
||||
|
||||
$requestFile = $request->file('torrent');
|
||||
@@ -169,21 +169,29 @@ class TorrentController extends BaseController
|
||||
$torrent->stream = $request->input('stream');
|
||||
$torrent->sd = $request->input('sd');
|
||||
$torrent->personal_release = $request->input('personal_release') ?? false;
|
||||
$torrent->internal = $user->group->is_modo || $user->group->is_internal ? ($request->input('internal') ?? 0) : 0;
|
||||
$torrent->doubleup = $user->group->is_modo || $user->group->is_internal ? ($request->input('doubleup') ?? 0) : 0;
|
||||
$torrent->refundable = $user->group->is_modo || $user->group->is_internal ? ($request->input('refundable') ?? false) : false;
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
$torrent->internal = $user->group->is_modo || $user->internals_exists ? ($request->input('internal') ?? 0) : 0;
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
$torrent->doubleup = $user->group->is_modo || $user->internals_exists ? ($request->input('doubleup') ?? 0) : 0;
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
$torrent->refundable = $user->group->is_modo || $user->internals_exists ? ($request->input('refundable') ?? false) : false;
|
||||
$du_until = $request->input('du_until');
|
||||
|
||||
if (($user->group->is_modo || $user->group->is_internal) && isset($du_until)) {
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
if (($user->group->is_modo || $user->internals_exists) && isset($du_until)) {
|
||||
$torrent->du_until = Carbon::now()->addDays($request->integer('du_until'));
|
||||
}
|
||||
$torrent->free = $user->group->is_modo || $user->group->is_internal ? ($request->input('free') ?? 0) : 0;
|
||||
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
$torrent->free = $user->group->is_modo || $user->internals_exists ? ($request->input('free') ?? 0) : 0;
|
||||
$fl_until = $request->input('fl_until');
|
||||
|
||||
if (($user->group->is_modo || $user->group->is_internal) && isset($fl_until)) {
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
if (($user->group->is_modo || $user->internals_exists) && isset($fl_until)) {
|
||||
$torrent->fl_until = Carbon::now()->addDays($request->integer('fl_until'));
|
||||
}
|
||||
$torrent->sticky = $user->group->is_modo || $user->group->is_internal ? ($request->input('sticky') ?? false) : false;
|
||||
/** @phpstan-ignore property.notFound (Larastan doesn't yet support loadExists()) */
|
||||
$torrent->sticky = $user->group->is_modo || $user->internals_exists ? ($request->input('sticky') ?? false) : false;
|
||||
$torrent->moderated_at = Carbon::now();
|
||||
$torrent->moderated_by = User::SYSTEM_USER_ID;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class TorrentBuffController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrent->bumped_at = Carbon::now();
|
||||
$torrent->save();
|
||||
@@ -78,7 +78,7 @@ class TorrentBuffController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrent->sticky = !$torrent->sticky;
|
||||
$torrent->save();
|
||||
@@ -94,7 +94,7 @@ class TorrentBuffController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrentUrl = href_torrent($torrent);
|
||||
|
||||
@@ -138,7 +138,7 @@ class TorrentBuffController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
|
||||
if ($torrent->featured()->doesntExist()) {
|
||||
@@ -201,7 +201,7 @@ class TorrentBuffController extends Controller
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrentUrl = href_torrent($torrent);
|
||||
|
||||
@@ -275,7 +275,7 @@ class TorrentBuffController extends Controller
|
||||
public function setRefundable(Request $request, int $id): \Illuminate\Http\RedirectResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless($user->group->is_modo || $user->group->is_internal, 403);
|
||||
abort_unless($user->group->is_modo || $user->internals()->exists(), 403);
|
||||
|
||||
$torrent = Torrent::withoutGlobalScope(ApprovedScope::class)->findOrFail($id);
|
||||
$torrent_url = href_torrent($torrent);
|
||||
|
||||
Reference in New Issue
Block a user