diff options
author | Carl Schwan <carl@carlschwan.eu> | 2021-10-15 21:59:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 21:59:43 +0300 |
commit | a67a12cb96250144c47ffb99ac1efa8a8c51a6b3 (patch) | |
tree | 70f6805d16880edcdcff4ae332e8c3e571db6446 /apps/federation | |
parent | ff67ada049fdb26f881450f7899f8eccfcd33310 (diff) | |
parent | 719dbafd1339702a170f04ebbc4f20e80d45e8c9 (diff) |
Merge pull request #29240 from nextcloud/work/admin-delegation-implementation
Add support for Delegation Settings for more apps
Diffstat (limited to 'apps/federation')
-rw-r--r-- | apps/federation/lib/Controller/SettingsController.php | 9 | ||||
-rw-r--r-- | apps/federation/lib/Settings/Admin.php | 25 | ||||
-rw-r--r-- | apps/federation/tests/Settings/AdminTest.php | 4 |
3 files changed, 31 insertions, 7 deletions
diff --git a/apps/federation/lib/Controller/SettingsController.php b/apps/federation/lib/Controller/SettingsController.php index 970211e4103..c60a7d31d7c 100644 --- a/apps/federation/lib/Controller/SettingsController.php +++ b/apps/federation/lib/Controller/SettingsController.php @@ -56,8 +56,9 @@ class SettingsController extends Controller { /** - * add server to the list of trusted Nextclouds + * Add server to the list of trusted Nextclouds. * + * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) * @param string $url * @return DataResponse * @throws HintException @@ -76,8 +77,9 @@ class SettingsController extends Controller { } /** - * add server to the list of trusted Nextclouds + * Add server to the list of trusted Nextclouds. * + * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) * @param int $id * @return DataResponse */ @@ -87,8 +89,9 @@ class SettingsController extends Controller { } /** - * check if the server should be added to the list of trusted servers or not + * Check if the server should be added to the list of trusted servers or not. * + * @AuthorizedAdminSetting(settings=OCA\Federation\Settings\Admin) * @param string $url * @return bool * @throws HintException diff --git a/apps/federation/lib/Settings/Admin.php b/apps/federation/lib/Settings/Admin.php index c4efe983783..7d4e51a124c 100644 --- a/apps/federation/lib/Settings/Admin.php +++ b/apps/federation/lib/Settings/Admin.php @@ -24,15 +24,26 @@ namespace OCA\Federation\Settings; use OCA\Federation\TrustedServers; use OCP\AppFramework\Http\TemplateResponse; -use OCP\Settings\ISettings; +use OCP\IL10N; +use OCP\Settings\IDelegatedSettings; -class Admin implements ISettings { +class Admin implements IDelegatedSettings { /** @var TrustedServers */ private $trustedServers; - public function __construct(TrustedServers $trustedServers) { + /** @var IL10N */ + private $l; + + /** + * Admin constructor. + * + * @param TrustedServers $trustedServers + * @param IL10N $l + */ + public function __construct(TrustedServers $trustedServers, IL10N $l) { $this->trustedServers = $trustedServers; + $this->l = $l; } /** @@ -63,4 +74,12 @@ class Admin implements ISettings { public function getPriority() { return 30; } + + public function getName(): ?string { + return $this->l->t("Trusted servers"); + } + + public function getAuthorizedAppConfig(): array { + return []; // Handled by custom controller + } } diff --git a/apps/federation/tests/Settings/AdminTest.php b/apps/federation/tests/Settings/AdminTest.php index e15fb5f8d2b..3d124d5c65a 100644 --- a/apps/federation/tests/Settings/AdminTest.php +++ b/apps/federation/tests/Settings/AdminTest.php @@ -26,6 +26,7 @@ namespace OCA\Federation\Tests\Settings; use OCA\Federation\Settings\Admin; use OCA\Federation\TrustedServers; use OCP\AppFramework\Http\TemplateResponse; +use OCP\IL10N; use Test\TestCase; class AdminTest extends TestCase { @@ -38,7 +39,8 @@ class AdminTest extends TestCase { parent::setUp(); $this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock(); $this->admin = new Admin( - $this->trustedServers + $this->trustedServers, + $this->createMock(IL10N::class) ); } |