Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
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 28 // grab the GET params - wantsurl could be anything - take it 29 // with PARAM_RAW 30 $hostid = optional_param('hostid', '0', PARAM_INT); 31 $hostwwwroot = optional_param('hostwwwroot', '', PARAM_URL); 32 $wantsurl = optional_param('wantsurl', '', PARAM_RAW); 33 34 $url = new moodle_url('/auth/mnet/jump.php'); 35 if ($hostid !== '0') $url->param('hostid', $hostid); 36 if ($hostwwwroot !== '') $url->param('hostwwwroot', $hostwwwroot); 37 if ($wantsurl !== '') $url->param('wantsurl', $wantsurl); 38 $PAGE->set_url($url); 39 40 if (!isloggedin() or isguestuser()) { 41 $SESSION->wantsurl = $PAGE->url->out(false); 42 redirect(get_login_url()); 43 } 44 45 if (!is_enabled_auth('mnet')) { 46 print_error('mnetdisable'); 47 } 48 49 // If hostid hasn't been specified, try getting it using wwwroot 50 if (!$hostid) { 51 $hostwwwroot = trim($hostwwwroot); 52 $hostwwwroot = rtrim($hostwwwroot, '/'); 53 54 // ensure the wwwroot starts with a http or https prefix 55 if (strtolower(substr($hostwwwroot, 0, 4)) != 'http') { 56 $hostwwwroot = 'http://'.$hostwwwroot; 57 } 58 $hostid = $DB->get_field('mnet_host', 'id', array('wwwroot' => $hostwwwroot)); 59 } 60 61 // start the mnet session and redirect browser to remote URL 62 $mnetauth = get_auth_plugin('mnet'); 63 $url = $mnetauth->start_jump_session($hostid, $wantsurl); 64 65 if (empty($url)) { 66 print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors 67 } 68 redirect($url); 69 70
title
Description
Body
title
Description
Body
title
Description
Body
title
Body