NOBUG: Fixed SVG browser compatibility
[moodle.git] / login / logout.php
blob664b179aa95462adf22e3a6e8c4f99e82d0fb340
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Logs the user out and sends them to the home page
21 * @package core
22 * @subpackage auth
23 * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require_once('../config.php');
29 $PAGE->set_url('/login/logout.php');
30 $PAGE->set_context(context_system::instance());
32 $sesskey = optional_param('sesskey', '__notpresent__', PARAM_RAW); // we want not null default to prevent required sesskey warning
33 $login = optional_param('loginpage', 0, PARAM_BOOL);
35 // can be overridden by auth plugins
36 if ($login) {
37 $redirect = get_login_url();
38 } else {
39 $redirect = $CFG->wwwroot.'/';
42 if (!isloggedin()) {
43 // no confirmation, user has already logged out
44 require_logout();
45 redirect($redirect);
47 } else if (!confirm_sesskey($sesskey)) {
48 $PAGE->set_title($SITE->fullname);
49 $PAGE->set_heading($SITE->fullname);
50 echo $OUTPUT->header();
51 echo $OUTPUT->confirm(get_string('logoutconfirm'), new moodle_url($PAGE->url, array('sesskey'=>sesskey())), $CFG->wwwroot.'/');
52 echo $OUTPUT->footer();
53 die;
56 $authsequence = get_enabled_auth_plugins(); // auths, in sequence
57 foreach($authsequence as $authname) {
58 $authplugin = get_auth_plugin($authname);
59 $authplugin->logoutpage_hook();
62 require_logout();
64 redirect($redirect);