Passed
Push — master ( cb2b38...37146c )
by Roeland
12:06 queued 11s
created
apps/dav/lib/CardDAV/ImageExportPlugin.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -32,85 +32,85 @@
 block discarded – undo
32 32
 
33 33
 class ImageExportPlugin extends ServerPlugin {
34 34
 
35
-	/** @var Server */
36
-	protected $server;
37
-	/** @var PhotoCache */
38
-	private $cache;
39
-
40
-	/**
41
-	 * ImageExportPlugin constructor.
42
-	 *
43
-	 * @param PhotoCache $cache
44
-	 */
45
-	public function __construct(PhotoCache $cache) {
46
-		$this->cache = $cache;
47
-	}
48
-
49
-	/**
50
-	 * Initializes the plugin and registers event handlers
51
-	 *
52
-	 * @param Server $server
53
-	 * @return void
54
-	 */
55
-	public function initialize(Server $server) {
56
-		$this->server = $server;
57
-		$this->server->on('method:GET', [$this, 'httpGet'], 90);
58
-	}
59
-
60
-	/**
61
-	 * Intercepts GET requests on addressbook urls ending with ?photo.
62
-	 *
63
-	 * @param RequestInterface $request
64
-	 * @param ResponseInterface $response
65
-	 * @return bool
66
-	 */
67
-	public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
-
69
-		$queryParams = $request->getQueryParameters();
70
-		// TODO: in addition to photo we should also add logo some point in time
71
-		if (!array_key_exists('photo', $queryParams)) {
72
-			return true;
73
-		}
74
-
75
-		$size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
-
77
-		$path = $request->getPath();
78
-		$node = $this->server->tree->getNodeForPath($path);
79
-
80
-		if (!($node instanceof Card)) {
81
-			return true;
82
-		}
83
-
84
-		$this->server->transactionType = 'carddav-image-export';
85
-
86
-		// Checking ACL, if available.
87
-		if ($aclPlugin = $this->server->getPlugin('acl')) {
88
-			/** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
-			$aclPlugin->checkPrivileges($path, '{DAV:}read');
90
-		}
91
-
92
-		// Fetch addressbook
93
-		$addressbookpath = explode('/', $path);
94
-		array_pop($addressbookpath);
95
-		$addressbookpath = implode('/', $addressbookpath);
96
-		/** @var AddressBook $addressbook */
97
-		$addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
-
99
-		$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
-		$response->setHeader('Etag', $node->getETag() );
101
-		$response->setHeader('Pragma', 'public');
102
-
103
-		try {
104
-			$file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
-			$response->setHeader('Content-Type', $file->getMimeType());
106
-			$response->setHeader('Content-Disposition', 'attachment');
107
-			$response->setStatus(200);
108
-
109
-			$response->setBody($file->getContent());
110
-		} catch (NotFoundException $e) {
111
-			$response->setStatus(404);
112
-		}
113
-
114
-		return false;
115
-	}
35
+    /** @var Server */
36
+    protected $server;
37
+    /** @var PhotoCache */
38
+    private $cache;
39
+
40
+    /**
41
+     * ImageExportPlugin constructor.
42
+     *
43
+     * @param PhotoCache $cache
44
+     */
45
+    public function __construct(PhotoCache $cache) {
46
+        $this->cache = $cache;
47
+    }
48
+
49
+    /**
50
+     * Initializes the plugin and registers event handlers
51
+     *
52
+     * @param Server $server
53
+     * @return void
54
+     */
55
+    public function initialize(Server $server) {
56
+        $this->server = $server;
57
+        $this->server->on('method:GET', [$this, 'httpGet'], 90);
58
+    }
59
+
60
+    /**
61
+     * Intercepts GET requests on addressbook urls ending with ?photo.
62
+     *
63
+     * @param RequestInterface $request
64
+     * @param ResponseInterface $response
65
+     * @return bool
66
+     */
67
+    public function httpGet(RequestInterface $request, ResponseInterface $response) {
68
+
69
+        $queryParams = $request->getQueryParameters();
70
+        // TODO: in addition to photo we should also add logo some point in time
71
+        if (!array_key_exists('photo', $queryParams)) {
72
+            return true;
73
+        }
74
+
75
+        $size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
76
+
77
+        $path = $request->getPath();
78
+        $node = $this->server->tree->getNodeForPath($path);
79
+
80
+        if (!($node instanceof Card)) {
81
+            return true;
82
+        }
83
+
84
+        $this->server->transactionType = 'carddav-image-export';
85
+
86
+        // Checking ACL, if available.
87
+        if ($aclPlugin = $this->server->getPlugin('acl')) {
88
+            /** @var \Sabre\DAVACL\Plugin $aclPlugin */
89
+            $aclPlugin->checkPrivileges($path, '{DAV:}read');
90
+        }
91
+
92
+        // Fetch addressbook
93
+        $addressbookpath = explode('/', $path);
94
+        array_pop($addressbookpath);
95
+        $addressbookpath = implode('/', $addressbookpath);
96
+        /** @var AddressBook $addressbook */
97
+        $addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98
+
99
+        $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
+        $response->setHeader('Etag', $node->getETag() );
101
+        $response->setHeader('Pragma', 'public');
102
+
103
+        try {
104
+            $file = $this->cache->get($addressbook->getResourceId(), $node->getName(), $size, $node);
105
+            $response->setHeader('Content-Type', $file->getMimeType());
106
+            $response->setHeader('Content-Disposition', 'attachment');
107
+            $response->setStatus(200);
108
+
109
+            $response->setBody($file->getContent());
110
+        } catch (NotFoundException $e) {
111
+            $response->setStatus(404);
112
+        }
113
+
114
+        return false;
115
+    }
116 116
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			return true;
73 73
 		}
