fix log edit&del + seedBox change status add reason

This commit is contained in:
xiaomlove
2023-03-19 17:31:15 +08:00
parent 9fcc5c0810
commit c28d2c5e23
11 changed files with 32 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Filament\Resources\System;
use App\Filament\OptionsTrait;
use App\Filament\Resources\System\SeedBoxRecordResource\Pages;
use App\Filament\Resources\System\SeedBoxRecordResource\RelationManagers;
use App\Models\NexusModel;
use App\Models\SeedBoxRecord;
use App\Repositories\SeedBoxRepository;
use Filament\Facades\Filament;
@@ -64,7 +65,11 @@ class SeedBoxRecordResource extends Resource
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('typeText')->label(__('label.seed_box_record.type')),
Tables\Columns\TextColumn::make('uid')->searchable(),
Tables\Columns\TextColumn::make('user.username')->label(__('label.username'))->searchable(),
Tables\Columns\TextColumn::make('user.username')
->label(__('label.username'))
->searchable()
->formatStateUsing(fn ($record) => username_for_admin($record->uid))
,
Tables\Columns\TextColumn::make('operator')->label(__('label.seed_box_record.operator'))->searchable(),
Tables\Columns\TextColumn::make('bandwidth')->label(__('label.seed_box_record.bandwidth')),
Tables\Columns\TextColumn::make('ip')
@@ -112,14 +117,24 @@ class SeedBoxRecordResource extends Resource
Tables\Actions\EditAction::make(),
Tables\Actions\Action::make('audit')
->label(__('admin.resources.seed_box_record.toggle_status'))
->mountUsing(fn (Forms\ComponentContainer $form, NexusModel $record) => $form->fill([
'status' => $record->status,
]))
->form([
Forms\Components\Radio::make('status')->options(SeedBoxRecord::listStatus('text'))
->inline()->label(__('label.seed_box_record.status'))->required()
Forms\Components\Radio::make('status')
->options(SeedBoxRecord::listStatus('text'))
->inline()
->label(__('label.seed_box_record.status'))
->required()
,
Forms\Components\TextInput::make('reason')
->label(__('label.reason'))
,
])
->action(function (SeedBoxRecord $record, array $data) {
$rep = new SeedBoxRepository();
try {
$rep->updateStatus($record, $data['status']);
$rep->updateStatus($record, $data['status'], $data['reason']);
} catch (\Exception $exception) {
Filament::notify('danger', class_basename($exception));
}

View File

@@ -100,7 +100,7 @@ class SeedBoxRepository extends BaseRepository
return SeedBoxRecord::query()->whereIn('id', Arr::wrap($id))->where('uid', $uid)->delete();
}
public function updateStatus(SeedBoxRecord $seedBoxRecord, $status): bool
public function updateStatus(SeedBoxRecord $seedBoxRecord, $status, $reason = ''): bool
{
if (Auth::user()->class < User::CLASS_ADMINISTRATOR) {
throw new InsufficientPermissionException();
@@ -119,6 +119,7 @@ class SeedBoxRepository extends BaseRepository
'operator' => Auth::user()->username,
'old_status' => $seedBoxRecord->statusText,
'new_status' => nexus_trans('seed-box.status_text.' . $status),
'reason' => $reason,
]),
'added' => now()
];

View File

@@ -1,6 +1,6 @@
<?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.0');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-13');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-03-19');
defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");

View File

