Passed
Push — master ( da9ad9...c724eb )
by Roeland
13:33 queued 01:55
created
lib/private/App/AppStore/Bundles/SocialSharingBundle.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 	 * {@inheritDoc}
28 28
 	 */
29 29
 	public function getName() {
30
-		return (string)$this->l10n->t('Social sharing bundle');
30
+		return (string) $this->l10n->t('Social sharing bundle');
31 31
 	}
32 32
 
33 33
 	/**
Please login to merge, or discard this patch.
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -25,23 +25,23 @@
 block discarded – undo
25 25
 
26 26
 class SocialSharingBundle extends Bundle {
27 27
 
28
-	/**
29
-	 * {@inheritDoc}
30
-	 */
31
-	public function getName() {
32
-		return (string)$this->l10n->t('Social sharing bundle');
33
-	}
28
+    /**
29
+     * {@inheritDoc}
30
+     */
31
+    public function getName() {
32
+        return (string)$this->l10n->t('Social sharing bundle');
33
+    }
34 34
 
35
-	/**
36
-	 * {@inheritDoc}
37
-	 */
38
-	public function getAppIdentifiers() {
39
-		return [
40
-			'socialsharing_twitter',
41
-			'socialsharing_facebook',
42
-			'socialsharing_email',
43
-			'socialsharing_diaspora',
44
-		];
45
-	}
35
+    /**
36
+     * {@inheritDoc}
37
+     */
38
+    public function getAppIdentifiers() {
39
+        return [
40
+            'socialsharing_twitter',
41
+            'socialsharing_facebook',
42
+            'socialsharing_email',
43
+            'socialsharing_diaspora',
44
+        ];
45
+    }
46 46
 
47 47
 }
Please login to merge, or discard this patch.
lib/public/Files/Mount/IMountPoint.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -29,103 +29,103 @@
 block discarded – undo
29 29
  */
30 30
 interface IMountPoint {
31 31
 
32
-	/**
33
-	 * get complete path to the mount point
34
-	 *
35
-	 * @return string
36
-	 * @since 8.0.0
37
-	 */
38
-	public function getMountPoint();
32
+    /**
33
+     * get complete path to the mount point
34
+     *
35
+     * @return string
36
+     * @since 8.0.0
37
+     */
38
+    public function getMountPoint();
39 39
 
40
-	/**
41
-	 * Set the mountpoint
42
-	 *
43
-	 * @param string $mountPoint new mount point
44
-	 * @since 8.0.0
45
-	 */
46
-	public function setMountPoint($mountPoint);
40
+    /**
41
+     * Set the mountpoint
42
+     *
43
+     * @param string $mountPoint new mount point
44
+     * @since 8.0.0
45
+     */
46
+    public function setMountPoint($mountPoint);
47 47
 
48
-	/**
49
-	 * Get the storage that is mounted
50
-	 *
51
-	 * @return \OC\Files\Storage\Storage
52
-	 * @since 8.0.0
53
-	 */
54
-	public function getStorage();
48
+    /**
49
+     * Get the storage that is mounted
50
+     *
51
+     * @return \OC\Files\Storage\Storage
52
+     * @since 8.0.0
53
+     */
54
+    public function getStorage();
55 55
 
56
-	/**
57
-	 * Get the id of the storages
58
-	 *
59
-	 * @return string
60
-	 * @since 8.0.0
61
-	 */
62
-	public function getStorageId();
56
+    /**
57
+     * Get the id of the storages
58
+     *
59
+     * @return string
60
+     * @since 8.0.0
61
+     */
62
+    public function getStorageId();
63 63
 
64
-	/**
65
-	 * Get the id of the storages
66
-	 *
67
-	 * @return int
68
-	 * @since 9.1.0
69
-	 */
70
-	public function getNumericStorageId();
64
+    /**
65
+     * Get the id of the storages
66
+     *
67
+     * @return int
68
+     * @since 9.1.0
69
+     */
70
+    public function getNumericStorageId();
71 71
 
72
-	/**
73
-	 * Get the path relative to the mountpoint
74
-	 *
75
-	 * @param string $path absolute path to a file or folder
76
-	 * @return string
77
-	 * @since 8.0.0
78
-	 */
79
-	public function getInternalPath($path);
72
+    /**
73
+     * Get the path relative to the mountpoint
74
+     *
75
+     * @param string $path absolute path to a file or folder
76
+     * @return string
77
+     * @since 8.0.0
78
+     */
79
+    public function getInternalPath($path);
80 80
 
81
-	/**
82
-	 * Apply a storage wrapper to the mounted storage
83
-	 *
84
-	 * @param callable $wrapper
85
-	 * @since 8.0.0
86
-	 */
87
-	public function wrapStorage($wrapper);
81
+    /**
82
+     * Apply a storage wrapper to the mounted storage
83
+     *
84
+     * @param callable $wrapper
85
+     * @since 8.0.0
86
+     */
87
+    public function wrapStorage($wrapper);
88 88
 
89
-	/**
90
-	 * Get a mount option
91
-	 *
92
-	 * @param string $name Name of the mount option to get
93
-	 * @param mixed $default Default value for the mount option
94
-	 * @return mixed
95
-	 * @since 8.0.0
96
-	 */
97
-	public function getOption($name, $default);
89
+    /**
90
+     * Get a mount option
91
+     *
92
+     * @param string $name Name of the mount option to get
93
+     * @param mixed $default Default value for the mount option
94
+     * @return mixed
95
+     * @since 8.0.0
96
+     */
97
+    public function getOption($name, $default);
98 98
 
99
-	/**
100
-	 * Get all options for the mount
101
-	 *
102
-	 * @return array
103
-	 * @since 8.1.0
104
-	 */
105
-	public function getOptions();
99
+    /**
100
+     * Get all options for the mount
101
+     *
102
+     * @return array
103
+     * @since 8.1.0
104
+     */
105
+    public function getOptions();
106 106
 
107
-	/**
108
-	 * Get the file id of the root of the storage
109
-	 *
110
-	 * @return int
111
-	 * @since 9.1.0
112
-	 */
113
-	public function getStorageRootId();
107
+    /**
108
+     * Get the file id of the root of the storage
109
+     *
110
+     * @return int
111
+     * @since 9.1.0
112
+     */
113
+    public function getStorageRootId();
114 114
 
115
-	/**
116
-	 * Get the id of the configured mount
117
-	 *
118
-	 * @return int|null mount id or null if not applicable
119
-	 * @since 9.1.0
120
-	 */
121
-	public function getMountId();
115
+    /**
116
+     * Get the id of the configured mount
117
+     *
118
+     * @return int|null mount id or null if not applicable
119
+     * @since 9.1.0
120
+     */
121
+    public function getMountId();
122 122
 
123
-	/**
124
-	 * Get the type of mount point, used to distinguish things like shares and external storages
125
-	 * in the web interface
126
-	 *
127
-	 * @return string
128
-	 * @since 12.0.0
129
-	 */
130
-	public function getMountType();
123
+    /**
124
+     * Get the type of mount point, used to distinguish things like shares and external storages
125
+     * in the web interface
126
+     *
127
+     * @return string
128
+     * @since 12.0.0
129
+     */
130
+    public function getMountType();
131 131
 }
Please login to merge, or discard this patch.
lib/private/Contacts/ContactsMenu/Providers/EMailProvider.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -31,34 +31,34 @@
 block discarded – undo
31 31
 
32 32
 class EMailProvider implements IProvider {
33 33
 
34
-	/** @var IActionFactory */
35
-	private $actionFactory;
34
+    /** @var IActionFactory */
35
+    private $actionFactory;
36 36
 
37
-	/** @var IURLGenerator */
38
-	private $urlGenerator;
37
+    /** @var IURLGenerator */
38
+    private $urlGenerator;
39 39
 
40
-	/**
41
-	 * @param IActionFactory $actionFactory
42
-	 * @param IURLGenerator $urlGenerator
43
-	 */
44
-	public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) {
45
-		$this->actionFactory = $actionFactory;
46
-		$this->urlGenerator = $urlGenerator;
47
-	}
40
+    /**
41
+     * @param IActionFactory $actionFactory
42
+     * @param IURLGenerator $urlGenerator
43
+     */
44
+    public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) {
45
+        $this->actionFactory = $actionFactory;
46
+        $this->urlGenerator = $urlGenerator;
47
+    }
48 48
 
