fix pos_state no until

This commit is contained in:
xiaomlove
2022-09-19 21:00:47 +08:00
parent 30a8fb131b
commit 1aad5314ba
2 changed files with 16 additions and 14 deletions

View File

@@ -146,13 +146,14 @@ if(user_can('torrentonpromotion'))
if(user_can('torrentsticky'))
{
if (isset($_POST['pos_state']) && isset(\App\Models\Torrent::$posStates[$_POST['pos_state']])) {
$posStateUntil = null;
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
if (!empty($_POST['pos_state_until']) && $_POST['pos_state'] != \App\Models\Torrent::POS_STATE_STICKY_NONE) {
$posStateUntil = \Carbon\Carbon::parse($_POST['pos_state_until']);
if ($posStateUntil->gte(now())) {
$posState = $_POST['pos_state'];
}
$posStateUntil = $_POST['pos_state_until'] ?: null;
$posState = $_POST['pos_state'];
if ($posState == \App\Models\Torrent::POS_STATE_STICKY_NONE) {
$posStateUntil = null;
}
if ($posStateUntil && \Carbon\Carbon::parse($posStateUntil)->lte(now())) {
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
$posStateUntil = null;
}
$updateset[] = sprintf("pos_state = %s", sqlesc($posState));
$updateset[] = sprintf("pos_state_until = %s", sqlesc($posStateUntil));

View File

@@ -344,13 +344,14 @@ if (isset($_POST['hr']) && isset(\App\Models\Torrent::$hrStatus[$_POST['hr']]) &
}
if(user_can('torrentsticky')) {
if (isset($_POST['pos_state']) && isset(\App\Models\Torrent::$posStates[$_POST['pos_state']])) {
$posStateUntil = null;
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
if (!empty($_POST['pos_state_until']) && $_POST['pos_state'] != \App\Models\Torrent::POS_STATE_STICKY_NONE) {
$posStateUntil = \Carbon\Carbon::parse($_POST['pos_state_until']);
if ($posStateUntil->gte(now())) {
$posState = $_POST['pos_state'];
}
$posStateUntil = $_POST['pos_state_until'] ?: null;
$posState = $_POST['pos_state'];
if ($posState == \App\Models\Torrent::POS_STATE_STICKY_NONE) {
$posStateUntil = null;
}
if ($posStateUntil && \Carbon\Carbon::parse($posStateUntil)->lte(now())) {
$posState = \App\Models\Torrent::POS_STATE_STICKY_NONE;
$posStateUntil = null;
}
$insert['pos_state'] = $posState;
$insert['pos_state_until'] = $posStateUntil;