mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
add user ban log from cleanup.php
This commit is contained in:
@@ -19,7 +19,7 @@ class BackupWeb extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'BackupWeb webRoot data';
|
||||
protected $description = 'BackupWeb web data';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
@@ -39,7 +39,7 @@ class BackupWeb extends Command
|
||||
public function handle()
|
||||
{
|
||||
$rep = new ToolRepository();
|
||||
$result = $rep->backupWebRoot();
|
||||
$result = $rep->backupWeb();
|
||||
$log = sprintf('[%s], %s, result: %s', REQUEST_ID, __METHOD__, var_export($result, true));
|
||||
$this->info($log);
|
||||
do_log($log);
|
||||
|
||||
@@ -124,6 +124,15 @@ class User extends Authenticatable
|
||||
return Locale::$languageMaps[$this->language->site_lang_folder] ?? 'en';
|
||||
}
|
||||
|
||||
public function getSiteLangFolderAttribute()
|
||||
{
|
||||
$result = optional($this->language)->site_lang_folder;
|
||||
if ($result && in_array($result, ['en', 'chs', 'cht'])) {
|
||||
return $result;
|
||||
}
|
||||
return 'en';
|
||||
}
|
||||
|
||||
|
||||
public function exams()
|
||||
{
|
||||
|
||||
@@ -6,4 +6,5 @@ class UserBanLog extends NexusModel
|
||||
{
|
||||
protected $table = 'user_ban_logs';
|
||||
|
||||
protected $fillable = ['uid', 'username', 'operator', 'reason'];
|
||||
}
|
||||
|
||||
@@ -559,8 +559,8 @@ class ExamRepository extends BaseRepository
|
||||
$userModcommentUpdate[] = sprintf("when `id` = %s then concat_ws('\n', '%s', modcomment)", $uid, $userModcomment);
|
||||
$banLogReason = nexus_trans('exam.ban_log_reason', [
|
||||
'exam_name' => $exam->name,
|
||||
'begin' => $exam->begin,
|
||||
'end' => $exam->end,
|
||||
'begin' => $examUser->begin,
|
||||
'end' => $examUser->end,
|
||||
], $locale);
|
||||
$userBanLog[] = [
|
||||
'uid' => $uid,
|
||||
@@ -587,7 +587,7 @@ class ExamRepository extends BaseRepository
|
||||
if (!empty($uidToDisable)) {
|
||||
$uidStr = implode(', ', $uidToDisable);
|
||||
$sql = sprintf(
|
||||
'update %s set enabled = %s, set modcomment = case when %s end where id in (%s)',
|
||||
"update %s set enabled = '%s', modcomment = case %s end where id in (%s)",
|
||||
$userTable, User::ENABLED_NO, implode(' ', $userModcommentUpdate), $uidStr
|
||||
);
|
||||
$updateResult = DB::update($sql);
|
||||
|
||||
@@ -21,11 +21,11 @@ class ToolRepository extends BaseRepository
|
||||
return $systemInfo;
|
||||
}
|
||||
|
||||
public function backupWebRoot()
|
||||
public function backupWeb()
|
||||
{
|
||||
$webRoot = base_path();
|
||||
$dirName = basename($webRoot);
|
||||
$filename = sprintf('%s/%s.%s.tar.gz', sys_get_temp_dir(), $dirName, date('Ymd.His'));
|
||||
$filename = sprintf('%s/%s.web.%s.tar.gz', sys_get_temp_dir(), $dirName, date('Ymd.His'));
|
||||
$command = sprintf(
|
||||
'tar --exclude=vendor --exclude=.git -czf %s -C %s %s',
|
||||
$filename, dirname($webRoot), $dirName
|
||||
@@ -57,7 +57,7 @@ class ToolRepository extends BaseRepository
|
||||
|
||||
public function backupAll($uploadToGoogleDrive = false)
|
||||
{
|
||||
$backupWeb = $this->backupWebRoot();
|
||||
$backupWeb = $this->backupWeb();
|
||||
if ($backupWeb['result_code'] != 0) {
|
||||
throw new \RuntimeException("backup web fail: " . json_encode($backupWeb));
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class UserRepository extends BaseRepository
|
||||
public function getDetail($id)
|
||||
{
|
||||
$with = [
|
||||
'inviter' => function (Builder $query) {return $query->select(User::$commonFields);}
|
||||
'inviter' => function ($query) {return $query->select(User::$commonFields);}
|
||||
];
|
||||
$user = User::query()->with($with)->findOrFail($id, User::$commonFields);
|
||||
$userResource = new UserResource($user);
|
||||
|
||||
Reference in New Issue
Block a user