Passed
Push — master ( 25ab12...62403d )
by Blizzz
12:17 queued 22s
created
apps/encryption/templates/settings-admin.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -9,10 +9,13 @@  discard block
 block discarded – undo
9 9
 	<h3><?php p($l->t("Default encryption module")); ?></h3>
10 10
 	<?php if(!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?>
11 11
 		<?php p($l->t("Encryption app is enabled but your keys are not initialized, please log-out and log-in again")); ?>
12
-	<?php else: ?>
12
+	<?php else {
13
+    : ?>
13 14
 		<p id="encryptHomeStorageSetting">
14 15
 			<input type="checkbox" class="checkbox" name="encrypt_home_storage" id="encryptHomeStorage"
15
-				   value="1" <?php if ($_['encryptHomeStorage']) print_unescaped('checked="checked"'); ?> />
16
+				   value="1" <?php if ($_['encryptHomeStorage']) print_unescaped('checked="checked"');
17
+}
18
+?> />
16 19
 			<label for="encryptHomeStorage"><?php p($l->t('Encrypt the home storage'));?></label></br>
17 20
 			<em><?php p( $l->t( "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" ) ); ?></em>
18 21
 		</p>
@@ -42,7 +45,10 @@  discard block
 block discarded – undo
42 45
 			</p>
43 46
 			<br/><br/>
44 47
 
45
-			<p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>>
48
+			<p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') {
49
+    print_unescaped('class="hidden"');
50
+}
51
+?>>
46 52
 				<?php p($l->t("Change recovery key password:")); ?>
47 53
 				<span class="msg"></span>
48 54
 				<br/>
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
 ?>
8 8
 <form id="ocDefaultEncryptionModule" class="sub-section">
9 9
 	<h3><?php p($l->t("Default encryption module")); ?></h3>
10
-	<?php if(!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?>
10
+	<?php if (!$_["initStatus"] && $_['masterKeyEnabled'] === false): ?>
11 11
 		<?php p($l->t("Encryption app is enabled but your keys are not initialized, please log-out and log-in again")); ?>
12 12
 	<?php else: ?>
13 13
 		<p id="encryptHomeStorageSetting">
14 14
 			<input type="checkbox" class="checkbox" name="encrypt_home_storage" id="encryptHomeStorage"
15 15
 				   value="1" <?php if ($_['encryptHomeStorage']) print_unescaped('checked="checked"'); ?> />
16
-			<label for="encryptHomeStorage"><?php p($l->t('Encrypt the home storage'));?></label></br>
17
-			<em><?php p( $l->t( "Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted" ) ); ?></em>
16
+			<label for="encryptHomeStorage"><?php p($l->t('Encrypt the home storage')); ?></label></br>
17
+			<em><?php p($l->t("Enabling this option encrypts all files stored on the main storage, otherwise only files on external storage will be encrypted")); ?></em>
18 18
 		</p>
19 19
 		<br />
20
-		<?php if($_['masterKeyEnabled'] === false): ?>
20
+		<?php if ($_['masterKeyEnabled'] === false): ?>
21 21
 			<p id="encryptionSetRecoveryKey">
22 22
 				<?php $_["recoveryEnabled"] === '0' ?  p($l->t("Enable recovery key")) : p($l->t("Disable recovery key")); ?>
23 23
 				<span class="msg"></span>
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 			</p>
43 43
 			<br/><br/>
44 44
 
45
-			<p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"');?>>
45
+			<p name="changeRecoveryPasswordBlock" id="encryptionChangeRecoveryKey" <?php if ($_['recoveryEnabled'] === '0') print_unescaped('class="hidden"'); ?>>
46 46
 				<?php p($l->t("Change recovery key password:")); ?>
47 47
 				<span class="msg"></span>
48 48
 				<br/>
Please login to merge, or discard this patch.
apps/encryption/lib/Migration/SetMasterKeyStatus.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -35,43 +35,43 @@
 block discarded – undo
35 35
 class SetMasterKeyStatus implements IRepairStep {
36 36
 
37 37
 
38
-	/** @var  IConfig */
39
-	private $config;
38
+    /** @var  IConfig */
39
+    private $config;
40 40
 
41 41
 
42
-	public function __construct(IConfig $config) {
43
-		$this->config = $config;
44
-	}
42
+    public function __construct(IConfig $config) {
43
+        $this->config = $config;
44
+    }
45 45
 
46
-	/**
47
-	 * Returns the step's name
48
-	 *
49
-	 * @return string
50
-	 * @since 9.1.0
51
-	 */
52
-	public function getName() {
53
-		return 'Write default encryption module configuration to the database';
54
-	}
46
+    /**
47
+     * Returns the step's name
48
+     *
49
+     * @return string
50
+     * @since 9.1.0
51
+     */
52
+    public function getName() {
53
+        return 'Write default encryption module configuration to the database';
54
+    }
55 55
 
56
-	/**
57
-	 * @param IOutput $output
58
-	 */
59
-	public function run(IOutput $output) {
60
-		if (!$this->shouldRun()) {
61
-			return;
62
-		}
56
+    /**
57
+     * @param IOutput $output
58
+     */
59
+    public function run(IOutput $output) {
60
+        if (!$this->shouldRun()) {
61
+            return;
62
+        }
63 63
 
64
-		// if no config for the master key is set we set it explicitly to '0' in
65
-		// order not to break old installations because the default changed to '1'.
66
-		$configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false);
67
-		if ($configAlreadySet === false) {
68
-			$this->config->setAppValue('encryption', 'useMasterKey', '0');
69
-		}
70
-	}
64
+        // if no config for the master key is set we set it explicitly to '0' in
65
+        // order not to break old installations because the default changed to '1'.
66
+        $configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false);
67
+        if ($configAlreadySet === false) {
68
+            $this->config->setAppValue('encryption', 'useMasterKey', '0');
69
+        }
70
+    }
71 71
 
72
-	protected function shouldRun() {
73
-		$appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0');
74
-		return version_compare($appVersion, '2.0.0', '<');
75
-	}
72
+    protected function shouldRun() {
73
+        $appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0');
74
+        return version_compare($appVersion, '2.0.0', '<');
75
+    }
76 76
 
77 77
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Command/DisableMasterKey.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
 
68 68
 		$isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
69 69
 
