Verified Commit 2dd4bbd5 authored by David Beniamine's avatar David Beniamine
Browse files

Directly redirect to LNB for user binding/creation

parent b4e5eec5
......@@ -13,7 +13,6 @@ require_once \dirname(__DIR__, 2) . '/config.php';
$returnUrl = \base64_decode(required_param('return', PARAM_ALPHANUM));
$courseid = required_param('courseid', PARAM_INT);
$create = optional_param('create', false, PARAM_BOOL);
$course = $DB->get_record('course', ['id' => $courseid], '*', MUST_EXIST);
require_login($course);
......@@ -22,34 +21,7 @@ $fetchInstitution = new fetch\institution();
$context = context_course::instance($courseid);
$isTeacher = has_capability('mod/labnbook:addinstance', $context);
$role = ($isTeacher ? 'teacher' : 'learner');
/* @var $PAGE moodle_page */
global $PAGE;
global $USER;
$PAGE->set_url('/mod/labnbook/user-binding.php');
$PAGE->set_title("LabNbook");
$PAGE->set_heading("LabNbook");
$PAGE->set_context($context);
/* @var $OUTPUT moodle_core_output */
global $OUTPUT;
echo $OUTPUT->header();
?>
<p>
Vous n'avez pas de compte dans LabNbook, ou ce compte n'est pas encore connu de Moodle.
</p>
<div class="container-fluid">
<div class="row">
<div class="col" style="text-align: center">
<form action="<?= $fetchInstitution->getRedirectUrl(); ?>" method="GET">
<input type="hidden" name="token" value="<?= $fetchInstitution->getBindingTokenForRedirect($CFG->wwwroot . $returnUrl, $role, $USER); ?>" />
<button type="submit" class="btn btn-primary">Se connecter à LabNbook</button>
</form>
</div>
</div>
</div>
<?php
echo $OUTPUT->footer();
$url = $fetchInstitution->getRedirectUrl();
$token=$fetchInstitution->getBindingTokenForRedirect($CFG->wwwroot . $returnUrl, $role, $USER);
redirect($url."?token=".$token);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment