diff options
Diffstat (limited to 'core/AppInfo')
-rw-r--r-- | core/AppInfo/Application.php | 90 | ||||
-rw-r--r-- | core/AppInfo/ConfigLexicon.php | 61 |
2 files changed, 151 insertions, 0 deletions
diff --git a/core/AppInfo/Application.php b/core/AppInfo/Application.php new file mode 100644 index 00000000000..f1fe7d763e3 --- /dev/null +++ b/core/AppInfo/Application.php @@ -0,0 +1,90 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only + */ +namespace OC\Core\AppInfo; + +use OC\Authentication\Events\RemoteWipeFinished; +use OC\Authentication\Events\RemoteWipeStarted; +use OC\Authentication\Listeners\RemoteWipeActivityListener; +use OC\Authentication\Listeners\RemoteWipeEmailListener; +use OC\Authentication\Listeners\RemoteWipeNotificationsListener; +use OC\Authentication\Listeners\UserDeletedFilesCleanupListener; +use OC\Authentication\Listeners\UserDeletedStoreCleanupListener; +use OC\Authentication\Listeners\UserDeletedTokenCleanupListener; +use OC\Authentication\Listeners\UserDeletedWebAuthnCleanupListener; +use OC\Authentication\Notifications\Notifier as AuthenticationNotifier; +use OC\Core\Listener\AddMissingIndicesListener; +use OC\Core\Listener\AddMissingPrimaryKeyListener; +use OC\Core\Listener\BeforeTemplateRenderedListener; +use OC\Core\Notification\CoreNotifier; +use OC\TagManager; +use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; +use OCP\AppFramework\Http\Events\BeforeLoginTemplateRenderedEvent; +use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; +use OCP\DB\Events\AddMissingIndicesEvent; +use OCP\DB\Events\AddMissingPrimaryKeyEvent; +use OCP\User\Events\BeforeUserDeletedEvent; +use OCP\User\Events\UserDeletedEvent; +use OCP\Util; + +/** + * Class Application + * + * @package OC\Core + */ +class Application extends App implements IBootstrap { + + public const APP_ID = 'core'; + + /** + * Application constructor. + */ + public function __construct(array $urlParams = []) { + parent::__construct(self::APP_ID, $urlParams); + } + + public function register(IRegistrationContext $context): void { + $context->registerService('defaultMailAddress', function () { + return Util::getDefaultEmailAddress('lostpassword-noreply'); + }); + + // register notifier + $context->registerNotifierService(CoreNotifier::class); + $context->registerNotifierService(AuthenticationNotifier::class); + + // register event listeners + $context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class); + $context->registerEventListener(AddMissingPrimaryKeyEvent::class, AddMissingPrimaryKeyListener::class); + $context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); + $context->registerEventListener(BeforeLoginTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class); + $context->registerEventListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class); + $context->registerEventListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class); + $context->registerEventListener(RemoteWipeStarted::class, RemoteWipeEmailListener::class); + $context->registerEventListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class); + $context->registerEventListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class); + $context->registerEventListener(RemoteWipeFinished::class, RemoteWipeEmailListener::class); + $context->registerEventListener(UserDeletedEvent::class, UserDeletedStoreCleanupListener::class); + $context->registerEventListener(UserDeletedEvent::class, UserDeletedTokenCleanupListener::class); + $context->registerEventListener(BeforeUserDeletedEvent::class, UserDeletedFilesCleanupListener::class); + $context->registerEventListener(UserDeletedEvent::class, UserDeletedFilesCleanupListener::class); + $context->registerEventListener(UserDeletedEvent::class, UserDeletedWebAuthnCleanupListener::class); + + // Tags + $context->registerEventListener(UserDeletedEvent::class, TagManager::class); + + // config lexicon + $context->registerConfigLexicon(ConfigLexicon::class); + } + + public function boot(IBootContext $context): void { + // ... + } + +} diff --git a/core/AppInfo/ConfigLexicon.php b/core/AppInfo/ConfigLexicon.php new file mode 100644 index 00000000000..df8243019ad --- /dev/null +++ b/core/AppInfo/ConfigLexicon.php @@ -0,0 +1,61 @@ +<?php + +declare(strict_types=1); +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +namespace OC\Core\AppInfo; + +use OCP\Config\Lexicon\Entry; +use OCP\Config\Lexicon\ILexicon; +use OCP\Config\Lexicon\Preset; +use OCP\Config\Lexicon\Strictness; +use OCP\Config\ValueType; + +/** + * Config Lexicon for core. + * + * Please Add & Manage your Config Keys in that file and keep the Lexicon up to date! + */ +class ConfigLexicon implements ILexicon { + public const SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES = 'shareapi_allow_federation_on_public_shares'; + public const SHARE_CUSTOM_TOKEN = 'shareapi_allow_custom_tokens'; + public const USER_LANGUAGE = 'lang'; + public const LASTCRON_TIMESTAMP = 'lastcron'; + + public function getStrictness(): Strictness { + return Strictness::IGNORE; + } + + public function getAppConfigs(): array { + return [ + new Entry( + key: self::SHAREAPI_ALLOW_FEDERATION_ON_PUBLIC_SHARES, + type: ValueType::BOOL, + defaultRaw: true, + definition: 'adds share permission to public shares to allow adding them to your Nextcloud (federation)', + lazy: true, + ), + new Entry( + key: self::SHARE_CUSTOM_TOKEN, + type: ValueType::BOOL, + defaultRaw: fn (Preset $p): bool => match ($p) { + Preset::FAMILY, Preset::PRIVATE => true, + default => false, + }, + definition: 'Allow users to set custom share link tokens', + lazy: true, + note: 'Shares with guessable tokens may be accessed easily. Shares with custom tokens will continue to be accessible after this setting has been disabled.', + ), + new Entry(self::LASTCRON_TIMESTAMP, ValueType::INT, 0, 'timestamp of last cron execution'), + ]; + } + + public function getUserConfigs(): array { + return [ + new Entry(self::USER_LANGUAGE, ValueType::STRING, null, 'language'), + ]; + } +} |