70
-		if(!$isMasterKeyEnabled) {
70
+		if (!$isMasterKeyEnabled) {
71 71
 			$output->writeln('Master key already disabled');
72 72
 		} else {
73 73
 			$question = new ConfirmationQuestion(
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -34,57 +34,57 @@
 block discarded – undo
34 34
 
35 35
 class DisableMasterKey extends Command {
36 36
 
37
-	/** @var Util */
38
-	protected $util;
37
+    /** @var Util */
38
+    protected $util;
39 39
 
40
-	/** @var IConfig */
41
-	protected $config;
40
+    /** @var IConfig */
41
+    protected $config;
42 42
 
43
-	/** @var  QuestionHelper */
44
-	protected $questionHelper;
43
+    /** @var  QuestionHelper */
44
+    protected $questionHelper;
45 45
 
46
-	/**
47
-	 * @param Util $util
48
-	 * @param IConfig $config
49
-	 * @param QuestionHelper $questionHelper
50
-	 */
51
-	public function __construct(Util $util,
52
-								IConfig $config,
53
-								QuestionHelper $questionHelper) {
46
+    /**
47
+     * @param Util $util
48
+     * @param IConfig $config
49
+     * @param QuestionHelper $questionHelper
50
+     */
51
+    public function __construct(Util $util,
52
+                                IConfig $config,
53
+                                QuestionHelper $questionHelper) {
54 54
 
55
-		$this->util = $util;
56
-		$this->config = $config;
57
-		$this->questionHelper = $questionHelper;
58
-		parent::__construct();
59
-	}
55
+        $this->util = $util;
56
+        $this->config = $config;
57
+        $this->questionHelper = $questionHelper;
58
+        parent::__construct();
59
+    }
60 60
 
61
-	protected function configure() {
62
-		$this
63
-			->setName('encryption:disable-master-key')
64
-			->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.');
65
-	}
61
+    protected function configure() {
62
+        $this
63
+            ->setName('encryption:disable-master-key')
64
+            ->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.');
65
+    }
66 66
 
67
-	protected function execute(InputInterface $input, OutputInterface $output) {
67
+    protected function execute(InputInterface $input, OutputInterface $output) {
68 68
 
69
-		$isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
69
+        $isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
70 70
 
71
-		if(!$isMasterKeyEnabled) {
72
-			$output->writeln('Master key already disabled');
73
-		} else {
74
-			$question = new ConfirmationQuestion(
75
-				'Warning: Only perform this operation for a fresh installations with no existing encrypted data! '
76
-				. 'There is no way to enable the master key again. '
77
-				. 'We strongly recommend to keep the master key, it provides significant performance improvements '
78
-				. 'and is easier to handle for both, users and administrators. '
79
-				. 'Do you really want to switch to per-user keys? (y/n) ', false);
80
-			if ($this->questionHelper->ask($input, $output, $question)) {
81
-				$this->config->setAppValue('encryption', 'useMasterKey', '0');
82
-				$output->writeln('Master key successfully disabled.');
83
-			} else {
84
-				$output->writeln('aborted.');
85
-			}
86
-		}
71
+        if(!$isMasterKeyEnabled) {
72
+            $output->writeln('Master key already disabled');
73
+        } else {
74
+            $question = new ConfirmationQuestion(
75
+                'Warning: Only perform this operation for a fresh installations with no existing encrypted data! '
76
+                . 'There is no way to enable the master key again. '
77
+                . 'We strongly recommend to keep the master key, it provides significant performance improvements '
78
+                . 'and is easier to handle for both, users and administrators. '
79
+                . 'Do you really want to switch to per-user keys? (y/n) ', false);
80
+            if ($this->questionHelper->ask($input, $output, $question)) {
81
+                $this->config->setAppValue('encryption', 'useMasterKey', '0');
82
+                $output->writeln('Master key successfully disabled.');
83
+            } else {
84
+                $output->writeln('aborted.');
85
+            }
86
+        }
87 87
 
88
-	}
88
+    }
89 89
 
90 90
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Settings/Personal.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -32,72 +32,72 @@
 block discarded – undo
32 32
 
33 33
 class Personal implements ISettings {
34 34
 
35
-	/** @var IManager */
36
-	private $encryptionManager;
35
+    /** @var IManager */
36
+    private $encryptionManager;
37 37
 
38
-	/** @var UserGlobalStoragesService */
39
-	private $userGlobalStoragesService;
38
+    /** @var UserGlobalStoragesService */
39
+    private $userGlobalStoragesService;
40 40
 
41
-	/** @var BackendService */
42
-	private $backendService;
41
+    /** @var BackendService */
42
+    private $backendService;
43 43
 
44
-	/** @var GlobalAuth	 */
45
-	private $globalAuth;
44
+    /** @var GlobalAuth	 */
45
+    private $globalAuth;
46 46
 
47
-	/** @var IUserSession */
48
-	private $userSession;
47
+    /** @var IUserSession */
48
+    private $userSession;
49 49
 
50
-	public function __construct(
51
-		IManager $encryptionManager,
52
-		UserGlobalStoragesService $userGlobalStoragesService,
53
-		BackendService $backendService,
54
-		GlobalAuth $globalAuth,
55
-		IUserSession $userSession
56
-	) {
57
-		$this->encryptionManager = $encryptionManager;
58
-		$this->userGlobalStoragesService = $userGlobalStoragesService;
59
-		$this->backendService = $backendService;
60
-		$this->globalAuth = $globalAuth;
61
-		$this->userSession = $userSession;
62
-	}
50
+    public function __construct(
51
+        IManager $encryptionManager,
52
+        UserGlobalStoragesService $userGlobalStoragesService,
53
+        BackendService $backendService,
54
+        GlobalAuth $globalAuth,
55
+        IUserSession $userSession
56
+    ) {
57
+        $this->encryptionManager = $encryptionManager;
58
+        $this->userGlobalStoragesService = $userGlobalStoragesService;
59
+        $this->backendService = $backendService;
60
+        $this->globalAuth = $globalAuth;
61
+        $this->userSession = $userSession;
62
+    }
63 63
 
64
-	/**
65
-	 * @return TemplateResponse
66
-	 */
67
-	public function getForm() {
68
-		$uid = $this->userSession->getUser()->getUID();
64
+    /**
65
+     * @return TemplateResponse
66
+     */
67
+    public function getForm() {
68
+        $uid = $this->userSession->getUser()->getUID();
69 69
 
70
-		$parameters = [
71
-			'encryptionEnabled'    => $this->encryptionManager->isEnabled(),
72
-			'visibilityType'       => BackendService::VISIBILITY_PERSONAL,
73
-			'storages'             => $this->userGlobalStoragesService->getStorages(),
74
-			'backends'             => $this->backendService->getAvailableBackends(),
75
-			'authMechanisms'       => $this->backendService->getAuthMechanisms(),
76
-			'dependencies'         => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()),
77
-			'allowUserMounting'    => $this->backendService->isUserMountingAllowed(),
78
-			'globalCredentials'    => $this->globalAuth->getAuth($uid),
79
-			'globalCredentialsUid' => $uid,
80
-		];
70
+        $parameters = [
71
+            'encryptionEnabled'    => $this->encryptionManager->isEnabled(),
72
+            'visibilityType'       => BackendService::VISIBILITY_PERSONAL,
73
+            'storages'             => $this->userGlobalStoragesService->getStorages(),
74
+            'backends'             => $this->backendService->getAvailableBackends(),
75
+            'authMechanisms'       => $this->backendService->getAuthMechanisms(),
76
+            'dependencies'         => \OC_Mount_Config::dependencyMessage($this->backendService->getBackends()),
77
+            'allowUserMounting'    => $this->backendService->isUserMountingAllowed(),
78
+            'globalCredentials'    => $this->globalAuth->getAuth($uid),
79
+            'globalCredentialsUid' => $uid,
80
+        ];
81 81
 
82
-		return new TemplateResponse('files_external', 'settings', $parameters, '');
83
-	}
82
+        return new TemplateResponse('files_external', 'settings', $parameters, '');
83
+    }
84 84
 
85
-	/**
86
-	 * @return string the section ID, e.g. 'sharing'
87
-	 */
88
-	public function getSection() {
89
-		return 'externalstorages';
90
-	}
85
+    /**
86
+     * @return string the section ID, e.g. 'sharing'
87
+     */
88
+    public function getSection() {
89
+        return 'externalstorages';
90
+    }
91 91
 
92
-	/**
93
-	 * @return int whether the form should be rather on the top or bottom of
94
-	 * the admin section. The forms are arranged in ascending order of the
95
-	 * priority values. It is required to return a value between 0 and 100.
96
-	 *
97
-	 * E.g.: 70
98
-	 */
99
-	public function getPriority() {
100
-		return 40;
101
-	}
92
+    /**
93
+     * @return int whether the form should be rather on the top or bottom of
94
+     * the admin section. The forms are arranged in ascending order of the
95
+     * priority values. It is required to return a value between 0 and 100.
96
+     *
97
+     * E.g.: 70
98
+     */
99
+    public function getPriority() {
100
+        return 40;
101
+    }
102 102
 
103 103
 }
Please login to merge, or discard this patch.
core/Command/Db/Migrations/ExecuteCommand.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 			$olderVersions = $ms->getMigratedVersions();
79 79
 			$olderVersions[] = '0';
80 80
 			$olderVersions[] = 'prev';
81
-			if (in_array($version,  $olderVersions, true)) {
81
+			if (in_array($version, $olderVersions, true)) {
82 82
 				$output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
83 83
 				return 1;
84 84
 			}
Please login to merge, or discard this patch.
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -38,95 +38,95 @@
 block discarded – undo
38 38
 
39 39
 class ExecuteCommand extends Command implements CompletionAwareInterface {
40 40
 
41
-	/** @var IDBConnection */
42
-	private $connection;
43
-
44
-	/** @var IConfig */
45
-	private $config;
46
-
47
-	/** @var IAppManager */
48
-	protected $appManager;
49
-
50
-	/**
51
-	 * ExecuteCommand constructor.
52
-	 *
53
-	 * @param IDBConnection $connection
54
-	 * @param IConfig $config
55
-	 * @param IAppManager $appManager
56
-	 */
57
-	public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) {
58
-		$this->connection = $connection;
59
-		$this->config = $config;
60
-
61
-		parent::__construct();
62
-	}
63
-
64
-	protected function configure() {
65
-		$this
66
-			->setName('migrations:execute')
67
-			->setDescription('Execute a single migration version manually.')
68
-			->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
69
-			->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null);
70
-
71
-		parent::configure();
72
-	}
73
-
74
-	/**
75
-	 * @param InputInterface $input
76
-	 * @param OutputInterface $output
77
-	 * @return int
78
-	 */
79
-	public function execute(InputInterface $input, OutputInterface $output) {
80
-		$appName = $input->getArgument('app');
81
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
82
-		$version = $input->getArgument('version');
83
-
84
-		if ($this->config->getSystemValue('debug', false) === false) {
85
-			$olderVersions = $ms->getMigratedVersions();
86
-			$olderVersions[] = '0';
87
-			$olderVersions[] = 'prev';
88
-			if (in_array($version,  $olderVersions, true)) {
89
-				$output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
90
-				return 1;
91
-			}
92
-		}
93
-
94
-
95
-		$ms->executeStep($version);
96
-		return 0;
97
-	}
98
-
99
-	/**
100
-	 * @param string $optionName
101
-	 * @param CompletionContext $context
102
-	 * @return string[]
103
-	 */
104
-	public function completeOptionValues($optionName, CompletionContext $context) {
105
-		return [];
106
-	}
107
-
108
-	/**
109
-	 * @param string $argumentName
110
-	 * @param CompletionContext $context
111
-	 * @return string[]
112
-	 */
113
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
114
-		if ($argumentName === 'app') {
115
-			$allApps = \OC_App::getAllApps();
116
-			return array_diff($allApps, \OC_App::getEnabledApps(true, true));
117
-		}
118
-
119
-		if ($argumentName === 'version') {
120
-			$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
121
-
122
-			$ms = new MigrationService($appName, $this->connection);
123
-			$migrations = $ms->getAvailableVersions();
124
-
125
-			array_unshift($migrations, 'next', 'latest');
126
-			return $migrations;
127
-		}
128
-
129
-		return [];
130
-	}
41
+    /** @var IDBConnection */
42
+    private $connection;
43
+
44
+    /** @var IConfig */
45
+    private $config;
46
+
47
+    /** @var IAppManager */
48
+    protected $appManager;
49
+
50
+    /**
51
+     * ExecuteCommand constructor.
52
+     *
53
+     * @param IDBConnection $connection
54
+     * @param IConfig $config
55
+     * @param IAppManager $appManager
56
+     */
57
+    public function __construct(IDBConnection $connection, IAppManager $appManager, IConfig $config) {
58
+        $this->connection = $connection;
59
+        $this->config = $config;
60
+
61
+        parent::__construct();
62
+    }
63
+
64
+    protected function configure() {
65
+        $this
66
+            ->setName('migrations:execute')
67
+            ->setDescription('Execute a single migration version manually.')
68
+            ->addArgument('app', InputArgument::REQUIRED, 'Name of the app this migration command shall work on')
69
+            ->addArgument('version', InputArgument::REQUIRED, 'The version to execute.', null);
70
+
71
+        parent::configure();
72
+    }
73
+
74
+    /**
75
+     * @param InputInterface $input
76
+     * @param OutputInterface $output
77
+     * @return int
78
+     */
79
+    public function execute(InputInterface $input, OutputInterface $output) {
80
+        $appName = $input->getArgument('app');
81
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
82
+        $version = $input->getArgument('version');
83
+
84
+        if ($this->config->getSystemValue('debug', false) === false) {
85
+            $olderVersions = $ms->getMigratedVersions();
86
+            $olderVersions[] = '0';
87
+            $olderVersions[] = 'prev';
88
+            if (in_array($version,  $olderVersions, true)) {
89
+                $output->writeln('<error>Can not go back to previous migration without debug enabled</error>');
90
+                return 1;
91
+            }
92
+        }
93
+
94
+
95
+        $ms->executeStep($version);
96
+        return 0;
97
+    }
98
+
99
+    /**
100
+     * @param string $optionName
101
+     * @param CompletionContext $context
102
+     * @return string[]
103
+     */
104
+    public function completeOptionValues($optionName, CompletionContext $context) {
105
+        return [];
106
+    }
107
+
108
+    /**
109
+     * @param string $argumentName
110
+     * @param CompletionContext $context
111
+     * @return string[]
112
+     */
113
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
114
+        if ($argumentName === 'app') {
115
+            $allApps = \OC_App::getAllApps();
116
+            return array_diff($allApps, \OC_App::getEnabledApps(true, true));
117
+        }
118
+
119
+        if ($argumentName === 'version') {
120
+            $appName = $context->getWordAtIndex($context->getWordIndex() - 1);
121
+
122
+            $ms = new MigrationService($appName, $this->connection);
123
+            $migrations = $ms->getAvailableVersions();
124
+
125
+            array_unshift($migrations, 'next', 'latest');
126
+            return $migrations;
127
+        }
128
+
129
+        return [];
130
+    }
131 131
 
132 132
 }
