|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Controller; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Repository\Node\IllustrationRepository; |
|
10
|
|
|
use Chamilo\CoreBundle\Repository\Node\UserRepository; |
|
11
|
|
|
use CourseManager; |
|
12
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
|
13
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Symfony\Component\Routing\Attribute\Route; |
|
16
|
|
|
use Symfony\Component\Security\Core\User\UserInterface; |
|
17
|
|
|
use UserGroupModel; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @author Julio Montoya <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class UserController extends AbstractController |
|
23
|
|
|
{ |
|
24
|
|
|
#[Route(path: '/main/user/overview', name: 'overview_class', methods: ['GET'])] |
|
25
|
|
|
public function overview(Request $request): Response |
|
26
|
|
|
{ |
|
27
|
|
|
$usergroupId = $request->query->get('usergroup'); |
|
28
|
|
|
$courseId = $request->query->get('course'); |
|
29
|
|
|
|
|
30
|
|
|
$usergroupLib = new UserGroupModel(); |
|
31
|
|
|
$usergroup = $usergroupLib->get($usergroupId); |
|
32
|
|
|
|
|
33
|
|
|
$courseLib = new CourseManager(); |
|
34
|
|
|
$courseName = $courseLib->getCourseNameFromCode($courseLib->get_course_code_from_course_id($courseId)); |
|
35
|
|
|
|
|
36
|
|
|
$data = $usergroupLib->getUsersInAndOutOfCourse($usergroupId, $courseId); |
|
37
|
|
|
|
|
38
|
|
|
return $this->render('@ChamiloCore/User/overview.html.twig', [ |
|
39
|
|
|
'courseId' => $courseId, |
|
40
|
|
|
'courseName' => $courseName, |
|
41
|
|
|
'usergroupName' => $usergroup['title'], |
|
42
|
|
|
'usersSubscribedToCourse' => $data['usersSubscribedToCourse'], |
|
43
|
|
|
'usersNotSubscribedToCourse' => $data['usersNotSubscribedToCourse'], |
|
44
|
|
|
'error' => $data['error'], |
|
45
|
|
|
'warning' => $data['warning'], |
|
46
|
|
|
]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Public profile. |
|
51
|
|
|
*/ |
|
52
|
|
|
#[Route(path: '/user/{username}', name: 'chamilo_core_user_profile', methods: ['GET'])] |
|
53
|
|
|
public function profile(string $username, UserRepository $userRepository, IllustrationRepository $illustrationRepository): Response |
|
54
|
|
|
{ |
|
55
|
|
|
$user = $userRepository->findByUsername($username); |
|
56
|
|
|
|
|
57
|
|
|
if (!\is_object($user) || !$user instanceof UserInterface) { |
|
58
|
|
|
throw $this->createAccessDeniedException('This user does not have access to this section'); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
$url = $illustrationRepository->getIllustrationUrl($user); |
|
62
|
|
|
|
|
63
|
|
|
return $this->render('@ChamiloCore/User/profile.html.twig', [ |
|
64
|
|
|
'user' => $user, |
|
65
|
|
|
'illustration_url' => $url, |
|
66
|
|
|
]); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|