Passed
Push — master ( 3749b7...a0444b )
by Julius
13:05 queued 12s
created
apps/files_sharing/lib/External/Manager.php 2 patches
Indentation   +534 added lines, -534 removed lines patch added patch discarded remove patch
@@ -51,579 +51,579 @@
 block discarded – undo
51 51
 use OCP\Share\IShare;
52 52
 
53 53
 class Manager {
54
-	public const STORAGE = '\OCA\Files_Sharing\External\Storage';
55
-
56
-	/** @var string|null */
57
-	private $uid;
58
-
59
-	/** @var IDBConnection */
60
-	private $connection;
61
-
62
-	/** @var \OC\Files\Mount\Manager */
63
-	private $mountManager;
64
-
65
-	/** @var IStorageFactory */
66
-	private $storageLoader;
67
-
68
-	/** @var IClientService */
69
-	private $clientService;
70
-
71
-	/** @var IManager */
72
-	private $notificationManager;
73
-
74
-	/** @var IDiscoveryService */
75
-	private $discoveryService;
76
-
77
-	/** @var ICloudFederationProviderManager */
78
-	private $cloudFederationProviderManager;
79
-
80
-	/** @var ICloudFederationFactory */
81
-	private $cloudFederationFactory;
82
-
83
-	/** @var IGroupManager  */
84
-	private $groupManager;
85
-
86
-	/** @var IUserManager */
87
-	private $userManager;
88
-
89
-	/** @var IEventDispatcher */
90
-	private $eventDispatcher;
91
-
92
-	public function __construct(IDBConnection $connection,
93
-								\OC\Files\Mount\Manager $mountManager,
94
-								IStorageFactory $storageLoader,
95
-								IClientService $clientService,
96
-								IManager $notificationManager,
97
-								IDiscoveryService $discoveryService,
98
-								ICloudFederationProviderManager $cloudFederationProviderManager,
99
-								ICloudFederationFactory $cloudFederationFactory,
100
-								IGroupManager $groupManager,
101
-								IUserManager $userManager,
102
-								?string $uid,
103
-								IEventDispatcher $eventDispatcher) {
104
-		$this->connection = $connection;
105
-		$this->mountManager = $mountManager;
106
-		$this->storageLoader = $storageLoader;
107
-		$this->clientService = $clientService;
108
-		$this->uid = $uid;
109
-		$this->notificationManager = $notificationManager;
110
-		$this->discoveryService = $discoveryService;
111
-		$this->cloudFederationProviderManager = $cloudFederationProviderManager;
112
-		$this->cloudFederationFactory = $cloudFederationFactory;
113
-		$this->groupManager = $groupManager;
114
-		$this->userManager = $userManager;
115
-		$this->eventDispatcher = $eventDispatcher;
116
-	}
117
-
118
-	/**
119
-	 * add new server-to-server share
120
-	 *
121
-	 * @param string $remote
122
-	 * @param string $token
123
-	 * @param string $password
124
-	 * @param string $name
125
-	 * @param string $owner
126
-	 * @param int $shareType
127
-	 * @param boolean $accepted
128
-	 * @param string $user
129
-	 * @param string $remoteId
130
-	 * @param int $parent
131
-	 * @return Mount|null
132
-	 * @throws \Doctrine\DBAL\DBALException
133
-	 */
134
-	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = '', $parent = -1) {
135
-		$user = $user ? $user : $this->uid;
136
-		$accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
-		$name = Filesystem::normalizePath('/' . $name);
138
-
139
-		if ($accepted !== IShare::STATUS_ACCEPTED) {
140
-			// To avoid conflicts with the mount point generation later,
141
-			// we only use a temporary mount point name here. The real
142
-			// mount point name will be generated when accepting the share,
143
-			// using the original share item name.
144
-			$tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
145
-			$mountPoint = $tmpMountPointName;
146
-			$hash = md5($tmpMountPointName);
147
-			$data = [
148
-				'remote' => $remote,
149
-				'share_token' => $token,
150
-				'password' => $password,
151
-				'name' => $name,
152
-				'owner' => $owner,
153
-				'user' => $user,
154
-				'mountpoint' => $mountPoint,
155
-				'mountpoint_hash' => $hash,
156
-				'accepted' => $accepted,
157
-				'remote_id' => $remoteId,
158
-				'share_type' => $shareType,
159
-			];
160
-
161
-			$i = 1;
162
-			while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163
-				// The external share already exists for the user
164
-				$data['mountpoint'] = $tmpMountPointName . '-' . $i;
165
-				$data['mountpoint_hash'] = md5($data['mountpoint']);
166
-				$i++;
167
-			}
168
-			return null;
169
-		}
170
-
171
-		$mountPoint = Files::buildNotExistingFileName('/', $name);
172
-		$mountPoint = Filesystem::normalizePath('/' . $mountPoint);
173
-		$hash = md5($mountPoint);
174
-
175
-		$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
176
-
177
-		$options = [
178
-			'remote' => $remote,
179
-			'token' => $token,
180
-			'password' => $password,
181
-			'mountpoint' => $mountPoint,
182
-			'owner' => $owner
183
-		];
184
-		return $this->mountShare($options);
185
-	}
186
-
187
-	/**
188
-	 * write remote share to the database
189
-	 *
190
-	 * @param $remote
191
-	 * @param $token
192
-	 * @param $password
193
-	 * @param $name
194
-	 * @param $owner
195
-	 * @param $user
196
-	 * @param $mountPoint
197
-	 * @param $hash
198
-	 * @param $accepted
199
-	 * @param $remoteId
200
-	 * @param $parent
201
-	 * @param $shareType
202
-	 * @return bool
203
-	 */
204
-	private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) {
205
-		$query = $this->connection->prepare('
54
+    public const STORAGE = '\OCA\Files_Sharing\External\Storage';
55
+
56
+    /** @var string|null */
57
+    private $uid;
58
+
59
+    /** @var IDBConnection */
60
+    private $connection;
61
+
62
+    /** @var \OC\Files\Mount\Manager */
63
+    private $mountManager;
64
+
65
+    /** @var IStorageFactory */
66
+    private $storageLoader;
67
+
68
+    /** @var IClientService */
69
+    private $clientService;
70
+
71
+    /** @var IManager */
72
+    private $notificationManager;
73
+
74
+    /** @var IDiscoveryService */
75
+    private $discoveryService;
76
+
77
+    /** @var ICloudFederationProviderManager */
78
+    private $cloudFederationProviderManager;
79
+
80
+    /** @var ICloudFederationFactory */
81
+    private $cloudFederationFactory;
82
+
83
+    /** @var IGroupManager  */
84
+    private $groupManager;
85
+
86
+    /** @var IUserManager */
87
+    private $userManager;
88
+
89
+    /** @var IEventDispatcher */
90
+    private $eventDispatcher;
91
+
92
+    public function __construct(IDBConnection $connection,
93
+                                \OC\Files\Mount\Manager $mountManager,
94
+                                IStorageFactory $storageLoader,
95
+                                IClientService $clientService,
96
+                                IManager $notificationManager,
97
+                                IDiscoveryService $discoveryService,
98
+                                ICloudFederationProviderManager $cloudFederationProviderManager,
99
+                                ICloudFederationFactory $cloudFederationFactory,
100
+                                IGroupManager $groupManager,
101
+                                IUserManager $userManager,
102
+                                ?string $uid,
103
+                                IEventDispatcher $eventDispatcher) {
104
+        $this->connection = $connection;
105
+        $this->mountManager = $mountManager;
106
+        $this->storageLoader = $storageLoader;
107
+        $this->clientService = $clientService;
108
+        $this->uid = $uid;
109
+        $this->notificationManager = $notificationManager;
110
+        $this->discoveryService = $discoveryService;
111
+        $this->cloudFederationProviderManager = $cloudFederationProviderManager;
112
+        $this->cloudFederationFactory = $cloudFederationFactory;
113
+        $this->groupManager = $groupManager;
114
+        $this->userManager = $userManager;
115
+        $this->eventDispatcher = $eventDispatcher;
116
+    }
117
+
118
+    /**
119
+     * add new server-to-server share
120
+     *
121
+     * @param string $remote
122
+     * @param string $token
123
+     * @param string $password
124
+     * @param string $name
125
+     * @param string $owner
126
+     * @param int $shareType
127
+     * @param boolean $accepted
128
+     * @param string $user
129
+     * @param string $remoteId
130
+     * @param int $parent
131
+     * @return Mount|null
132
+     * @throws \Doctrine\DBAL\DBALException
133
+     */
134
+    public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = '', $parent = -1) {
135
+        $user = $user ? $user : $this->uid;
136
+        $accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
+        $name = Filesystem::normalizePath('/' . $name);
138
+
139
+        if ($accepted !== IShare::STATUS_ACCEPTED) {
140
+            // To avoid conflicts with the mount point generation later,
141
+            // we only use a temporary mount point name here. The real
142
+            // mount point name will be generated when accepting the share,
143
+            // using the original share item name.
144
+            $tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
145
+            $mountPoint = $tmpMountPointName;
146
+            $hash = md5($tmpMountPointName);
147
+            $data = [
148
+                'remote' => $remote,
149
+                'share_token' => $token,
150
+                'password' => $password,
151
+                'name' => $name,
152
+                'owner' => $owner,
153
+                'user' => $user,
154
+                'mountpoint' => $mountPoint,
155
+                'mountpoint_hash' => $hash,
156
+                'accepted' => $accepted,
157
+                'remote_id' => $remoteId,
158
+                'share_type' => $shareType,
159
+            ];
160
+
161
+            $i = 1;
162
+            while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163
+                // The external share already exists for the user
164
+                $data['mountpoint'] = $tmpMountPointName . '-' . $i;
165
+                $data['mountpoint_hash'] = md5($data['mountpoint']);
166
+                $i++;
167
+            }
168
+            return null;
169
+        }
170
+
171
+        $mountPoint = Files::buildNotExistingFileName('/', $name);
172
+        $mountPoint = Filesystem::normalizePath('/' . $mountPoint);
173
+        $hash = md5($mountPoint);
174
+
175
+        $this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
176
+
177
+        $options = [
178
+            'remote' => $remote,
179
+            'token' => $token,
180
+            'password' => $password,
181
+            'mountpoint' => $mountPoint,
182
+            'owner' => $owner
183
+        ];
184
+        return $this->mountShare($options);
185
+    }
186
+
187
+    /**
188
+     * write remote share to the database
189
+     *
190
+     * @param $remote
191
+     * @param $token
192
+     * @param $password
193
+     * @param $name
194
+     * @param $owner
195
+     * @param $user
196
+     * @param $mountPoint
197
+     * @param $hash
198
+     * @param $accepted
199
+     * @param $remoteId
200
+     * @param $parent
201
+     * @param $shareType
202
+     * @return bool
203
+     */
204
+    private function writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType) {
205
+        $query = $this->connection->prepare('
206 206
 				INSERT INTO `*PREFIX*share_external`
207 207
 					(`remote`, `share_token`, `password`, `name`, `owner`, `user`, `mountpoint`, `mountpoint_hash`, `accepted`, `remote_id`, `parent`, `share_type`)
208 208
 				VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
209 209
 			');
210
-		return $query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]);
211
-	}
212
-
213
-	/**
214
-	 * get share
215
-	 *
216
-	 * @param int $id share id
217
-	 * @return mixed share of false
218
-	 */
219
-	public function getShare($id) {
220
-		$getShare = $this->connection->prepare('
210
+        return $query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]);
211
+    }
212
+
213
+    /**
214
+     * get share
215
+     *
216
+     * @param int $id share id
217
+     * @return mixed share of false
218
+     */
219
+    public function getShare($id) {
220
+        $getShare = $this->connection->prepare('
221 221
 			SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash`
222 222
 			FROM  `*PREFIX*share_external`
223 223
 			WHERE `id` = ?');
224
-		$result = $getShare->execute([$id]);
225
-
226
-		$share = $result ? $getShare->fetch() : [];
227
-
228
-		$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229
-
230
-		// check if the user is allowed to access it
231
-		if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232
-			return $share;
233
-		} elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
234
-			$user = $this->userManager->get($this->uid);
235
-			if ($this->groupManager->get($share['user'])->inGroup($user)) {
236
-				return $share;
237
-			}
238
-		}
239
-
240
-		return false;
241
-	}
242
-
243
-	/**
244
-	 * accept server-to-server share
245
-	 *
246
-	 * @param int $id
247
-	 * @return bool True if the share could be accepted, false otherwise
248
-	 */
249
-	public function acceptShare($id) {
250
-		$share = $this->getShare($id);
251
-		$result = false;
252
-
253
-		if ($share) {
254
-			\OC_Util::setupFS($this->uid);
255
-			$shareFolder = Helper::getShareFolder();
256
-			$mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']);
257
-			$mountPoint = Filesystem::normalizePath($mountPoint);
258
-			$hash = md5($mountPoint);
259
-			$userShareAccepted = false;
260
-
261
-			if ((int)$share['share_type'] === IShare::TYPE_USER) {
262
-				$acceptShare = $this->connection->prepare('
224
+        $result = $getShare->execute([$id]);
225
+
226
+        $share = $result ? $getShare->fetch() : [];
227
+
228
+        $validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229
+
230
+        // check if the user is allowed to access it
231
+        if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232
+            return $share;
233
+        } elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
234
+            $user = $this->userManager->get($this->uid);
235
+            if ($this->groupManager->get($share['user'])->inGroup($user)) {
236
+                return $share;
237
+            }
238
+        }
239
+
240
+        return false;
241
+    }
242
+
243
+    /**
244
+     * accept server-to-server share
245
+     *
246
+     * @param int $id
247
+     * @return bool True if the share could be accepted, false otherwise
248
+     */
249
+    public function acceptShare($id) {
250
+        $share = $this->getShare($id);
251
+        $result = false;
252
+
253
+        if ($share) {
254
+            \OC_Util::setupFS($this->uid);
255
+            $shareFolder = Helper::getShareFolder();
256
+            $mountPoint = Files::buildNotExistingFileName($shareFolder, $share['name']);
257
+            $mountPoint = Filesystem::normalizePath($mountPoint);
258
+            $hash = md5($mountPoint);
259
+            $userShareAccepted = false;
260
+
261
+            if ((int)$share['share_type'] === IShare::TYPE_USER) {
262
+                $acceptShare = $this->connection->prepare('
263 263
 				UPDATE `*PREFIX*share_external`
264 264
 				SET `accepted` = ?,
265 265
 					`mountpoint` = ?,
266 266
 					`mountpoint_hash` = ?
267 267
 				WHERE `id` = ? AND `user` = ?');
268
-				$userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]);
269
-			} else {
270
-				$result = $this->writeShareToDb(
271
-					$share['remote'],
272
-					$share['share_token'],
273
-					$share['password'],
274
-					$share['name'],
275
-					$share['owner'],
276
-					$this->uid,
277
-					$mountPoint, $hash, 1,
278
-					$share['remote_id'],
279
-					$id,
280
-					$share['share_type']);
281
-			}
282
-			if ($userShareAccepted === true) {
283
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
284
-				$event = new FederatedShareAddedEvent($share['remote']);
285
-				$this->eventDispatcher->dispatchTyped($event);
286
-				$result = true;
287
-			}
288
-		}
289
-
290
-		// Make sure the user has no notification for something that does not exist anymore.
291
-		$this->processNotification($id);
292
-
293
-		return $result;
294
-	}
295
-
296
-	/**
297
-	 * decline server-to-server share
298
-	 *
299
-	 * @param int $id
300
-	 * @return bool True if the share could be declined, false otherwise
301
-	 */
302
-	public function declineShare($id) {
303
-		$share = $this->getShare($id);
304
-		$result = false;
305
-
306
-		if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
307
-			$removeShare = $this->connection->prepare('
268
+                $userShareAccepted = $acceptShare->execute([1, $mountPoint, $hash, $id, $this->uid]);
269
+            } else {
270
+                $result = $this->writeShareToDb(
271
+                    $share['remote'],
272
+                    $share['share_token'],
273
+                    $share['password'],
274
+                    $share['name'],
275
+                    $share['owner'],
276
+                    $this->uid,
277
+                    $mountPoint, $hash, 1,
278
+                    $share['remote_id'],
279
+                    $id,
280
+                    $share['share_type']);
281
+            }
282
+            if ($userShareAccepted === true) {
283
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
284
+                $event = new FederatedShareAddedEvent($share['remote']);
285
+                $this->eventDispatcher->dispatchTyped($event);
286
+                $result = true;
287
+            }
288
+        }
289
+
290
+        // Make sure the user has no notification for something that does not exist anymore.
291
+        $this->processNotification($id);
292
+
293
+        return $result;
294
+    }
295
+
296
+    /**
297
+     * decline server-to-server share
298
+     *
299
+     * @param int $id
300
+     * @return bool True if the share could be declined, false otherwise
301
+     */
302
+    public function declineShare($id) {
303
+        $share = $this->getShare($id);
304
+        $result = false;
305
+
306
+        if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
307
+            $removeShare = $this->connection->prepare('
308 308
 				DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
309
-			$removeShare->execute([$id, $this->uid]);
310
-			$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
311
-
312
-			$this->processNotification($id);
313
-			$result = true;
314
-		} elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
315
-			$result = $this->writeShareToDb(
316
-				$share['remote'],
317
-				$share['share_token'],
318
-				$share['password'],
319
-				$share['name'],
320
-				$share['owner'],
321
-				$this->uid,
322
-				$share['mountpoint'],
323
-				$share['mountpoint_hash'],
324
-				0,
325
-				$share['remote_id'],
326
-				$id,
327
-				$share['share_type']);
328
-			$this->processNotification($id);
329
-		}
330
-
331
-		return $result;
332
-	}
333
-
334
-	/**
335
-	 * @param int $remoteShare
336
-	 */
337
-	public function processNotification($remoteShare) {
338
-		$filter = $this->notificationManager->createNotification();
339
-		$filter->setApp('files_sharing')
340
-			->setUser($this->uid)
341
-			->setObject('remote_share', (int) $remoteShare);
342
-		$this->notificationManager->markProcessed($filter);
343
-	}
344
-
345
-	/**
346
-	 * inform remote server whether server-to-server share was accepted/declined
347
-	 *
348
-	 * @param string $remote
349
-	 * @param string $token
350
-	 * @param string $remoteId Share id on the remote host
351
-	 * @param string $feedback
352
-	 * @return boolean
353
-	 */
354
-	private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
355
-		$result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
356
-
357
-		if ($result === true) {
358
-			return true;
359
-		}
360
-
361
-		$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362
-		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363
-
364
-		$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
365
-		$fields = ['token' => $token];
366
-
367
-		$client = $this->clientService->newClient();
368
-
369
-		try {
370
-			$response = $client->post(
371
-				$url,
372
-				[
373
-					'body' => $fields,
374
-					'connect_timeout' => 10,
375
-				]
376
-			);
377
-		} catch (\Exception $e) {
378
-			return false;
379
-		}
380
-
381
-		$status = json_decode($response->getBody(), true);
382
-
383
-		return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
384
-	}
385
-
386
-	/**
387
-	 * try send accept message to ocm end-point
388
-	 *
389
-	 * @param string $remoteDomain
390
-	 * @param string $token
391
-	 * @param string $remoteId id of the share
392
-	 * @param string $feedback
393
-	 * @return bool
394
-	 */
395
-	protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) {
396
-		switch ($feedback) {
397
-			case 'accept':
398
-				$notification = $this->cloudFederationFactory->getCloudFederationNotification();
399
-				$notification->setMessage(
400
-					'SHARE_ACCEPTED',
401
-					'file',
402
-					$remoteId,
403
-					[
404
-						'sharedSecret' => $token,
405
-						'message' => 'Recipient accept the share'
406
-					]
407
-
408
-				);
409
-				return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
410
-			case 'decline':
411
-				$notification = $this->cloudFederationFactory->getCloudFederationNotification();
412
-				$notification->setMessage(
413
-					'SHARE_DECLINED',
414
-					'file',
415
-					$remoteId,
416
-					[
417
-						'sharedSecret' => $token,
418
-						'message' => 'Recipient declined the share'
419
-					]
420
-
421
-				);
422
-				return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
423
-		}
424
-
425
-		return false;
426
-	}
427
-
428
-
429
-	/**
430
-	 * remove '/user/files' from the path and trailing slashes
431
-	 *
432
-	 * @param string $path
433
-	 * @return string
434
-	 */
435
-	protected function stripPath($path) {
436
-		$prefix = '/' . $this->uid . '/files';
437
-		return rtrim(substr($path, strlen($prefix)), '/');
438
-	}
439
-
440
-	public function getMount($data) {
441
-		$data['manager'] = $this;
442
-		$mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
443
-		$data['mountpoint'] = $mountPoint;
444
-		$data['certificateManager'] = \OC::$server->getCertificateManager();
445
-		return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
446
-	}
447
-
448
-	/**
449
-	 * @param array $data
450
-	 * @return Mount
451
-	 */
452
-	protected function mountShare($data) {
453
-		$mount = $this->getMount($data);
454
-		$this->mountManager->addMount($mount);
455
-		return $mount;
456
-	}
457
-
458
-	/**
459
-	 * @return \OC\Files\Mount\Manager
460
-	 */
461
-	public function getMountManager() {
462
-		return $this->mountManager;
463
-	}
464
-
465
-	/**
466
-	 * @param string $source
467
-	 * @param string $target
468
-	 * @return bool
469
-	 */
470
-	public function setMountPoint($source, $target) {
471
-		$source = $this->stripPath($source);
472
-		$target = $this->stripPath($target);
473
-		$sourceHash = md5($source);
474
-		$targetHash = md5($target);
475
-
476
-		$query = $this->connection->prepare('
309
+            $removeShare->execute([$id, $this->uid]);
310
+            $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
311
+
312
+            $this->processNotification($id);
313
+            $result = true;
314
+        } elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
315
+            $result = $this->writeShareToDb(
316
+                $share['remote'],
317
+                $share['share_token'],
318
+                $share['password'],
319
+                $share['name'],
320
+                $share['owner'],
321
+                $this->uid,
322
+                $share['mountpoint'],
323
+                $share['mountpoint_hash'],
324
+                0,
325
+                $share['remote_id'],
326
+                $id,
327
+                $share['share_type']);
328
+            $this->processNotification($id);
329
+        }
330
+
331
+        return $result;
332
+    }
333
+
334
+    /**
335
+     * @param int $remoteShare
336
+     */
337
+    public function processNotification($remoteShare) {
338
+        $filter = $this->notificationManager->createNotification();
339
+        $filter->setApp('files_sharing')
340
+            ->setUser($this->uid)
341
+            ->setObject('remote_share', (int) $remoteShare);
342
+        $this->notificationManager->markProcessed($filter);
343
+    }
344
+
345
+    /**
346
+     * inform remote server whether server-to-server share was accepted/declined
347
+     *
348
+     * @param string $remote
349
+     * @param string $token
350
+     * @param string $remoteId Share id on the remote host
351
+     * @param string $feedback
352
+     * @return boolean
353
+     */
354
+    private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
355
+        $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
356
+
357
+        if ($result === true) {
358
+            return true;
359
+        }
360
+
361
+        $federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362
+        $endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363
+
364
+        $url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
365
+        $fields = ['token' => $token];
366
+
367
+        $client = $this->clientService->newClient();
368
+
369
+        try {
370
+            $response = $client->post(
371
+                $url,
372
+                [
373
+                    'body' => $fields,
374
+                    'connect_timeout' => 10,
375
+                ]
376
+            );
377
+        } catch (\Exception $e) {
378
+            return false;
379
+        }
380
+
381
+        $status = json_decode($response->getBody(), true);
382
+
383
+        return ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
384
+    }
385
+
386
+    /**
387
+     * try send accept message to ocm end-point
388
+     *
389
+     * @param string $remoteDomain
390
+     * @param string $token
391
+     * @param string $remoteId id of the share
392
+     * @param string $feedback
393
+     * @return bool
394
+     */
395
+    protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) {
396
+        switch ($feedback) {
397
+            case 'accept':
398
+                $notification = $this->cloudFederationFactory->getCloudFederationNotification();
399
+                $notification->setMessage(
400
+                    'SHARE_ACCEPTED',
401
+                    'file',
402
+                    $remoteId,
403
+                    [
404
+                        'sharedSecret' => $token,
405
+                        'message' => 'Recipient accept the share'
406
+                    ]
407
+
408
+                );
409
+                return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
410
+            case 'decline':
411
+                $notification = $this->cloudFederationFactory->getCloudFederationNotification();
412
+                $notification->setMessage(
413
+                    'SHARE_DECLINED',
414
+                    'file',
415
+                    $remoteId,
416
+                    [
417
+                        'sharedSecret' => $token,
418
+                        'message' => 'Recipient declined the share'
419
+                    ]
420
+
421
+                );
422
+                return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
423
+        }
424
+
425
+        return false;
426
+    }
427
+
428
+
429
+    /**
430
+     * remove '/user/files' from the path and trailing slashes
431
+     *
432
+     * @param string $path
433
+     * @return string
434
+     */
435
+    protected function stripPath($path) {
436
+        $prefix = '/' . $this->uid . '/files';
437
+        return rtrim(substr($path, strlen($prefix)), '/');
438
+    }
439
+
440
+    public function getMount($data) {
441
+        $data['manager'] = $this;
442
+        $mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
443
+        $data['mountpoint'] = $mountPoint;
444
+        $data['certificateManager'] = \OC::$server->getCertificateManager();
445
+        return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
446
+    }
447
+
448
+    /**
449
+     * @param array $data
450
+     * @return Mount
451
+     */
452
+    protected function mountShare($data) {
453
+        $mount = $this->getMount($data);
454
+        $this->mountManager->addMount($mount);
455
+        return $mount;
456
+    }
457
+
458
+    /**
459
+     * @return \OC\Files\Mount\Manager
460
+     */
461
+    public function getMountManager() {
462
+        return $this->mountManager;
463
+    }
464
+
465
+    /**
466
+     * @param string $source
467
+     * @param string $target
468
+     * @return bool
469
+     */
470
+    public function setMountPoint($source, $target) {
471
+        $source = $this->stripPath($source);
472
+        $target = $this->stripPath($target);
473
+        $sourceHash = md5($source);
474
+        $targetHash = md5($target);
475
+
476
+        $query = $this->connection->prepare('
477 477
 			UPDATE `*PREFIX*share_external`
478 478
 			SET `mountpoint` = ?, `mountpoint_hash` = ?
479 479
 			WHERE `mountpoint_hash` = ?
480 480
 			AND `user` = ?
481 481
 		');
482
-		$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
482
+        $result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
483 483
 
484
-		return $result;
485
-	}
484
+        return $result;
485
+    }
486 486
 
487
-	public function removeShare($mountPoint) {
488
-		$mountPointObj = $this->mountManager->find($mountPoint);
489
-		$id = $mountPointObj->getStorage()->getCache()->getId('');
487
+    public function removeShare($mountPoint) {
488
+        $mountPointObj = $this->mountManager->find($mountPoint);
489
+        $id = $mountPointObj->getStorage()->getCache()->getId('');
490 490
 
491
-		$mountPoint = $this->stripPath($mountPoint);
492
-		$hash = md5($mountPoint);
491
+        $mountPoint = $this->stripPath($mountPoint);
492
+        $hash = md5($mountPoint);
493 493
 
494
-		$getShare = $this->connection->prepare('
494
+        $getShare = $this->connection->prepare('
495 495
 			SELECT `remote`, `share_token`, `remote_id`, `share_type`, `id`
496 496
 			FROM  `*PREFIX*share_external`
497 497
 			WHERE `mountpoint_hash` = ? AND `user` = ?');
498
-		$result = $getShare->execute([$hash, $this->uid]);
499
-
500
-		$share = $getShare->fetch();
501
-		$getShare->closeCursor();
502
-		if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
503
-			try {
504
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505
-			} catch (\Throwable $e) {
506
-				// if we fail to notify the remote (probably cause the remote is down)
507
-				// we still want the share to be gone to prevent undeletable remotes
508
-			}
509
-
510
-			$query = $this->connection->prepare('
498
+        $result = $getShare->execute([$hash, $this->uid]);
499
+
500
+        $share = $getShare->fetch();
501
+        $getShare->closeCursor();
502
+        if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
503
+            try {
504
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505
+            } catch (\Throwable $e) {
506
+                // if we fail to notify the remote (probably cause the remote is down)
507
+                // we still want the share to be gone to prevent undeletable remotes
508
+            }
509
+
510
+            $query = $this->connection->prepare('
511 511
 			DELETE FROM `*PREFIX*share_external`
512 512
 			WHERE `id` = ?
513 513
 			');
514
-			$result = (bool)$query->execute([(int)$share['id']]);
515
-		} elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
516
-			$query = $this->connection->prepare('
514
+            $result = (bool)$query->execute([(int)$share['id']]);
515
+        } elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
516
+            $query = $this->connection->prepare('
517 517
 				UPDATE `*PREFIX*share_external`
518 518
 				SET `accepted` = ?
519 519
 				WHERE `id` = ?');
520
-			$result = (bool)$query->execute([0, (int)$share['id']]);
521
-		}
522
-
523
-		if ($result) {
524
-			$this->removeReShares($id);
525
-		}
526
-
527
-		return $result;
528
-	}
529
-
530
-	/**
531
-	 * remove re-shares from share table and mapping in the federated_reshares table
532
-	 *
533
-	 * @param $mountPointId
534
-	 */
535
-	protected function removeReShares($mountPointId) {
536
-		$selectQuery = $this->connection->getQueryBuilder();
537
-		$query = $this->connection->getQueryBuilder();
538
-		$selectQuery->select('id')->from('share')
539
-			->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId)));
540
-		$select = $selectQuery->getSQL();
541
-
542
-
543
-		$query->delete('federated_reshares')
544
-			->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
545
-		$query->execute();
546
-
547
-		$deleteReShares = $this->connection->getQueryBuilder();
548
-		$deleteReShares->delete('share')
549
-			->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId)));
550
-		$deleteReShares->execute();
551
-	}
552
-
553
-	/**
554
-	 * remove all shares for user $uid if the user was deleted
555
-	 *
556
-	 * @param string $uid
557
-	 * @return bool
558
-	 */
559
-	public function removeUserShares($uid) {
560
-		$getShare = $this->connection->prepare('
520
+            $result = (bool)$query->execute([0, (int)$share['id']]);
521
+        }
522
+
523
+        if ($result) {
524
+            $this->removeReShares($id);
525
+        }
526
+
527
+        return $result;
528
+    }
529
+
530
+    /**
531
+     * remove re-shares from share table and mapping in the federated_reshares table
532
+     *
533
+     * @param $mountPointId
534
+     */
535
+    protected function removeReShares($mountPointId) {
536
+        $selectQuery = $this->connection->getQueryBuilder();
537
+        $query = $this->connection->getQueryBuilder();
538
+        $selectQuery->select('id')->from('share')
539
+            ->where($selectQuery->expr()->eq('file_source', $query->createNamedParameter($mountPointId)));
540
+        $select = $selectQuery->getSQL();
541
+
542
+
543
+        $query->delete('federated_reshares')
544
+            ->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
545
+        $query->execute();
546
+
547
+        $deleteReShares = $this->connection->getQueryBuilder();
548
+        $deleteReShares->delete('share')
549
+            ->where($deleteReShares->expr()->eq('file_source', $deleteReShares->createNamedParameter($mountPointId)));
550
+        $deleteReShares->execute();
551
+    }
552
+
553
+    /**
554
+     * remove all shares for user $uid if the user was deleted
555
+     *
556
+     * @param string $uid
557
+     * @return bool
558
+     */
559
+    public function removeUserShares($uid) {
560
+        $getShare = $this->connection->prepare('
561 561
 			SELECT `remote`, `share_token`, `remote_id`
562 562
 			FROM  `*PREFIX*share_external`
563 563
 			WHERE `user` = ?');
564
-		$result = $getShare->execute([$uid]);
564
+        $result = $getShare->execute([$uid]);
565 565
 
566
-		if ($result) {
567
-			$shares = $getShare->fetchAll();
568
-			foreach ($shares as $share) {
569
-				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
570
-			}
571
-		}
566
+        if ($result) {
567
+            $shares = $getShare->fetchAll();
568
+            foreach ($shares as $share) {
569
+                $this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
570
+            }
571
+        }
572 572
 
573
-		$query = $this->connection->prepare('
573
+        $query = $this->connection->prepare('
574 574
 			DELETE FROM `*PREFIX*share_external`
575 575
 			WHERE `user` = ?
576 576
 		');
577
-		return (bool)$query->execute([$uid]);
578
-	}
579
-
580
-	/**
581
-	 * return a list of shares which are not yet accepted by the user
582
-	 *
583
-	 * @return array list of open server-to-server shares
584
-	 */
585
-	public function getOpenShares() {
586
-		return $this->getShares(false);
587
-	}
588
-
589
-	/**
590
-	 * return a list of shares which are accepted by the user
591
-	 *
592
-	 * @return array list of accepted server-to-server shares
593
-	 */
594
-	public function getAcceptedShares() {
595
-		return $this->getShares(true);
596
-	}
597
-
598
-	/**
599
-	 * return a list of shares for the user
600
-	 *
601
-	 * @param bool|null $accepted True for accepted only,
602
-	 *                            false for not accepted,
603
-	 *                            null for all shares of the user
604
-	 * @return array list of open server-to-server shares
605
-	 */
606
-	private function getShares($accepted) {
607
-		$user = $this->userManager->get($this->uid);
608
-		$groups = $this->groupManager->getUserGroups($user);
609
-		$userGroups = [];
610
-		foreach ($groups as $group) {
611
-			$userGroups[] = $group->getGID();
612
-		}
613
-
614
-		$query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
577
+        return (bool)$query->execute([$uid]);
578
+    }
579
+
580
+    /**
581
+     * return a list of shares which are not yet accepted by the user
582
+     *
583
+     * @return array list of open server-to-server shares
584
+     */
585
+    public function getOpenShares() {
586
+        return $this->getShares(false);
587
+    }
588
+
589
+    /**
590
+     * return a list of shares which are accepted by the user
591
+     *
592
+     * @return array list of accepted server-to-server shares
593
+     */
594
+    public function getAcceptedShares() {
595
+        return $this->getShares(true);
596
+    }
597
+
598
+    /**
599
+     * return a list of shares for the user
600
+     *
601
+     * @param bool|null $accepted True for accepted only,
602
+     *                            false for not accepted,
603
+     *                            null for all shares of the user
604
+     * @return array list of open server-to-server shares
605
+     */
606
+    private function getShares($accepted) {
607
+        $user = $this->userManager->get($this->uid);
608
+        $groups = $this->groupManager->getUserGroups($user);
609
+        $userGroups = [];
610
+        foreach ($groups as $group) {
611
+            $userGroups[] = $group->getGID();
612
+        }
613
+
614
+        $query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
615 615
 		          FROM `*PREFIX*share_external`
616 616
 				  WHERE (`user` = ? OR `user` IN (?))';
617
-		$parameters = [$this->uid, implode(',',$userGroups)];
618
-		if (!is_null($accepted)) {
619
-			$query .= ' AND `accepted` = ?';
620
-			$parameters[] = (int) $accepted;
621
-		}
622
-		$query .= ' ORDER BY `id` ASC';
623
-
624
-		$shares = $this->connection->prepare($query);
625
-		$result = $shares->execute($parameters);
626
-
627
-		return $result ? $shares->fetchAll() : [];
628
-	}
617
+        $parameters = [$this->uid, implode(',',$userGroups)];
618
+        if (!is_null($accepted)) {
619
+            $query .= ' AND `accepted` = ?';
620
+            $parameters[] = (int) $accepted;
621
+        }
622
+        $query .= ' ORDER BY `id` ASC';
623
+
624
+        $shares = $this->connection->prepare($query);
625
+        $result = $shares->execute($parameters);
626
+
627
+        return $result ? $shares->fetchAll() : [];
628
+    }
629 629
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
 	public function addShare($remote, $token, $password, $name, $owner, $shareType, $accepted = false, $user = null, $remoteId = '', $parent = -1) {
135 135
 		$user = $user ? $user : $this->uid;
136 136
 		$accepted = $accepted ? IShare::STATUS_ACCEPTED : IShare::STATUS_PENDING;
137
-		$name = Filesystem::normalizePath('/' . $name);
137
+		$name = Filesystem::normalizePath('/'.$name);
138 138
 
139 139
 		if ($accepted !== IShare::STATUS_ACCEPTED) {
140 140
 			// To avoid conflicts with the mount point generation later,
141 141
 			// we only use a temporary mount point name here. The real
142 142
 			// mount point name will be generated when accepting the share,
143 143
 			// using the original share item name.
144
-			$tmpMountPointName = '{{TemporaryMountPointName#' . $name . '}}';
144
+			$tmpMountPointName = '{{TemporaryMountPointName#'.$name.'}}';
145 145
 			$mountPoint = $tmpMountPointName;
146 146
 			$hash = md5($tmpMountPointName);
147 147
 			$data = [
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 			$i = 1;
162 162
 			while (!$this->connection->insertIfNotExist('*PREFIX*share_external', $data, ['user', 'mountpoint_hash'])) {
163 163
 				// The external share already exists for the user
164
-				$data['mountpoint'] = $tmpMountPointName . '-' . $i;
164
+				$data['mountpoint'] = $tmpMountPointName.'-'.$i;
165 165
 				$data['mountpoint_hash'] = md5($data['mountpoint']);
166 166
 				$i++;
167 167
 			}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		}
170 170
 
171 171
 		$mountPoint = Files::buildNotExistingFileName('/', $name);
172
-		$mountPoint = Filesystem::normalizePath('/' . $mountPoint);
172
+		$mountPoint = Filesystem::normalizePath('/'.$mountPoint);
173 173
 		$hash = md5($mountPoint);
174 174
 
175 175
 		$this->writeShareToDb($remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType);
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 		$validShare = is_array($share) && isset($share['share_type']) && isset($share['user']);
229 229
 
230 230
 		// check if the user is allowed to access it
231
-		if ($validShare && (int)$share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
231
+		if ($validShare && (int) $share['share_type'] === IShare::TYPE_USER && $share['user'] === $this->uid) {
232 232
 			return $share;
233
-		} elseif ($validShare && (int)$share['share_type'] === IShare::TYPE_GROUP) {
233
+		} elseif ($validShare && (int) $share['share_type'] === IShare::TYPE_GROUP) {
234 234
 			$user = $this->userManager->get($this->uid);
235 235
 			if ($this->groupManager->get($share['user'])->inGroup($user)) {
236 236
 				return $share;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			$hash = md5($mountPoint);
259 259
 			$userShareAccepted = false;
260 260
 
261
-			if ((int)$share['share_type'] === IShare::TYPE_USER) {
261
+			if ((int) $share['share_type'] === IShare::TYPE_USER) {
262 262
 				$acceptShare = $this->connection->prepare('
263 263
 				UPDATE `*PREFIX*share_external`
264 264
 				SET `accepted` = ?,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 		$share = $this->getShare($id);
304 304
 		$result = false;
305 305
 
306
-		if ($share && (int)$share['share_type'] === IShare::TYPE_USER) {
306
+		if ($share && (int) $share['share_type'] === IShare::TYPE_USER) {
307 307
 			$removeShare = $this->connection->prepare('
308 308
 				DELETE FROM `*PREFIX*share_external` WHERE `id` = ? AND `user` = ?');
309 309
 			$removeShare->execute([$id, $this->uid]);
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 
312 312
 			$this->processNotification($id);
313 313
 			$result = true;
314
-		} elseif ($share && (int)$share['share_type'] === IShare::TYPE_GROUP) {
314
+		} elseif ($share && (int) $share['share_type'] === IShare::TYPE_GROUP) {
315 315
 			$result = $this->writeShareToDb(
316 316
 				$share['remote'],
317 317
 				$share['share_token'],
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 		$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
362 362
 		$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
363 363
 
364
-		$url = rtrim($remote, '/') . $endpoint . '/' . $remoteId . '/' . $feedback . '?format=' . Share::RESPONSE_FORMAT;
364
+		$url = rtrim($remote, '/').$endpoint.'/'.$remoteId.'/'.$feedback.'?format='.Share::RESPONSE_FORMAT;
365 365
 		$fields = ['token' => $token];
366 366
 
367 367
 		$client = $this->clientService->newClient();
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
 	 * @return string
434 434
 	 */
435 435
 	protected function stripPath($path) {
436
-		$prefix = '/' . $this->uid . '/files';
436
+		$prefix = '/'.$this->uid.'/files';
437 437
 		return rtrim(substr($path, strlen($prefix)), '/');
438 438
 	}
439 439
 
440 440
 	public function getMount($data) {
441 441
 		$data['manager'] = $this;
442
-		$mountPoint = '/' . $this->uid . '/files' . $data['mountpoint'];
442
+		$mountPoint = '/'.$this->uid.'/files'.$data['mountpoint'];
443 443
 		$data['mountpoint'] = $mountPoint;
444 444
 		$data['certificateManager'] = \OC::$server->getCertificateManager();
445 445
 		return new Mount(self::STORAGE, $mountPoint, $data, $this, $this->storageLoader);
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 			WHERE `mountpoint_hash` = ?
480 480
 			AND `user` = ?
481 481
 		');
482
-		$result = (bool)$query->execute([$target, $targetHash, $sourceHash, $this->uid]);
482
+		$result = (bool) $query->execute([$target, $targetHash, $sourceHash, $this->uid]);
483 483
 
484 484
 		return $result;
485 485
 	}
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
 		$share = $getShare->fetch();
501 501
 		$getShare->closeCursor();
502
-		if ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_USER) {
502
+		if ($result && $share !== false && (int) $share['share_type'] === IShare::TYPE_USER) {
503 503
 			try {
504 504
 				$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
505 505
 			} catch (\Throwable $e) {
@@ -511,13 +511,13 @@  discard block
 block discarded – undo
511 511
 			DELETE FROM `*PREFIX*share_external`
512 512
 			WHERE `id` = ?
513 513
 			');
514
-			$result = (bool)$query->execute([(int)$share['id']]);
515
-		} elseif ($result && $share !== false && (int)$share['share_type'] === IShare::TYPE_GROUP) {
514
+			$result = (bool) $query->execute([(int) $share['id']]);
515
+		} elseif ($result && $share !== false && (int) $share['share_type'] === IShare::TYPE_GROUP) {
516 516
 			$query = $this->connection->prepare('
517 517
 				UPDATE `*PREFIX*share_external`
518 518
 				SET `accepted` = ?
519 519
 				WHERE `id` = ?');
520
-			$result = (bool)$query->execute([0, (int)$share['id']]);
520
+			$result = (bool) $query->execute([0, (int) $share['id']]);
521 521
 		}
522 522
 
523 523
 		if ($result) {
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 
542 542
 
543 543
 		$query->delete('federated_reshares')
544
-			->where($query->expr()->in('share_id', $query->createFunction('(' . $select . ')')));
544
+			->where($query->expr()->in('share_id', $query->createFunction('('.$select.')')));
545 545
 		$query->execute();
546 546
 
547 547
 		$deleteReShares = $this->connection->getQueryBuilder();
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 			DELETE FROM `*PREFIX*share_external`
575 575
 			WHERE `user` = ?
576 576
 		');
577
-		return (bool)$query->execute([$uid]);
577
+		return (bool) $query->execute([$uid]);
578 578
 	}
579 579
 
580 580
 	/**
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 		$query = 'SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`
615 615
 		          FROM `*PREFIX*share_external`
616 616
 				  WHERE (`user` = ? OR `user` IN (?))';
617
-		$parameters = [$this->uid, implode(',',$userGroups)];
617
+		$parameters = [$this->uid, implode(',', $userGroups)];
618 618
 		if (!is_null($accepted)) {
619 619
 			$query .= ' AND `accepted` = ?';
620 620
 			$parameters[] = (int) $accepted;
Please login to merge, or discard this patch.
apps/files_sharing/lib/Migration/Version11300Date20201120141438.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -37,95 +37,95 @@
 block discarded – undo
37 37
 
38 38
 class Version11300Date20201120141438 extends SimpleMigrationStep {
39 39
 
40
-	/** @var IDBConnection */
41
-	private $connection;
40
+    /** @var IDBConnection */
41
+    private $connection;
42 42
 
43
-	public function __construct(IDBConnection $connection) {
44
-		$this->connection = $connection;
45
-	}
43
+    public function __construct(IDBConnection $connection) {
44
+        $this->connection = $connection;
45
+    }
46 46
 
47
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
48
-		/** @var ISchemaWrapper $schema */
49
-		$schema = $schemaClosure();
47
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
48
+        /** @var ISchemaWrapper $schema */
49
+        $schema = $schemaClosure();
50 50
 
51
-		if (!$schema->hasTable('share_external')) {
52
-			$table = $schema->createTable('share_external');
53
-			$table->addColumn('id', Types::BIGINT, [
54
-				'autoincrement' => true,
55
-				'notnull' => true,
56
-			]);
57
-			$table->addColumn('parent', Types::BIGINT, [
58
-				'notnull' => false,
59
-				'default' => -1,
60
-			]);
61
-			$table->addColumn('share_type', Types::INTEGER, [
62
-				'notnull' => false,
63
-				'length' => 4,
64
-			]);
65
-			$table->addColumn('remote', Types::STRING, [
66
-				'notnull' => true,
67
-				'length' => 512,
68
-			]);
69
-			$table->addColumn('remote_id', Types::STRING, [
70
-				'notnull' => false,
71
-				'length' => 255,
72
-				'default' => '',
73
-			]);
74
-			$table->addColumn('share_token', Types::STRING, [
75
-				'notnull' => true,
76
-				'length' => 64,
77
-			]);
78
-			$table->addColumn('password', Types::STRING, [
79
-				'notnull' => false,
80
-				'length' => 64,
81
-			]);
82
-			$table->addColumn('name', Types::STRING, [
83
-				'notnull' => true,
84
-				'length' => 64,
85
-			]);
86
-			$table->addColumn('owner', Types::STRING, [
87
-				'notnull' => true,
88
-				'length' => 64,
89
-			]);
90
-			$table->addColumn('user', Types::STRING, [
91
-				'notnull' => true,
92
-				'length' => 64,
93
-			]);
94
-			$table->addColumn('mountpoint', Types::STRING, [
95
-				'notnull' => true,
96
-				'length' => 4000,
97
-			]);
98
-			$table->addColumn('mountpoint_hash', Types::STRING, [
99
-				'notnull' => true,
100
-				'length' => 32,
101
-			]);
102
-			$table->addColumn('accepted', Types::INTEGER, [
103
-				'notnull' => true,
104
-				'length' => 4,
105
-				'default' => 0,
106
-			]);
107
-			$table->setPrimaryKey(['id']);
108
-			$table->addIndex(['user'], 'sh_external_user');
109
-			$table->addUniqueIndex(['user', 'mountpoint_hash'], 'sh_external_mp');
110
-		} else {
111
-			$table = $schema->getTable('share_external');
112
-			$remoteIdColumn = $table->getColumn('remote_id');
113
-			if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
114
-				$remoteIdColumn->setNotnull(false);
115
-				$remoteIdColumn->setType(Type::getType(Types::STRING));
116
-				$remoteIdColumn->setOptions(['length' => 255]);
117
-				$remoteIdColumn->setDefault('');
118
-			}
119
-		}
51
+        if (!$schema->hasTable('share_external')) {
52
+            $table = $schema->createTable('share_external');
53
+            $table->addColumn('id', Types::BIGINT, [
54
+                'autoincrement' => true,
55
+                'notnull' => true,
56
+            ]);
57
+            $table->addColumn('parent', Types::BIGINT, [
58
+                'notnull' => false,
59
+                'default' => -1,
60
+            ]);
61
+            $table->addColumn('share_type', Types::INTEGER, [
62
+                'notnull' => false,
63
+                'length' => 4,
64
+            ]);
65
+            $table->addColumn('remote', Types::STRING, [
66
+                'notnull' => true,
67
+                'length' => 512,
68
+            ]);
69
+            $table->addColumn('remote_id', Types::STRING, [
70
+                'notnull' => false,
71
+                'length' => 255,
72
+                'default' => '',
73
+            ]);
74
+            $table->addColumn('share_token', Types::STRING, [
75
+                'notnull' => true,
76
+                'length' => 64,
77
+            ]);
78
+            $table->addColumn('password', Types::STRING, [
79
+                'notnull' => false,
80
+                'length' => 64,
81
+            ]);
82
+            $table->addColumn('name', Types::STRING, [
83
+                'notnull' => true,
84
+                'length' => 64,
85
+            ]);
86
+            $table->addColumn('owner', Types::STRING, [
87
+                'notnull' => true,
88
+                'length' => 64,
89
+            ]);
90
+            $table->addColumn('user', Types::STRING, [
91
+                'notnull' => true,
92
+                'length' => 64,
93
+            ]);
94
+            $table->addColumn('mountpoint', Types::STRING, [
95
+                'notnull' => true,
96
+                'length' => 4000,
97
+            ]);
98
+            $table->addColumn('mountpoint_hash', Types::STRING, [
99
+                'notnull' => true,
100
+                'length' => 32,
101
+            ]);
102
+            $table->addColumn('accepted', Types::INTEGER, [
103
+                'notnull' => true,
104
+                'length' => 4,
105
+                'default' => 0,
106
+            ]);
107
+            $table->setPrimaryKey(['id']);
108
+            $table->addIndex(['user'], 'sh_external_user');
109
+            $table->addUniqueIndex(['user', 'mountpoint_hash'], 'sh_external_mp');
110
+        } else {
111
+            $table = $schema->getTable('share_external');
112
+            $remoteIdColumn = $table->getColumn('remote_id');
113
+            if ($remoteIdColumn && $remoteIdColumn->getType()->getName() !== Types::STRING) {
114
+                $remoteIdColumn->setNotnull(false);
115
+                $remoteIdColumn->setType(Type::getType(Types::STRING));
116
+                $remoteIdColumn->setOptions(['length' => 255]);
117
+                $remoteIdColumn->setDefault('');
118
+            }
119
+        }
120 120
 
121
-		return $schema;
122
-	}
121
+        return $schema;
122
+    }
123 123
 
124
-	public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
125
-		$qb = $this->connection->getQueryBuilder();
126
-		$qb->update('share_external')
127
-			->set('remote_id', $qb->createNamedParameter(''))
128
-			->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
129
-		$qb->execute();
130
-	}
124
+    public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options) {
125
+        $qb = $this->connection->getQueryBuilder();
126
+        $qb->update('share_external')
127
+            ->set('remote_id', $qb->createNamedParameter(''))
128
+            ->where($qb->expr()->eq('remote_id', $qb->createNamedParameter('-1')));
129
+        $qb->execute();
130
+    }
131 131
 }