49
-	/**
50
-	 * @param IEntry $entry
51
-	 */
52
-	public function process(IEntry $entry) {
53
-		$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
54
-		foreach ($entry->getEMailAddresses() as $address) {
55
-			if (empty($address)) {
56
-				// Skip
57
-				continue;
58
-			}
59
-			$action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
60
-			$entry->addAction($action);
61
-		}
62
-	}
49
+    /**
50
+     * @param IEntry $entry
51
+     */
52
+    public function process(IEntry $entry) {
53
+        $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg'));
54
+        foreach ($entry->getEMailAddresses() as $address) {
55
+            if (empty($address)) {
56
+                // Skip
57
+                continue;
58
+            }
59
+            $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address);
60
+            $entry->addAction($action);
61
+        }
62
+    }
63 63
 
64 64
 }
Please login to merge, or discard this patch.
lib/private/App/CodeChecker/LanguageParseChecker.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -25,36 +25,36 @@
 block discarded – undo
25 25
 
26 26
 class LanguageParseChecker {
27 27
 
28
-	/**
29
-	 * @param string $appId
30
-	 * @return array
31
-	 */
32
-	public function analyse($appId) {
33
-		$appPath = \OC_App::getAppPath($appId);
34
-		if ($appPath === false) {
35
-			throw new \RuntimeException("No app with given id <$appId> known.");
36
-		}
37
-
38
-		if (!is_dir($appPath . '/l10n/')) {
39
-			return [];
40
-		}
41
-
42
-		$errors = [];
43
-		$directory = new \DirectoryIterator($appPath . '/l10n/');
44
-
45
-		foreach ($directory as $file) {
46
-			if ($file->getExtension() !== 'json') {
47
-				continue;
48
-			}
49
-
50
-			$content = file_get_contents($file->getPathname());
51
-			json_decode($content, true);
52
-
53
-			if (json_last_error() !== JSON_ERROR_NONE) {
54
-				$errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
55
-			}
56
-		}
57
-
58
-		return $errors;
59
-	}
28
+    /**
29
+     * @param string $appId
30
+     * @return array
31
+     */
32
+    public function analyse($appId) {
33
+        $appPath = \OC_App::getAppPath($appId);
34
+        if ($appPath === false) {
35
+            throw new \RuntimeException("No app with given id <$appId> known.");
36
+        }
37
+
38
+        if (!is_dir($appPath . '/l10n/')) {
39
+            return [];
40
+        }
41
+
42
+        $errors = [];
43
+        $directory = new \DirectoryIterator($appPath . '/l10n/');
44
+
45
+        foreach ($directory as $file) {
46
+            if ($file->getExtension() !== 'json') {
47
+                continue;
48
+            }
49
+
50
+            $content = file_get_contents($file->getPathname());
51
+            json_decode($content, true);
52
+
53
+            if (json_last_error() !== JSON_ERROR_NONE) {
54
+                $errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
55
+            }
56
+        }
57
+
58
+        return $errors;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 			throw new \RuntimeException("No app with given id <$appId> known.");
36 36
 		}
37 37
 
38
-		if (!is_dir($appPath . '/l10n/')) {
38
+		if (!is_dir($appPath.'/l10n/')) {
39 39
 			return [];
40 40
 		}
41 41
 
42 42
 		$errors = [];
43
-		$directory = new \DirectoryIterator($appPath . '/l10n/');
43
+		$directory = new \DirectoryIterator($appPath.'/l10n/');
44 44
 
45 45
 		foreach ($directory as $file) {
46 46
 			if ($file->getExtension() !== 'json') {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			json_decode($content, true);
52 52
 
53 53
 			if (json_last_error() !== JSON_ERROR_NONE) {
54
-				$errors[] = 'Invalid language file found: l10n/' . $file->getFilename() . ': ' . json_last_error_msg();
54
+				$errors[] = 'Invalid language file found: l10n/'.$file->getFilename().': '.json_last_error_msg();
55 55
 			}
56 56
 		}
57 57
 
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Import.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			$json = file_get_contents('php://stdin');
113 113
 		} else {
114 114
 			if (!file_exists($path)) {
115
-				$output->writeln('<error>File not found: ' . $path . '</error>');
115
+				$output->writeln('<error>File not found: '.$path.'</error>');
116 116
 				return 1;
117 117
 			}
118 118
 			$json = file_get_contents($path);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165 165
 					$existingMount->getBackendOptions() === $mount->getBackendOptions()
166 166
 				) {
167
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
167
+					$output->writeln("<error>Duplicate mount (".$mount->getMountPoint().")</error>");
168 168
 					return 1;
169 169
 				}
170 170
 			}
Please login to merge, or discard this patch.
Indentation   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -40,187 +40,187 @@
 block discarded – undo
40 40
 use Symfony\Component\Console\Output\OutputInterface;
41 41
 
42 42
 class Import extends Base {
43
-	/**
44
-	 * @var GlobalStoragesService
45
-	 */
46
-	private $globalService;
47
-
48
-	/**
49
-	 * @var UserStoragesService
50
-	 */
51
-	private $userService;
52
-
53
-	/**
54
-	 * @var IUserSession
55
-	 */
56
-	private $userSession;
57
-
58
-	/**
59
-	 * @var IUserManager
60
-	 */
61
-	private $userManager;
62
-
63
-	/** @var ImportLegacyStoragesService */
64
-	private $importLegacyStorageService;
65
-
66
-	/** @var BackendService */
67
-	private $backendService;
68
-
69
-	public function __construct(GlobalStoragesService $globalService,
70
-						 UserStoragesService $userService,
71
-						 IUserSession $userSession,
72
-						 IUserManager $userManager,
73
-						 ImportLegacyStoragesService $importLegacyStorageService,
74
-						 BackendService $backendService
75
-	) {
76
-		parent::__construct();
77
-		$this->globalService = $globalService;
78
-		$this->userService = $userService;
79
-		$this->userSession = $userSession;
80
-		$this->userManager = $userManager;
81
-		$this->importLegacyStorageService = $importLegacyStorageService;
82
-		$this->backendService = $backendService;
83
-	}
84
-
85
-	protected function configure() {
86
-		$this
87
-			->setName('files_external:import')
88
-			->setDescription('Import mount configurations')
89
-			->addOption(
90
-				'user',
91
-				'',
92
-				InputOption::VALUE_OPTIONAL,
93
-				'user to add the mount configurations for, if not set the mount will be added as system mount'
94
-			)
95
-			->addArgument(
96
-				'path',
97
-				InputArgument::REQUIRED,
98
-				'path to a json file containing the mounts to import, use "-" to read from stdin'
99
-			)
100
-			->addOption(
101
-				'dry',
102
-				'',
103
-				InputOption::VALUE_NONE,
104
-				'Don\'t save the imported mounts, only list the new mounts'
105
-			);
106
-		parent::configure();
107
-	}
108
-
109
-	protected function execute(InputInterface $input, OutputInterface $output) {
110
-		$user = $input->getOption('user');
111
-		$path = $input->getArgument('path');
112
-		if ($path === '-') {
113
-			$json = file_get_contents('php://stdin');
114
-		} else {
115
-			if (!file_exists($path)) {
116
-				$output->writeln('<error>File not found: ' . $path . '</error>');
117
-				return 1;
118
-			}
119
-			$json = file_get_contents($path);
120
-		}
121
-		if (!is_string($json) || strlen($json) < 2) {
122
-			$output->writeln('<error>Error while reading json</error>');
123
-			return 1;
124
-		}
125
-		$data = json_decode($json, true);
126
-		if (!is_array($data)) {
127
-			$output->writeln('<error>Error while parsing json</error>');
128
-			return 1;
129
-		}
130
-
131
-		$isLegacy = isset($data['user']) || isset($data['group']);
132
-		if ($isLegacy) {
133
-			$this->importLegacyStorageService->setData($data);
134
-			$mounts = $this->importLegacyStorageService->getAllStorages();
135
-			foreach ($mounts as $mount) {
136
-				if ($mount->getBackendOption('password') === false) {
137
-					$output->writeln('<error>Failed to decrypt password</error>');
138
-					return 1;
139
-				}
140
-			}
141
-		} else {
142
-			if (!isset($data[0])) { //normalize to an array of mounts
143
-				$data = [$data];
144
-			}
145
-			$mounts = array_map([$this, 'parseData'], $data);
146
-		}
147
-
148
-		if ($user) {
149
-			// ensure applicables are correct for personal mounts
150
-			foreach ($mounts as $mount) {
151
-				$mount->setApplicableGroups([]);
152
-				$mount->setApplicableUsers([$user]);
153
-			}
154
-		}
155
-
156
-		$storageService = $this->getStorageService($user);
157
-
158
-		$existingMounts = $storageService->getAllStorages();
159
-
160
-		foreach ($mounts as $mount) {
161
-			foreach ($existingMounts as $existingMount) {
162
-				if (
163
-					$existingMount->getMountPoint() === $mount->getMountPoint() &&
164
-					$existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
165
-					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
166
-					$existingMount->getBackendOptions() === $mount->getBackendOptions()
167
-				) {
168
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
169
-					return 1;
170
-				}
171
-			}
172
-		}
173
-
174
-		if ($input->getOption('dry')) {
175
-			if (count($mounts) === 0) {
176
-				$output->writeln('<error>No mounts to be imported</error>');
177
-				return 1;
178
-			}
179
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
180
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
181
-			$listInput->setOption('output', $input->getOption('output'));
182
-			$listInput->setOption('show-password', true);
183
-			$listCommand->listMounts($user, $mounts, $listInput, $output);
184
-		} else {
185
-			foreach ($mounts as $mount) {
186
-				$storageService->addStorage($mount);
187
-			}
188
-		}
189
-		return 0;
190
-	}
191
-
192
-	private function parseData(array $data) {
193
-		$mount = new StorageConfig($data['mount_id']);
194
-		$mount->setMountPoint($data['mount_point']);
195
-		$mount->setBackend($this->getBackendByClass($data['storage']));
196
-		$authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
197
-		$mount->setAuthMechanism($authBackend);
198
-		$mount->setBackendOptions($data['configuration']);
199
-		$mount->setMountOptions($data['options']);
200
-		$mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
201
-		$mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
202
-		return $mount;
203
-	}
204
-
205
-	private function getBackendByClass($className) {
206
-		$backends = $this->backendService->getBackends();
207
-		foreach ($backends as $backend) {
208
-			if ($backend->getStorageClass() === $className) {
209
-				return $backend;
210
-			}
211
-		}
212
-	}
213
-
214
-	protected function getStorageService($userId) {
215
-		if (!empty($userId)) {
216
-			$user = $this->userManager->get($userId);
217
-			if (is_null($user)) {
218
-				throw new NoUserException("user $userId not found");
219
-			}
220
-			$this->userSession->setUser($user);
221
-			return $this->userService;
222
-		} else {
223
-			return $this->globalService;
224
-		}
225
-	}
43
+    /**
44
+     * @var GlobalStoragesService
45
+     */
46
+    private $globalService;
47
+
48
+    /**
49
+     * @var UserStoragesService
50
+     */
51
+    private $userService;
52
+
53
+    /**
54
+     * @var IUserSession
55
+     */
56
+    private $userSession;
57
+
58
+    /**
59
+     * @var IUserManager
60
+     */
61
+    private $userManager;
62
+
63
+    /** @var ImportLegacyStoragesService */
64
+    private $importLegacyStorageService;
65
+
66
+    /** @var BackendService */
67
+    private $backendService;
68
+
69
+    public function __construct(GlobalStoragesService $globalService,
70
+                            UserStoragesService $userService,
71
+                            IUserSession $userSession,
72
+                            IUserManager $userManager,
73
+                            ImportLegacyStoragesService $importLegacyStorageService,
74
+                            BackendService $backendService
75
+    ) {
76
+        parent::__construct();
77
+        $this->globalService = $globalService;
78
+        $this->userService = $userService;
79
+        $this->userSession = $userSession;
80
+        $this->userManager = $userManager;
81
+        $this->importLegacyStorageService = $importLegacyStorageService;
82
+        $this->backendService = $backendService;
83
+    }
84
+
85
+    protected function configure() {
86
+        $this
87
+            ->setName('files_external:import')
88
+            ->setDescription('Import mount configurations')
89
+            ->addOption(
90
+                'user',
91
+                '',
92
+                InputOption::VALUE_OPTIONAL,
93
+                'user to add the mount configurations for, if not set the mount will be added as system mount'
94
+            )
95
+            ->addArgument(
96
+                'path',
97
+                InputArgument::REQUIRED,
98
+                'path to a json file containing the mounts to import, use "-" to read from stdin'
99
+            )
100
+            ->addOption(
101
+                'dry',
102
+                '',
103
+                InputOption::VALUE_NONE,
104
+                'Don\'t save the imported mounts, only list the new mounts'
105
+            );
106
+        parent::configure();
107
+    }
108
+
109
+    protected function execute(InputInterface $input, OutputInterface $output) {
110
+        $user = $input->getOption('user');
111
+        $path = $input->getArgument('path');
112
+        if ($path === '-') {
113
+            $json = file_get_contents('php://stdin');
114
+        } else {
115
+            if (!file_exists($path)) {
116
+                $output->writeln('<error>File not found: ' . $path . '</error>');
117
+                return 1;
118
+            }
119
+            $json = file_get_contents($path);
120
+        }
121
+        if (!is_string($json) || strlen($json) < 2) {
122
+            $output->writeln('<error>Error while reading json</error>');
123
+            return 1;
124
+        }
125
+        $data = json_decode($json, true);
126
+        if (!is_array($data)) {
127
+            $output->writeln('<error>Error while parsing json</error>');
128
+            return 1;
129
+        }
130
+
131
+        $isLegacy = isset($data['user']) || isset($data['group']);
132
+        if ($isLegacy) {
133
+            $this->importLegacyStorageService->setData($data);
134
+            $mounts = $this->importLegacyStorageService->getAllStorages();
135
+            foreach ($mounts as $mount) {
136
+                if ($mount->getBackendOption('password') === false) {
137
+                    $output->writeln('<error>Failed to decrypt password</error>');
138
+                    return 1;
139
+                }
140
+            }
141
+        } else {
142
+            if (!isset($data[0])) { //normalize to an array of mounts
143
+                $data = [$data];
144
+            }
145
+            $mounts = array_map([$this, 'parseData'], $data);
146
+        }
147
+
148
+        if ($user) {
149
+            // ensure applicables are correct for personal mounts
150
+            foreach ($mounts as $mount) {
151
+                $mount->setApplicableGroups([]);
152
+                $mount->setApplicableUsers([$user]);
153
+            }
154
+        }
155
+
156
+        $storageService = $this->getStorageService($user);
157
+
158
+        $existingMounts = $storageService->getAllStorages();
159
+
160
+        foreach ($mounts as $mount) {
161
+            foreach ($existingMounts as $existingMount) {
162
+                if (
163
+                    $existingMount->getMountPoint() === $mount->getMountPoint() &&
164
+                    $existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
165
+                    $existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
166
+                    $existingMount->getBackendOptions() === $mount->getBackendOptions()
167
+                ) {
168
+                    $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
169
+                    return 1;
170
+                }
171
+            }
172
+        }
173
+
174
+        if ($input->getOption('dry')) {
175
+            if (count($mounts) === 0) {
176
+                $output->writeln('<error>No mounts to be imported</error>');
177
+                return 1;
178
+            }
179
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
180
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
181
+            $listInput->setOption('output', $input->getOption('output'));
182
+            $listInput->setOption('show-password', true);
183
+            $listCommand->listMounts($user, $mounts, $listInput, $output);
184
+        } else {
185
+            foreach ($mounts as $mount) {
186
+                $storageService->addStorage($mount);
187
+            }
188
+        }
189
+        return 0;
190
+    }
191
+
192
+    private function parseData(array $data) {
193
+        $mount = new StorageConfig($data['mount_id']);
194
+        $mount->setMountPoint($data['mount_point']);
195
+        $mount->setBackend($this->getBackendByClass($data['storage']));
196
+        $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
197
+        $mount->setAuthMechanism($authBackend);
198
+        $mount->setBackendOptions($data['configuration']);
199
+        $mount->setMountOptions($data['options']);
200
+        $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
201
+        $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
202
+        return $mount;
203
+    }
204
+
205
+    private function getBackendByClass($className) {
206
+        $backends = $this->backendService->getBackends();
207
+        foreach ($backends as $backend) {
208
+            if ($backend->getStorageClass() === $className) {
209
+                return $backend;
210
+            }
211
+        }
212
+    }
213
+
214
+    protected function getStorageService($userId) {
215
+        if (!empty($userId)) {
216
+            $user = $this->userManager->get($userId);
217
+            if (is_null($user)) {
218
+                throw new NoUserException("user $userId not found");
219
+            }
220
+            $this->userSession->setUser($user);
221
+            return $this->userService;
222
+        } else {
223
+            return $this->globalService;
224
+        }
225
+    }
226 226
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/Migration/OwncloudGuestShareType.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
 
69 69
 		$query = $this->connection->getQueryBuilder();
70 70
 		$query->update('share')
71
-			->set('share_type',  $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
71
+			->set('share_type', $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
72 72
 			->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL)));
73 73
 		$query->execute();
74 74
 	}
