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