mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-15 05:00:49 +08:00
hr list add cancel + complain reply send email to notice
This commit is contained in:
@@ -47,6 +47,7 @@ class ClaimResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.user.label'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('torrent.name')->limit(40)->label(__('label.torrent.label'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('torrent.size')->label(__('label.torrent.size'))->formatStateUsing(fn (Model $record) => mksize($record->torrent->size)),
|
||||
|
||||
@@ -50,6 +50,7 @@ class ExamUserResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('exam.name')->label(__('label.exam.label')),
|
||||
Tables\Columns\TextColumn::make('begin')->label(__('label.begin'))->dateTime(),
|
||||
|
||||
@@ -36,24 +36,12 @@ class HitAndRunResource extends Resource
|
||||
return self::getNavigationLabel();
|
||||
}
|
||||
|
||||
// public static function form(Form $form): Form
|
||||
// {
|
||||
// return $form
|
||||
// ->schema(Forms\Components\Card::make()->schema([
|
||||
//// Forms\Components\Select::make('user')->relationship('user', 'username')->required(),
|
||||
//// Forms\Components\Select::make('torrent_id')->relationship('torrent', 'name')->required(),
|
||||
// Forms\Components\Radio::make('status')->options(HitAndRun::listStatus(true))->inline()->required(),
|
||||
//// Forms\Components\Select::make('snatch_id')->relationship('snatch', 'uploaded'),
|
||||
// Forms\Components\Textarea::make('comment'),
|
||||
// Forms\Components\DateTimePicker::make('created_at')->displayFormat('Y-m-d H:i:s'),
|
||||
// ]));
|
||||
// }
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->searchable()->label(__('label.username')),
|
||||
Tables\Columns\TextColumn::make('torrent.name')->limit(30)->label(__('label.torrent.label')),
|
||||
Tables\Columns\TextColumn::make('snatch.uploadText')->label(__('label.uploaded')),
|
||||
|
||||
@@ -46,6 +46,7 @@ class UserMedalResource extends Resource
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||
Tables\Columns\TextColumn::make('uid')->searchable(),
|
||||
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('medal.name')->label(__('label.medal.label'))->searchable(),
|
||||
Tables\Columns\ImageColumn::make('medal.image_large')->label(__('label.image')),
|
||||
|
||||
@@ -69,6 +69,7 @@ class UserResource extends Resource
|
||||
->sortable()->label(__("label.downloaded")),
|
||||
Tables\Columns\BadgeColumn::make('status')->colors(['success' => 'confirmed', 'warning' => 'pending'])->label(__("label.user.status")),
|
||||
Tables\Columns\BadgeColumn::make('enabled')->colors(['success' => 'yes', 'danger' => 'no'])->label(__("label.user.enabled")),
|
||||
Tables\Columns\BadgeColumn::make('downloadpos')->colors(['success' => 'yes', 'danger' => 'no'])->label(__("label.user.downloadpos")),
|
||||
Tables\Columns\TextColumn::make('added')->sortable()->dateTime('Y-m-d H:i')->label(__("label.added")),
|
||||
Tables\Columns\TextColumn::make('last_access')->dateTime()->label(__("label.last_access")),
|
||||
])
|
||||
@@ -77,6 +78,7 @@ class UserResource extends Resource
|
||||
Tables\Filters\SelectFilter::make('class')->options(array_column(User::$classes, 'text'))->label(__('label.user.class')),
|
||||
Tables\Filters\SelectFilter::make('status')->options(['confirmed' => 'confirmed', 'pending' => 'pending'])->label(__('label.user.status')),
|
||||
Tables\Filters\SelectFilter::make('enabled')->options(self::$yesOrNo)->label(__('label.user.enabled')),
|
||||
Tables\Filters\SelectFilter::make('downloadpos')->options(self::$yesOrNo)->label(__('label.user.downloadpos')),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
|
||||
9
app/Models/Complain.php
Normal file
9
app/Models/Complain.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
|
||||
class Complain extends NexusModel
|
||||
{
|
||||
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class BonusRepository extends BaseRepository
|
||||
|
||||
$hitAndRun->update([
|
||||
'status' => HitAndRun::STATUS_PARDONED,
|
||||
'comment' => NexusDB::raw("concat(comment, '\n$comment')"),
|
||||
'comment' => NexusDB::raw("if(comment = '', '$comment', concat_ws('\n', '$comment', comment))"),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ class BonusRepository extends BaseRepository
|
||||
$user = $this->getUser($user);
|
||||
if ($user->seedbonus < $requireBonus) {
|
||||
do_log("user: {$user->id}, bonus: {$user->seedbonus} < requireBonus: $requireBonus", 'error');
|
||||
throw new \LogicException("User bonus point not enough.");
|
||||
throw new \LogicException("User bonus not enough.");
|
||||
}
|
||||
NexusDB::transaction(function () use ($user, $requireBonus, $logBusinessType, $logComment, $userUpdates) {
|
||||
$logComment = addslashes($logComment);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.7.20');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-07-31');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2022-08-02');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
@@ -27,4 +27,6 @@ $lang_complains = [
|
||||
'complaints_processed' => '已处理申诉',
|
||||
'no_complaints_have_been_processed' => '暂无已处理的申诉',
|
||||
'text_view_band_log' => '查看封禁记录',
|
||||
'reply_notify_subject' => '申诉回复',
|
||||
'reply_notify_body' => '你在网站 %s 的申诉有了回复,点此 <a href="%s" target="_blank">查看</a>。',
|
||||
];
|
||||
|
||||
@@ -10,5 +10,5 @@ $lang_myhr = [
|
||||
'th_completed_at' => '下载完成时间',
|
||||
'th_ttl' => '剩余考察时间',
|
||||
'th_comment' => '备注',
|
||||
|
||||
'action_remove' => '消除',
|
||||
];
|
||||
|
||||
@@ -27,4 +27,6 @@ $lang_complains = [
|
||||
'complaints_processed' => '已處理申訴',
|
||||
'no_complaints_have_been_processed' => '暫無已處理的申訴',
|
||||
'text_view_band_log' => '查看封禁記錄',
|
||||
'reply_notify_subject' => '申訴回復',
|
||||
'reply_notify_body' => '你在網站 %s 的申訴有了回復,點此 <a href="%s" target="_blank">查看</a>。',
|
||||
];
|
||||
|
||||
@@ -10,5 +10,5 @@ $lang_myhr = [
|
||||
'th_completed_at' => '下載完成時間',
|
||||
'th_ttl' => '剩余考察時間',
|
||||
'th_comment' => '備註',
|
||||
|
||||
'action_remove' => '消除',
|
||||
];
|
||||
|
||||
@@ -27,4 +27,6 @@ $lang_complains = [
|
||||
'complaints_processed' => 'Complaints processed',
|
||||
'no_complaints_have_been_processed' => 'No complaints have been processed',
|
||||
'text_view_band_log' => 'View ban log',
|
||||
'reply_notify_subject' => 'Complaint replied',
|
||||
'reply_notify_body' => 'You have a reply to your complaint on the site %s, click here <a href="%s" target="_blank">to see it</a>.',
|
||||
];
|
||||
|
||||
@@ -10,5 +10,5 @@ $lang_myhr = [
|
||||
'th_completed_at' => 'Completed at',
|
||||
'th_ttl' => 'Inspecting time left',
|
||||
'th_comment' => 'Comment',
|
||||
|
||||
'action_remove' => 'Remove',
|
||||
];
|
||||
|
||||
@@ -109,3 +109,10 @@ function removeSeedBoxRecord($params)
|
||||
$rep = new \App\Repositories\SeedBoxRepository();
|
||||
return $rep->delete($params['id'], $CURUSER['id']);
|
||||
}
|
||||
|
||||
function removeHitAndRun($params)
|
||||
{
|
||||
global $CURUSER;
|
||||
$rep = new \App\Repositories\BonusRepository();
|
||||
return $rep->consumeToCancelHitAndRun($CURUSER['id'], $params['id']);
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@ require get_langfile_path();
|
||||
$isLogin = isset($CURUSER['id']);
|
||||
$isAdmin = get_user_class() >= $staffmem_class;
|
||||
|
||||
if($isLogin && !$isAdmin) permissiondenied();
|
||||
|
||||
if($isLogin && !$isAdmin) {
|
||||
permissiondenied();
|
||||
}
|
||||
$uid = $CURUSER['id'] ?? 0;
|
||||
if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
||||
switch($action = filter_input(INPUT_POST, 'action', FILTER_SANITIZE_FULL_SPECIAL_CHARS)){
|
||||
case 'new':
|
||||
@@ -23,8 +25,17 @@ if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
||||
case 'reply':
|
||||
$id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
|
||||
$body = filter_input(INPUT_POST, 'body', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$complain = \App\Models\Complain::query()->findOrFail($id);
|
||||
if(empty($id) || empty($body)) stderr($lang_functions['std_error'], $lang_complains['text_new_failure']);
|
||||
sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, isset($CURUSER['id']) ? $CURUSER['id'] : 0, sqlesc($body))) or sqlerr(__FILE__, __LINE__);
|
||||
sql_query(sprintf('INSERT INTO complain_replies (complain, userid, added, body) VALUES (%u, %u, NOW(), %s)', $id, $uid, sqlesc($body))) or sqlerr(__FILE__, __LINE__);
|
||||
if ($uid > 0) {
|
||||
try {
|
||||
$toolRep = new \App\Repositories\ToolRepository();
|
||||
$toolRep->sendMail($complain->email, $lang_complains['reply_notify_subject'], sprintf($lang_complains['reply_notify_body'], get_setting('basic.SITENAME'), getSchemeAndHttpHost() . '/complains.php?action=view&id=' . $complain->uuid));
|
||||
} catch (\Exception $exception) {
|
||||
do_log($exception->getMessage(), 'error');
|
||||
}
|
||||
}
|
||||
nexus_redirect($_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
case 'answered':
|
||||
|
||||
@@ -13,7 +13,7 @@ if (!empty($_GET['userid'])) {
|
||||
$userid = $_GET['userid'];
|
||||
$pagerParams['userid'] = $userid;
|
||||
}
|
||||
$userInfo = \App\Models\User::query()->find($userid);
|
||||
$userInfo = \App\Models\User::query()->find($userid, \App\Models\User::$commonFields);
|
||||
if (empty($userInfo)) {
|
||||
stderr('Error', "User not exists.");
|
||||
}
|
||||
@@ -50,7 +50,7 @@ print $filterForm;
|
||||
$baseQuery = \App\Models\HitAndRun::query()->where('uid', $userid)->where('status', $status);
|
||||
$rescount = (clone $baseQuery)->count();
|
||||
list($pagertop, $pagerbottom, $limit, $offset, $pageSize) = pager(50, $rescount, sprintf('?%s&', $queryString));
|
||||
print("<table width='100%'>");
|
||||
print("<table width='100%' id='hr-table'>");
|
||||
print("<tr>
|
||||
<td class='colhead' align='center'>{$lang_myhr['th_hr_id']}</td>
|
||||
<td class='colhead' align='center'>{$lang_myhr['th_torrent_name']}</td>
|
||||
@@ -61,6 +61,7 @@ print("<tr>
|
||||
<td class='colhead' align='center'>{$lang_myhr['th_completed_at']}</td>
|
||||
<td class='colhead' align='center'>{$lang_myhr['th_ttl']}</td>
|
||||
<td class='colhead' align='center'>{$lang_myhr['th_comment']}</td>
|
||||
<td class='colhead' align='center'>{$lang_functions['std_action']}</td>
|
||||
</tr>");
|
||||
if ($rescount) {
|
||||
|
||||
@@ -78,8 +79,13 @@ if ($rescount) {
|
||||
$query->where('id', $q);
|
||||
}
|
||||
$list = $query->get();
|
||||
|
||||
$hasActionRemove = false;
|
||||
foreach($list as $row) {
|
||||
$columnAction = '';
|
||||
if ($row->uid == $CURUSER['id'] && $row->status == \App\Models\HitAndRun::STATUS_INSPECTING) {
|
||||
$hasActionRemove = true;
|
||||
$columnAction = sprintf('<td class="rowfollow nowrap" align="center"><input class="remove-hr" type="button" value="%s" data-id="%s"></td>', $lang_myhr['action_remove'], $row->id);
|
||||
}
|
||||
print("<tr>
|
||||
<td class='rowfollow nowrap' align='center'>" . $row->id . "</td>
|
||||
<td class='rowfollow' align='left'><a href='details.php?id=" . $row->torrent_id . "'>" . optional($row->torrent)->name . "</a></td>
|
||||
@@ -89,9 +95,29 @@ if ($rescount) {
|
||||
<td class='rowfollow nowrap' align='center'>" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(3600 * get_setting('hr.seed_time_minimum') - $row->snatch->seedtime) : '---') . "</td>
|
||||
<td class='rowfollow nowrap' align='center'>" . format_datetime($row->snatch->completedat) . "</td>
|
||||
<td class='rowfollow nowrap' align='center' >" . ($row->status == \App\Models\HitAndRun::STATUS_INSPECTING ? mkprettytime(\Carbon\Carbon::now()->diffInSeconds($row->snatch->completedat->addHours(get_setting('hr.inspect_time')))) : '---') . "</td>
|
||||
<td class='rowfollow nowrap' align='left' style='padding-left: 10px'>" . nl2br($row->comment) . "</td>
|
||||
<td class='rowfollow nowrap' align='left' style='padding-left: 10px'>" . nl2br(trim($row->comment)) . "</td>
|
||||
{$columnAction}
|
||||
</tr>");
|
||||
}
|
||||
if ($hasActionRemove) {
|
||||
$msg = nexus_trans('hr.remove_confirm_msg', ['bonus' => get_setting('bonus.cancel_hr')]);
|
||||
$js = <<<JS
|
||||
jQuery('#hr-table').on('click', '.remove-hr', function () {
|
||||
var id = jQuery(this).attr('data-id')
|
||||
layer.confirm('{$msg}', function (index) {
|
||||
jQuery.post('ajax.php', {"action": "removeHitAndRun", "params": {"id": id}}, function (response) {
|
||||
console.log(response)
|
||||
if (response.ret != 0) {
|
||||
layer.alert(response.msg)
|
||||
return
|
||||
}
|
||||
window.location.reload()
|
||||
}, 'json')
|
||||
})
|
||||
})
|
||||
JS;
|
||||
\Nexus\Nexus::js($js, 'footer', false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,5 @@ return [
|
||||
'unreached_disable_message_content' => 'Your account has been disabled because the cumulative H&R count has been reached the system limit: :ban_user_when_counts_reach',
|
||||
|
||||
'bonus_cancel_comment' => 'spend :bonus canceled',
|
||||
'remove_confirm_msg' => 'Eliminate an H&R by deducting :bonus bonus, OK?',
|
||||
];
|
||||
|
||||
@@ -24,4 +24,5 @@ return [
|
||||
'unreached_disable_message_content' => '由于累计 H&R 数量已达系统上限::ban_user_when_counts_reach,你的账号已被禁用。',
|
||||
|
||||
'bonus_cancel_comment' => '花费 :bonus 魔力进行了消除',
|
||||
'remove_confirm_msg' => '消除一个 H&R 需要扣除 :bonus 魔力,确定吗?',
|
||||
];
|
||||
|
||||
@@ -24,4 +24,5 @@ return [
|
||||
'unreached_disable_message_content' => '由於累計 H&R 數量已達系統上限::ban_user_when_counts_reach,你的賬號已被禁用。',
|
||||
|
||||
'bonus_cancel_comment' => '花費 :bonus 魔力進行了消除',
|
||||
'remove_confirm_msg' => '消除一個 H&R 需要扣除 :bonus 魔力,確定嗎?',
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user