From a99c142b474b5006076cf3e50effa1a1e16c5358 Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Mon, 4 Feb 2019 13:41:15 -0200 Subject: [PATCH] =?UTF-8?q?Parametriza=C3=A7=C3=A3o=20de=20sigla=20da=20Es?= =?UTF-8?q?cola=20Modelo=20e=20corre=C3=A7=C3=A3o=20em=20encode=20de=20URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process.php | 6 ++++-- return.php | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/process.php b/process.php index 950775d..388e37b 100644 --- a/process.php +++ b/process.php @@ -27,6 +27,8 @@ require_once("lib.php"); require_once($CFG->libdir.'/eventslib.php'); require_once($CFG->libdir.'/enrollib.php'); +global $CFG; + // Obtem ID da instância do método de inscrição $instanceid = optional_param('instanceid', 0, PARAM_INT); @@ -40,10 +42,10 @@ $urlRedirect = new moodle_url('/enrol/evl/return.php', array('id' => $courseid, // Monta url para matrícula $urlEnrol = new moodle_url('https://escolamodelows.interlegis.leg.br/cursos/registro', array( - 'school' => 'ILB', // FIXME utilizar código da escola + 'school' => $CFG->emSigla, 'school_course' => $courseid, 'key' => $USER->$idnumber, - 'redirect' => $urlRedirect + 'redirect' => $urlRedirect->out(false) // false evita codificar '&' na url de redirecionamento ) ); redirect($urlEnrol); \ No newline at end of file diff --git a/return.php b/return.php index 898da70..d911251 100644 --- a/return.php +++ b/return.php @@ -26,6 +26,8 @@ require("../../config.php"); require_once("$CFG->dirroot/enrol/evl/lib.php"); require_once("../../blocks/escola_modelo/classes/httpful.phar"); +global $DB; + // Obtém parâmetros opcionais da URL $id = optional_param('id', 0, PARAM_INT); // id do curso $instanceid = optional_param('instanceid', 0, PARAM_INT); // id da instancia do enrol @@ -57,6 +59,7 @@ if( matriculadoNaEvl($key, $course->id, 'ILB') ) { // FIXME obter código da esc $roleid = $DB->get_field('role', 'id', array('shortname' => 'student')); $enrol_plugin = enrol_get_plugin('evl'); $enrol_instance = $DB->get_record('enrol', array('id' => $instanceid)); + mtrace("INSTANCIA = " . $instanceid); $enrol_plugin->enrol_user($enrol_instance, $USER->id, $roleid); // Assegura que foi matriculado