mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-22 02:47:27 +08:00
approval change to single action
This commit is contained in:
+10
-5
@@ -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', 'approval_status'
|
||||
'times_completed', 'approval_status', 'banned', 'visible',
|
||||
];
|
||||
|
||||
private static $globalPromotionState;
|
||||
@@ -132,19 +132,19 @@ 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;
|
||||
const APPROVAL_STATUS_ALLOW = 1;
|
||||
const APPROVAL_STATUS_DENY = 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 => [
|
||||
self::APPROVAL_STATUS_ALLOW => [
|
||||
'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 => [
|
||||
self::APPROVAL_STATUS_DENY => [
|
||||
'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>',
|
||||
],
|
||||
@@ -401,4 +401,9 @@ class Torrent extends NexusModel
|
||||
{
|
||||
return $this->hasMany(Reward::class, 'torrentid');
|
||||
}
|
||||
|
||||
public function operationLogs(): \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
{
|
||||
return $this->hasMany(TorrentOperationLog::class, 'torrent_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
class TorrentOperationLog extends NexusModel
|
||||
{
|
||||
protected $table = 'torrent_operation_logs';
|
||||
@@ -10,12 +12,14 @@ class TorrentOperationLog extends NexusModel
|
||||
|
||||
protected $fillable = ['uid', 'torrent_id', 'action_type', 'comment'];
|
||||
|
||||
const ACTION_TYPE_BAN = 'ban';
|
||||
const ACTION_TYPE_CANCEL_BAN = 'cancel_ban';
|
||||
const ACTION_TYPE_APPROVAL_NONE = 'approval_none';
|
||||
const ACTION_TYPE_APPROVAL_ALLOW = 'approval_allow';
|
||||
const ACTION_TYPE_APPROVAL_DENY = 'approval_deny';
|
||||
|
||||
public static array $actionTypes = [
|
||||
self::ACTION_TYPE_BAN => ['text' => 'Ban'],
|
||||
self::ACTION_TYPE_CANCEL_BAN => ['text' => 'Cancel ban'],
|
||||
self::ACTION_TYPE_APPROVAL_NONE => ['text' => 'Approval none'],
|
||||
self::ACTION_TYPE_APPROVAL_ALLOW => ['text' => 'Approval allow'],
|
||||
self::ACTION_TYPE_APPROVAL_DENY => ['text' => 'Approval deny'],
|
||||
];
|
||||
|
||||
public function user()
|
||||
@@ -32,7 +36,7 @@ class TorrentOperationLog extends NexusModel
|
||||
public static function add(array $params)
|
||||
{
|
||||
$log = self::query()->create($params);
|
||||
if (!in_array($params['action_type'], [self::ACTION_TYPE_CANCEL_BAN, self::ACTION_TYPE_BAN])) {
|
||||
if (!in_array($params['action_type'], [self::ACTION_TYPE_APPROVAL_ALLOW, self::ACTION_TYPE_APPROVAL_DENY])) {
|
||||
do_log("actionType: {$params['action_type']}, do not notify");
|
||||
return $log;
|
||||
}
|
||||
@@ -60,5 +64,6 @@ class TorrentOperationLog extends NexusModel
|
||||
'added' => now(),
|
||||
];
|
||||
Message::query()->insert($message);
|
||||
NexusDB::cache_del("user_{$receiver->id}_inbox_count");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,4 +36,20 @@ class BaseRepository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user
|
||||
* @param null $fields
|
||||
* @return User
|
||||
*/
|
||||
protected function getUser($user, $fields = null): User
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
return $user;
|
||||
}
|
||||
if ($fields === null) {
|
||||
$fields = User::$commonFields;
|
||||
}
|
||||
return User::query()->findOrFail(intval($user), $fields);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ use App\Models\SearchBox;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Snatch;
|
||||
use App\Models\Source;
|
||||
use App\Models\StaffMessage;
|
||||
use App\Models\Standard;
|
||||
use App\Models\Team;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\TorrentOperationLog;
|
||||
use App\Models\TorrentSecret;
|
||||
use App\Models\User;
|
||||
use Carbon\Carbon;
|
||||
@@ -422,5 +424,117 @@ class TorrentRepository extends BaseRepository
|
||||
|
||||
}
|
||||
|
||||
public function buildApprovalModal($user, $torrentId)
|
||||
{
|
||||
$user = $this->getUser($user);
|
||||
if ($user->class < Setting::get('authority.torrentmanage')) {
|
||||
throw new \RuntimeException("No permission !");
|
||||
}
|
||||
$torrent = Torrent::query()->findOrFail($torrentId, ['id', 'approval_status', 'banned']);
|
||||
$radios = [];
|
||||
foreach (Torrent::$approvalStatus as $key => $value) {
|
||||
if ($torrent->approval_status == $key) {
|
||||
$checked = " checked";
|
||||
} else {
|
||||
$checked = "";
|
||||
}
|
||||
$radios[] = sprintf(
|
||||
'<label><input type="radio" name="params[approval_status]" value="%s"%s>%s</label>',
|
||||
$key, $checked, nexus_trans("torrent.approval.status_text.$key")
|
||||
);
|
||||
}
|
||||
$id = "torrent-approval";
|
||||
$rows = [];
|
||||
$rowStyle = "display: flex; padding: 10px; align-items: center";
|
||||
$labelStyle = "width: 80px";
|
||||
$formId = "$id-form";
|
||||
$rows[] = sprintf(
|
||||
'<div class="%s-row" style="%s"><div style="%s">%s: </div><div>%s</div></div>',
|
||||
$id, $rowStyle, $labelStyle,nexus_trans('torrent.approval.status_label'), implode('', $radios)
|
||||
);
|
||||
$rows[] = sprintf(
|
||||
'<div class="%s-row" style="%s"><div style="%s">%s: </div><div><textarea name="params[comment]" rows="4" cols="40"></textarea></div></div>',
|
||||
$id, $rowStyle, $labelStyle, nexus_trans('torrent.approval.comment_label')
|
||||
);
|
||||
$rows[] = sprintf('<input type="hidden" name="params[torrent_id]" value="%s" />', $torrent->id);
|
||||
|
||||
$html = sprintf('<div id="%s-box" style="padding: 15px 30px"><form id="%s">%s</form></div>', $id, $formId, implode('', $rows));
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'form_id' => $formId,
|
||||
'title' => nexus_trans('torrent.approval.modal_title'),
|
||||
'content' => $html,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function approval($user, array $params): array
|
||||
{
|
||||
$user = $this->getUser($user);
|
||||
$torrent = Torrent::query()->findOrFail($params['torrent_id'], ['id', 'banned', 'approval_status', 'visible', 'owner']);
|
||||
if ($torrent->approval_status == $params['approval_status']) {
|
||||
//No change
|
||||
return $params;
|
||||
}
|
||||
$torrentUpdate = $torrentOperationLog = $staffMsg = [];
|
||||
$torrentUpdate['approval_status'] = $params['approval_status'];
|
||||
if ($params['approval_status'] == Torrent::APPROVAL_STATUS_ALLOW) {
|
||||
$torrentUpdate['banned'] = 'no';
|
||||
$torrentUpdate['visible'] = 'yes';
|
||||
if ($torrent->approval_status != $params['approval_status']) {
|
||||
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW;
|
||||
}
|
||||
} elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_DENY) {
|
||||
$torrentUpdate['banned'] = 'yes';
|
||||
$torrentUpdate['visible'] = 'no';
|
||||
if ($torrent->approval_status != $params['approval_status']) {
|
||||
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY;
|
||||
}
|
||||
} elseif ($params['approval_status'] == Torrent::APPROVAL_STATUS_NONE) {
|
||||
if ($torrent->approval_status != $params['approval_status']) {
|
||||
$torrentOperationLog['action_type'] = TorrentOperationLog::ACTION_TYPE_APPROVAL_NONE;
|
||||
}
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Invalid approval_status: " . $params['approval_status']);
|
||||
}
|
||||
if (isset($torrentOperationLog['action_type'])) {
|
||||
$torrentOperationLog['uid'] = $user->id;
|
||||
$torrentOperationLog['torrent_id'] = $torrent->id;
|
||||
$torrentOperationLog['comment'] = $params['comment'] ?? '';
|
||||
}
|
||||
|
||||
if ($torrent->banned == 'yes' && $torrent->owner == $user->id) {
|
||||
$torrentUrl = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $torrent->id);
|
||||
$staffMsg = [
|
||||
'sender' => $user->id,
|
||||
'subject' => nexus_trans('torrent.owner_update_torrent_subject', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
|
||||
'msg' => nexus_trans('torrent.owner_update_torrent_msg', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
|
||||
'added' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
NexusDB::transaction(function () use ($torrent, $torrentOperationLog, $torrentUpdate, $staffMsg) {
|
||||
$log = "";
|
||||
if (!empty($torrentUpdate)) {
|
||||
$log .= "[UPDATE_TORRENT]: " . nexus_json_encode($torrentUpdate);
|
||||
$torrent->update($torrentUpdate);
|
||||
}
|
||||
if (!empty($torrentOperationLog)) {
|
||||
$log .= "[ADD_TORRENT_OPERATION_LOG]: " . nexus_json_encode($torrentOperationLog);
|
||||
TorrentOperationLog::add($torrentOperationLog);
|
||||
}
|
||||
if (!empty($staffMsg)) {
|
||||
$log .= "[INSERT_STAFF_MESSAGE]: " . nexus_json_encode($staffMsg);
|
||||
StaffMessage::query()->insert($staffMsg);
|
||||
NexusDB::cache_del('staff_new_message_count');
|
||||
}
|
||||
do_log($log);
|
||||
});
|
||||
|
||||
return $params;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.16');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-06-14');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-06-15');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', true);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -2501,6 +2501,7 @@ foreach (\Nexus\Nexus::getAppendHeaders() as $value) {
|
||||
?>
|
||||
<script type="text/javascript" src="js/jquery-1.12.4.min.js<?php echo $cssupdatedate?>"></script>
|
||||
<script type="text/javascript">jQuery.noConflict();</script>
|
||||
<script type="text/javascript" src="vendor/layer-v3.5.1/layer/layer.js<?php echo $cssupdatedate?>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<table class="head" cellspacing="0" cellpadding="0" align="center">
|
||||
|
||||
@@ -237,6 +237,7 @@ $lang_details = array
|
||||
'claim_detail' => '认领详情',
|
||||
'claim_label' => '认领种子',
|
||||
'claim_confirm' => '确定要认领此种子吗?',
|
||||
'action_approval' => '审核',
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
@@ -74,3 +74,22 @@ function getOffer($params)
|
||||
return $offer->toArray();
|
||||
}
|
||||
|
||||
function approvalModal($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\TorrentRepository();
|
||||
return $rep->buildApprovalModal($CURUSER['id'], $params['torrent_id']);
|
||||
}
|
||||
|
||||
function approval($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
foreach (['torrent_id', 'approval_status',] as $field) {
|
||||
if (!isset($params[$field])) {
|
||||
throw new \InvalidArgumentException("Require $field");
|
||||
}
|
||||
}
|
||||
$rep = new \App\Repositories\TorrentRepository();
|
||||
return $rep->approval($CURUSER['id'], $params);
|
||||
}
|
||||
|
||||
|
||||
+68
-3
@@ -10,7 +10,7 @@ int_check($id);
|
||||
if (!isset($id) || !$id)
|
||||
die();
|
||||
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type,
|
||||
$res = sql_query("SELECT torrents.cache_stamp, torrents.sp_state, torrents.url, torrents.small_descr, torrents.seeders, torrents.banned, torrents.leechers, torrents.info_hash, torrents.filename, nfo, LENGTH(torrents.nfo) AS nfosz, torrents.last_action, torrents.name, torrents.owner, torrents.save_as, torrents.descr, torrents.visible, torrents.size, torrents.added, torrents.views, torrents.hits, torrents.times_completed, torrents.id, torrents.type, torrents.numfiles, torrents.anonymous, torrents.pt_gen, torrents.technical_info, torrents.hr, torrents.promotion_until, torrents.promotion_time_type, torrents.approval_status,
|
||||
categories.name AS cat_name, categories.mode as search_box_id, sources.name AS source_name, media.name AS medium_name, codecs.name AS codec_name, standards.name AS standard_name, processings.name AS processing_name, teams.name AS team_name, audiocodecs.name AS audiocodec_name
|
||||
FROM torrents LEFT JOIN categories ON torrents.category = categories.id
|
||||
LEFT JOIN sources ON torrents.source = sources.id
|
||||
@@ -55,7 +55,6 @@ if (!$row) {
|
||||
|
||||
if (!isset($_GET["cmtpage"])) {
|
||||
stdhead($lang_details['head_details_for_torrent']. "\"" . $row["name"] . "\"");
|
||||
|
||||
if (!empty($_GET["uploaded"]))
|
||||
{
|
||||
print("<h1 align=\"center\">".$lang_details['text_successfully_uploaded']."</h1>");
|
||||
@@ -74,6 +73,23 @@ if (!$row) {
|
||||
$hrImg = get_hr_img($row);
|
||||
$s=htmlspecialchars($row["name"]).$banned_torrent.($sp_torrent ? " ".$sp_torrent : "").($sp_torrent_sub) . $hrImg;
|
||||
print("<h1 align=\"center\" id=\"top\">".$s."</h1>\n");
|
||||
|
||||
//Banned reason
|
||||
if ($row['approval_status'] == \App\Models\Torrent::APPROVAL_STATUS_DENY) {
|
||||
$torrentOperationLog = \App\Models\TorrentOperationLog::query()
|
||||
->where('torrent_id', $row['id'])
|
||||
->where('action_type', \App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
if ($torrentOperationLog) {
|
||||
$dangerIcon = '<svg t="1655242121471" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="46590" width="16" height="16"><path d="M963.555556 856.888889a55.978667 55.978667 0 0 1-55.978667 56.007111c-0.284444 0-0.540444-0.085333-0.824889-0.085333l-0.056889 0.085333H110.734222l-0.654222-1.137778A55.409778 55.409778 0 0 1 56.888889 856.462222c0-9.756444 2.730667-18.773333 7.139555-26.737778l-3.726222-6.599111L453.461333 156.302222A59.335111 59.335111 0 0 1 510.236444 113.777778c26.936889 0 49.436444 18.005333 56.803556 42.552889l389.973333 661.447111-3.669333 6.997333c6.4 9.102222 10.211556 20.138667 10.211556 32.113778z m-497.777778-541.326222l16.014222 312.888889h56.888889l16.014222-312.888889h-88.917333z m44.458666 398.222222a56.888889 56.888889 0 1 0-0.028444 113.749333 56.888889 56.888889 0 0 0 0.028444-113.749333z" p-id="46591" fill="#d81e06" data-spm-anchor-id="a313x.7781069.0.i61" class="selected"></path></svg>';
|
||||
printf(
|
||||
'<div style="display: flex; justify-content: center;margin-bottom: 10px"><div style="display: flex;background-color: black; color: white;font-weight: bold; padding: 10px 100px">%s %s</div></div>',
|
||||
$dangerIcon, nexus_trans('torrent.approval.deny_comment_show', ['reason' => $torrentOperationLog->comment])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
print("<table width=\"97%\" cellspacing=\"0\" cellpadding=\"5\">\n");
|
||||
|
||||
$url = "edit.php?id=" . $row["id"];
|
||||
@@ -139,8 +155,57 @@ if (!$row) {
|
||||
if (get_user_class() >= $askreseed_class && $row['seeders'] == 0) {
|
||||
$actions[] = "<a title=\"".$lang_details['title_ask_for_reseed']."\" href=\"takereseed.php?reseedid=$id\"><img class=\"dt_reseed\" src=\"pic/trans.gif\" alt=\"reseed\"> <b><font class=\"small\">".$lang_details['text_ask_for_reseed'] ."</font></b></a>";
|
||||
}
|
||||
$actions[] = "<a title=\"".$lang_details['title_report_torrent']."\" href=\"report.php?torrent=$id\"><img class=\"dt_report\" src=\"pic/trans.gif\" alt=\"report\" /> <b><font class=\"small\">".$lang_details['text_report_torrent']."</font></b></a>";
|
||||
if (get_user_class() >= $torrentmanage_class) {
|
||||
$approvalIcon = '<svg t="1655224943277" class="icon" viewBox="0 0 1397 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="45530" width="16" height="16"><path d="M1396.363636 121.018182c0 0-223.418182 74.472727-484.072727 372.363636-242.036364 269.963636-297.890909 381.672727-390.981818 530.618182C512 1014.690909 372.363636 744.727273 0 549.236364l195.490909-186.181818c0 0 176.872727 121.018182 297.890909 344.436364 0 0 307.2-474.763636 902.981818-707.490909L1396.363636 121.018182 1396.363636 121.018182zM1396.363636 121.018182" p-id="45531" fill="#e78d0f"></path></svg>';
|
||||
$actions[] = sprintf(
|
||||
'<a href="javascript:;"><b><font id="approval" class="small approval" data-torrent_id="%s">%s %s</font></b></a>',
|
||||
$row['id'], $approvalIcon, $lang_details['action_approval']
|
||||
);
|
||||
$js = <<<JS
|
||||
jQuery('#approval').on("click", function () {
|
||||
let loadingIndex1 = layer.load()
|
||||
let torrentId = jQuery(this).attr('data-torrent_id')
|
||||
let params = {
|
||||
action: 'approvalModal',
|
||||
params: {
|
||||
torrent_id: torrentId
|
||||
}
|
||||
}
|
||||
jQuery.post('ajax.php', params, function (response) {
|
||||
layer.close(loadingIndex1)
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg)
|
||||
return
|
||||
}
|
||||
let formId = response.data.form_id;
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: response.data.title,
|
||||
content: response.data.content,
|
||||
btn: ["OK"],
|
||||
btnAlign: 'c',
|
||||
yes: function () {
|
||||
let loadingIndex2 = layer.load()
|
||||
let params = jQuery("#" + formId).serialize();
|
||||
jQuery.post("ajax.php", params + "&action=approval", function (response) {
|
||||
layer.close(loadingIndex2)
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg)
|
||||
return
|
||||
}
|
||||
window.location.reload()
|
||||
}, 'json')
|
||||
}
|
||||
})
|
||||
}, 'json')
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($js, 'footer', false);
|
||||
}
|
||||
$actions = apply_filter('torrent_detail_actions', $actions, $row);
|
||||
$actions[] = "<a title=\"".$lang_details['title_report_torrent']."\" href=\"report.php?torrent=$id\"><img class=\"dt_report\" src=\"pic/trans.gif\" alt=\"report\" /> <b><font class=\"small\">".$lang_details['text_report_torrent']."</font></b></a>";
|
||||
tr($lang_details['row_action'], implode(' | ', $actions), 1);
|
||||
|
||||
// ------------- start claim block ------------------//
|
||||
|
||||
@@ -155,48 +155,6 @@ else {
|
||||
}
|
||||
if (get_user_class() >= $torrentmanage_class) {
|
||||
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 = "hidden";
|
||||
$banReasonReadonly = "";
|
||||
if ($row['banned'] == 'yes') {
|
||||
$banReasonDisplay = 'visible';
|
||||
$banReasonReadonly = " readonly disabled";
|
||||
}
|
||||
$rowChecks[] = sprintf(
|
||||
'<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')
|
||||
let visible = jQuery('#visible')
|
||||
jQuery('#approval-status-box').on("click", "input", function () {
|
||||
let _this = jQuery(this)
|
||||
let value = _this.val()
|
||||
if (value == 2) {
|
||||
banReasonBox.css({"visibility": "visible"})
|
||||
visible.prop("checked", false)
|
||||
} else {
|
||||
banReasonBox.css({"visibility": "hidden"})
|
||||
visible.prop("checked", true)
|
||||
}
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($js, 'footer', false);
|
||||
|
||||
}
|
||||
if (!empty($rowChecks)) {
|
||||
tr($lang_edit['row_check'], implode(' ', $rowChecks), 1);
|
||||
|
||||
+1
-35
@@ -19,7 +19,7 @@ if (!$id)
|
||||
die();
|
||||
|
||||
|
||||
$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));
|
||||
$res = sql_query("SELECT id, category, owner, filename, save_as, anonymous, picktype, picktime, added, pt_gen FROM torrents WHERE id = ".mysql_real_escape_string($id));
|
||||
$row = mysql_fetch_array($res);
|
||||
$torrentAddedTimeString = $row['added'];
|
||||
if (!$row)
|
||||
@@ -106,24 +106,6 @@ $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 && 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") . "'";
|
||||
if(get_user_class()>=$torrentonpromotion_class)
|
||||
{
|
||||
@@ -269,22 +251,6 @@ else
|
||||
$searchRep = new \App\Repositories\SearchRepository();
|
||||
$searchRep->updateTorrent($id);
|
||||
|
||||
if (!empty($torrentOperationLog['action_type'])) {
|
||||
$torrentOperationLog['uid'] = $CURUSER['id'];
|
||||
$torrentOperationLog['torrent_id'] = $row['id'];
|
||||
$torrentOperationLog['comment'] = $_POST['ban_reason'] ?? '';
|
||||
\App\Models\TorrentOperationLog::add($torrentOperationLog);
|
||||
}
|
||||
if ($row['banned'] == 'yes' && $row['owner'] == $CURUSER['id']) {
|
||||
$torrentUrl = sprintf('%s/details.php?id=%s', getSchemeAndHttpHost(), $row['id']);
|
||||
\App\Models\StaffMessage::query()->insert([
|
||||
'sender' => $CURUSER['id'],
|
||||
'subject' => nexus_trans('torrent.owner_update_torrent_subject', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
|
||||
'msg' => nexus_trans('torrent.owner_update_torrent_msg', ['detail_url' => $torrentUrl, 'torrent_name' => $_POST['name']]),
|
||||
'added' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
$returl = "details.php?id=$id&edited=1";
|
||||
if (isset($_POST["returnto"]))
|
||||
$returl = $_POST["returnto"];
|
||||
|
||||
@@ -45,12 +45,12 @@ return [
|
||||
'claim_number_reach_torrent_maximum' => 'The maximum number of torrent is reached',
|
||||
'claim_disabled' => 'Claim is disabled',
|
||||
'operation_log' => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
|
||||
'type_text' => 'Banned',
|
||||
'notify_subject' => 'Torrent was banned',
|
||||
'notify_msg' => 'Your torrent:[url=:detail_url]:torrent_name[/url] was banned by :operator, Reason: :reason',
|
||||
],
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_CANCEL_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
|
||||
'type_text' => 'Cancel banned',
|
||||
'notify_subject' => 'Torrent was unbanned',
|
||||
'notify_msg' => 'Your torrent: [url=:detail_url]:torrent_name[/url] unbanned by :operator',
|
||||
@@ -58,9 +58,15 @@ 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',
|
||||
'approval' => [
|
||||
'modal_title' => 'Torrent approval',
|
||||
'status_label' => 'Approval status',
|
||||
'comment_label' => 'Comment(optional)',
|
||||
'status_text' => [
|
||||
\App\Models\Torrent::APPROVAL_STATUS_NONE => 'None',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => 'Allow',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_DENY => 'Deny',
|
||||
],
|
||||
'deny_comment_show' => 'Denied, reason: reason',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -45,12 +45,12 @@ return [
|
||||
'claim_number_reach_torrent_maximum' => '认领达到种子数上限',
|
||||
'claim_disabled' => '认领未启用',
|
||||
'operation_log' => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
|
||||
'type_text' => '禁止',
|
||||
'notify_subject' => '种子被禁止',
|
||||
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 禁止,原因::reason',
|
||||
],
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_CANCEL_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
|
||||
'type_text' => '取消禁止',
|
||||
'notify_subject' => '种子取消禁止',
|
||||
'notify_msg' => '你的种子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
|
||||
@@ -58,9 +58,15 @@ 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 => '拒绝',
|
||||
'approval' => [
|
||||
'modal_title' => '种子审核',
|
||||
'status_label' => '审核状态',
|
||||
'comment_label' => '备注(可选)',
|
||||
'status_text' => [
|
||||
\App\Models\Torrent::APPROVAL_STATUS_NONE => '未审',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => '通过',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_DENY => '拒绝',
|
||||
],
|
||||
'deny_comment_show' => '审核不通过,原因::reason',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -45,12 +45,12 @@ return [
|
||||
'claim_number_reach_torrent_maximum' => '認領達到種子數上限',
|
||||
'claim_disabled' => '認領未啟用',
|
||||
'operation_log' => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_DENY => [
|
||||
'type_text' => '禁止',
|
||||
'notify_subject' => '種子被禁止',
|
||||
'notify_msg' => '你的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 禁止,原因::reason',
|
||||
],
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_CANCEL_BAN => [
|
||||
\App\Models\TorrentOperationLog::ACTION_TYPE_APPROVAL_ALLOW => [
|
||||
'type_text' => '取消禁止',
|
||||
'notify_subject' => '種子取消禁止',
|
||||
'notify_msg' => '你的種子:[url=:detail_url]:torrent_name[/url] 被 :operator 取消禁止',
|
||||
@@ -58,9 +58,15 @@ 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 => '拒絕',
|
||||
'approval' => [
|
||||
'modal_title' => '種子審核',
|
||||
'status_label' => '審核狀態',
|
||||
'comment_label' => '備註(可選)',
|
||||
'status_text' => [
|
||||
\App\Models\Torrent::APPROVAL_STATUS_NONE => '未審',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_ALLOW => '通過',
|
||||
\App\Models\Torrent::APPROVAL_STATUS_DENY => '拒絕',
|
||||
],
|
||||
'deny_comment_show' => '審核不通過,原因::reason',
|
||||
],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user