Please login to merge, or discard this patch.
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -36,47 +36,47 @@
 block discarded – undo
36 36
  */
37 37
 class OwncloudGuestShareType implements IRepairStep {
38 38
 
39
-	/** @var IDBConnection */
40
-	private $connection;
39
+    /** @var IDBConnection */
40
+    private $connection;
41 41
 
42
-	/** @var  IConfig */
43
-	private $config;
42
+    /** @var  IConfig */
43
+    private $config;
44 44
 
45 45
 
46
-	public function __construct(IDBConnection $connection, IConfig $config) {
47
-		$this->connection = $connection;
48
-		$this->config = $config;
49
-	}
46
+    public function __construct(IDBConnection $connection, IConfig $config) {
47
+        $this->connection = $connection;
48
+        $this->config = $config;
49
+    }
50 50
 
51
-	/**
52
-	 * Returns the step's name
53
-	 *
54
-	 * @return string
55
-	 * @since 9.1.0
56
-	 */
57
-	public function getName() {
58
-		return 'Fix the share type of guest shares when migrating from ownCloud';
59
-	}
51
+    /**
52
+     * Returns the step's name
53
+     *
54
+     * @return string
55
+     * @since 9.1.0
56
+     */
57
+    public function getName() {
58
+        return 'Fix the share type of guest shares when migrating from ownCloud';
59
+    }
60 60
 
61
-	/**
62
-	 * @param IOutput $output
63
-	 */
64
-	public function run(IOutput $output) {
65
-		if (!$this->shouldRun()) {
66
-			return;
67
-		}
61
+    /**
62
+     * @param IOutput $output
63
+     */
64
+    public function run(IOutput $output) {
65
+        if (!$this->shouldRun()) {
66
+            return;
67
+        }
68 68
 
69
-		$query = $this->connection->getQueryBuilder();
70
-		$query->update('share')
71
-			->set('share_type',  $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
72
-			->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL)));
73
-		$query->execute();
74
-	}
69
+        $query = $this->connection->getQueryBuilder();
70
+        $query->update('share')
71
+            ->set('share_type',  $query->createNamedParameter(Share::SHARE_TYPE_GUEST))
72
+            ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_EMAIL)));
73
+        $query->execute();
74
+    }
75 75
 
