Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

user-binding.php 896 Bytes
Newer Older
Francois Gannaz's avatar
Francois Gannaz committed
1
2
3
4
<?php

/**
 * Inner HTL page.
Francois Gannaz's avatar
Francois Gannaz committed
5
 * Bind a Moodle user to a LabNbook account.
Francois Gannaz's avatar
Francois Gannaz committed
6
7
8
9
 *
 * @copyright   2019 Université Grenoble Alpes
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
Francois Gannaz's avatar
Francois Gannaz committed
10
use mod_labnbook\fetch;
Francois Gannaz's avatar
Francois Gannaz committed
11

Francois Gannaz's avatar
Francois Gannaz committed
12
require_once \dirname(__DIR__, 2) . '/config.php';
13

Francois Gannaz's avatar
Francois Gannaz committed
14
$returnUrl = \base64_decode(required_param('return', PARAM_ALPHANUM));
15
16
17
18
19
20
21
$courseid = required_param('courseid', PARAM_INT);

$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
require_login($course);

$fetchInstitution = new fetch\institution();
$context = context_course::instance($courseid);
22
23
$isTeacher = has_capability('mod/labnbook:addinstance', $context);
$role = ($isTeacher ? 'teacher' : 'learner');
24
global $USER;
25
26
27
$url = $fetchInstitution->getRedirectUrl();
$token=$fetchInstitution->getBindingTokenForRedirect($CFG->wwwroot . $returnUrl, $role, $USER);
redirect($url."?token=".$token);