@@ -93,11 +93,10 @@ public function listFilesInfo(Request $request, ResourceFileRepository $resource
93
93
#[IsGranted('ROLE_ADMIN ' )]
94
94
#[Route('/resources_info ' , name: 'admin_resources_info ' , methods: ['GET ' ])]
95
95
public function listResourcesInfo (
96
- Request $ request ,
96
+ Request $ request ,
97
97
ResourceNodeRepository $ resourceNodeRepo ,
98
98
EntityManagerInterface $ em
99
- ): Response
100
- {
99
+ ): Response {
101
100
$ resourceTypeId = $ request ->query ->getInt ('type ' );
102
101
$ resourceTypes = $ em ->getRepository (ResourceType::class)->findAll ();
103
102
@@ -117,7 +116,8 @@ public function listResourcesInfo(
117
116
->where ('rn.resourceType = :type ' )
118
117
->setParameter ('type ' , $ resourceTypeId )
119
118
->getQuery ()
120
- ->getResult ();
119
+ ->getResult ()
120
+ ;
121
121
122
122
/** Aggregate by course/session key */
123
123
$ seen = [];
@@ -140,10 +140,10 @@ public function listResourcesInfo(
140
140
'id ' => $ sid ?: $ cid ,
141
141
'courseId ' => $ cid ,
142
142
'sessionId ' => $ sid ,
143
- 'title ' => $ sid ? ($ session ->getTitle () . ' - ' . $ course ->getTitle ()) : $ course ->getTitle (),
143
+ 'title ' => $ sid ? ($ session ->getTitle (). ' - ' . $ course ->getTitle ()) : $ course ->getTitle (),
144
144
'url ' => $ sid
145
- ? '/course/ ' . $ cid . '/home?sid= ' . $ sid
146
- : '/course/ ' . $ cid . '/home ' ,
145
+ ? '/course/ ' . $ cid. '/home?sid= ' . $ sid
146
+ : '/course/ ' . $ cid. '/home ' ,
147
147
'count ' => 0 ,
148
148
'items ' => [],
149
149
'users ' => [],
@@ -160,7 +160,7 @@ public function listResourcesInfo(
160
160
}
161
161
}
162
162
163
- /** Populate users depending on the resource type */
163
+ /* Populate users depending on the resource type */
164
164
if (!empty ($ seen )) {
165
165
$ usersMap = $ this ->fetchUsersForType ($ typeTitle , $ em , $ keysMeta );
166
166
foreach ($ usersMap as $ key => $ names ) {
@@ -169,16 +169,17 @@ public function listResourcesInfo(
169
169
}
170
170
}
171
171
// Show the "Users" column only if there's any user to display
172
- $ showUsers = array_reduce ($ seen , fn ($ acc , $ row ) => $ acc || !empty ($ row ['users ' ]), false );
172
+ $ showUsers = array_reduce ($ seen , fn ($ acc , $ row ) => $ acc || !empty ($ row ['users ' ]), false );
173
173
}
174
174
175
175
/** Normalize output */
176
176
$ courses = array_values (array_map (function ($ row ) {
177
177
$ row ['items ' ] = array_values (array_unique ($ row ['items ' ]));
178
+
178
179
return $ row ;
179
180
}, $ seen ));
180
181
181
- usort ($ courses , fn ($ a , $ b ) => strnatcasecmp ($ a ['title ' ], $ b ['title ' ]));
182
+ usort ($ courses , fn ($ a , $ b ) => strnatcasecmp ($ a ['title ' ], $ b ['title ' ]));
182
183
}
183
184
184
185
return $ this ->render ('@ChamiloCore/Admin/resources_info.html.twig ' , [
@@ -312,11 +313,12 @@ public function runCleanupTempUploads(
312
313
* Returns a map key => [user names...] depending on the selected resource type.
313
314
*
314
315
* @param array<string,array{cid:int,sid:int}> $keysMeta
316
+ *
315
317
* @return array<string,string[]>
316
318
*/
317
319
private function fetchUsersForType (?string $ typeTitle , EntityManagerInterface $ em , array $ keysMeta ): array
318
320
{
319
- $ type = is_string ($ typeTitle ) ? strtolower ($ typeTitle ) : '' ;
321
+ $ type = \ is_string ($ typeTitle ) ? strtolower ($ typeTitle ) : '' ;
320
322
321
323
return match ($ type ) {
322
324
'dropbox ' => $ this ->fetchDropboxRecipients ($ em , $ keysMeta ),
@@ -329,6 +331,7 @@ private function fetchUsersForType(?string $typeTitle, EntityManagerInterface $e
329
331
* Default behavior: list users tied to ResourceLink.user (user-scoped visibility).
330
332
*
331
333
* @param array<string,array{cid:int,sid:int}> $keysMeta
334
+ *
332
335
* @return array<string,string[]>
333
336
*/
334
337
private function fetchUsersFromResourceLinks (EntityManagerInterface $ em , array $ keysMeta ): array
@@ -346,6 +349,7 @@ private function fetchUsersFromResourceLinks(EntityManagerInterface $em, array $
346
349
LEFT JOIN rl.user u
347
350
WHERE rl.user IS NOT NULL '
348
351
);
352
+
349
353
/** @var ResourceLink[] $links */
350
354
$ links = $ q ->getResult ();
351
355
@@ -370,13 +374,15 @@ private function fetchUsersFromResourceLinks(EntityManagerInterface $em, array $
370
374
foreach ($ out as $ k => $ arr ) {
371
375
$ out [$ k ] = array_values (array_unique (array_filter ($ arr )));
372
376
}
377
+
373
378
return $ out ;
374
379
}
375
380
376
381
/**
377
382
* Dropbox-specific: list real recipients from c_dropbox_person (joined with c_dropbox_file and user).
378
383
*
379
384
* @param array<string,array{cid:int,sid:int}> $keysMeta
385
+ *
380
386
* @return array<string,string[]>
381
387
*/
382
388
private function fetchDropboxRecipients (EntityManagerInterface $ em , array $ keysMeta ): array
@@ -385,7 +391,7 @@ private function fetchDropboxRecipients(EntityManagerInterface $em, array $keysM
385
391
return [];
386
392
}
387
393
388
- $ cids = array_values (array_unique (array_map (fn ($ m ) => (int ) $ m ['cid ' ], $ keysMeta )));
394
+ $ cids = array_values (array_unique (array_map (fn ($ m ) => (int ) $ m ['cid ' ], $ keysMeta )));
389
395
if (!$ cids ) {
390
396
return [];
391
397
}
@@ -415,20 +421,23 @@ private function fetchDropboxRecipients(EntityManagerInterface $em, array $keysM
415
421
continue ; // ignore entries not displayed in the table
416
422
}
417
423
$ uname = trim ((string ) ($ r ['uname ' ] ?? '' ));
418
- if ($ uname !== '' ) {
424
+ if ('' !== $ uname ) {
419
425
$ out [$ key ][] = $ uname ;
420
426
}
421
427
}
422
428
// Dedupe
423
429
foreach ($ out as $ k => $ arr ) {
424
430
$ out [$ k ] = array_values (array_unique (array_filter ($ arr )));
425
431
}
432
+
426
433
return $ out ;
427
434
}
428
435
429
- /** Helper to build the aggregation key for course/session rows. */
436
+ /**
437
+ * Helper to build the aggregation key for course/session rows.
438
+ */
430
439
private static function makeKey (int $ cid , int $ sid ): string
431
440
{
432
- return $ sid > 0 ? ('s ' . $ sid . '- ' . $ cid ) : ('c ' . $ cid );
441
+ return $ sid > 0 ? ('s ' . $ sid. '- ' . $ cid ) : ('c ' . $ cid );
433
442
}
434
443
}
0 commit comments