approval status icon

This commit is contained in:
xiaomlove
2022-06-14 13:50:50 +08:00
parent bcaaa020b1
commit 7063dd47db
16 changed files with 130 additions and 27 deletions

View File

@@ -11,6 +11,7 @@ Complete PT website building solution. Based on NexusPHP + Laravel Framework + E
- Exam
- H&R
- Claim
- Approval
- Attendance
- Retroactive attendance card
- Medal

View File

@@ -9,7 +9,8 @@
- 字幕
- 考核
- H&R
- 认领
- 认领
- 审核
- 签到
- 补签卡
- 勋章

View File

@@ -15,7 +15,7 @@ class Torrent extends NexusModel
'size', 'added', 'type', 'numfiles', 'owner', 'nfo', 'sp_state', 'promotion_time_type',
'promotion_until', 'anonymous', 'url', 'pos_state', 'cache_stamp', 'picktype', 'picktime',
'last_reseed', 'pt_gen', 'technical_info', 'leechers', 'seeders', 'cover', 'last_action',
'times_completed'
'times_completed', 'approval_status'
];
private static $globalPromotionState;
@@ -34,7 +34,7 @@ class Torrent extends NexusModel
public static $commentFields = [
'id', 'name', 'added', 'visible', 'banned', 'owner', 'sp_state', 'pos_state', 'hr', 'picktype', 'picktime',
'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover', 'anonymous',
'last_action', 'leechers', 'seeders', 'times_completed', 'views', 'size', 'cover', 'anonymous', 'approval_status'
];
public static $basicRelations = [
@@ -131,6 +131,25 @@ class Torrent extends NexusModel
const BONUS_REWARD_VALUES = [50, 100, 200, 500, 1000];
const APPROVAL_STATUS_NONE = 0;
const APPROVAL_STATUS_YES = 1;
const APPROVAL_STATUS_NO = 2;
public static array $approvalStatus = [
self::APPROVAL_STATUS_NONE => [
'text' => 'None',
'icon' => '<svg t="1655184824967" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="34118" width="16" height="16"><path d="M450.267 772.245l0 92.511 92.511 0 0-92.511L450.267 772.245zM689.448 452.28c13.538-24.367 20.311-50.991 20.311-79.875 0-49.938-19.261-92.516-57.765-127.713-38.517-35.197-90.114-52.8-154.797-52.8-61.077 0-110.191 16.4-147.342 49.188-37.16 32.798-59.497 80.032-67.014 141.703l83.486 9.927c7.218-46.025 22.41-79.875 45.576-101.533 23.166-21.665 52.047-32.494 86.647-32.494 35.802 0 66.038 11.957 90.711 35.874 24.667 23.92 37.01 51.675 37.01 83.266 0 17.451-4.222 33.55-12.642 48.284-8.425 14.747-26.698 34.526-54.83 59.346s-47.607 43.701-58.442 56.637c-14.741 17.754-25.424 35.354-32.037 52.797-9.028 23.172-13.537 50.701-13.537 82.584 0 5.418 0.146 13.539 0.45 24.374l78.069 0c0.599-32.495 2.855-55.966 6.772-70.4 3.903-14.44 9.926-27.229 18.047-38.363 8.127-11.123 25.425-28.43 51.901-51.895C649.43 506.288 675.908 476.656 689.448 452.28L689.448 452.28z" p-id="34119" fill="#e78d0f"></path></svg>',
],
self::APPROVAL_STATUS_YES => [
'text' => 'Allow',
'icon' => '<svg t="1655145688503" class="icon" viewBox="0 0 1413 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16225" width="16" height="16"><path d="M1381.807797 107.47394L1274.675044 0.438669 465.281736 809.880718l-322.665524-322.714266L35.434718 594.152982l430.041982 430.041982 107.084012-107.035271-0.243705-0.292446z" fill="#1afa29" p-id="16226"></path></svg>',
],
self::APPROVAL_STATUS_NO => [
'text' => 'Deny',
'icon' => '<svg t="1655184952662" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="35029" width="16" height="16"><path d="M220.8 812.8l22.4 22.4 272-272 272 272 48-44.8-275.2-272 275.2-272-48-48-272 275.2-272-275.2-22.4 25.6-22.4 22.4 272 272-272 272z" fill="#d81e06" p-id="35030"></path></svg>',
],
];
public function getPickInfoAttribute()
{
$info = self::$pickTypes[$this->picktype] ?? null;
@@ -192,7 +211,7 @@ class Torrent extends NexusModel
public static function getFieldsForList($appendTableName = false): array|bool
{
$fields = 'id, sp_state, promotion_time_type, promotion_until, banned, picktype, pos_state, category, source, medium, codec, standard, processing, team, audiocodec, leechers, seeders, name, small_descr, times_completed, size, added, comments,anonymous,owner,url,cache_stamp, pt_gen, hr';
$fields = 'id, sp_state, promotion_time_type, promotion_until, banned, picktype, pos_state, category, source, medium, codec, standard, processing, team, audiocodec, leechers, seeders, name, small_descr, times_completed, size, added, comments,anonymous,owner,url,cache_stamp, pt_gen, hr, approval_status';
$fields = preg_split('/[,\s]+/', $fields);
if ($appendTableName) {
foreach ($fields as &$value) {

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('torrents', function (Blueprint $table) {
$table->integer('approval_status')->default(0);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('torrents', function (Blueprint $table) {
$table->dropColumn('approval_status');
});
}
};

View File

@@ -3449,7 +3449,8 @@ foreach ($rows as $row)
$banned_torrent = ($row["banned"] == 'yes' ? " <b>(<font class=\"striking\">".$lang_functions['text_banned']."</font>)</b>" : "");
$sp_torrent_sub = get_torrent_promotion_append_sub($row['sp_state'],"",true,$row['added'], $row['promotion_time_type'], $row['promotion_until'], $row['__ignore_global_sp_state'] ?? false);
$titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg;
$approvalStatusIcon = $torrent->renderApprovalStatus($row['approval_status']);
$titleSuffix = $banned_torrent.$picked_torrent.$sp_torrent.$sp_torrent_sub. $hrImg . $approvalStatusIcon;
$titleSuffix = apply_filter('torrent_title_suffix', $titleSuffix, $row);
print($titleSuffix);
//$tags = torrentTags($row['tags'], 'span');

View File

@@ -758,6 +758,8 @@ $lang_settings = array
'text_misc_settings_note' => '配置其他杂项。',
'row_misc_donation_custom' => '捐赠自定义内容',
'text_donation_custom_note' => '捐赠页自定义的内容展示于支付宝、PayPal上面。支持&nbsp;<b><a href="tags.php" target="_blank">bbcode 标签</a></b>',
'row_approval_status_icon_enabled' => '审核状态图标',
'text_approval_status_icon_enabled_note' => "是否在种子列表展示审核状态图标,默认: '否'。"
);
?>

View File

@@ -758,6 +758,8 @@ $lang_settings = array
'text_misc_settings_note' => '配置其他雜項。',
'row_misc_donation_custom' => '捐贈自定義內容',
'text_donation_custom_note' => '捐贈頁自定義的內容展示於支付寶、PayPal上面。支持&nbsp;<b><a href="tags.php" target="_blank">bbcode 標簽</a></b>',
'row_approval_status_icon_enabled' => '審核狀態圖標',
'text_approval_status_icon_enabled_note' => "是否在種子列表展示審核狀態圖標,默認: '否'。"
);
?>

View File

@@ -758,6 +758,8 @@ $lang_settings = array
'text_misc_settings_note' => 'Misc settings',
'row_misc_donation_custom' => 'Donation custom',
'text_donation_custom_note' => 'Donation page custom content, displayed above Alipay, PayPal. Support&nbsp;<b><a href="tags.php" target="_blank">bbcode tag</a></b>',
'row_approval_status_icon_enabled' => 'Approval status icon',
'text_approval_status_icon_enabled_note' => "Whether to show the approval status icon in the torrent list, default: 'No'."
);
?>

View File

@@ -332,6 +332,7 @@ return array (
'claim_bonus_multiplier' => \App\Models\Claim::BONUS_MULTIPLIER,
'claim_reach_standard_seed_time' => \App\Models\Claim::STANDARD_SEED_TIME_HOURS,
'claim_reach_standard_uploaded' => \App\Models\Claim::STANDARD_UPLOADED_TIMES,
'approval_status_icon_enabled' => 'no',
),
'attachment' =>
array (

View File

@@ -86,4 +86,12 @@ class Torrent
return $ptGen->buildRatingSpan($siteIdAndRating);
}
public function renderApprovalStatus($status): string
{
if (Setting::get('torrent.approval_status_icon_enabled') == 'yes') {
return sprintf('<span style="margin-left: 6px">%s</span>', \App\Models\Torrent::$approvalStatus[$status]['icon']);
}
return '';
}
}

View File

@@ -154,28 +154,44 @@ else {
$rowChecks[] = "<label><input type=\"checkbox\" name=\"anonymous\"" . ($row["anonymous"] == "yes" ? " checked=\"checked\"" : "" ) . " value=\"1\" />".$lang_edit['checkbox_anonymous_note']."</label>";
}
if (get_user_class() >= $torrentmanage_class) {
array_unshift($rowChecks, "<label><input type=\"checkbox\" name=\"visible\"" . ($row["visible"] == "yes" ? " checked=\"checked\"" : "" ) . " value=\"1\" />".$lang_edit['checkbox_visible']."</label>");
$rowChecks[] = "<label><input type=\"checkbox\" name=\"banned\"" . (($row["banned"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"yes\" />".$lang_edit['checkbox_banned']."</label>";
array_unshift($rowChecks, "<label><input id='visible' type=\"checkbox\" name=\"visible\"" . ($row["visible"] == "yes" ? " checked=\"checked\"" : "" ) . " value=\"1\" />".$lang_edit['checkbox_visible']."</label>");
$approvalStatusRadio = [];
foreach (\App\Models\Torrent::$approvalStatus as $key => $value) {
if ($row['approval_status'] == $key) {
$checked = " checked";
} else {
$checked = "";
}
$approvalStatusRadio[] = sprintf(
'<label><input type="radio" name="approval_status" value="%s"%s>%s</label>',
$key, $checked, nexus_trans("torrent.approval_status.$key")
);
}
$rowChecks[] = sprintf('<span style="margin-left: 6px" id="approval-status-box">审核:%s</span>', implode('', $approvalStatusRadio));
// $rowChecks[] = "<label><input type=\"checkbox\" name=\"banned\"" . (($row["banned"] == "yes") ? " checked=\"checked\"" : "" ) . " value=\"yes\" />".$lang_edit['checkbox_banned']."</label>";
$banLog = \App\Models\TorrentOperationLog::query()->where('torrent_id', $row['id'])->where('action_type', \App\Models\TorrentOperationLog::ACTION_TYPE_BAN)->orderBy('id', 'desc')->first();
$banReasonDisplay = "none";
$banReasonDisplay = "hidden";
$banReasonReadonly = "";
if ($row['banned'] == 'yes') {
$banReasonDisplay = 'inline-block';
$banReasonDisplay = 'visible';
$banReasonReadonly = " readonly disabled";
}
$rowChecks[] = sprintf(
'<span id="ban-reason-box" style="display: %s">%s<input type="text" name="ban_reason" value="%s" style="width: 300px"%s/></span>',
'<span id="ban-reason-box" style="visibility: %s">%s<input type="text" name="ban_reason" value="%s" style="width: 300px"%s/></span>',
$banReasonDisplay, $lang_edit['ban_reason_label'], $row['banned'] == 'yes' && $banLog ? $banLog->comment : '', $banReasonReadonly
);
$js = <<<JS
let banReasonBox = jQuery('#ban-reason-box')
jQuery('input[name=banned]').on("change", function () {
let visible = jQuery('#visible')
jQuery('#approval-status-box').on("click", "input", function () {
let _this = jQuery(this)
let checked = _this.prop('checked')
if (checked) {
banReasonBox.show()
let value = _this.val()
if (value == 2) {
banReasonBox.css({"visibility": "visible"})
visible.prop("checked", false)
} else {
banReasonBox.hide()
banReasonBox.css({"visibility": "hidden"})
visible.prop("checked", true)
}
})
JS;

View File

@@ -151,7 +151,7 @@ elseif($action == 'savesettings_torrent') // save account
'twoupbecome','twoupfreebecome', 'twouphalfleechbecome','normalbecome','uploaderdouble','deldeadtorrent', 'randomthirtypercentdown',
'thirtypercentleechbecome', 'expirethirtypercentleech', 'sticky_first_level_background_color', 'sticky_second_level_background_color',
'download_support_passkey', 'claim_enabled', 'claim_torrent_ttl', 'claim_torrent_user_counts_up_limit', 'claim_user_torrent_counts_up_limit', 'claim_remove_deduct_user_bonus',
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded'
'claim_give_up_deduct_user_bonus', 'claim_bonus_multiplier', 'claim_reach_standard_seed_time', 'claim_reach_standard_uploaded', 'approval_status_icon_enabled'
);
$validConfig = apply_filter('setting_valid_config', $validConfig);
GetVar($validConfig);
@@ -660,6 +660,7 @@ elseif ($action == 'torrentsettings')
tr($lang_settings['row_sticky_first_level_background_color'],"<input type='text' name=sticky_first_level_background_color style=\"width: 100px\" value={$TORRENT['sticky_first_level_background_color']}> ".$lang_settings['text_sticky_first_level_background_color_note'], 1);
tr($lang_settings['row_sticky_second_level_background_color'],"<input type='text' name=sticky_second_level_background_color style=\"width: 100px\" value={$TORRENT['sticky_second_level_background_color']}> ".$lang_settings['text_sticky_second_level_background_color_note'], 1);
yesorno($lang_settings['row_download_support_passkey'], 'download_support_passkey', $TORRENT["download_support_passkey"], $lang_settings['text_download_support_passkey_note']);
yesorno($lang_settings['row_approval_status_icon_enabled'], 'approval_status_icon_enabled', $TORRENT["approval_status_icon_enabled"], $lang_settings['text_approval_status_icon_enabled_note']);
yesorno($lang_settings['row_promotion_rules'], 'prorules', $TORRENT["prorules"], $lang_settings['text_promotion_rules_note']);
tr($lang_settings['row_random_promotion'], $lang_settings['text_random_promotion_note_one']."<ul><li><input type='text' style=\"width: 50px\" name=randomhalfleech value='".(isset($TORRENT["randomhalfleech"]) ? $TORRENT["randomhalfleech"] : 5 )."'>".$lang_settings['text_halfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomfree value='".(isset($TORRENT["randomfree"]) ? $TORRENT["randomfree"] : 2 )."'>".$lang_settings['text_free_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoup value='".(isset($TORRENT["randomtwoup"]) ? $TORRENT["randomtwoup"] : 2 )."'>".$lang_settings['text_twoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwoupfree value='".(isset($TORRENT["randomtwoupfree"]) ? $TORRENT["randomtwoupfree"] : 1 )."'>".$lang_settings['text_freetwoup_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomtwouphalfdown value='".(isset($TORRENT["randomtwouphalfdown"]) ? $TORRENT["randomtwouphalfdown"] : 0 )."'>".$lang_settings['text_twouphalfleech_chance_becoming']."</li><li><input type='text' style=\"width: 50px\" name=randomthirtypercentdown value='".(isset($TORRENT["randomthirtypercentdown"]) ? $TORRENT["randomthirtypercentdown"] : 0 )."'>".$lang_settings['text_thirtypercentleech_chance_becoming']."</li></ul>".$lang_settings['text_random_promotion_note_two'], 1);
tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."<input type='text' style=\"width: 50px\" name=largesize value='".(isset($TORRENT["largesize"]) ? $TORRENT["largesize"] : 20 )."'>".$lang_settings['text_gb_promoted_to']."<select name=largepro>".promotion_selection((isset($TORRENT['largepro']) ? $TORRENT['largepro'] : 2), 1)."</select>".$lang_settings['text_by_system_upon_uploading']."<br />".$lang_settings['text_large_torrent_promotion_note'], 1);

View File

@@ -19,7 +19,7 @@ if (!$id)
die();
$res = sql_query("SELECT id, category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen, banned FROM torrents WHERE id = ".mysql_real_escape_string($id));
$res = sql_query("SELECT id, category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen, banned, approval_status FROM torrents WHERE id = ".mysql_real_escape_string($id));
$row = mysql_fetch_array($res);
$torrentAddedTimeString = $row['added'];
if (!$row)
@@ -106,20 +106,22 @@ $updateset[] = "standard = " . sqlesc(intval($_POST["standard_sel"] ?? 0));
$updateset[] = "processing = " . sqlesc(intval($_POST["processing_sel"] ?? 0));
$updateset[] = "team = " . sqlesc(intval($_POST["team_sel"] ?? 0));
$updateset[] = "audiocodec = " . sqlesc(intval($_POST["audiocodec_sel"] ?? 0));
if (get_user_class() >= $torrentmanage_class) {
if (!empty($_POST["banned"])) {
//Ban
$updateset[] = "banned = 'yes'";
$_POST['visible'] = 0;
if ($row['banned'] == 'no') {
$torrentOperationLog['action_type'] = \App\Models\TorrentOperationLog::ACTION_TYPE_BAN;
}
} else {
//Cancel ban
if (get_user_class() >= $torrentmanage_class && isset($_POST['approval_status']) && isset(\App\Models\Torrent::$approvalStatus[$_POST['approval_status']])) {
$approvalStatus = $_POST['approval_status'];
if ($approvalStatus == \App\Models\Torrent::APPROVAL_STATUS_YES) {
$updateset[] = "banned = 'no'";
if ($row['banned'] == 'yes') {
$torrentOperationLog['action_type'] = \App\Models\TorrentOperationLog::ACTION_TYPE_CANCEL_BAN;
}
} elseif ($approvalStatus == \App\Models\Torrent::APPROVAL_STATUS_NO) {
$updateset[] = "banned = 'yes'";
$_POST['visible'] = 0;
if ($row['banned'] == 'no') {
$torrentOperationLog['action_type'] = \App\Models\TorrentOperationLog::ACTION_TYPE_BAN;
}
}
if ($row['owner'] != $CURUSER['id'] && get_user_class() >= $staffmem_class) {
$updateset[] = "approval_status = $approvalStatus";
}
}
$updateset[] = "visible = '" . (isset($_POST["visible"]) && $_POST["visible"] ? "yes" : "no") . "'";

View File

@@ -58,4 +58,9 @@ return [
],
'owner_update_torrent_subject' => 'Banned torrent have been updated',
'owner_update_torrent_msg' => 'Torrent[url=:detail_url]:torrent_name[/url] has been updated by the owner, you can check if it meets the requirements and cancel the ban',
'approval_status' => [
\App\Models\Torrent::APPROVAL_STATUS_NONE => 'None',
\App\Models\Torrent::APPROVAL_STATUS_YES => 'Allow',
\App\Models\Torrent::APPROVAL_STATUS_NO => 'Deny',
],
];

View File

@@ -58,4 +58,9 @@ return [
],
'owner_update_torrent_subject' => '被禁种子已更新',
'owner_update_torrent_msg' => '种子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以检查是否符合要求并取消禁止',
'approval_status' => [
\App\Models\Torrent::APPROVAL_STATUS_NONE => '未审',
\App\Models\Torrent::APPROVAL_STATUS_YES => '通过',
\App\Models\Torrent::APPROVAL_STATUS_NO => '拒绝',
],
];

View File

@@ -58,4 +58,9 @@ return [
],
'owner_update_torrent_subject' => '被禁種子已更新',
'owner_update_torrent_msg' => '種子:[url=:detail_url]:torrent_name[/url] 已被作者更新,可以檢查是否符合要求並取消禁止',
'approval_status' => [
\App\Models\Torrent::APPROVAL_STATUS_NONE => '未審',
\App\Models\Torrent::APPROVAL_STATUS_YES => '通過',
\App\Models\Torrent::APPROVAL_STATUS_NO => '拒絕',
],
];