123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?php
- declare(strict_types=1);
- namespace OCA\Settings\AppInfo;
- use OC\AppFramework\Utility\TimeFactory;
- use OC\Authentication\Events\AppPasswordCreatedEvent;
- use OC\Authentication\Token\IProvider;
- use OC\Server;
- use OCA\Settings\Hooks;
- use OCA\Settings\Listener\AppPasswordCreatedActivityListener;
- use OCA\Settings\Listener\GroupRemovedListener;
- use OCA\Settings\Listener\UserAddedToGroupActivityListener;
- use OCA\Settings\Listener\UserRemovedFromGroupActivityListener;
- use OCA\Settings\Mailer\NewUserMailHelper;
- use OCA\Settings\Middleware\SubadminMiddleware;
- use OCA\Settings\Search\AppSearch;
- use OCA\Settings\Search\SectionSearch;
- use OCA\Settings\Search\UserSearch;
- use OCA\Settings\SetupChecks\AppDirsWithDifferentOwner;
- use OCA\Settings\SetupChecks\BruteForceThrottler;
- use OCA\Settings\SetupChecks\CheckUserCertificates;
- use OCA\Settings\SetupChecks\CodeIntegrity;
- use OCA\Settings\SetupChecks\CronErrors;
- use OCA\Settings\SetupChecks\CronInfo;
- use OCA\Settings\SetupChecks\DatabaseHasMissingColumns;
- use OCA\Settings\SetupChecks\DatabaseHasMissingIndices;
- use OCA\Settings\SetupChecks\DatabaseHasMissingPrimaryKeys;
- use OCA\Settings\SetupChecks\DatabasePendingBigIntConversions;
- use OCA\Settings\SetupChecks\DebugMode;
- use OCA\Settings\SetupChecks\DefaultPhoneRegionSet;
- use OCA\Settings\SetupChecks\EmailTestSuccessful;
- use OCA\Settings\SetupChecks\FileLocking;
- use OCA\Settings\SetupChecks\ForwardedForHeaders;
- use OCA\Settings\SetupChecks\InternetConnectivity;
- use OCA\Settings\SetupChecks\JavaScriptModules;
- use OCA\Settings\SetupChecks\LegacySSEKeyFormat;
- use OCA\Settings\SetupChecks\MaintenanceWindowStart;
- use OCA\Settings\SetupChecks\MemcacheConfigured;
- use OCA\Settings\SetupChecks\MysqlUnicodeSupport;
- use OCA\Settings\SetupChecks\OverwriteCliUrl;
- use OCA\Settings\SetupChecks\PhpDefaultCharset;
- use OCA\Settings\SetupChecks\PhpDisabledFunctions;
- use OCA\Settings\SetupChecks\PhpFreetypeSupport;
- use OCA\Settings\SetupChecks\PhpGetEnv;
- use OCA\Settings\SetupChecks\PhpMemoryLimit;
- use OCA\Settings\SetupChecks\PhpModules;
- use OCA\Settings\SetupChecks\PhpOpcacheSetup;
- use OCA\Settings\SetupChecks\PhpOutdated;
- use OCA\Settings\SetupChecks\PhpOutputBuffering;
- use OCA\Settings\SetupChecks\PushService;
- use OCA\Settings\SetupChecks\RandomnessSecure;
- use OCA\Settings\SetupChecks\ReadOnlyConfig;
- use OCA\Settings\SetupChecks\SupportedDatabase;
- use OCA\Settings\SetupChecks\SystemIs64bit;
- use OCA\Settings\SetupChecks\TempSpaceAvailable;
- use OCA\Settings\SetupChecks\TransactionIsolation;
- use OCA\Settings\SetupChecks\Woff2Loading;
- use OCA\Settings\UserMigration\AccountMigrator;
- use OCA\Settings\WellKnown\ChangePasswordHandler;
- use OCA\Settings\WellKnown\SecurityTxtHandler;
- use OCP\AppFramework\App;
- use OCP\AppFramework\Bootstrap\IBootContext;
- use OCP\AppFramework\Bootstrap\IBootstrap;
- use OCP\AppFramework\Bootstrap\IRegistrationContext;
- use OCP\AppFramework\IAppContainer;
- use OCP\Defaults;
- use OCP\Group\Events\GroupDeletedEvent;
- use OCP\Group\Events\UserAddedEvent;
- use OCP\Group\Events\UserRemovedEvent;
- use OCP\IServerContainer;
- use OCP\Settings\IManager;
- use OCP\Util;
- class Application extends App implements IBootstrap {
- public const APP_ID = 'settings';
-
- public function __construct(array $urlParams = []) {
- parent::__construct(self::APP_ID, $urlParams);
- }
- public function register(IRegistrationContext $context): void {
-
- $context->registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class);
- $context->registerMiddleware(SubadminMiddleware::class);
- $context->registerSearchProvider(SectionSearch::class);
- $context->registerSearchProvider(AppSearch::class);
- $context->registerSearchProvider(UserSearch::class);
-
- $context->registerEventListener(AppPasswordCreatedEvent::class, AppPasswordCreatedActivityListener::class);
- $context->registerEventListener(UserAddedEvent::class, UserAddedToGroupActivityListener::class);
- $context->registerEventListener(UserRemovedEvent::class, UserRemovedFromGroupActivityListener::class);
- $context->registerEventListener(GroupDeletedEvent::class, GroupRemovedListener::class);
-
- $context->registerWellKnownHandler(SecurityTxtHandler::class);
- $context->registerWellKnownHandler(ChangePasswordHandler::class);
-
-
- $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) {
-
- $serverContainer = $appContainer->query(IServerContainer::class);
- return $serverContainer->query(IProvider::class);
- });
- $context->registerService(IManager::class, function (IAppContainer $appContainer) {
-
- $serverContainer = $appContainer->query(IServerContainer::class);
- return $serverContainer->getSettingsManager();
- });
- $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) {
-
- $server = $appContainer->query(IServerContainer::class);
-
- $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(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(DebugMode::class);
- $context->registerSetupCheck(DefaultPhoneRegionSet::class);
- $context->registerSetupCheck(EmailTestSuccessful::class);
- $context->registerSetupCheck(FileLocking::class);
- $context->registerSetupCheck(ForwardedForHeaders::class);
- $context->registerSetupCheck(InternetConnectivity::class);
- $context->registerSetupCheck(JavaScriptModules::class);
- $context->registerSetupCheck(LegacySSEKeyFormat::class);
- $context->registerSetupCheck(MaintenanceWindowStart::class);
- $context->registerSetupCheck(MemcacheConfigured::class);
- $context->registerSetupCheck(MysqlUnicodeSupport::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(SupportedDatabase::class);
- $context->registerSetupCheck(SystemIs64bit::class);
- $context->registerSetupCheck(TempSpaceAvailable::class);
- $context->registerSetupCheck(TransactionIsolation::class);
- $context->registerSetupCheck(PushService::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');
- }
-
- public function onChangePassword(array $parameters) {
-
- $hooks = $this->getContainer()->query(Hooks::class);
- $hooks->onChangePassword($parameters['uid']);
- }
-
- public function onChangeInfo(array $parameters) {
- if ($parameters['feature'] !== 'eMailAddress') {
- return;
- }
-
- $hooks = $this->getContainer()->query(Hooks::class);
- $hooks->onChangeEmail($parameters['user'], $parameters['old_value']);
- }
- }
|