See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Authentication Plugin: Moodle Network Authentication 19 * Multiple host authentication support for Moodle Network. 20 * 21 * @package auth_mnet 22 * @author Martin Dougiamas 23 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 24 */ 25 26 require_once __DIR__ . '/../../config.php'; 27 require_once $CFG->dirroot . '/mnet/xmlrpc/client.php'; 28 29 // grab the GET params 30 $token = required_param('token', PARAM_BASE64); 31 $remotewwwroot = required_param('idp', PARAM_URL); 32 $wantsurl = required_param('wantsurl', PARAM_LOCALURL); 33 $wantsremoteurl = optional_param('remoteurl', false, PARAM_BOOL); 34 35 $url = new moodle_url('/auth/mnet/jump.php', array('token'=>$token, 'idp'=>$remotewwwroot, 'wantsurl'=>$wantsurl)); 36 if ($wantsremoteurl !== false) $url->param('remoteurl', $wantsremoteurl); 37 $PAGE->set_url($url); 38 $PAGE->set_context(context_system::instance()); 39 40 $site = get_site(); 41 42 if (!is_enabled_auth('mnet')) { 43 throw new \moodle_exception('mnetdisable'); 44 } 45 46 // confirm the MNET session 47 $mnetauth = get_auth_plugin('mnet'); 48 $remotepeer = new mnet_peer(); 49 $remotepeer->set_wwwroot($remotewwwroot); 50 // this creates the local user account if necessary, or updates it if it already exists 51 $localuser = $mnetauth->confirm_mnet_session($token, $remotepeer); 52 53 // log in 54 $user = get_complete_user_data('id', $localuser->id, $localuser->mnethostid); 55 complete_user_login($user); 56 // now that we've logged in, set up the mnet session properly 57 $mnetauth->update_mnet_session($user, $token, $remotepeer); 58 59 if (!empty($localuser->mnet_foreign_host_array)) { 60 $USER->mnet_foreign_host_array = $localuser->mnet_foreign_host_array; 61 } 62 63 // redirect 64 if ($wantsremoteurl) { 65 redirect($remotewwwroot . $wantsurl); 66 } 67 redirect($CFG->wwwroot . $wantsurl); 68 69
title
Description
Body
title
Description
Body
title
Description
Body
title
Body