@@ -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; |
@@ -48,274 +48,274 @@ |
||
48 | 48 | */ |
49 | 49 | class ProviderFactory implements IProviderFactory { |
50 | 50 | |
51 | - /** @var IServerContainer */ |
|
52 | - private $serverContainer; |
|
53 | - /** @var DefaultShareProvider */ |
|
54 | - private $defaultProvider = null; |
|
55 | - /** @var FederatedShareProvider */ |
|
56 | - private $federatedProvider = null; |
|
57 | - /** @var ShareByMailProvider */ |
|
58 | - private $shareByMailProvider; |
|
59 | - /** @var \OCA\Circles\ShareByCircleProvider */ |
|
60 | - private $shareByCircleProvider = null; |
|
61 | - /** @var bool */ |
|
62 | - private $circlesAreNotAvailable = false; |
|
63 | - /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
64 | - private $roomShareProvider = null; |
|
65 | - |
|
66 | - /** |
|
67 | - * IProviderFactory constructor. |
|
68 | - * |
|
69 | - * @param IServerContainer $serverContainer |
|
70 | - */ |
|
71 | - public function __construct(IServerContainer $serverContainer) { |
|
72 | - $this->serverContainer = $serverContainer; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Create the default share provider. |
|
77 | - * |
|
78 | - * @return DefaultShareProvider |
|
79 | - */ |
|
80 | - protected function defaultShareProvider() { |
|
81 | - if ($this->defaultProvider === null) { |
|
82 | - $this->defaultProvider = new DefaultShareProvider( |
|
83 | - $this->serverContainer->getDatabaseConnection(), |
|
84 | - $this->serverContainer->getUserManager(), |
|
85 | - $this->serverContainer->getGroupManager(), |
|
86 | - $this->serverContainer->getLazyRootFolder(), |
|
87 | - $this->serverContainer->getMailer(), |
|
88 | - $this->serverContainer->query(Defaults::class), |
|
89 | - $this->serverContainer->getL10N('sharing'), |
|
90 | - $this->serverContainer->getURLGenerator() |
|
91 | - ); |
|
92 | - } |
|
93 | - |
|
94 | - return $this->defaultProvider; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Create the federated share provider |
|
99 | - * |
|
100 | - * @return FederatedShareProvider |
|
101 | - */ |
|
102 | - protected function federatedShareProvider() { |
|
103 | - if ($this->federatedProvider === null) { |
|
104 | - /* |
|
51 | + /** @var IServerContainer */ |
|
52 | + private $serverContainer; |
|
53 | + /** @var DefaultShareProvider */ |
|
54 | + private $defaultProvider = null; |
|
55 | + /** @var FederatedShareProvider */ |
|
56 | + private $federatedProvider = null; |
|
57 | + /** @var ShareByMailProvider */ |
|
58 | + private $shareByMailProvider; |
|
59 | + /** @var \OCA\Circles\ShareByCircleProvider */ |
|
60 | + private $shareByCircleProvider = null; |
|
61 | + /** @var bool */ |
|
62 | + private $circlesAreNotAvailable = false; |
|
63 | + /** @var \OCA\Talk\Share\RoomShareProvider */ |
|
64 | + private $roomShareProvider = null; |
|
65 | + |
|
66 | + /** |
|
67 | + * IProviderFactory constructor. |
|
68 | + * |
|
69 | + * @param IServerContainer $serverContainer |
|
70 | + */ |
|
71 | + public function __construct(IServerContainer $serverContainer) { |
|
72 | + $this->serverContainer = $serverContainer; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Create the default share provider. |
|
77 | + * |
|
78 | + * @return DefaultShareProvider |
|
79 | + */ |
|
80 | + protected function defaultShareProvider() { |
|
81 | + if ($this->defaultProvider === null) { |
|
82 | + $this->defaultProvider = new DefaultShareProvider( |
|
83 | + $this->serverContainer->getDatabaseConnection(), |
|
84 | + $this->serverContainer->getUserManager(), |
|
85 | + $this->serverContainer->getGroupManager(), |
|
86 | + $this->serverContainer->getLazyRootFolder(), |
|
87 | + $this->serverContainer->getMailer(), |
|
88 | + $this->serverContainer->query(Defaults::class), |
|
89 | + $this->serverContainer->getL10N('sharing'), |
|
90 | + $this->serverContainer->getURLGenerator() |
|
91 | + ); |
|
92 | + } |
|
93 | + |
|
94 | + return $this->defaultProvider; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Create the federated share provider |
|
99 | + * |
|
100 | + * @return FederatedShareProvider |
|
101 | + */ |
|
102 | + protected function federatedShareProvider() { |
|
103 | + if ($this->federatedProvider === null) { |
|
104 | + /* |
|
105 | 105 | * Check if the app is enabled |
106 | 106 | */ |
107 | - $appManager = $this->serverContainer->getAppManager(); |
|
108 | - if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
109 | - return null; |
|
110 | - } |
|
107 | + $appManager = $this->serverContainer->getAppManager(); |
|
108 | + if (!$appManager->isEnabledForUser('federatedfilesharing')) { |
|
109 | + return null; |
|
110 | + } |
|
111 | 111 | |
112 | - /* |
|
112 | + /* |
|
113 | 113 | * TODO: add factory to federated sharing app |
114 | 114 | */ |
115 | - $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
116 | - $addressHandler = new AddressHandler( |
|
117 | - $this->serverContainer->getURLGenerator(), |
|
118 | - $l, |
|
119 | - $this->serverContainer->getCloudIdManager() |
|
120 | - ); |
|
121 | - $notifications = new Notifications( |
|
122 | - $addressHandler, |
|
123 | - $this->serverContainer->getHTTPClientService(), |
|
124 | - $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
125 | - $this->serverContainer->getJobList(), |
|
126 | - \OC::$server->getCloudFederationProviderManager(), |
|
127 | - \OC::$server->getCloudFederationFactory() |
|
128 | - ); |
|
129 | - $tokenHandler = new TokenHandler( |
|
130 | - $this->serverContainer->getSecureRandom() |
|
131 | - ); |
|
132 | - |
|
133 | - $this->federatedProvider = new FederatedShareProvider( |
|
134 | - $this->serverContainer->getDatabaseConnection(), |
|
135 | - $addressHandler, |
|
136 | - $notifications, |
|
137 | - $tokenHandler, |
|
138 | - $l, |
|
139 | - $this->serverContainer->getLogger(), |
|
140 | - $this->serverContainer->getLazyRootFolder(), |
|
141 | - $this->serverContainer->getConfig(), |
|
142 | - $this->serverContainer->getUserManager(), |
|
143 | - $this->serverContainer->getCloudIdManager(), |
|
144 | - $this->serverContainer->getGlobalScaleConfig(), |
|
145 | - $this->serverContainer->getCloudFederationProviderManager() |
|
146 | - ); |
|
147 | - } |
|
148 | - |
|
149 | - return $this->federatedProvider; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Create the federated share provider |
|
154 | - * |
|
155 | - * @return ShareByMailProvider |
|
156 | - */ |
|
157 | - protected function getShareByMailProvider() { |
|
158 | - if ($this->shareByMailProvider === null) { |
|
159 | - /* |
|
115 | + $l = $this->serverContainer->getL10N('federatedfilesharing'); |
|
116 | + $addressHandler = new AddressHandler( |
|
117 | + $this->serverContainer->getURLGenerator(), |
|
118 | + $l, |
|
119 | + $this->serverContainer->getCloudIdManager() |
|
120 | + ); |
|
121 | + $notifications = new Notifications( |
|
122 | + $addressHandler, |
|
123 | + $this->serverContainer->getHTTPClientService(), |
|
124 | + $this->serverContainer->query(\OCP\OCS\IDiscoveryService::class), |
|
125 | + $this->serverContainer->getJobList(), |
|
126 | + \OC::$server->getCloudFederationProviderManager(), |
|
127 | + \OC::$server->getCloudFederationFactory() |
|
128 | + ); |
|
129 | + $tokenHandler = new TokenHandler( |
|
130 | + $this->serverContainer->getSecureRandom() |
|
131 | + ); |
|
132 | + |
|
133 | + $this->federatedProvider = new FederatedShareProvider( |
|
134 | + $this->serverContainer->getDatabaseConnection(), |
|
135 | + $addressHandler, |
|
136 | + $notifications, |
|
137 | + $tokenHandler, |
|
138 | + $l, |
|
139 | + $this->serverContainer->getLogger(), |
|
140 | + $this->serverContainer->getLazyRootFolder(), |
|
141 | + $this->serverContainer->getConfig(), |
|
142 | + $this->serverContainer->getUserManager(), |
|
143 | + $this->serverContainer->getCloudIdManager(), |
|
144 | + $this->serverContainer->getGlobalScaleConfig(), |
|
145 | + $this->serverContainer->getCloudFederationProviderManager() |
|
146 | + ); |
|
147 | + } |
|
148 | + |
|
149 | + return $this->federatedProvider; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Create the federated share provider |
|
154 | + * |
|
155 | + * @return ShareByMailProvider |
|
156 | + */ |
|
157 | + protected function getShareByMailProvider() { |
|
158 | + if ($this->shareByMailProvider === null) { |
|
159 | + /* |
|
160 | 160 | * Check if the app is enabled |
161 | 161 | */ |
162 | - $appManager = $this->serverContainer->getAppManager(); |
|
163 | - if (!$appManager->isEnabledForUser('sharebymail')) { |
|
164 | - return null; |
|
165 | - } |
|
166 | - |
|
167 | - $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
168 | - |
|
169 | - $this->shareByMailProvider = new ShareByMailProvider( |
|
170 | - $this->serverContainer->getDatabaseConnection(), |
|
171 | - $this->serverContainer->getSecureRandom(), |
|
172 | - $this->serverContainer->getUserManager(), |
|
173 | - $this->serverContainer->getLazyRootFolder(), |
|
174 | - $this->serverContainer->getL10N('sharebymail'), |
|
175 | - $this->serverContainer->getLogger(), |
|
176 | - $this->serverContainer->getMailer(), |
|
177 | - $this->serverContainer->getURLGenerator(), |
|
178 | - $this->serverContainer->getActivityManager(), |
|
179 | - $settingsManager, |
|
180 | - $this->serverContainer->query(Defaults::class), |
|
181 | - $this->serverContainer->getHasher(), |
|
182 | - $this->serverContainer->query(CapabilitiesManager::class) |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - return $this->shareByMailProvider; |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * Create the circle share provider |
|
192 | - * |
|
193 | - * @return FederatedShareProvider |
|
194 | - * |
|
195 | - * @suppress PhanUndeclaredClassMethod |
|
196 | - */ |
|
197 | - protected function getShareByCircleProvider() { |
|
198 | - |
|
199 | - if ($this->circlesAreNotAvailable) { |
|
200 | - return null; |
|
201 | - } |
|
202 | - |
|
203 | - if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
204 | - !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
205 | - ) { |
|
206 | - $this->circlesAreNotAvailable = true; |
|
207 | - return null; |
|
208 | - } |
|
209 | - |
|
210 | - if ($this->shareByCircleProvider === null) { |
|
211 | - |
|
212 | - $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
213 | - $this->serverContainer->getDatabaseConnection(), |
|
214 | - $this->serverContainer->getSecureRandom(), |
|
215 | - $this->serverContainer->getUserManager(), |
|
216 | - $this->serverContainer->getLazyRootFolder(), |
|
217 | - $this->serverContainer->getL10N('circles'), |
|
218 | - $this->serverContainer->getLogger(), |
|
219 | - $this->serverContainer->getURLGenerator() |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - return $this->shareByCircleProvider; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Create the room share provider |
|
228 | - * |
|
229 | - * @return RoomShareProvider |
|
230 | - */ |
|
231 | - protected function getRoomShareProvider() { |
|
232 | - if ($this->roomShareProvider === null) { |
|
233 | - /* |
|
162 | + $appManager = $this->serverContainer->getAppManager(); |
|
163 | + if (!$appManager->isEnabledForUser('sharebymail')) { |
|
164 | + return null; |
|
165 | + } |
|
166 | + |
|
167 | + $settingsManager = new SettingsManager($this->serverContainer->getConfig()); |
|
168 | + |
|
169 | + $this->shareByMailProvider = new ShareByMailProvider( |
|
170 | + $this->serverContainer->getDatabaseConnection(), |
|
171 | + $this->serverContainer->getSecureRandom(), |
|
172 | + $this->serverContainer->getUserManager(), |
|
173 | + $this->serverContainer->getLazyRootFolder(), |
|
174 | + $this->serverContainer->getL10N('sharebymail'), |
|
175 | + $this->serverContainer->getLogger(), |
|
176 | + $this->serverContainer->getMailer(), |
|
177 | + $this->serverContainer->getURLGenerator(), |
|
178 | + $this->serverContainer->getActivityManager(), |
|
179 | + $settingsManager, |
|
180 | + $this->serverContainer->query(Defaults::class), |
|
181 | + $this->serverContainer->getHasher(), |
|
182 | + $this->serverContainer->query(CapabilitiesManager::class) |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + return $this->shareByMailProvider; |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * Create the circle share provider |
|
192 | + * |
|
193 | + * @return FederatedShareProvider |
|
194 | + * |
|
195 | + * @suppress PhanUndeclaredClassMethod |
|
196 | + */ |
|
197 | + protected function getShareByCircleProvider() { |
|
198 | + |
|
199 | + if ($this->circlesAreNotAvailable) { |
|
200 | + return null; |
|
201 | + } |
|
202 | + |
|
203 | + if (!$this->serverContainer->getAppManager()->isEnabledForUser('circles') || |
|
204 | + !class_exists('\OCA\Circles\ShareByCircleProvider') |
|
205 | + ) { |
|
206 | + $this->circlesAreNotAvailable = true; |
|
207 | + return null; |
|
208 | + } |
|
209 | + |
|
210 | + if ($this->shareByCircleProvider === null) { |
|
211 | + |
|
212 | + $this->shareByCircleProvider = new \OCA\Circles\ShareByCircleProvider( |
|
213 | + $this->serverContainer->getDatabaseConnection(), |
|
214 | + $this->serverContainer->getSecureRandom(), |
|
215 | + $this->serverContainer->getUserManager(), |
|
216 | + $this->serverContainer->getLazyRootFolder(), |
|
217 | + $this->serverContainer->getL10N('circles'), |
|
218 | + $this->serverContainer->getLogger(), |
|
219 | + $this->serverContainer->getURLGenerator() |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + return $this->shareByCircleProvider; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Create the room share provider |
|
228 | + * |
|
229 | + * @return RoomShareProvider |
|
230 | + */ |
|
231 | + protected function getRoomShareProvider() { |
|
232 | + if ($this->roomShareProvider === null) { |
|
233 | + /* |
|
234 | 234 | * Check if the app is enabled |
235 | 235 | */ |
236 | - $appManager = $this->serverContainer->getAppManager(); |
|
237 | - if (!$appManager->isEnabledForUser('spreed')) { |
|
238 | - return null; |
|
239 | - } |
|
240 | - |
|
241 | - try { |
|
242 | - $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
243 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
244 | - return null; |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - return $this->roomShareProvider; |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * @inheritdoc |
|
253 | - */ |
|
254 | - public function getProvider($id) { |
|
255 | - $provider = null; |
|
256 | - if ($id === 'ocinternal') { |
|
257 | - $provider = $this->defaultShareProvider(); |
|
258 | - } else if ($id === 'ocFederatedSharing') { |
|
259 | - $provider = $this->federatedShareProvider(); |
|
260 | - } else if ($id === 'ocMailShare') { |
|
261 | - $provider = $this->getShareByMailProvider(); |
|
262 | - } else if ($id === 'ocCircleShare') { |
|
263 | - $provider = $this->getShareByCircleProvider(); |
|
264 | - } else if ($id === 'ocRoomShare') { |
|
265 | - $provider = $this->getRoomShareProvider(); |
|
266 | - } |
|
267 | - |
|
268 | - if ($provider === null) { |
|
269 | - throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
270 | - } |
|
271 | - |
|
272 | - return $provider; |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * @inheritdoc |
|
277 | - */ |
|
278 | - public function getProviderForType($shareType) { |
|
279 | - $provider = null; |
|
280 | - |
|
281 | - if ($shareType === \OCP\Share::SHARE_TYPE_USER || |
|
282 | - $shareType === \OCP\Share::SHARE_TYPE_GROUP || |
|
283 | - $shareType === \OCP\Share::SHARE_TYPE_LINK |
|
284 | - ) { |
|
285 | - $provider = $this->defaultShareProvider(); |
|
286 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { |
|
287 | - $provider = $this->federatedShareProvider(); |
|
288 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { |
|
289 | - $provider = $this->getShareByMailProvider(); |
|
290 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { |
|
291 | - $provider = $this->getShareByCircleProvider(); |
|
292 | - } else if ($shareType === \OCP\Share::SHARE_TYPE_ROOM) { |
|
293 | - $provider = $this->getRoomShareProvider(); |
|
294 | - } |
|
295 | - |
|
296 | - |
|
297 | - if ($provider === null) { |
|
298 | - throw new ProviderException('No share provider for share type ' . $shareType); |
|
299 | - } |
|
300 | - |
|
301 | - return $provider; |
|
302 | - } |
|
303 | - |
|
304 | - public function getAllProviders() { |
|
305 | - $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
306 | - $shareByMail = $this->getShareByMailProvider(); |
|
307 | - if ($shareByMail !== null) { |
|
308 | - $shares[] = $shareByMail; |
|
309 | - } |
|
310 | - $shareByCircle = $this->getShareByCircleProvider(); |
|
311 | - if ($shareByCircle !== null) { |
|
312 | - $shares[] = $shareByCircle; |
|
313 | - } |
|
314 | - $roomShare = $this->getRoomShareProvider(); |
|
315 | - if ($roomShare !== null) { |
|
316 | - $shares[] = $roomShare; |
|
317 | - } |
|
318 | - |
|
319 | - return $shares; |
|
320 | - } |
|
236 | + $appManager = $this->serverContainer->getAppManager(); |
|
237 | + if (!$appManager->isEnabledForUser('spreed')) { |
|
238 | + return null; |
|
239 | + } |
|
240 | + |
|
241 | + try { |
|
242 | + $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider'); |
|
243 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
244 | + return null; |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + return $this->roomShareProvider; |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * @inheritdoc |
|
253 | + */ |
|
254 | + public function getProvider($id) { |
|
255 | + $provider = null; |
|
256 | + if ($id === 'ocinternal') { |
|
257 | + $provider = $this->defaultShareProvider(); |
|
258 | + } else if ($id === 'ocFederatedSharing') { |
|
259 | + $provider = $this->federatedShareProvider(); |
|
260 | + } else if ($id === 'ocMailShare') { |
|
261 | + $provider = $this->getShareByMailProvider(); |
|
262 | + } else if ($id === 'ocCircleShare') { |
|
263 | + $provider = $this->getShareByCircleProvider(); |
|
264 | + } else if ($id === 'ocRoomShare') { |
|
265 | + $provider = $this->getRoomShareProvider(); |
|
266 | + } |
|
267 | + |
|
268 | + if ($provider === null) { |
|
269 | + throw new ProviderException('No provider with id .' . $id . ' found.'); |
|
270 | + } |
|
271 | + |
|
272 | + return $provider; |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * @inheritdoc |
|
277 | + */ |
|
278 | + public function getProviderForType($shareType) { |
|
279 | + $provider = null; |
|
280 | + |
|
281 | + if ($shareType === \OCP\Share::SHARE_TYPE_USER || |
|
282 | + $shareType === \OCP\Share::SHARE_TYPE_GROUP || |
|
283 | + $shareType === \OCP\Share::SHARE_TYPE_LINK |
|
284 | + ) { |
|
285 | + $provider = $this->defaultShareProvider(); |
|
286 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_REMOTE || $shareType === \OCP\Share::SHARE_TYPE_REMOTE_GROUP) { |
|
287 | + $provider = $this->federatedShareProvider(); |
|
288 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { |
|
289 | + $provider = $this->getShareByMailProvider(); |
|
290 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_CIRCLE) { |
|
291 | + $provider = $this->getShareByCircleProvider(); |
|
292 | + } else if ($shareType === \OCP\Share::SHARE_TYPE_ROOM) { |
|
293 | + $provider = $this->getRoomShareProvider(); |
|
294 | + } |
|
295 | + |
|
296 | + |
|
297 | + if ($provider === null) { |
|
298 | + throw new ProviderException('No share provider for share type ' . $shareType); |
|
299 | + } |
|
300 | + |
|
301 | + return $provider; |
|
302 | + } |
|
303 | + |
|
304 | + public function getAllProviders() { |
|
305 | + $shares = [$this->defaultShareProvider(), $this->federatedShareProvider()]; |
|
306 | + $shareByMail = $this->getShareByMailProvider(); |
|
307 | + if ($shareByMail !== null) { |
|
308 | + $shares[] = $shareByMail; |
|
309 | + } |
|
310 | + $shareByCircle = $this->getShareByCircleProvider(); |
|
311 | + if ($shareByCircle !== null) { |
|
312 | + $shares[] = $shareByCircle; |
|
313 | + } |
|
314 | + $roomShare = $this->getRoomShareProvider(); |
|
315 | + if ($roomShare !== null) { |
|
316 | + $shares[] = $roomShare; |
|
317 | + } |
|
318 | + |
|
319 | + return $shares; |
|
320 | + } |
|
321 | 321 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | $eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener); |
66 | 66 | $eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener); |
67 | 67 | |
68 | -\OCA\Files\App::getNavigationManager()->add(function () { |
|
68 | +\OCA\Files\App::getNavigationManager()->add(function() { |
|
69 | 69 | $l = \OC::$server->getL10N('systemtags'); |
70 | 70 | return [ |
71 | 71 | 'id' => 'systemtagsfilter', |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | |
31 | 31 | $eventDispatcher = \OC::$server->getEventDispatcher(); |
32 | 32 | $eventDispatcher->addListener( |
33 | - 'OCA\Files::loadAdditionalScripts', |
|
34 | - function() { |
|
35 | - // FIXME: no public API for these ? |
|
36 | - \OCP\Util::addScript('dist/systemtags'); |
|
37 | - \OCP\Util::addScript('systemtags', 'systemtags'); |
|
38 | - } |
|
33 | + 'OCA\Files::loadAdditionalScripts', |
|
34 | + function() { |
|
35 | + // FIXME: no public API for these ? |
|
36 | + \OCP\Util::addScript('dist/systemtags'); |
|
37 | + \OCP\Util::addScript('systemtags', 'systemtags'); |
|
38 | + } |
|
39 | 39 | ); |
40 | 40 | |
41 | 41 | $managerListener = function(ManagerEvent $event) { |
42 | - $application = new \OCP\AppFramework\App('systemtags'); |
|
43 | - /** @var \OCA\SystemTags\Activity\Listener $listener */ |
|
44 | - $listener = $application->getContainer()->query(Listener::class); |
|
45 | - $listener->event($event); |
|
42 | + $application = new \OCP\AppFramework\App('systemtags'); |
|
43 | + /** @var \OCA\SystemTags\Activity\Listener $listener */ |
|
44 | + $listener = $application->getContainer()->query(Listener::class); |
|
45 | + $listener->event($event); |
|
46 | 46 | }; |
47 | 47 | |
48 | 48 | $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener); |
@@ -50,23 +50,23 @@ discard block |
||
50 | 50 | $eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener); |
51 | 51 | |
52 | 52 | $mapperListener = function(MapperEvent $event) { |
53 | - $application = new \OCP\AppFramework\App('systemtags'); |
|
54 | - /** @var \OCA\SystemTags\Activity\Listener $listener */ |
|
55 | - $listener = $application->getContainer()->query(Listener::class); |
|
56 | - $listener->mapperEvent($event); |
|
53 | + $application = new \OCP\AppFramework\App('systemtags'); |
|
54 | + /** @var \OCA\SystemTags\Activity\Listener $listener */ |
|
55 | + $listener = $application->getContainer()->query(Listener::class); |
|
56 | + $listener->mapperEvent($event); |
|
57 | 57 | }; |
58 | 58 | |
59 | 59 | $eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener); |
60 | 60 | $eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener); |
61 | 61 | |
62 | 62 | \OCA\Files\App::getNavigationManager()->add(function () { |
63 | - $l = \OC::$server->getL10N('systemtags'); |
|
64 | - return [ |
|
65 | - 'id' => 'systemtagsfilter', |
|
66 | - 'appname' => 'systemtags', |
|
67 | - 'script' => 'list.php', |
|
68 | - 'order' => 25, |
|
69 | - 'name' => $l->t('Tags'), |
|
70 | - ]; |
|
63 | + $l = \OC::$server->getL10N('systemtags'); |
|
64 | + return [ |
|
65 | + 'id' => 'systemtagsfilter', |
|
66 | + 'appname' => 'systemtags', |
|
67 | + 'script' => 'list.php', |
|
68 | + 'order' => 25, |
|
69 | + 'name' => $l->t('Tags'), |
|
70 | + ]; |
|
71 | 71 | }); |
72 | 72 |
@@ -28,7 +28,7 @@ |
||
28 | 28 | // register hooks |
29 | 29 | \OCA\Files_Trashbin\Trashbin::registerHooks(); |
30 | 30 | |
31 | -\OCA\Files\App::getNavigationManager()->add(function () { |
|
31 | +\OCA\Files\App::getNavigationManager()->add(function() { |
|
32 | 32 | $l = \OC::$server->getL10N('files_trashbin'); |
33 | 33 | return [ |
34 | 34 | 'id' => 'trashbin', |
@@ -29,13 +29,13 @@ |
||
29 | 29 | \OCA\Files_Trashbin\Trashbin::registerHooks(); |
30 | 30 | |
31 | 31 | \OCA\Files\App::getNavigationManager()->add(function () { |
32 | - $l = \OC::$server->getL10N('files_trashbin'); |
|
33 | - return [ |
|
34 | - 'id' => 'trashbin', |
|
35 | - 'appname' => 'files_trashbin', |
|
36 | - 'script' => 'list.php', |
|
37 | - 'order' => 50, |
|
38 | - 'name' => $l->t('Deleted files'), |
|
39 | - 'classes' => 'pinned', |
|
40 | - ]; |
|
32 | + $l = \OC::$server->getL10N('files_trashbin'); |
|
33 | + return [ |
|
34 | + 'id' => 'trashbin', |
|
35 | + 'appname' => 'files_trashbin', |
|
36 | + 'script' => 'list.php', |
|
37 | + 'order' => 50, |
|
38 | + 'name' => $l->t('Deleted files'), |
|
39 | + 'classes' => 'pinned', |
|
40 | + ]; |
|
41 | 41 | }); |
@@ -23,50 +23,50 @@ |
||
23 | 23 | $application = new \OCA\Federation\AppInfo\Application(); |
24 | 24 | |
25 | 25 | $application->registerRoutes( |
26 | - $this, |
|
27 | - [ |
|
28 | - 'routes' => [ |
|
29 | - [ |
|
30 | - 'name' => 'Settings#addServer', |
|
31 | - 'url' => '/trusted-servers', |
|
32 | - 'verb' => 'POST' |
|
33 | - ], |
|
34 | - [ |
|
35 | - 'name' => 'Settings#removeServer', |
|
36 | - 'url' => '/trusted-servers/{id}', |
|
37 | - 'verb' => 'DELETE' |
|
38 | - ], |
|
39 | - [ |
|
40 | - 'name' => 'Settings#autoAddServers', |
|
41 | - 'url' => '/auto-add-servers', |
|
42 | - 'verb' => 'POST' |
|
43 | - ], |
|
44 | - ], |
|
45 | - 'ocs' => [ |
|
46 | - // old endpoints, only used by Nextcloud and ownCloud |
|
47 | - [ |
|
48 | - 'name' => 'OCSAuthAPI#getSharedSecretLegacy', |
|
49 | - 'url' => '/api/v1/shared-secret', |
|
50 | - 'verb' => 'GET', |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'name' => 'OCSAuthAPI#requestSharedSecretLegacy', |
|
54 | - 'url' => '/api/v1/request-shared-secret', |
|
55 | - 'verb' => 'POST', |
|
56 | - ], |
|
57 | - // new endpoints, published as public api |
|
58 | - [ |
|
59 | - 'name' => 'OCSAuthAPI#getSharedSecret', |
|
60 | - 'root' => '/cloud', |
|
61 | - 'url' => '/shared-secret', |
|
62 | - 'verb' => 'GET', |
|
63 | - ], |
|
64 | - [ |
|
65 | - 'name' => 'OCSAuthAPI#requestSharedSecret', |
|
66 | - 'root' => '/cloud', |
|
67 | - 'url' => '/shared-secret', |
|
68 | - 'verb' => 'POST', |
|
69 | - ], |
|
70 | - ], |
|
71 | - ] |
|
26 | + $this, |
|
27 | + [ |
|
28 | + 'routes' => [ |
|
29 | + [ |
|
30 | + 'name' => 'Settings#addServer', |
|
31 | + 'url' => '/trusted-servers', |
|
32 | + 'verb' => 'POST' |
|
33 | + ], |
|
34 | + [ |
|
35 | + 'name' => 'Settings#removeServer', |
|
36 | + 'url' => '/trusted-servers/{id}', |
|
37 | + 'verb' => 'DELETE' |
|
38 | + ], |
|
39 | + [ |
|
40 | + 'name' => 'Settings#autoAddServers', |
|
41 | + 'url' => '/auto-add-servers', |
|
42 | + 'verb' => 'POST' |
|
43 | + ], |
|
44 | + ], |
|
45 | + 'ocs' => [ |
|
46 | + // old endpoints, only used by Nextcloud and ownCloud |
|
47 | + [ |
|
48 | + 'name' => 'OCSAuthAPI#getSharedSecretLegacy', |
|
49 | + 'url' => '/api/v1/shared-secret', |
|
50 | + 'verb' => 'GET', |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'name' => 'OCSAuthAPI#requestSharedSecretLegacy', |
|
54 | + 'url' => '/api/v1/request-shared-secret', |
|
55 | + 'verb' => 'POST', |
|
56 | + ], |
|
57 | + // new endpoints, published as public api |
|
58 | + [ |
|
59 | + 'name' => 'OCSAuthAPI#getSharedSecret', |
|
60 | + 'root' => '/cloud', |
|
61 | + 'url' => '/shared-secret', |
|
62 | + 'verb' => 'GET', |
|
63 | + ], |
|
64 | + [ |
|
65 | + 'name' => 'OCSAuthAPI#requestSharedSecret', |
|
66 | + 'root' => '/cloud', |
|
67 | + 'url' => '/shared-secret', |
|
68 | + 'verb' => 'POST', |
|
69 | + ], |
|
70 | + ], |
|
71 | + ] |
|
72 | 72 | ); |
@@ -119,9 +119,9 @@ |
||
119 | 119 | $elements = explode(' ', $fullName); |
120 | 120 | $result = ['', '', '', '', '']; |
121 | 121 | if (count($elements) > 2) { |
122 | - $result[0] = implode(' ', array_slice($elements, count($elements)-1)); |
|
122 | + $result[0] = implode(' ', array_slice($elements, count($elements) - 1)); |
|
123 | 123 | $result[1] = $elements[0]; |
124 | - $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2)); |
|
124 | + $result[2] = implode(' ', array_slice($elements, 1, count($elements) - 2)); |
|
125 | 125 | } elseif (count($elements) === 2) { |
126 | 126 | $result[0] = $elements[1]; |
127 | 127 | $result[1] = $elements[0]; |
@@ -31,122 +31,122 @@ |
||
31 | 31 | |
32 | 32 | class Converter { |
33 | 33 | |
34 | - /** @var AccountManager */ |
|
35 | - private $accountManager; |
|
36 | - |
|
37 | - /** |
|
38 | - * Converter constructor. |
|
39 | - * |
|
40 | - * @param AccountManager $accountManager |
|
41 | - */ |
|
42 | - public function __construct(AccountManager $accountManager) { |
|
43 | - $this->accountManager = $accountManager; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * @param IUser $user |
|
48 | - * @return VCard|null |
|
49 | - */ |
|
50 | - public function createCardFromUser(IUser $user) { |
|
51 | - |
|
52 | - $userData = $this->accountManager->getUser($user); |
|
53 | - |
|
54 | - $uid = $user->getUID(); |
|
55 | - $cloudId = $user->getCloudId(); |
|
56 | - $image = $this->getAvatarImage($user); |
|
57 | - |
|
58 | - $vCard = new VCard(); |
|
59 | - $vCard->VERSION = '3.0'; |
|
60 | - $vCard->UID = $uid; |
|
61 | - |
|
62 | - $publish = false; |
|
63 | - |
|
64 | - if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) { |
|
65 | - $userData[AccountManager::PROPERTY_AVATAR]['value'] = true; |
|
66 | - } |
|
67 | - |
|
68 | - foreach ($userData as $property => $value) { |
|
69 | - |
|
70 | - $shareWithTrustedServers = |
|
71 | - $value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY || |
|
72 | - $value['scope'] === AccountManager::VISIBILITY_PUBLIC; |
|
73 | - |
|
74 | - $emptyValue = !isset($value['value']) || $value['value'] === ''; |
|
75 | - |
|
76 | - if ($shareWithTrustedServers && !$emptyValue) { |
|
77 | - $publish = true; |
|
78 | - switch ($property) { |
|
79 | - case AccountManager::PROPERTY_DISPLAYNAME: |
|
80 | - $vCard->add(new Text($vCard, 'FN', $value['value'])); |
|
81 | - $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value']))); |
|
82 | - break; |
|
83 | - case AccountManager::PROPERTY_AVATAR: |
|
84 | - if ($image !== null) { |
|
85 | - $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]); |
|
86 | - } |
|
87 | - break; |
|
88 | - case AccountManager::PROPERTY_EMAIL: |
|
89 | - $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER'])); |
|
90 | - break; |
|
91 | - case AccountManager::PROPERTY_WEBSITE: |
|
92 | - $vCard->add(new Text($vCard, 'URL', $value['value'])); |
|
93 | - break; |
|
94 | - case AccountManager::PROPERTY_PHONE: |
|
95 | - $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER'])); |
|
96 | - break; |
|
97 | - case AccountManager::PROPERTY_ADDRESS: |
|
98 | - $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER'])); |
|
99 | - break; |
|
100 | - case AccountManager::PROPERTY_TWITTER: |
|
101 | - $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER'])); |
|
102 | - break; |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
106 | - |
|
107 | - if ($publish && !empty($cloudId)) { |
|
108 | - $vCard->add(new Text($vCard, 'CLOUD', $cloudId)); |
|
109 | - $vCard->validate(); |
|
110 | - return $vCard; |
|
111 | - } |
|
112 | - |
|
113 | - return null; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $fullName |
|
118 | - * @return string[] |
|
119 | - */ |
|
120 | - public function splitFullName($fullName) { |
|
121 | - // Very basic western style parsing. I'm not gonna implement |
|
122 | - // https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;) |
|
123 | - |
|
124 | - $elements = explode(' ', $fullName); |
|
125 | - $result = ['', '', '', '', '']; |
|
126 | - if (count($elements) > 2) { |
|
127 | - $result[0] = implode(' ', array_slice($elements, count($elements)-1)); |
|
128 | - $result[1] = $elements[0]; |
|
129 | - $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2)); |
|
130 | - } elseif (count($elements) === 2) { |
|
131 | - $result[0] = $elements[1]; |
|
132 | - $result[1] = $elements[0]; |
|
133 | - } else { |
|
134 | - $result[0] = $elements[0]; |
|
135 | - } |
|
136 | - |
|
137 | - return $result; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param IUser $user |
|
142 | - * @return null|IImage |
|
143 | - */ |
|
144 | - private function getAvatarImage(IUser $user) { |
|
145 | - try { |
|
146 | - return $user->getAvatarImage(-1); |
|
147 | - } catch (\Exception $ex) { |
|
148 | - return null; |
|
149 | - } |
|
150 | - } |
|
34 | + /** @var AccountManager */ |
|
35 | + private $accountManager; |
|
36 | + |
|
37 | + /** |
|
38 | + * Converter constructor. |
|
39 | + * |
|
40 | + * @param AccountManager $accountManager |
|
41 | + */ |
|
42 | + public function __construct(AccountManager $accountManager) { |
|
43 | + $this->accountManager = $accountManager; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * @param IUser $user |
|
48 | + * @return VCard|null |
|
49 | + */ |
|
50 | + public function createCardFromUser(IUser $user) { |
|
51 | + |
|
52 | + $userData = $this->accountManager->getUser($user); |
|
53 | + |
|
54 | + $uid = $user->getUID(); |
|
55 | + $cloudId = $user->getCloudId(); |
|
56 | + $image = $this->getAvatarImage($user); |
|
57 | + |
|
58 | + $vCard = new VCard(); |
|
59 | + $vCard->VERSION = '3.0'; |
|
60 | + $vCard->UID = $uid; |
|
61 | + |
|
62 | + $publish = false; |
|
63 | + |
|
64 | + if ($image !== null && isset($userData[AccountManager::PROPERTY_AVATAR])) { |
|
65 | + $userData[AccountManager::PROPERTY_AVATAR]['value'] = true; |
|
66 | + } |
|
67 | + |
|
68 | + foreach ($userData as $property => $value) { |
|
69 | + |
|
70 | + $shareWithTrustedServers = |
|
71 | + $value['scope'] === AccountManager::VISIBILITY_CONTACTS_ONLY || |
|
72 | + $value['scope'] === AccountManager::VISIBILITY_PUBLIC; |
|
73 | + |
|
74 | + $emptyValue = !isset($value['value']) || $value['value'] === ''; |
|
75 | + |
|
76 | + if ($shareWithTrustedServers && !$emptyValue) { |
|
77 | + $publish = true; |
|
78 | + switch ($property) { |
|
79 | + case AccountManager::PROPERTY_DISPLAYNAME: |
|
80 | + $vCard->add(new Text($vCard, 'FN', $value['value'])); |
|
81 | + $vCard->add(new Text($vCard, 'N', $this->splitFullName($value['value']))); |
|
82 | + break; |
|
83 | + case AccountManager::PROPERTY_AVATAR: |
|
84 | + if ($image !== null) { |
|
85 | + $vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]); |
|
86 | + } |
|
87 | + break; |
|
88 | + case AccountManager::PROPERTY_EMAIL: |
|
89 | + $vCard->add(new Text($vCard, 'EMAIL', $value['value'], ['TYPE' => 'OTHER'])); |
|
90 | + break; |
|
91 | + case AccountManager::PROPERTY_WEBSITE: |
|
92 | + $vCard->add(new Text($vCard, 'URL', $value['value'])); |
|
93 | + break; |
|
94 | + case AccountManager::PROPERTY_PHONE: |
|
95 | + $vCard->add(new Text($vCard, 'TEL', $value['value'], ['TYPE' => 'OTHER'])); |
|
96 | + break; |
|
97 | + case AccountManager::PROPERTY_ADDRESS: |
|
98 | + $vCard->add(new Text($vCard, 'ADR', $value['value'], ['TYPE' => 'OTHER'])); |
|
99 | + break; |
|
100 | + case AccountManager::PROPERTY_TWITTER: |
|
101 | + $vCard->add(new Text($vCard, 'X-SOCIALPROFILE', $value['value'], ['TYPE' => 'TWITTER'])); |
|
102 | + break; |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | + |
|
107 | + if ($publish && !empty($cloudId)) { |
|
108 | + $vCard->add(new Text($vCard, 'CLOUD', $cloudId)); |
|
109 | + $vCard->validate(); |
|
110 | + return $vCard; |
|
111 | + } |
|
112 | + |
|
113 | + return null; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $fullName |
|
118 | + * @return string[] |
|
119 | + */ |
|
120 | + public function splitFullName($fullName) { |
|
121 | + // Very basic western style parsing. I'm not gonna implement |
|
122 | + // https://github.com/android/platform_packages_providers_contactsprovider/blob/master/src/com/android/providers/contacts/NameSplitter.java ;) |
|
123 | + |
|
124 | + $elements = explode(' ', $fullName); |
|
125 | + $result = ['', '', '', '', '']; |
|
126 | + if (count($elements) > 2) { |
|
127 | + $result[0] = implode(' ', array_slice($elements, count($elements)-1)); |
|
128 | + $result[1] = $elements[0]; |
|
129 | + $result[2] = implode(' ', array_slice($elements, 1, count($elements)-2)); |
|
130 | + } elseif (count($elements) === 2) { |
|
131 | + $result[0] = $elements[1]; |
|
132 | + $result[1] = $elements[0]; |
|
133 | + } else { |
|
134 | + $result[0] = $elements[0]; |
|
135 | + } |
|
136 | + |
|
137 | + return $result; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param IUser $user |
|
142 | + * @return null|IImage |
|
143 | + */ |
|
144 | + private function getAvatarImage(IUser $user) { |
|
145 | + try { |
|
146 | + return $user->getAvatarImage(-1); |
|
147 | + } catch (\Exception $ex) { |
|
148 | + return null; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | 152 | } |
@@ -30,64 +30,64 @@ |
||
30 | 30 | |
31 | 31 | class SyncFederationAddressBooks { |
32 | 32 | |
33 | - /** @var DbHandler */ |
|
34 | - protected $dbHandler; |
|
33 | + /** @var DbHandler */ |
|
34 | + protected $dbHandler; |
|
35 | 35 | |
36 | - /** @var SyncService */ |
|
37 | - private $syncService; |
|
36 | + /** @var SyncService */ |
|
37 | + private $syncService; |
|
38 | 38 | |
39 | - /** @var DiscoveryService */ |
|
40 | - private $ocsDiscoveryService; |
|
39 | + /** @var DiscoveryService */ |
|
40 | + private $ocsDiscoveryService; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param DbHandler $dbHandler |
|
44 | - * @param SyncService $syncService |
|
45 | - * @param IDiscoveryService $ocsDiscoveryService |
|
46 | - */ |
|
47 | - public function __construct(DbHandler $dbHandler, |
|
48 | - SyncService $syncService, |
|
49 | - IDiscoveryService $ocsDiscoveryService |
|
50 | - ) { |
|
51 | - $this->syncService = $syncService; |
|
52 | - $this->dbHandler = $dbHandler; |
|
53 | - $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | - } |
|
42 | + /** |
|
43 | + * @param DbHandler $dbHandler |
|
44 | + * @param SyncService $syncService |
|
45 | + * @param IDiscoveryService $ocsDiscoveryService |
|
46 | + */ |
|
47 | + public function __construct(DbHandler $dbHandler, |
|
48 | + SyncService $syncService, |
|
49 | + IDiscoveryService $ocsDiscoveryService |
|
50 | + ) { |
|
51 | + $this->syncService = $syncService; |
|
52 | + $this->dbHandler = $dbHandler; |
|
53 | + $this->ocsDiscoveryService = $ocsDiscoveryService; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param \Closure $callback |
|
58 | - */ |
|
59 | - public function syncThemAll(\Closure $callback) { |
|
56 | + /** |
|
57 | + * @param \Closure $callback |
|
58 | + */ |
|
59 | + public function syncThemAll(\Closure $callback) { |
|
60 | 60 | |
61 | - $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | - foreach ($trustedServers as $trustedServer) { |
|
63 | - $url = $trustedServer['url']; |
|
64 | - $callback($url, null); |
|
65 | - $sharedSecret = $trustedServer['shared_secret']; |
|
66 | - $syncToken = $trustedServer['sync_token']; |
|
61 | + $trustedServers = $this->dbHandler->getAllServer(); |
|
62 | + foreach ($trustedServers as $trustedServer) { |
|
63 | + $url = $trustedServer['url']; |
|
64 | + $callback($url, null); |
|
65 | + $sharedSecret = $trustedServer['shared_secret']; |
|
66 | + $syncToken = $trustedServer['sync_token']; |
|
67 | 67 | |
68 | - $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | - $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | - $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
68 | + $endPoints = $this->ocsDiscoveryService->discover($url, 'FEDERATED_SHARING'); |
|
69 | + $cardDavUser = isset($endPoints['carddav-user']) ? $endPoints['carddav-user'] : 'system'; |
|
70 | + $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; |
|
71 | 71 | |
72 | - if (is_null($sharedSecret)) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $targetBookId = $trustedServer['url_hash']; |
|
76 | - $targetPrincipal = "principals/system/system"; |
|
77 | - $targetBookProperties = [ |
|
78 | - '{DAV:}displayname' => $url |
|
79 | - ]; |
|
80 | - try { |
|
81 | - $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | - if ($newToken !== $syncToken) { |
|
83 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | - } |
|
85 | - } catch (\Exception $ex) { |
|
86 | - if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | - $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | - } |
|
89 | - $callback($url, $ex); |
|
90 | - } |
|
91 | - } |
|
92 | - } |
|
72 | + if (is_null($sharedSecret)) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $targetBookId = $trustedServer['url_hash']; |
|
76 | + $targetPrincipal = "principals/system/system"; |
|
77 | + $targetBookProperties = [ |
|
78 | + '{DAV:}displayname' => $url |
|
79 | + ]; |
|
80 | + try { |
|
81 | + $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); |
|
82 | + if ($newToken !== $syncToken) { |
|
83 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); |
|
84 | + } |
|
85 | + } catch (\Exception $ex) { |
|
86 | + if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { |
|
87 | + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); |
|
88 | + } |
|
89 | + $callback($url, $ex); |
|
90 | + } |
|
91 | + } |
|
92 | + } |
|
93 | 93 | } |
@@ -28,35 +28,35 @@ |
||
28 | 28 | use Symfony\Component\Console\Output\OutputInterface; |
29 | 29 | |
30 | 30 | class Check extends Base { |
31 | - /** |
|
32 | - * @var SystemConfig |
|
33 | - */ |
|
34 | - private $config; |
|
31 | + /** |
|
32 | + * @var SystemConfig |
|
33 | + */ |
|
34 | + private $config; |
|
35 | 35 | |
36 | - public function __construct(SystemConfig $config) { |
|
37 | - parent::__construct(); |
|
38 | - $this->config = $config; |
|
39 | - } |
|
36 | + public function __construct(SystemConfig $config) { |
|
37 | + parent::__construct(); |
|
38 | + $this->config = $config; |
|
39 | + } |
|
40 | 40 | |
41 | - protected function configure() { |
|
42 | - parent::configure(); |
|
41 | + protected function configure() { |
|
42 | + parent::configure(); |
|
43 | 43 | |
44 | - $this |
|
45 | - ->setName('check') |
|
46 | - ->setDescription('check dependencies of the server environment') |
|
47 | - ; |
|
48 | - } |
|
44 | + $this |
|
45 | + ->setName('check') |
|
46 | + ->setDescription('check dependencies of the server environment') |
|
47 | + ; |
|
48 | + } |
|
49 | 49 | |
50 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
51 | - $errors = \OC_Util::checkServer($this->config); |
|
52 | - if (!empty($errors)) { |
|
53 | - $errors = array_map(function($item) { |
|
54 | - return (string) $item['error']; |
|
55 | - }, $errors); |
|
50 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
51 | + $errors = \OC_Util::checkServer($this->config); |
|
52 | + if (!empty($errors)) { |
|
53 | + $errors = array_map(function($item) { |
|
54 | + return (string) $item['error']; |
|
55 | + }, $errors); |
|
56 | 56 | |
57 | - $this->writeArrayInOutputFormat($input, $output, $errors); |
|
58 | - return 1; |
|
59 | - } |
|
60 | - return 0; |
|
61 | - } |
|
57 | + $this->writeArrayInOutputFormat($input, $output, $errors); |
|
58 | + return 1; |
|
59 | + } |
|
60 | + return 0; |
|
61 | + } |
|
62 | 62 | } |
@@ -39,33 +39,33 @@ |
||
39 | 39 | * @package OCA\DAV\Connector\Sabre |
40 | 40 | */ |
41 | 41 | class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin { |
42 | - /** @var \Sabre\DAV\Server */ |
|
43 | - protected $server; |
|
42 | + /** @var \Sabre\DAV\Server */ |
|
43 | + protected $server; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param \Sabre\DAV\Server $server |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - function initialize(\Sabre\DAV\Server $server) { |
|
50 | - $this->server = $server; |
|
51 | - $this->server->on('method:GET', [$this, 'httpGet'], 200); |
|
52 | - } |
|
45 | + /** |
|
46 | + * @param \Sabre\DAV\Server $server |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + function initialize(\Sabre\DAV\Server $server) { |
|
50 | + $this->server = $server; |
|
51 | + $this->server->on('method:GET', [$this, 'httpGet'], 200); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param RequestInterface $request |
|
56 | - * @param ResponseInterface $response |
|
57 | - * @return false |
|
58 | - */ |
|
59 | - function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
60 | - $string = 'This is the WebDAV interface. It can only be accessed by ' . |
|
61 | - 'WebDAV clients such as the Nextcloud desktop sync client.'; |
|
62 | - $stream = fopen('php://memory','r+'); |
|
63 | - fwrite($stream, $string); |
|
64 | - rewind($stream); |
|
54 | + /** |
|
55 | + * @param RequestInterface $request |
|
56 | + * @param ResponseInterface $response |
|
57 | + * @return false |
|
58 | + */ |
|
59 | + function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
60 | + $string = 'This is the WebDAV interface. It can only be accessed by ' . |
|
61 | + 'WebDAV clients such as the Nextcloud desktop sync client.'; |
|
62 | + $stream = fopen('php://memory','r+'); |
|
63 | + fwrite($stream, $string); |
|
64 | + rewind($stream); |
|
65 | 65 | |
66 | - $response->setStatus(200); |
|
67 | - $response->setBody($stream); |
|
66 | + $response->setStatus(200); |
|
67 | + $response->setBody($stream); |
|
68 | 68 | |
69 | - return false; |
|
70 | - } |
|
69 | + return false; |
|
70 | + } |
|
71 | 71 | } |
@@ -57,9 +57,9 @@ |
||
57 | 57 | * @return false |
58 | 58 | */ |
59 | 59 | function httpGet(RequestInterface $request, ResponseInterface $response) { |
60 | - $string = 'This is the WebDAV interface. It can only be accessed by ' . |
|
60 | + $string = 'This is the WebDAV interface. It can only be accessed by '. |
|
61 | 61 | 'WebDAV clients such as the Nextcloud desktop sync client.'; |
62 | - $stream = fopen('php://memory','r+'); |
|
62 | + $stream = fopen('php://memory', 'r+'); |
|
63 | 63 | fwrite($stream, $string); |
64 | 64 | rewind($stream); |
65 | 65 |
@@ -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 | } |