. * */ declare(strict_types=0); namespace Ampache\Module\Application\Admin\User; use Ampache\Config\ConfigContainerInterface; use Ampache\Repository\Model\ModelFactoryInterface; use Ampache\Module\User\UserStateTogglerInterface; use Ampache\Module\Util\UiInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; final class EnableAction extends AbstractUserAction { public const REQUEST_KEY = 'enable'; private UiInterface $ui; private ModelFactoryInterface $modelFactory; private ConfigContainerInterface $configContainer; private UserStateTogglerInterface $userStateToggler; public function __construct( UiInterface $ui, ModelFactoryInterface $modelFactory, ConfigContainerInterface $configContainer, UserStateTogglerInterface $userStateToggler ) { $this->ui = $ui; $this->modelFactory = $modelFactory; $this->configContainer = $configContainer; $this->userStateToggler = $userStateToggler; } protected function handle(ServerRequestInterface $request): ?ResponseInterface { $this->ui->showHeader(); $user = $this->modelFactory->createUser((int) $request->getQueryParams()['user_id'] ?? 0); $this->userStateToggler->enable($user); $this->ui->showConfirmation( T_('No Problem'), /* HINT: Username and fullname together: Username (fullname) */ sprintf(T_('%s (%s) has been enabled'), $user->username, $user->fullname), 'admin/users.php' ); $this->ui->showQueryStats(); $this->ui->showFooter(); return null; } }