1 | <?php |
||
2 | /* For license terms, see /license.txt */ |
||
3 | |||
4 | require_once __DIR__.'/../inc/global.inc.php'; |
||
5 | |||
6 | $token = isset($_GET['token']) ? $_GET['token'] : ''; |
||
7 | |||
8 | if (!ctype_alnum($token)) { |
||
9 | $token = ''; |
||
10 | } |
||
11 | |||
12 | /** @var \Chamilo\UserBundle\Entity\User $user */ |
||
13 | $user = UserManager::getManager()->findUserByConfirmationToken($token); |
||
14 | |||
15 | if ($user) { |
||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
16 | $user->setActive(1); // Set to 1 to activate the user |
||
17 | $user->setConfirmationToken(null); |
||
18 | |||
19 | Database::getManager()->persist($user); |
||
20 | Database::getManager()->flush(); |
||
21 | |||
22 | // See where to redirect the user to, if any redirection has been set |
||
23 | $url = api_get_path(WEB_PATH); |
||
24 | |||
25 | if (!empty($_GET['c'])) { |
||
26 | $courseCode = Security::remove_XSS($_GET['c']); |
||
27 | } |
||
28 | if (!empty($_GET['s'])) { |
||
29 | $sessionId = (int) $_GET['s']; |
||
30 | } |
||
31 | |||
32 | // Get URL to a course, to a session, or an empty string |
||
33 | $courseUrl = api_get_course_url($courseCode, $sessionId); |
||
34 | if (!empty($courseUrl)) { |
||
35 | $url = $courseUrl; |
||
36 | } |
||
37 | |||
38 | Event::addEvent( |
||
39 | LOG_USER_CONFIRMED_EMAIL, |
||
40 | LOG_USER_OBJECT, |
||
41 | api_get_user_info($user->getId()), |
||
42 | api_get_utc_datetime() |
||
43 | ); |
||
44 | |||
45 | Display::addFlash( |
||
46 | Display::return_message(get_lang('UserConfirmedNowYouCanLogInThePlatform'), 'success') |
||
47 | ); |
||
48 | header('Location: '.$url); |
||
49 | exit; |
||
50 | } else { |
||
51 | Display::addFlash( |
||
52 | Display::return_message(get_lang('LinkExpired')) |
||
53 | ); |
||
54 | header('Location: '.api_get_path(WEB_PATH)); |
||
55 | exit; |
||
56 | } |
||
57 |