. * */ declare(strict_types=0); namespace Ampache\Module\Application\Register; use Ampache\Config\ConfigContainerInterface; use Ampache\Config\ConfigurationKeyEnum; use Ampache\Module\Application\ApplicationActionInterface; use Ampache\Module\Application\Exception\AccessDeniedException; use Ampache\Module\Authorization\GuiGatekeeperInterface; use Ampache\Module\Util\Mailer; use Ampache\Module\Util\Ui; use Ampache\Module\Util\UiInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; final class ShowAddUserAction implements ApplicationActionInterface { public const REQUEST_KEY = 'show_add_user'; private ConfigContainerInterface $configContainer; private UiInterface $ui; public function __construct( ConfigContainerInterface $configContainer, UiInterface $ui ) { $this->configContainer = $configContainer; $this->ui = $ui; } /** * @param ServerRequestInterface $request * @param GuiGatekeeperInterface $gatekeeper * @return ResponseInterface|null * @todo drop copy/paste code from register action after fixing the captcha problem */ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gatekeeper): ?ResponseInterface { /* Check Perms */ if ( $this->configContainer->isFeatureEnabled(ConfigurationKeyEnum::ALLOW_PUBLIC_REGISTRATION) === false && !Mailer::is_mail_enabled() ) { throw new AccessDeniedException('Error attempted registration'); } /* Don't even include it if we aren't going to use it */ if ($this->configContainer->isFeatureEnabled(ConfigurationKeyEnum::CAPTCHA_PUBLIC_REG) === true) { define('CAPTCHA_INVERSE', 1); /** * @todo broken, the path does not exist any longer */ define( 'CAPTCHA_BASE_URL', sprintf( '%s/modules/captcha/captcha.php', $this->configContainer->getWebPath() ) ); require_once __DIR__ . '/../../Util/Captcha/init.php'; } require_once Ui::find_template('show_user_registration.inc.php'); return null; } }