74 74
 
75
-		$size = isset($queryParams['size']) ? (int)$queryParams['size'] : -1;
75
+		$size = isset($queryParams['size']) ? (int) $queryParams['size'] : -1;
76 76
 
77 77
 		$path = $request->getPath();
78 78
 		$node = $this->server->tree->getNodeForPath($path);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 		$addressbook = $this->server->tree->getNodeForPath($addressbookpath);
98 98
 
99 99
 		$response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate');
100
-		$response->setHeader('Etag', $node->getETag() );
100
+		$response->setHeader('Etag', $node->getETag());
101 101
 		$response->setHeader('Pragma', 'public');
102 102
 
103 103
 		try {
Please login to merge, or discard this patch.
core/templates/layout.guest.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
 									<?php p($theme->getName()); ?>
42 42
 								</h1>
43 43
 								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
44
-									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
44
+                                    && \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
45 45
 									<img src="<?php p($theme->getLogo()); ?>"/>
46 46
 								<?php endif; ?>
47 47
 							</div>
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,21 +18,21 @@
 block discarded – undo
18 18
 		<?php emit_script_loading_tags($_); ?>
19 19
 		<?php print_unescaped($_['headers']); ?>
20 20
 	</head>
21
-	<body id="<?php p($_['bodyid']);?>">
21
+	<body id="<?php p($_['bodyid']); ?>">
22 22
 		<?php include 'layout.noscript.warning.php'; ?>
23 23
 		<?php foreach ($_['initialStates'] as $app => $initialState) { ?>
24 24
 			<input type="hidden" id="initial-state-<?php p($app); ?>" value="<?php p(base64_encode($initialState)); ?>">
25 25
 		<?php }?>
26 26
 		<div class="wrapper">
27 27
 			<div class="v-align">
28
-				<?php if ($_['bodyid'] === 'body-login' ): ?>
28
+				<?php if ($_['bodyid'] === 'body-login'): ?>
29 29
 					<header role="banner">
30 30
 						<div id="header">
31 31
 							<div class="logo">
32 32
 								<h1 class="hidden-visually">
33 33
 									<?php p($theme->getName()); ?>
34 34
 								</h1>
35
-								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
35
+								<?php if (\OC::$server->getConfig()->getSystemValue('installed', false)
36 36
 									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
37 37
 									<img src="<?php p($theme->getLogo()); ?>"/>
38 38
 								<?php endif; ?>
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
@@ -39,187 +39,187 @@
 block discarded – undo
39 39
 use Symfony\Component\Console\Output\OutputInterface;
40 40
 
41 41
 class Import extends Base {
42
-	/**
43
-	 * @var GlobalStoragesService
44
-	 */
45
-	private $globalService;
46
-
47
-	/**
48
-	 * @var UserStoragesService
49
-	 */
50
-	private $userService;
51
-
52
-	/**
53
-	 * @var IUserSession
54
-	 */
55
-	private $userSession;
56
-
57
-	/**
58
-	 * @var IUserManager
59
-	 */
60
-	private $userManager;
61
-
62
-	/** @var ImportLegacyStoragesService */
63
-	private $importLegacyStorageService;
64
-
65
-	/** @var BackendService */
66
-	private $backendService;
67
-
68
-	function __construct(GlobalStoragesService $globalService,
69
-						 UserStoragesService $userService,
70
-						 IUserSession $userSession,
71
-						 IUserManager $userManager,
72
-						 ImportLegacyStoragesService $importLegacyStorageService,
73
-						 BackendService $backendService
74
-	) {
75
-		parent::__construct();
76
-		$this->globalService = $globalService;
77
-		$this->userService = $userService;
78
-		$this->userSession = $userSession;
79
-		$this->userManager = $userManager;
80
-		$this->importLegacyStorageService = $importLegacyStorageService;
81
-		$this->backendService = $backendService;
82
-	}
83
-
84
-	protected function configure() {
85
-		$this
86
-			->setName('files_external:import')
87
-			->setDescription('Import mount configurations')
88
-			->addOption(
89
-				'user',
90
-				'',
91
-				InputOption::VALUE_OPTIONAL,
92
-				'user to add the mount configurations for, if not set the mount will be added as system mount'
93
-			)
94
-			->addArgument(
95
-				'path',
96
-				InputArgument::REQUIRED,
97
-				'path to a json file containing the mounts to import, use "-" to read from stdin'
98
-			)
99
-			->addOption(
100
-				'dry',
101
-				'',
102
-				InputOption::VALUE_NONE,
103
-				'Don\'t save the imported mounts, only list the new mounts'
104
-			);
105
-		parent::configure();
106
-	}
107
-
108
-	protected function execute(InputInterface $input, OutputInterface $output) {
109
-		$user = $input->getOption('user');
110
-		$path = $input->getArgument('path');
111
-		if ($path === '-') {
112
-			$json = file_get_contents('php://stdin');
113
-		} else {
114
-			if (!file_exists($path)) {
115
-				$output->writeln('<error>File not found: ' . $path . '</error>');
116
-				return 1;
117
-			}
118
-			$json = file_get_contents($path);
119
-		}
120
-		if (!is_string($json) || strlen($json) < 2) {
121
-			$output->writeln('<error>Error while reading json</error>');
122
-			return 1;
123
-		}
124
-		$data = json_decode($json, true);
125
-		if (!is_array($data)) {
126
-			$output->writeln('<error>Error while parsing json</error>');
127
-			return 1;
128
-		}
129
-
130
-		$isLegacy = isset($data['user']) || isset($data['group']);
131
-		if ($isLegacy) {
132
-			$this->importLegacyStorageService->setData($data);
133
-			$mounts = $this->importLegacyStorageService->getAllStorages();
134
-			foreach ($mounts as $mount) {
135
-				if ($mount->getBackendOption('password') === false) {
136
-					$output->writeln('<error>Failed to decrypt password</error>');
137
-					return 1;
138
-				}
139
-			}
140
-		} else {
141
-			if (!isset($data[0])) { //normalize to an array of mounts
142
-				$data = [$data];
143
-			}
144
-			$mounts = array_map([$this, 'parseData'], $data);
145
-		}
146
-
147
-		if ($user) {
148
-			// ensure applicables are correct for personal mounts
149
-			foreach ($mounts as $mount) {
150
-				$mount->setApplicableGroups([]);
151
-				$mount->setApplicableUsers([$user]);
152
-			}
153
-		}
154
-
155
-		$storageService = $this->getStorageService($user);
156
-
157
-		$existingMounts = $storageService->getAllStorages();
158
-
159
-		foreach ($mounts as $mount) {
160
-			foreach ($existingMounts as $existingMount) {
161
-				if (
162
-					$existingMount->getMountPoint() === $mount->getMountPoint() &&
163
-					$existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
164
-					$existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165
-					$existingMount->getBackendOptions() === $mount->getBackendOptions()
166
-				) {
167
-					$output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
168
-					return 1;
169
-				}
170
-			}
171
-		}
172
-
173
-		if ($input->getOption('dry')) {
174
-			if (count($mounts) === 0) {
175
-				$output->writeln('<error>No mounts to be imported</error>');
176
-				return 1;
177
-			}
178
-			$listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
179
-			$listInput = new ArrayInput([], $listCommand->getDefinition());
180
-			$listInput->setOption('output', $input->getOption('output'));
181
-			$listInput->setOption('show-password', true);
182
-			$listCommand->listMounts($user, $mounts, $listInput, $output);
183
-		} else {
184
-			foreach ($mounts as $mount) {
185
-				$storageService->addStorage($mount);
186
-			}
187
-		}
188
-		return 0;
189
-	}
190
-
191
-	private function parseData(array $data) {
192
-		$mount = new StorageConfig($data['mount_id']);
193
-		$mount->setMountPoint($data['mount_point']);
194
-		$mount->setBackend($this->getBackendByClass($data['storage']));
195
-		$authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
196
-		$mount->setAuthMechanism($authBackend);
197
-		$mount->setBackendOptions($data['configuration']);
198
-		$mount->setMountOptions($data['options']);
199
-		$mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
200
-		$mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
201
-		return $mount;
202
-	}
203
-
204
-	private function getBackendByClass($className) {
205
-		$backends = $this->backendService->getBackends();
206
-		foreach ($backends as $backend) {
207
-			if ($backend->getStorageClass() === $className) {
208
-				return $backend;
209
-			}
210
-		}
211
-	}
212
-
213
-	protected function getStorageService($userId) {
214
-		if (!empty($userId)) {
215
-			$user = $this->userManager->get($userId);
216
-			if (is_null($user)) {
217
-				throw new NoUserException("user $userId not found");
218
-			}
219
-			$this->userSession->setUser($user);
220
-			return $this->userService;
221
-		} else {
222
-			return $this->globalService;
223
-		}
224
-	}
42
+    /**
43
+     * @var GlobalStoragesService
44
+     */
45
+    private $globalService;
46
+
47
+    /**
48
+     * @var UserStoragesService
49
+     */
50
+    private $userService;
51
+
52
+    /**
53
+     * @var IUserSession
54
+     */
55
+    private $userSession;
56
+
57
+    /**
58
+     * @var IUserManager
59
+     */
60
+    private $userManager;
61
+
62
+    /** @var ImportLegacyStoragesService */
63
+    private $importLegacyStorageService;
64
+
65
+    /** @var BackendService */
66
+    private $backendService;
67
+
68
+    function __construct(GlobalStoragesService $globalService,
69
+                            UserStoragesService $userService,
70
+                            IUserSession $userSession,
71
+                            IUserManager $userManager,
72
+                            ImportLegacyStoragesService $importLegacyStorageService,
73
+                            BackendService $backendService
74
+    ) {
75
+        parent::__construct();
76
+        $this->globalService = $globalService;
77
+        $this->userService = $userService;
78
+        $this->userSession = $userSession;
79
+        $this->userManager = $userManager;
80
+        $this->importLegacyStorageService = $importLegacyStorageService;
81
+        $this->backendService = $backendService;
82
+    }
83
+
84
+    protected function configure() {
85
+        $this
86
+            ->setName('files_external:import')
87
+            ->setDescription('Import mount configurations')
88
+            ->addOption(
89
+                'user',
90
+                '',
91
+                InputOption::VALUE_OPTIONAL,
92
+                'user to add the mount configurations for, if not set the mount will be added as system mount'
93
+            )
94
+            ->addArgument(
95
+                'path',
96
+                InputArgument::REQUIRED,
97
+                'path to a json file containing the mounts to import, use "-" to read from stdin'
98
+            )
99
+            ->addOption(
100
+                'dry',
101
+                '',
102
+                InputOption::VALUE_NONE,
103
+                'Don\'t save the imported mounts, only list the new mounts'
104
+            );
105
+        parent::configure();
106
+    }
107
+
108
+    protected function execute(InputInterface $input, OutputInterface $output) {
109
+        $user = $input->getOption('user');
110
+        $path = $input->getArgument('path');
111
+        if ($path === '-') {
112
+            $json = file_get_contents('php://stdin');
113
+        } else {
114
+            if (!file_exists($path)) {
115
+                $output->writeln('<error>File not found: ' . $path . '</error>');
116
+                return 1;
117
+            }
118
+            $json = file_get_contents($path);
119
+        }
120
+        if (!is_string($json) || strlen($json) < 2) {
121
+            $output->writeln('<error>Error while reading json</error>');
122
+            return 1;
123
+        }
124
+        $data = json_decode($json, true);
125
+        if (!is_array($data)) {
126
+            $output->writeln('<error>Error while parsing json</error>');
127
+            return 1;
128
+        }
129
+
130
+        $isLegacy = isset($data['user']) || isset($data['group']);
131
+        if ($isLegacy) {
132
+            $this->importLegacyStorageService->setData($data);
133
+            $mounts = $this->importLegacyStorageService->getAllStorages();
134
+            foreach ($mounts as $mount) {
135
+                if ($mount->getBackendOption('password') === false) {
136
+                    $output->writeln('<error>Failed to decrypt password</error>');
137
+                    return 1;
138
+                }
139
+            }
140
+        } else {
141
+            if (!isset($data[0])) { //normalize to an array of mounts
142
+                $data = [$data];
143
+            }
144
+            $mounts = array_map([$this, 'parseData'], $data);
145
+        }
146
+
147
+        if ($user) {
148
+            // ensure applicables are correct for personal mounts
149
+            foreach ($mounts as $mount) {
150
+                $mount->setApplicableGroups([]);
151
+                $mount->setApplicableUsers([$user]);
152
+            }
153
+        }
154
+
155
+        $storageService = $this->getStorageService($user);
156
+
157
+        $existingMounts = $storageService->getAllStorages();
158
+
159
+        foreach ($mounts as $mount) {
160
+            foreach ($existingMounts as $existingMount) {
161
+                if (
162
+                    $existingMount->getMountPoint() === $mount->getMountPoint() &&
163
+                    $existingMount->getApplicableGroups() === $mount->getApplicableGroups() &&
164
+                    $existingMount->getApplicableUsers() === $mount->getApplicableUsers() &&
165
+                    $existingMount->getBackendOptions() === $mount->getBackendOptions()
166
+                ) {
167
+                    $output->writeln("<error>Duplicate mount (" . $mount->getMountPoint() . ")</error>");
168
+                    return 1;
169
+                }
170
+            }
171
+        }
172
+
173
+        if ($input->getOption('dry')) {
174
+            if (count($mounts) === 0) {
175
+                $output->writeln('<error>No mounts to be imported</error>');
176
+                return 1;
177
+            }
178
+            $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager);
179
+            $listInput = new ArrayInput([], $listCommand->getDefinition());
180
+            $listInput->setOption('output', $input->getOption('output'));
181
+            $listInput->setOption('show-password', true);
182
+            $listCommand->listMounts($user, $mounts, $listInput, $output);
183
+        } else {
184
+            foreach ($mounts as $mount) {
185
+                $storageService->addStorage($mount);
186
+            }
187
+        }
188
+        return 0;
189
+    }
190
+
191
+    private function parseData(array $data) {
192
+        $mount = new StorageConfig($data['mount_id']);
193
+        $mount->setMountPoint($data['mount_point']);
194
+        $mount->setBackend($this->getBackendByClass($data['storage']));
195
+        $authBackend = $this->backendService->getAuthMechanism($data['authentication_type']);
196
+        $mount->setAuthMechanism($authBackend);
197
+        $mount->setBackendOptions($data['configuration']);
198
+        $mount->setMountOptions($data['options']);
199
+        $mount->setApplicableUsers(isset($data['applicable_users']) ? $data['applicable_users'] : []);
200
+        $mount->setApplicableGroups(isset($data['applicable_groups']) ? $data['applicable_groups'] : []);
201
+        return $mount;
202
+    }
203
+
204
+    private function getBackendByClass($className) {
205
+        $backends = $this->backendService->getBackends();
206
+        foreach ($backends as $backend) {
207
+            if ($backend->getStorageClass() === $className) {
208
+                return $backend;
209
+            }
210
+        }
211
+    }
212
+
213
+    protected function getStorageService($userId) {
214
+        if (!empty($userId)) {
215
+            $user = $this->userManager->get($userId);
216
+            if (is_null($user)) {
217
+                throw new NoUserException("user $userId not found");
218
+            }
219
+            $this->userSession->setUser($user);
220
+            return $this->userService;
221
+        } else {
222
+            return $this->globalService;
223
+        }
224
+    }
225 225
 }
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/files_sharing/lib/Migration/SetPasswordColumn.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -36,62 +36,62 @@
 block discarded – undo
36 36
  */
37 37
 class SetPasswordColumn implements IRepairStep {
38 38
 
39
-	/** @var IDBConnection */
40
-	private $connection;
41
-
42
-	/** @var  IConfig */
43
-	private $config;
44
-
45
-
46
-	public function __construct(IDBConnection $connection, IConfig $config) {
47
-		$this->connection = $connection;
48
-		$this->config = $config;
49
-	}
50
-
51
-	/**
52
-	 * Returns the step's name
53
-	 *
54
-	 * @return string
55
-	 * @since 9.1.0
56
-	 */
57
-	public function getName() {
58
-		return 'Copy the share password into the dedicated column';
59
-	}
60
-
61
-	/**
62
-	 * @param IOutput $output
63
-	 */
64
-	public function run(IOutput $output) {
65
-		if (!$this->shouldRun()) {
66
-			return;
67
-		}
68
-
69
-		$query = $this->connection->getQueryBuilder();
70
-		$query
71
-			->update('share')
72
-			->set('password', 'share_with')
73
-			->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
74
-			->andWhere($query->expr()->isNotNull('share_with'));
75
-		$result = $query->execute();
76
-
77
-		if ($result === 0) {
78
-			// No link updated, no need to run the second query
79
-			return;
80
-		}
81
-
82
-		$clearQuery = $this->connection->getQueryBuilder();
83
-		$clearQuery
84
-			->update('share')
85
-			->set('share_with', $clearQuery->createNamedParameter(null))
86
-			->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
87
-
88
-		$clearQuery->execute();
89
-
90
-	}
91
-
92
-	protected function shouldRun() {
93
-		$appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
94
-		return version_compare($appVersion, '1.4.0', '<');
95
-	}
39
+    /** @var IDBConnection */
40
+    private $connection;
41
+
42
+    /** @var  IConfig */
43
+    private $config;
44
+
45
+
46
+    public function __construct(IDBConnection $connection, IConfig $config) {
47
+        $this->connection = $connection;
48
+        $this->config = $config;
49
+    }
50
+
51
+    /**
52
+     * Returns the step's name
53
+     *
54
+     * @return string
55
+     * @since 9.1.0
56
+     */
57
+    public function getName() {
58
+        return 'Copy the share password into the dedicated column';
59
+    }
60
+
61
+    /**
62
+     * @param IOutput $output
63
+     */
64
+    public function run(IOutput $output) {
65
+        if (!$this->shouldRun()) {
66
+            return;
67
+        }
68
+
69
+        $query = $this->connection->getQueryBuilder();
70
+        $query
71
+            ->update('share')
72
+            ->set('password', 'share_with')
73
+            ->where($query->expr()->eq('share_type', $query->createNamedParameter(Share::SHARE_TYPE_LINK)))
74
+            ->andWhere($query->expr()->isNotNull('share_with'));
75
+        $result = $query->execute();
76
+
77
+        if ($result === 0) {
78
+            // No link updated, no need to run the second query
79
+            return;
80
+        }
81
+
82
+        $clearQuery = $this->connection->getQueryBuilder();
83
+        $clearQuery
84
+            ->update('share')
85
+            ->set('share_with', $clearQuery->createNamedParameter(null))
86
+            ->where($clearQuery->expr()->eq('share_type', $clearQuery->createNamedParameter(Share::SHARE_TYPE_LINK)));
87
+
88
+        $clearQuery->execute();
89
+
90
+    }
91
+
92
+    protected function shouldRun() {
93
+        $appVersion = $this->config->getAppValue('files_sharing', 'installed_version', '0.0.0');
94
+        return version_compare($appVersion, '1.4.0', '<');
95
+    }
96 96
 
97 97
 }
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.