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/

Commit 9328ed06 authored by Francois Gannaz's avatar Francois Gannaz
Browse files

move requireLabnbookAuthentication() into local NS

parent 8e92e797
<?php
/**
* @package mod_labnbook
* @copyright 2019 Université Grenoble Alpes
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_labnbook\local;
class helper
{
/**
* Stop loading the current page if the current user has no LabnBook account.
* Redirects on an account binding|creation if necessary.
*
* @global \Stdclass $COURSE
* @return null
* @throws \moodle_exception
*/
public static function requireLabnbookAuthentication() {
global $COURSE;
if (fetch\user::isAuthenticated()) {
return;
}
$institutionFetcher = new fetch\institution;
switch ($institutionFetcher->loginUser()) {
case fetch\institution::OK:
return;
case fetch\institution::ERROR_LOGIN_UNKNOWN:
redirect(
"/mod/labnbook/user-binding.php?courseid={$COURSE->id}&return="
. base64_encode($_SERVER['REQUEST_URI'])
);
break;
case fetch\institution::ERROR_TOKEN_NOTVALID:
throw new \moodle_exception("Internal error with LabNbook");
default:
throw new \moodle_exception("Unknown error with LabNbook");
}
}
}
......@@ -8,15 +8,15 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
use \mod_labnbook\fetch;
use \mod_labnbook\form\select_dynamic;
use mod_labnbook\fetch;
use mod_labnbook\form\select_dynamic;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/course/moodleform_mod.php');
// short-cut before loading the form, see `course/modedit.php`
requireLabnbookAuthentication();
\mod_labnbook\local\helper::requireLabnbookAuthentication();
define('TEAMCONFIG_METHOD_STUDENTS', 1);
define('TEAMCONFIG_METHOD_RANDOM', 3);
......@@ -187,32 +187,3 @@ EOJS
}
}
}
/**
* Stop loading the form if the current user has no LabnBook account.
*
* @global \Stdclass $COURSE
* @return null
* @throws \moodle_exception
*/
function requireLabnbookAuthentication() {
global $COURSE;
if (fetch\user::isAuthenticated()) {
return;
}
$institutionFetcher = new fetch\institution;
switch ($institutionFetcher->loginUser()) {
case fetch\institution::OK:
return;
case fetch\institution::ERROR_LOGIN_UNKNOWN:
redirect(
"/mod/labnbook/user-binding.php?courseid={$COURSE->id}&return="
. base64_encode($_SERVER['REQUEST_URI'])
);
break;
case fetch\institution::ERROR_TOKEN_NOTVALID:
throw new \moodle_exception("Internal error with LabNbook");
default:
throw new \moodle_exception("Unknown error with LabNbook");
}
}
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