Please login to merge, or discard this patch.
apps/files_sharing/lib/AppInfo/Application.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -63,179 +63,179 @@
 block discarded – undo
63 63
 use Symfony\Component\EventDispatcher\GenericEvent;
64 64
 
65 65
 class Application extends App {
66
-	public const APP_ID = 'files_sharing';
67
-
68
-	public function __construct(array $urlParams = []) {
69
-		parent::__construct(self::APP_ID, $urlParams);
70
-
71
-		$container = $this->getContainer();
72
-
73
-		/** @var IServerContainer $server */
74
-		$server = $container->getServer();
75
-
76
-		/** @var IEventDispatcher $dispatcher */
77
-		$dispatcher = $container->query(IEventDispatcher::class);
78
-		$oldDispatcher = $container->getServer()->getEventDispatcher();
79
-		$mountProviderCollection = $server->getMountProviderCollection();
80
-		$notifications = $server->getNotificationManager();
81
-
82
-		/**
83
-		 * Core class wrappers
84
-		 */
85
-		$container->registerService(Manager::class, function (SimpleContainer $c) use ($server) {
86
-			$user = $server->getUserSession()->getUser();
87
-			$uid = $user ? $user->getUID() : null;
88
-			return new \OCA\Files_Sharing\External\Manager(
89
-				$server->getDatabaseConnection(),
90
-				\OC\Files\Filesystem::getMountManager(),
91
-				\OC\Files\Filesystem::getLoader(),
92
-				$server->getHTTPClientService(),
93
-				$server->getNotificationManager(),
94
-				$server->query(\OCP\OCS\IDiscoveryService::class),
95
-				$server->getCloudFederationProviderManager(),
96
-				$server->getCloudFederationFactory(),
97
-				$server->getGroupManager(),
98
-				$server->getUserManager(),
99
-				$uid,
100
-				$server->query(IEventDispatcher::class)
101
-			);
102
-		});
103
-
104
-		/**
105
-		 * Middleware
106
-		 */
107
-		$container->registerMiddleWare(SharingCheckMiddleware::class);
108
-		$container->registerMiddleWare(OCSShareAPIMiddleware::class);
109
-		$container->registerMiddleWare(ShareInfoMiddleware::class);
110
-
111
-		$container->registerService('ExternalMountProvider', function (ContainerInterface $c) {
112
-			return new \OCA\Files_Sharing\External\MountProvider(
113
-				$c->get(IDBConnection::class),
114
-				function () use ($c) {
115
-					return $c->get(Manager::class);
116
-				},
117
-				$c->get(ICloudIdManager::class)
118
-			);
119
-		});
120
-
121
-		/**
122
-		 * Register capabilities
123
-		 */
124
-		$container->registerCapability(Capabilities::class);
125
-
126
-		$notifications->registerNotifierService(Notifier::class);
127
-
128
-		$this->registerMountProviders($mountProviderCollection);
129
-		$this->registerEventsScripts($dispatcher, $oldDispatcher);
130
-		$this->setupSharingMenus();
131
-
132
-		/**
133
-		 * Always add main sharing script
134
-		 */
135
-		Util::addScript(self::APP_ID, 'dist/main');
136
-	}
137
-
138
-	protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) {
139
-		$mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class));
140
-		$mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
141
-	}
142
-
143
-	protected function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher) {
144
-		// sidebar and files scripts
145
-		$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
146
-		$dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
147
-		$dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
148
-		$dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
149
-		$dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
150
-			\OCP\Util::addScript('files_sharing', 'dist/collaboration');
151
-		});
152
-		$dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
153
-		$dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
154
-
155
-		// notifications api to accept incoming user shares
156
-		$oldDispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) {
157
-			/** @var Listener $listener */
158
-			$listener = $this->getContainer()->query(Listener::class);
159
-			$listener->shareNotification($event);
160
-		});
161
-		$oldDispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) {
162
-			/** @var Listener $listener */
163
-			$listener = $this->getContainer()->query(Listener::class);
164
-			$listener->userAddedToGroup($event);
165
-		});
166
-	}
167
-
168
-	protected function setupSharingMenus() {
169
-		$config = \OC::$server->getConfig();
170
-
171
-		if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes' || !class_exists('\OCA\Files\App')) {
172
-			return;
173
-		}
174
-
175
-		// show_Quick_Access stored as string
176
-		\OCA\Files\App::getNavigationManager()->add(function () {
177
-			$config = \OC::$server->getConfig();
178
-			$l = \OC::$server->getL10N('files_sharing');
179
-
180
-			$sharingSublistArray = [];
181
-
182
-			if (\OCP\Util::isSharingDisabledForUser() === false) {
183
-				$sharingSublistArray[] = [
184
-					'id' => 'sharingout',
185
-					'appname' => 'files_sharing',
186
-					'script' => 'list.php',
187
-					'order' => 16,
188
-					'name' => $l->t('Shared with others'),
189
-				];
190
-			}
191
-
192
-			$sharingSublistArray[] = [
193
-				'id' => 'sharingin',
194
-				'appname' => 'files_sharing',
195
-				'script' => 'list.php',
196
-				'order' => 15,
197
-				'name' => $l->t('Shared with you'),
198
-			];
199
-
200
-			if (\OCP\Util::isSharingDisabledForUser() === false) {
201
-				// Check if sharing by link is enabled
202
-				if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
203
-					$sharingSublistArray[] = [
204
-						'id' => 'sharinglinks',
205
-						'appname' => 'files_sharing',
206
-						'script' => 'list.php',
207
-						'order' => 17,
208
-						'name' => $l->t('Shared by link'),
209
-					];
210
-				}
211
-			}
212
-
213
-			$sharingSublistArray[] = [
214
-				'id' => 'deletedshares',
215
-				'appname' => 'files_sharing',
216
-				'script' => 'list.php',
217
-				'order' => 19,
218
-				'name' => $l->t('Deleted shares'),
219
-			];
220
-
221
-			$sharingSublistArray[] = [
222
-				'id' => 'pendingshares',
223
-				'appname' => 'files_sharing',
224
-				'script' => 'list.php',
225
-				'order' => 19,
226
-				'name' => $l->t('Pending shares'),
227
-			];
228
-
229
-			return [
230
-				'id' => 'shareoverview',
231
-				'appname' => 'files_sharing',
232
-				'script' => 'list.php',
233
-				'order' => 18,
234
-				'name' => $l->t('Shares'),
235
-				'classes' => 'collapsible',
236
-				'sublist' => $sharingSublistArray,
237
-				'expandedState' => 'show_sharing_menu'
238
-			];
239
-		});
240
-	}
66
+    public const APP_ID = 'files_sharing';
67
+
68
+    public function __construct(array $urlParams = []) {
69
+        parent::__construct(self::APP_ID, $urlParams);
70
+
71
+        $container = $this->getContainer();
72
+
73
+        /** @var IServerContainer $server */
74
+        $server = $container->getServer();
75
+
76
+        /** @var IEventDispatcher $dispatcher */
77
+        $dispatcher = $container->query(IEventDispatcher::class);
78
+        $oldDispatcher = $container->getServer()->getEventDispatcher();
79
+        $mountProviderCollection = $server->getMountProviderCollection();
80
+        $notifications = $server->getNotificationManager();
81
+
82
+        /**
83
+         * Core class wrappers
84
+         */
85
+        $container->registerService(Manager::class, function (SimpleContainer $c) use ($server) {
86
+            $user = $server->getUserSession()->getUser();
87
+            $uid = $user ? $user->getUID() : null;
88
+            return new \OCA\Files_Sharing\External\Manager(
89
+                $server->getDatabaseConnection(),
90
+                \OC\Files\Filesystem::getMountManager(),
91
+                \OC\Files\Filesystem::getLoader(),
92
+                $server->getHTTPClientService(),
93
+                $server->getNotificationManager(),
94
+                $server->query(\OCP\OCS\IDiscoveryService::class),
95
+                $server->getCloudFederationProviderManager(),
96
+                $server->getCloudFederationFactory(),
97
+                $server->getGroupManager(),
98
+                $server->getUserManager(),
99
+                $uid,
100
+                $server->query(IEventDispatcher::class)
101
+            );
102
+        });
103
+
104
+        /**
105
+         * Middleware
106
+         */
107
+        $container->registerMiddleWare(SharingCheckMiddleware::class);
108
+        $container->registerMiddleWare(OCSShareAPIMiddleware::class);
109
+        $container->registerMiddleWare(ShareInfoMiddleware::class);
110
+
111
+        $container->registerService('ExternalMountProvider', function (ContainerInterface $c) {
112
+            return new \OCA\Files_Sharing\External\MountProvider(
113
+                $c->get(IDBConnection::class),
114
+                function () use ($c) {
115
+                    return $c->get(Manager::class);
116
+                },
117
+                $c->get(ICloudIdManager::class)
118
+            );
119
+        });
120
+
121
+        /**
122
+         * Register capabilities
123
+         */
124
+        $container->registerCapability(Capabilities::class);
125
+
126
+        $notifications->registerNotifierService(Notifier::class);
127
+
128
+        $this->registerMountProviders($mountProviderCollection);
129
+        $this->registerEventsScripts($dispatcher, $oldDispatcher);
130
+        $this->setupSharingMenus();
131
+
132
+        /**
133
+         * Always add main sharing script
134
+         */
135
+        Util::addScript(self::APP_ID, 'dist/main');
136
+    }
137
+
138
+    protected function registerMountProviders(IMountProviderCollection $mountProviderCollection) {
139
+        $mountProviderCollection->registerProvider($this->getContainer()->query(MountProvider::class));
140
+        $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider'));
141
+    }
142
+
143
+    protected function registerEventsScripts(IEventDispatcher $dispatcher, EventDispatcherInterface $oldDispatcher) {
144
+        // sidebar and files scripts
145
+        $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class);
146
+        $dispatcher->addServiceListener(BeforeTemplateRenderedEvent::class, LegacyBeforeTemplateRenderedListener::class);
147
+        $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
148
+        $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class);
149
+        $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
150
+            \OCP\Util::addScript('files_sharing', 'dist/collaboration');
151
+        });
152
+        $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class);
153
+        $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class);
154
+
155
+        // notifications api to accept incoming user shares
156
+        $oldDispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) {
157
+            /** @var Listener $listener */
158
+            $listener = $this->getContainer()->query(Listener::class);
159
+            $listener->shareNotification($event);
160
+        });
161
+        $oldDispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) {
162
+            /** @var Listener $listener */
163
+            $listener = $this->getContainer()->query(Listener::class);
164
+            $listener->userAddedToGroup($event);
165
+        });
166
+    }
167
+
168
+    protected function setupSharingMenus() {
169
+        $config = \OC::$server->getConfig();
170
+
171
+        if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes' || !class_exists('\OCA\Files\App')) {
172
+            return;
173
+        }
174
+
175
+        // show_Quick_Access stored as string
176
+        \OCA\Files\App::getNavigationManager()->add(function () {
177
+            $config = \OC::$server->getConfig();
178
+            $l = \OC::$server->getL10N('files_sharing');
179
+
180
+            $sharingSublistArray = [];
181
+
182
+            if (\OCP\Util::isSharingDisabledForUser() === false) {
183
+                $sharingSublistArray[] = [
184
+                    'id' => 'sharingout',
185
+                    'appname' => 'files_sharing',
186
+                    'script' => 'list.php',
187
+                    'order' => 16,
188
+                    'name' => $l->t('Shared with others'),
189
+                ];
190
+            }
191
+
192
+            $sharingSublistArray[] = [
193
+                'id' => 'sharingin',
194
+                'appname' => 'files_sharing',
195
+                'script' => 'list.php',
196
+                'order' => 15,
197
+                'name' => $l->t('Shared with you'),
198
+            ];
199
+
200
+            if (\OCP\Util::isSharingDisabledForUser() === false) {
201
+                // Check if sharing by link is enabled
202
+                if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
203
+                    $sharingSublistArray[] = [
204
+                        'id' => 'sharinglinks',
205
+                        'appname' => 'files_sharing',
206
+                        'script' => 'list.php',
207
+                        'order' => 17,
208
+                        'name' => $l->t('Shared by link'),
209
+                    ];
210
+                }
211
+            }
212
+
213
+            $sharingSublistArray[] = [
214
+                'id' => 'deletedshares',
215
+                'appname' => 'files_sharing',
216
+                'script' => 'list.php',
217
+                'order' => 19,
218
+                'name' => $l->t('Deleted shares'),
219
+            ];
220
+
221
+            $sharingSublistArray[] = [
222
+                'id' => 'pendingshares',
223
+                'appname' => 'files_sharing',
224
+                'script' => 'list.php',
225
+                'order' => 19,
226
+                'name' => $l->t('Pending shares'),
227
+            ];
228
+
229
+            return [
230
+                'id' => 'shareoverview',
231
+                'appname' => 'files_sharing',
232
+                'script' => 'list.php',
233
+                'order' => 18,
234
+                'name' => $l->t('Shares'),
235
+                'classes' => 'collapsible',
236
+                'sublist' => $sharingSublistArray,
237
+                'expandedState' => 'show_sharing_menu'
238
+            ];
239
+        });
240
+    }
241 241
 }
Please login to merge, or discard this patch.