registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class); $context->registerMiddleware(SubadminMiddleware::class); $context->registerSearchProvider(SectionSearch::class); $context->registerSearchProvider(AppSearch::class); $context->registerSearchProvider(UserSearch::class); // Register listeners $context->registerEventListener(AppPasswordCreatedEvent::class, AppPasswordCreatedActivityListener::class); $context->registerEventListener(UserAddedEvent::class, UserAddedToGroupActivityListener::class); $context->registerEventListener(UserRemovedEvent::class, UserRemovedFromGroupActivityListener::class); $context->registerEventListener(GroupDeletedEvent::class, GroupRemovedListener::class); // Register well-known handlers $context->registerWellKnownHandler(SecurityTxtHandler::class); $context->registerWellKnownHandler(ChangePasswordHandler::class); /** * Core class wrappers */ /** FIXME: Remove once OC_SubAdmin is non-static and mockable */ $context->registerService('isSubAdmin', function () { $userObject = \OC::$server->getUserSession()->getUser(); $isSubAdmin = false; if ($userObject !== null) { $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); } return $isSubAdmin; }); $context->registerService(IProvider::class, function (IAppContainer $appContainer) { /** @var IServerContainer $serverContainer */ $serverContainer = $appContainer->query(IServerContainer::class); return $serverContainer->query(IProvider::class); }); $context->registerService(IManager::class, function (IAppContainer $appContainer) { /** @var IServerContainer $serverContainer */ $serverContainer = $appContainer->query(IServerContainer::class); return $serverContainer->getSettingsManager(); }); $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) { /** @var Server $server */ $server = $appContainer->query(IServerContainer::class); /** @var Defaults $defaults */ $defaults = $server->query(Defaults::class); return new NewUserMailHelper( $defaults, $server->getURLGenerator(), $server->getL10NFactory(), $server->getMailer(), $server->getSecureRandom(), new TimeFactory(), $server->getConfig(), $server->getCrypto(), Util::getDefaultEmailAddress('no-reply') ); }); $context->registerSetupCheck(AllowedAdminRanges::class); $context->registerSetupCheck(AppDirsWithDifferentOwner::class); $context->registerSetupCheck(BruteForceThrottler::class); $context->registerSetupCheck(CheckUserCertificates::class); $context->registerSetupCheck(CodeIntegrity::class); $context->registerSetupCheck(CronErrors::class); $context->registerSetupCheck(CronInfo::class); $context->registerSetupCheck(DatabaseHasMissingColumns::class); $context->registerSetupCheck(DatabaseHasMissingIndices::class); $context->registerSetupCheck(DatabaseHasMissingPrimaryKeys::class); $context->registerSetupCheck(DatabasePendingBigIntConversions::class); $context->registerSetupCheck(DataDirectoryProtected::class); $context->registerSetupCheck(DebugMode::class); $context->registerSetupCheck(DefaultPhoneRegionSet::class); $context->registerSetupCheck(EmailTestSuccessful::class); $context->registerSetupCheck(FileLocking::class); $context->registerSetupCheck(ForwardedForHeaders::class); $context->registerSetupCheck(HttpsUrlGeneration::class); $context->registerSetupCheck(InternetConnectivity::class); $context->registerSetupCheck(JavaScriptSourceMaps::class); $context->registerSetupCheck(JavaScriptModules::class); $context->registerSetupCheck(LegacySSEKeyFormat::class); $context->registerSetupCheck(MaintenanceWindowStart::class); $context->registerSetupCheck(MemcacheConfigured::class); $context->registerSetupCheck(MimeTypeMigrationAvailable::class); $context->registerSetupCheck(MysqlUnicodeSupport::class); $context->registerSetupCheck(OcxProviders::class); $context->registerSetupCheck(OverwriteCliUrl::class); $context->registerSetupCheck(PhpDefaultCharset::class); $context->registerSetupCheck(PhpDisabledFunctions::class); $context->registerSetupCheck(PhpFreetypeSupport::class); $context->registerSetupCheck(PhpGetEnv::class); $context->registerSetupCheck(PhpMemoryLimit::class); $context->registerSetupCheck(PhpModules::class); $context->registerSetupCheck(PhpOpcacheSetup::class); $context->registerSetupCheck(PhpOutdated::class); $context->registerSetupCheck(PhpOutputBuffering::class); $context->registerSetupCheck(RandomnessSecure::class); $context->registerSetupCheck(ReadOnlyConfig::class); $context->registerSetupCheck(SecurityHeaders::class); $context->registerSetupCheck(SchedulingTableSize::class); $context->registerSetupCheck(SupportedDatabase::class); $context->registerSetupCheck(SystemIs64bit::class); $context->registerSetupCheck(TempSpaceAvailable::class); $context->registerSetupCheck(TransactionIsolation::class); $context->registerSetupCheck(PushService::class); $context->registerSetupCheck(WellKnownUrls::class); $context->registerSetupCheck(Woff2Loading::class); $context->registerUserMigrator(AccountMigrator::class); } public function boot(IBootContext $context): void { Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword'); Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo'); } /** * @param array $parameters * @throws \InvalidArgumentException * @throws \BadMethodCallException * @throws \Exception * @throws \OCP\AppFramework\QueryException */ public function onChangePassword(array $parameters) { /** @var Hooks $hooks */ $hooks = $this->getContainer()->query(Hooks::class); $hooks->onChangePassword($parameters['uid']); } /** * @param array $parameters * @throws \InvalidArgumentException * @throws \BadMethodCallException * @throws \Exception * @throws \OCP\AppFramework\QueryException */ public function onChangeInfo(array $parameters) { if ($parameters['feature'] !== 'eMailAddress') { return; } /** @var Hooks $hooks */ $hooks = $this->getContainer()->query(Hooks::class); $hooks->onChangeEmail($parameters['user'], $parameters['old_value']); } }