diff --git a/README-EN.md b/README-EN.md
index ea9c615f..eb2e2fea 100644
--- a/README-EN.md
+++ b/README-EN.md
@@ -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
diff --git a/README.md b/README.md
index df38cb6d..b6120eb4 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,8 @@
- 字幕
- 考核
- H&R
-- 认领
+- 认领
+- 审核
- 签到
- 补签卡
- 勋章
diff --git a/app/Models/Torrent.php b/app/Models/Torrent.php
index 74a3d99d..a17e7cc8 100644
--- a/app/Models/Torrent.php
+++ b/app/Models/Torrent.php
@@ -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' => '',
+ ],
+ self::APPROVAL_STATUS_YES => [
+ 'text' => 'Allow',
+ 'icon' => '',
+ ],
+ self::APPROVAL_STATUS_NO => [
+ 'text' => 'Deny',
+ 'icon' => '',
+ ],
+ ];
+
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) {
diff --git a/database/migrations/2022_06_14_021936_add_approval_status_to_torrents_table.php b/database/migrations/2022_06_14_021936_add_approval_status_to_torrents_table.php
new file mode 100644
index 00000000..c22cee5e
--- /dev/null
+++ b/database/migrations/2022_06_14_021936_add_approval_status_to_torrents_table.php
@@ -0,0 +1,32 @@
+integer('approval_status')->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('torrents', function (Blueprint $table) {
+ $table->dropColumn('approval_status');
+ });
+ }
+};
diff --git a/include/functions.php b/include/functions.php
index fb6a6a19..f0d2e8fd 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -3449,7 +3449,8 @@ foreach ($rows as $row)
$banned_torrent = ($row["banned"] == 'yes' ? " (".$lang_functions['text_banned'].")" : "");
$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');
diff --git a/lang/chs/lang_settings.php b/lang/chs/lang_settings.php
index 96801ce6..c8d6aeb9 100644
--- a/lang/chs/lang_settings.php
+++ b/lang/chs/lang_settings.php
@@ -758,6 +758,8 @@ $lang_settings = array
'text_misc_settings_note' => '配置其他杂项。',
'row_misc_donation_custom' => '捐赠自定义内容',
'text_donation_custom_note' => '捐赠页自定义的内容,展示于支付宝、PayPal上面。支持 bbcode 标签',
+ 'row_approval_status_icon_enabled' => '审核状态图标',
+ 'text_approval_status_icon_enabled_note' => "是否在种子列表展示审核状态图标,默认: '否'。"
);
?>
diff --git a/lang/cht/lang_settings.php b/lang/cht/lang_settings.php
index 166f210d..faaf0246 100644
--- a/lang/cht/lang_settings.php
+++ b/lang/cht/lang_settings.php
@@ -758,6 +758,8 @@ $lang_settings = array
'text_misc_settings_note' => '配置其他雜項。',
'row_misc_donation_custom' => '捐贈自定義內容',
'text_donation_custom_note' => '捐贈頁自定義的內容,展示於支付寶、PayPal上面。支持 bbcode 標簽',
+ 'row_approval_status_icon_enabled' => '審核狀態圖標',
+ 'text_approval_status_icon_enabled_note' => "是否在種子列表展示審核狀態圖標,默認: '否'。"
);
?>
diff --git a/lang/en/lang_settings.php b/lang/en/lang_settings.php
index 34685cf1..e8758434 100644
--- a/lang/en/lang_settings.php
+++ b/lang/en/lang_settings.php
@@ -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 bbcode tag',
+ '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'."
);
?>
diff --git a/nexus/Install/settings.default.php b/nexus/Install/settings.default.php
index 54d723bd..8625c19c 100644
--- a/nexus/Install/settings.default.php
+++ b/nexus/Install/settings.default.php
@@ -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 (
diff --git a/nexus/Torrent/Torrent.php b/nexus/Torrent/Torrent.php
index c2427110..7e6e819e 100644
--- a/nexus/Torrent/Torrent.php
+++ b/nexus/Torrent/Torrent.php
@@ -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('%s', \App\Models\Torrent::$approvalStatus[$status]['icon']);
+ }
+ return '';
+ }
+
}
diff --git a/public/edit.php b/public/edit.php
index 81768d84..f409ae5b 100644
--- a/public/edit.php
+++ b/public/edit.php
@@ -154,28 +154,44 @@ else {
$rowChecks[] = "";
}
if (get_user_class() >= $torrentmanage_class) {
- array_unshift($rowChecks, "");
- $rowChecks[] = "";
+ array_unshift($rowChecks, "");
+ $approvalStatusRadio = [];
+ foreach (\App\Models\Torrent::$approvalStatus as $key => $value) {
+ if ($row['approval_status'] == $key) {
+ $checked = " checked";
+ } else {
+ $checked = "";
+ }
+ $approvalStatusRadio[] = sprintf(
+ '',
+ $key, $checked, nexus_trans("torrent.approval_status.$key")
+ );
+ }
+ $rowChecks[] = sprintf('审核:%s', implode('', $approvalStatusRadio));
+// $rowChecks[] = "";
$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(
- '%s:',
+ '%s:',
$banReasonDisplay, $lang_edit['ban_reason_label'], $row['banned'] == 'yes' && $banLog ? $banLog->comment : '', $banReasonReadonly
);
$js = << ".$lang_settings['text_sticky_first_level_background_color_note'], 1);
tr($lang_settings['row_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']."".$lang_settings['text_random_promotion_note_two'], 1);
tr($lang_settings['row_large_torrent_promotion'], $lang_settings['text_torrent_larger_than']."".$lang_settings['text_gb_promoted_to']."".$lang_settings['text_by_system_upon_uploading']."
".$lang_settings['text_large_torrent_promotion_note'], 1);
diff --git a/public/takeedit.php b/public/takeedit.php
index 01465fa1..ec9adaf0 100644
--- a/public/takeedit.php
+++ b/public/takeedit.php
@@ -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") . "'";
diff --git a/resources/lang/en/torrent.php b/resources/lang/en/torrent.php
index 2ee536da..73dc46d4 100644
--- a/resources/lang/en/torrent.php
+++ b/resources/lang/en/torrent.php
@@ -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',
+ ],
];
diff --git a/resources/lang/zh_CN/torrent.php b/resources/lang/zh_CN/torrent.php
index aa2048c7..4c65e664 100644
--- a/resources/lang/zh_CN/torrent.php
+++ b/resources/lang/zh_CN/torrent.php
@@ -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 => '拒绝',
+ ],
];
diff --git a/resources/lang/zh_TW/torrent.php b/resources/lang/zh_TW/torrent.php
index c2a4418a..dbb27a99 100644
--- a/resources/lang/zh_TW/torrent.php
+++ b/resources/lang/zh_TW/torrent.php
@@ -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 => '拒絕',
+ ],
];