@@ -211,7 +211,7 @@ else {
while ($arr = mysql_fetch_assoc($res))
{
$date = gettime($arr['added'],true,false);
print("<tr><td class=rowfollow align=center><nobr>$date</nobr></td><td class=rowfollow align=left>".format_comment($arr["txt"],true,false,true)."</td>".(user_can('chrmanage') ? "<td align=center nowrap><b><a href=\"".$_SERVER['REQUEST_URI']."?action=chronicle&do=edit&id=".$arr["id"]."\">".$lang_log['text_edit']."</a>&nbsp;|&nbsp;<a href=\"".$_SERVER['REQUEST_URI']."?action=chronicle&do=del&id=".$arr["id"]."\"><font color=red>".$lang_log['text_delete']."</font></a></b></td>" : "")."</tr>\n");
print("<tr><td class=rowfollow align=center><nobr>$date</nobr></td><td class=rowfollow align=left>".format_comment($arr["txt"],true,false,true)."</td>".(user_can('chrmanage') ? "<td align=center nowrap><b><a href=\"?action=chronicle&do=edit&id=".$arr["id"]."\">".$lang_log['text_edit']."</a>&nbsp;|&nbsp;<a href=\"?action=chronicle&do=del&id=".$arr["id"]."\"><font color=red>".$lang_log['text_delete']."</font></a></b></td>" : "")."</tr>\n");
}
print("</table>");
echo $pagerbottom;

View File

@@ -62,7 +62,7 @@ if (!$action) {
$answered = "<font color=red>".$lang_staffbox['text_no']."</font>";
$pmid = $arr["id"];
print("<tr><td width=100% class=rowfollow align=left><a href=staffbox.php?action=viewpm&pmid=$pmid>".htmlspecialchars($arr['subject'])."</td><td class=rowfollow align=center>" . get_username($arr['sender']) . "</td><td class=rowfollow align=center><nobr>".gettime($arr['added'], true, false)."</nobr></td><td class=rowfollow align=center>$answered</td><td class=rowfollow align=center><input type=\"checkbox\" name=\"setanswered[]\" value=\"" . $arr['id'] . "\" /></td></tr>\n");
print("<tr><td width=100% class=rowfollow align=left><a href=staffbox.php?action=viewpm&pmid=$pmid&return=".urlencode($_SERVER['QUERY_STRING']).">".htmlspecialchars($arr['subject'])."</td><td class=rowfollow align=center>" . get_username($arr['sender']) . "</td><td class=rowfollow align=center><nobr>".gettime($arr['added'], true, false)."</nobr></td><td class=rowfollow align=center>$answered</td><td class=rowfollow align=center><input type=\"checkbox\" name=\"setanswered[]\" value=\"" . $arr['id'] . "\" /></td></tr>\n");
}
print("<tr><td class=rowfollow align=right colspan=5><input type=\"submit\" name=\"setdealt\" value=\"".$lang_staffbox['submit_set_answered']."\" /><input type=\"submit\" name=\"delete\" value=\"".$lang_staffbox['submit_delete']."\" /></td></tr>");
print("</table>\n");
@@ -121,7 +121,7 @@ print("<tr><td colspan=\"".$colspan."\" align=\"left\">".format_comment($arr4["a
print("<tr><td colspan=\"".$colspan."\" align=\"right\">");
print("<font color=white>");
if ($arr4["answered"] == 0)
print("[ <a href=\"staffbox.php?action=answermessage&receiver=" . $arr4['sender'] . "&answeringto=".$arr4['id']."\">".$lang_staffbox['text_reply']."</a> ] [ <a href=\"staffbox.php?action=setanswered&id=".$arr4['id']."\">".$lang_staffbox['text_mark_answered']."</a> ] ");
print("[ <a href=\"staffbox.php?action=answermessage&receiver=" . $arr4['sender'] . "&answeringto=".$arr4['id']."\">".$lang_staffbox['text_reply']."</a> ] [ <a href=\"staffbox.php?action=setanswered&id=".$arr4['id']."&return=".urlencode($_GET['return'] ?? '')."\">".$lang_staffbox['text_mark_answered']."</a> ] ");
print("[ <a href=\"staffbox.php?action=deletestaffmessage&id=" . $arr4["id"] . "\">".$lang_staffbox['text_delete']."</a> ]");
print("</font>");
print("</td></tr>");
@@ -231,7 +231,7 @@ $id = intval($_GET["id"] ?? 0);
sql_query ("UPDATE staffmessages SET answered=1, answeredby = {$CURUSER['id']} WHERE id = $id") or sqlerr();
$Cache->delete_value('staff_new_message_count');
clear_staff_message_cache();
header("Refresh: 0; url=staffbox.php?action=viewpm&pmid=$id");
header("Refresh: 0; url=staffbox.php" . (!empty($_GET['return']) ? "?" . $_GET['return'] : ''));
}
//////////////////////////

View File

@@ -39,6 +39,7 @@ return [
'country' => 'Country',
'city' => 'City',
'client' => 'Client',
'reason' => 'Reason',
'setting' => [
'nav_text' => 'Setting',
'backup' => [

View File

@@ -12,6 +12,6 @@ return [
],
'status_change_message' => [
'subject' => 'SeedBox record status changed',
'body' => 'The status of your SeedBox record with ID :id was changed by :operator from :old_status to :new_status',
'body' => 'The status of your SeedBox record with ID :id was changed by :operator from :old_status to :new_status. Reason: :reason',
],
];

View File

@@ -39,6 +39,7 @@ return [
'country' => '国家',
'city' => '城市',
'client' => '客户端',
'reason' => '原因',
'setting' => [
'nav_text' => '设置',
'backup' => [

View File

@@ -12,6 +12,6 @@ return [
],
'status_change_message' => [
'subject' => 'SeedBox 记录状态变更',
'body' => '你的 ID 为 :id 的 SeedBox 记录状态被 :operator 由 :old_status 变更为 :new_status',
'body' => '你的 ID 为 :id 的 SeedBox 记录状态被 :operator 由 :old_status 变更为 :new_status。原因::reason',
],
];

View File

@@ -39,6 +39,7 @@ return [
'country' => '國家',
'city' => '城市',
'client' => '客戶端',
'reason' => '原因',
'setting' => [
'nav_text' => '設置',
'backup' => [

View File

@@ -12,6 +12,6 @@ return [
],
'status_change_message' => [
'subject' => 'SeedBox 記錄狀態變更',
'body' => '你的 ID 為 :id 的 SeedBox 記錄狀態被 :operator 由 :old_status 變更為 :new_status',
'body' => '你的 ID 為 :id 的 SeedBox 記錄狀態被 :operator 由 :old_status 變更為 :new_status。原因::reason',
],
];