]> source.dussan.org Git - nextcloud-server.git/commitdiff
Move personal settings to proper registration 19217/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 30 Jan 2020 12:30:45 +0000 (13:30 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 30 Jan 2020 21:06:28 +0000 (22:06 +0100)
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
13 files changed:
apps/settings/appinfo/info.xml
apps/settings/composer/composer/autoload_classmap.php
apps/settings/composer/composer/autoload_static.php
apps/settings/lib/Settings/Personal/Additional.php
apps/settings/lib/Settings/Personal/PersonalInfo.php
apps/settings/lib/Settings/Personal/Security/Authtokens.php
apps/settings/lib/Settings/Personal/Security/Password.php
apps/settings/lib/Settings/Personal/ServerDevNotice.php
apps/settings/tests/Controller/AdminSettingsControllerTest.php
apps/settings/tests/Settings/Personal/Security/AuthtokensTest.php
apps/settings/tests/Settings/Personal/Security/PasswordTest.php
lib/private/Settings/Manager.php
tests/lib/Settings/ManagerTest.php

index d86e5395efc40ccc301305aecbd92b06aecc7ecc..d77d8690b4468fb44a083e82e360426374a659da 100644 (file)
                <admin-section>OCA\Settings\Sections\Admin\Security</admin-section>
                <admin-section>OCA\Settings\Sections\Admin\Server</admin-section>
                <admin-section>OCA\Settings\Sections\Admin\Sharing</admin-section>
+               <personal>OCA\Settings\Settings\Personal\Additional</personal>
+               <personal>OCA\Settings\Settings\Personal\PersonalInfo</personal>
+               <personal>OCA\Settings\Settings\Personal\ServerDevNotice</personal>
+               <personal>OCA\Settings\Settings\Personal\Security\Authtokens</personal>
+               <personal>OCA\Settings\Settings\Personal\Security\Password</personal>
                <personal>OCA\Settings\Settings\Personal\Security\TwoFactor</personal>
                <personal-section>OCA\Settings\Sections\Personal\PersonalInfo</personal-section>
                <personal-section>OCA\Settings\Sections\Personal\Security</personal-section>
index 3e83c20bd388e6c2af3edd6c585dbad0f98a5a12..c68f3d85279868c6b5bca97a9a4e84357bcc1a2f 100644 (file)
@@ -36,11 +36,6 @@ return array(
     'OCA\\Settings\\Hooks' => $baseDir . '/../lib/Hooks.php',
     'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/../lib/Mailer/NewUserMailHelper.php',
     'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
-    'OCA\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
-    'OCA\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
-    'OCA\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
-    'OCA\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
-    'OCA\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
     'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php',
     'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php',
     'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir . '/../lib/Sections/Admin/Overview.php',
@@ -50,5 +45,10 @@ return array(
     'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php',
     'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php',
     'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php',
+    'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
+    'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
+    'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
+    'OCA\\Settings\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
     'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
+    'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
 );
index a76fe97eec9097a6682bf9c6b526dda8c75b8896..41b2ad27271a5afd1a45092b976b47b181aa7e19 100644 (file)
@@ -51,11 +51,6 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
         'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php',
         'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
-        'OCA\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
-        'OCA\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
-        'OCA\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
-        'OCA\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
-        'OCA\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
         'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
         'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php',
         'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php',
@@ -65,7 +60,12 @@ class ComposerStaticInitSettings
         'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
         'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php',
         'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php',
+        'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
+        'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
+        'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
+        'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
         'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
+        'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
     );
 
     public static function getInitializer(ClassLoader $loader)
index 2fc710b88c3cdb0fffa3a9e18be05afceb6c5f3c..ab128afe9a8d6604fa2f96edbd7645cb1016abbb 100644 (file)
@@ -22,7 +22,7 @@
  *
  */
 
-namespace OCA\Settings\Personal;
+namespace OCA\Settings\Settings\Personal;
 
 
 use OCP\AppFramework\Http\TemplateResponse;
index a91be782431f9e58bec1006f7dd5cf7cbcb09ca3..c8d9b3f8128494c58065df012f8bc7d5117477f4 100644 (file)
@@ -29,7 +29,7 @@
  *
  */
 
-namespace OCA\Settings\Personal;
+namespace OCA\Settings\Settings\Personal;
 
 use OC\Accounts\AccountManager;
 use OCA\FederatedFileSharing\AppInfo\Application;
index 1944670b2eac8d5e3e7b89bfa65e72dee579d527..93019766663b1bd95e7335a7329536c99425826c 100644 (file)
@@ -25,7 +25,7 @@ declare(strict_types=1);
  *
  */
 
-namespace OCA\Settings\Personal\Security;
+namespace OCA\Settings\Settings\Personal\Security;
 
 use OCP\IUserSession;
 use function array_map;
index 91d8b9228e865ba34e1fc7f6162c341f2e47cb96..06e82f6e4c3c1b3812baae511d9c72cf3702fb2e 100644 (file)
@@ -26,7 +26,7 @@ declare(strict_types=1);
  *
  */
 
-namespace OCA\Settings\Personal\Security;
+namespace OCA\Settings\Settings\Personal\Security;
 
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IUserManager;
index b5cf8c2c49c73f90c4be739a067884688921e73b..f69863fe35e262a95a537484df6bb1ef6546a9f7 100644 (file)
@@ -23,7 +23,7 @@
  *
  */
 
-namespace OCA\Settings\Personal;
+namespace OCA\Settings\Settings\Personal;
 
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\Settings\ISettings;
index ee8672691fca065453dec1af2a73c24def50a031..9a82fd978545bdf8ad7d63ed95569304912ca34d 100644 (file)
@@ -28,7 +28,7 @@
 namespace OCA\Settings\Tests\Controller;
 
 use OCA\Settings\Controller\AdminSettingsController;
-use OCA\Settings\Personal\ServerDevNotice;
+use OCA\Settings\Settings\Personal\ServerDevNotice;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\Group\ISubAdmin;
 use OCP\IGroupManager;
index 6fd7cf22efee1ad898387ee5aec9169a58bdd79a..1f85f49106ae98521953ab82dda624ef950055f3 100644 (file)
@@ -29,8 +29,7 @@ namespace OCA\Settings\Tests\Settings\Personal\Security;
 
 use OC\Authentication\Token\DefaultToken;
 use OC\Authentication\Token\IProvider as IAuthTokenProvider;
-use OCA\Settings\Personal\Password;
-use OCA\Settings\Personal\Security\Authtokens;
+use OCA\Settings\Settings\Personal\Security\Authtokens;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IInitialStateService;
 use OCP\ISession;
@@ -55,7 +54,7 @@ class AuthtokensTest extends TestCase {
        /** @var string */
        private $uid;
 
-       /** @var Security\Authtokens */
+       /** @var Authtokens */
        private $section;
 
        protected function setUp(): void {
index 160e4ebf844bdbe2716c558818374dd447dcbdcc..8eb4c022e711f314f67794847afbf53327cee8f2 100644 (file)
@@ -25,9 +25,9 @@ declare(strict_types=1);
  *
  */
 
-namespace OCA\Settings\Tests\Settings\Personal;
+namespace OCA\Settings\Tests\Settings\Personal\Security;
 
-use OCA\Settings\Personal\Security\Password;
+use OCA\Settings\Settings\Personal\Security\Password;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\IUser;
 use OCP\IUserManager;
@@ -69,7 +69,7 @@ class PasswordTest extends TestCase {
 
                $form = $this->section->getForm();
 
-               $expected = new TemplateResponse('settings', 'settings/personal/security', [
+               $expected = new TemplateResponse('settings', 'settings/personal/security/password', [
                        'passwordChangeSupported' => true,
                ]);
                $this->assertEquals($expected, $form);
index 157ab9db1d3e269e53df2702d091f3b459e20e3a..8018ecaba6176ba72acd77e69cca11c800584d2f 100644 (file)
@@ -175,7 +175,7 @@ class Manager implements IManager {
 
                        try {
                                /** @var ISettings $setting */
-                               $setting = \OC::$server->query($class);
+                               $setting = $this->container->query($class);
                        } catch (QueryException $e) {
                                $this->log->logException($e, ['level' => ILogger::INFO]);
                                continue;
@@ -272,39 +272,6 @@ class Manager implements IManager {
                return $forms;
        }
 
-       /**
-        * @param string $section
-        *
-        * @return ISection[]
-        */
-       private function getBuiltInPersonalSettings($section): array {
-               $forms = [];
-
-               if ($section === 'personal-info') {
-                       /** @var ISettings $form */
-                       $form = $this->container->query(\OCA\Settings\Personal\PersonalInfo::class);
-                       $forms[$form->getPriority()] = [$form];
-                       $form = new \OCA\Settings\Personal\ServerDevNotice();
-                       $forms[$form->getPriority()] = [$form];
-               }
-               if ($section === 'security') {
-                       /** @var ISettings $form */
-                       $form = $this->container->query(\OCA\Settings\Personal\Security\Password::class);
-                       $forms[$form->getPriority()] = [$form];
-
-                       /** @var ISettings $form */
-                       $form = $this->container->query(\OCA\Settings\Personal\Security\Authtokens::class);
-                       $forms[$form->getPriority()] = [$form];
-               }
-               if ($section === 'additional') {
-                       /** @var ISettings $form */
-                       $form = $this->container->query(\OCA\Settings\Personal\Additional::class);
-                       $forms[$form->getPriority()] = [$form];
-               }
-
-               return $forms;
-       }
-
        /**
         * @inheritdoc
         */
@@ -380,7 +347,7 @@ class Manager implements IManager {
         * @inheritdoc
         */
        public function getPersonalSettings($section): array {
-               $settings = $this->getBuiltInPersonalSettings($section);
+               $settings = [];
                $appSettings = $this->getSettings('personal', $section);
 
                foreach ($appSettings as $setting) {
index 7972a4bdbba93488ecd4c59c2317dbbc8e7618ae..06eafb6528bee64f2626d580c22ab94b882a5174 100644 (file)
 namespace OCA\Settings\Tests\AppInfo;
 
 use OC\Settings\Manager;
-use OC\Settings\Section;
 use OCA\Settings\Admin\Sharing;
-use OCA\Settings\Personal\Password;
 use OCP\IDBConnection;
 use OCP\IL10N;
 use OCP\ILogger;
 use OCP\IServerContainer;
 use OCP\IURLGenerator;
 use OCP\L10N\IFactory;
+use OCP\Settings\ISettings;
 use OCP\Settings\ISubAdminSettings;
 use Test\TestCase;
 
@@ -149,21 +148,27 @@ class ManagerTest extends TestCase {
        }
 
        public function testGetPersonalSettings() {
-               $section = $this->createMock(Password::class);
-               $section->expects($this->once())
-                       ->method('getPriority')
+               $section = $this->createMock(ISettings::class);
+               $section->method('getPriority')
                        ->willReturn(16);
-               $section2 = $this->createMock(Security\Authtokens::class);
-               $section2->expects($this->once())
-                       ->method('getPriority')
+               $section->method('getSection')
+                       ->willReturn('security');
+               $section2 = $this->createMock(ISettings::class);
+               $section2->method('getPriority')
                        ->willReturn(100);
+               $section2->method('getSection')
+                       ->willReturn('security');
+
+               $this->manager->registerSetting('personal', 'section1');
+               $this->manager->registerSetting('personal', 'section2');
+
                $this->container->expects($this->at(0))
                        ->method('query')
-                       ->with(Password::class)
+                       ->with('section1')
                        ->willReturn($section);
                $this->container->expects($this->at(1))
                        ->method('query')
-                       ->with(Security\Authtokens::class)
+                       ->with('section2')
                        ->willReturn($section2);
 
                $settings = $this->manager->getPersonalSettings('security');