enable user handle leechwarn

This commit is contained in:
xiaomlove
2021-05-15 12:59:59 +08:00
parent 682cf806d7
commit 73f9920e1f
5 changed files with 22 additions and 9 deletions
+1 -1
View File
@@ -153,7 +153,7 @@ class ToolRepository extends BaseRepository
$filename = $backupResult['filename'];
$upload_result = $filesystem->put(basename($filename), fopen($filename, 'r'));
$backupResult['upload_result'] = $upload_result;
do_log("Final result: " . json_encode($backupResult));
return $backupResult;
}
}
+15 -3
View File
@@ -123,13 +123,25 @@ class UserRepository extends BaseRepository
public function enableUser(User $operator, $uid)
{
$targetUser = User::query()->findOrFail($uid, ['id', 'enabled', 'username']);
$targetUser = User::query()->findOrFail($uid, ['id', 'enabled', 'username', 'class']);
if ($targetUser->enabled == User::ENABLED_YES) {
throw new NexusException('Already enabled!');
}
$update = [
'enabled' => User::ENABLED_YES
];
if ($targetUser->class == User::CLASS_PEASANT) {
// warn users until 30 days
$until = now()->addDays(30)->toDateTimeString();
$update['leechwarn'] = 'yes';
$update['leechwarnuntil'] = $until;
} else {
$update['leechwarn'] = 'no';
$update['leechwarnuntil'] = null;
}
$modCommentText = sprintf("Enable by %s.", $operator->username);
$targetUser->updateWithModComment(['enabled' => User::ENABLED_YES], $modCommentText);
do_log("user: $uid, $modCommentText");
$targetUser->updateWithModComment($update, $modCommentText);
do_log("user: $uid, $modCommentText, update: " . nexus_json_encode($update));
return true;
}