mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17347] Use progress bar and test bot deletion only
PHPBB-17347
This commit is contained in:
parent
8c77da9c30
commit
db40145fd5
3 changed files with 23 additions and 12 deletions
|
@ -159,8 +159,9 @@ $lang = array_merge($lang, array(
|
||||||
|
|
||||||
'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.',
|
'CLI_USER_ADD_SUCCESS' => 'Successfully added user %s.',
|
||||||
'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete ‘%s’? [y/N]',
|
'CLI_USER_DELETE_CONFIRM' => 'Are you sure you want to delete ‘%s’? [y/N]',
|
||||||
'CLI_USER_DELETE_IDS_CONFIRM' => 'Are you sure you want to delete the user IDs ‘%s’? [y/N]',
|
'CLI_USER_DELETE_ID_CONFIRM' => 'Are you sure you want to delete the user IDs ‘%s’? [y/N]',
|
||||||
'CLI_USER_DELETE_IDS_SUCCESS' => 'Successfully deleted user IDs.',
|
'CLI_USER_DELETE_ID_SUCCESS' => 'Successfully deleted user IDs.',
|
||||||
|
'CLI_USER_DELETE_ID_START' => 'Deleting users by ID',
|
||||||
'CLI_USER_DELETE_NONE' => 'No users were deleted by user ID.',
|
'CLI_USER_DELETE_NONE' => 'No users were deleted by user ID.',
|
||||||
'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames',
|
'CLI_USER_RECLEAN_START' => 'Re-cleaning usernames',
|
||||||
'CLI_USER_RECLEAN_DONE' => [
|
'CLI_USER_RECLEAN_DONE' => [
|
||||||
|
|
|
@ -132,6 +132,10 @@ class delete_id extends command
|
||||||
{
|
{
|
||||||
$this->user_loader->load_users($user_ids);
|
$this->user_loader->load_users($user_ids);
|
||||||
|
|
||||||
|
$progress = $this->create_progress_bar(count($user_ids), $io, $output);
|
||||||
|
$progress->setMessage($this->language->lang('CLI_USER_DELETE_ID_START'));
|
||||||
|
$progress->start();
|
||||||
|
|
||||||
foreach ($user_ids as $user_id)
|
foreach ($user_ids as $user_id)
|
||||||
{
|
{
|
||||||
$user_row = $this->user_loader->get_user($user_id);
|
$user_row = $this->user_loader->get_user($user_id);
|
||||||
|
@ -139,14 +143,15 @@ class delete_id extends command
|
||||||
// Skip anonymous user
|
// Skip anonymous user
|
||||||
if ($user_row['user_id'] == ANONYMOUS)
|
if ($user_row['user_id'] == ANONYMOUS)
|
||||||
{
|
{
|
||||||
|
$progress->advance();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ($user_row['user_type'] == USER_IGNORE)
|
else if ($user_row['user_type'] == USER_IGNORE)
|
||||||
{
|
{
|
||||||
$this->delete_bot_user($user_row);
|
$this->delete_bot_user($user_row);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (!function_exists('user_delete'))
|
if (!function_exists('user_delete'))
|
||||||
{
|
{
|
||||||
require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
require($this->phpbb_root_path . 'includes/functions_user.' . $this->php_ext);
|
||||||
|
@ -155,12 +160,17 @@ class delete_id extends command
|
||||||
user_delete($mode, $user_row['user_id'], $user_row['username']);
|
user_delete($mode, $user_row['user_id'], $user_row['username']);
|
||||||
|
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username']));
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_USER_DELETED', false, array($user_row['username']));
|
||||||
|
}
|
||||||
|
|
||||||
|
$progress->advance();
|
||||||
$deleted_users++;
|
$deleted_users++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$progress->finish();
|
||||||
|
|
||||||
if ($deleted_users > 0)
|
if ($deleted_users > 0)
|
||||||
{
|
{
|
||||||
$io->success($this->language->lang('CLI_USER_DELETE_IDS_SUCCESS'));
|
$io->success($this->language->lang('CLI_USER_DELETE_ID_SUCCESS'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +197,7 @@ class delete_id extends command
|
||||||
if (count($user_ids) > 0)
|
if (count($user_ids) > 0)
|
||||||
{
|
{
|
||||||
$question = new ConfirmationQuestion(
|
$question = new ConfirmationQuestion(
|
||||||
$this->language->lang('CLI_USER_DELETE_IDS_CONFIRM', implode(',', $user_ids)),
|
$this->language->lang('CLI_USER_DELETE_ID_CONFIRM', implode(',', $user_ids)),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class phpbb_console_user_delete_ids_test extends phpbb_console_user_base
|
||||||
|
|
||||||
$command_tester->execute(array(
|
$command_tester->execute(array(
|
||||||
'command' => $this->command_name,
|
'command' => $this->command_name,
|
||||||
'user_ids' => [3, 6],
|
'user_ids' => [6],
|
||||||
'--delete-posts' => false,
|
'--delete-posts' => false,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue