Passed
Push — master ( 7a0ac3...8d02ee )
by Morris
14:29 queued 11s
created
core/register_command.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -50,143 +50,143 @@
 block discarded – undo
50 50
 $application->add(new OC\Core\Command\App\CheckCode());
51 51
 $application->add(new OC\Core\Command\L10n\CreateJs());
52 52
 $application->add(new \OC\Core\Command\Integrity\SignApp(
53
-		\OC::$server->getIntegrityCodeChecker(),
54
-		new \OC\IntegrityCheck\Helpers\FileAccessHelper(),
55
-		\OC::$server->getURLGenerator()
53
+        \OC::$server->getIntegrityCodeChecker(),
54
+        new \OC\IntegrityCheck\Helpers\FileAccessHelper(),
55
+        \OC::$server->getURLGenerator()
56 56
 ));
57 57
 $application->add(new \OC\Core\Command\Integrity\SignCore(
58
-		\OC::$server->getIntegrityCodeChecker(),
59
-		new \OC\IntegrityCheck\Helpers\FileAccessHelper()
58
+        \OC::$server->getIntegrityCodeChecker(),
59
+        new \OC\IntegrityCheck\Helpers\FileAccessHelper()
60 60
 ));
61 61
 $application->add(new \OC\Core\Command\Integrity\CheckApp(
62
-		\OC::$server->getIntegrityCodeChecker()
62
+        \OC::$server->getIntegrityCodeChecker()
63 63
 ));
64 64
 $application->add(new \OC\Core\Command\Integrity\CheckCore(
65
-		\OC::$server->getIntegrityCodeChecker()
65
+        \OC::$server->getIntegrityCodeChecker()
66 66
 ));
67 67
 
68 68
 
69 69
 if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
70
-	$application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));
71
-	$application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager()));
72
-	$application->add(new OC\Core\Command\App\Install());
73
-	$application->add(new OC\Core\Command\App\GetPath());
74
-	$application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
75
-	$application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->getLogger()));
76
-	$application->add(\OC::$server->query(\OC\Core\Command\App\Update::class));
77
-
78
-	$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class));
79
-	$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enforce::class));
80
-	$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enable::class));
81
-	$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Disable::class));
82
-	$application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\State::class));
83
-
84
-	$application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig()));
85
-	$application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig()));
86
-	$application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig()));
87
-
88
-	$application->add(\OC::$server->query(\OC\Core\Command\Broadcast\Test::class));
89
-
90
-	$application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig()));
91
-	$application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig()));
92
-	$application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig()));
93
-	$application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig()));
94
-	$application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig()));
95
-	$application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig()));
96
-	$application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig()));
97
-	$application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
98
-
99
-	$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
100
-	$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger()));
101
-	$application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection()));
102
-	$application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()));
103
-	$application->add(new OC\Core\Command\Db\AddMissingColumns(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()));
104
-	$application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection()));
105
-	$application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection()));
106
-	$application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager()));
107
-	$application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection()));
108
-	$application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig()));
109
-
110
-	$application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
111
-	$application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
112
-	$application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
113
-	$application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
114
-	$application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager()));
115
-	$application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
116
-	$application->add(new OC\Core\Command\Encryption\DecryptAll(
117
-		\OC::$server->getEncryptionManager(),
118
-		\OC::$server->getAppManager(),
119
-		\OC::$server->getConfig(),
120
-		new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()),
121
-		new \Symfony\Component\Console\Helper\QuestionHelper())
122
-	);
123
-
124
-	$application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig()));
125
-	$application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig()));
126
-
127
-	$view = new \OC\Files\View();
128
-	$util = new \OC\Encryption\Util(
129
-		$view,
130
-		\OC::$server->getUserManager(),
131
-		\OC::$server->getGroupManager(),
132
-		\OC::$server->getConfig()
133
-	);
134
-	$application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot(
135
-			$view,
136
-			\OC::$server->getUserManager(),
137
-			\OC::$server->getConfig(),
138
-			$util,
139
-			new \Symfony\Component\Console\Helper\QuestionHelper()
140
-		)
141
-	);
142
-	$application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util));
143
-	$application->add(new OC\Core\Command\Encryption\MigrateKeyStorage(
144
-			$view,
145
-			\OC::$server->getUserManager(),
146
-			\OC::$server->getConfig(),
147
-			$util,
148
-			\OC::$server->getCrypto()
149
-		)
150
-	);
151
-
152
-	$application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory()));
153
-	$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
154
-	$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
155
-	$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
156
-	$application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
157
-	$application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory()));
158
-
159
-	$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class)));
160
-	$application->add(new OC\Core\Command\Maintenance\Repair(
161
-		new \OC\Repair([], \OC::$server->getEventDispatcher()),
162
-		\OC::$server->getConfig(),
163
-		\OC::$server->getEventDispatcher(),
164
-		\OC::$server->getAppManager()
165
-	));
166
-
167
-	$application->add(\OC::$server->query(\OC\Core\Command\Preview\Repair::class));
168
-
169
-	$application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
170
-	$application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager()));
171
-	$application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager()));
172
-	$application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
173
-	$application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
174
-	$application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
175
-	$application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
176
-	$application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection()));
177
-	$application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
178
-	$application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
179
-
180
-	$application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager()));
181
-	$application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager()));
182
-	$application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager()));
183
-	$application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
184
-	$application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
185
-
186
-	$application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(), \OC::$server->getL10N('core')));
187
-	$application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager()));
188
-	$application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager()));
189
-	$application->add(new OC\Core\Command\Security\ResetBruteforceAttempts(\OC::$server->getBruteForceThrottler()));
70
+    $application->add(new OC\Core\Command\App\Disable(\OC::$server->getAppManager()));
71
+    $application->add(new OC\Core\Command\App\Enable(\OC::$server->getAppManager(), \OC::$server->getGroupManager()));
72
+    $application->add(new OC\Core\Command\App\Install());
73
+    $application->add(new OC\Core\Command\App\GetPath());
74
+    $application->add(new OC\Core\Command\App\ListApps(\OC::$server->getAppManager()));
75
+    $application->add(new OC\Core\Command\App\Remove(\OC::$server->getAppManager(), \OC::$server->query(\OC\Installer::class), \OC::$server->getLogger()));
76
+    $application->add(\OC::$server->query(\OC\Core\Command\App\Update::class));
77
+
78
+    $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Cleanup::class));
79
+    $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enforce::class));
80
+    $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Enable::class));
81
+    $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\Disable::class));
82
+    $application->add(\OC::$server->query(\OC\Core\Command\TwoFactorAuth\State::class));
83
+
84
+    $application->add(new OC\Core\Command\Background\Cron(\OC::$server->getConfig()));
85
+    $application->add(new OC\Core\Command\Background\WebCron(\OC::$server->getConfig()));
86
+    $application->add(new OC\Core\Command\Background\Ajax(\OC::$server->getConfig()));
87
+
88
+    $application->add(\OC::$server->query(\OC\Core\Command\Broadcast\Test::class));
89
+
90
+    $application->add(new OC\Core\Command\Config\App\DeleteConfig(\OC::$server->getConfig()));
91
+    $application->add(new OC\Core\Command\Config\App\GetConfig(\OC::$server->getConfig()));
92
+    $application->add(new OC\Core\Command\Config\App\SetConfig(\OC::$server->getConfig()));
93
+    $application->add(new OC\Core\Command\Config\Import(\OC::$server->getConfig()));
94
+    $application->add(new OC\Core\Command\Config\ListConfigs(\OC::$server->getSystemConfig(), \OC::$server->getAppConfig()));
95
+    $application->add(new OC\Core\Command\Config\System\DeleteConfig(\OC::$server->getSystemConfig()));
96
+    $application->add(new OC\Core\Command\Config\System\GetConfig(\OC::$server->getSystemConfig()));
97
+    $application->add(new OC\Core\Command\Config\System\SetConfig(\OC::$server->getSystemConfig()));
98
+
99
+    $application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
100
+    $application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->getLogger()));
101
+    $application->add(new OC\Core\Command\Db\ConvertFilecacheBigInt(\OC::$server->getDatabaseConnection()));
102
+    $application->add(new OC\Core\Command\Db\AddMissingIndices(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()));
103
+    $application->add(new OC\Core\Command\Db\AddMissingColumns(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()));
104
+    $application->add(new OC\Core\Command\Db\Migrations\StatusCommand(\OC::$server->getDatabaseConnection()));
105
+    $application->add(new OC\Core\Command\Db\Migrations\MigrateCommand(\OC::$server->getDatabaseConnection()));
106
+    $application->add(new OC\Core\Command\Db\Migrations\GenerateCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager()));
107
+    $application->add(new OC\Core\Command\Db\Migrations\GenerateFromSchemaFileCommand(\OC::$server->getConfig(), \OC::$server->getAppManager(), \OC::$server->getDatabaseConnection()));
108
+    $application->add(new OC\Core\Command\Db\Migrations\ExecuteCommand(\OC::$server->getDatabaseConnection(), \OC::$server->getAppManager(), \OC::$server->getConfig()));
109
+
110
+    $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig()));
111
+    $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager()));
112
+    $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
113
+    $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig()));
114
+    $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager()));
115
+    $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper()));
116
+    $application->add(new OC\Core\Command\Encryption\DecryptAll(
117
+        \OC::$server->getEncryptionManager(),
118
+        \OC::$server->getAppManager(),
119
+        \OC::$server->getConfig(),
120
+        new \OC\Encryption\DecryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getUserManager(), new \OC\Files\View()),
121
+        new \Symfony\Component\Console\Helper\QuestionHelper())
122
+    );
123
+
124
+    $application->add(new OC\Core\Command\Log\Manage(\OC::$server->getConfig()));
125
+    $application->add(new OC\Core\Command\Log\File(\OC::$server->getConfig()));
126
+
127
+    $view = new \OC\Files\View();
128
+    $util = new \OC\Encryption\Util(
129
+        $view,
130
+        \OC::$server->getUserManager(),
131
+        \OC::$server->getGroupManager(),
132
+        \OC::$server->getConfig()
133
+    );
134
+    $application->add(new OC\Core\Command\Encryption\ChangeKeyStorageRoot(
135
+            $view,
136
+            \OC::$server->getUserManager(),
137
+            \OC::$server->getConfig(),
138
+            $util,
139
+            new \Symfony\Component\Console\Helper\QuestionHelper()
140
+        )
141
+    );
142
+    $application->add(new OC\Core\Command\Encryption\ShowKeyStorageRoot($util));
143
+    $application->add(new OC\Core\Command\Encryption\MigrateKeyStorage(
144
+            $view,
145
+            \OC::$server->getUserManager(),
146
+            \OC::$server->getConfig(),
147
+            $util,
148
+            \OC::$server->getCrypto()
149
+        )
150
+    );
151
+
152
+    $application->add(new OC\Core\Command\Maintenance\DataFingerprint(\OC::$server->getConfig(), new \OC\AppFramework\Utility\TimeFactory()));
153
+    $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
154
+    $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
155
+    $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
156
+    $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
157
+    $application->add(new OC\Core\Command\Maintenance\UpdateTheme(\OC::$server->getMimeTypeDetector(), \OC::$server->getMemCacheFactory()));
158
+
159
+    $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->query(\OC\Installer::class)));
160
+    $application->add(new OC\Core\Command\Maintenance\Repair(
161
+        new \OC\Repair([], \OC::$server->getEventDispatcher()),
162
+        \OC::$server->getConfig(),
163
+        \OC::$server->getEventDispatcher(),
164
+        \OC::$server->getAppManager()
165
+    ));
166
+
167
+    $application->add(\OC::$server->query(\OC\Core\Command\Preview\Repair::class));
168
+
169
+    $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
170
+    $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager()));
171
+    $application->add(new OC\Core\Command\User\Disable(\OC::$server->getUserManager()));
172
+    $application->add(new OC\Core\Command\User\Enable(\OC::$server->getUserManager()));
173
+    $application->add(new OC\Core\Command\User\LastSeen(\OC::$server->getUserManager()));
174
+    $application->add(\OC::$server->get(\OC\Core\Command\User\Report::class));
175
+    $application->add(new OC\Core\Command\User\ResetPassword(\OC::$server->getUserManager()));
176
+    $application->add(new OC\Core\Command\User\Setting(\OC::$server->getUserManager(), \OC::$server->getConfig(), \OC::$server->getDatabaseConnection()));
177
+    $application->add(new OC\Core\Command\User\ListCommand(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
178
+    $application->add(new OC\Core\Command\User\Info(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
179
+
180
+    $application->add(new OC\Core\Command\Group\Add(\OC::$server->getGroupManager()));
181
+    $application->add(new OC\Core\Command\Group\Delete(\OC::$server->getGroupManager()));
182
+    $application->add(new OC\Core\Command\Group\ListCommand(\OC::$server->getGroupManager()));
183
+    $application->add(new OC\Core\Command\Group\AddUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
184
+    $application->add(new OC\Core\Command\Group\RemoveUser(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
185
+
186
+    $application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(), \OC::$server->getL10N('core')));
187
+    $application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager()));
188
+    $application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager()));
189
+    $application->add(new OC\Core\Command\Security\ResetBruteforceAttempts(\OC::$server->getBruteForceThrottler()));
190 190
 } else {
191
-	$application->add(\OC::$server->get(\OC\Core\Command\Maintenance\Install::class));
191
+    $application->add(\OC::$server->get(\OC\Core\Command\Maintenance\Install::class));
192 192
 }
Please login to merge, or discard this patch.
core/BackgroundJobs/CheckForUserCertificates.php 2 patches
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,47 +33,47 @@
 block discarded – undo
33 33
 
34 34
 class CheckForUserCertificates extends QueuedJob {
35 35
 
36
-	/** @var IConfig */
37
-	protected $config;
38
-	/** @var IUserManager */
39
-	private $userManager;
40
-	/** @var IRootFolder */
41
-	private $rootFolder;
36
+    /** @var IConfig */
37
+    protected $config;
38
+    /** @var IUserManager */
39
+    private $userManager;
40
+    /** @var IRootFolder */
41
+    private $rootFolder;
42 42
 
43
-	public function __construct(IConfig $config, IUserManager $userManager, IRootFolder $rootFolder) {
44
-		$this->config = $config;
45
-		$this->userManager = $userManager;
46
-		$this->rootFolder = $rootFolder;
47
-	}
43
+    public function __construct(IConfig $config, IUserManager $userManager, IRootFolder $rootFolder) {
44
+        $this->config = $config;
45
+        $this->userManager = $userManager;
46
+        $this->rootFolder = $rootFolder;
47
+    }
48 48
 
49
-	/**
50
-	 * Checks all user directories for old user uploaded certificates
51
-	 */
52
-	public function run($arguments) {
53
-		$uploadList = [];
54
-		$this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList) {
55
-			$userId = $user->getUID();
56
-			try {
57
-				\OC_Util::setupFS($userId);
58
-				$filesExternalUploadsFolder = $this->rootFolder->get($userId . '/files_external/uploads');
59
-			} catch (NotFoundException $e) {
60
-				\OC_Util::tearDownFS();
61
-				return;
62
-			}
63
-			if ($filesExternalUploadsFolder instanceof Folder) {
64
-				$files = $filesExternalUploadsFolder->getDirectoryListing();
65
-				foreach ($files as $file) {
66
-					$filename = $file->getName();
67
-					$uploadList[] = "$userId/files_external/uploads/$filename";
68
-				}
69
-			}
70
-			\OC_Util::tearDownFS();
71
-		});
49
+    /**
50
+     * Checks all user directories for old user uploaded certificates
51
+     */
52
+    public function run($arguments) {
53
+        $uploadList = [];
54
+        $this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList) {
55
+            $userId = $user->getUID();
56
+            try {
57
+                \OC_Util::setupFS($userId);
58
+                $filesExternalUploadsFolder = $this->rootFolder->get($userId . '/files_external/uploads');
59
+            } catch (NotFoundException $e) {
60
+                \OC_Util::tearDownFS();
61
+                return;
62
+            }
63
+            if ($filesExternalUploadsFolder instanceof Folder) {
64
+                $files = $filesExternalUploadsFolder->getDirectoryListing();
65
+                foreach ($files as $file) {
66
+                    $filename = $file->getName();
67
+                    $uploadList[] = "$userId/files_external/uploads/$filename";
68
+                }
69
+            }
70
+            \OC_Util::tearDownFS();
71
+        });
72 72
 
73
-		if (empty($uploadList)) {
74
-			$this->config->deleteAppValue('files_external', 'user_certificate_scan');
75
-		} else {
76
-			$this->config->setAppValue('files_external', 'user_certificate_scan', json_encode($uploadList));
77
-		}
78
-	}
73
+        if (empty($uploadList)) {
74
+            $this->config->deleteAppValue('files_external', 'user_certificate_scan');
75
+        } else {
76
+            $this->config->setAppValue('files_external', 'user_certificate_scan', json_encode($uploadList));
77
+        }
78
+    }
79 79
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@
 block discarded – undo
51 51
 	 */
52 52
 	public function run($arguments) {
53 53
 		$uploadList = [];
54
-		$this->userManager->callForSeenUsers(function (IUser $user) use (&$uploadList) {
54
+		$this->userManager->callForSeenUsers(function(IUser $user) use (&$uploadList) {
55 55
 			$userId = $user->getUID();
56 56
 			try {
57 57
 				\OC_Util::setupFS($userId);
58
-				$filesExternalUploadsFolder = $this->rootFolder->get($userId . '/files_external/uploads');
58
+				$filesExternalUploadsFolder = $this->rootFolder->get($userId.'/files_external/uploads');
59 59
 			} catch (NotFoundException $e) {
60 60
 				\OC_Util::tearDownFS();
61 61
 				return;
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/Manager.php 2 patches
Indentation   +534 added lines, -534 removed lines patch added patch discarded remove patch
@@ -51,579 +51,579 @@
 block discarded – undo
51 51
 use OCP\Share\IShare;
52 52
 
53 53
 class Manager {
54
-	public const STORAGE = '\OCA\Files_Sharing\External\Storage';
55
-
56
-	/** @var string|null */
57
-	private $uid;
58
-
59
-	/** @var IDBConnection */
60
-	private $connection;
61
-
62
-	/** @var \OC\Files\Mount\Manager */
63
-	private $mountManager;
64
-
65
-	/** @var IStorageFactory */
66
-	private $storageLoader;
67
-
68
-	/** @var IClientService */
69
-	private $clientService;
70
-
71
-	/** @var IManager */
72
-	private $notificationManager;
73
-
74
-	/** @var IDiscoveryService */
75
-	private $discoveryService;
76
-
77
-	/** @var ICloudFederationProviderManager */
78
-	private $cloudFederationProviderManager;
79
-
80
-	/** @var ICloudFederationFactory */
81
-	private $cloudFederationFactory;
82
-
83
-	/** @var IGroupManager  */
84
-	private $groupManager;
85
-
86
-	/** @var IUserManager */
87
-	private $userManager;
88
-
89
-	/** @var IEventDispatcher */
90
-	private $eventDispatcher;
91
-
92
-	public function __construct(IDBConnection $connection,
93
-								\OC\Files\Mount\Manager $mountManager,
94
-								IStorageFactory $storageLoader,
95
-								IClientService $clientService,
96
-								IManager $notificationManager,
97
-								IDiscoveryService $discoveryService,
98
-								ICloudFederationProviderManager $cloudFederationProviderManager,
99
-								ICloudFederationFactory $cloudFederationFactory,
100
-								IGroupManager $groupManager,
101
-								IUserManager $userManager,
102
-								?string $uid,
103
-								IEventDispatcher $eventDispatcher) {
104
-		$this->connection = $connection;
105
-		$this->mountManager = $mountManager;
106
-		$this->storageLoader = $storageLoader;
107
-		$this->clientService = $clientService;
108
-		$this->uid = $uid;
109
-		$this->notificationManager = $notificationManager;
110
-		$this->discoveryService = $discoveryService;
111
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
112
-		$this->cloudFederationFactory = $cloudFederationFactory;
113
-		$this->groupManager = $groupManager;
114
-		$this->userManager = $userManager;
115
-		$this->eventDispatcher = $eventDispatcher;
116
-	}
117
-
118
-	/**
119
-	 * add new server-to-server share
120
-	 *
121
-	 * @param string $remote
122
-	 * @param string $token
123
-	 * @param string $password
124
-	 * @param string $name
125
-	 * @param string $owner
126
-	 * @param int $shareType
127
-	 * @param boolean $accepted
128
-	 * @param string $user
129
-	 * @param int $remoteId
130
-	 * @param int $parent
131
-	 * @return Mount|null
132
-	 * @throws \Doctrine\DBAL\DBALException
133
-	 */
134
-	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) {
135
-		$user = $user ? $user : $this->uid;
136
-		$accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
-		$name = Filesystem::normalizePath('/' . $name);
138
-
139
-		if ($accepted !== IShare::STATUS_ACCEPTED) {
140
-			// To avoid conflicts with the mount point generation later,
141
-			// we only use a temporary mount point name here. The real
142
-			// mount point name will be generated when accepting the share,
143
-			// using the original share item name.
144
-			$tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
145
-			$mountPoint = $tmpMountPointName;
146
-			$hash = md5($tmpMountPointName);
147
-			$data = [
148
-				'remote' => $remote,
149
-				'share_token' => $token,
150
-				'password' => $password,
151
-				'name' => $name,
152
-				'owner' => $owner,
153
-				'user' => $user,
154
-				'mountpoint' => $mountPoint,
155
-				'mountpoint_hash' => $hash,
156
-				'accepted' => $accepted,
157
-				'remote_id' => $remoteId,
158
-				'share_type' => $shareType,
159
-			];
160
-
161
-			$i = 1;
162
-			while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163
-				// The external share already exists for the user
164
-				$data['mountpoint'] = $tmpMountPointName . '-' . $i;
165
-				$data['mountpoint_hash'] = md5($data['mountpoint']);
166
-				$i++;
167
-			}
168
-			return null;
169
-		}
170
-
171
-		$mountPoint = Files::buildNotExistingFileName('/', $name);
172
-		$mountPoint = Filesystem::normalizePath('/' . $mountPoint);
173
-		$hash = md5($mountPoint);
174
-
175
-		$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
176
-
177
-		$options = [
178
-			'remote' => $remote,
179
-			'token' => $token,
180
-			'password' => $password,
181
-			'mountpoint' => $mountPoint,
182
-			'owner' => $owner
183
-		];
184
-		return $this->mountShare($options);
185
-	}
186
-
187
-	/**
188
-	 * write remote share to the database
189
-	 *
190
-	 * @param $remote
191
-	 * @param $token
192
-	 * @param $password
193
-	 * @param $name
194
-	 * @param $owner
195
-	 * @param $user
196
-	 * @param $mountPoint
197
-	 * @param $hash
198
-	 * @param $accepted
199
-	 * @param $remoteId
200
-	 * @param $parent
201
-	 * @param $shareType
202
-	 * @return bool
203
-	 */
204
-	private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) {
205
-		$query = $this->connection->prepare('
54
+    public const STORAGE = '\OCA\Files_Sharing\External\Storage';
55
+
56
+    /** @var string|null */
57
+    private $uid;
58
+
59
+    /** @var IDBConnection */
60
+    private $connection;
61
+
62
+    /** @var \OC\Files\Mount\Manager */
63
+    private $mountManager;
64
+
65
+    /** @var IStorageFactory */
66
+    private $storageLoader;
67
+
68
+    /** @var IClientService */
69
+    private $clientService;
70
+
71
+    /** @var IManager */
72
+    private $notificationManager;
73
+
74
+    /** @var IDiscoveryService */
75
+    private $discoveryService;
76
+
77
+    /** @var ICloudFederationProviderManager */
78
+    private $cloudFederationProviderManager;
79
+
80
+    /** @var ICloudFederationFactory */
81
+    private $cloudFederationFactory;
82
+
83
+    /** @var IGroupManager  */
84
+    private $groupManager;
85
+
86
+    /** @var IUserManager */
87
+    private $userManager;
88
+
89
+    /** @var IEventDispatcher */
90
+    private $eventDispatcher;
91
+
92
+    public function __construct(IDBConnection $connection,
93
+                                \OC\Files\Mount\Manager $mountManager,
94
+                                IStorageFactory $storageLoader,
95
+                                IClientService $clientService,
96
+                                IManager $notificationManager,
97
+                                IDiscoveryService $discoveryService,
98
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
99
+                                ICloudFederationFactory $cloudFederationFactory,
100
+                                IGroupManager $groupManager,
101
+                                IUserManager $userManager,
102
+                                ?string $uid,
103
+                                IEventDispatcher $eventDispatcher) {
104
+        $this->connection = $connection;
105
+        $this->mountManager = $mountManager;
106
+        $this->storageLoader = $storageLoader;
107
+        $this->clientService = $clientService;
108
+        $this->uid = $uid;
109
+        $this->notificationManager = $notificationManager;
110
+        $this->discoveryService = $discoveryService;
111
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
112
+        $this->cloudFederationFactory = $cloudFederationFactory;
113
+        $this->groupManager = $groupManager;
114
+        $this->userManager = $userManager;
115
+        $this->eventDispatcher = $eventDispatcher;
116
+    }
117
+
118
+    /**
119
+     * add new server-to-server share
120
+     *
121
+     * @param string $remote
122
+     * @param string $token
123
+     * @param string $password
124
+     * @param string $name
125
+     * @param string $owner
126
+     * @param int $shareType
127
+     * @param boolean $accepted
128
+     * @param string $user
129
+     * @param int $remoteId
130
+     * @param int $parent
131
+     * @return Mount|null
132
+     * @throws \Doctrine\DBAL\DBALException
133
+     */
134
+    public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) {
135
+        $user = $user ? $user : $this->uid;
136
+        $accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
+        $name = Filesystem::normalizePath('/' . $name);
138
+
139
+        if ($accepted !== IShare::STATUS_ACCEPTED) {
140
+            // To avoid conflicts with the mount point generation later,
141
+            // we only use a temporary mount point name here. The real
142
+            // mount point name will be generated when accepting the share,
143
+            // using the original share item name.
144
+            $tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
145
+            $mountPoint = $tmpMountPointName;
146
+            $hash = md5($tmpMountPointName);
147
+            $data = [
148
+                'remote' => $remote,
149
+                'share_token' => $token,
150
+                'password' => $password,
151
+                'name' => $name,
152
+                'owner' => $owner,
153
+                'user' => $user,
154
+                'mountpoint' => $mountPoint,
155
+                'mountpoint_hash' => $hash,
156
+                'accepted' => $accepted,
157
+                'remote_id' => $remoteId,
158
+                'share_type' => $shareType,
159
+            ];
160
+
161
+            $i = 1;
162
+            while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163
+                // The external share already exists for the user
164
+                $data['mountpoint'] = $tmpMountPointName . '-' . $i;
165
+                $data['mountpoint_hash'] = md5($data['mountpoint']);
166
+                $i++;
167
+            }
168
+            return null;
169
+        }
170
+
171
+        $mountPoint = Files::buildNotExistingFileName('/', $name);
172
+        $mountPoint = Filesystem::normalizePath('/' . $mountPoint);
173
+        $hash = md5($mountPoint);
174
+
175
+        $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
176
+
177
+        $options = [
178
+            'remote' => $remote,
179
+            'token' => $token,
180
+            'password' => $password,
181
+            'mountpoint' => $mountPoint,
182
+            'owner' => $owner
183
+        ];
184
+        return $this->mountShare($options);
185
+    }
186
+
187
+    /**
188
+     * write remote share to the database
189
+     *
190
+     * @param $remote
191
+     * @param $token
192
+     * @param $password
193
+     * @param $name
194
+     * @param $owner
195
+     * @param $user
196
+     * @param $mountPoint
197
+     * @param $hash
198
+     * @param $accepted
199
+     * @param $remoteId
200
+     * @param $parent
201
+     * @param $shareType
202
+     * @return bool
203
+     */
204
+    private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) {
205
+        $query = $this->connection->prepare('
206 206
 				INSERT INTO `*PREFIX*share_external`
207 207
 					(`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`, `parent`, `share_type`)
208 208
 				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
209 209
 			');
210
-		return $query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]);
211
-	}
212
-
213
-	/**
214
-	 * get share
215
-	 *
216
-	 * @param int $id share id
217
-	 * @return mixed share of false
218
-	 */
219
-	public function getShare($id) {
220
-		$getShare = $this->connection->prepare('
210
+        return $query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]);
211
+    }
212
+
213
+    /**
214
+     * get share
215
+     *
216
+     * @param int $id share id
217
+     * @return mixed share of false
218
+     */
219
+    public function getShare($id) {
220
+        $getShare = $this->connection->prepare('
221 221
 			SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash`
222 222
 			FROM  `*PREFIX*share_external`
223 223
 			WHERE `id` = ?');
224
-		$result = $getShare->execute([$id]);
225
-
226
-		$share = $result ? $getShare->fetch() : [];
227
-
228
-		$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229
-
230
-		// check if the user is allowed to access it
231
-		if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232
-			return $share;
233
-		} elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
234
-			$user = $this->userManager->get($this->uid);
235
-			if ($this->groupManager->get($share['user'])->inGroup($user)) {
236
-				return $share;
237
-			}
238
-		}
239
-
240
-		return false;
241
-	}
242
-
243
-	/**
244
-	 * accept server-to-server share
245
-	 *
246
-	 * @param int $id
247
-	 * @return bool True if the share could be accepted, false otherwise
248
-	 */
249
-	public function acceptShare($id) {
250
-		$share = $this->getShare($id);
251
-		$result = false;
252
-
253
-		if ($share) {
254
-			\OC_Util::setupFS($this->uid);
255
-			$shareFolder = Helper::getShareFolder();
256
-			$mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']);
257
-			$mountPoint = Filesystem::normalizePath($mountPoint);
258
-			$hash = md5($mountPoint);
259
-			$userShareAccepted = false;
260
-
261
-			if ((int)$share['share_type'] === IShare::TYPE_USER) {
262
-				$acceptShare = $this->connection->prepare('
224
+        $result = $getShare->execute([$id]);
225
+
226
+        $share = $result ? $getShare->fetch() : [];
227
+
228
+        $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229
+
230
+        // check if the user is allowed to access it
231
+        if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232
+            return $share;
233
+        } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
234
+            $user = $this->userManager->get($this->uid);
235
+            if ($this->groupManager->get($share['user'])->inGroup($user)) {
236
+                return $share;
237
+            }
238
+        }
239
+
240
+        return false;
241
+    }
242
+
243
+    /**
244
+     * accept server-to-server share
245
+     *
246
+     * @param int $id
247
+     * @return bool True if the share could be accepted, false otherwise
248
+     */
249
+    public function acceptShare($id) {
250
+        $share = $this->getShare($id);
251
+        $result = false;
252
+
253
+        if ($share) {
254
+            \OC_Util::setupFS($this->uid);
255
+            $shareFolder = Helper::getShareFolder();
256
+            $mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']);
257
+            $mountPoint = Filesystem::normalizePath($mountPoint);
258
+            $hash = md5($mountPoint);
259
+            $userShareAccepted = false;
260
+
261
+            if ((int)$share['share_type'] === IShare::TYPE_USER) {
262
+                $acceptShare = $this->connection->prepare('
263 263
 				UPDATE `*PREFIX*share_external`
264 264
 				SET `accepted` = ?,
265 265
 					`mountpoint` = ?,
266 266
 					`mountpoint_hash` = ?
267 267
 				WHERE `id` = ? AND `user` = ?');
268
-				$userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]);
269
-			} else {
270
-				$result = $this->writeShareToDb(
271
-					$share['remote'],
272
-					$share['share_token'],
273
-					$share['password'],
274
-					$share['name'],
275
-					$share['owner'],
276
-					$this->uid,
277
-					$mountPoint, $hash, 1,
278
-					$share['remote_id'],
279
-					$id,
280
-					$share['share_type']);
281
-			}
282
-			if ($userShareAccepted === true) {
283
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
284
-				$event = new FederatedShareAddedEvent($share['remote']);
285
-				$this->eventDispatcher->dispatchTyped($event);
286
-				$result = true;
287
-			}
288
-		}
289
-
290
-		// Make sure the user has no notification for something that does not exist anymore.
291
-		$this->processNotification($id);
292
-
293
-		return $result;
294
-	}
295
-
296
-	/**
297
-	 * decline server-to-server share
298
-	 *
299
-	 * @param int $id
300
-	 * @return bool True if the share could be declined, false otherwise
301
-	 */
302
-	public function declineShare($id) {
303
-		$share = $this->getShare($id);
304
-		$result = false;
305
-
306
-		if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
307
-			$removeShare = $this->connection->prepare('
268
+                $userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]);
269
+            } else {
270
+                $result = $this->writeShareToDb(
271
+                    $share['remote'],
272
+                    $share['share_token'],
273
+                    $share['password'],
274
+                    $share['name'],
275
+                    $share['owner'],
276
+                    $this->uid,
277
+                    $mountPoint, $hash, 1,
278
+                    $share['remote_id'],
279
+                    $id,
280
+                    $share['share_type']);
281
+            }
282
+            if ($userShareAccepted === true) {
283
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
284
+                $event = new FederatedShareAddedEvent($share['remote']);
285
+                $this->eventDispatcher->dispatchTyped($event);
286
+                $result = true;
287
+            }
288
+        }
289
+
290
+        // Make sure the user has no notification for something that does not exist anymore.
291
+        $this->processNotification($id);
292
+
293
+        return $result;
294
+    }
295
+
296
+    /**
297
+     * decline server-to-server share
298
+     *
299
+     * @param int $id
300
+     * @return bool True if the share could be declined, false otherwise
301
+     */
302
+    public function declineShare($id) {
303
+        $share = $this->getShare($id);
304
+        $result = false;
305
+
306
+        if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
307
+            $removeShare = $this->connection->prepare('
308 308
 				DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
309
-			$removeShare->execute([$id, $this->uid]);
310
-			$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
311
-
312
-			$this->processNotification($id);
313
-			$result = true;
314
-		} elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
315
-			$result = $this->writeShareToDb(
316
-				$share['remote'],
317
-				$share['share_token'],
318
-				$share['password'],
319
-				$share['name'],
320
-				$share['owner'],
321
-				$this->uid,
322
-				$share['mountpoint'],
323
-				$share['mountpoint_hash'],
324
-				0,
325
-				$share['remote_id'],
326
-				$id,
327
-				$share['share_type']);
328
-			$this->processNotification($id);
329
-		}
330
-
331
-		return $result;
332
-	}
333
-
334
-	/**
335
-	 * @param int $remoteShare
336
-	 */
337
-	public function processNotification($remoteShare) {
338
-		$filter = $this->notificationManager->createNotification();
339
-		$filter->setApp('files_sharing')
340
-			->setUser($this->uid)
341
-			->setObject('remote_share', (int) $remoteShare);
342
-		$this->notificationManager->markProcessed($filter);
343
-	}
344
-
345
-	/**
346
-	 * inform remote server whether server-to-server share was accepted/declined
347
-	 *
348
-	 * @param string $remote
349
-	 * @param string $token
350
-	 * @param int $remoteId Share id on the remote host
351
-	 * @param string $feedback
352
-	 * @return boolean
353
-	 */
354
-	private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
355
-		$result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
356
-
357
-		if ($result === true) {
358
-			return true;
359
-		}
360
-
361
-		$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362
-		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363
-
364
-		$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
365
-		$fields = ['token' => $token];
366
-
367
-		$client = $this->clientService->newClient();
368
-
369
-		try {
370
-			$response = $client->post(
371
-				$url,
372
-				[
373
-					'body' => $fields,
374
-					'connect_timeout' => 10,
375
-				]
376
-			);
377
-		} catch (\Exception $e) {
378
-			return false;
379
-		}
380
-
381
-		$status = json_decode($response->getBody(), true);
382
-
383
-		return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
384
-	}
385
-
386
-	/**
387
-	 * try send accept message to ocm end-point
388
-	 *
389
-	 * @param string $remoteDomain
390
-	 * @param string $token
391
-	 * @param $remoteId id of the share
392
-	 * @param string $feedback
393
-	 * @return bool
394
-	 */
395
-	protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) {
396
-		switch ($feedback) {
397
-			case 'accept':
398
-				$notification = $this->cloudFederationFactory->getCloudFederationNotification();
399
-				$notification->setMessage(
400
-					'SHARE_ACCEPTED',
401
-					'file',
402
-					$remoteId,
403
-					[
404
-						'sharedSecret' => $token,
405
-						'message' => 'Recipient accept the share'
406
-					]
407
-
408
-				);
409
-				return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
410
-			case 'decline':
411
-				$notification = $this->cloudFederationFactory->getCloudFederationNotification();
412
-				$notification->setMessage(
413
-					'SHARE_DECLINED',
414
-					'file',
415
-					$remoteId,
416
-					[
417
-						'sharedSecret' => $token,
418
-						'message' => 'Recipient declined the share'
419
-					]
420
-
421
-				);
422
-				return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
423
-		}
424
-
425
-		return false;
426
-	}
427
-
428
-
429
-	/**
430
-	 * remove '/user/files' from the path and trailing slashes
431
-	 *
432
-	 * @param string $path
433
-	 * @return string
434
-	 */
435
-	protected function stripPath($path) {
436
-		$prefix = '/' . $this->uid . '/files';
437
-		return rtrim(substr($path, strlen($prefix)), '/');
438
-	}
439
-
440
-	public function getMount($data) {
441
-		$data['manager'] = $this;
442
-		$mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
443
-		$data['mountpoint'] = $mountPoint;
444
-		$data['certificateManager'] = \OC::$server->getCertificateManager();
445
-		return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
446
-	}
447
-
448
-	/**
449
-	 * @param array $data
450
-	 * @return Mount
451
-	 */
452
-	protected function mountShare($data) {
453
-		$mount = $this->getMount($data);
454
-		$this->mountManager->addMount($mount);
455
-		return $mount;
456
-	}
457
-
458
-	/**
459
-	 * @return \OC\Files\Mount\Manager
460
-	 */
461
-	public function getMountManager() {
462
-		return $this->mountManager;
463
-	}
464
-
465
-	/**
466
-	 * @param string $source
467
-	 * @param string $target
468
-	 * @return bool
469
-	 */
470
-	public function setMountPoint($source, $target) {
471
-		$source = $this->stripPath($source);
472
-		$target = $this->stripPath($target);
473
-		$sourceHash = md5($source);
474
-		$targetHash = md5($target);
475
-
476
-		$query = $this->connection->prepare('
309
+            $removeShare->execute([$id, $this->uid]);
310
+            $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
311
+
312
+            $this->processNotification($id);
313
+            $result = true;
314
+        } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
315
+            $result = $this->writeShareToDb(
316
+                $share['remote'],
317
+                $share['share_token'],
318
+                $share['password'],
319
+                $share['name'],
320
+                $share['owner'],
321
+                $this->uid,
322
+                $share['mountpoint'],
323
+                $share['mountpoint_hash'],
324
+                0,
325
+                $share['remote_id'],
326
+                $id,
327
+                $share['share_type']);
328
+            $this->processNotification($id);
329
+        }
330
+
331
+        return $result;
332
+    }
333
+
334
+    /**
335
+     * @param int $remoteShare
336
+     */
337
+    public function processNotification($remoteShare) {
338
+        $filter = $this->notificationManager->createNotification();
339
+        $filter->setApp('files_sharing')
340
+            ->setUser($this->uid)
341
+            ->setObject('remote_share', (int) $remoteShare);
342
+        $this->notificationManager->markProcessed($filter);
343
+    }
344
+
345
+    /**
346
+     * inform remote server whether server-to-server share was accepted/declined
347
+     *
348
+     * @param string $remote
349
+     * @param string $token
350
+     * @param int $remoteId Share id on the remote host
351
+     * @param string $feedback
352
+     * @return boolean
353
+     */
354
+    private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
355
+        $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
356
+
357
+        if ($result === true) {
358
+            return true;
359
+        }
360
+
361
+        $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362
+        $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363
+
364
+        $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
365
+        $fields = ['token' => $token];
366
+
367
+        $client = $this->clientService->newClient();
368
+
369
+        try {
370
+            $response = $client->post(
371
+                $url,
372
+                [
373
+                    'body' => $fields,
374
+                    'connect_timeout' => 10,
375
+                ]
376
+            );
377
+        } catch (\Exception $e) {
378
+            return false;
379
+        }
380
+
381
+        $status = json_decode($response->getBody(), true);
382
+
383
+        return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
384
+    }
385
+
386
+    /**
387
+     * try send accept message to ocm end-point
388
+     *
389
+     * @param string $remoteDomain
390
+     * @param string $token
391
+     * @param $remoteId id of the share
392
+     * @param string $feedback
393
+     * @return bool
394
+     */
395
+    protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) {
396
+        switch ($feedback) {
397
+            case 'accept':
398
+                $notification = $this->cloudFederationFactory->getCloudFederationNotification();
399
+                $notification->setMessage(
400
+                    'SHARE_ACCEPTED',
401
+                    'file',
402
+                    $remoteId,
403
+                    [
404
+                        'sharedSecret' => $token,
405
+                        'message' => 'Recipient accept the share'
406
+                    ]
407
+
408
+                );
409
+                return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
410
+            case 'decline':
411
+                $notification = $this->cloudFederationFactory->getCloudFederationNotification();
412
+                $notification->setMessage(
413
+                    'SHARE_DECLINED',
414
+                    'file',
415
+                    $remoteId,
416
+                    [
417
+                        'sharedSecret' => $token,
418
+                        'message' => 'Recipient declined the share'
419
+                    ]
420
+
421
+                );
422
+                return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
423
+        }
424
+
425
+        return false;
426
+    }
427
+
428
+
429
+    /**
430
+     * remove '/user/files' from the path and trailing slashes
431
+     *
432
+     * @param string $path
433
+     * @return string
434
+     */
435
+    protected function stripPath($path) {
436
+        $prefix = '/' . $this->uid . '/files';
437
+        return rtrim(substr($path, strlen($prefix)), '/');
438
+    }
439
+
440
+    public function getMount($data) {
441
+        $data['manager'] = $this;
442
+        $mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
443
+        $data['mountpoint'] = $mountPoint;
444
+        $data['certificateManager'] = \OC::$server->getCertificateManager();
445
+        return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
446
+    }
447
+
448
+    /**
449
+     * @param array $data
450
+     * @return Mount
451
+     */
452
+    protected function mountShare($data) {
453
+        $mount = $this->getMount($data);
454
+        $this->mountManager->addMount($mount);
455
+        return $mount;
456
+    }
457
+
458
+    /**
459
+     * @return \OC\Files\Mount\Manager
460
+     */
461
+    public function getMountManager() {
462
+        return $this->mountManager;
463
+    }
464
+
465
+    /**
466
+     * @param string $source
467
+     * @param string $target
468
+     * @return bool
469
+     */
470
+    public function setMountPoint($source, $target) {
471
+        $source = $this->stripPath($source);
472
+        $target = $this->stripPath($target);
473
+        $sourceHash = md5($source);
474
+        $targetHash = md5($target);
475
+
476
+        $query = $this->connection->prepare('
477 477
 			UPDATE `*PREFIX*share_external`
478 478
 			SET `mountpoint` = ?, `mountpoint_hash` = ?
479 479
 			WHERE `mountpoint_hash` = ?
480 480
 			AND `user` = ?
481 481
 		');
482
-		$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
482
+        $result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
483 483
 
484
-		return $result;
485
-	}
484
+        return $result;
485
+    }
486 486
 
487
-	public function removeShare($mountPoint) {
488
-		$mountPointObj = $this->mountManager->find($mountPoint);
489
-		$id = $mountPointObj->getStorage()->getCache()->getId('');
487
+    public function removeShare($mountPoint) {
488
+        $mountPointObj = $this->mountManager->find($mountPoint);
489
+        $id = $mountPointObj->getStorage()->getCache()->getId('');
490 490
 
491
-		$mountPoint = $this->stripPath($mountPoint);
492
-		$hash = md5($mountPoint);
491
+        $mountPoint = $this->stripPath($mountPoint);
492
+        $hash = md5($mountPoint);
493 493
 
494
-		$getShare = $this->connection->prepare('
494
+        $getShare = $this->connection->prepare('
495 495
 			SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id`
496 496
 			FROM  `*PREFIX*share_external`
497 497
 			WHERE `mountpoint_hash` = ? AND `user` = ?');
498
-		$result = $getShare->execute([$hash, $this->uid]);
499
-
500
-		$share = $getShare->fetch();
501
-		$getShare->closeCursor();
502
-		if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
503
-			try {
504
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505
-			} catch (\Throwable $e) {
506
-				// if we fail to notify the remote (probably cause the remote is down)
507
-				// we still want the share to be gone to prevent undeletable remotes
508
-			}
509
-
510
-			$query = $this->connection->prepare('
498
+        $result = $getShare->execute([$hash, $this->uid]);
499
+
500
+        $share = $getShare->fetch();
501
+        $getShare->closeCursor();
502
+        if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
503
+            try {
504
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505
+            } catch (\Throwable $e) {
506
+                // if we fail to notify the remote (probably cause the remote is down)
507
+                // we still want the share to be gone to prevent undeletable remotes
508
+            }
509
+
510
+            $query = $this->connection->prepare('
511 511
 			DELETE FROM `*PREFIX*share_external`
512 512
 			WHERE `id` = ?
513 513
 			');
514
-			$result = (bool)$query->execute([(int)$share['id']]);
515
-		} elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
516
-			$query = $this->connection->prepare('
514
+            $result = (bool)$query->execute([(int)$share['id']]);
515
+        } elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
516
+            $query = $this->connection->prepare('
517 517
 				UPDATE `*PREFIX*share_external`
518 518
 				SET `accepted` = ?
519 519
 				WHERE `id` = ?');
520
-			$result = (bool)$query->execute([0, (int)$share['id']]);
521
-		}
522
-
523
-		if ($result) {
524
-			$this->removeReShares($id);
525
-		}
526
-
527
-		return $result;
528
-	}
529
-
530
-	/**
531
-	 * remove re-shares from share table and mapping in the federated_reshares table
532
-	 *
533
-	 * @param $mountPointId
534
-	 */
535
-	protected function removeReShares($mountPointId) {
536
-		$selectQuery = $this->connection->getQueryBuilder();
537
-		$query = $this->connection->getQueryBuilder();
538
-		$selectQuery->select('id')->from('share')
539
-			->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId)));
540
-		$select = $selectQuery->getSQL();
541
-
542
-
543
-		$query->delete('federated_reshares')
544
-			->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
545
-		$query->execute();
546
-
547
-		$deleteReShares = $this->connection->getQueryBuilder();
548
-		$deleteReShares->delete('share')
549
-			->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId)));
550
-		$deleteReShares->execute();
551
-	}
552
-
553
-	/**
554
-	 * remove all shares for user $uid if the user was deleted
555
-	 *
556
-	 * @param string $uid
557
-	 * @return bool
558
-	 */
559
-	public function removeUserShares($uid) {
560
-		$getShare = $this->connection->prepare('
520
+            $result = (bool)$query->execute([0, (int)$share['id']]);
521
+        }
522
+
523
+        if ($result) {
524
+            $this->removeReShares($id);
525
+        }
526
+
527
+        return $result;
528
+    }
529
+
530
+    /**
531
+     * remove re-shares from share table and mapping in the federated_reshares table
532
+     *
533
+     * @param $mountPointId
534
+     */
535
+    protected function removeReShares($mountPointId) {
536
+        $selectQuery = $this->connection->getQueryBuilder();
537
+        $query = $this->connection->getQueryBuilder();
538
+        $selectQuery->select('id')->from('share')
539
+            ->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId)));
540
+        $select = $selectQuery->getSQL();
541
+
542
+
543
+        $query->delete('federated_reshares')
544
+            ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
545
+        $query->execute();
546
+
547
+        $deleteReShares = $this->connection->getQueryBuilder();
548
+        $deleteReShares->delete('share')
549
+            ->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId)));
550
+        $deleteReShares->execute();
551
+    }
552
+
553
+    /**
554
+     * remove all shares for user $uid if the user was deleted
555
+     *
556
+     * @param string $uid
557
+     * @return bool
558
+     */
559
+    public function removeUserShares($uid) {
560
+        $getShare = $this->connection->prepare('
561 561
 			SELECT `remote`, `share_token`, `remote_id`
562 562
 			FROM  `*PREFIX*share_external`
563 563
 			WHERE `user` = ?');
564
-		$result = $getShare->execute([$uid]);
564
+        $result = $getShare->execute([$uid]);
565 565
 
566
-		if ($result) {
567
-			$shares = $getShare->fetchAll();
568
-			foreach ($shares as $share) {
569
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
570
-			}
571
-		}
566
+        if ($result) {
567
+            $shares = $getShare->fetchAll();
568
+            foreach ($shares as $share) {
569
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
570
+            }
571
+        }
572 572
 
573
-		$query = $this->connection->prepare('
573
+        $query = $this->connection->prepare('
574 574
 			DELETE FROM `*PREFIX*share_external`
575 575
 			WHERE `user` = ?
576 576
 		');
577
-		return (bool)$query->execute([$uid]);
578
-	}
579
-
580
-	/**
581
-	 * return a list of shares which are not yet accepted by the user
582
-	 *
583
-	 * @return array list of open server-to-server shares
584
-	 */
585
-	public function getOpenShares() {
586
-		return $this->getShares(false);
587
-	}
588
-
589
-	/**
590
-	 * return a list of shares which are accepted by the user
591
-	 *
592
-	 * @return array list of accepted server-to-server shares
593
-	 */
594
-	public function getAcceptedShares() {
595
-		return $this->getShares(true);
596
-	}
597
-
598
-	/**
599
-	 * return a list of shares for the user
600
-	 *
601
-	 * @param bool|null $accepted True for accepted only,
602
-	 *                            false for not accepted,
603
-	 *                            null for all shares of the user
604
-	 * @return array list of open server-to-server shares
605
-	 */
606
-	private function getShares($accepted) {
607
-		$user = $this->userManager->get($this->uid);
608
-		$groups = $this->groupManager->getUserGroups($user);
609
-		$userGroups = [];
610
-		foreach ($groups as $group) {
611
-			$userGroups[] = $group->getGID();
612
-		}
613
-
614
-		$query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
577
+        return (bool)$query->execute([$uid]);
578
+    }
579
+
580
+    /**
581
+     * return a list of shares which are not yet accepted by the user
582
+     *
583
+     * @return array list of open server-to-server shares
584
+     */
585
+    public function getOpenShares() {
586
+        return $this->getShares(false);
587
+    }
588
+
589
+    /**
590
+     * return a list of shares which are accepted by the user
591
+     *
592
+     * @return array list of accepted server-to-server shares
593
+     */
594
+    public function getAcceptedShares() {
595
+        return $this->getShares(true);
596
+    }
597
+
598
+    /**
599
+     * return a list of shares for the user
600
+     *
601
+     * @param bool|null $accepted True for accepted only,
602
+     *                            false for not accepted,
603
+     *                            null for all shares of the user
604
+     * @return array list of open server-to-server shares
605
+     */
606
+    private function getShares($accepted) {
607
+        $user = $this->userManager->get($this->uid);
608
+        $groups = $this->groupManager->getUserGroups($user);
609
+        $userGroups = [];
610
+        foreach ($groups as $group) {
611
+            $userGroups[] = $group->getGID();
612
+        }
613
+
614
+        $query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
615 615
 		          FROM `*PREFIX*share_external`
616 616
 				  WHERE (`user` = ? OR `user` IN (?))';
617
-		$parameters = [$this->uid, implode(',',$userGroups)];
618
-		if (!is_null($accepted)) {
619
-			$query .= ' AND `accepted` = ?';
620
-			$parameters[] = (int) $accepted;
621
-		}
622
-		$query .= ' ORDER BY `id` ASC';
623
-
624
-		$shares = $this->connection->prepare($query);
625
-		$result = $shares->execute($parameters);
626
-
627
-		return $result ? $shares->fetchAll() : [];
628
-	}
617
+        $parameters = [$this->uid, implode(',',$userGroups)];
618
+        if (!is_null($accepted)) {
619
+            $query .= ' AND `accepted` = ?';
620
+            $parameters[] = (int) $accepted;
621
+        }
622
+        $query .= ' ORDER BY `id` ASC';
623
+
624
+        $shares = $this->connection->prepare($query);
625
+        $result = $shares->execute($parameters);
626
+
627
+        return $result ? $shares->fetchAll() : [];
628
+    }
629 629
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = -1, $parent = -1) {
135 135
 		$user = $user ? $user : $this->uid;
136 136
 		$accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
-		$name = Filesystem::normalizePath('/' . $name);
137
+		$name = Filesystem::normalizePath('/'.$name);
138 138
 
139 139
 		if ($accepted !== IShare::STATUS_ACCEPTED) {
140 140
 			// To avoid conflicts with the mount point generation later,
141 141
 			// we only use a temporary mount point name here. The real
142 142
 			// mount point name will be generated when accepting the share,
143 143
 			// using the original share item name.
144
-			$tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
144
+			$tmpMountPointName = '{{TemporaryMountPointName#'.$name.'}}';
145 145
 			$mountPoint = $tmpMountPointName;
146 146
 			$hash = md5($tmpMountPointName);
147 147
 			$data = [
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 			$i = 1;
162 162
 			while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163 163
 				// The external share already exists for the user
164
-				$data['mountpoint'] = $tmpMountPointName . '-' . $i;
164
+				$data['mountpoint'] = $tmpMountPointName.'-'.$i;
165 165
 				$data['mountpoint_hash'] = md5($data['mountpoint']);
166 166
 				$i++;
167 167
 			}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		}
170 170
 
171 171
 		$mountPoint = Files::buildNotExistingFileName('/', $name);
172
-		$mountPoint = Filesystem::normalizePath('/' . $mountPoint);
172
+		$mountPoint = Filesystem::normalizePath('/'.$mountPoint);
173 173
 		$hash = md5($mountPoint);
174 174
 
175 175
 		$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 		$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229 229
 
230 230
 		// check if the user is allowed to access it
231
-		if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
231
+		if ($validShare && (int) $share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232 232
 			return $share;
233
-		} elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
233
+		} elseif ($validShare && (int) $share['share_type'] === IShare::TYPE_GROUP) {
234 234
 			$user = $this->userManager->get($this->uid);
235 235
 			if ($this->groupManager->get($share['user'])->inGroup($user)) {
236 236
 				return $share;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			$hash = md5($mountPoint);
259 259
 			$userShareAccepted = false;
260 260
 
261
-			if ((int)$share['share_type'] === IShare::TYPE_USER) {
261
+			if ((int) $share['share_type'] === IShare::TYPE_USER) {
262 262
 				$acceptShare = $this->connection->prepare('
263 263
 				UPDATE `*PREFIX*share_external`
264 264
 				SET `accepted` = ?,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		$share = $this->getShare($id);
304 304
 		$result = false;
305 305
 
306
-		if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
306
+		if ($share && (int) $share['share_type'] === IShare::TYPE_USER) {
307 307
 			$removeShare = $this->connection->prepare('
308 308
 				DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
309 309
 			$removeShare->execute([$id, $this->uid]);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
 			$this->processNotification($id);
313 313
 			$result = true;
314
-		} elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
314
+		} elseif ($share && (int) $share['share_type'] === IShare::TYPE_GROUP) {
315 315
 			$result = $this->writeShareToDb(
316 316
 				$share['remote'],
317 317
 				$share['share_token'],
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362 362
 		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363 363
 
364
-		$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
364
+		$url = rtrim($remote, '/').$endpoint.'/'.$remoteId.'/'.$feedback.'?format='.Share::RESPONSE_FORMAT;
365 365
 		$fields = ['token' => $token];
366 366
 
367 367
 		$client = $this->clientService->newClient();
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 	 * @return string
434 434
 	 */
435 435
 	protected function stripPath($path) {
436
-		$prefix = '/' . $this->uid . '/files';
436
+		$prefix = '/'.$this->uid.'/files';
437 437
 		return rtrim(substr($path, strlen($prefix)), '/');
438 438
 	}
439 439
 
440 440
 	public function getMount($data) {
441 441
 		$data['manager'] = $this;
442
-		$mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
442
+		$mountPoint = '/'.$this->uid.'/files'.$data['mountpoint'];
443 443
 		$data['mountpoint'] = $mountPoint;
444 444
 		$data['certificateManager'] = \OC::$server->getCertificateManager();
445 445
 		return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			WHERE `mountpoint_hash` = ?
480 480
 			AND `user` = ?
481 481
 		');
482
-		$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
482
+		$result = (bool) $query->execute([$target, $targetHash, $sourceHash, $this->uid]);
483 483
 
484 484
 		return $result;
485 485
 	}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
 		$share = $getShare->fetch();
501 501
 		$getShare->closeCursor();
502
-		if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
502
+		if ($result && $share !== false && (int) $share['share_type'] === IShare::TYPE_USER) {
503 503
 			try {
504 504
 				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505 505
 			} catch (\Throwable $e) {
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 			DELETE FROM `*PREFIX*share_external`
512 512
 			WHERE `id` = ?
513 513
 			');
514
-			$result = (bool)$query->execute([(int)$share['id']]);
515
-		} elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
514
+			$result = (bool) $query->execute([(int) $share['id']]);
515
+		} elseif ($result && $share !== false && (int) $share['share_type'] === IShare::TYPE_GROUP) {
516 516
 			$query = $this->connection->prepare('
517 517
 				UPDATE `*PREFIX*share_external`
518 518
 				SET `accepted` = ?
519 519
 				WHERE `id` = ?');
520
-			$result = (bool)$query->execute([0, (int)$share['id']]);
520
+			$result = (bool) $query->execute([0, (int) $share['id']]);
521 521
 		}
522 522
 
523 523
 		if ($result) {
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
 
543 543
 		$query->delete('federated_reshares')
544
-			->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
544
+			->where($query->expr()->in('share_id', $query->createFunction('('.$select.')')));
545 545
 		$query->execute();
546 546
 
547 547
 		$deleteReShares = $this->connection->getQueryBuilder();
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 			DELETE FROM `*PREFIX*share_external`
575 575
 			WHERE `user` = ?
576 576
 		');
577
-		return (bool)$query->execute([$uid]);
577
+		return (bool) $query->execute([$uid]);
578 578
 	}
579 579
 
580 580
 	/**
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		$query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
615 615
 		          FROM `*PREFIX*share_external`
616 616
 				  WHERE (`user` = ? OR `user` IN (?))';
617
-		$parameters = [$this->uid, implode(',',$userGroups)];
617
+		$parameters = [$this->uid, implode(',', $userGroups)];
618 618
 		if (!is_null($accepted)) {
619 619
 			$query .= ' AND `accepted` = ?';
620 620
 			$parameters[] = (int) $accepted;
Please login to merge, or discard this patch.
apps/files_sharing/lib/External/MountProvider.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -31,59 +31,59 @@
 block discarded – undo
31 31
 use OCP\IUser;
32 32
 
33 33
 class MountProvider implements IMountProvider {
34
-	public const STORAGE = '\OCA\Files_Sharing\External\Storage';
34
+    public const STORAGE = '\OCA\Files_Sharing\External\Storage';
35 35
 
36
-	/**
37
-	 * @var \OCP\IDBConnection
38
-	 */
39
-	private $connection;
36
+    /**
37
+     * @var \OCP\IDBConnection
38
+     */
39
+    private $connection;
40 40
 
41
-	/**
42
-	 * @var callable
43
-	 */
44
-	private $managerProvider;
41
+    /**
42
+     * @var callable
43
+     */
44
+    private $managerProvider;
45 45
 
46
-	/**
47
-	 * @var ICloudIdManager
48
-	 */
49
-	private $cloudIdManager;
46
+    /**
47
+     * @var ICloudIdManager
48
+     */
49
+    private $cloudIdManager;
50 50
 
51
-	/**
52
-	 * @param \OCP\IDBConnection $connection
53
-	 * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
54
-	 * @param ICloudIdManager $cloudIdManager
55
-	 */
56
-	public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
57
-		$this->connection = $connection;
58
-		$this->managerProvider = $managerProvider;
59
-		$this->cloudIdManager = $cloudIdManager;
60
-	}
51
+    /**
52
+     * @param \OCP\IDBConnection $connection
53
+     * @param callable $managerProvider due to setup order we need a callable that return the manager instead of the manager itself
54
+     * @param ICloudIdManager $cloudIdManager
55
+     */
56
+    public function __construct(IDBConnection $connection, callable $managerProvider, ICloudIdManager $cloudIdManager) {
57
+        $this->connection = $connection;
58
+        $this->managerProvider = $managerProvider;
59
+        $this->cloudIdManager = $cloudIdManager;
60
+    }
61 61
 
62
-	public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
63
-		$managerProvider = $this->managerProvider;
64
-		$manager = $managerProvider();
65
-		$data['manager'] = $manager;
66
-		$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
67
-		$data['mountpoint'] = $mountPoint;
68
-		$data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
69
-		$data['certificateManager'] = \OC::$server->getCertificateManager();
70
-		$data['HttpClientService'] = \OC::$server->getHTTPClientService();
71
-		return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
72
-	}
62
+    public function getMount(IUser $user, $data, IStorageFactory $storageFactory) {
63
+        $managerProvider = $this->managerProvider;
64
+        $manager = $managerProvider();
65
+        $data['manager'] = $manager;
66
+        $mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
67
+        $data['mountpoint'] = $mountPoint;
68
+        $data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
69
+        $data['certificateManager'] = \OC::$server->getCertificateManager();
70
+        $data['HttpClientService'] = \OC::$server->getHTTPClientService();
71
+        return new Mount(self::STORAGE, $mountPoint, $data, $manager, $storageFactory);
72
+    }
73 73
 
74
-	public function getMountsForUser(IUser $user, IStorageFactory $loader) {
75
-		$query = $this->connection->prepare('
74
+    public function getMountsForUser(IUser $user, IStorageFactory $loader) {
75
+        $query = $this->connection->prepare('
76 76
 				SELECT `remote`, `share_token`, `password`, `mountpoint`, `owner`
77 77
 				FROM `*PREFIX*share_external`
78 78
 				WHERE `user` = ? AND `accepted` = ?
79 79
 			');
80
-		$query->execute([$user->getUID(), 1]);
81
-		$mounts = [];
82
-		while ($row = $query->fetch()) {
83
-			$row['manager'] = $this;
84
-			$row['token'] = $row['share_token'];
85
-			$mounts[] = $this->getMount($user, $row, $loader);
86
-		}
87
-		return $mounts;
88
-	}
80
+        $query->execute([$user->getUID(), 1]);
81
+        $mounts = [];
82
+        while ($row = $query->fetch()) {
83
+            $row['manager'] = $this;
84
+            $row['token'] = $row['share_token'];
85
+            $mounts[] = $this->getMount($user, $row, $loader);
86
+        }
87
+        return $mounts;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 		$managerProvider = $this->managerProvider;
64 64
 		$manager = $managerProvider();
65 65
 		$data['manager'] = $manager;
66
-		$mountPoint = '/' . $user->getUID() . '/files/' . ltrim($data['mountpoint'], '/');
66
+		$mountPoint = '/'.$user->getUID().'/files/'.ltrim($data['mountpoint'], '/');
67 67
 		$data['mountpoint'] = $mountPoint;
68 68
 		$data['cloudId'] = $this->cloudIdManager->getCloudId($data['owner'], $data['remote']);
69 69
 		$data['certificateManager'] = \OC::$server->getCertificateManager();
Please login to merge, or discard this patch.
apps/dav/lib/CardDAV/SyncService.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -42,300 +42,300 @@
 block discarded – undo
42 42
 
43 43
 class SyncService {
44 44
 
45
-	/** @var CardDavBackend */
46
-	private $backend;
47
-
48
-	/** @var IUserManager */
49
-	private $userManager;
50
-
51
-	/** @var ILogger */
52
-	private $logger;
53
-
54
-	/** @var array */
55
-	private $localSystemAddressBook;
56
-
57
-	/** @var AccountManager */
58
-	private $accountManager;
59
-
60
-	/** @var string */
61
-	protected $certPath;
62
-
63
-	/**
64
-	 * SyncService constructor.
65
-	 *
66
-	 * @param CardDavBackend $backend
67
-	 * @param IUserManager $userManager
68
-	 * @param ILogger $logger
69
-	 * @param AccountManager $accountManager
70
-	 */
71
-	public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) {
72
-		$this->backend = $backend;
73
-		$this->userManager = $userManager;
74
-		$this->logger = $logger;
75
-		$this->accountManager = $accountManager;
76
-		$this->certPath = '';
77
-	}
78
-
79
-	/**
80
-	 * @param string $url
81
-	 * @param string $userName
82
-	 * @param string $addressBookUrl
83
-	 * @param string $sharedSecret
84
-	 * @param string $syncToken
85
-	 * @param int $targetBookId
86
-	 * @param string $targetPrincipal
87
-	 * @param array $targetProperties
88
-	 * @return string
89
-	 * @throws \Exception
90
-	 */
91
-	public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
92
-		// 1. create addressbook
93
-		$book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
94
-		$addressBookId = $book['id'];
95
-
96
-		// 2. query changes
97
-		try {
98
-			$response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken);
99
-		} catch (ClientHttpException $ex) {
100
-			if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
101
-				// remote server revoked access to the address book, remove it
102
-				$this->backend->deleteAddressBook($addressBookId);
103
-				$this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']);
104
-				throw $ex;
105
-			}
106
-		}
107
-
108
-		// 3. apply changes
109
-		// TODO: use multi-get for download
110
-		foreach ($response['response'] as $resource => $status) {
111
-			$cardUri = basename($resource);
112
-			if (isset($status[200])) {
113
-				$vCard = $this->download($url, $userName, $sharedSecret, $resource);
114
-				$existingCard = $this->backend->getCard($addressBookId, $cardUri);
115
-				if ($existingCard === false) {
116
-					$this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
117
-				} else {
118
-					$this->backend->updateCard($addressBookId, $cardUri, $vCard['body']);
119
-				}
120
-			} else {
121
-				$this->backend->deleteCard($addressBookId, $cardUri);
122
-			}
123
-		}
124
-
125
-		return $response['token'];
126
-	}
127
-
128
-	/**
129
-	 * @param string $principal
130
-	 * @param string $id
131
-	 * @param array $properties
132
-	 * @return array|null
133
-	 * @throws \Sabre\DAV\Exception\BadRequest
134
-	 */
135
-	public function ensureSystemAddressBookExists($principal, $id, $properties) {
136
-		$book = $this->backend->getAddressBooksByUri($principal, $id);
137
-		if (!is_null($book)) {
138
-			return $book;
139
-		}
140
-		$this->backend->createAddressBook($principal, $id, $properties);
141
-
142
-		return $this->backend->getAddressBooksByUri($principal, $id);
143
-	}
144
-
145
-	/**
146
-	 * Check if there is a valid certPath we should use
147
-	 *
148
-	 * @return string
149
-	 */
150
-	protected function getCertPath() {
151
-
152
-		// we already have a valid certPath
153
-		if ($this->certPath !== '') {
154
-			return $this->certPath;
155
-		}
156
-
157
-		$certManager = \OC::$server->getCertificateManager();
158
-		$certPath = $certManager->getAbsoluteBundlePath();
159
-		if (file_exists($certPath)) {
160
-			$this->certPath = $certPath;
161
-		}
162
-
163
-		return $this->certPath;
164
-	}
165
-
166
-	/**
167
-	 * @param string $url
168
-	 * @param string $userName
169
-	 * @param string $addressBookUrl
170
-	 * @param string $sharedSecret
171
-	 * @return Client
172
-	 */
173
-	protected function getClient($url, $userName, $sharedSecret) {
174
-		$settings = [
175
-			'baseUri' => $url . '/',
176
-			'userName' => $userName,
177
-			'password' => $sharedSecret,
178
-		];
179
-		$client = new Client($settings);
180
-		$certPath = $this->getCertPath();
181
-		$client->setThrowExceptions(true);
182
-
183
-		if ($certPath !== '' && strpos($url, 'http://') !== 0) {
184
-			$client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
185
-		}
186
-
187
-		return $client;
188
-	}
189
-
190
-	/**
191
-	 * @param string $url
192
-	 * @param string $userName
193
-	 * @param string $addressBookUrl
194
-	 * @param string $sharedSecret
195
-	 * @param string $syncToken
196
-	 * @return array
197
-	 */
198
-	protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
199
-		$client = $this->getClient($url, $userName, $sharedSecret);
200
-
201
-		$body = $this->buildSyncCollectionRequestBody($syncToken);
202
-
203
-		$response = $client->request('REPORT', $addressBookUrl, $body, [
204
-			'Content-Type' => 'application/xml'
205
-		]);
206
-
207
-		return $this->parseMultiStatus($response['body']);
208
-	}
209
-
210
-	/**
211
-	 * @param string $url
212
-	 * @param string $userName
213
-	 * @param string $sharedSecret
214
-	 * @param string $resourcePath
215
-	 * @return array
216
-	 */
217
-	protected function download($url, $userName, $sharedSecret, $resourcePath) {
218
-		$client = $this->getClient($url, $userName, $sharedSecret);
219
-		return $client->request('GET', $resourcePath);
220
-	}
221
-
222
-	/**
223
-	 * @param string|null $syncToken
224
-	 * @return string
225
-	 */
226
-	private function buildSyncCollectionRequestBody($syncToken) {
227
-		$dom = new \DOMDocument('1.0', 'UTF-8');
228
-		$dom->formatOutput = true;
229
-		$root = $dom->createElementNS('DAV:', 'd:sync-collection');
230
-		$sync = $dom->createElement('d:sync-token', $syncToken);
231
-		$prop = $dom->createElement('d:prop');
232
-		$cont = $dom->createElement('d:getcontenttype');
233
-		$etag = $dom->createElement('d:getetag');
234
-
235
-		$prop->appendChild($cont);
236
-		$prop->appendChild($etag);
237
-		$root->appendChild($sync);
238
-		$root->appendChild($prop);
239
-		$dom->appendChild($root);
240
-		return $dom->saveXML();
241
-	}
242
-
243
-	/**
244
-	 * @param string $body
245
-	 * @return array
246
-	 * @throws \Sabre\Xml\ParseException
247
-	 */
248
-	private function parseMultiStatus($body) {
249
-		$xml = new Service();
250
-
251
-		/** @var MultiStatus $multiStatus */
252
-		$multiStatus = $xml->expect('{DAV:}multistatus', $body);
253
-
254
-		$result = [];
255
-		foreach ($multiStatus->getResponses() as $response) {
256
-			$result[$response->getHref()] = $response->getResponseProperties();
257
-		}
258
-
259
-		return ['response' => $result, 'token' => $multiStatus->getSyncToken()];
260
-	}
261
-
262
-	/**
263
-	 * @param IUser $user
264
-	 */
265
-	public function updateUser(IUser $user) {
266
-		$systemAddressBook = $this->getLocalSystemAddressBook();
267
-		$addressBookId = $systemAddressBook['id'];
268
-		$converter = new Converter($this->accountManager);
269
-		$name = $user->getBackendClassName();
270
-		$userId = $user->getUID();
271
-
272
-		$cardId = "$name:$userId.vcf";
273
-		$card = $this->backend->getCard($addressBookId, $cardId);
274
-		if ($user->isEnabled()) {
275
-			if ($card === false) {
276
-				$vCard = $converter->createCardFromUser($user);
277
-				if ($vCard !== null) {
278
-					$this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
279
-				}
280
-			} else {
281
-				$vCard = $converter->createCardFromUser($user);
282
-				if (is_null($vCard)) {
283
-					$this->backend->deleteCard($addressBookId, $cardId);
284
-				} else {
285
-					$this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
286
-				}
287
-			}
288
-		} else {
289
-			$this->backend->deleteCard($addressBookId, $cardId);
290
-		}
291
-	}
292
-
293
-	/**
294
-	 * @param IUser|string $userOrCardId
295
-	 */
296
-	public function deleteUser($userOrCardId) {
297
-		$systemAddressBook = $this->getLocalSystemAddressBook();
298
-		if ($userOrCardId instanceof IUser) {
299
-			$name = $userOrCardId->getBackendClassName();
300
-			$userId = $userOrCardId->getUID();
301
-
302
-			$userOrCardId = "$name:$userId.vcf";
303
-		}
304
-		$this->backend->deleteCard($systemAddressBook['id'], $userOrCardId);
305
-	}
306
-
307
-	/**
308
-	 * @return array|null
309
-	 */
310
-	public function getLocalSystemAddressBook() {
311
-		if (is_null($this->localSystemAddressBook)) {
312
-			$systemPrincipal = "principals/system/system";
313
-			$this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [
314
-				'{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
315
-			]);
316
-		}
317
-
318
-		return $this->localSystemAddressBook;
319
-	}
320
-
321
-	public function syncInstance(\Closure $progressCallback = null) {
322
-		$systemAddressBook = $this->getLocalSystemAddressBook();
323
-		$this->userManager->callForAllUsers(function ($user) use ($systemAddressBook, $progressCallback) {
324
-			$this->updateUser($user);
325
-			if (!is_null($progressCallback)) {
326
-				$progressCallback();
327
-			}
328
-		});
329
-
330
-		// remove no longer existing
331
-		$allCards = $this->backend->getCards($systemAddressBook['id']);
332
-		foreach ($allCards as $card) {
333
-			$vCard = Reader::read($card['carddata']);
334
-			$uid = $vCard->UID->getValue();
335
-			// load backend and see if user exists
336
-			if (!$this->userManager->userExists($uid)) {
337
-				$this->deleteUser($card['uri']);
338
-			}
339
-		}
340
-	}
45
+    /** @var CardDavBackend */
46
+    private $backend;
47
+
48
+    /** @var IUserManager */
49
+    private $userManager;
50
+
51
+    /** @var ILogger */
52
+    private $logger;
53
+
54
+    /** @var array */
55
+    private $localSystemAddressBook;
56
+
57
+    /** @var AccountManager */
58
+    private $accountManager;
59
+
60
+    /** @var string */
61
+    protected $certPath;
62
+
63
+    /**
64
+     * SyncService constructor.
65
+     *
66
+     * @param CardDavBackend $backend
67
+     * @param IUserManager $userManager
68
+     * @param ILogger $logger
69
+     * @param AccountManager $accountManager
70
+     */
71
+    public function __construct(CardDavBackend $backend, IUserManager $userManager, ILogger $logger, AccountManager $accountManager) {
72
+        $this->backend = $backend;
73
+        $this->userManager = $userManager;
74
+        $this->logger = $logger;
75
+        $this->accountManager = $accountManager;
76
+        $this->certPath = '';
77
+    }
78
+
79
+    /**
80
+     * @param string $url
81
+     * @param string $userName
82
+     * @param string $addressBookUrl
83
+     * @param string $sharedSecret
84
+     * @param string $syncToken
85
+     * @param int $targetBookId
86
+     * @param string $targetPrincipal
87
+     * @param array $targetProperties
88
+     * @return string
89
+     * @throws \Exception
90
+     */
91
+    public function syncRemoteAddressBook($url, $userName, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties) {
92
+        // 1. create addressbook
93
+        $book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
94
+        $addressBookId = $book['id'];
95
+
96
+        // 2. query changes
97
+        try {
98
+            $response = $this->requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken);
99
+        } catch (ClientHttpException $ex) {
100
+            if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
101
+                // remote server revoked access to the address book, remove it
102
+                $this->backend->deleteAddressBook($addressBookId);
103
+                $this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']);
104
+                throw $ex;
105
+            }
106
+        }
107
+
108
+        // 3. apply changes
109
+        // TODO: use multi-get for download
110
+        foreach ($response['response'] as $resource => $status) {
111
+            $cardUri = basename($resource);
112
+            if (isset($status[200])) {
113
+                $vCard = $this->download($url, $userName, $sharedSecret, $resource);
114
+                $existingCard = $this->backend->getCard($addressBookId, $cardUri);
115
+                if ($existingCard === false) {
116
+                    $this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
117
+                } else {
118
+                    $this->backend->updateCard($addressBookId, $cardUri, $vCard['body']);
119
+                }
120
+            } else {
121
+                $this->backend->deleteCard($addressBookId, $cardUri);
122
+            }
123
+        }
124
+
125
+        return $response['token'];
126
+    }
127
+
128
+    /**
129
+     * @param string $principal
130
+     * @param string $id
131
+     * @param array $properties
132
+     * @return array|null
133
+     * @throws \Sabre\DAV\Exception\BadRequest
134
+     */
135
+    public function ensureSystemAddressBookExists($principal, $id, $properties) {
136
+        $book = $this->backend->getAddressBooksByUri($principal, $id);
137
+        if (!is_null($book)) {
138
+            return $book;
139
+        }
140
+        $this->backend->createAddressBook($principal, $id, $properties);
141
+
142
+        return $this->backend->getAddressBooksByUri($principal, $id);
143
+    }
144
+
145
+    /**
146
+     * Check if there is a valid certPath we should use
147
+     *
148
+     * @return string
149
+     */
150
+    protected function getCertPath() {
151
+
152
+        // we already have a valid certPath
153
+        if ($this->certPath !== '') {
154
+            return $this->certPath;
155
+        }
156
+
157
+        $certManager = \OC::$server->getCertificateManager();
158
+        $certPath = $certManager->getAbsoluteBundlePath();
159
+        if (file_exists($certPath)) {
160
+            $this->certPath = $certPath;
161
+        }
162
+
163
+        return $this->certPath;
164
+    }
165
+
166
+    /**
167
+     * @param string $url
168
+     * @param string $userName
169
+     * @param string $addressBookUrl
170
+     * @param string $sharedSecret
171
+     * @return Client
172
+     */
173
+    protected function getClient($url, $userName, $sharedSecret) {
174
+        $settings = [
175
+            'baseUri' => $url . '/',
176
+            'userName' => $userName,
177
+            'password' => $sharedSecret,
178
+        ];
179
+        $client = new Client($settings);
180
+        $certPath = $this->getCertPath();
181
+        $client->setThrowExceptions(true);
182
+
183
+        if ($certPath !== '' && strpos($url, 'http://') !== 0) {
184
+            $client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
185
+        }
186
+
187
+        return $client;
188
+    }
189
+
190
+    /**
191
+     * @param string $url
192
+     * @param string $userName
193
+     * @param string $addressBookUrl
194
+     * @param string $sharedSecret
195
+     * @param string $syncToken
196
+     * @return array
197
+     */
198
+    protected function requestSyncReport($url, $userName, $addressBookUrl, $sharedSecret, $syncToken) {
199
+        $client = $this->getClient($url, $userName, $sharedSecret);
200
+
201
+        $body = $this->buildSyncCollectionRequestBody($syncToken);
202
+
203
+        $response = $client->request('REPORT', $addressBookUrl, $body, [
204
+            'Content-Type' => 'application/xml'
205
+        ]);
206
+
207
+        return $this->parseMultiStatus($response['body']);
208
+    }
209
+
210
+    /**
211
+     * @param string $url
212
+     * @param string $userName
213
+     * @param string $sharedSecret
214
+     * @param string $resourcePath
215
+     * @return array
216
+     */
217
+    protected function download($url, $userName, $sharedSecret, $resourcePath) {
218
+        $client = $this->getClient($url, $userName, $sharedSecret);
219
+        return $client->request('GET', $resourcePath);
220
+    }
221
+
222
+    /**
223
+     * @param string|null $syncToken
224
+     * @return string
225
+     */
226
+    private function buildSyncCollectionRequestBody($syncToken) {
227
+        $dom = new \DOMDocument('1.0', 'UTF-8');
228
+        $dom->formatOutput = true;
229
+        $root = $dom->createElementNS('DAV:', 'd:sync-collection');
230
+        $sync = $dom->createElement('d:sync-token', $syncToken);
231
+        $prop = $dom->createElement('d:prop');
232
+        $cont = $dom->createElement('d:getcontenttype');
233
+        $etag = $dom->createElement('d:getetag');
234
+
235
+        $prop->appendChild($cont);
236
+        $prop->appendChild($etag);
237
+        $root->appendChild($sync);
238
+        $root->appendChild($prop);
239
+        $dom->appendChild($root);
240
+        return $dom->saveXML();
241
+    }
242
+
243
+    /**
244
+     * @param string $body
245
+     * @return array
246
+     * @throws \Sabre\Xml\ParseException
247
+     */
248
+    private function parseMultiStatus($body) {
249
+        $xml = new Service();
250
+
251
+        /** @var MultiStatus $multiStatus */
252
+        $multiStatus = $xml->expect('{DAV:}multistatus', $body);
253
+
254
+        $result = [];
255
+        foreach ($multiStatus->getResponses() as $response) {
256
+            $result[$response->getHref()] = $response->getResponseProperties();
257
+        }
258
+
259
+        return ['response' => $result, 'token' => $multiStatus->getSyncToken()];
260
+    }
261
+
262
+    /**
263
+     * @param IUser $user
264
+     */
265
+    public function updateUser(IUser $user) {
266
+        $systemAddressBook = $this->getLocalSystemAddressBook();
267
+        $addressBookId = $systemAddressBook['id'];
268
+        $converter = new Converter($this->accountManager);
269
+        $name = $user->getBackendClassName();
270
+        $userId = $user->getUID();
271
+
272
+        $cardId = "$name:$userId.vcf";
273
+        $card = $this->backend->getCard($addressBookId, $cardId);
274
+        if ($user->isEnabled()) {
275
+            if ($card === false) {
276
+                $vCard = $converter->createCardFromUser($user);
277
+                if ($vCard !== null) {
278
+                    $this->backend->createCard($addressBookId, $cardId, $vCard->serialize());
279
+                }
280
+            } else {
281
+                $vCard = $converter->createCardFromUser($user);
282
+                if (is_null($vCard)) {
283
+                    $this->backend->deleteCard($addressBookId, $cardId);
284
+                } else {
285
+                    $this->backend->updateCard($addressBookId, $cardId, $vCard->serialize());
286
+                }
287
+            }
288
+        } else {
289
+            $this->backend->deleteCard($addressBookId, $cardId);
290
+        }
291
+    }
292
+
293
+    /**
294
+     * @param IUser|string $userOrCardId
295
+     */
296
+    public function deleteUser($userOrCardId) {
297
+        $systemAddressBook = $this->getLocalSystemAddressBook();
298
+        if ($userOrCardId instanceof IUser) {
299
+            $name = $userOrCardId->getBackendClassName();
300
+            $userId = $userOrCardId->getUID();
301
+
302
+            $userOrCardId = "$name:$userId.vcf";
303
+        }
304
+        $this->backend->deleteCard($systemAddressBook['id'], $userOrCardId);
305
+    }
306
+
307
+    /**
308
+     * @return array|null
309
+     */
310
+    public function getLocalSystemAddressBook() {
311
+        if (is_null($this->localSystemAddressBook)) {
312
+            $systemPrincipal = "principals/system/system";
313
+            $this->localSystemAddressBook = $this->ensureSystemAddressBookExists($systemPrincipal, 'system', [
314
+                '{' . Plugin::NS_CARDDAV . '}addressbook-description' => 'System addressbook which holds all users of this instance'
315
+            ]);
316
+        }
317
+
318
+        return $this->localSystemAddressBook;
319
+    }
320
+
321
+    public function syncInstance(\Closure $progressCallback = null) {
322
+        $systemAddressBook = $this->getLocalSystemAddressBook();
323
+        $this->userManager->callForAllUsers(function ($user) use ($systemAddressBook, $progressCallback) {
324
+            $this->updateUser($user);
325
+            if (!is_null($progressCallback)) {
326
+                $progressCallback();
327
+            }
328
+        });
329
+
330
+        // remove no longer existing
331
+        $allCards = $this->backend->getCards($systemAddressBook['id']);
332
+        foreach ($allCards as $card) {
333
+            $vCard = Reader::read($card['carddata']);
334
+            $uid = $vCard->UID->getValue();
335
+            // load backend and see if user exists
336
+            if (!$this->userManager->userExists($uid)) {
337
+                $this->deleteUser($card['uri']);
338
+            }
339
+        }
340
+    }
341 341
 }
Please login to merge, or discard this patch.
apps/settings/lib/AppInfo/Application.php 2 patches
Indentation   +162 added lines, -162 removed lines patch added patch discarded remove patch
@@ -66,166 +66,166 @@
 block discarded – undo
66 66
 use Symfony\Component\EventDispatcher\GenericEvent;
67 67
 
68 68
 class Application extends App implements IBootstrap {
69
-	public const APP_ID = 'settings';
70
-
71
-	/**
72
-	 * @param array $urlParams
73
-	 */
74
-	public function __construct(array $urlParams = []) {
75
-		parent::__construct(self::APP_ID, $urlParams);
76
-	}
77
-
78
-	public function register(IRegistrationContext $context): void {
79
-		// Register Middleware
80
-		$context->registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class);
81
-		$context->registerMiddleware(SubadminMiddleware::class);
82
-		$context->registerSearchProvider(SectionSearch::class);
83
-		$context->registerSearchProvider(AppSearch::class);
84
-
85
-		/**
86
-		 * Core class wrappers
87
-		 */
88
-		/** FIXME: Remove once OC_User is non-static and mockable */
89
-		$context->registerService('isAdmin', function () {
90
-			return \OC_User::isAdminUser(\OC_User::getUser());
91
-		});
92
-		/** FIXME: Remove once OC_SubAdmin is non-static and mockable */
93
-		$context->registerService('isSubAdmin', function () {
94
-			$userObject = \OC::$server->getUserSession()->getUser();
95
-			$isSubAdmin = false;
96
-			if ($userObject !== null) {
97
-				$isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
98
-			}
99
-			return $isSubAdmin;
100
-		});
101
-		$context->registerService(IProvider::class, function (IAppContainer $appContainer) {
102
-			/** @var IServerContainer $serverContainer */
103
-			$serverContainer = $appContainer->query(IServerContainer::class);
104
-			return $serverContainer->query(IProvider::class);
105
-		});
106
-		$context->registerService(IManager::class, function (IAppContainer $appContainer) {
107
-			/** @var IServerContainer $serverContainer */
108
-			$serverContainer = $appContainer->query(IServerContainer::class);
109
-			return $serverContainer->getSettingsManager();
110
-		});
111
-
112
-		$context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) {
113
-			/** @var Server $server */
114
-			$server = $appContainer->query(IServerContainer::class);
115
-			/** @var Defaults $defaults */
116
-			$defaults = $server->query(Defaults::class);
117
-
118
-			return new NewUserMailHelper(
119
-				$defaults,
120
-				$server->getURLGenerator(),
121
-				$server->getL10NFactory(),
122
-				$server->getMailer(),
123
-				$server->getSecureRandom(),
124
-				new TimeFactory(),
125
-				$server->getConfig(),
126
-				$server->getCrypto(),
127
-				Util::getDefaultEmailAddress('no-reply')
128
-			);
129
-		});
130
-	}
131
-
132
-	public function boot(IBootContext $context): void {
133
-		$context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) {
134
-			$dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) {
135
-				if (($token = $event->getSubject()) instanceof IToken) {
136
-					/** @var IActivityManager $activityManager */
137
-					$activityManager = $appContainer->get(IActivityManager::class);
138
-					/** @var ILogger $logger */
139
-					$logger = $appContainer->get(ILogger::class);
140
-
141
-					$activity = $activityManager->generateEvent();
142
-					$activity->setApp('settings')
143
-						->setType('security')
144
-						->setAffectedUser($token->getUID())
145
-						->setAuthor($token->getUID())
146
-						->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()])
147
-						->setObject('app_token', $token->getId());
148
-
149
-					try {
150
-						$activityManager->publish($activity);
151
-					} catch (BadMethodCallException $e) {
152
-						$logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]);
153
-					}
154
-				}
155
-			});
156
-		});
157
-
158
-		Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
159
-		Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');
160
-
161
-		$context->injectFn(function (IGroupManager $groupManager) {
162
-			/** @var IGroupManager|Manager $groupManager */
163
-			$groupManager->listen('\OC\Group', 'postRemoveUser',  [$this, 'removeUserFromGroup']);
164
-			$groupManager->listen('\OC\Group', 'postAddUser',  [$this, 'addUserToGroup']);
165
-		});
166
-
167
-		Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
168
-	}
169
-
170
-	public function addUserToGroup(IGroup $group, IUser $user): void {
171
-		/** @var Hooks $hooks */
172
-		$hooks = $this->getContainer()->query(Hooks::class);
173
-		$hooks->addUserToGroup($group, $user);
174
-	}
175
-
176
-	public function removeUserFromGroup(IGroup $group, IUser $user): void {
177
-		/** @var Hooks $hooks */
178
-		$hooks = $this->getContainer()->query(Hooks::class);
179
-		$hooks->removeUserFromGroup($group, $user);
180
-	}
181
-
182
-
183
-	/**
184
-	 * @param array $parameters
185
-	 * @throws \InvalidArgumentException
186
-	 * @throws \BadMethodCallException
187
-	 * @throws \Exception
188
-	 * @throws \OCP\AppFramework\QueryException
189
-	 */
190
-	public function onChangePassword(array $parameters) {
191
-		/** @var Hooks $hooks */
192
-		$hooks = $this->getContainer()->query(Hooks::class);
193
-		$hooks->onChangePassword($parameters['uid']);
194
-	}
195
-
196
-	/**
197
-	 * @param array $parameters
198
-	 * @throws \InvalidArgumentException
199
-	 * @throws \BadMethodCallException
200
-	 * @throws \Exception
201
-	 * @throws \OCP\AppFramework\QueryException
202
-	 */
203
-	public function onChangeInfo(array $parameters) {
204
-		if ($parameters['feature'] !== 'eMailAddress') {
205
-			return;
206
-		}
207
-
208
-		/** @var Hooks $hooks */
209
-		$hooks = $this->getContainer()->query(Hooks::class);
210
-		$hooks->onChangeEmail($parameters['user'], $parameters['old_value']);
211
-	}
212
-
213
-	/**
214
-	 * @param array $settings
215
-	 */
216
-	public function extendJsConfig(array $settings) {
217
-		$appConfig = json_decode($settings['array']['oc_appconfig'], true);
218
-
219
-		$publicWebFinger = \OC::$server->getConfig()->getAppValue('core', 'public_webfinger', '');
220
-		if (!empty($publicWebFinger)) {
221
-			$appConfig['core']['public_webfinger'] = $publicWebFinger;
222
-		}
223
-
224
-		$publicNodeInfo = \OC::$server->getConfig()->getAppValue('core', 'public_nodeinfo', '');
225
-		if (!empty($publicNodeInfo)) {
226
-			$appConfig['core']['public_nodeinfo'] = $publicNodeInfo;
227
-		}
228
-
229
-		$settings['array']['oc_appconfig'] = json_encode($appConfig);
230
-	}
69
+    public const APP_ID = 'settings';
70
+
71
+    /**
72
+     * @param array $urlParams
73
+     */
74
+    public function __construct(array $urlParams = []) {
75
+        parent::__construct(self::APP_ID, $urlParams);
76
+    }
77
+
78
+    public function register(IRegistrationContext $context): void {
79
+        // Register Middleware
80
+        $context->registerServiceAlias('SubadminMiddleware', SubadminMiddleware::class);
81
+        $context->registerMiddleware(SubadminMiddleware::class);
82
+        $context->registerSearchProvider(SectionSearch::class);
83
+        $context->registerSearchProvider(AppSearch::class);
84
+
85
+        /**
86
+         * Core class wrappers
87
+         */
88
+        /** FIXME: Remove once OC_User is non-static and mockable */
89
+        $context->registerService('isAdmin', function () {
90
+            return \OC_User::isAdminUser(\OC_User::getUser());
91
+        });
92
+        /** FIXME: Remove once OC_SubAdmin is non-static and mockable */
93
+        $context->registerService('isSubAdmin', function () {
94
+            $userObject = \OC::$server->getUserSession()->getUser();
95
+            $isSubAdmin = false;
96
+            if ($userObject !== null) {
97
+                $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject);
98
+            }
99
+            return $isSubAdmin;
100
+        });
101
+        $context->registerService(IProvider::class, function (IAppContainer $appContainer) {
102
+            /** @var IServerContainer $serverContainer */
103
+            $serverContainer = $appContainer->query(IServerContainer::class);
104
+            return $serverContainer->query(IProvider::class);
105
+        });
106
+        $context->registerService(IManager::class, function (IAppContainer $appContainer) {
107
+            /** @var IServerContainer $serverContainer */
108
+            $serverContainer = $appContainer->query(IServerContainer::class);
109
+            return $serverContainer->getSettingsManager();
110
+        });
111
+
112
+        $context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) {
113
+            /** @var Server $server */
114
+            $server = $appContainer->query(IServerContainer::class);
115
+            /** @var Defaults $defaults */
116
+            $defaults = $server->query(Defaults::class);
117
+
118
+            return new NewUserMailHelper(
119
+                $defaults,
120
+                $server->getURLGenerator(),
121
+                $server->getL10NFactory(),
122
+                $server->getMailer(),
123
+                $server->getSecureRandom(),
124
+                new TimeFactory(),
125
+                $server->getConfig(),
126
+                $server->getCrypto(),
127
+                Util::getDefaultEmailAddress('no-reply')
128
+            );
129
+        });
130
+    }
131
+
132
+    public function boot(IBootContext $context): void {
133
+        $context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) {
134
+            $dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) {
135
+                if (($token = $event->getSubject()) instanceof IToken) {
136
+                    /** @var IActivityManager $activityManager */
137
+                    $activityManager = $appContainer->get(IActivityManager::class);
138
+                    /** @var ILogger $logger */
139
+                    $logger = $appContainer->get(ILogger::class);
140
+
141
+                    $activity = $activityManager->generateEvent();
142
+                    $activity->setApp('settings')
143
+                        ->setType('security')
144
+                        ->setAffectedUser($token->getUID())
145
+                        ->setAuthor($token->getUID())
146
+                        ->setSubject(Provider::APP_TOKEN_CREATED, ['name' => $token->getName()])
147
+                        ->setObject('app_token', $token->getId());
148
+
149
+                    try {
150
+                        $activityManager->publish($activity);
151
+                    } catch (BadMethodCallException $e) {
152
+                        $logger->logException($e, ['message' => 'could not publish activity', 'level' => ILogger::WARN]);
153
+                    }
154
+                }
155
+            });
156
+        });
157
+
158
+        Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
159
+        Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');
160
+
161
+        $context->injectFn(function (IGroupManager $groupManager) {
162
+            /** @var IGroupManager|Manager $groupManager */
163
+            $groupManager->listen('\OC\Group', 'postRemoveUser',  [$this, 'removeUserFromGroup']);
164
+            $groupManager->listen('\OC\Group', 'postAddUser',  [$this, 'addUserToGroup']);
165
+        });
166
+
167
+        Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
168
+    }
169
+
170
+    public function addUserToGroup(IGroup $group, IUser $user): void {
171
+        /** @var Hooks $hooks */
172
+        $hooks = $this->getContainer()->query(Hooks::class);
173
+        $hooks->addUserToGroup($group, $user);
174
+    }
175
+
176
+    public function removeUserFromGroup(IGroup $group, IUser $user): void {
177
+        /** @var Hooks $hooks */
178
+        $hooks = $this->getContainer()->query(Hooks::class);
179
+        $hooks->removeUserFromGroup($group, $user);
180
+    }
181
+
182
+
183
+    /**
184
+     * @param array $parameters
185
+     * @throws \InvalidArgumentException
186
+     * @throws \BadMethodCallException
187
+     * @throws \Exception
188
+     * @throws \OCP\AppFramework\QueryException
189
+     */
190
+    public function onChangePassword(array $parameters) {
191
+        /** @var Hooks $hooks */
192
+        $hooks = $this->getContainer()->query(Hooks::class);
193
+        $hooks->onChangePassword($parameters['uid']);
194
+    }
195
+
196
+    /**
197
+     * @param array $parameters
198
+     * @throws \InvalidArgumentException
199
+     * @throws \BadMethodCallException
200
+     * @throws \Exception
201
+     * @throws \OCP\AppFramework\QueryException
202
+     */
203
+    public function onChangeInfo(array $parameters) {
204
+        if ($parameters['feature'] !== 'eMailAddress') {
205
+            return;
206
+        }
207
+
208
+        /** @var Hooks $hooks */
209
+        $hooks = $this->getContainer()->query(Hooks::class);
210
+        $hooks->onChangeEmail($parameters['user'], $parameters['old_value']);
211
+    }
212
+
213
+    /**
214
+     * @param array $settings
215
+     */
216
+    public function extendJsConfig(array $settings) {
217
+        $appConfig = json_decode($settings['array']['oc_appconfig'], true);
218
+
219
+        $publicWebFinger = \OC::$server->getConfig()->getAppValue('core', 'public_webfinger', '');
220
+        if (!empty($publicWebFinger)) {
221
+            $appConfig['core']['public_webfinger'] = $publicWebFinger;
222
+        }
223
+
224
+        $publicNodeInfo = \OC::$server->getConfig()->getAppValue('core', 'public_nodeinfo', '');
225
+        if (!empty($publicNodeInfo)) {
226
+            $appConfig['core']['public_nodeinfo'] = $publicNodeInfo;
227
+        }
228
+
229
+        $settings['array']['oc_appconfig'] = json_encode($appConfig);
230
+    }
231 231
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 		 * Core class wrappers
87 87
 		 */
88 88
 		/** FIXME: Remove once OC_User is non-static and mockable */
89
-		$context->registerService('isAdmin', function () {
89
+		$context->registerService('isAdmin', function() {
90 90
 			return \OC_User::isAdminUser(\OC_User::getUser());
91 91
 		});
92 92
 		/** FIXME: Remove once OC_SubAdmin is non-static and mockable */
93
-		$context->registerService('isSubAdmin', function () {
93
+		$context->registerService('isSubAdmin', function() {
94 94
 			$userObject = \OC::$server->getUserSession()->getUser();
95 95
 			$isSubAdmin = false;
96 96
 			if ($userObject !== null) {
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 			}
99 99
 			return $isSubAdmin;
100 100
 		});
101
-		$context->registerService(IProvider::class, function (IAppContainer $appContainer) {
101
+		$context->registerService(IProvider::class, function(IAppContainer $appContainer) {
102 102
 			/** @var IServerContainer $serverContainer */
103 103
 			$serverContainer = $appContainer->query(IServerContainer::class);
104 104
 			return $serverContainer->query(IProvider::class);
105 105
 		});
106
-		$context->registerService(IManager::class, function (IAppContainer $appContainer) {
106
+		$context->registerService(IManager::class, function(IAppContainer $appContainer) {
107 107
 			/** @var IServerContainer $serverContainer */
108 108
 			$serverContainer = $appContainer->query(IServerContainer::class);
109 109
 			return $serverContainer->getSettingsManager();
110 110
 		});
111 111
 
112
-		$context->registerService(NewUserMailHelper::class, function (IAppContainer $appContainer) {
112
+		$context->registerService(NewUserMailHelper::class, function(IAppContainer $appContainer) {
113 113
 			/** @var Server $server */
114 114
 			$server = $appContainer->query(IServerContainer::class);
115 115
 			/** @var Defaults $defaults */
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	public function boot(IBootContext $context): void {
133
-		$context->injectFn(function (EventDispatcherInterface $dispatcher, IAppContainer $appContainer) {
134
-			$dispatcher->addListener('app_password_created', function (GenericEvent $event) use ($appContainer) {
133
+		$context->injectFn(function(EventDispatcherInterface $dispatcher, IAppContainer $appContainer) {
134
+			$dispatcher->addListener('app_password_created', function(GenericEvent $event) use ($appContainer) {
135 135
 				if (($token = $event->getSubject()) instanceof IToken) {
136 136
 					/** @var IActivityManager $activityManager */
137 137
 					$activityManager = $appContainer->get(IActivityManager::class);
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 		Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
159 159
 		Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');
160 160
 
161
-		$context->injectFn(function (IGroupManager $groupManager) {
161
+		$context->injectFn(function(IGroupManager $groupManager) {
162 162
 			/** @var IGroupManager|Manager $groupManager */
163
-			$groupManager->listen('\OC\Group', 'postRemoveUser',  [$this, 'removeUserFromGroup']);
164
-			$groupManager->listen('\OC\Group', 'postAddUser',  [$this, 'addUserToGroup']);
163
+			$groupManager->listen('\OC\Group', 'postRemoveUser', [$this, 'removeUserFromGroup']);
164
+			$groupManager->listen('\OC\Group', 'postAddUser', [$this, 'addUserToGroup']);
165 165
 		});
166 166
 
167 167
 		Util::connectHook('\OCP\Config', 'js', $this, 'extendJsConfig');
Please login to merge, or discard this patch.
apps/settings/lib/SetupChecks/CheckUserCertificates.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -31,50 +31,50 @@
 block discarded – undo
31 31
 use OCP\IURLGenerator;
32 32
 
33 33
 class CheckUserCertificates {
34
-	/** @var IL10N */
35
-	private $l10n;
36
-	/** @var string */
37
-	private $configValue;
38
-	/** @var IURLGenerator */
39
-	private $urlGenerator;
34
+    /** @var IL10N */
35
+    private $l10n;
36
+    /** @var string */
37
+    private $configValue;
38
+    /** @var IURLGenerator */
39
+    private $urlGenerator;
40 40
 
41
-	public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
42
-		$this->l10n = $l10n;
43
-		$configValue = $config->getAppValue('files_external', 'user_certificate_scan', false);
44
-		if (!is_string($configValue)) {
45
-			$configValue = '';
46
-		}
47
-		$this->configValue = $configValue;
48
-		$this->urlGenerator = $urlGenerator;
49
-	}
41
+    public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
42
+        $this->l10n = $l10n;
43
+        $configValue = $config->getAppValue('files_external', 'user_certificate_scan', false);
44
+        if (!is_string($configValue)) {
45
+            $configValue = '';
46
+        }
47
+        $this->configValue = $configValue;
48
+        $this->urlGenerator = $urlGenerator;
49
+    }
50 50
 
51
-	public function description(): string {
52
-		if ($this->configValue === '') {
53
-			return '';
54
-		}
55
-		if ($this->configValue === 'not-run-yet') {
56
-			return $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.');
57
-		}
58
-		return $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.');
59
-	}
51
+    public function description(): string {
52
+        if ($this->configValue === '') {
53
+            return '';
54
+        }
55
+        if ($this->configValue === 'not-run-yet') {
56
+            return $this->l10n->t('A background job is pending that checks for user imported SSL certificates. Please check back later.');
57
+        }
58
+        return $this->l10n->t('There are some user imported SSL certificates present, that are not used anymore with Nextcloud 21. They can be imported on the command line via "occ security:certificates:import" command. Their paths inside the data directory are shown below.');
59
+    }
60 60
 
61
-	public function severity(): string {
62
-		return 'warning';
63
-	}
61
+    public function severity(): string {
62
+        return 'warning';
63
+    }
64 64
 
65
-	public function run(): bool {
66
-		// all fine if neither "not-run-yet" nor a result
67
-		return $this->configValue === '';
68
-	}
65
+    public function run(): bool {
66
+        // all fine if neither "not-run-yet" nor a result
67
+        return $this->configValue === '';
68
+    }
69 69
 
70
-	public function elements(): array {
71
-		if ($this->configValue === '' || $this->configValue === 'not-run-yet') {
72
-			return [];
73
-		}
74
-		$data = json_decode($this->configValue);
75
-		if (!is_array($data)) {
76
-			return [];
77
-		}
78
-		return $data;
79
-	}
70
+    public function elements(): array {
71
+        if ($this->configValue === '' || $this->configValue === 'not-run-yet') {
72
+            return [];
73
+        }
74
+        $data = json_decode($this->configValue);
75
+        if (!is_array($data)) {
76
+            return [];
77
+        }
78
+        return $data;
79
+    }
80 80
 }
Please login to merge, or discard this patch.
apps/settings/lib/Controller/CheckSetupController.php 1 patch
Indentation   +655 added lines, -655 removed lines patch added patch discarded remove patch
@@ -75,292 +75,292 @@  discard block
 block discarded – undo
75 75
 use Symfony\Component\EventDispatcher\GenericEvent;
76 76
 
77 77
 class CheckSetupController extends Controller {
78
-	/** @var IConfig */
79
-	private $config;
80
-	/** @var IClientService */
81
-	private $clientService;
82
-	/** @var IURLGenerator */
83
-	private $urlGenerator;
84
-	/** @var IL10N */
85
-	private $l10n;
86
-	/** @var Checker */
87
-	private $checker;
88
-	/** @var ILogger */
89
-	private $logger;
90
-	/** @var EventDispatcherInterface */
91
-	private $dispatcher;
92
-	/** @var IDBConnection|Connection */
93
-	private $db;
94
-	/** @var ILockingProvider */
95
-	private $lockingProvider;
96
-	/** @var IDateTimeFormatter */
97
-	private $dateTimeFormatter;
98
-	/** @var MemoryInfo */
99
-	private $memoryInfo;
100
-	/** @var ISecureRandom */
101
-	private $secureRandom;
102
-	/** @var IniGetWrapper */
103
-	private $iniGetWrapper;
104
-
105
-	public function __construct($AppName,
106
-								IRequest $request,
107
-								IConfig $config,
108
-								IClientService $clientService,
109
-								IURLGenerator $urlGenerator,
110
-								IL10N $l10n,
111
-								Checker $checker,
112
-								ILogger $logger,
113
-								EventDispatcherInterface $dispatcher,
114
-								IDBConnection $db,
115
-								ILockingProvider $lockingProvider,
116
-								IDateTimeFormatter $dateTimeFormatter,
117
-								MemoryInfo $memoryInfo,
118
-								ISecureRandom $secureRandom,
119
-								IniGetWrapper $iniGetWrapper) {
120
-		parent::__construct($AppName, $request);
121
-		$this->config = $config;
122
-		$this->clientService = $clientService;
123
-		$this->urlGenerator = $urlGenerator;
124
-		$this->l10n = $l10n;
125
-		$this->checker = $checker;
126
-		$this->logger = $logger;
127
-		$this->dispatcher = $dispatcher;
128
-		$this->db = $db;
129
-		$this->lockingProvider = $lockingProvider;
130
-		$this->dateTimeFormatter = $dateTimeFormatter;
131
-		$this->memoryInfo = $memoryInfo;
132
-		$this->secureRandom = $secureRandom;
133
-		$this->iniGetWrapper = $iniGetWrapper;
134
-	}
135
-
136
-	/**
137
-	 * Checks if the server can connect to the internet using HTTPS and HTTP
138
-	 * @return bool
139
-	 */
140
-	private function hasInternetConnectivityProblems(): bool {
141
-		if ($this->config->getSystemValue('has_internet_connection', true) === false) {
142
-			return false;
143
-		}
144
-
145
-		$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
146
-			'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
147
-		]);
148
-
149
-		foreach ($siteArray as $site) {
150
-			if ($this->isSiteReachable($site)) {
151
-				return false;
152
-			}
153
-		}
154
-		return true;
155
-	}
156
-
157
-	/**
158
-	 * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
159
-	 * @return bool
160
-	 */
161
-	private function isSiteReachable($sitename) {
162
-		$httpSiteName = 'http://' . $sitename . '/';
163
-		$httpsSiteName = 'https://' . $sitename . '/';
164
-
165
-		try {
166
-			$client = $this->clientService->newClient();
167
-			$client->get($httpSiteName);
168
-			$client->get($httpsSiteName);
169
-		} catch (\Exception $e) {
170
-			$this->logger->logException($e, ['app' => 'internet_connection_check']);
171
-			return false;
172
-		}
173
-		return true;
174
-	}
175
-
176
-	/**
177
-	 * Checks whether a local memcache is installed or not
178
-	 * @return bool
179
-	 */
180
-	private function isMemcacheConfigured() {
181
-		return $this->config->getSystemValue('memcache.local', null) !== null;
182
-	}
183
-
184
-	/**
185
-	 * Whether PHP can generate "secure" pseudorandom integers
186
-	 *
187
-	 * @return bool
188
-	 */
189
-	private function isRandomnessSecure() {
190
-		try {
191
-			$this->secureRandom->generate(1);
192
-		} catch (\Exception $ex) {
193
-			return false;
194
-		}
195
-		return true;
196
-	}
197
-
198
-	/**
199
-	 * Public for the sake of unit-testing
200
-	 *
201
-	 * @return array
202
-	 */
203
-	protected function getCurlVersion() {
204
-		return curl_version();
205
-	}
206
-
207
-	/**
208
-	 * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
209
-	 * have multiple bugs which likely lead to problems in combination with
210
-	 * functionality required by ownCloud such as SNI.
211
-	 *
212
-	 * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
213
-	 * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
214
-	 * @return string
215
-	 */
216
-	private function isUsedTlsLibOutdated() {
217
-		// Don't run check when:
218
-		// 1. Server has `has_internet_connection` set to false
219
-		// 2. AppStore AND S2S is disabled
220
-		if (!$this->config->getSystemValue('has_internet_connection', true)) {
221
-			return '';
222
-		}
223
-		if (!$this->config->getSystemValue('appstoreenabled', true)
224
-			&& $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
225
-			&& $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
226
-			return '';
227
-		}
228
-
229
-		$versionString = $this->getCurlVersion();
230
-		if (isset($versionString['ssl_version'])) {
231
-			$versionString = $versionString['ssl_version'];
232
-		} else {
233
-			return '';
234
-		}
235
-
236
-		$features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
237
-		if (!$this->config->getSystemValue('appstoreenabled', true)) {
238
-			$features = (string)$this->l10n->t('Federated Cloud Sharing');
239
-		}
240
-
241
-		// Check if at least OpenSSL after 1.01d or 1.0.2b
242
-		if (strpos($versionString, 'OpenSSL/') === 0) {
243
-			$majorVersion = substr($versionString, 8, 5);
244
-			$patchRelease = substr($versionString, 13, 6);
245
-
246
-			if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
247
-				($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
248
-				return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]);
249
-			}
250
-		}
251
-
252
-		// Check if NSS and perform heuristic check
253
-		if (strpos($versionString, 'NSS/') === 0) {
254
-			try {
255
-				$firstClient = $this->clientService->newClient();
256
-				$firstClient->get('https://nextcloud.com/');
257
-
258
-				$secondClient = $this->clientService->newClient();
259
-				$secondClient->get('https://nextcloud.com/');
260
-			} catch (ClientException $e) {
261
-				if ($e->getResponse()->getStatusCode() === 400) {
262
-					return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]);
263
-				}
264
-			}
265
-		}
266
-
267
-		return '';
268
-	}
269
-
270
-	/**
271
-	 * Whether the version is outdated
272
-	 *
273
-	 * @return bool
274
-	 */
275
-	protected function isPhpOutdated(): bool {
276
-		return PHP_VERSION_ID < 70300;
277
-	}
278
-
279
-	/**
280
-	 * Whether the php version is still supported (at time of release)
281
-	 * according to: https://secure.php.net/supported-versions.php
282
-	 *
283
-	 * @return array
284
-	 */
285
-	private function isPhpSupported(): array {
286
-		return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
287
-	}
288
-
289
-	/**
290
-	 * Check if the reverse proxy configuration is working as expected
291
-	 *
292
-	 * @return bool
293
-	 */
294
-	private function forwardedForHeadersWorking() {
295
-		$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
296
-		$remoteAddress = $this->request->getHeader('REMOTE_ADDR');
297
-
298
-		if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
299
-			return false;
300
-		}
301
-
302
-		if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
303
-			return $remoteAddress !== $this->request->getRemoteAddress();
304
-		}
305
-
306
-		// either not enabled or working correctly
307
-		return true;
308
-	}
309
-
310
-	/**
311
-	 * Checks if the correct memcache module for PHP is installed. Only
312
-	 * fails if memcached is configured and the working module is not installed.
313
-	 *
314
-	 * @return bool
315
-	 */
316
-	private function isCorrectMemcachedPHPModuleInstalled() {
317
-		if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
318
-			return true;
319
-		}
320
-
321
-		// there are two different memcached modules for PHP
322
-		// we only support memcached and not memcache
323
-		// https://code.google.com/p/memcached/wiki/PHPClientComparison
324
-		return !(!extension_loaded('memcached') && extension_loaded('memcache'));
325
-	}
326
-
327
-	/**
328
-	 * Checks if set_time_limit is not disabled.
329
-	 *
330
-	 * @return bool
331
-	 */
332
-	private function isSettimelimitAvailable() {
333
-		if (function_exists('set_time_limit')
334
-			&& strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
335
-			return true;
336
-		}
337
-
338
-		return false;
339
-	}
340
-
341
-	/**
342
-	 * @return RedirectResponse
343
-	 */
344
-	public function rescanFailedIntegrityCheck() {
345
-		$this->checker->runInstanceVerification();
346
-		return new RedirectResponse(
347
-			$this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
348
-		);
349
-	}
350
-
351
-	/**
352
-	 * @NoCSRFRequired
353
-	 * @return DataResponse
354
-	 */
355
-	public function getFailedIntegrityCheckFiles() {
356
-		if (!$this->checker->isCodeCheckEnforced()) {
357
-			return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
358
-		}
359
-
360
-		$completeResults = $this->checker->getResults();
361
-
362
-		if (!empty($completeResults)) {
363
-			$formattedTextResponse = 'Technical information
78
+    /** @var IConfig */
79
+    private $config;
80
+    /** @var IClientService */
81
+    private $clientService;
82
+    /** @var IURLGenerator */
83
+    private $urlGenerator;
84
+    /** @var IL10N */
85
+    private $l10n;
86
+    /** @var Checker */
87
+    private $checker;
88
+    /** @var ILogger */
89
+    private $logger;
90
+    /** @var EventDispatcherInterface */
91
+    private $dispatcher;
92
+    /** @var IDBConnection|Connection */
93
+    private $db;
94
+    /** @var ILockingProvider */
95
+    private $lockingProvider;
96
+    /** @var IDateTimeFormatter */
97
+    private $dateTimeFormatter;
98
+    /** @var MemoryInfo */
99
+    private $memoryInfo;
100
+    /** @var ISecureRandom */
101
+    private $secureRandom;
102
+    /** @var IniGetWrapper */
103
+    private $iniGetWrapper;
104
+
105
+    public function __construct($AppName,
106
+                                IRequest $request,
107
+                                IConfig $config,
108
+                                IClientService $clientService,
109
+                                IURLGenerator $urlGenerator,
110
+                                IL10N $l10n,
111
+                                Checker $checker,
112
+                                ILogger $logger,
113
+                                EventDispatcherInterface $dispatcher,
114
+                                IDBConnection $db,
115
+                                ILockingProvider $lockingProvider,
116
+                                IDateTimeFormatter $dateTimeFormatter,
117
+                                MemoryInfo $memoryInfo,
118
+                                ISecureRandom $secureRandom,
119
+                                IniGetWrapper $iniGetWrapper) {
120
+        parent::__construct($AppName, $request);
121
+        $this->config = $config;
122
+        $this->clientService = $clientService;
123
+        $this->urlGenerator = $urlGenerator;
124
+        $this->l10n = $l10n;
125
+        $this->checker = $checker;
126
+        $this->logger = $logger;
127
+        $this->dispatcher = $dispatcher;
128
+        $this->db = $db;
129
+        $this->lockingProvider = $lockingProvider;
130
+        $this->dateTimeFormatter = $dateTimeFormatter;
131
+        $this->memoryInfo = $memoryInfo;
132
+        $this->secureRandom = $secureRandom;
133
+        $this->iniGetWrapper = $iniGetWrapper;
134
+    }
135
+
136
+    /**
137
+     * Checks if the server can connect to the internet using HTTPS and HTTP
138
+     * @return bool
139
+     */
140
+    private function hasInternetConnectivityProblems(): bool {
141
+        if ($this->config->getSystemValue('has_internet_connection', true) === false) {
142
+            return false;
143
+        }
144
+
145
+        $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
146
+            'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
147
+        ]);
148
+
149
+        foreach ($siteArray as $site) {
150
+            if ($this->isSiteReachable($site)) {
151
+                return false;
152
+            }
153
+        }
154
+        return true;
155
+    }
156
+
157
+    /**
158
+     * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
159
+     * @return bool
160
+     */
161
+    private function isSiteReachable($sitename) {
162
+        $httpSiteName = 'http://' . $sitename . '/';
163
+        $httpsSiteName = 'https://' . $sitename . '/';
164
+
165
+        try {
166
+            $client = $this->clientService->newClient();
167
+            $client->get($httpSiteName);
168
+            $client->get($httpsSiteName);
169
+        } catch (\Exception $e) {
170
+            $this->logger->logException($e, ['app' => 'internet_connection_check']);
171
+            return false;
172
+        }
173
+        return true;
174
+    }
175
+
176
+    /**
177
+     * Checks whether a local memcache is installed or not
178
+     * @return bool
179
+     */
180
+    private function isMemcacheConfigured() {
181
+        return $this->config->getSystemValue('memcache.local', null) !== null;
182
+    }
183
+
184
+    /**
185
+     * Whether PHP can generate "secure" pseudorandom integers
186
+     *
187
+     * @return bool
188
+     */
189
+    private function isRandomnessSecure() {
190
+        try {
191
+            $this->secureRandom->generate(1);
192
+        } catch (\Exception $ex) {
193
+            return false;
194
+        }
195
+        return true;
196
+    }
197
+
198
+    /**
199
+     * Public for the sake of unit-testing
200
+     *
201
+     * @return array
202
+     */
203
+    protected function getCurlVersion() {
204
+        return curl_version();
205
+    }
206
+
207
+    /**
208
+     * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
209
+     * have multiple bugs which likely lead to problems in combination with
210
+     * functionality required by ownCloud such as SNI.
211
+     *
212
+     * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
213
+     * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
214
+     * @return string
215
+     */
216
+    private function isUsedTlsLibOutdated() {
217
+        // Don't run check when:
218
+        // 1. Server has `has_internet_connection` set to false
219
+        // 2. AppStore AND S2S is disabled
220
+        if (!$this->config->getSystemValue('has_internet_connection', true)) {
221
+            return '';
222
+        }
223
+        if (!$this->config->getSystemValue('appstoreenabled', true)
224
+            && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
225
+            && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
226
+            return '';
227
+        }
228
+
229
+        $versionString = $this->getCurlVersion();
230
+        if (isset($versionString['ssl_version'])) {
231
+            $versionString = $versionString['ssl_version'];
232
+        } else {
233
+            return '';
234
+        }
235
+
236
+        $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
237
+        if (!$this->config->getSystemValue('appstoreenabled', true)) {
238
+            $features = (string)$this->l10n->t('Federated Cloud Sharing');
239
+        }
240
+
241
+        // Check if at least OpenSSL after 1.01d or 1.0.2b
242
+        if (strpos($versionString, 'OpenSSL/') === 0) {
243
+            $majorVersion = substr($versionString, 8, 5);
244
+            $patchRelease = substr($versionString, 13, 6);
245
+
246
+            if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
247
+                ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
248
+                return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]);
249
+            }
250
+        }
251
+
252
+        // Check if NSS and perform heuristic check
253
+        if (strpos($versionString, 'NSS/') === 0) {
254
+            try {
255
+                $firstClient = $this->clientService->newClient();
256
+                $firstClient->get('https://nextcloud.com/');
257
+
258
+                $secondClient = $this->clientService->newClient();
259
+                $secondClient->get('https://nextcloud.com/');
260
+            } catch (ClientException $e) {
261
+                if ($e->getResponse()->getStatusCode() === 400) {
262
+                    return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]);
263
+                }
264
+            }
265
+        }
266
+
267
+        return '';
268
+    }
269
+
270
+    /**
271
+     * Whether the version is outdated
272
+     *
273
+     * @return bool
274
+     */
275
+    protected function isPhpOutdated(): bool {
276
+        return PHP_VERSION_ID < 70300;
277
+    }
278
+
279
+    /**
280
+     * Whether the php version is still supported (at time of release)
281
+     * according to: https://secure.php.net/supported-versions.php
282
+     *
283
+     * @return array
284
+     */
285
+    private function isPhpSupported(): array {
286
+        return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
287
+    }
288
+
289
+    /**
290
+     * Check if the reverse proxy configuration is working as expected
291
+     *
292
+     * @return bool
293
+     */
294
+    private function forwardedForHeadersWorking() {
295
+        $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
296
+        $remoteAddress = $this->request->getHeader('REMOTE_ADDR');
297
+
298
+        if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
299
+            return false;
300
+        }
301
+
302
+        if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
303
+            return $remoteAddress !== $this->request->getRemoteAddress();
304
+        }
305
+
306
+        // either not enabled or working correctly
307
+        return true;
308
+    }
309
+
310
+    /**
311
+     * Checks if the correct memcache module for PHP is installed. Only
312
+     * fails if memcached is configured and the working module is not installed.
313
+     *
314
+     * @return bool
315
+     */
316
+    private function isCorrectMemcachedPHPModuleInstalled() {
317
+        if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
318
+            return true;
319
+        }
320
+
321
+        // there are two different memcached modules for PHP
322
+        // we only support memcached and not memcache
323
+        // https://code.google.com/p/memcached/wiki/PHPClientComparison
324
+        return !(!extension_loaded('memcached') && extension_loaded('memcache'));
325
+    }
326
+
327
+    /**
328
+     * Checks if set_time_limit is not disabled.
329
+     *
330
+     * @return bool
331
+     */
332
+    private function isSettimelimitAvailable() {
333
+        if (function_exists('set_time_limit')
334
+            && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
335
+            return true;
336
+        }
337
+
338
+        return false;
339
+    }
340
+
341
+    /**
342
+     * @return RedirectResponse
343
+     */
344
+    public function rescanFailedIntegrityCheck() {
345
+        $this->checker->runInstanceVerification();
346
+        return new RedirectResponse(
347
+            $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
348
+        );
349
+    }
350
+
351
+    /**
352
+     * @NoCSRFRequired
353
+     * @return DataResponse
354
+     */
355
+    public function getFailedIntegrityCheckFiles() {
356
+        if (!$this->checker->isCodeCheckEnforced()) {
357
+            return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
358
+        }
359
+
360
+        $completeResults = $this->checker->getResults();
361
+
362
+        if (!empty($completeResults)) {
363
+            $formattedTextResponse = 'Technical information
364 364
 =====================
365 365
 The following list covers which files have failed the integrity check. Please read
366 366
 the previous linked documentation to learn more about the errors and how to fix
@@ -369,376 +369,376 @@  discard block
 block discarded – undo
369 369
 Results
370 370
 =======
371 371
 ';
372
-			foreach ($completeResults as $context => $contextResult) {
373
-				$formattedTextResponse .= "- $context\n";
374
-
375
-				foreach ($contextResult as $category => $result) {
376
-					$formattedTextResponse .= "\t- $category\n";
377
-					if ($category !== 'EXCEPTION') {
378
-						foreach ($result as $key => $results) {
379
-							$formattedTextResponse .= "\t\t- $key\n";
380
-						}
381
-					} else {
382
-						foreach ($result as $key => $results) {
383
-							$formattedTextResponse .= "\t\t- $results\n";
384
-						}
385
-					}
386
-				}
387
-			}
388
-
389
-			$formattedTextResponse .= '
372
+            foreach ($completeResults as $context => $contextResult) {
373
+                $formattedTextResponse .= "- $context\n";
374
+
375
+                foreach ($contextResult as $category => $result) {
376
+                    $formattedTextResponse .= "\t- $category\n";
377
+                    if ($category !== 'EXCEPTION') {
378
+                        foreach ($result as $key => $results) {
379
+                            $formattedTextResponse .= "\t\t- $key\n";
380
+                        }
381
+                    } else {
382
+                        foreach ($result as $key => $results) {
383
+                            $formattedTextResponse .= "\t\t- $results\n";
384
+                        }
385
+                    }
386
+                }
387
+            }
388
+
389
+            $formattedTextResponse .= '
390 390
 Raw output
391 391
 ==========
392 392
 ';
393
-			$formattedTextResponse .= print_r($completeResults, true);
394
-		} else {
395
-			$formattedTextResponse = 'No errors have been found.';
396
-		}
397
-
398
-
399
-		$response = new DataDisplayResponse(
400
-			$formattedTextResponse,
401
-			Http::STATUS_OK,
402
-			[
403
-				'Content-Type' => 'text/plain',
404
-			]
405
-		);
406
-
407
-		return $response;
408
-	}
409
-
410
-	/**
411
-	 * Checks whether a PHP opcache is properly set up
412
-	 * @return bool
413
-	 */
414
-	protected function isOpcacheProperlySetup() {
415
-		if (!$this->iniGetWrapper->getBool('opcache.enable')) {
416
-			return false;
417
-		}
418
-
419
-		if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
420
-			return false;
421
-		}
422
-
423
-		if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
424
-			return false;
425
-		}
426
-
427
-		if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
428
-			return false;
429
-		}
430
-
431
-		if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
432
-			return false;
433
-		}
434
-
435
-		return true;
436
-	}
437
-
438
-	/**
439
-	 * Check if the required FreeType functions are present
440
-	 * @return bool
441
-	 */
442
-	protected function hasFreeTypeSupport() {
443
-		return function_exists('imagettfbbox') && function_exists('imagettftext');
444
-	}
445
-
446
-	protected function hasMissingIndexes(): array {
447
-		$indexInfo = new MissingIndexInformation();
448
-		// Dispatch event so apps can also hint for pending index updates if needed
449
-		$event = new GenericEvent($indexInfo);
450
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
451
-
452
-		return $indexInfo->getListOfMissingIndexes();
453
-	}
454
-
455
-	protected function hasMissingColumns(): array {
456
-		$indexInfo = new MissingColumnInformation();
457
-		// Dispatch event so apps can also hint for pending index updates if needed
458
-		$event = new GenericEvent($indexInfo);
459
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
460
-
461
-		return $indexInfo->getListOfMissingColumns();
462
-	}
463
-
464
-	protected function isSqliteUsed() {
465
-		return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
466
-	}
467
-
468
-	protected function isReadOnlyConfig(): bool {
469
-		return \OC_Helper::isReadOnlyConfigEnabled();
470
-	}
471
-
472
-	protected function hasValidTransactionIsolationLevel(): bool {
473
-		try {
474
-			if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
475
-				return true;
476
-			}
477
-
478
-			return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
479
-		} catch (DBALException $e) {
480
-			// ignore
481
-		}
482
-
483
-		return true;
484
-	}
485
-
486
-	protected function hasFileinfoInstalled(): bool {
487
-		return \OC_Util::fileInfoLoaded();
488
-	}
489
-
490
-	protected function hasWorkingFileLocking(): bool {
491
-		return !($this->lockingProvider instanceof NoopLockingProvider);
492
-	}
493
-
494
-	protected function getSuggestedOverwriteCliURL(): string {
495
-		$suggestedOverwriteCliUrl = '';
496
-		if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
497
-			$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
498
-			if (!$this->config->getSystemValue('config_is_read_only', false)) {
499
-				// Set the overwrite URL when it was not set yet.
500
-				$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
501
-				$suggestedOverwriteCliUrl = '';
502
-			}
503
-		}
504
-		return $suggestedOverwriteCliUrl;
505
-	}
506
-
507
-	protected function getLastCronInfo(): array {
508
-		$lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
509
-		return [
510
-			'diffInSeconds' => time() - $lastCronRun,
511
-			'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
512
-			'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
513
-		];
514
-	}
515
-
516
-	protected function getCronErrors() {
517
-		$errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
518
-
519
-		if (is_array($errors)) {
520
-			return $errors;
521
-		}
522
-
523
-		return [];
524
-	}
525
-
526
-	protected function hasOpcacheLoaded(): bool {
527
-		return extension_loaded('Zend OPcache');
528
-	}
529
-
530
-	/**
531
-	 * Iterates through the configured app roots and
532
-	 * tests if the subdirectories are owned by the same user than the current user.
533
-	 *
534
-	 * @return array
535
-	 */
536
-	protected function getAppDirsWithDifferentOwner(): array {
537
-		$currentUser = posix_getuid();
538
-		$appDirsWithDifferentOwner = [[]];
539
-
540
-		foreach (OC::$APPSROOTS as $appRoot) {
541
-			if ($appRoot['writable'] === true) {
542
-				$appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
543
-			}
544
-		}
545
-
546
-		$appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
547
-		sort($appDirsWithDifferentOwner);
548
-
549
-		return $appDirsWithDifferentOwner;
550
-	}
551
-
552
-	/**
553
-	 * Tests if the directories for one apps directory are writable by the current user.
554
-	 *
555
-	 * @param int $currentUser The current user
556
-	 * @param array $appRoot The app root config
557
-	 * @return string[] The none writable directory paths inside the app root
558
-	 */
559
-	private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
560
-		$appDirsWithDifferentOwner = [];
561
-		$appsPath = $appRoot['path'];
562
-		$appsDir = new DirectoryIterator($appRoot['path']);
563
-
564
-		foreach ($appsDir as $fileInfo) {
565
-			if ($fileInfo->isDir() && !$fileInfo->isDot()) {
566
-				$absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
567
-				$appDirUser = fileowner($absAppPath);
568
-				if ($appDirUser !== $currentUser) {
569
-					$appDirsWithDifferentOwner[] = $absAppPath;
570
-				}
571
-			}
572
-		}
573
-
574
-		return $appDirsWithDifferentOwner;
575
-	}
576
-
577
-	/**
578
-	 * Checks for potential PHP modules that would improve the instance
579
-	 *
580
-	 * @return string[] A list of PHP modules that is recommended
581
-	 */
582
-	protected function hasRecommendedPHPModules(): array {
583
-		$recommendedPHPModules = [];
584
-
585
-		if (!extension_loaded('intl')) {
586
-			$recommendedPHPModules[] = 'intl';
587
-		}
588
-
589
-		if (!extension_loaded('bcmath')) {
590
-			$recommendedPHPModules[] = 'bcmath';
591
-		}
592
-
593
-		if (!extension_loaded('gmp')) {
594
-			$recommendedPHPModules[] = 'gmp';
595
-		}
596
-
597
-		if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
598
-			if (!extension_loaded('imagick')) {
599
-				$recommendedPHPModules[] = 'imagick';
600
-			}
601
-		}
602
-
603
-		return $recommendedPHPModules;
604
-	}
605
-
606
-	protected function isMysqlUsedWithoutUTF8MB4(): bool {
607
-		return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
608
-	}
609
-
610
-	protected function hasBigIntConversionPendingColumns(): array {
611
-		// copy of ConvertFilecacheBigInt::getColumnsByTable()
612
-		$tables = [
613
-			'activity' => ['activity_id', 'object_id'],
614
-			'activity_mq' => ['mail_id'],
615
-			'authtoken' => ['id'],
616
-			'bruteforce_attempts' => ['id'],
617
-			'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
618
-			'filecache_extended' => ['fileid'],
619
-			'file_locks' => ['id'],
620
-			'jobs' => ['id'],
621
-			'mimetypes' => ['id'],
622
-			'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
623
-			'storages' => ['numeric_id'],
624
-		];
625
-
626
-		$schema = new SchemaWrapper($this->db);
627
-		$isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
628
-		$pendingColumns = [];
629
-
630
-		foreach ($tables as $tableName => $columns) {
631
-			if (!$schema->hasTable($tableName)) {
632
-				continue;
633
-			}
634
-
635
-			$table = $schema->getTable($tableName);
636
-			foreach ($columns as $columnName) {
637
-				$column = $table->getColumn($columnName);
638
-				$isAutoIncrement = $column->getAutoincrement();
639
-				$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
640
-				if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
641
-					$pendingColumns[] = $tableName . '.' . $columnName;
642
-				}
643
-			}
644
-		}
645
-
646
-		return $pendingColumns;
647
-	}
648
-
649
-	protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
650
-		$objectStore = $this->config->getSystemValue('objectstore', null);
651
-		$objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
652
-
653
-		if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
654
-			return true;
655
-		}
656
-
657
-		if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
658
-			return true;
659
-		}
660
-
661
-		if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
662
-			return true;
663
-		}
664
-
665
-		$tempPath = sys_get_temp_dir();
666
-		if (!is_dir($tempPath)) {
667
-			$this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
668
-			return false;
669
-		}
670
-		$freeSpaceInTemp = disk_free_space($tempPath);
671
-		if ($freeSpaceInTemp === false) {
672
-			$this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
673
-			return false;
674
-		}
675
-
676
-		$freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
677
-		if ($freeSpaceInTempInGB > 50) {
678
-			return true;
679
-		}
680
-
681
-		$this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
682
-		return false;
683
-	}
684
-
685
-	protected function imageMagickLacksSVGSupport(): bool {
686
-		return extension_loaded('imagick') && count(\Imagick::queryFormats('SVG')) === 0;
687
-	}
688
-
689
-	/**
690
-	 * @return DataResponse
691
-	 */
692
-	public function check() {
693
-		$phpDefaultCharset = new PhpDefaultCharset();
694
-		$phpOutputBuffering = new PhpOutputBuffering();
695
-		$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
696
-		$checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
697
-
698
-		return new DataResponse(
699
-			[
700
-				'isGetenvServerWorking' => !empty(getenv('PATH')),
701
-				'isReadOnlyConfig' => $this->isReadOnlyConfig(),
702
-				'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
703
-				'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
704
-				'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
705
-				'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
706
-				'cronInfo' => $this->getLastCronInfo(),
707
-				'cronErrors' => $this->getCronErrors(),
708
-				'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
709
-				'isMemcacheConfigured' => $this->isMemcacheConfigured(),
710
-				'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
711
-				'isRandomnessSecure' => $this->isRandomnessSecure(),
712
-				'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
713
-				'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
714
-				'phpSupported' => $this->isPhpSupported(),
715
-				'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
716
-				'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
717
-				'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
718
-				'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
719
-				'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
720
-				'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
721
-				'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
722
-				'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
723
-				'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
724
-				'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
725
-				'missingIndexes' => $this->hasMissingIndexes(),
726
-				'missingColumns' => $this->hasMissingColumns(),
727
-				'isSqliteUsed' => $this->isSqliteUsed(),
728
-				'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
729
-				'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
730
-				'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
731
-				'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
732
-				'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
733
-				'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
734
-				'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
735
-				'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
736
-				'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
737
-				PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
738
-				PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
739
-				LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
740
-				CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
741
-			]
742
-		);
743
-	}
393
+            $formattedTextResponse .= print_r($completeResults, true);
394
+        } else {
395
+            $formattedTextResponse = 'No errors have been found.';
396
+        }
397
+
398
+
399
+        $response = new DataDisplayResponse(
400
+            $formattedTextResponse,
401
+            Http::STATUS_OK,
402
+            [
403
+                'Content-Type' => 'text/plain',
404
+            ]
405
+        );
406
+
407
+        return $response;
408
+    }
409
+
410
+    /**
411
+     * Checks whether a PHP opcache is properly set up
412
+     * @return bool
413
+     */
414
+    protected function isOpcacheProperlySetup() {
415
+        if (!$this->iniGetWrapper->getBool('opcache.enable')) {
416
+            return false;
417
+        }
418
+
419
+        if (!$this->iniGetWrapper->getBool('opcache.save_comments')) {
420
+            return false;
421
+        }
422
+
423
+        if ($this->iniGetWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
424
+            return false;
425
+        }
426
+
427
+        if ($this->iniGetWrapper->getNumeric('opcache.memory_consumption') < 128) {
428
+            return false;
429
+        }
430
+
431
+        if ($this->iniGetWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
432
+            return false;
433
+        }
434
+
435
+        return true;
436
+    }
437
+
438
+    /**
439
+     * Check if the required FreeType functions are present
440
+     * @return bool
441
+     */
442
+    protected function hasFreeTypeSupport() {
443
+        return function_exists('imagettfbbox') && function_exists('imagettftext');
444
+    }
445
+
446
+    protected function hasMissingIndexes(): array {
447
+        $indexInfo = new MissingIndexInformation();
448
+        // Dispatch event so apps can also hint for pending index updates if needed
449
+        $event = new GenericEvent($indexInfo);
450
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
451
+
452
+        return $indexInfo->getListOfMissingIndexes();
453
+    }
454
+
455
+    protected function hasMissingColumns(): array {
456
+        $indexInfo = new MissingColumnInformation();
457
+        // Dispatch event so apps can also hint for pending index updates if needed
458
+        $event = new GenericEvent($indexInfo);
459
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
460
+
461
+        return $indexInfo->getListOfMissingColumns();
462
+    }
463
+
464
+    protected function isSqliteUsed() {
465
+        return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
466
+    }
467
+
468
+    protected function isReadOnlyConfig(): bool {
469
+        return \OC_Helper::isReadOnlyConfigEnabled();
470
+    }
471
+
472
+    protected function hasValidTransactionIsolationLevel(): bool {
473
+        try {
474
+            if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
475
+                return true;
476
+            }
477
+
478
+            return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
479
+        } catch (DBALException $e) {
480
+            // ignore
481
+        }
482
+
483
+        return true;
484
+    }
485
+
486
+    protected function hasFileinfoInstalled(): bool {
487
+        return \OC_Util::fileInfoLoaded();
488
+    }
489
+
490
+    protected function hasWorkingFileLocking(): bool {
491
+        return !($this->lockingProvider instanceof NoopLockingProvider);
492
+    }
493
+
494
+    protected function getSuggestedOverwriteCliURL(): string {
495
+        $suggestedOverwriteCliUrl = '';
496
+        if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
497
+            $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
498
+            if (!$this->config->getSystemValue('config_is_read_only', false)) {
499
+                // Set the overwrite URL when it was not set yet.
500
+                $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
501
+                $suggestedOverwriteCliUrl = '';
502
+            }
503
+        }
504
+        return $suggestedOverwriteCliUrl;
505
+    }
506
+
507
+    protected function getLastCronInfo(): array {
508
+        $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
509
+        return [
510
+            'diffInSeconds' => time() - $lastCronRun,
511
+            'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
512
+            'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
513
+        ];
514
+    }
515
+
516
+    protected function getCronErrors() {
517
+        $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
518
+
519
+        if (is_array($errors)) {
520
+            return $errors;
521
+        }
522
+
523
+        return [];
524
+    }
525
+
526
+    protected function hasOpcacheLoaded(): bool {
527
+        return extension_loaded('Zend OPcache');
528
+    }
529
+
530
+    /**
531
+     * Iterates through the configured app roots and
532
+     * tests if the subdirectories are owned by the same user than the current user.
533
+     *
534
+     * @return array
535
+     */
536
+    protected function getAppDirsWithDifferentOwner(): array {
537
+        $currentUser = posix_getuid();
538
+        $appDirsWithDifferentOwner = [[]];
539
+
540
+        foreach (OC::$APPSROOTS as $appRoot) {
541
+            if ($appRoot['writable'] === true) {
542
+                $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
543
+            }
544
+        }
545
+
546
+        $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
547
+        sort($appDirsWithDifferentOwner);
548
+
549
+        return $appDirsWithDifferentOwner;
550
+    }
551
+
552
+    /**
553
+     * Tests if the directories for one apps directory are writable by the current user.
554
+     *
555
+     * @param int $currentUser The current user
556
+     * @param array $appRoot The app root config
557
+     * @return string[] The none writable directory paths inside the app root
558
+     */
559
+    private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
560
+        $appDirsWithDifferentOwner = [];
561
+        $appsPath = $appRoot['path'];
562
+        $appsDir = new DirectoryIterator($appRoot['path']);
563
+
564
+        foreach ($appsDir as $fileInfo) {
565
+            if ($fileInfo->isDir() && !$fileInfo->isDot()) {
566
+                $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
567
+                $appDirUser = fileowner($absAppPath);
568
+                if ($appDirUser !== $currentUser) {
569
+                    $appDirsWithDifferentOwner[] = $absAppPath;
570
+                }
571
+            }
572
+        }
573
+
574
+        return $appDirsWithDifferentOwner;
575
+    }
576
+
577
+    /**
578
+     * Checks for potential PHP modules that would improve the instance
579
+     *
580
+     * @return string[] A list of PHP modules that is recommended
581
+     */
582
+    protected function hasRecommendedPHPModules(): array {
583
+        $recommendedPHPModules = [];
584
+
585
+        if (!extension_loaded('intl')) {
586
+            $recommendedPHPModules[] = 'intl';
587
+        }
588
+
589
+        if (!extension_loaded('bcmath')) {
590
+            $recommendedPHPModules[] = 'bcmath';
591
+        }
592
+
593
+        if (!extension_loaded('gmp')) {
594
+            $recommendedPHPModules[] = 'gmp';
595
+        }
596
+
597
+        if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
598
+            if (!extension_loaded('imagick')) {
599
+                $recommendedPHPModules[] = 'imagick';
600
+            }
601
+        }
602
+
603
+        return $recommendedPHPModules;
604
+    }
605
+
606
+    protected function isMysqlUsedWithoutUTF8MB4(): bool {
607
+        return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
608
+    }
609
+
610
+    protected function hasBigIntConversionPendingColumns(): array {
611
+        // copy of ConvertFilecacheBigInt::getColumnsByTable()
612
+        $tables = [
613
+            'activity' => ['activity_id', 'object_id'],
614
+            'activity_mq' => ['mail_id'],
615
+            'authtoken' => ['id'],
616
+            'bruteforce_attempts' => ['id'],
617
+            'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
618
+            'filecache_extended' => ['fileid'],
619
+            'file_locks' => ['id'],
620
+            'jobs' => ['id'],
621
+            'mimetypes' => ['id'],
622
+            'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
623
+            'storages' => ['numeric_id'],
624
+        ];
625
+
626
+        $schema = new SchemaWrapper($this->db);
627
+        $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
628
+        $pendingColumns = [];
629
+
630
+        foreach ($tables as $tableName => $columns) {
631
+            if (!$schema->hasTable($tableName)) {
632
+                continue;
633
+            }
634
+
635
+            $table = $schema->getTable($tableName);
636
+            foreach ($columns as $columnName) {
637
+                $column = $table->getColumn($columnName);
638
+                $isAutoIncrement = $column->getAutoincrement();
639
+                $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
640
+                if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
641
+                    $pendingColumns[] = $tableName . '.' . $columnName;
642
+                }
643
+            }
644
+        }
645
+
646
+        return $pendingColumns;
647
+    }
648
+
649
+    protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
650
+        $objectStore = $this->config->getSystemValue('objectstore', null);
651
+        $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
652
+
653
+        if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
654
+            return true;
655
+        }
656
+
657
+        if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
658
+            return true;
659
+        }
660
+
661
+        if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
662
+            return true;
663
+        }
664
+
665
+        $tempPath = sys_get_temp_dir();
666
+        if (!is_dir($tempPath)) {
667
+            $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
668
+            return false;
669
+        }
670
+        $freeSpaceInTemp = disk_free_space($tempPath);
671
+        if ($freeSpaceInTemp === false) {
672
+            $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
673
+            return false;
674
+        }
675
+
676
+        $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
677
+        if ($freeSpaceInTempInGB > 50) {
678
+            return true;
679
+        }
680
+
681
+        $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
682
+        return false;
683
+    }
684
+
685
+    protected function imageMagickLacksSVGSupport(): bool {
686
+        return extension_loaded('imagick') && count(\Imagick::queryFormats('SVG')) === 0;
687
+    }
688
+
689
+    /**
690
+     * @return DataResponse
691
+     */
692
+    public function check() {
693
+        $phpDefaultCharset = new PhpDefaultCharset();
694
+        $phpOutputBuffering = new PhpOutputBuffering();
695
+        $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
696
+        $checkUserCertificates = new CheckUserCertificates($this->l10n, $this->config, $this->urlGenerator);
697
+
698
+        return new DataResponse(
699
+            [
700
+                'isGetenvServerWorking' => !empty(getenv('PATH')),
701
+                'isReadOnlyConfig' => $this->isReadOnlyConfig(),
702
+                'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
703
+                'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
704
+                'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
705
+                'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
706
+                'cronInfo' => $this->getLastCronInfo(),
707
+                'cronErrors' => $this->getCronErrors(),
708
+                'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
709
+                'isMemcacheConfigured' => $this->isMemcacheConfigured(),
710
+                'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
711
+                'isRandomnessSecure' => $this->isRandomnessSecure(),
712
+                'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
713
+                'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
714
+                'phpSupported' => $this->isPhpSupported(),
715
+                'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
716
+                'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
717
+                'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
718
+                'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
719
+                'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
720
+                'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
721
+                'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
722
+                'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
723
+                'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
724
+                'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
725
+                'missingIndexes' => $this->hasMissingIndexes(),
726
+                'missingColumns' => $this->hasMissingColumns(),
727
+                'isSqliteUsed' => $this->isSqliteUsed(),
728
+                'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
729
+                'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
730
+                'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
731
+                'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
732
+                'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
733
+                'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
734
+                'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
735
+                'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
736
+                'imageMagickLacksSVGSupport' => $this->imageMagickLacksSVGSupport(),
737
+                PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
738
+                PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
739
+                LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
740
+                CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
741
+            ]
742
+        );
743
+    }
744 744
 }
