mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
enable user handle leechwarn
This commit is contained in:
+2
-1
@@ -82,7 +82,8 @@ class User extends Authenticatable
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status'
|
||||
'username', 'email', 'passhash', 'secret', 'stylesheet', 'editsecret', 'added', 'modcomment', 'enabled', 'status',
|
||||
'leechwarn', 'leechwarnuntil'
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user