Please login to merge, or discard this patch.
lib/private/DB/OracleConnection.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -26,80 +26,80 @@
 block discarded – undo
26 26
 namespace OC\DB;
27 27
 
28 28
 class OracleConnection extends Connection {
29
-	/**
30
-	 * Quote the keys of the array
31
-	 */
32
-	private function quoteKeys(array $data) {
33
-		$return = [];
34
-		$c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter();
35
-		foreach($data as $key => $value) {
36
-			if ($key[0] !== $c) {
37
-				$return[$this->quoteIdentifier($key)] = $value;
38
-			} else {
39
-				$return[$key] = $value;
40
-			}
41
-		}
42
-		return $return;
43
-	}
29
+    /**
30
+     * Quote the keys of the array
31
+     */
32
+    private function quoteKeys(array $data) {
33
+        $return = [];
34
+        $c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter();
35
+        foreach($data as $key => $value) {
36
+            if ($key[0] !== $c) {
37
+                $return[$this->quoteIdentifier($key)] = $value;
38
+            } else {
39
+                $return[$key] = $value;
40
+            }
41
+        }
42
+        return $return;
43
+    }
44 44
 
45
-	/**
46
-	 * {@inheritDoc}
47
-	 */
48
-	public function insert($tableName, array $data, array $types = array()) {
49
-		if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
50
-			$tableName = $this->quoteIdentifier($tableName);
51
-		}
52
-		$data = $this->quoteKeys($data);
53
-		return parent::insert($tableName, $data, $types);
54
-	}
45
+    /**
46
+     * {@inheritDoc}
47
+     */
48
+    public function insert($tableName, array $data, array $types = array()) {
49
+        if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
50
+            $tableName = $this->quoteIdentifier($tableName);
51
+        }
52
+        $data = $this->quoteKeys($data);
53
+        return parent::insert($tableName, $data, $types);
54
+    }
55 55
 
