@@ -140,7 +140,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
140
140
$ aclManager = $ this ->aclManagerFactory ->getACLManager ($ user , $ this ->getRootStorageId ());
141
141
$ rootRules = $ aclManager ->getRelevantRulesForPath ($ aclRootPaths );
142
142
143
- return array_values ( array_filter (array_map (function ($ folder ) use ($ user , $ loader , $ conflicts , $ aclManager , $ rootRules ) {
143
+ return array_merge (... array_filter (array_map (function (array $ folder ) use ($ user , $ loader , $ conflicts , $ aclManager , $ rootRules ): ? array {
144
144
// check for existing files in the user home and rename them if needed
145
145
$ originalFolderName = $ folder ['mount_point ' ];
146
146
if (in_array ($ originalFolderName , $ conflicts )) {
@@ -159,7 +159,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
159
159
$ userStorage ->getPropagator ()->propagateChange ("files/ $ folderName " , time ());
160
160
}
161
161
162
- return $ this ->getMount (
162
+ $ mount = $ this ->getMount (
163
163
$ folder ['folder_id ' ],
164
164
'/ ' . $ user ->getUID () . '/files/ ' . $ folder ['mount_point ' ],
165
165
$ folder ['permissions ' ],
@@ -171,6 +171,22 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
171
171
$ aclManager ,
172
172
$ rootRules
173
173
);
174
+ if (!$ mount ) {
175
+ return null ;
176
+ }
177
+ $ trashMount = $ this ->getTrashMount (
178
+ $ folder ['folder_id ' ],
179
+ '/ ' . $ user ->getUID () . '/files_trashbin/groupfolders/ ' . $ folder ['folder_id ' ],
180
+ $ folder ['quota ' ],
181
+ $ loader ,
182
+ $ user
183
+ );
184
+
185
+ return [
186
+ $ mount ,
187
+ $ trashMount ,
188
+ ];
189
+
174
190
}, $ folders )));
175
191
}
176
192
@@ -193,16 +209,16 @@ private function getCurrentUID(): ?string {
193
209
}
194
210
195
211
public function getMount (
196
- int $ id ,
197
- string $ mountPoint ,
198
- int $ permissions ,
199
- int $ quota ,
200
- ?ICacheEntry $ cacheEntry = null ,
212
+ int $ id ,
213
+ string $ mountPoint ,
214
+ int $ permissions ,
215
+ int $ quota ,
216
+ ?ICacheEntry $ cacheEntry = null ,
201
217
?IStorageFactory $ loader = null ,
202
- bool $ acl = false ,
203
- ?IUser $ user = null ,
204
- ?ACLManager $ aclManager = null ,
205
- array $ rootRules = []
218
+ bool $ acl = false ,
219
+ ?IUser $ user = null ,
220
+ ?ACLManager $ aclManager = null ,
221
+ array $ rootRules = []
206
222
): ?IMountPoint {
207
223
if (!$ cacheEntry ) {
208
224
// trigger folder creation
@@ -230,52 +246,91 @@ public function getMount(
230
246
$ cacheEntry ['permissions ' ] &= $ aclRootPermissions ;
231
247
}
232
248
249
+ $ quotaStorage = $ this ->getGroupFolderStorage ($ id , $ storage , $ user , $ rootPath , $ quota , $ cacheEntry );
250
+
251
+ $ maskedStore = new PermissionsMask ([
252
+ 'storage ' => $ quotaStorage ,
253
+ 'mask ' => $ permissions ,
254
+ ]);
255
+
256
+ if (!$ this ->allowRootShare ) {
257
+ $ maskedStore = new RootPermissionsMask ([
258
+ 'storage ' => $ maskedStore ,
259
+ 'mask ' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE ,
260
+ ]);
261
+ }
262
+
263
+ return new GroupMountPoint (
264
+ $ id ,
265
+ $ maskedStore ,
266
+ $ mountPoint ,
267
+ null ,
268
+ $ loader
269
+ );
270
+ }
271
+
272
+ public function getTrashMount (
273
+ int $ id ,
274
+ string $ mountPoint ,
275
+ int $ quota ,
276
+ IStorageFactory $ loader ,
277
+ IUser $ user ,
278
+ ): IMountPoint {
279
+
280
+ $ storage = $ this ->getRootFolder ()->getStorage ();
281
+
282
+ $ storage ->setOwner ($ user ->getUID ());
283
+
284
+ $ trashPath = $ this ->getRootFolder ()->getInternalPath () . '/trash/ ' . $ id ;
285
+
286
+ $ trashStorage = $ this ->getGroupFolderStorage ($ id , $ storage , $ user , $ trashPath , $ quota , null );
287
+
288
+ return new GroupMountPoint (
289
+ $ id ,
290
+ $ trashStorage ,
291
+ $ mountPoint ,
292
+ null ,
293
+ $ loader
294
+ );
295
+ }
296
+
297
+ public function getGroupFolderStorage (
298
+ int $ id ,
299
+ IStorage $ rootStorage ,
300
+ ?IUser $ user ,
301
+ string $ rootPath ,
302
+ int $ quota ,
303
+ ?ICacheEntry $ rootCacheEntry ,
304
+ ): IStorage {
233
305
if ($ this ->enableEncryption ) {
234
306
$ baseStorage = new GroupFolderEncryptionJail ([
235
- 'storage ' => $ storage ,
236
- 'root ' => $ rootPath
307
+ 'storage ' => $ rootStorage ,
308
+ 'root ' => $ rootPath,
237
309
]);
238
310
$ quotaStorage = new GroupFolderStorage ([
239
311
'storage ' => $ baseStorage ,
240
312
'quota ' => $ quota ,
241
313
'folder_id ' => $ id ,
242
- 'rootCacheEntry ' => $ cacheEntry ,
314
+ 'rootCacheEntry ' => $ rootCacheEntry ,
243
315
'userSession ' => $ this ->userSession ,
244
316
'mountOwner ' => $ user ,
245
317
]);
246
318
} else {
247
319
$ baseStorage = new Jail ([
248
- 'storage ' => $ storage ,
249
- 'root ' => $ rootPath
320
+ 'storage ' => $ rootStorage ,
321
+ 'root ' => $ rootPath,
250
322
]);
251
323
$ quotaStorage = new GroupFolderNoEncryptionStorage ([
252
324
'storage ' => $ baseStorage ,
253
325
'quota ' => $ quota ,
254
326
'folder_id ' => $ id ,
255
- 'rootCacheEntry ' => $ cacheEntry ,
327
+ 'rootCacheEntry ' => $ rootCacheEntry ,
256
328
'userSession ' => $ this ->userSession ,
257
329
'mountOwner ' => $ user ,
258
330
]);
259
331
}
260
- $ maskedStore = new PermissionsMask ([
261
- 'storage ' => $ quotaStorage ,
262
- 'mask ' => $ permissions
263
- ]);
264
-
265
- if (!$ this ->allowRootShare ) {
266
- $ maskedStore = new RootPermissionsMask ([
267
- 'storage ' => $ maskedStore ,
268
- 'mask ' => Constants::PERMISSION_ALL - Constants::PERMISSION_SHARE ,
269
- ]);
270
- }
271
332
272
- return new GroupMountPoint (
273
- $ id ,
274
- $ maskedStore ,
275
- $ mountPoint ,
276
- null ,
277
- $ loader
278
- );
333
+ return $ quotaStorage ;
279
334
}
280
335
281
336
public function getJailPath (int $ folderId ): string {
0 commit comments