76
-	protected function shouldRun() {
77
-		$appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
78
-		return $appVersion === '0.10.0' ||
79
-			$this->config->getAppValue('core', 'vendor', '') === 'owncloud';
80
-	}
76
+    protected function shouldRun() {
77
+        $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
78
+        return $appVersion === '0.10.0' ||
79
+            $this->config->getAppValue('core', 'vendor', '') === 'owncloud';
80
+    }
81 81
 
82 82
 }
Please login to merge, or discard this patch.
apps/oauth2/lib/Db/Client.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@
 block discarded – undo
34 34
  * @method void setName(string $name)
35 35
  */
36 36
 class Client extends Entity {
37
-	/** @var string */
38
-	protected $name;
39
-	/** @var string */
40
-	protected $redirectUri;
41
-	/** @var string */
42
-	protected $clientIdentifier;
43
-	/** @var string */
44
-	protected $secret;
37
+    /** @var string */
38
+    protected $name;
39
+    /** @var string */
40
+    protected $redirectUri;
41
+    /** @var string */
42
+    protected $clientIdentifier;
43
+    /** @var string */
44
+    protected $secret;
45 45
 
46
-	public function __construct() {
47
-		$this->addType('id', 'int');
48
-		$this->addType('name', 'string');
49
-		$this->addType('redirect_uri', 'string');
50
-		$this->addType('client_identifier', 'string');
51
-		$this->addType('secret', 'string');
52
-	}
46
+    public function __construct() {
47
+        $this->addType('id', 'int');
48
+        $this->addType('name', 'string');
49
+        $this->addType('redirect_uri', 'string');
50
+        $this->addType('client_identifier', 'string');
51
+        $this->addType('secret', 'string');
52
+    }
53 53
 }