56
-	/**
57
-	 * {@inheritDoc}
58
-	 */
59
-	public function update($tableName, array $data, array $identifier, array $types = array()) {
60
-		if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
61
-			$tableName = $this->quoteIdentifier($tableName);
62
-		}
63
-		$data = $this->quoteKeys($data);
64
-		$identifier = $this->quoteKeys($identifier);
65
-		return parent::update($tableName, $data, $identifier, $types);
66
-	}
56
+    /**
57
+     * {@inheritDoc}
58
+     */
59
+    public function update($tableName, array $data, array $identifier, array $types = array()) {
60
+        if ($tableName[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
61
+            $tableName = $this->quoteIdentifier($tableName);
62
+        }
63
+        $data = $this->quoteKeys($data);
64
+        $identifier = $this->quoteKeys($identifier);
65
+        return parent::update($tableName, $data, $identifier, $types);
66
+    }
67 67
 
68
-	/**
69
-	 * {@inheritDoc}
70
-	 */
71
-	public function delete($tableExpression, array $identifier, array $types = array()) {
72
-		if ($tableExpression[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
73
-			$tableExpression = $this->quoteIdentifier($tableExpression);
74
-		}
75
-		$identifier = $this->quoteKeys($identifier);
76
-		return parent::delete($tableExpression, $identifier);
77
-	}
68
+    /**
69
+     * {@inheritDoc}
70
+     */
71
+    public function delete($tableExpression, array $identifier, array $types = array()) {
72
+        if ($tableExpression[0] !== $this->getDatabasePlatform()->getIdentifierQuoteCharacter()) {
73
+            $tableExpression = $this->quoteIdentifier($tableExpression);
74
+        }
75
+        $identifier = $this->quoteKeys($identifier);
76
+        return parent::delete($tableExpression, $identifier);
77
+    }
78 78
 
79
-	/**
80
-	 * Drop a table from the database if it exists
81
-	 *
82
-	 * @param string $table table name without the prefix
83
-	 */
84
-	public function dropTable($table) {
85
-		$table = $this->tablePrefix . trim($table);
86
-		$table = $this->quoteIdentifier($table);
87
-		$schema = $this->getSchemaManager();
88
-		if($schema->tablesExist(array($table))) {
89
-			$schema->dropTable($table);
90
-		}
91
-	}
79
+    /**
80
+     * Drop a table from the database if it exists
81
+     *
82
+     * @param string $table table name without the prefix
83
+     */
84
+    public function dropTable($table) {
85
+        $table = $this->tablePrefix . trim($table);
86
+        $table = $this->quoteIdentifier($table);
87
+        $schema = $this->getSchemaManager();
88
+        if($schema->tablesExist(array($table))) {
89
+            $schema->dropTable($table);
90
+        }
91
+    }
92 92
 
93
-	/**
94
-	 * Check if a table exists
95
-	 *
96
-	 * @param string $table table name without the prefix
97
-	 * @return bool
98
-	 */
99
-	public function tableExists($table){
100
-		$table = $this->tablePrefix . trim($table);
101
-		$table = $this->quoteIdentifier($table);
102
-		$schema = $this->getSchemaManager();
103
-		return $schema->tablesExist(array($table));
104
-	}
93
+    /**
94
+     * Check if a table exists
95
+     *
96
+     * @param string $table table name without the prefix
97
+     * @return bool
98
+     */
99
+    public function tableExists($table){
100
+        $table = $this->tablePrefix . trim($table);
101
+        $table = $this->quoteIdentifier($table);
102
+        $schema = $this->getSchemaManager();
103
+        return $schema->tablesExist(array($table));
104
+    }
105 105
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	private function quoteKeys(array $data) {
33 33
 		$return = [];
34 34
 		$c = $this->getDatabasePlatform()->getIdentifierQuoteCharacter();
35
-		foreach($data as $key => $value) {
35
+		foreach ($data as $key => $value) {
36 36
 			if ($key[0] !== $c) {
37 37
 				$return[$this->quoteIdentifier($key)] = $value;
38 38
 			} else {
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @param string $table table name without the prefix
83 83
 	 */
84 84
 	public function dropTable($table) {
85
-		$table = $this->tablePrefix . trim($table);
85
+		$table = $this->tablePrefix.trim($table);
86 86
 		$table = $this->quoteIdentifier($table);
87 87
 		$schema = $this->getSchemaManager();
88
-		if($schema->tablesExist(array($table))) {
88
+		if ($schema->tablesExist(array($table))) {
89 89
 			$schema->dropTable($table);
90 90
 		}
91 91
 	}
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @param string $table table name without the prefix
97 97
 	 * @return bool
98 98
 	 */
99
-	public function tableExists($table){
100
-		$table = $this->tablePrefix . trim($table);
99
+	public function tableExists($table) {
100
+		$table = $this->tablePrefix.trim($table);
101 101
 		$table = $this->quoteIdentifier($table);
102 102
 		$schema = $this->getSchemaManager();
103 103
 		return $schema->tablesExist(array($table));
Please login to merge, or discard this patch.
lib/private/Migration/SimpleOutput.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -36,49 +36,49 @@
 block discarded – undo
36 36
  */
37 37
 class SimpleOutput implements IOutput {
38 38
 
39
-	/** @var ILogger */
40
-	private $logger;
41
-	private $appName;
39
+    /** @var ILogger */
40
+    private $logger;
41
+    private $appName;
42 42
 
43
-	public function __construct(ILogger $logger, $appName) {
44
-		$this->logger = $logger;
45
-		$this->appName = $appName;
46
-	}
43
+    public function __construct(ILogger $logger, $appName) {
44
+        $this->logger = $logger;
45
+        $this->appName = $appName;
46
+    }
47 47
 
48
-	/**
49
-	 * @param string $message
50
-	 * @since 9.1.0
51
-	 */
52
-	public function info($message) {
53
-		$this->logger->info($message, ['app' => $this->appName]);
54
-	}
48
+    /**
49
+     * @param string $message
50
+     * @since 9.1.0
51
+     */
52
+    public function info($message) {
53
+        $this->logger->info($message, ['app' => $this->appName]);
54
+    }
55 55
 
56
-	/**
57
-	 * @param string $message
58
-	 * @since 9.1.0
59
-	 */
60
-	public function warning($message) {
61
-		$this->logger->warning($message, ['app' => $this->appName]);
62
-	}
56
+    /**
57
+     * @param string $message
58
+     * @since 9.1.0
59
+     */
60
+    public function warning($message) {
61
+        $this->logger->warning($message, ['app' => $this->appName]);
62
+    }
63 63
 
64
-	/**
65
-	 * @param int $max
66
-	 * @since 9.1.0
67
-	 */
68
-	public function startProgress($max = 0) {
69
-	}
64
+    /**
65
+     * @param int $max
66
+     * @since 9.1.0
67
+     */
68
+    public function startProgress($max = 0) {
69
+    }
70 70
 
71
-	/**
72
-	 * @param int $step
73
-	 * @param string $description
74
-	 * @since 9.1.0
75
-	 */
76
-	public function advance($step = 1, $description = '') {
77
-	}
71
+    /**
72
+     * @param int $step
73
+     * @param string $description
74
+     * @since 9.1.0
75
+     */
76
+    public function advance($step = 1, $description = '') {
77
+    }
78 78
 
79
-	/**
80
-	 * @since 9.1.0
81
-	 */
82
-	public function finishProgress() {
83
-	}
79
+    /**
80
+     * @since 9.1.0
81
+     */
82
+    public function finishProgress() {
83
+    }
84 84
 }
Please login to merge, or discard this patch.
lib/private/DB/SchemaWrapper.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @throws \Doctrine\DBAL\Schema\SchemaException
81 81
 	 */
82 82
 	public function getTable($tableName) {
83
-		return $this->schema->getTable($this->connection->getPrefix() . $tableName);
83
+		return $this->schema->getTable($this->connection->getPrefix().$tableName);
84 84
 	}
85 85
 
86 86
 	/**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return boolean
92 92
 	 */
93 93
 	public function hasTable($tableName) {
94
-		return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
94
+		return $this->schema->hasTable($this->connection->getPrefix().$tableName);
95 95
 	}
96 96
 
97 97
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return \Doctrine\DBAL\Schema\Table
102 102
 	 */
103 103
 	public function createTable($tableName) {
104
-		return $this->schema->createTable($this->connection->getPrefix() . $tableName);
104
+		return $this->schema->createTable($this->connection->getPrefix().$tableName);
105 105
 	}
106 106
 
107 107
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 */
126 126
 	public function dropTable($tableName) {
127 127
 		$this->tablesToDelete[$tableName] = true;
128
-		return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
128
+		return $this->schema->dropTable($this->connection->getPrefix().$tableName);
129 129
 	}
130 130
 
131 131
 	/**
Please login to merge, or discard this patch.
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -30,107 +30,107 @@
 block discarded – undo
30 30
 
31 31
 class SchemaWrapper implements ISchemaWrapper {
32 32
 
33
-	/** @var IDBConnection|Connection */
34
-	protected $connection;
35
-
36
-	/** @var Schema */
37
-	protected $schema;
38
-
39
-	/** @var array */
40
-	protected $tablesToDelete = [];
41
-
42
-	/**
43
-	 * @param IDBConnection $connection
44
-	 */
45
-	public function __construct(IDBConnection $connection) {
46
-		$this->connection = $connection;
47
-		$this->schema = $this->connection->createSchema();
48
-	}
49
-
50
-	public function getWrappedSchema() {
51
-		return $this->schema;
52
-	}
53
-
54
-	public function performDropTableCalls() {
55
-		foreach ($this->tablesToDelete as $tableName => $true) {
56
-			$this->connection->dropTable($tableName);
57
-			unset($this->tablesToDelete[$tableName]);
58
-		}
59
-	}
60
-
61
-	/**
62
-	 * Gets all table names
63
-	 *
64
-	 * @return array
65
-	 */
66
-	public function getTableNamesWithoutPrefix() {
67
-		$tableNames = $this->schema->getTableNames();
68
-		return array_map(function($tableName) {
69
-			if (strpos($tableName, $this->connection->getPrefix()) === 0) {
70
-				return substr($tableName, strlen($this->connection->getPrefix()));
71
-			}
72
-
73
-			return $tableName;
74
-		}, $tableNames);
75
-	}
76
-
77
-	// Overwritten methods
78
-
79
-	/**
80
-	 * @return array
81
-	 */
82
-	public function getTableNames() {
83
-		return $this->schema->getTableNames();
84
-	}
85
-
86
-	/**
87
-	 * @param string $tableName
88
-	 *
89
-	 * @return \Doctrine\DBAL\Schema\Table
90
-	 * @throws \Doctrine\DBAL\Schema\SchemaException
91
-	 */
92
-	public function getTable($tableName) {
93
-		return $this->schema->getTable($this->connection->getPrefix() . $tableName);
94
-	}
95
-
96
-	/**
97
-	 * Does this schema have a table with the given name?
98
-	 *
99
-	 * @param string $tableName
100
-	 *
101
-	 * @return boolean
102
-	 */
103
-	public function hasTable($tableName) {
104
-		return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
105
-	}
106
-
107
-	/**
108
-	 * Creates a new table.
109
-	 *
110
-	 * @param string $tableName
111
-	 * @return \Doctrine\DBAL\Schema\Table
112
-	 */
113
-	public function createTable($tableName) {
114
-		return $this->schema->createTable($this->connection->getPrefix() . $tableName);
115
-	}
116
-
117
-	/**
118
-	 * Drops a table from the schema.
119
-	 *
120
-	 * @param string $tableName
121
-	 * @return \Doctrine\DBAL\Schema\Schema
122
-	 */
123
-	public function dropTable($tableName) {
124
-		$this->tablesToDelete[$tableName] = true;
125
-		return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
126
-	}
127
-
128
-	/**
129
-	 * Gets all tables of this schema.
130
-	 *
131
-	 * @return \Doctrine\DBAL\Schema\Table[]
132
-	 */
133
-	public function getTables() {
134
-		return $this->schema->getTables();
135
-	}
33
+    /** @var IDBConnection|Connection */
34
+    protected $connection;
35
+
36
+    /** @var Schema */
37
+    protected $schema;
38
+
39
+    /** @var array */
40
+    protected $tablesToDelete = [];
41
+
42
+    /**
43
+     * @param IDBConnection $connection
44
+     */
45
+    public function __construct(IDBConnection $connection) {
46
+        $this->connection = $connection;
47
+        $this->schema = $this->connection->createSchema();
48
+    }
49
+
50
+    public function getWrappedSchema() {
51
+        return $this->schema;
52
+    }
53
+
54
+    public function performDropTableCalls() {
55
+        foreach ($this->tablesToDelete as $tableName => $true) {
56
+            $this->connection->dropTable($tableName);
57
+            unset($this->tablesToDelete[$tableName]);
58
+        }
59
+    }
60
+
61
+    /**
62
+     * Gets all table names
63
+     *
64
+     * @return array
65
+     */
66
+    public function getTableNamesWithoutPrefix() {
67
+        $tableNames = $this->schema->getTableNames();
68
+        return array_map(function($tableName) {
69
+            if (strpos($tableName, $this->connection->getPrefix()) === 0) {
70
+                return substr($tableName, strlen($this->connection->getPrefix()));
71
+            }
72
+
73
+            return $tableName;
74
+        }, $tableNames);
75
+    }
76
+
77
+    // Overwritten methods
78
+
79
+    /**
80
+     * @return array
81
+     */
82
+    public function getTableNames() {
83
+        return $this->schema->getTableNames();
84
+    }
85
+
86
+    /**
87
+     * @param string $tableName
88
+     *
89
+     * @return \Doctrine\DBAL\Schema\Table
90
+     * @throws \Doctrine\DBAL\Schema\SchemaException
91
+     */
92
+    public function getTable($tableName) {
93
+        return $this->schema->getTable($this->connection->getPrefix() . $tableName);
94
+    }
95
+
96
+    /**
97
+     * Does this schema have a table with the given name?
98
+     *
99
+     * @param string $tableName
100
+     *
101
+     * @return boolean
102
+     */
103
+    public function hasTable($tableName) {
104
+        return $this->schema->hasTable($this->connection->getPrefix() . $tableName);
105
+    }
106
+
107
+    /**
108
+     * Creates a new table.
109
+     *
110
+     * @param string $tableName
111
+     * @return \Doctrine\DBAL\Schema\Table
112
+     */
113
+    public function createTable($tableName) {
114
+        return $this->schema->createTable($this->connection->getPrefix() . $tableName);
115
+    }
116
+
117
+    /**
118
+     * Drops a table from the schema.
119
+     *
120
+     * @param string $tableName
121
+     * @return \Doctrine\DBAL\Schema\Schema
122
+     */
123
+    public function dropTable($tableName) {
124
+        $this->tablesToDelete[$tableName] = true;
125
+        return $this->schema->dropTable($this->connection->getPrefix() . $tableName);
126
+    }
127
+
128
+    /**
129
+     * Gets all tables of this schema.
130
+     *
131
+     * @return \Doctrine\DBAL\Schema\Table[]
132
+     */
133
+    public function getTables() {
134
+        return $this->schema->getTables();
135
+    }
136 136
 }
Please login to merge, or discard this patch.
lib/private/Encryption/Util.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		$this->config = $config;
97 97
 
98 98
 		$this->excludedPaths[] = 'files_encryption';
99
-		$this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
99
+		$this->excludedPaths[] = 'appdata_'.$config->getSystemValue('instanceid', null);
100 100
 		$this->excludedPaths[] = 'files_external';
101 101
 	}
102 102
 
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
 	 * @throws EncryptionHeaderKeyExistsException if header key is already in use
137 137
 	 */
138 138
 	public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
139
-		$header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
139
+		$header = self::HEADER_START.':'.self::HEADER_ENCRYPTION_MODULE_KEY.':'.$encryptionModule->getId().':';
140 140
 		foreach ($headerData as $key => $value) {
141 141
 			if (in_array($key, $this->ocHeaderKeys)) {
142 142
 				throw new EncryptionHeaderKeyExistsException($key);
143 143
 			}
144
-			$header .= $key . ':' . $value . ':';
144
+			$header .= $key.':'.$value.':';
145 145
 		}
146 146
 		$header .= self::HEADER_END;
147 147
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 				if ($c->getType() === 'dir') {
173 173
 					$dirList[] = $c->getPath();
174 174
 				} else {
175
-					$result[] =  $c->getPath();
175
+					$result[] = $c->getPath();
176 176
 				}
177 177
 			}
178 178
 
@@ -249,15 +249,15 @@  discard block
 block discarded – undo
249 249
 	public function stripPartialFileExtension($path) {
250 250
 		$extension = pathinfo($path, PATHINFO_EXTENSION);
251 251
 
252
-		if ( $extension === 'part') {
252
+		if ($extension === 'part') {
253 253
 
254 254
 			$newLength = strlen($path) - 5; // 5 = strlen(".part")
255 255
 			$fPath = substr($path, 0, $newLength);
256 256
 
257 257
 			// if path also contains a transaction id, we remove it too
258 258
 			$extension = pathinfo($fPath, PATHINFO_EXTENSION);
259
-			if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
260
-				$newLength = strlen($fPath) - strlen($extension) -1;
259
+			if (substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
260
+				$newLength = strlen($fPath) - strlen($extension) - 1;
261 261
 				$fPath = substr($fPath, 0, $newLength);
262 262
 			}
263 263
 			return $fPath;
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 		if (\OCP\App::isEnabled("files_external")) {
302 302
 			$mounts = \OC_Mount_Config::getSystemMountPoints();
303 303
 			foreach ($mounts as $mount) {
304
-				if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
304
+				if (strpos($path, '/files/'.$mount['mountpoint']) === 0) {
305 305
 					if ($this->isMountPointApplicableToUser($mount, $uid)) {
306 306
 						return true;
307 307
 					}
Please login to merge, or discard this patch.
Indentation   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -39,374 +39,374 @@
 block discarded – undo
39 39
 
40 40
 class Util {
41 41
 
42
-	const HEADER_START = 'HBEGIN';
43
-	const HEADER_END = 'HEND';
44
-	const HEADER_PADDING_CHAR = '-';
45
-
46
-	const HEADER_ENCRYPTION_MODULE_KEY = 'oc_encryption_module';
47
-
48
-	/**
49
-	 * block size will always be 8192 for a PHP stream
50
-	 * @see https://bugs.php.net/bug.php?id=21641
51
-	 * @var integer
52
-	 */
53
-	protected $headerSize = 8192;
54
-
55
-	/**
56
-	 * block size will always be 8192 for a PHP stream
57
-	 * @see https://bugs.php.net/bug.php?id=21641
58
-	 * @var integer
59
-	 */
60
-	protected $blockSize = 8192;
61
-
62
-	/** @var View */
63
-	protected $rootView;
64
-
65
-	/** @var array */
66
-	protected $ocHeaderKeys;
67
-
68
-	/** @var \OC\User\Manager */
69
-	protected $userManager;
70
-
71
-	/** @var IConfig */
72
-	protected $config;
73
-
74
-	/** @var array paths excluded from encryption */
75
-	protected $excludedPaths;
76
-
77
-	/** @var \OC\Group\Manager $manager */
78
-	protected $groupManager;
79
-
80
-	/**
81
-	 *
82
-	 * @param View $rootView
83
-	 * @param \OC\User\Manager $userManager
84
-	 * @param \OC\Group\Manager $groupManager
85
-	 * @param IConfig $config
86
-	 */
87
-	public function __construct(
88
-		View $rootView,
89
-		\OC\User\Manager $userManager,
90
-		\OC\Group\Manager $groupManager,
91
-		IConfig $config) {
92
-
93
-		$this->ocHeaderKeys = [
94
-			self::HEADER_ENCRYPTION_MODULE_KEY
95
-		];
96
-
97
-		$this->rootView = $rootView;
98
-		$this->userManager = $userManager;
99
-		$this->groupManager = $groupManager;
100
-		$this->config = $config;
101
-
102
-		$this->excludedPaths[] = 'files_encryption';
103
-		$this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
104
-		$this->excludedPaths[] = 'files_external';
105
-	}
106
-
107
-	/**
108
-	 * read encryption module ID from header
109
-	 *
110
-	 * @param array $header
111
-	 * @return string
112
-	 * @throws ModuleDoesNotExistsException
113
-	 */
114
-	public function getEncryptionModuleId(array $header = null) {
115
-		$id = '';
116
-		$encryptionModuleKey = self::HEADER_ENCRYPTION_MODULE_KEY;
117
-
118
-		if (isset($header[$encryptionModuleKey])) {
119
-			$id = $header[$encryptionModuleKey];
120
-		} elseif (isset($header['cipher'])) {
121
-			if (class_exists('\OCA\Encryption\Crypto\Encryption')) {
122
-				// fall back to default encryption if the user migrated from
123
-				// ownCloud <= 8.0 with the old encryption
124
-				$id = \OCA\Encryption\Crypto\Encryption::ID;
125
-			} else {
126
-				throw new ModuleDoesNotExistsException('Default encryption module missing');
127
-			}
128
-		}
129
-
130
-		return $id;
131
-	}
132
-
133
-	/**
134
-	 * create header for encrypted file
135
-	 *
136
-	 * @param array $headerData
137
-	 * @param IEncryptionModule $encryptionModule
138
-	 * @return string
139
-	 * @throws EncryptionHeaderToLargeException if header has to many arguments
140
-	 * @throws EncryptionHeaderKeyExistsException if header key is already in use
141
-	 */
142
-	public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
143
-		$header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
144
-		foreach ($headerData as $key => $value) {
145
-			if (in_array($key, $this->ocHeaderKeys)) {
146
-				throw new EncryptionHeaderKeyExistsException($key);
147
-			}
148
-			$header .= $key . ':' . $value . ':';
149
-		}
150
-		$header .= self::HEADER_END;
151
-
152
-		if (strlen($header) > $this->getHeaderSize()) {
153
-			throw new EncryptionHeaderToLargeException();
154
-		}
155
-
156
-		$paddedHeader = str_pad($header, $this->headerSize, self::HEADER_PADDING_CHAR, STR_PAD_RIGHT);
157
-
158
-		return $paddedHeader;
159
-	}
160
-
161
-	/**
162
-	 * go recursively through a dir and collect all files and sub files.
163
-	 *
164
-	 * @param string $dir relative to the users files folder
165
-	 * @return array with list of files relative to the users files folder
166
-	 */
167
-	public function getAllFiles($dir) {
168
-		$result = array();
169
-		$dirList = array($dir);
170
-
171
-		while ($dirList) {
172
-			$dir = array_pop($dirList);
173
-			$content = $this->rootView->getDirectoryContent($dir);
174
-
175
-			foreach ($content as $c) {
176
-				if ($c->getType() === 'dir') {
177
-					$dirList[] = $c->getPath();
178
-				} else {
179
-					$result[] =  $c->getPath();
180
-				}
181
-			}
182
-
183
-		}
184
-
185
-		return $result;
186
-	}
187
-
188
-	/**
189
-	 * check if it is a file uploaded by the user stored in data/user/files
190
-	 * or a metadata file
191
-	 *
192
-	 * @param string $path relative to the data/ folder
193
-	 * @return boolean
194
-	 */
195
-	public function isFile($path) {
196
-		$parts = explode('/', Filesystem::normalizePath($path), 4);
197
-		if (isset($parts[2]) && $parts[2] === 'files') {
198
-			return true;
199
-		}
200
-		return false;
201
-	}
202
-
203
-	/**
204
-	 * return size of encryption header
205
-	 *
206
-	 * @return integer
207
-	 */
208
-	public function getHeaderSize() {
209
-		return $this->headerSize;
210
-	}
211
-
212
-	/**
213
-	 * return size of block read by a PHP stream
214
-	 *
215
-	 * @return integer
216
-	 */
217
-	public function getBlockSize() {
218
-		return $this->blockSize;
219
-	}
220
-
221
-	/**
222
-	 * get the owner and the path for the file relative to the owners files folder
223
-	 *
224
-	 * @param string $path
225
-	 * @return array
226
-	 * @throws \BadMethodCallException
227
-	 */
228
-	public function getUidAndFilename($path) {
229
-
230
-		$parts = explode('/', $path);
231
-		$uid = '';
232
-		if (count($parts) > 2) {
233
-			$uid = $parts[1];
234
-		}
235
-		if (!$this->userManager->userExists($uid)) {
236
-			throw new \BadMethodCallException(
237
-				'path needs to be relative to the system wide data folder and point to a user specific file'
238
-			);
239
-		}
240
-
241
-		$ownerPath = implode('/', array_slice($parts, 2));
242
-
243
-		return array($uid, Filesystem::normalizePath($ownerPath));
244
-
245
-	}
246
-
247
-	/**
248
-	 * Remove .path extension from a file path
249
-	 * @param string $path Path that may identify a .part file
250
-	 * @return string File path without .part extension
251
-	 * @note this is needed for reusing keys
252
-	 */
253
-	public function stripPartialFileExtension($path) {
254
-		$extension = pathinfo($path, PATHINFO_EXTENSION);
255
-
256
-		if ( $extension === 'part') {
257
-
258
-			$newLength = strlen($path) - 5; // 5 = strlen(".part")
259
-			$fPath = substr($path, 0, $newLength);
260
-
261
-			// if path also contains a transaction id, we remove it too
262
-			$extension = pathinfo($fPath, PATHINFO_EXTENSION);
263
-			if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
264
-				$newLength = strlen($fPath) - strlen($extension) -1;
265
-				$fPath = substr($fPath, 0, $newLength);
266
-			}
267
-			return $fPath;
268
-
269
-		} else {
270
-			return $path;
271
-		}
272
-	}
273
-
274
-	public function getUserWithAccessToMountPoint($users, $groups) {
275
-		$result = [];
276
-		if (in_array('all', $users)) {
277
-			$users = $this->userManager->search('', null, null);
278
-			$result = array_map(function(IUser $user) {
279
-				return $user->getUID();
280
-			}, $users);
281
-		} else {
282
-			$result = array_merge($result, $users);
283
-
284
-			$groupManager = \OC::$server->getGroupManager();
285
-			foreach ($groups as $group) {
286
-				$groupObject = $groupManager->get($group);
287
-				if ($groupObject) {
288
-					$foundUsers = $groupObject->searchUsers('', -1, 0);
289
-					$userIds = [];
290
-					foreach ($foundUsers as $user) {
291
-						$userIds[] = $user->getUID();
292
-					}
293
-					$result = array_merge($result, $userIds);
294
-				}
295
-			}
296
-		}
297
-
298
-		return $result;
299
-	}
300
-
301
-	/**
302
-	 * check if the file is stored on a system wide mount point
303
-	 * @param string $path relative to /data/user with leading '/'
304
-	 * @param string $uid
305
-	 * @return boolean
306
-	 */
307
-	public function isSystemWideMountPoint($path, $uid) {
308
-		if (\OCP\App::isEnabled("files_external")) {
309
-			$mounts = \OC_Mount_Config::getSystemMountPoints();
310
-			foreach ($mounts as $mount) {
311
-				if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
312
-					if ($this->isMountPointApplicableToUser($mount, $uid)) {
313
-						return true;
314
-					}
315
-				}
316
-			}
317
-		}
318
-		return false;
319
-	}
320
-
321
-	/**
322
-	 * check if mount point is applicable to user
323
-	 *
324
-	 * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
325
-	 * @param string $uid
326
-	 * @return boolean
327
-	 */
328
-	private function isMountPointApplicableToUser($mount, $uid) {
329
-		$acceptedUids = array('all', $uid);
330
-		// check if mount point is applicable for the user
331
-		$intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
332
-		if (!empty($intersection)) {
333
-			return true;
334
-		}
335
-		// check if mount point is applicable for group where the user is a member
336
-		foreach ($mount['applicable']['groups'] as $gid) {
337
-			if ($this->groupManager->isInGroup($uid, $gid)) {
338
-				return true;
339
-			}
340
-		}
341
-		return false;
342
-	}
343
-
344
-	/**
345
-	 * check if it is a path which is excluded by ownCloud from encryption
346
-	 *
347
-	 * @param string $path
348
-	 * @return boolean
349
-	 */
350
-	public function isExcluded($path) {
351
-		$normalizedPath = Filesystem::normalizePath($path);
352
-		$root = explode('/', $normalizedPath, 4);
353
-		if (count($root) > 1) {
354
-
355
-			// detect alternative key storage root
356
-			$rootDir = $this->getKeyStorageRoot();
357
-			if ($rootDir !== '' &&
358
-				0 === strpos(
359
-					Filesystem::normalizePath($path),
360
-					Filesystem::normalizePath($rootDir)
361
-				)
362
-			) {
363
-				return true;
364
-			}
365
-
366
-
367
-			//detect system wide folders
368
-			if (in_array($root[1], $this->excludedPaths)) {
369
-				return true;
370
-			}
371
-
372
-			// detect user specific folders
373
-			if ($this->userManager->userExists($root[1])
374
-				&& in_array($root[2], $this->excludedPaths)) {
375
-
376
-				return true;
377
-			}
378
-		}
379
-		return false;
380
-	}
381
-
382
-	/**
383
-	 * check if recovery key is enabled for user
384
-	 *
385
-	 * @param string $uid
386
-	 * @return boolean
387
-	 */
388
-	public function recoveryEnabled($uid) {
389
-		$enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
390
-
391
-		return $enabled === '1';
392
-	}
393
-
394
-	/**
395
-	 * set new key storage root
396
-	 *
397
-	 * @param string $root new key store root relative to the data folder
398
-	 */
399
-	public function setKeyStorageRoot($root) {
400
-		$this->config->setAppValue('core', 'encryption_key_storage_root', $root);
401
-	}
402
-
403
-	/**
404
-	 * get key storage root
405
-	 *
406
-	 * @return string key storage root
407
-	 */
408
-	public function getKeyStorageRoot() {
409
-		return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
410
-	}
42
+    const HEADER_START = 'HBEGIN';
43
+    const HEADER_END = 'HEND';
44
+    const HEADER_PADDING_CHAR = '-';
45
+
46
+    const HEADER_ENCRYPTION_MODULE_KEY = 'oc_encryption_module';
47
+
48
+    /**
49
+     * block size will always be 8192 for a PHP stream
50
+     * @see https://bugs.php.net/bug.php?id=21641
51
+     * @var integer
52
+     */
53
+    protected $headerSize = 8192;
54
+
55
+    /**
56
+     * block size will always be 8192 for a PHP stream
57
+     * @see https://bugs.php.net/bug.php?id=21641
58
+     * @var integer
59
+     */
60
+    protected $blockSize = 8192;
61
+
62
+    /** @var View */
63
+    protected $rootView;
64
+
65
+    /** @var array */
66
+    protected $ocHeaderKeys;
67
+
68
+    /** @var \OC\User\Manager */
69
+    protected $userManager;
70
+
71
+    /** @var IConfig */
72
+    protected $config;
73
+
74
+    /** @var array paths excluded from encryption */
75
+    protected $excludedPaths;
76
+
77
+    /** @var \OC\Group\Manager $manager */
78
+    protected $groupManager;
79
+
80
+    /**
81
+     *
82
+     * @param View $rootView
83
+     * @param \OC\User\Manager $userManager
84
+     * @param \OC\Group\Manager $groupManager
85
+     * @param IConfig $config
86
+     */
87
+    public function __construct(
88
+        View $rootView,
89
+        \OC\User\Manager $userManager,
90
+        \OC\Group\Manager $groupManager,
91
+        IConfig $config) {
92
+
93
+        $this->ocHeaderKeys = [
94
+            self::HEADER_ENCRYPTION_MODULE_KEY
95
+        ];
96
+
97
+        $this->rootView = $rootView;
98
+        $this->userManager = $userManager;
99
+        $this->groupManager = $groupManager;
100
+        $this->config = $config;
101
+
102
+        $this->excludedPaths[] = 'files_encryption';
103
+        $this->excludedPaths[] = 'appdata_' . $config->getSystemValue('instanceid', null);
104
+        $this->excludedPaths[] = 'files_external';
105
+    }
106
+
107
+    /**
108
+     * read encryption module ID from header
109
+     *
110
+     * @param array $header
111
+     * @return string
112
+     * @throws ModuleDoesNotExistsException
113
+     */
114
+    public function getEncryptionModuleId(array $header = null) {
115
+        $id = '';
116
+        $encryptionModuleKey = self::HEADER_ENCRYPTION_MODULE_KEY;
117
+
118
+        if (isset($header[$encryptionModuleKey])) {
119
+            $id = $header[$encryptionModuleKey];
120
+        } elseif (isset($header['cipher'])) {
121
+            if (class_exists('\OCA\Encryption\Crypto\Encryption')) {
122
+                // fall back to default encryption if the user migrated from
123
+                // ownCloud <= 8.0 with the old encryption
124
+                $id = \OCA\Encryption\Crypto\Encryption::ID;
125
+            } else {
126
+                throw new ModuleDoesNotExistsException('Default encryption module missing');
127
+            }
128
+        }
129
+
130
+        return $id;
131
+    }
132
+
133
+    /**
134
+     * create header for encrypted file
135
+     *
136
+     * @param array $headerData
137
+     * @param IEncryptionModule $encryptionModule
138
+     * @return string
139
+     * @throws EncryptionHeaderToLargeException if header has to many arguments
140
+     * @throws EncryptionHeaderKeyExistsException if header key is already in use
141
+     */
142
+    public function createHeader(array $headerData, IEncryptionModule $encryptionModule) {
143
+        $header = self::HEADER_START . ':' . self::HEADER_ENCRYPTION_MODULE_KEY . ':' . $encryptionModule->getId() . ':';
144
+        foreach ($headerData as $key => $value) {
145
+            if (in_array($key, $this->ocHeaderKeys)) {
146
+                throw new EncryptionHeaderKeyExistsException($key);
147
+            }
148
+            $header .= $key . ':' . $value . ':';
149
+        }
150
+        $header .= self::HEADER_END;
151
+
152
+        if (strlen($header) > $this->getHeaderSize()) {
153
+            throw new EncryptionHeaderToLargeException();
154
+        }
155
+
156
+        $paddedHeader = str_pad($header, $this->headerSize, self::HEADER_PADDING_CHAR, STR_PAD_RIGHT);
157
+
158
+        return $paddedHeader;
159
+    }
160
+
161
+    /**
162
+     * go recursively through a dir and collect all files and sub files.
163
+     *
164
+     * @param string $dir relative to the users files folder
165
+     * @return array with list of files relative to the users files folder
166
+     */
167
+    public function getAllFiles($dir) {
168
+        $result = array();
169
+        $dirList = array($dir);
170
+
171
+        while ($dirList) {
172
+            $dir = array_pop($dirList);
173
+            $content = $this->rootView->getDirectoryContent($dir);
174
+
175
+            foreach ($content as $c) {
176
+                if ($c->getType() === 'dir') {
177
+                    $dirList[] = $c->getPath();
178
+                } else {
179
+                    $result[] =  $c->getPath();
180
+                }
181
+            }
182
+
183
+        }
184
+
185
+        return $result;
186
+    }
187
+
188
+    /**
189
+     * check if it is a file uploaded by the user stored in data/user/files
190
+     * or a metadata file
191
+     *
192
+     * @param string $path relative to the data/ folder
193
+     * @return boolean
194
+     */
195
+    public function isFile($path) {
196
+        $parts = explode('/', Filesystem::normalizePath($path), 4);
197
+        if (isset($parts[2]) && $parts[2] === 'files') {
198
+            return true;
199
+        }
200
+        return false;
201
+    }
202
+
203
+    /**
204
+     * return size of encryption header
205
+     *
206
+     * @return integer
207
+     */
208
+    public function getHeaderSize() {
209
+        return $this->headerSize;
210
+    }
211
+
212
+    /**
213
+     * return size of block read by a PHP stream
214
+     *
215
+     * @return integer
216
+     */
217
+    public function getBlockSize() {
218
+        return $this->blockSize;
219
+    }
220
+
221
+    /**
222
+     * get the owner and the path for the file relative to the owners files folder
223
+     *
224
+     * @param string $path
225
+     * @return array
226
+     * @throws \BadMethodCallException
227
+     */
228
+    public function getUidAndFilename($path) {
229
+
230
+        $parts = explode('/', $path);
231
+        $uid = '';
232
+        if (count($parts) > 2) {
233
+            $uid = $parts[1];
234
+        }
235
+        if (!$this->userManager->userExists($uid)) {
236
+            throw new \BadMethodCallException(
237
+                'path needs to be relative to the system wide data folder and point to a user specific file'
238
+            );
239
+        }
240
+
241
+        $ownerPath = implode('/', array_slice($parts, 2));
242
+
243
+        return array($uid, Filesystem::normalizePath($ownerPath));
244
+
245
+    }
246
+
247
+    /**
248
+     * Remove .path extension from a file path
249
+     * @param string $path Path that may identify a .part file
250
+     * @return string File path without .part extension
251
+     * @note this is needed for reusing keys
252
+     */
253
+    public function stripPartialFileExtension($path) {
254
+        $extension = pathinfo($path, PATHINFO_EXTENSION);
255
+
256
+        if ( $extension === 'part') {
257
+
258
+            $newLength = strlen($path) - 5; // 5 = strlen(".part")
259
+            $fPath = substr($path, 0, $newLength);
260
+
261
+            // if path also contains a transaction id, we remove it too
262
+            $extension = pathinfo($fPath, PATHINFO_EXTENSION);
263
+            if(substr($extension, 0, 12) === 'ocTransferId') { // 12 = strlen("ocTransferId")
264
+                $newLength = strlen($fPath) - strlen($extension) -1;
265
+                $fPath = substr($fPath, 0, $newLength);
266
+            }
267
+            return $fPath;
268
+
269
+        } else {
270
+            return $path;
271
+        }
272
+    }
273
+
274
+    public function getUserWithAccessToMountPoint($users, $groups) {
275
+        $result = [];
276
+        if (in_array('all', $users)) {
277
+            $users = $this->userManager->search('', null, null);
278
+            $result = array_map(function(IUser $user) {
279
+                return $user->getUID();
280
+            }, $users);
281
+        } else {
282
+            $result = array_merge($result, $users);
283
+
284
+            $groupManager = \OC::$server->getGroupManager();
285
+            foreach ($groups as $group) {
286
+                $groupObject = $groupManager->get($group);
287
+                if ($groupObject) {
288
+                    $foundUsers = $groupObject->searchUsers('', -1, 0);
289
+                    $userIds = [];
290
+                    foreach ($foundUsers as $user) {
291
+                        $userIds[] = $user->getUID();
292
+                    }
293
+                    $result = array_merge($result, $userIds);
294
+                }
295
+            }
296
+        }
297
+
298
+        return $result;
299
+    }
300
+
301
+    /**
302
+     * check if the file is stored on a system wide mount point
303
+     * @param string $path relative to /data/user with leading '/'
304
+     * @param string $uid
305
+     * @return boolean
306
+     */
307
+    public function isSystemWideMountPoint($path, $uid) {
308
+        if (\OCP\App::isEnabled("files_external")) {
309
+            $mounts = \OC_Mount_Config::getSystemMountPoints();
310
+            foreach ($mounts as $mount) {
311
+                if (strpos($path, '/files/' . $mount['mountpoint']) === 0) {
312
+                    if ($this->isMountPointApplicableToUser($mount, $uid)) {
313
+                        return true;
314
+                    }
315
+                }
316
+            }
317
+        }
318
+        return false;
319
+    }
320
+
321
+    /**
322
+     * check if mount point is applicable to user
323
+     *
324
+     * @param array $mount contains $mount['applicable']['users'], $mount['applicable']['groups']
325
+     * @param string $uid
326
+     * @return boolean
327
+     */
328
+    private function isMountPointApplicableToUser($mount, $uid) {
329
+        $acceptedUids = array('all', $uid);
330
+        // check if mount point is applicable for the user
331
+        $intersection = array_intersect($acceptedUids, $mount['applicable']['users']);
332
+        if (!empty($intersection)) {
333
+            return true;
334
+        }
335
+        // check if mount point is applicable for group where the user is a member
336
+        foreach ($mount['applicable']['groups'] as $gid) {
337
+            if ($this->groupManager->isInGroup($uid, $gid)) {
338
+                return true;
339
+            }
340
+        }
341
+        return false;
342
+    }
343
+
344
+    /**
345
+     * check if it is a path which is excluded by ownCloud from encryption
346
+     *
347
+     * @param string $path
348
+     * @return boolean
349
+     */
350
+    public function isExcluded($path) {
351
+        $normalizedPath = Filesystem::normalizePath($path);
352
+        $root = explode('/', $normalizedPath, 4);
353
+        if (count($root) > 1) {
354
+
355
+            // detect alternative key storage root
356
+            $rootDir = $this->getKeyStorageRoot();
357
+            if ($rootDir !== '' &&
358
+                0 === strpos(
359
+                    Filesystem::normalizePath($path),
360
+                    Filesystem::normalizePath($rootDir)
361
+                )
362
+            ) {
363
+                return true;
364
+            }
365
+
366
+
367
+            //detect system wide folders
368
+            if (in_array($root[1], $this->excludedPaths)) {
369
+                return true;
370
+            }
371
+
372
+            // detect user specific folders
373
+            if ($this->userManager->userExists($root[1])
374
+                && in_array($root[2], $this->excludedPaths)) {
375
+
376
+                return true;
377
+            }
378
+        }
379
+        return false;
380
+    }
381
+
382
+    /**
383
+     * check if recovery key is enabled for user
384
+     *
385
+     * @param string $uid
386
+     * @return boolean
387
+     */
388
+    public function recoveryEnabled($uid) {
389
+        $enabled = $this->config->getUserValue($uid, 'encryption', 'recovery_enabled', '0');
390
+
391
+        return $enabled === '1';
392
+    }
393
+
394
+    /**
395
+     * set new key storage root
396
+     *
397
+     * @param string $root new key store root relative to the data folder
398
+     */
399
+    public function setKeyStorageRoot($root) {
400
+        $this->config->setAppValue('core', 'encryption_key_storage_root', $root);
401
+    }
402
+
403
+    /**
404
+     * get key storage root
405
+     *
406
+     * @return string key storage root
407
+     */
408
+    public function getKeyStorageRoot() {
409
+        return $this->config->getAppValue('core', 'encryption_key_storage_root', '');
410
+    }
411 411
 
412 412
 }
Please login to merge, or discard this patch.