@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | if ($provider === null) { |
217 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
217 | + throw new ProviderException('No provider with id .'.$id.' found.'); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | return $provider; |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | |
243 | 243 | if ($provider === null) { |
244 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
244 | + throw new ProviderException('No share provider for share type '.$shareType); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $provider; |
@@ -55,311 +55,311 @@ |
||
55 | 55 | */ |
56 | 56 | class ProviderFactory implements IProviderFactory { |
57 | 57 | |
58 | - /** @var IServerContainer */ |
|
59 | - private $serverContainer; |
|
60 | - /** @var DefaultShareProvider */ |
|
61 | - private $defaultProvider = null; |
|
62 | - /** @var FederatedShareProvider */ |
|
63 | - private $federatedProvider = null; |
|
64 | - /** @var ShareByMailProvider */ |
|
65 | - private $shareByMailProvider; |
|
66 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
67 | - private $shareByCircleProvider = null; |
|
68 | - /** @var bool */ |
|
69 | - private $circlesAreNotAvailable = false; |
|
70 | - /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
71 | - private $roomShareProvider = null; |
|
72 | - |
|
73 | - private $registeredShareProviders = []; |
|
74 | - |
|
75 | - private $shareProviders = []; |
|
76 | - |
|
77 | - /** |
|
78 | - * IProviderFactory constructor. |
|
79 | - * |
|
80 | - * @param IServerContainer $serverContainer |
|
81 | - */ |
|
82 | - public function __construct(IServerContainer $serverContainer) { |
|
83 | - $this->serverContainer = $serverContainer; |
|
84 | - } |
|
85 | - |
|
86 | - public function registerProvider(string $shareProviderClass): void { |
|
87 | - $this->registeredShareProviders[] = $shareProviderClass; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Create the default share provider. |
|
92 | - * |
|
93 | - * @return DefaultShareProvider |
|
94 | - */ |
|
95 | - protected function defaultShareProvider() { |
|
96 | - if ($this->defaultProvider === null) { |
|
97 | - $this->defaultProvider = new DefaultShareProvider( |
|
98 | - $this->serverContainer->getDatabaseConnection(), |
|
99 | - $this->serverContainer->getUserManager(), |
|
100 | - $this->serverContainer->getGroupManager(), |
|
101 | - $this->serverContainer->getLazyRootFolder(), |
|
102 | - $this->serverContainer->getMailer(), |
|
103 | - $this->serverContainer->query(Defaults::class), |
|
104 | - $this->serverContainer->getL10NFactory(), |
|
105 | - $this->serverContainer->getURLGenerator(), |
|
106 | - $this->serverContainer->getConfig() |
|
107 | - ); |
|
108 | - } |
|
109 | - |
|
110 | - return $this->defaultProvider; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Create the federated share provider |
|
115 | - * |
|
116 | - * @return FederatedShareProvider |
|
117 | - */ |
|
118 | - protected function federatedShareProvider() { |
|
119 | - if ($this->federatedProvider === null) { |
|
120 | - /* |
|
58 | + /** @var IServerContainer */ |
|
59 | + private $serverContainer; |
|
60 | + /** @var DefaultShareProvider */ |
|
61 | + private $defaultProvider = null; |
|
62 | + /** @var FederatedShareProvider */ |
|
63 | + private $federatedProvider = null; |
|
64 | + /** @var ShareByMailProvider */ |
|
65 | + private $shareByMailProvider; |
|
66 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
67 | + private $shareByCircleProvider = null; |
|
68 | + /** @var bool */ |
|
69 | + private $circlesAreNotAvailable = false; |
|
70 | + /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
71 | + private $roomShareProvider = null; |
|
72 | + |
|
73 | + private $registeredShareProviders = []; |
|
74 | + |
|
75 | + private $shareProviders = []; |
|
76 | + |
|
77 | + /** |
|
78 | + * IProviderFactory constructor. |
|
79 | + * |
|
80 | + * @param IServerContainer $serverContainer |
|
81 | + */ |
|
82 | + public function __construct(IServerContainer $serverContainer) { |
|
83 | + $this->serverContainer = $serverContainer; |
|
84 | + } |
|
85 | + |
|
86 | + public function registerProvider(string $shareProviderClass): void { |
|
87 | + $this->registeredShareProviders[] = $shareProviderClass; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Create the default share provider. |
|
92 | + * |
|
93 | + * @return DefaultShareProvider |
|
94 | + */ |
|
95 | + protected function defaultShareProvider() { |
|
96 | + if ($this->defaultProvider === null) { |
|
97 | + $this->defaultProvider = new DefaultShareProvider( |
|
98 | + $this->serverContainer->getDatabaseConnection(), |
|
99 | + $this->serverContainer->getUserManager(), |
|
100 | + $this->serverContainer->getGroupManager(), |
|
101 | + $this->serverContainer->getLazyRootFolder(), |
|
102 | + $this->serverContainer->getMailer(), |
|
103 | + $this->serverContainer->query(Defaults::class), |
|
104 | + $this->serverContainer->getL10NFactory(), |
|
105 | + $this->serverContainer->getURLGenerator(), |
|
106 | + $this->serverContainer->getConfig() |
|
107 | + ); |
|
108 | + } |
|
109 | + |
|
110 | + return $this->defaultProvider; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Create the federated share provider |
|
115 | + * |
|
116 | + * @return FederatedShareProvider |
|
117 | + */ |
|
118 | + protected function federatedShareProvider() { |
|
119 | + if ($this->federatedProvider === null) { |
|
120 | + /* |
|
121 | 121 | * Check if the app is enabled |
122 | 122 | */ |
123 | - $appManager = $this->serverContainer->getAppManager(); |
|
124 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
125 | - return null; |
|
126 | - } |
|
123 | + $appManager = $this->serverContainer->getAppManager(); |
|
124 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
125 | + return null; |
|
126 | + } |
|
127 | 127 | |
128 | - /* |
|
128 | + /* |
|
129 | 129 | * TODO: add factory to federated sharing app |
130 | 130 | */ |
131 | - $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
132 | - $addressHandler = new AddressHandler( |
|
133 | - $this->serverContainer->getURLGenerator(), |
|
134 | - $l, |
|
135 | - $this->serverContainer->getCloudIdManager() |
|
136 | - ); |
|
137 | - $notifications = new Notifications( |
|
138 | - $addressHandler, |
|
139 | - $this->serverContainer->getHTTPClientService(), |
|
140 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
141 | - $this->serverContainer->getLogger(), |
|
142 | - $this->serverContainer->getJobList(), |
|
143 | - \OC::$server->getCloudFederationProviderManager(), |
|
144 | - \OC::$server->getCloudFederationFactory(), |
|
145 | - $this->serverContainer->query(IEventDispatcher::class) |
|
146 | - ); |
|
147 | - $tokenHandler = new TokenHandler( |
|
148 | - $this->serverContainer->getSecureRandom() |
|
149 | - ); |
|
150 | - |
|
151 | - $this->federatedProvider = new FederatedShareProvider( |
|
152 | - $this->serverContainer->getDatabaseConnection(), |
|
153 | - $addressHandler, |
|
154 | - $notifications, |
|
155 | - $tokenHandler, |
|
156 | - $l, |
|
157 | - $this->serverContainer->getLogger(), |
|
158 | - $this->serverContainer->getLazyRootFolder(), |
|
159 | - $this->serverContainer->getConfig(), |
|
160 | - $this->serverContainer->getUserManager(), |
|
161 | - $this->serverContainer->getCloudIdManager(), |
|
162 | - $this->serverContainer->getGlobalScaleConfig(), |
|
163 | - $this->serverContainer->getCloudFederationProviderManager() |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - return $this->federatedProvider; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Create the federated share provider |
|
172 | - * |
|
173 | - * @return ShareByMailProvider |
|
174 | - */ |
|
175 | - protected function getShareByMailProvider() { |
|
176 | - if ($this->shareByMailProvider === null) { |
|
177 | - /* |
|
131 | + $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
132 | + $addressHandler = new AddressHandler( |
|
133 | + $this->serverContainer->getURLGenerator(), |
|
134 | + $l, |
|
135 | + $this->serverContainer->getCloudIdManager() |
|
136 | + ); |
|
137 | + $notifications = new Notifications( |
|
138 | + $addressHandler, |
|
139 | + $this->serverContainer->getHTTPClientService(), |
|
140 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
141 | + $this->serverContainer->getLogger(), |
|
142 | + $this->serverContainer->getJobList(), |
|
143 | + \OC::$server->getCloudFederationProviderManager(), |
|
144 | + \OC::$server->getCloudFederationFactory(), |
|
145 | + $this->serverContainer->query(IEventDispatcher::class) |
|
146 | + ); |
|
147 | + $tokenHandler = new TokenHandler( |
|
148 | + $this->serverContainer->getSecureRandom() |
|
149 | + ); |
|
150 | + |
|
151 | + $this->federatedProvider = new FederatedShareProvider( |
|
152 | + $this->serverContainer->getDatabaseConnection(), |
|
153 | + $addressHandler, |
|
154 | + $notifications, |
|
155 | + $tokenHandler, |
|
156 | + $l, |
|
157 | + $this->serverContainer->getLogger(), |
|
158 | + $this->serverContainer->getLazyRootFolder(), |
|
159 | + $this->serverContainer->getConfig(), |
|
160 | + $this->serverContainer->getUserManager(), |
|
161 | + $this->serverContainer->getCloudIdManager(), |
|
162 | + $this->serverContainer->getGlobalScaleConfig(), |
|
163 | + $this->serverContainer->getCloudFederationProviderManager() |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + return $this->federatedProvider; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Create the federated share provider |
|
172 | + * |
|
173 | + * @return ShareByMailProvider |
|
174 | + */ |
|
175 | + protected function getShareByMailProvider() { |
|
176 | + if ($this->shareByMailProvider === null) { |
|
177 | + /* |
|
178 | 178 | * Check if the app is enabled |
179 | 179 | */ |
180 | - $appManager = $this->serverContainer->getAppManager(); |
|
181 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
182 | - return null; |
|
183 | - } |
|
184 | - |
|
185 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
186 | - |
|
187 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
188 | - $this->serverContainer->getDatabaseConnection(), |
|
189 | - $this->serverContainer->getSecureRandom(), |
|
190 | - $this->serverContainer->getUserManager(), |
|
191 | - $this->serverContainer->getLazyRootFolder(), |
|
192 | - $this->serverContainer->getL10N('sharebymail'), |
|
193 | - $this->serverContainer->getLogger(), |
|
194 | - $this->serverContainer->getMailer(), |
|
195 | - $this->serverContainer->getURLGenerator(), |
|
196 | - $this->serverContainer->getActivityManager(), |
|
197 | - $settingsManager, |
|
198 | - $this->serverContainer->query(Defaults::class), |
|
199 | - $this->serverContainer->getHasher(), |
|
200 | - $this->serverContainer->get(IEventDispatcher::class), |
|
201 | - $this->serverContainer->get(IManager::class) |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - return $this->shareByMailProvider; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * Create the circle share provider |
|
211 | - * |
|
212 | - * @return FederatedShareProvider |
|
213 | - * |
|
214 | - * @suppress PhanUndeclaredClassMethod |
|
215 | - */ |
|
216 | - protected function getShareByCircleProvider() { |
|
217 | - if ($this->circlesAreNotAvailable) { |
|
218 | - return null; |
|
219 | - } |
|
220 | - |
|
221 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
222 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
223 | - ) { |
|
224 | - $this->circlesAreNotAvailable = true; |
|
225 | - return null; |
|
226 | - } |
|
227 | - |
|
228 | - if ($this->shareByCircleProvider === null) { |
|
229 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
230 | - $this->serverContainer->getDatabaseConnection(), |
|
231 | - $this->serverContainer->getSecureRandom(), |
|
232 | - $this->serverContainer->getUserManager(), |
|
233 | - $this->serverContainer->getLazyRootFolder(), |
|
234 | - $this->serverContainer->getL10N('circles'), |
|
235 | - $this->serverContainer->getLogger(), |
|
236 | - $this->serverContainer->getURLGenerator() |
|
237 | - ); |
|
238 | - } |
|
239 | - |
|
240 | - return $this->shareByCircleProvider; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Create the room share provider |
|
245 | - * |
|
246 | - * @return RoomShareProvider |
|
247 | - */ |
|
248 | - protected function getRoomShareProvider() { |
|
249 | - if ($this->roomShareProvider === null) { |
|
250 | - /* |
|
180 | + $appManager = $this->serverContainer->getAppManager(); |
|
181 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
182 | + return null; |
|
183 | + } |
|
184 | + |
|
185 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
186 | + |
|
187 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
188 | + $this->serverContainer->getDatabaseConnection(), |
|
189 | + $this->serverContainer->getSecureRandom(), |
|
190 | + $this->serverContainer->getUserManager(), |
|
191 | + $this->serverContainer->getLazyRootFolder(), |
|
192 | + $this->serverContainer->getL10N('sharebymail'), |
|
193 | + $this->serverContainer->getLogger(), |
|
194 | + $this->serverContainer->getMailer(), |
|
195 | + $this->serverContainer->getURLGenerator(), |
|
196 | + $this->serverContainer->getActivityManager(), |
|
197 | + $settingsManager, |
|
198 | + $this->serverContainer->query(Defaults::class), |
|
199 | + $this->serverContainer->getHasher(), |
|
200 | + $this->serverContainer->get(IEventDispatcher::class), |
|
201 | + $this->serverContainer->get(IManager::class) |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + return $this->shareByMailProvider; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * Create the circle share provider |
|
211 | + * |
|
212 | + * @return FederatedShareProvider |
|
213 | + * |
|
214 | + * @suppress PhanUndeclaredClassMethod |
|
215 | + */ |
|
216 | + protected function getShareByCircleProvider() { |
|
217 | + if ($this->circlesAreNotAvailable) { |
|
218 | + return null; |
|
219 | + } |
|
220 | + |
|
221 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
222 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
223 | + ) { |
|
224 | + $this->circlesAreNotAvailable = true; |
|
225 | + return null; |
|
226 | + } |
|
227 | + |
|
228 | + if ($this->shareByCircleProvider === null) { |
|
229 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
230 | + $this->serverContainer->getDatabaseConnection(), |
|
231 | + $this->serverContainer->getSecureRandom(), |
|
232 | + $this->serverContainer->getUserManager(), |
|
233 | + $this->serverContainer->getLazyRootFolder(), |
|
234 | + $this->serverContainer->getL10N('circles'), |
|
235 | + $this->serverContainer->getLogger(), |
|
236 | + $this->serverContainer->getURLGenerator() |
|
237 | + ); |
|
238 | + } |
|
239 | + |
|
240 | + return $this->shareByCircleProvider; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Create the room share provider |
|
245 | + * |
|
246 | + * @return RoomShareProvider |
|
247 | + */ |
|
248 | + protected function getRoomShareProvider() { |
|
249 | + if ($this->roomShareProvider === null) { |
|
250 | + /* |
|
251 | 251 | * Check if the app is enabled |
252 | 252 | */ |
253 | - $appManager = $this->serverContainer->getAppManager(); |
|
254 | - if (!$appManager->isEnabledForUser('spreed')) { |
|
255 | - return null; |
|
256 | - } |
|
257 | - |
|
258 | - try { |
|
259 | - $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
260 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
261 | - return null; |
|
262 | - } |
|
263 | - } |
|
264 | - |
|
265 | - return $this->roomShareProvider; |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * @inheritdoc |
|
270 | - */ |
|
271 | - public function getProvider($id) { |
|
272 | - $provider = null; |
|
273 | - if (isset($this->shareProviders[$id])) { |
|
274 | - return $this->shareProviders[$id]; |
|
275 | - } |
|
276 | - |
|
277 | - if ($id === 'ocinternal') { |
|
278 | - $provider = $this->defaultShareProvider(); |
|
279 | - } elseif ($id === 'ocFederatedSharing') { |
|
280 | - $provider = $this->federatedShareProvider(); |
|
281 | - } elseif ($id === 'ocMailShare') { |
|
282 | - $provider = $this->getShareByMailProvider(); |
|
283 | - } elseif ($id === 'ocCircleShare') { |
|
284 | - $provider = $this->getShareByCircleProvider(); |
|
285 | - } elseif ($id === 'ocRoomShare') { |
|
286 | - $provider = $this->getRoomShareProvider(); |
|
287 | - } |
|
288 | - |
|
289 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
290 | - /** @var IShareProvider $instance */ |
|
291 | - $instance = $this->serverContainer->get($shareProvider); |
|
292 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
293 | - } |
|
294 | - |
|
295 | - if (isset($this->shareProviders[$id])) { |
|
296 | - $provider = $this->shareProviders[$id]; |
|
297 | - } |
|
298 | - |
|
299 | - if ($provider === null) { |
|
300 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
301 | - } |
|
302 | - |
|
303 | - return $provider; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * @inheritdoc |
|
308 | - */ |
|
309 | - public function getProviderForType($shareType) { |
|
310 | - $provider = null; |
|
311 | - |
|
312 | - if ($shareType === IShare::TYPE_USER || |
|
313 | - $shareType === IShare::TYPE_GROUP || |
|
314 | - $shareType === IShare::TYPE_LINK |
|
315 | - ) { |
|
316 | - $provider = $this->defaultShareProvider(); |
|
317 | - } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
318 | - $provider = $this->federatedShareProvider(); |
|
319 | - } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
320 | - $provider = $this->getShareByMailProvider(); |
|
321 | - } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
322 | - $provider = $this->getShareByCircleProvider(); |
|
323 | - } elseif ($shareType === IShare::TYPE_ROOM) { |
|
324 | - $provider = $this->getRoomShareProvider(); |
|
325 | - } elseif ($shareType === IShare::TYPE_DECK) { |
|
326 | - $provider = $this->getProvider('deck'); |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - if ($provider === null) { |
|
331 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
332 | - } |
|
333 | - |
|
334 | - return $provider; |
|
335 | - } |
|
336 | - |
|
337 | - public function getAllProviders() { |
|
338 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
339 | - $shareByMail = $this->getShareByMailProvider(); |
|
340 | - if ($shareByMail !== null) { |
|
341 | - $shares[] = $shareByMail; |
|
342 | - } |
|
343 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
344 | - if ($shareByCircle !== null) { |
|
345 | - $shares[] = $shareByCircle; |
|
346 | - } |
|
347 | - $roomShare = $this->getRoomShareProvider(); |
|
348 | - if ($roomShare !== null) { |
|
349 | - $shares[] = $roomShare; |
|
350 | - } |
|
351 | - |
|
352 | - foreach ($this->registeredShareProviders as $shareProvider) { |
|
353 | - /** @var IShareProvider $instance */ |
|
354 | - $instance = $this->serverContainer->get($shareProvider); |
|
355 | - if (!isset($this->shareProviders[$instance->identifier()])) { |
|
356 | - $this->shareProviders[$instance->identifier()] = $instance; |
|
357 | - } |
|
358 | - $shares[] = $this->shareProviders[$instance->identifier()]; |
|
359 | - } |
|
360 | - |
|
361 | - |
|
362 | - |
|
363 | - return $shares; |
|
364 | - } |
|
253 | + $appManager = $this->serverContainer->getAppManager(); |
|
254 | + if (!$appManager->isEnabledForUser('spreed')) { |
|
255 | + return null; |
|
256 | + } |
|
257 | + |
|
258 | + try { |
|
259 | + $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
260 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
261 | + return null; |
|
262 | + } |
|
263 | + } |
|
264 | + |
|
265 | + return $this->roomShareProvider; |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * @inheritdoc |
|
270 | + */ |
|
271 | + public function getProvider($id) { |
|
272 | + $provider = null; |
|
273 | + if (isset($this->shareProviders[$id])) { |
|
274 | + return $this->shareProviders[$id]; |
|
275 | + } |
|
276 | + |
|
277 | + if ($id === 'ocinternal') { |
|
278 | + $provider = $this->defaultShareProvider(); |
|
279 | + } elseif ($id === 'ocFederatedSharing') { |
|
280 | + $provider = $this->federatedShareProvider(); |
|
281 | + } elseif ($id === 'ocMailShare') { |
|
282 | + $provider = $this->getShareByMailProvider(); |
|
283 | + } elseif ($id === 'ocCircleShare') { |
|
284 | + $provider = $this->getShareByCircleProvider(); |
|
285 | + } elseif ($id === 'ocRoomShare') { |
|
286 | + $provider = $this->getRoomShareProvider(); |
|
287 | + } |
|
288 | + |
|
289 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
290 | + /** @var IShareProvider $instance */ |
|
291 | + $instance = $this->serverContainer->get($shareProvider); |
|
292 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
293 | + } |
|
294 | + |
|
295 | + if (isset($this->shareProviders[$id])) { |
|
296 | + $provider = $this->shareProviders[$id]; |
|
297 | + } |
|
298 | + |
|
299 | + if ($provider === null) { |
|
300 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
301 | + } |
|
302 | + |
|
303 | + return $provider; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * @inheritdoc |
|
308 | + */ |
|
309 | + public function getProviderForType($shareType) { |
|
310 | + $provider = null; |
|
311 | + |
|
312 | + if ($shareType === IShare::TYPE_USER || |
|
313 | + $shareType === IShare::TYPE_GROUP || |
|
314 | + $shareType === IShare::TYPE_LINK |
|
315 | + ) { |
|
316 | + $provider = $this->defaultShareProvider(); |
|
317 | + } elseif ($shareType === IShare::TYPE_REMOTE || $shareType === IShare::TYPE_REMOTE_GROUP) { |
|
318 | + $provider = $this->federatedShareProvider(); |
|
319 | + } elseif ($shareType === IShare::TYPE_EMAIL) { |
|
320 | + $provider = $this->getShareByMailProvider(); |
|
321 | + } elseif ($shareType === IShare::TYPE_CIRCLE) { |
|
322 | + $provider = $this->getShareByCircleProvider(); |
|
323 | + } elseif ($shareType === IShare::TYPE_ROOM) { |
|
324 | + $provider = $this->getRoomShareProvider(); |
|
325 | + } elseif ($shareType === IShare::TYPE_DECK) { |
|
326 | + $provider = $this->getProvider('deck'); |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + if ($provider === null) { |
|
331 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
332 | + } |
|
333 | + |
|
334 | + return $provider; |
|
335 | + } |
|
336 | + |
|
337 | + public function getAllProviders() { |
|
338 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
339 | + $shareByMail = $this->getShareByMailProvider(); |
|
340 | + if ($shareByMail !== null) { |
|
341 | + $shares[] = $shareByMail; |
|
342 | + } |
|
343 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
344 | + if ($shareByCircle !== null) { |
|
345 | + $shares[] = $shareByCircle; |
|
346 | + } |
|
347 | + $roomShare = $this->getRoomShareProvider(); |
|
348 | + if ($roomShare !== null) { |
|
349 | + $shares[] = $roomShare; |
|
350 | + } |
|
351 | + |
|
352 | + foreach ($this->registeredShareProviders as $shareProvider) { |
|
353 | + /** @var IShareProvider $instance */ |
|
354 | + $instance = $this->serverContainer->get($shareProvider); |
|
355 | + if (!isset($this->shareProviders[$instance->identifier()])) { |
|
356 | + $this->shareProviders[$instance->identifier()] = $instance; |
|
357 | + } |
|
358 | + $shares[] = $this->shareProviders[$instance->identifier()]; |
|
359 | + } |
|
360 | + |
|
361 | + |
|
362 | + |
|
363 | + return $shares; |
|
364 | + } |
|
365 | 365 | } |
@@ -37,57 +37,57 @@ |
||
37 | 37 | */ |
38 | 38 | class ConsoleOutput implements IOutput { |
39 | 39 | |
40 | - /** @var OutputInterface */ |
|
41 | - private $output; |
|
40 | + /** @var OutputInterface */ |
|
41 | + private $output; |
|
42 | 42 | |
43 | - /** @var ProgressBar */ |
|
44 | - private $progressBar; |
|
43 | + /** @var ProgressBar */ |
|
44 | + private $progressBar; |
|
45 | 45 | |
46 | - public function __construct(OutputInterface $output) { |
|
47 | - $this->output = $output; |
|
48 | - } |
|
46 | + public function __construct(OutputInterface $output) { |
|
47 | + $this->output = $output; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $message |
|
52 | - */ |
|
53 | - public function info($message) { |
|
54 | - $this->output->writeln("<info>$message</info>"); |
|
55 | - } |
|
50 | + /** |
|
51 | + * @param string $message |
|
52 | + */ |
|
53 | + public function info($message) { |
|
54 | + $this->output->writeln("<info>$message</info>"); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $message |
|
59 | - */ |
|
60 | - public function warning($message) { |
|
61 | - $this->output->writeln("<comment>$message</comment>"); |
|
62 | - } |
|
57 | + /** |
|
58 | + * @param string $message |
|
59 | + */ |
|
60 | + public function warning($message) { |
|
61 | + $this->output->writeln("<comment>$message</comment>"); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param int $max |
|
66 | - */ |
|
67 | - public function startProgress($max = 0) { |
|
68 | - if (!is_null($this->progressBar)) { |
|
69 | - $this->progressBar->finish(); |
|
70 | - } |
|
71 | - $this->progressBar = new ProgressBar($this->output); |
|
72 | - $this->progressBar->start($max); |
|
73 | - } |
|
64 | + /** |
|
65 | + * @param int $max |
|
66 | + */ |
|
67 | + public function startProgress($max = 0) { |
|
68 | + if (!is_null($this->progressBar)) { |
|
69 | + $this->progressBar->finish(); |
|
70 | + } |
|
71 | + $this->progressBar = new ProgressBar($this->output); |
|
72 | + $this->progressBar->start($max); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param int $step |
|
77 | - * @param string $description |
|
78 | - */ |
|
79 | - public function advance($step = 1, $description = '') { |
|
80 | - if (!is_null($this->progressBar)) { |
|
81 | - $this->progressBar = new ProgressBar($this->output); |
|
82 | - $this->progressBar->start(); |
|
83 | - } |
|
84 | - $this->progressBar->advance($step); |
|
85 | - } |
|
75 | + /** |
|
76 | + * @param int $step |
|
77 | + * @param string $description |
|
78 | + */ |
|
79 | + public function advance($step = 1, $description = '') { |
|
80 | + if (!is_null($this->progressBar)) { |
|
81 | + $this->progressBar = new ProgressBar($this->output); |
|
82 | + $this->progressBar->start(); |
|
83 | + } |
|
84 | + $this->progressBar->advance($step); |
|
85 | + } |
|
86 | 86 | |
87 | - public function finishProgress() { |
|
88 | - if (is_null($this->progressBar)) { |
|
89 | - return; |
|
90 | - } |
|
91 | - $this->progressBar->finish(); |
|
92 | - } |
|
87 | + public function finishProgress() { |
|
88 | + if (is_null($this->progressBar)) { |
|
89 | + return; |
|
90 | + } |
|
91 | + $this->progressBar->finish(); |
|
92 | + } |
|
93 | 93 | } |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class RootCollection extends AbstractPrincipalCollection { |
9 | 9 | |
10 | - /** |
|
11 | - * This method returns a node for a principal. |
|
12 | - * |
|
13 | - * The passed array contains principal information, and is guaranteed to |
|
14 | - * at least contain a uri item. Other properties may or may not be |
|
15 | - * supplied by the authentication backend. |
|
16 | - * |
|
17 | - * @param array $principalInfo |
|
18 | - * @return AvatarHome |
|
19 | - */ |
|
20 | - public function getChildForPrincipal(array $principalInfo) { |
|
21 | - $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | - return new AvatarHome($principalInfo, $avatarManager); |
|
23 | - } |
|
10 | + /** |
|
11 | + * This method returns a node for a principal. |
|
12 | + * |
|
13 | + * The passed array contains principal information, and is guaranteed to |
|
14 | + * at least contain a uri item. Other properties may or may not be |
|
15 | + * supplied by the authentication backend. |
|
16 | + * |
|
17 | + * @param array $principalInfo |
|
18 | + * @return AvatarHome |
|
19 | + */ |
|
20 | + public function getChildForPrincipal(array $principalInfo) { |
|
21 | + $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | + return new AvatarHome($principalInfo, $avatarManager); |
|
23 | + } |
|
24 | 24 | |
25 | - public function getName() { |
|
26 | - return 'avatars'; |
|
27 | - } |
|
25 | + public function getName() { |
|
26 | + return 'avatars'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | |
66 | 66 | $output->startProgress(count($objects)); |
67 | 67 | foreach ($objects as $row) { |
68 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
68 | + $calObject = $this->calDavBackend->getCalendarObject((int) $row['calendarid'], $row['uri']); |
|
69 | + $data = preg_replace('/'.$pattern.'/', ':', $calObject['calendardata']); |
|
70 | 70 | |
71 | 71 | if ($data !== $calObject['calendardata']) { |
72 | 72 | $output->advance(); |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | } catch (InvalidDataException $e) { |
77 | 77 | $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
78 | 78 | 'app' => 'dav', |
79 | - 'cal' => (int)$row['calendarid'], |
|
79 | + 'cal' => (int) $row['calendarid'], |
|
80 | 80 | 'uri' => $row['uri'], |
81 | 81 | ]); |
82 | 82 | $warnings++; |
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | |
86 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
86 | + $this->calDavBackend->updateCalendarObject((int) $row['calendarid'], $row['uri'], $data); |
|
87 | 87 | $count++; |
88 | 88 | } |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | ->where($query->expr()->like( |
105 | 105 | 'calendardata', |
106 | 106 | $query->createNamedParameter( |
107 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
107 | + '%'.$this->db->escapeLikeParameter($pattern).'%', |
|
108 | 108 | IQueryBuilder::PARAM_STR |
109 | 109 | ), |
110 | 110 | IQueryBuilder::PARAM_STR |
@@ -35,118 +35,118 @@ |
||
35 | 35 | |
36 | 36 | class CalDAVRemoveEmptyValue implements IRepairStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - private $db; |
|
40 | - |
|
41 | - /** @var CalDavBackend */ |
|
42 | - private $calDavBackend; |
|
43 | - |
|
44 | - /** @var ILogger */ |
|
45 | - private $logger; |
|
46 | - |
|
47 | - /** |
|
48 | - * @param IDBConnection $db |
|
49 | - * @param CalDavBackend $calDavBackend |
|
50 | - * @param ILogger $logger |
|
51 | - */ |
|
52 | - public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
53 | - $this->db = $db; |
|
54 | - $this->calDavBackend = $calDavBackend; |
|
55 | - $this->logger = $logger; |
|
56 | - } |
|
57 | - |
|
58 | - public function getName() { |
|
59 | - return 'Fix broken values of calendar objects'; |
|
60 | - } |
|
61 | - |
|
62 | - public function run(IOutput $output) { |
|
63 | - $pattern = ';VALUE=:'; |
|
64 | - $count = $warnings = 0; |
|
65 | - |
|
66 | - $objects = $this->getInvalidObjects($pattern); |
|
67 | - |
|
68 | - $output->startProgress(count($objects)); |
|
69 | - foreach ($objects as $row) { |
|
70 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
71 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
72 | - |
|
73 | - if ($data !== $calObject['calendardata']) { |
|
74 | - $output->advance(); |
|
75 | - |
|
76 | - try { |
|
77 | - $this->calDavBackend->getDenormalizedData($data); |
|
78 | - } catch (InvalidDataException $e) { |
|
79 | - $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
80 | - 'app' => 'dav', |
|
81 | - 'cal' => (int)$row['calendarid'], |
|
82 | - 'uri' => $row['uri'], |
|
83 | - ]); |
|
84 | - $warnings++; |
|
85 | - continue; |
|
86 | - } |
|
87 | - |
|
88 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
89 | - $count++; |
|
90 | - } |
|
91 | - } |
|
92 | - $output->finishProgress(); |
|
93 | - |
|
94 | - if ($warnings > 0) { |
|
95 | - $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
96 | - } |
|
97 | - if ($count > 0) { |
|
98 | - $output->info(sprintf('Updated %d events', $count)); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - protected function getInvalidObjects($pattern) { |
|
103 | - if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
104 | - $rows = []; |
|
105 | - $chunkSize = 500; |
|
106 | - $query = $this->db->getQueryBuilder(); |
|
107 | - $query->select($query->func()->count('*', 'num_entries')) |
|
108 | - ->from('calendarobjects'); |
|
109 | - $result = $query->execute(); |
|
110 | - $count = $result->fetchOne(); |
|
111 | - $result->closeCursor(); |
|
112 | - |
|
113 | - $numChunks = ceil($count / $chunkSize); |
|
114 | - |
|
115 | - $query = $this->db->getQueryBuilder(); |
|
116 | - $query->select(['calendarid', 'uri', 'calendardata']) |
|
117 | - ->from('calendarobjects') |
|
118 | - ->setMaxResults($chunkSize); |
|
119 | - for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
120 | - $query->setFirstResult($chunk * $chunkSize); |
|
121 | - $result = $query->execute(); |
|
122 | - |
|
123 | - while ($row = $result->fetch()) { |
|
124 | - if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
125 | - unset($row['calendardata']); |
|
126 | - $rows[] = $row; |
|
127 | - } |
|
128 | - } |
|
129 | - $result->closeCursor(); |
|
130 | - } |
|
131 | - return $rows; |
|
132 | - } |
|
133 | - |
|
134 | - $query = $this->db->getQueryBuilder(); |
|
135 | - $query->select(['calendarid', 'uri']) |
|
136 | - ->from('calendarobjects') |
|
137 | - ->where($query->expr()->like( |
|
138 | - 'calendardata', |
|
139 | - $query->createNamedParameter( |
|
140 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
141 | - IQueryBuilder::PARAM_STR |
|
142 | - ), |
|
143 | - IQueryBuilder::PARAM_STR |
|
144 | - )); |
|
145 | - |
|
146 | - $result = $query->execute(); |
|
147 | - $rows = $result->fetchAll(); |
|
148 | - $result->closeCursor(); |
|
149 | - |
|
150 | - return $rows; |
|
151 | - } |
|
38 | + /** @var IDBConnection */ |
|
39 | + private $db; |
|
40 | + |
|
41 | + /** @var CalDavBackend */ |
|
42 | + private $calDavBackend; |
|
43 | + |
|
44 | + /** @var ILogger */ |
|
45 | + private $logger; |
|
46 | + |
|
47 | + /** |
|
48 | + * @param IDBConnection $db |
|
49 | + * @param CalDavBackend $calDavBackend |
|
50 | + * @param ILogger $logger |
|
51 | + */ |
|
52 | + public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
53 | + $this->db = $db; |
|
54 | + $this->calDavBackend = $calDavBackend; |
|
55 | + $this->logger = $logger; |
|
56 | + } |
|
57 | + |
|
58 | + public function getName() { |
|
59 | + return 'Fix broken values of calendar objects'; |
|
60 | + } |
|
61 | + |
|
62 | + public function run(IOutput $output) { |
|
63 | + $pattern = ';VALUE=:'; |
|
64 | + $count = $warnings = 0; |
|
65 | + |
|
66 | + $objects = $this->getInvalidObjects($pattern); |
|
67 | + |
|
68 | + $output->startProgress(count($objects)); |
|
69 | + foreach ($objects as $row) { |
|
70 | + $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
71 | + $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
72 | + |
|
73 | + if ($data !== $calObject['calendardata']) { |
|
74 | + $output->advance(); |
|
75 | + |
|
76 | + try { |
|
77 | + $this->calDavBackend->getDenormalizedData($data); |
|
78 | + } catch (InvalidDataException $e) { |
|
79 | + $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
80 | + 'app' => 'dav', |
|
81 | + 'cal' => (int)$row['calendarid'], |
|
82 | + 'uri' => $row['uri'], |
|
83 | + ]); |
|
84 | + $warnings++; |
|
85 | + continue; |
|
86 | + } |
|
87 | + |
|
88 | + $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
89 | + $count++; |
|
90 | + } |
|
91 | + } |
|
92 | + $output->finishProgress(); |
|
93 | + |
|
94 | + if ($warnings > 0) { |
|
95 | + $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
96 | + } |
|
97 | + if ($count > 0) { |
|
98 | + $output->info(sprintf('Updated %d events', $count)); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + protected function getInvalidObjects($pattern) { |
|
103 | + if ($this->db->getDatabasePlatform() instanceof OraclePlatform) { |
|
104 | + $rows = []; |
|
105 | + $chunkSize = 500; |
|
106 | + $query = $this->db->getQueryBuilder(); |
|
107 | + $query->select($query->func()->count('*', 'num_entries')) |
|
108 | + ->from('calendarobjects'); |
|
109 | + $result = $query->execute(); |
|
110 | + $count = $result->fetchOne(); |
|
111 | + $result->closeCursor(); |
|
112 | + |
|
113 | + $numChunks = ceil($count / $chunkSize); |
|
114 | + |
|
115 | + $query = $this->db->getQueryBuilder(); |
|
116 | + $query->select(['calendarid', 'uri', 'calendardata']) |
|
117 | + ->from('calendarobjects') |
|
118 | + ->setMaxResults($chunkSize); |
|
119 | + for ($chunk = 0; $chunk < $numChunks; $chunk++) { |
|
120 | + $query->setFirstResult($chunk * $chunkSize); |
|
121 | + $result = $query->execute(); |
|
122 | + |
|
123 | + while ($row = $result->fetch()) { |
|
124 | + if (mb_strpos($row['calendardata'], $pattern) !== false) { |
|
125 | + unset($row['calendardata']); |
|
126 | + $rows[] = $row; |
|
127 | + } |
|
128 | + } |
|
129 | + $result->closeCursor(); |
|
130 | + } |
|
131 | + return $rows; |
|
132 | + } |
|
133 | + |
|
134 | + $query = $this->db->getQueryBuilder(); |
|
135 | + $query->select(['calendarid', 'uri']) |
|
136 | + ->from('calendarobjects') |
|
137 | + ->where($query->expr()->like( |
|
138 | + 'calendardata', |
|
139 | + $query->createNamedParameter( |
|
140 | + '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
141 | + IQueryBuilder::PARAM_STR |
|
142 | + ), |
|
143 | + IQueryBuilder::PARAM_STR |
|
144 | + )); |
|
145 | + |
|
146 | + $result = $query->execute(); |
|
147 | + $rows = $result->fetchAll(); |
|
148 | + $result->closeCursor(); |
|
149 | + |
|
150 | + return $rows; |
|
151 | + } |
|
152 | 152 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}comp-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class CompFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $reader->parseInnerTree(); |
40 | 40 | |
41 | 41 | if (!is_string($componentName)) { |
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
42 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}prop-filter requires a valid name attribute'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | return $componentName; |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class PropFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}prop-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |
@@ -40,11 +40,11 @@ |
||
40 | 40 | $reader->parseInnerTree(); |
41 | 41 | |
42 | 42 | if (!is_string($property)) { |
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
43 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid property attribute'); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | if (!is_string($parameter)) { |
47 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | + throw new BadRequest('The {'.SearchPlugin::NS_Nextcloud.'}param-filter requires a valid parameter attribute'); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return [ |
@@ -27,28 +27,28 @@ |
||
27 | 27 | |
28 | 28 | class ParamFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - public static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $property = $att['property']; |
|
38 | - $parameter = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + public static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $property = $att['property']; |
|
38 | + $parameter = $att['name']; |
|
39 | 39 | |
40 | - $reader->parseInnerTree(); |
|
40 | + $reader->parseInnerTree(); |
|
41 | 41 | |
42 | - if (!is_string($property)) { |
|
43 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | - } |
|
45 | - if (!is_string($parameter)) { |
|
46 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | - } |
|
42 | + if (!is_string($property)) { |
|
43 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid property attribute'); |
|
44 | + } |
|
45 | + if (!is_string($parameter)) { |
|
46 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}param-filter requires a valid parameter attribute'); |
|
47 | + } |
|
48 | 48 | |
49 | - return [ |
|
50 | - 'property' => $property, |
|
51 | - 'parameter' => $parameter, |
|
52 | - ]; |
|
53 | - } |
|
49 | + return [ |
|
50 | + 'property' => $property, |
|
51 | + 'parameter' => $parameter, |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | <tr><td> |
28 | 28 | <table cellspacing="0" cellpadding="0" border="0" width="600px"> |
29 | 29 | <tr> |
30 | - <td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>"> |
|
30 | + <td colspan="2" bgcolor="<?php p($theme->getColorPrimary()); ?>"> |
|
31 | 31 | <img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/> |
32 | 32 | </td> |
33 | 33 | </tr> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | <td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br> |
53 | 53 | <?php p($theme->getName()); ?> - |
54 | 54 | <?php p($theme->getSlogan()); ?> |
55 | - <br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a> |
|
55 | + <br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl()); ?></a> |
|
56 | 56 | </td> |
57 | 57 | </tr> |
58 | 58 | <tr> |
@@ -15,10 +15,10 @@ |
||
15 | 15 | <td width="20px"> </td> |
16 | 16 | <td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;"> |
17 | 17 | <?php |
18 | - print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']])); |
|
19 | - // TRANSLATORS term at the end of a mail |
|
20 | - p($l->t('Cheers!')); |
|
21 | - ?> |
|
18 | + print_unescaped($l->t('Hey there,<br><br>the admin enabled server-side-encryption. Your files were encrypted using the password <strong>%s</strong>.<br><br>Please login to the web interface, go to the section "basic encryption module" of your personal settings and update your encryption password by entering this password into the "old log-in password" field and your current login-password.<br><br>', [$_['password']])); |
|
19 | + // TRANSLATORS term at the end of a mail |
|
20 | + p($l->t('Cheers!')); |
|
21 | + ?> |
|
22 | 22 | </td> |
23 | 23 | </tr> |
24 | 24 | <tr><td colspan="2"> </td></tr> |
@@ -171,14 +171,14 @@ |
||
171 | 171 | protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { |
172 | 172 | $qb = $this->connection->getQueryBuilder(); |
173 | 173 | |
174 | - $qb->select('d.' . $deleteId) |
|
174 | + $qb->select('d.'.$deleteId) |
|
175 | 175 | ->from($deleteTable, 'd') |
176 | - ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId)) |
|
176 | + ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.'.$deleteId, 's.'.$sourceId)) |
|
177 | 177 | ->where( |
178 | 178 | $qb->expr()->eq('d.type', $qb->expr()->literal('files')) |
179 | 179 | ) |
180 | 180 | ->andWhere( |
181 | - $qb->expr()->isNull('s.' . $sourceNullColumn) |
|
181 | + $qb->expr()->isNull('s.'.$sourceNullColumn) |
|
182 | 182 | ); |
183 | 183 | $result = $qb->execute(); |
184 | 184 |
@@ -41,171 +41,171 @@ |
||
41 | 41 | */ |
42 | 42 | class CleanTags implements IRepairStep { |
43 | 43 | |
44 | - /** @var IDBConnection */ |
|
45 | - protected $connection; |
|
46 | - |
|
47 | - /** @var IUserManager */ |
|
48 | - protected $userManager; |
|
49 | - |
|
50 | - protected $deletedTags = 0; |
|
51 | - |
|
52 | - /** |
|
53 | - * @param IDBConnection $connection |
|
54 | - * @param IUserManager $userManager |
|
55 | - */ |
|
56 | - public function __construct(IDBConnection $connection, IUserManager $userManager) { |
|
57 | - $this->connection = $connection; |
|
58 | - $this->userManager = $userManager; |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function getName() { |
|
65 | - return 'Clean tags and favorites'; |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Updates the configuration after running an update |
|
70 | - */ |
|
71 | - public function run(IOutput $output) { |
|
72 | - $this->deleteOrphanTags($output); |
|
73 | - $this->deleteOrphanFileEntries($output); |
|
74 | - $this->deleteOrphanTagEntries($output); |
|
75 | - $this->deleteOrphanCategoryEntries($output); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Delete tags for deleted users |
|
80 | - */ |
|
81 | - protected function deleteOrphanTags(IOutput $output) { |
|
82 | - $offset = 0; |
|
83 | - while ($this->checkTags($offset)) { |
|
84 | - $offset += 50; |
|
85 | - } |
|
86 | - |
|
87 | - $output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags)); |
|
88 | - } |
|
89 | - |
|
90 | - protected function checkTags($offset) { |
|
91 | - $query = $this->connection->getQueryBuilder(); |
|
92 | - $query->select('uid') |
|
93 | - ->from('vcategory') |
|
94 | - ->groupBy('uid') |
|
95 | - ->orderBy('uid') |
|
96 | - ->setMaxResults(50) |
|
97 | - ->setFirstResult($offset); |
|
98 | - $result = $query->execute(); |
|
99 | - |
|
100 | - $users = []; |
|
101 | - $hadResults = false; |
|
102 | - while ($row = $result->fetch()) { |
|
103 | - $hadResults = true; |
|
104 | - if (!$this->userManager->userExists($row['uid'])) { |
|
105 | - $users[] = $row['uid']; |
|
106 | - } |
|
107 | - } |
|
108 | - $result->closeCursor(); |
|
109 | - |
|
110 | - if (!$hadResults) { |
|
111 | - // No more tags, stop looping |
|
112 | - return false; |
|
113 | - } |
|
114 | - |
|
115 | - if (!empty($users)) { |
|
116 | - $query = $this->connection->getQueryBuilder(); |
|
117 | - $query->delete('vcategory') |
|
118 | - ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY))); |
|
119 | - $this->deletedTags += $query->execute(); |
|
120 | - } |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Delete tag entries for deleted files |
|
126 | - */ |
|
127 | - protected function deleteOrphanFileEntries(IOutput $output) { |
|
128 | - $this->deleteOrphanEntries( |
|
129 | - $output, |
|
130 | - '%d tags for delete files have been removed.', |
|
131 | - 'vcategory_to_object', 'objid', |
|
132 | - 'filecache', 'fileid', 'path_hash' |
|
133 | - ); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Delete tag entries for deleted tags |
|
138 | - */ |
|
139 | - protected function deleteOrphanTagEntries(IOutput $output) { |
|
140 | - $this->deleteOrphanEntries( |
|
141 | - $output, |
|
142 | - '%d tag entries for deleted tags have been removed.', |
|
143 | - 'vcategory_to_object', 'categoryid', |
|
144 | - 'vcategory', 'id', 'uid' |
|
145 | - ); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Delete tags that have no entries |
|
150 | - */ |
|
151 | - protected function deleteOrphanCategoryEntries(IOutput $output) { |
|
152 | - $this->deleteOrphanEntries( |
|
153 | - $output, |
|
154 | - '%d tags with no entries have been removed.', |
|
155 | - 'vcategory', 'id', |
|
156 | - 'vcategory_to_object', 'categoryid', 'type' |
|
157 | - ); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable |
|
162 | - * |
|
163 | - * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks |
|
164 | - * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable |
|
165 | - * is being deleted. |
|
166 | - * |
|
167 | - * @param string $repairInfo |
|
168 | - * @param string $deleteTable |
|
169 | - * @param string $deleteId |
|
170 | - * @param string $sourceTable |
|
171 | - * @param string $sourceId |
|
172 | - * @param string $sourceNullColumn If this column is null in the source table, |
|
173 | - * the entry is deleted in the $deleteTable |
|
174 | - */ |
|
175 | - protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { |
|
176 | - $qb = $this->connection->getQueryBuilder(); |
|
177 | - |
|
178 | - $qb->select('d.' . $deleteId) |
|
179 | - ->from($deleteTable, 'd') |
|
180 | - ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId)) |
|
181 | - ->where( |
|
182 | - $qb->expr()->eq('d.type', $qb->expr()->literal('files')) |
|
183 | - ) |
|
184 | - ->andWhere( |
|
185 | - $qb->expr()->isNull('s.' . $sourceNullColumn) |
|
186 | - ); |
|
187 | - $result = $qb->execute(); |
|
188 | - |
|
189 | - $orphanItems = []; |
|
190 | - while ($row = $result->fetch()) { |
|
191 | - $orphanItems[] = (int) $row[$deleteId]; |
|
192 | - } |
|
193 | - |
|
194 | - if (!empty($orphanItems)) { |
|
195 | - $orphanItemsBatch = array_chunk($orphanItems, 200); |
|
196 | - foreach ($orphanItemsBatch as $items) { |
|
197 | - $qb->delete($deleteTable) |
|
198 | - ->where( |
|
199 | - $qb->expr()->eq('type', $qb->expr()->literal('files')) |
|
200 | - ) |
|
201 | - ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids'))); |
|
202 | - $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY); |
|
203 | - $qb->execute(); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - if ($repairInfo) { |
|
208 | - $output->info(sprintf($repairInfo, count($orphanItems))); |
|
209 | - } |
|
210 | - } |
|
44 | + /** @var IDBConnection */ |
|
45 | + protected $connection; |
|
46 | + |
|
47 | + /** @var IUserManager */ |
|
48 | + protected $userManager; |
|
49 | + |
|
50 | + protected $deletedTags = 0; |
|
51 | + |
|
52 | + /** |
|
53 | + * @param IDBConnection $connection |
|
54 | + * @param IUserManager $userManager |
|
55 | + */ |
|
56 | + public function __construct(IDBConnection $connection, IUserManager $userManager) { |
|
57 | + $this->connection = $connection; |
|
58 | + $this->userManager = $userManager; |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function getName() { |
|
65 | + return 'Clean tags and favorites'; |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Updates the configuration after running an update |
|
70 | + */ |
|
71 | + public function run(IOutput $output) { |
|
72 | + $this->deleteOrphanTags($output); |
|
73 | + $this->deleteOrphanFileEntries($output); |
|
74 | + $this->deleteOrphanTagEntries($output); |
|
75 | + $this->deleteOrphanCategoryEntries($output); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Delete tags for deleted users |
|
80 | + */ |
|
81 | + protected function deleteOrphanTags(IOutput $output) { |
|
82 | + $offset = 0; |
|
83 | + while ($this->checkTags($offset)) { |
|
84 | + $offset += 50; |
|
85 | + } |
|
86 | + |
|
87 | + $output->info(sprintf('%d tags of deleted users have been removed.', $this->deletedTags)); |
|
88 | + } |
|
89 | + |
|
90 | + protected function checkTags($offset) { |
|
91 | + $query = $this->connection->getQueryBuilder(); |
|
92 | + $query->select('uid') |
|
93 | + ->from('vcategory') |
|
94 | + ->groupBy('uid') |
|
95 | + ->orderBy('uid') |
|
96 | + ->setMaxResults(50) |
|
97 | + ->setFirstResult($offset); |
|
98 | + $result = $query->execute(); |
|
99 | + |
|
100 | + $users = []; |
|
101 | + $hadResults = false; |
|
102 | + while ($row = $result->fetch()) { |
|
103 | + $hadResults = true; |
|
104 | + if (!$this->userManager->userExists($row['uid'])) { |
|
105 | + $users[] = $row['uid']; |
|
106 | + } |
|
107 | + } |
|
108 | + $result->closeCursor(); |
|
109 | + |
|
110 | + if (!$hadResults) { |
|
111 | + // No more tags, stop looping |
|
112 | + return false; |
|
113 | + } |
|
114 | + |
|
115 | + if (!empty($users)) { |
|
116 | + $query = $this->connection->getQueryBuilder(); |
|
117 | + $query->delete('vcategory') |
|
118 | + ->where($query->expr()->in('uid', $query->createNamedParameter($users, IQueryBuilder::PARAM_STR_ARRAY))); |
|
119 | + $this->deletedTags += $query->execute(); |
|
120 | + } |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Delete tag entries for deleted files |
|
126 | + */ |
|
127 | + protected function deleteOrphanFileEntries(IOutput $output) { |
|
128 | + $this->deleteOrphanEntries( |
|
129 | + $output, |
|
130 | + '%d tags for delete files have been removed.', |
|
131 | + 'vcategory_to_object', 'objid', |
|
132 | + 'filecache', 'fileid', 'path_hash' |
|
133 | + ); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Delete tag entries for deleted tags |
|
138 | + */ |
|
139 | + protected function deleteOrphanTagEntries(IOutput $output) { |
|
140 | + $this->deleteOrphanEntries( |
|
141 | + $output, |
|
142 | + '%d tag entries for deleted tags have been removed.', |
|
143 | + 'vcategory_to_object', 'categoryid', |
|
144 | + 'vcategory', 'id', 'uid' |
|
145 | + ); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Delete tags that have no entries |
|
150 | + */ |
|
151 | + protected function deleteOrphanCategoryEntries(IOutput $output) { |
|
152 | + $this->deleteOrphanEntries( |
|
153 | + $output, |
|
154 | + '%d tags with no entries have been removed.', |
|
155 | + 'vcategory', 'id', |
|
156 | + 'vcategory_to_object', 'categoryid', 'type' |
|
157 | + ); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Deletes all entries from $deleteTable that do not have a matching entry in $sourceTable |
|
162 | + * |
|
163 | + * A query joins $deleteTable.$deleteId = $sourceTable.$sourceId and checks |
|
164 | + * whether $sourceNullColumn is null. If it is null, the entry in $deleteTable |
|
165 | + * is being deleted. |
|
166 | + * |
|
167 | + * @param string $repairInfo |
|
168 | + * @param string $deleteTable |
|
169 | + * @param string $deleteId |
|
170 | + * @param string $sourceTable |
|
171 | + * @param string $sourceId |
|
172 | + * @param string $sourceNullColumn If this column is null in the source table, |
|
173 | + * the entry is deleted in the $deleteTable |
|
174 | + */ |
|
175 | + protected function deleteOrphanEntries(IOutput $output, $repairInfo, $deleteTable, $deleteId, $sourceTable, $sourceId, $sourceNullColumn) { |
|
176 | + $qb = $this->connection->getQueryBuilder(); |
|
177 | + |
|
178 | + $qb->select('d.' . $deleteId) |
|
179 | + ->from($deleteTable, 'd') |
|
180 | + ->leftJoin('d', $sourceTable, 's', $qb->expr()->eq('d.' . $deleteId, 's.' . $sourceId)) |
|
181 | + ->where( |
|
182 | + $qb->expr()->eq('d.type', $qb->expr()->literal('files')) |
|
183 | + ) |
|
184 | + ->andWhere( |
|
185 | + $qb->expr()->isNull('s.' . $sourceNullColumn) |
|
186 | + ); |
|
187 | + $result = $qb->execute(); |
|
188 | + |
|
189 | + $orphanItems = []; |
|
190 | + while ($row = $result->fetch()) { |
|
191 | + $orphanItems[] = (int) $row[$deleteId]; |
|
192 | + } |
|
193 | + |
|
194 | + if (!empty($orphanItems)) { |
|
195 | + $orphanItemsBatch = array_chunk($orphanItems, 200); |
|
196 | + foreach ($orphanItemsBatch as $items) { |
|
197 | + $qb->delete($deleteTable) |
|
198 | + ->where( |
|
199 | + $qb->expr()->eq('type', $qb->expr()->literal('files')) |
|
200 | + ) |
|
201 | + ->andWhere($qb->expr()->in($deleteId, $qb->createParameter('ids'))); |
|
202 | + $qb->setParameter('ids', $items, IQueryBuilder::PARAM_INT_ARRAY); |
|
203 | + $qb->execute(); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + if ($repairInfo) { |
|
208 | + $output->info(sprintf($repairInfo, count($orphanItems))); |
|
209 | + } |
|
210 | + } |
|
211 | 211 | } |