Please login to merge, or discard this patch.
lib/public/Authentication/LoginCredentials/ICredentials.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -31,31 +31,31 @@
 block discarded – undo
31 31
  */
32 32
 interface ICredentials {
33 33
 
34
-	/**
35
-	 * Get the user UID
36
-	 *
37
-	 * @since 12
38
-	 *
39
-	 * @return string
40
-	 */
41
-	public function getUID();
34
+    /**
35
+     * Get the user UID
36
+     *
37
+     * @since 12
38
+     *
39
+     * @return string
40
+     */
41
+    public function getUID();
42 42
 
43
-	/**
44
-	 * Get the login name the users used to login
45
-	 *
46
-	 * @since 12
47
-	 *
48
-	 * @return string
49
-	 */
50
-	public function getLoginName();
43
+    /**
44
+     * Get the login name the users used to login
45
+     *
46
+     * @since 12
47
+     *
48
+     * @return string
49
+     */
50
+    public function getLoginName();
51 51
 
52
-	/**
53
-	 * Get the password
54
-	 *
55
-	 * @since 12
56
-	 *
57
-	 * @return string
58
-	 * @throws PasswordUnavailableException
59
-	 */
60
-	public function getPassword();
52
+    /**
53
+     * Get the password
54
+     *
55
+     * @since 12
56
+     *
57
+     * @return string
58
+     * @throws PasswordUnavailableException
59
+     */
60
+    public function getPassword();
61 61
 }