Please login to merge, or discard this patch.
apps/settings/composer/composer/autoload_static.php 1 patch
Spacing   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -6,80 +6,80 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitSettings
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Settings\\' => 13,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Settings\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\Settings\\Activity\\GroupProvider' => __DIR__ . '/..' . '/../lib/Activity/GroupProvider.php',
25
-        'OCA\\Settings\\Activity\\GroupSetting' => __DIR__ . '/..' . '/../lib/Activity/GroupSetting.php',
26
-        'OCA\\Settings\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
27
-        'OCA\\Settings\\Activity\\SecurityFilter' => __DIR__ . '/..' . '/../lib/Activity/SecurityFilter.php',
28
-        'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__ . '/..' . '/../lib/Activity/SecurityProvider.php',
29
-        'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__ . '/..' . '/../lib/Activity/SecuritySetting.php',
30
-        'OCA\\Settings\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php',
31
-        'OCA\\Settings\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
32
-        'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/..' . '/../lib/BackgroundJobs/VerifyUserData.php',
33
-        'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AdminSettingsController.php',
34
-        'OCA\\Settings\\Controller\\AppSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AppSettingsController.php',
35
-        'OCA\\Settings\\Controller\\AuthSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AuthSettingsController.php',
36
-        'OCA\\Settings\\Controller\\ChangePasswordController' => __DIR__ . '/..' . '/../lib/Controller/ChangePasswordController.php',
37
-        'OCA\\Settings\\Controller\\CheckSetupController' => __DIR__ . '/..' . '/../lib/Controller/CheckSetupController.php',
38
-        'OCA\\Settings\\Controller\\CommonSettingsTrait' => __DIR__ . '/..' . '/../lib/Controller/CommonSettingsTrait.php',
39
-        'OCA\\Settings\\Controller\\HelpController' => __DIR__ . '/..' . '/../lib/Controller/HelpController.php',
40
-        'OCA\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/..' . '/../lib/Controller/LogSettingsController.php',
41
-        'OCA\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/..' . '/../lib/Controller/MailSettingsController.php',
42
-        'OCA\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/..' . '/../lib/Controller/PersonalSettingsController.php',
43
-        'OCA\\Settings\\Controller\\ReasonsController' => __DIR__ . '/..' . '/../lib/Controller/ReasonsController.php',
44
-        'OCA\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__ . '/..' . '/../lib/Controller/TwoFactorSettingsController.php',
45
-        'OCA\\Settings\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
46
-        'OCA\\Settings\\Controller\\WebAuthnController' => __DIR__ . '/..' . '/../lib/Controller/WebAuthnController.php',
47
-        'OCA\\Settings\\Events\\BeforeTemplateRenderedEvent' => __DIR__ . '/..' . '/../lib/Events/BeforeTemplateRenderedEvent.php',
48
-        'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
49
-        'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php',
50
-        'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
51
-        'OCA\\Settings\\Search\\AppSearch' => __DIR__ . '/..' . '/../lib/Search/AppSearch.php',
52
-        'OCA\\Settings\\Search\\SectionSearch' => __DIR__ . '/..' . '/../lib/Search/SectionSearch.php',
53
-        'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
54
-        'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php',
55
-        'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php',
56
-        'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Sections/Admin/Security.php',
57
-        'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Sections/Admin/Server.php',
58
-        'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Sections/Admin/Sharing.php',
59
-        'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
60
-        'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php',
61
-        'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php',
62
-        'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php',
63
-        'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php',
64
-        'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php',
65
-        'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php',
66
-        'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php',
67
-        'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
68
-        'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
69
-        'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
70
-        'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
71
-        'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
72
-        'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php',
73
-        'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
74
-        'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__ . '/..' . '/../lib/SetupChecks/CheckUserCertificates.php',
75
-        'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
76
-        'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
77
-        'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
23
+    public static $classMap = array(
24
+        'OCA\\Settings\\Activity\\GroupProvider' => __DIR__.'/..'.'/../lib/Activity/GroupProvider.php',
25
+        'OCA\\Settings\\Activity\\GroupSetting' => __DIR__.'/..'.'/../lib/Activity/GroupSetting.php',
26
+        'OCA\\Settings\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php',
27
+        'OCA\\Settings\\Activity\\SecurityFilter' => __DIR__.'/..'.'/../lib/Activity/SecurityFilter.php',
28
+        'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__.'/..'.'/../lib/Activity/SecurityProvider.php',
29
+        'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__.'/..'.'/../lib/Activity/SecuritySetting.php',
30
+        'OCA\\Settings\\Activity\\Setting' => __DIR__.'/..'.'/../lib/Activity/Setting.php',
31
+        'OCA\\Settings\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
32
+        'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__.'/..'.'/../lib/BackgroundJobs/VerifyUserData.php',
33
+        'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__.'/..'.'/../lib/Controller/AdminSettingsController.php',
34
+        'OCA\\Settings\\Controller\\AppSettingsController' => __DIR__.'/..'.'/../lib/Controller/AppSettingsController.php',
35
+        'OCA\\Settings\\Controller\\AuthSettingsController' => __DIR__.'/..'.'/../lib/Controller/AuthSettingsController.php',
36
+        'OCA\\Settings\\Controller\\ChangePasswordController' => __DIR__.'/..'.'/../lib/Controller/ChangePasswordController.php',
37
+        'OCA\\Settings\\Controller\\CheckSetupController' => __DIR__.'/..'.'/../lib/Controller/CheckSetupController.php',
38
+        'OCA\\Settings\\Controller\\CommonSettingsTrait' => __DIR__.'/..'.'/../lib/Controller/CommonSettingsTrait.php',
39
+        'OCA\\Settings\\Controller\\HelpController' => __DIR__.'/..'.'/../lib/Controller/HelpController.php',
40
+        'OCA\\Settings\\Controller\\LogSettingsController' => __DIR__.'/..'.'/../lib/Controller/LogSettingsController.php',
41
+        'OCA\\Settings\\Controller\\MailSettingsController' => __DIR__.'/..'.'/../lib/Controller/MailSettingsController.php',
42
+        'OCA\\Settings\\Controller\\PersonalSettingsController' => __DIR__.'/..'.'/../lib/Controller/PersonalSettingsController.php',
43
+        'OCA\\Settings\\Controller\\ReasonsController' => __DIR__.'/..'.'/../lib/Controller/ReasonsController.php',
44
+        'OCA\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__.'/..'.'/../lib/Controller/TwoFactorSettingsController.php',
45
+        'OCA\\Settings\\Controller\\UsersController' => __DIR__.'/..'.'/../lib/Controller/UsersController.php',
46
+        'OCA\\Settings\\Controller\\WebAuthnController' => __DIR__.'/..'.'/../lib/Controller/WebAuthnController.php',
47
+        'OCA\\Settings\\Events\\BeforeTemplateRenderedEvent' => __DIR__.'/..'.'/../lib/Events/BeforeTemplateRenderedEvent.php',
48
+        'OCA\\Settings\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php',
49
+        'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__.'/..'.'/../lib/Mailer/NewUserMailHelper.php',
50
+        'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__.'/..'.'/../lib/Middleware/SubadminMiddleware.php',
51
+        'OCA\\Settings\\Search\\AppSearch' => __DIR__.'/..'.'/../lib/Search/AppSearch.php',
52
+        'OCA\\Settings\\Search\\SectionSearch' => __DIR__.'/..'.'/../lib/Search/SectionSearch.php',
53
+        'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__.'/..'.'/../lib/Sections/Admin/Additional.php',
54
+        'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__.'/..'.'/../lib/Sections/Admin/Groupware.php',
55
+        'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__.'/..'.'/../lib/Sections/Admin/Overview.php',
56
+        'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__.'/..'.'/../lib/Sections/Admin/Security.php',
57
+        'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__.'/..'.'/../lib/Sections/Admin/Server.php',
58
+        'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__.'/..'.'/../lib/Sections/Admin/Sharing.php',
59
+        'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__.'/..'.'/../lib/Sections/Personal/PersonalInfo.php',
60
+        'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__.'/..'.'/../lib/Sections/Personal/Security.php',
61
+        'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__.'/..'.'/../lib/Sections/Personal/SyncClients.php',
62
+        'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__.'/..'.'/../lib/Settings/Admin/Mail.php',
63
+        'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__.'/..'.'/../lib/Settings/Admin/Overview.php',
64
+        'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__.'/..'.'/../lib/Settings/Admin/Security.php',
65
+        'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__.'/..'.'/../lib/Settings/Admin/Server.php',
66
+        'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__.'/..'.'/../lib/Settings/Admin/Sharing.php',
67
+        'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__.'/..'.'/../lib/Settings/Personal/Additional.php',
68
+        'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__.'/..'.'/../lib/Settings/Personal/PersonalInfo.php',
69
+        'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/Authtokens.php',
70
+        'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/Password.php',
71
+        'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/TwoFactor.php',
72
+        'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/WebAuthn.php',
73
+        'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__.'/..'.'/../lib/Settings/Personal/ServerDevNotice.php',
74
+        'OCA\\Settings\\SetupChecks\\CheckUserCertificates' => __DIR__.'/..'.'/../lib/SetupChecks/CheckUserCertificates.php',
75
+        'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__.'/..'.'/../lib/SetupChecks/LegacySSEKeyFormat.php',
76
+        'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__.'/..'.'/../lib/SetupChecks/PhpDefaultCharset.php',
77
+        'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__.'/..'.'/../lib/SetupChecks/PhpOutputBuffering.php',
78 78
     );
79 79
 
80 80
     public static function getInitializer(ClassLoader $loader)
81 81
     {
82
-        return \Closure::bind(function () use ($loader) {
82
+        return \Closure::bind(function() use ($loader) {
83 83
             $loader->prefixLengthsPsr4 = ComposerStaticInitSettings::$prefixLengthsPsr4;
84 84
             $loader->prefixDirsPsr4 = ComposerStaticInitSettings::$prefixDirsPsr4;
85 85
             $loader->classMap = ComposerStaticInitSettings::$classMap;
Please login to merge, or discard this patch.