Please login to merge, or discard this patch.
lib/private/Files/Cache/Wrapper/CachePermissionsMask.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -24,25 +24,25 @@
 block discarded – undo
24 24
 namespace OC\Files\Cache\Wrapper;
25 25
 
26 26
 class CachePermissionsMask extends CacheWrapper {
27
-	/**
28
-	 * @var int
29
-	 */
30
-	protected $mask;
27
+    /**
28
+     * @var int
29
+     */
30
+    protected $mask;
31 31
 
32
-	/**
33
-	 * @param \OCP\Files\Cache\ICache $cache
34
-	 * @param int $mask
35
-	 */
36
-	public function __construct($cache, $mask) {
37
-		parent::__construct($cache);
38
-		$this->mask = $mask;
39
-	}
32
+    /**
33
+     * @param \OCP\Files\Cache\ICache $cache
34
+     * @param int $mask
35
+     */
36
+    public function __construct($cache, $mask) {
37
+        parent::__construct($cache);
38
+        $this->mask = $mask;
39
+    }
40 40
 
41
-	protected function formatCacheEntry($entry) {
42
-		if (isset($entry['permissions'])) {
43
-			$entry['scan_permissions'] = $entry['permissions'];
44
-			$entry['permissions'] &= $this->mask;
45
-		}
46
-		return $entry;
47
-	}
41
+    protected function formatCacheEntry($entry) {
42
+        if (isset($entry['permissions'])) {
43
+            $entry['scan_permissions'] = $entry['permissions'];
44
+            $entry['permissions'] &= $this->mask;
45
+        }
46
+        return $entry;
47
+    }
48 48
 }
Please login to merge, or discard this patch.